sandcovery 0.1.0 → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +91 -0
- package/dist/Schema-C4ay0Aif.mjs +11473 -0
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.mjs +1710 -0
- package/dist/handlers-BxhSLDGk.mjs +2217 -0
- package/dist/index.d.mts +76 -1
- package/dist/index.mjs +1 -5
- package/dist/origin-Dj-n4EQa.mjs +356 -0
- package/dist/posthog-project-B0jmQTwy.mjs +1 -0
- package/dist/posthog-project-Bb0IFKUv.mjs +20 -0
- package/dist/spec-ClAX0dAN.mjs +1910 -0
- package/dist/src-D3WZodpF.mjs +572 -0
- package/dist/telemetry-BYnuVdoZ.mjs +43 -0
- package/dist/telemetry-delivery-1a7C-8DK.mjs +8712 -0
- package/dist/types-Dxh7amZB.d.mts +345 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +51 -0
- package/package.json +46 -4
|
@@ -0,0 +1,1910 @@
|
|
|
1
|
+
import { M as TaggedError } from "./Schema-C4ay0Aif.mjs";
|
|
2
|
+
import { _ as SandboxStatus, b as ProviderSort, c as SpendLimit, o as KeyKind } from "./origin-Dj-n4EQa.mjs";
|
|
3
|
+
// ../cli-core/src/canceled.ts
|
|
4
|
+
var Canceled = class extends TaggedError("Canceled") {};
|
|
5
|
+
// ../cli-core/src/failure.ts
|
|
6
|
+
const classExitCodes = {
|
|
7
|
+
authentication: 1,
|
|
8
|
+
bug: 1,
|
|
9
|
+
config: 1,
|
|
10
|
+
conflict: 1,
|
|
11
|
+
limit: 1,
|
|
12
|
+
missing_input: 2,
|
|
13
|
+
network: 1,
|
|
14
|
+
not_found: 1,
|
|
15
|
+
permission: 1,
|
|
16
|
+
platform: 1,
|
|
17
|
+
rate_limit: 1,
|
|
18
|
+
unknown_outcome: 1,
|
|
19
|
+
usage: 2
|
|
20
|
+
};
|
|
21
|
+
const blockedClasses = /* @__PURE__ */ new Set([
|
|
22
|
+
"authentication",
|
|
23
|
+
"limit",
|
|
24
|
+
"missing_input",
|
|
25
|
+
"permission",
|
|
26
|
+
"usage"
|
|
27
|
+
]);
|
|
28
|
+
const reasons = {
|
|
29
|
+
agreement_not_accepted: "conflict",
|
|
30
|
+
api_error: "platform",
|
|
31
|
+
campaign_funding_active: "conflict",
|
|
32
|
+
campaign_match_delivered: "conflict",
|
|
33
|
+
campaign_request_denied: "conflict",
|
|
34
|
+
campaign_status_locked: "conflict",
|
|
35
|
+
concurrency_limit_reached: "limit",
|
|
36
|
+
confirmation_required: "missing_input",
|
|
37
|
+
conflict: "conflict",
|
|
38
|
+
contract_locked: "conflict",
|
|
39
|
+
internal_error: "bug",
|
|
40
|
+
invalid_arguments: "usage",
|
|
41
|
+
invalid_config: "config",
|
|
42
|
+
login_locked: "conflict",
|
|
43
|
+
login_required: "authentication",
|
|
44
|
+
market_information_locked: "conflict",
|
|
45
|
+
missing_command: "usage",
|
|
46
|
+
missing_key: "missing_input",
|
|
47
|
+
missing_path: "missing_input",
|
|
48
|
+
missing_port: "missing_input",
|
|
49
|
+
missing_provider: "missing_input",
|
|
50
|
+
missing_query: "missing_input",
|
|
51
|
+
missing_run: "missing_input",
|
|
52
|
+
missing_sandbox: "missing_input",
|
|
53
|
+
missing_site: "missing_input",
|
|
54
|
+
missing_value: "missing_input",
|
|
55
|
+
mode_not_entitled: "conflict",
|
|
56
|
+
network_error: "network",
|
|
57
|
+
no_contact: "not_found",
|
|
58
|
+
no_provider_available: "platform",
|
|
59
|
+
not_found: "not_found",
|
|
60
|
+
out_of_credits: "limit",
|
|
61
|
+
permission_denied: "permission",
|
|
62
|
+
provider_error: "platform",
|
|
63
|
+
rate_limited: "rate_limit",
|
|
64
|
+
redirected: "network",
|
|
65
|
+
site_unverified: "conflict",
|
|
66
|
+
spawn_failed: "platform",
|
|
67
|
+
spend_limit_reached: "limit",
|
|
68
|
+
stale_login: "conflict",
|
|
69
|
+
subscription_required: "limit",
|
|
70
|
+
token_expired: "authentication",
|
|
71
|
+
token_scope_required: "permission",
|
|
72
|
+
tool_refused: "conflict",
|
|
73
|
+
turn_failed: "platform",
|
|
74
|
+
unknown_command: "usage",
|
|
75
|
+
unknown_option: "usage",
|
|
76
|
+
unknown_outcome: "unknown_outcome",
|
|
77
|
+
unsupported: "conflict"
|
|
78
|
+
};
|
|
79
|
+
var CliFailure = class extends TaggedError("CliFailure") {};
|
|
80
|
+
const exitCodeOf = (reason) => classExitCodes[reasons[reason]];
|
|
81
|
+
const statusOf = ({ blocked, reason }) => blocked === true || blockedClasses.has(reasons[reason]) ? "action_required" : "error";
|
|
82
|
+
const usageFailure = ({ help, issues, message, reason = "invalid_arguments" }) => new CliFailure({
|
|
83
|
+
issues,
|
|
84
|
+
message,
|
|
85
|
+
reason,
|
|
86
|
+
recovery: [{
|
|
87
|
+
instruction: "See all options",
|
|
88
|
+
next: { argv: [...help, "--help"] }
|
|
89
|
+
}]
|
|
90
|
+
});
|
|
91
|
+
// ../cli-core/src/characters.ts
|
|
92
|
+
const between = (character, low, high) => character.length === 1 && character >= low && character <= high;
|
|
93
|
+
const isDigit = (character) => between(character, "0", "9");
|
|
94
|
+
const isUpper = (character) => between(character, "A", "Z");
|
|
95
|
+
const isWordCharacter = (character) => isDigit(character) || isUpper(character) || between(character, "a", "z") || character === "_";
|
|
96
|
+
const consistsOf = (text, allowed) => text !== "" && text.split("").every(allowed);
|
|
97
|
+
const isDigits = (text) => consistsOf(text, isDigit);
|
|
98
|
+
const codePoints = (text) => Array.from(text, (point) => point);
|
|
99
|
+
// ../cli-core/src/sanitize.ts
|
|
100
|
+
const ESC = 27;
|
|
101
|
+
const BEL = 7;
|
|
102
|
+
const TAB = 9;
|
|
103
|
+
const LINE_FEED = 10;
|
|
104
|
+
const CARRIAGE_RETURN = 13;
|
|
105
|
+
const DELETE = 127;
|
|
106
|
+
const C1_END = 159;
|
|
107
|
+
const SPACE = 32;
|
|
108
|
+
const CSI_FINAL_START = 64;
|
|
109
|
+
const CSI_FINAL_END = 126;
|
|
110
|
+
const C1_CSI = 155;
|
|
111
|
+
const C1_OSC = 157;
|
|
112
|
+
const C1_ST = 156;
|
|
113
|
+
const stringIntroducers = /* @__PURE__ */ new Set([
|
|
114
|
+
"P",
|
|
115
|
+
"X",
|
|
116
|
+
"^",
|
|
117
|
+
"_"
|
|
118
|
+
]);
|
|
119
|
+
const c1StringIntroducers = /* @__PURE__ */ new Set([
|
|
120
|
+
144,
|
|
121
|
+
152,
|
|
122
|
+
158,
|
|
123
|
+
159
|
|
124
|
+
]);
|
|
125
|
+
const formatRanges = [
|
|
126
|
+
[1564, 1564],
|
|
127
|
+
[8203, 8207],
|
|
128
|
+
[8234, 8238],
|
|
129
|
+
[8288, 8303],
|
|
130
|
+
[65279, 65279]
|
|
131
|
+
];
|
|
132
|
+
const isFormatCharacter = (point) => formatRanges.some(([low, high]) => point >= low && point <= high);
|
|
133
|
+
const keptControls = /* @__PURE__ */ new Set([
|
|
134
|
+
TAB,
|
|
135
|
+
LINE_FEED,
|
|
136
|
+
CARRIAGE_RETURN
|
|
137
|
+
]);
|
|
138
|
+
const isC0Control = (point) => point < SPACE && !keptControls.has(point);
|
|
139
|
+
const isC1Control = (point) => point >= DELETE && point <= C1_END;
|
|
140
|
+
const isStrippedControl = (point) => isC0Control(point) || isC1Control(point);
|
|
141
|
+
const pointAt = (characters, index) => characters[index]?.codePointAt(0) ?? -1;
|
|
142
|
+
const skipControlSequence = (characters, start) => {
|
|
143
|
+
let index = start;
|
|
144
|
+
while (index < characters.length) {
|
|
145
|
+
const point = pointAt(characters, index);
|
|
146
|
+
if (point >= CSI_FINAL_START && point <= CSI_FINAL_END) return index + 1;
|
|
147
|
+
index += 1;
|
|
148
|
+
}
|
|
149
|
+
return index;
|
|
150
|
+
};
|
|
151
|
+
const skipUntilTerminator = (characters, start, { bell }) => {
|
|
152
|
+
let index = start;
|
|
153
|
+
while (index < characters.length) {
|
|
154
|
+
const point = pointAt(characters, index);
|
|
155
|
+
if (bell && point === BEL || point === C1_ST) return index + 1;
|
|
156
|
+
if (point === ESC && characters[index + 1] === "\\") return index + 2;
|
|
157
|
+
index += 1;
|
|
158
|
+
}
|
|
159
|
+
return index;
|
|
160
|
+
};
|
|
161
|
+
const skipEscape = (characters, start) => {
|
|
162
|
+
const introducer = characters[start + 1];
|
|
163
|
+
if (introducer === "[") return skipControlSequence(characters, start + 2);
|
|
164
|
+
if (introducer === "]") return skipUntilTerminator(characters, start + 2, { bell: true });
|
|
165
|
+
if (introducer !== void 0 && stringIntroducers.has(introducer)) return skipUntilTerminator(characters, start + 2, { bell: false });
|
|
166
|
+
return Math.min(start + 2, characters.length);
|
|
167
|
+
};
|
|
168
|
+
const skipC1 = (characters, start, point) => {
|
|
169
|
+
if (point === C1_CSI) return skipControlSequence(characters, start + 1);
|
|
170
|
+
if (point === C1_OSC) return skipUntilTerminator(characters, start + 1, { bell: true });
|
|
171
|
+
return c1StringIntroducers.has(point) ? skipUntilTerminator(characters, start + 1, { bell: false }) : start + 1;
|
|
172
|
+
};
|
|
173
|
+
const escapedPoint = (point) => point > 255 ? `\\u{${point.toString(16)}}` : `\\x${point.toString(16).padStart(2, "0")}`;
|
|
174
|
+
const escapeUnprintable = (text) => codePoints(text).map((character) => {
|
|
175
|
+
const point = character.codePointAt(0) ?? 0;
|
|
176
|
+
return isStrippedControl(point) || isFormatCharacter(point) ? escapedPoint(point) : character;
|
|
177
|
+
}).join("");
|
|
178
|
+
const remoteText = (text) => {
|
|
179
|
+
const characters = codePoints(text);
|
|
180
|
+
const kept = [];
|
|
181
|
+
let index = 0;
|
|
182
|
+
while (index < characters.length) {
|
|
183
|
+
const point = pointAt(characters, index);
|
|
184
|
+
if (point === ESC) index = skipEscape(characters, index);
|
|
185
|
+
else if (isC1Control(point)) index = skipC1(characters, index, point);
|
|
186
|
+
else {
|
|
187
|
+
if (!isStrippedControl(point) && !isFormatCharacter(point)) kept.push(characters[index] ?? "");
|
|
188
|
+
index += 1;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return kept.join("");
|
|
192
|
+
};
|
|
193
|
+
const remoteLine = (text) => remoteText(text).replaceAll("\r\n", "\\n").replaceAll("\n", "\\n").replaceAll("\r", "\\r");
|
|
194
|
+
const remoteCell = ({ separated, text }) => {
|
|
195
|
+
const tab = separated ? "\\t" : " ";
|
|
196
|
+
return remoteLine(text).replaceAll(" ", () => tab);
|
|
197
|
+
};
|
|
198
|
+
// ../cli-core/src/theme.ts
|
|
199
|
+
const weights = {
|
|
200
|
+
bold: [1, 22],
|
|
201
|
+
faint: [2, 22],
|
|
202
|
+
underline: [4, 24]
|
|
203
|
+
};
|
|
204
|
+
const hues = {
|
|
205
|
+
cyan: [36, 39],
|
|
206
|
+
green: [32, 39],
|
|
207
|
+
magenta: [35, 39],
|
|
208
|
+
red: [31, 39],
|
|
209
|
+
yellow: [33, 39]
|
|
210
|
+
};
|
|
211
|
+
const wrap = ([open, close], text) => `\u001B[${String(open)}m${text}\u001B[${String(close)}m`;
|
|
212
|
+
const weighted = (style, weight, text) => style.rich && style.color ? wrap(weights[weight], text) : text;
|
|
213
|
+
const tinted = (style, hue, text) => style.rich && style.color ? wrap(hues[hue], text) : text;
|
|
214
|
+
const richGlyphs = {
|
|
215
|
+
error: "✗",
|
|
216
|
+
success: "✓",
|
|
217
|
+
warning: "!"
|
|
218
|
+
};
|
|
219
|
+
const glyphHues = {
|
|
220
|
+
error: "red",
|
|
221
|
+
success: "green",
|
|
222
|
+
warning: "yellow"
|
|
223
|
+
};
|
|
224
|
+
const glyph = (style, kind) => tinted(style, glyphHues[kind], richGlyphs[kind]);
|
|
225
|
+
const plainPrefixes = {
|
|
226
|
+
error: "Error:",
|
|
227
|
+
warning: "Warning:"
|
|
228
|
+
};
|
|
229
|
+
const plainPrefix = (style, kind) => style.color ? wrap(hues[glyphHues[kind]], plainPrefixes[kind]) : plainPrefixes[kind];
|
|
230
|
+
const ellipsis = (style) => style.rich ? "…" : "...";
|
|
231
|
+
const theme = {
|
|
232
|
+
command: (style, text) => tinted(style, "cyan", text),
|
|
233
|
+
heading: (style, text) => style.rich && style.color ? wrap(weights.bold, wrap(hues.magenta, text)) : text,
|
|
234
|
+
link: (style, text) => weighted(style, "underline", text),
|
|
235
|
+
name: (style, text) => weighted(style, "bold", text),
|
|
236
|
+
optional: (style, text) => weighted(style, "faint", text),
|
|
237
|
+
outcome: (style, text) => weighted(style, "bold", text)
|
|
238
|
+
};
|
|
239
|
+
const SPINNER_FRAMES = [
|
|
240
|
+
"⠋",
|
|
241
|
+
"⠙",
|
|
242
|
+
"⠹",
|
|
243
|
+
"⠸",
|
|
244
|
+
"⠼",
|
|
245
|
+
"⠴",
|
|
246
|
+
"⠦",
|
|
247
|
+
"⠧",
|
|
248
|
+
"⠇",
|
|
249
|
+
"⠏"
|
|
250
|
+
];
|
|
251
|
+
const spinnerFrame = (tick) => SPINNER_FRAMES[tick % SPINNER_FRAMES.length] ?? "";
|
|
252
|
+
const clearLine = "\r\x1B[2K";
|
|
253
|
+
// ../cli-core/src/parse.ts
|
|
254
|
+
const distance = (left, right) => {
|
|
255
|
+
const rightCharacters = codePoints(right);
|
|
256
|
+
const previous = Array.from({ length: rightCharacters.length + 1 }, (_, index) => index);
|
|
257
|
+
for (const [row, leftCharacter] of codePoints(left).entries()) {
|
|
258
|
+
let diagonal = previous[0] ?? 0;
|
|
259
|
+
previous[0] = row + 1;
|
|
260
|
+
for (const [column, rightCharacter] of rightCharacters.entries()) {
|
|
261
|
+
const above = previous[column + 1] ?? 0;
|
|
262
|
+
const before = previous[column] ?? 0;
|
|
263
|
+
previous[column + 1] = Math.min(above + 1, before + 1, diagonal + (leftCharacter === rightCharacter ? 0 : 1));
|
|
264
|
+
diagonal = above;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return previous[rightCharacters.length] ?? 0;
|
|
268
|
+
};
|
|
269
|
+
const closest = ({ candidates, token }) => {
|
|
270
|
+
const limit = Math.max(1, Math.floor(token.length / 3));
|
|
271
|
+
const [best, runnerUp] = candidates.flatMap((candidate) => {
|
|
272
|
+
const score = distance(token, candidate);
|
|
273
|
+
return score <= limit ? [{
|
|
274
|
+
candidate,
|
|
275
|
+
score
|
|
276
|
+
}] : [];
|
|
277
|
+
}).toSorted((left, right) => left.score - right.score);
|
|
278
|
+
if (best === void 0 || runnerUp !== void 0 && runnerUp.score === best.score) return;
|
|
279
|
+
return best.candidate;
|
|
280
|
+
};
|
|
281
|
+
const findOption = ({ name, options }) => options.find((option) => option.name === name);
|
|
282
|
+
const gluedValue = ({ head, shorts }) => {
|
|
283
|
+
const flags = [];
|
|
284
|
+
for (const character of head.slice(1, -1)) {
|
|
285
|
+
const option = shorts.get(character);
|
|
286
|
+
if (option === void 0) return;
|
|
287
|
+
flags.push(character);
|
|
288
|
+
if (option.kind === "value") {
|
|
289
|
+
const hint = option.hint ?? "<VALUE>";
|
|
290
|
+
return {
|
|
291
|
+
separated: [...flags.map((flag) => `-${flag}`), hint].join(" "),
|
|
292
|
+
spelled: `-${flags.join("")}${hint}`
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
const readShort = ({ explicit, head, options }) => {
|
|
298
|
+
const shorts = new Map(options.flatMap((option) => option.short === void 0 ? [] : [[option.short, option]]));
|
|
299
|
+
const glued = gluedValue({
|
|
300
|
+
head,
|
|
301
|
+
shorts
|
|
302
|
+
});
|
|
303
|
+
return {
|
|
304
|
+
explicit,
|
|
305
|
+
negated: false,
|
|
306
|
+
option: head.length === 2 ? shorts.get(head.slice(1)) : void 0,
|
|
307
|
+
spelled: glued?.spelled ?? head,
|
|
308
|
+
suggestion: glued?.separated
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
const readLong = ({ explicit, head, options }) => {
|
|
312
|
+
const name = head.slice(2);
|
|
313
|
+
const direct = findOption({
|
|
314
|
+
name,
|
|
315
|
+
options
|
|
316
|
+
});
|
|
317
|
+
if (direct !== void 0 || !name.startsWith("no-")) return {
|
|
318
|
+
explicit,
|
|
319
|
+
negated: false,
|
|
320
|
+
option: direct,
|
|
321
|
+
spelled: head
|
|
322
|
+
};
|
|
323
|
+
const negated = findOption({
|
|
324
|
+
name: name.slice(3),
|
|
325
|
+
options
|
|
326
|
+
});
|
|
327
|
+
const usable = negated?.negatable === true && negated.kind === "flag";
|
|
328
|
+
return {
|
|
329
|
+
explicit,
|
|
330
|
+
negated: usable,
|
|
331
|
+
option: usable ? negated : void 0,
|
|
332
|
+
spelled: head
|
|
333
|
+
};
|
|
334
|
+
};
|
|
335
|
+
const readOptionToken = ({ options, token }) => {
|
|
336
|
+
const equals = token.indexOf("=");
|
|
337
|
+
const head = equals === -1 ? token : token.slice(0, equals);
|
|
338
|
+
const explicit = equals === -1 ? null : token.slice(equals + 1);
|
|
339
|
+
const read = head.startsWith("--") ? readLong({
|
|
340
|
+
explicit,
|
|
341
|
+
head,
|
|
342
|
+
options
|
|
343
|
+
}) : readShort({
|
|
344
|
+
explicit,
|
|
345
|
+
head,
|
|
346
|
+
options
|
|
347
|
+
});
|
|
348
|
+
if (read.option !== void 0) return read;
|
|
349
|
+
const similar = closest({
|
|
350
|
+
candidates: [...new Set(options.map((option) => `--${option.name}`))],
|
|
351
|
+
token: head
|
|
352
|
+
});
|
|
353
|
+
return {
|
|
354
|
+
...read,
|
|
355
|
+
suggestion: similar ?? read.suggestion
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
const booleanText = /* @__PURE__ */ new Map([["false", false], ["true", true]]);
|
|
359
|
+
const isOptionToken = (token) => token.startsWith("-") && token !== "-";
|
|
360
|
+
const flagOf = (options, name) => {
|
|
361
|
+
const value = options[name];
|
|
362
|
+
return value?.kind === "flag" ? value.value : void 0;
|
|
363
|
+
};
|
|
364
|
+
const valuesOf = (options, name) => {
|
|
365
|
+
const value = options[name];
|
|
366
|
+
return value?.kind === "value" ? value.values : [];
|
|
367
|
+
};
|
|
368
|
+
const lastValue = (options, name) => valuesOf(options, name).at(-1);
|
|
369
|
+
const rerunArgv = ({ arguments: positionals, options, path }) => {
|
|
370
|
+
const flags = Object.entries(options).flatMap(([name, value]) => {
|
|
371
|
+
if (name === "token") return [];
|
|
372
|
+
if (value.kind === "flag") return [value.value ? `--${name}` : `--no-${name}`];
|
|
373
|
+
return value.values.flatMap((text) => [`--${name}`, text]);
|
|
374
|
+
});
|
|
375
|
+
return [
|
|
376
|
+
...path,
|
|
377
|
+
...Object.values(positionals).flat(),
|
|
378
|
+
...flags
|
|
379
|
+
];
|
|
380
|
+
};
|
|
381
|
+
const record = (state, option, next) => {
|
|
382
|
+
const previous = state.values.get(option.name);
|
|
383
|
+
state.used.push(option.name);
|
|
384
|
+
if (previous === void 0) {
|
|
385
|
+
state.values.set(option.name, next);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
const repeat = option.repeat ?? "error";
|
|
389
|
+
if (repeat === "error") {
|
|
390
|
+
state.issues.push({
|
|
391
|
+
field: `--${option.name}`,
|
|
392
|
+
message: `Can't use --${option.name} more than once.`,
|
|
393
|
+
reason: "invalid_arguments"
|
|
394
|
+
});
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
if (repeat === "append" && previous.kind === "value" && next.kind === "value") {
|
|
398
|
+
state.values.set(option.name, {
|
|
399
|
+
kind: "value",
|
|
400
|
+
values: [...previous.values, ...next.values]
|
|
401
|
+
});
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
state.values.set(option.name, next);
|
|
405
|
+
};
|
|
406
|
+
const takePositional = (state, token) => {
|
|
407
|
+
state.positionals.push(token);
|
|
408
|
+
state.index += 1;
|
|
409
|
+
};
|
|
410
|
+
const unknownOption = (state, read) => {
|
|
411
|
+
const hint = read.suggestion === void 0 ? "" : ` Did you mean ${read.suggestion}?`;
|
|
412
|
+
state.issues.push({
|
|
413
|
+
field: read.spelled,
|
|
414
|
+
message: `Unknown option ${read.spelled} for ${state.command}.${hint}`,
|
|
415
|
+
reason: "unknown_option"
|
|
416
|
+
});
|
|
417
|
+
};
|
|
418
|
+
const takeFlag = (state, read, option) => {
|
|
419
|
+
const parsed = read.explicit === null ? !read.negated : booleanText.get(read.explicit.toLowerCase());
|
|
420
|
+
if (parsed === void 0 || read.negated && read.explicit !== null) {
|
|
421
|
+
state.issues.push({
|
|
422
|
+
field: `--${option.name}`,
|
|
423
|
+
message: `--${option.name} takes no value other than true or false.`,
|
|
424
|
+
reason: "invalid_arguments"
|
|
425
|
+
});
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
record(state, option, {
|
|
429
|
+
kind: "flag",
|
|
430
|
+
value: parsed
|
|
431
|
+
});
|
|
432
|
+
};
|
|
433
|
+
const takeValue = (state, read, option) => {
|
|
434
|
+
if (read.explicit !== null) {
|
|
435
|
+
record(state, option, {
|
|
436
|
+
kind: "value",
|
|
437
|
+
values: [read.explicit]
|
|
438
|
+
});
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
const next = state.tokens[state.index];
|
|
442
|
+
if (next === void 0 || isOptionToken(next)) {
|
|
443
|
+
const example = option.hint === void 0 ? "" : `, such as ${option.hint}`;
|
|
444
|
+
state.issues.push({
|
|
445
|
+
field: `--${option.name}`,
|
|
446
|
+
message: `--${option.name} needs a value${example}.`,
|
|
447
|
+
reason: "invalid_arguments"
|
|
448
|
+
});
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
record(state, option, {
|
|
452
|
+
kind: "value",
|
|
453
|
+
values: [next]
|
|
454
|
+
});
|
|
455
|
+
state.index += 1;
|
|
456
|
+
};
|
|
457
|
+
const takeOption = (state, token) => {
|
|
458
|
+
const read = readOptionToken({
|
|
459
|
+
options: state.options,
|
|
460
|
+
token
|
|
461
|
+
});
|
|
462
|
+
state.index += 1;
|
|
463
|
+
if (read.option === void 0) unknownOption(state, read);
|
|
464
|
+
else if (read.option.kind === "flag") takeFlag(state, read, read.option);
|
|
465
|
+
else takeValue(state, read, read.option);
|
|
466
|
+
};
|
|
467
|
+
const assignArguments = ({ argumentSpecs, command, issues, positionals }) => {
|
|
468
|
+
const assigned = /* @__PURE__ */ new Map();
|
|
469
|
+
let cursor = 0;
|
|
470
|
+
for (const spec of argumentSpecs) {
|
|
471
|
+
const taken = spec.variadic === true ? positionals.slice(cursor) : positionals.slice(cursor, cursor + 1);
|
|
472
|
+
assigned.set(spec.name, taken);
|
|
473
|
+
cursor += taken.length;
|
|
474
|
+
if (spec.optional !== true && taken.length === 0) {
|
|
475
|
+
const missing = spec.missing ?? {
|
|
476
|
+
message: `Can't run ${command} without <${spec.name}>.`,
|
|
477
|
+
reason: "invalid_arguments"
|
|
478
|
+
};
|
|
479
|
+
issues.push({
|
|
480
|
+
field: `<${spec.name}>`,
|
|
481
|
+
message: missing.message,
|
|
482
|
+
reason: missing.reason
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
const extra = positionals.slice(cursor);
|
|
487
|
+
if (extra.length > 0) issues.push({
|
|
488
|
+
field: extra.join(" "),
|
|
489
|
+
message: `Unexpected argument ${extra.join(" ")} for ${command}.`,
|
|
490
|
+
reason: "invalid_arguments"
|
|
491
|
+
});
|
|
492
|
+
return Object.fromEntries(assigned);
|
|
493
|
+
};
|
|
494
|
+
const parseLeaf = ({ arguments: argumentSpecs, command, options, tokens }) => {
|
|
495
|
+
const state = {
|
|
496
|
+
command,
|
|
497
|
+
index: 0,
|
|
498
|
+
issues: [],
|
|
499
|
+
literal: false,
|
|
500
|
+
options,
|
|
501
|
+
positionals: [],
|
|
502
|
+
tokens,
|
|
503
|
+
used: [],
|
|
504
|
+
values: /* @__PURE__ */ new Map()
|
|
505
|
+
};
|
|
506
|
+
while (state.index < tokens.length) {
|
|
507
|
+
const token = tokens[state.index] ?? "";
|
|
508
|
+
if (state.literal || !isOptionToken(token)) takePositional(state, token);
|
|
509
|
+
else if (token === "--") {
|
|
510
|
+
state.literal = true;
|
|
511
|
+
state.index += 1;
|
|
512
|
+
} else takeOption(state, token);
|
|
513
|
+
}
|
|
514
|
+
const argumentIssues = [];
|
|
515
|
+
const assigned = assignArguments({
|
|
516
|
+
argumentSpecs,
|
|
517
|
+
command,
|
|
518
|
+
issues: argumentIssues,
|
|
519
|
+
positionals: state.positionals
|
|
520
|
+
});
|
|
521
|
+
const unknown = state.issues.findIndex((issue) => issue.reason === "unknown_option");
|
|
522
|
+
return {
|
|
523
|
+
input: {
|
|
524
|
+
arguments: assigned,
|
|
525
|
+
options: Object.fromEntries(state.values),
|
|
526
|
+
used: state.used
|
|
527
|
+
},
|
|
528
|
+
issues: unknown === -1 ? [...state.issues, ...argumentIssues] : state.issues.slice(0, unknown + 1)
|
|
529
|
+
};
|
|
530
|
+
};
|
|
531
|
+
const parseFailure = ({ bin, issues, path }) => {
|
|
532
|
+
const [first] = issues;
|
|
533
|
+
const several = issues.length > 1;
|
|
534
|
+
return usageFailure({
|
|
535
|
+
help: path,
|
|
536
|
+
issues: issues.map(({ field, message }) => ({
|
|
537
|
+
field,
|
|
538
|
+
message
|
|
539
|
+
})),
|
|
540
|
+
message: several ? `Can't run ${[bin, ...path].join(" ")}. ${String(issues.length)} inputs are invalid.` : first?.message ?? "",
|
|
541
|
+
reason: first?.reason ?? "invalid_arguments"
|
|
542
|
+
});
|
|
543
|
+
};
|
|
544
|
+
// package.json
|
|
545
|
+
var version = "0.2.0";
|
|
546
|
+
// src/cli/spec.ts
|
|
547
|
+
const BIN = "sandcovery";
|
|
548
|
+
const NULLABLE_TEXT = "string | null";
|
|
549
|
+
const SANDBOX = "<SANDBOX>";
|
|
550
|
+
const SPEND_LIMIT = "spend-limit";
|
|
551
|
+
const NEEDS_MANAGEMENT = "Needs a management key.";
|
|
552
|
+
const CLEARABLE = {
|
|
553
|
+
"expires-at": "expires_at",
|
|
554
|
+
"max-concurrent": "max_concurrent_sandboxes",
|
|
555
|
+
"max-ttl": "max_ttl_seconds",
|
|
556
|
+
provider: "allowed_providers",
|
|
557
|
+
"spend-limit": "spend_limit"
|
|
558
|
+
};
|
|
559
|
+
const flag = (option) => ({
|
|
560
|
+
...option,
|
|
561
|
+
kind: "flag",
|
|
562
|
+
negatable: true,
|
|
563
|
+
repeat: "last"
|
|
564
|
+
});
|
|
565
|
+
const json = flag({
|
|
566
|
+
name: "json",
|
|
567
|
+
summary: "Print the result as one JSON document"
|
|
568
|
+
});
|
|
569
|
+
const baseUrl = {
|
|
570
|
+
defaultText: "https://www.sandcovery.com; SANDCOVERY_BASE_URL also sets it",
|
|
571
|
+
hint: "<URL>",
|
|
572
|
+
kind: "value",
|
|
573
|
+
name: "base-url",
|
|
574
|
+
summary: "Sandcovery origin to send requests to"
|
|
575
|
+
};
|
|
576
|
+
const yes = flag({
|
|
577
|
+
name: "yes",
|
|
578
|
+
short: "y",
|
|
579
|
+
summary: "Confirm without a prompt, after a person has approved"
|
|
580
|
+
});
|
|
581
|
+
const limit = (noun) => ({
|
|
582
|
+
defaultText: "20",
|
|
583
|
+
hint: "<NUMBER>",
|
|
584
|
+
kind: "value",
|
|
585
|
+
name: "limit",
|
|
586
|
+
short: "n",
|
|
587
|
+
summary: `Number of ${noun} on the page, from 1 to ${String(100)}`
|
|
588
|
+
});
|
|
589
|
+
const next = {
|
|
590
|
+
hint: "<CURSOR>",
|
|
591
|
+
kind: "value",
|
|
592
|
+
name: "next",
|
|
593
|
+
summary: "Continue after a page, from the cursor that page printed"
|
|
594
|
+
};
|
|
595
|
+
const env = {
|
|
596
|
+
hint: "<NAME=VALUE>",
|
|
597
|
+
kind: "value",
|
|
598
|
+
name: "env",
|
|
599
|
+
repeat: "append",
|
|
600
|
+
short: "e",
|
|
601
|
+
summary: "Environment variable to set; repeat for each one"
|
|
602
|
+
};
|
|
603
|
+
const provider = (summary) => ({
|
|
604
|
+
hint: "<PROVIDER>",
|
|
605
|
+
kind: "value",
|
|
606
|
+
name: "provider",
|
|
607
|
+
repeat: "append",
|
|
608
|
+
short: "p",
|
|
609
|
+
summary
|
|
610
|
+
});
|
|
611
|
+
const required = ({ message, name, reason, summary }) => ({
|
|
612
|
+
missing: {
|
|
613
|
+
message,
|
|
614
|
+
reason
|
|
615
|
+
},
|
|
616
|
+
name,
|
|
617
|
+
summary
|
|
618
|
+
});
|
|
619
|
+
const sandboxArgument = (verb) => required({
|
|
620
|
+
message: `Can't ${verb} without a sandbox ID.`,
|
|
621
|
+
name: "sandbox",
|
|
622
|
+
reason: "missing_sandbox",
|
|
623
|
+
summary: "Sandbox ID, such as sbx_ and a UUID, as sandcovery sandboxes list prints it"
|
|
624
|
+
});
|
|
625
|
+
const keyArgument = (verb) => required({
|
|
626
|
+
message: `Can't ${verb} without a key ID.`,
|
|
627
|
+
name: "key",
|
|
628
|
+
reason: "missing_key",
|
|
629
|
+
summary: "Key ID, such as key_ or mkey_ and a UUID, as sandcovery keys list prints it"
|
|
630
|
+
});
|
|
631
|
+
const providerArgument = (verb) => required({
|
|
632
|
+
message: `Can't ${verb} without a provider.`,
|
|
633
|
+
name: "provider",
|
|
634
|
+
reason: "missing_provider",
|
|
635
|
+
summary: "Provider, such as e2b, as sandcovery providers list prints it"
|
|
636
|
+
});
|
|
637
|
+
const pathArgument = (verb) => required({
|
|
638
|
+
message: `Can't ${verb} without a path in the sandbox.`,
|
|
639
|
+
name: "path",
|
|
640
|
+
reason: "missing_path",
|
|
641
|
+
summary: "Path in the sandbox"
|
|
642
|
+
});
|
|
643
|
+
const SANDBOX_RESULT = [
|
|
644
|
+
{
|
|
645
|
+
name: "sandbox.id",
|
|
646
|
+
type: "string"
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
name: "sandbox.status",
|
|
650
|
+
type: "string"
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
name: "sandbox.provider",
|
|
654
|
+
type: NULLABLE_TEXT
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
name: "sandbox.expires_at",
|
|
658
|
+
type: "string"
|
|
659
|
+
}
|
|
660
|
+
];
|
|
661
|
+
const sandboxLeaf = ({ name, notes, result = SANDBOX_RESULT, summary, verb }) => ({
|
|
662
|
+
arguments: [sandboxArgument(verb)],
|
|
663
|
+
examples: [{
|
|
664
|
+
argv: [
|
|
665
|
+
"sandboxes",
|
|
666
|
+
name,
|
|
667
|
+
SANDBOX
|
|
668
|
+
],
|
|
669
|
+
summary
|
|
670
|
+
}],
|
|
671
|
+
kind: "leaf",
|
|
672
|
+
name,
|
|
673
|
+
notes,
|
|
674
|
+
options: [baseUrl, json],
|
|
675
|
+
result,
|
|
676
|
+
summary
|
|
677
|
+
});
|
|
678
|
+
const keyPolicyOptions = [
|
|
679
|
+
{
|
|
680
|
+
hint: "<TIME>",
|
|
681
|
+
kind: "value",
|
|
682
|
+
name: "expires-at",
|
|
683
|
+
summary: "When the key stops working, as a UTC time such as 2026-12-31T00:00:00.000Z"
|
|
684
|
+
},
|
|
685
|
+
{
|
|
686
|
+
hint: "<NUMBER>",
|
|
687
|
+
kind: "value",
|
|
688
|
+
name: "max-concurrent",
|
|
689
|
+
summary: "Most sandboxes the key can run at once"
|
|
690
|
+
},
|
|
691
|
+
{
|
|
692
|
+
hint: "<SECONDS>",
|
|
693
|
+
kind: "value",
|
|
694
|
+
name: "max-ttl",
|
|
695
|
+
summary: "Longest TTL, in seconds, the key can give a sandbox"
|
|
696
|
+
},
|
|
697
|
+
provider("Provider the key can create sandboxes on; repeat for each one"),
|
|
698
|
+
{
|
|
699
|
+
hint: "<USD>",
|
|
700
|
+
kind: "value",
|
|
701
|
+
name: SPEND_LIMIT,
|
|
702
|
+
summary: "Most the key can spend per --spend-period, in US dollars, such as 25 or 0.50"
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
defaultText: "month",
|
|
706
|
+
hint: "<PERIOD>",
|
|
707
|
+
kind: "value",
|
|
708
|
+
name: "spend-period",
|
|
709
|
+
summary: "Period --spend-limit applies to",
|
|
710
|
+
values: SpendLimit.fields.period.literals
|
|
711
|
+
}
|
|
712
|
+
];
|
|
713
|
+
const KEY_RESULT = [
|
|
714
|
+
{
|
|
715
|
+
name: "key.id",
|
|
716
|
+
type: "string"
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
name: "key.kind",
|
|
720
|
+
type: "\"api\" | \"management\""
|
|
721
|
+
},
|
|
722
|
+
{
|
|
723
|
+
name: "key.name",
|
|
724
|
+
type: "string"
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
name: "key.start",
|
|
728
|
+
type: "string"
|
|
729
|
+
},
|
|
730
|
+
{
|
|
731
|
+
name: "key.revoked_at",
|
|
732
|
+
type: NULLABLE_TEXT
|
|
733
|
+
}
|
|
734
|
+
];
|
|
735
|
+
const sandboxSpecOptions = [
|
|
736
|
+
env,
|
|
737
|
+
{
|
|
738
|
+
hint: "<SECONDS>",
|
|
739
|
+
kind: "value",
|
|
740
|
+
name: "idle-timeout",
|
|
741
|
+
summary: "Seconds without a command after which the provider may pause the sandbox"
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
hint: "<IMAGE>",
|
|
745
|
+
kind: "value",
|
|
746
|
+
name: "image",
|
|
747
|
+
summary: "Image to start from, on providers that run custom images"
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
hint: "<PORT>",
|
|
751
|
+
kind: "value",
|
|
752
|
+
name: "port",
|
|
753
|
+
repeat: "append",
|
|
754
|
+
summary: "Port to expose for previews; repeat for each one"
|
|
755
|
+
},
|
|
756
|
+
provider("Provider to run on; repeat to allow several, tried in the order given"),
|
|
757
|
+
{
|
|
758
|
+
defaultText: "the provider's",
|
|
759
|
+
hint: "<REGION>",
|
|
760
|
+
kind: "value",
|
|
761
|
+
name: "region",
|
|
762
|
+
short: "r",
|
|
763
|
+
summary: "Region to run in, such as us, eu, or asia"
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
defaultText: "2x4",
|
|
767
|
+
hint: "<SIZE>",
|
|
768
|
+
kind: "value",
|
|
769
|
+
name: "size",
|
|
770
|
+
short: "s",
|
|
771
|
+
summary: "Size as <vcpu>x<memory_gib>, such as 2x4 or 4x8, with an optional routing suffix such as :cheapest"
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
hint: "<SORT>",
|
|
775
|
+
kind: "value",
|
|
776
|
+
name: "sort",
|
|
777
|
+
summary: "How to rank providers when no --provider is given",
|
|
778
|
+
values: ProviderSort.literals
|
|
779
|
+
},
|
|
780
|
+
{
|
|
781
|
+
defaultText: "the key's maximum",
|
|
782
|
+
hint: "<SECONDS>",
|
|
783
|
+
kind: "value",
|
|
784
|
+
name: "ttl",
|
|
785
|
+
summary: "Seconds until Sandcovery destroys the sandbox"
|
|
786
|
+
}
|
|
787
|
+
];
|
|
788
|
+
const sandboxesList = {
|
|
789
|
+
arguments: [],
|
|
790
|
+
examples: [{
|
|
791
|
+
argv: ["sandboxes", "list"],
|
|
792
|
+
summary: "List your newest sandboxes"
|
|
793
|
+
}, {
|
|
794
|
+
argv: [
|
|
795
|
+
"sandboxes",
|
|
796
|
+
"list",
|
|
797
|
+
"--status",
|
|
798
|
+
"running",
|
|
799
|
+
"--json"
|
|
800
|
+
],
|
|
801
|
+
summary: "List running sandboxes in a script"
|
|
802
|
+
}],
|
|
803
|
+
kind: "leaf",
|
|
804
|
+
name: "list",
|
|
805
|
+
notes: ["Sandboxes list newest first, one page per run. --next continues after the page that printed it."],
|
|
806
|
+
options: [
|
|
807
|
+
baseUrl,
|
|
808
|
+
json,
|
|
809
|
+
limit("sandboxes"),
|
|
810
|
+
next,
|
|
811
|
+
{
|
|
812
|
+
hint: "<STATUS>",
|
|
813
|
+
kind: "value",
|
|
814
|
+
name: "status",
|
|
815
|
+
summary: "List only sandboxes in this status",
|
|
816
|
+
values: SandboxStatus.literals
|
|
817
|
+
}
|
|
818
|
+
],
|
|
819
|
+
result: [
|
|
820
|
+
{
|
|
821
|
+
name: "sandboxes",
|
|
822
|
+
type: "array"
|
|
823
|
+
},
|
|
824
|
+
{
|
|
825
|
+
name: "sandboxes[].id",
|
|
826
|
+
type: "string"
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
name: "sandboxes[].status",
|
|
830
|
+
type: "string"
|
|
831
|
+
},
|
|
832
|
+
{
|
|
833
|
+
name: "next_cursor",
|
|
834
|
+
type: NULLABLE_TEXT
|
|
835
|
+
}
|
|
836
|
+
],
|
|
837
|
+
shortcuts: ["ls"],
|
|
838
|
+
summary: "List your sandboxes, newest first"
|
|
839
|
+
};
|
|
840
|
+
const sandboxesCreate = {
|
|
841
|
+
arguments: [],
|
|
842
|
+
examples: [
|
|
843
|
+
{
|
|
844
|
+
argv: ["sandboxes", "create"],
|
|
845
|
+
summary: "Create a 2x4 sandbox on the best provider"
|
|
846
|
+
},
|
|
847
|
+
{
|
|
848
|
+
argv: [
|
|
849
|
+
"sandboxes",
|
|
850
|
+
"create",
|
|
851
|
+
"--size",
|
|
852
|
+
"4x8:cheapest",
|
|
853
|
+
"--ttl",
|
|
854
|
+
"600",
|
|
855
|
+
"--json"
|
|
856
|
+
],
|
|
857
|
+
summary: "Create the cheapest 4x8 sandbox for 10 minutes in a script"
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
argv: [
|
|
861
|
+
"sandboxes",
|
|
862
|
+
"create",
|
|
863
|
+
"--provider",
|
|
864
|
+
"e2b",
|
|
865
|
+
"--provider",
|
|
866
|
+
"daytona"
|
|
867
|
+
],
|
|
868
|
+
summary: "Try E2B first, then Daytona"
|
|
869
|
+
}
|
|
870
|
+
],
|
|
871
|
+
kind: "leaf",
|
|
872
|
+
name: "create",
|
|
873
|
+
notes: [
|
|
874
|
+
"Sandcovery tries each candidate provider in order and falls back on capacity, quota, timeout, and server errors, unless --no-fallbacks is given.",
|
|
875
|
+
"Each create sends an idempotency key, so the CLI retries a create that got no answer without making a second sandbox.",
|
|
876
|
+
"When stdout is not a terminal, the command prints the sandbox ID there."
|
|
877
|
+
],
|
|
878
|
+
options: [
|
|
879
|
+
baseUrl,
|
|
880
|
+
flag({
|
|
881
|
+
name: "fallbacks",
|
|
882
|
+
summary: "Fall back to the next provider when one fails; --no-fallbacks stops at the first failure"
|
|
883
|
+
}),
|
|
884
|
+
json,
|
|
885
|
+
...sandboxSpecOptions,
|
|
886
|
+
{
|
|
887
|
+
hint: "<SNAPSHOT>",
|
|
888
|
+
kind: "value",
|
|
889
|
+
name: "snapshot",
|
|
890
|
+
summary: "Snapshot ID to restore, as sandcovery sandboxes snapshot prints it"
|
|
891
|
+
}
|
|
892
|
+
],
|
|
893
|
+
result: [...SANDBOX_RESULT, {
|
|
894
|
+
name: "sandbox.attempts",
|
|
895
|
+
type: "array"
|
|
896
|
+
}],
|
|
897
|
+
summary: "Create a sandbox"
|
|
898
|
+
};
|
|
899
|
+
const sandboxesExec = {
|
|
900
|
+
arguments: [sandboxArgument("run a command"), {
|
|
901
|
+
missing: {
|
|
902
|
+
message: "Can't run a command without the command, after --.",
|
|
903
|
+
reason: "missing_command"
|
|
904
|
+
},
|
|
905
|
+
name: "command",
|
|
906
|
+
summary: "Command to run, after --; like ssh, its words join with spaces and run in the sandbox's shell",
|
|
907
|
+
variadic: true
|
|
908
|
+
}],
|
|
909
|
+
examples: [{
|
|
910
|
+
argv: [
|
|
911
|
+
"sandboxes",
|
|
912
|
+
"exec",
|
|
913
|
+
SANDBOX,
|
|
914
|
+
"--",
|
|
915
|
+
"ls",
|
|
916
|
+
"-la"
|
|
917
|
+
],
|
|
918
|
+
summary: "List the working directory"
|
|
919
|
+
}, {
|
|
920
|
+
argv: [
|
|
921
|
+
"sandboxes",
|
|
922
|
+
"exec",
|
|
923
|
+
SANDBOX,
|
|
924
|
+
"--json",
|
|
925
|
+
"--",
|
|
926
|
+
"npm",
|
|
927
|
+
"test"
|
|
928
|
+
],
|
|
929
|
+
summary: "Run the tests and read their output and exit code in a script"
|
|
930
|
+
}],
|
|
931
|
+
kind: "leaf",
|
|
932
|
+
name: "exec",
|
|
933
|
+
notes: [
|
|
934
|
+
"The command's stdout and stderr stream to this terminal's, and the CLI exits with the command's exit code.",
|
|
935
|
+
"With --json, the CLI waits for the command and prints its stdout, stderr, exit code, and duration as one document.",
|
|
936
|
+
"The CLI never retries a command, since running it twice may change the sandbox twice."
|
|
937
|
+
],
|
|
938
|
+
options: [
|
|
939
|
+
baseUrl,
|
|
940
|
+
{
|
|
941
|
+
hint: "<DIR>",
|
|
942
|
+
kind: "value",
|
|
943
|
+
name: "cwd",
|
|
944
|
+
summary: "Directory in the sandbox to run the command in"
|
|
945
|
+
},
|
|
946
|
+
env,
|
|
947
|
+
json,
|
|
948
|
+
{
|
|
949
|
+
hint: "<SECONDS>",
|
|
950
|
+
kind: "value",
|
|
951
|
+
name: "timeout",
|
|
952
|
+
summary: "Seconds after which the provider stops the command"
|
|
953
|
+
}
|
|
954
|
+
],
|
|
955
|
+
result: [
|
|
956
|
+
{
|
|
957
|
+
name: "exec.exit_code",
|
|
958
|
+
type: "number"
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
name: "exec.stdout",
|
|
962
|
+
type: "string"
|
|
963
|
+
},
|
|
964
|
+
{
|
|
965
|
+
name: "exec.stderr",
|
|
966
|
+
type: "string"
|
|
967
|
+
},
|
|
968
|
+
{
|
|
969
|
+
name: "exec.duration_ms",
|
|
970
|
+
type: "number"
|
|
971
|
+
}
|
|
972
|
+
],
|
|
973
|
+
summary: "Run a command in a sandbox"
|
|
974
|
+
};
|
|
975
|
+
const sandboxesDestroy = {
|
|
976
|
+
arguments: [sandboxArgument("destroy a sandbox")],
|
|
977
|
+
examples: [{
|
|
978
|
+
argv: [
|
|
979
|
+
"sandboxes",
|
|
980
|
+
"destroy",
|
|
981
|
+
SANDBOX
|
|
982
|
+
],
|
|
983
|
+
summary: "Destroy a sandbox after a prompt"
|
|
984
|
+
}, {
|
|
985
|
+
argv: [
|
|
986
|
+
"sandboxes",
|
|
987
|
+
"destroy",
|
|
988
|
+
SANDBOX,
|
|
989
|
+
"--yes"
|
|
990
|
+
],
|
|
991
|
+
summary: "Destroy it in a script, after a person approved"
|
|
992
|
+
}],
|
|
993
|
+
kind: "leaf",
|
|
994
|
+
name: "destroy",
|
|
995
|
+
notes: ["Destroying a sandbox deletes its files and stops its commands. It asks first, and needs --yes without a terminal.", "Destroying a sandbox that already ended changes nothing."],
|
|
996
|
+
options: [
|
|
997
|
+
baseUrl,
|
|
998
|
+
json,
|
|
999
|
+
yes
|
|
1000
|
+
],
|
|
1001
|
+
result: SANDBOX_RESULT,
|
|
1002
|
+
shortcuts: ["delete", "rm"],
|
|
1003
|
+
summary: "Destroy a sandbox and everything in it"
|
|
1004
|
+
};
|
|
1005
|
+
const sandboxesPortsInspect = {
|
|
1006
|
+
arguments: [sandboxArgument("preview a port"), required({
|
|
1007
|
+
message: "Can't preview a port without its number.",
|
|
1008
|
+
name: "port",
|
|
1009
|
+
reason: "missing_port",
|
|
1010
|
+
summary: "Port the sandbox exposes, as sandcovery sandboxes create --port set it"
|
|
1011
|
+
})],
|
|
1012
|
+
examples: [{
|
|
1013
|
+
argv: [
|
|
1014
|
+
"sandboxes",
|
|
1015
|
+
"ports",
|
|
1016
|
+
"inspect",
|
|
1017
|
+
SANDBOX,
|
|
1018
|
+
"3000"
|
|
1019
|
+
],
|
|
1020
|
+
summary: "Print a port's preview URL"
|
|
1021
|
+
}],
|
|
1022
|
+
kind: "leaf",
|
|
1023
|
+
name: "inspect",
|
|
1024
|
+
notes: ["Prints the preview URL and any headers a request to it needs. The headers can grant access to the sandbox, so treat them as secrets."],
|
|
1025
|
+
options: [baseUrl, json],
|
|
1026
|
+
result: [
|
|
1027
|
+
{
|
|
1028
|
+
name: "preview.url",
|
|
1029
|
+
type: "string"
|
|
1030
|
+
},
|
|
1031
|
+
{
|
|
1032
|
+
name: "preview.headers",
|
|
1033
|
+
secret: true,
|
|
1034
|
+
type: "object"
|
|
1035
|
+
},
|
|
1036
|
+
{
|
|
1037
|
+
name: "preview.expires_at",
|
|
1038
|
+
type: NULLABLE_TEXT
|
|
1039
|
+
}
|
|
1040
|
+
],
|
|
1041
|
+
summary: "Print a port's preview URL"
|
|
1042
|
+
};
|
|
1043
|
+
const filesList = {
|
|
1044
|
+
arguments: [sandboxArgument("list files"), pathArgument("list files")],
|
|
1045
|
+
examples: [{
|
|
1046
|
+
argv: [
|
|
1047
|
+
"sandboxes",
|
|
1048
|
+
"files",
|
|
1049
|
+
"list",
|
|
1050
|
+
SANDBOX,
|
|
1051
|
+
"logs"
|
|
1052
|
+
],
|
|
1053
|
+
summary: "List a directory"
|
|
1054
|
+
}],
|
|
1055
|
+
kind: "leaf",
|
|
1056
|
+
name: "list",
|
|
1057
|
+
notes: ["Lists the entries of one directory, without descending into subdirectories."],
|
|
1058
|
+
options: [baseUrl, json],
|
|
1059
|
+
result: [{
|
|
1060
|
+
name: "files.path",
|
|
1061
|
+
type: "string"
|
|
1062
|
+
}, {
|
|
1063
|
+
name: "files.entries",
|
|
1064
|
+
type: "array"
|
|
1065
|
+
}],
|
|
1066
|
+
shortcuts: ["ls"],
|
|
1067
|
+
summary: "List a directory in a sandbox"
|
|
1068
|
+
};
|
|
1069
|
+
const filesRead = {
|
|
1070
|
+
arguments: [sandboxArgument("read a file"), pathArgument("read a file")],
|
|
1071
|
+
examples: [{
|
|
1072
|
+
argv: [
|
|
1073
|
+
"sandboxes",
|
|
1074
|
+
"files",
|
|
1075
|
+
"read",
|
|
1076
|
+
SANDBOX,
|
|
1077
|
+
"logs/out.txt"
|
|
1078
|
+
],
|
|
1079
|
+
summary: "Print a file"
|
|
1080
|
+
}, {
|
|
1081
|
+
argv: [
|
|
1082
|
+
"sandboxes",
|
|
1083
|
+
"files",
|
|
1084
|
+
"read",
|
|
1085
|
+
SANDBOX,
|
|
1086
|
+
"build.tar"
|
|
1087
|
+
],
|
|
1088
|
+
summary: "Copy a file out, with stdout redirected to a local file"
|
|
1089
|
+
}],
|
|
1090
|
+
kind: "leaf",
|
|
1091
|
+
name: "read",
|
|
1092
|
+
notes: ["Writes the file's bytes to stdout unchanged when stdout is not a terminal."],
|
|
1093
|
+
options: [baseUrl],
|
|
1094
|
+
result: [],
|
|
1095
|
+
shortcuts: ["cat"],
|
|
1096
|
+
summary: "Print a file from a sandbox"
|
|
1097
|
+
};
|
|
1098
|
+
const filesWrite = {
|
|
1099
|
+
arguments: [sandboxArgument("write a file"), pathArgument("write a file")],
|
|
1100
|
+
examples: [{
|
|
1101
|
+
argv: [
|
|
1102
|
+
"sandboxes",
|
|
1103
|
+
"files",
|
|
1104
|
+
"write",
|
|
1105
|
+
SANDBOX,
|
|
1106
|
+
"in.txt",
|
|
1107
|
+
"--from",
|
|
1108
|
+
"in.txt"
|
|
1109
|
+
],
|
|
1110
|
+
summary: "Copy a local file into a sandbox"
|
|
1111
|
+
}, {
|
|
1112
|
+
argv: [
|
|
1113
|
+
"sandboxes",
|
|
1114
|
+
"files",
|
|
1115
|
+
"write",
|
|
1116
|
+
SANDBOX,
|
|
1117
|
+
"in.txt",
|
|
1118
|
+
"--from",
|
|
1119
|
+
"-"
|
|
1120
|
+
],
|
|
1121
|
+
summary: "Write stdin to a file"
|
|
1122
|
+
}],
|
|
1123
|
+
kind: "leaf",
|
|
1124
|
+
name: "write",
|
|
1125
|
+
notes: ["Replaces the file at the path when one exists."],
|
|
1126
|
+
options: [
|
|
1127
|
+
baseUrl,
|
|
1128
|
+
{
|
|
1129
|
+
hint: "<FILE|->",
|
|
1130
|
+
kind: "value",
|
|
1131
|
+
name: "from",
|
|
1132
|
+
required: true,
|
|
1133
|
+
stdin: true,
|
|
1134
|
+
summary: "Local file to upload, or - for stdin"
|
|
1135
|
+
},
|
|
1136
|
+
json
|
|
1137
|
+
],
|
|
1138
|
+
result: [{
|
|
1139
|
+
name: "file.path",
|
|
1140
|
+
type: "string"
|
|
1141
|
+
}, {
|
|
1142
|
+
name: "file.size_bytes",
|
|
1143
|
+
type: "number | null"
|
|
1144
|
+
}],
|
|
1145
|
+
summary: "Write a file into a sandbox"
|
|
1146
|
+
};
|
|
1147
|
+
const sandboxes = {
|
|
1148
|
+
children: [
|
|
1149
|
+
sandboxesList,
|
|
1150
|
+
sandboxesCreate,
|
|
1151
|
+
sandboxLeaf({
|
|
1152
|
+
name: "inspect",
|
|
1153
|
+
notes: ["Prints the sandbox, its cost so far, and every create attempt."],
|
|
1154
|
+
result: [...SANDBOX_RESULT, {
|
|
1155
|
+
name: "sandbox.cost",
|
|
1156
|
+
type: "object"
|
|
1157
|
+
}],
|
|
1158
|
+
summary: "Show one sandbox",
|
|
1159
|
+
verb: "show a sandbox"
|
|
1160
|
+
}),
|
|
1161
|
+
sandboxesExec,
|
|
1162
|
+
sandboxesDestroy,
|
|
1163
|
+
sandboxLeaf({
|
|
1164
|
+
name: "pause",
|
|
1165
|
+
notes: ["Pausing keeps the memory and files where the provider can. The TTL keeps counting."],
|
|
1166
|
+
summary: "Pause a sandbox",
|
|
1167
|
+
verb: "pause a sandbox"
|
|
1168
|
+
}),
|
|
1169
|
+
sandboxLeaf({
|
|
1170
|
+
name: "resume",
|
|
1171
|
+
notes: ["Resumes a paused sandbox with its files as they were."],
|
|
1172
|
+
summary: "Resume a paused sandbox",
|
|
1173
|
+
verb: "resume a sandbox"
|
|
1174
|
+
}),
|
|
1175
|
+
sandboxLeaf({
|
|
1176
|
+
name: "snapshot",
|
|
1177
|
+
notes: ["Saves the sandbox as a snapshot that sandcovery sandboxes create --snapshot restores."],
|
|
1178
|
+
result: [{
|
|
1179
|
+
name: "snapshot.id",
|
|
1180
|
+
type: "string"
|
|
1181
|
+
}, {
|
|
1182
|
+
name: "snapshot.provider",
|
|
1183
|
+
type: "string"
|
|
1184
|
+
}],
|
|
1185
|
+
summary: "Snapshot a sandbox",
|
|
1186
|
+
verb: "snapshot a sandbox"
|
|
1187
|
+
}),
|
|
1188
|
+
{
|
|
1189
|
+
children: [
|
|
1190
|
+
filesList,
|
|
1191
|
+
filesRead,
|
|
1192
|
+
filesWrite
|
|
1193
|
+
],
|
|
1194
|
+
kind: "group",
|
|
1195
|
+
name: "files",
|
|
1196
|
+
shortcuts: ["file"],
|
|
1197
|
+
summary: "List, read, and write files in a sandbox"
|
|
1198
|
+
},
|
|
1199
|
+
{
|
|
1200
|
+
children: [sandboxesPortsInspect],
|
|
1201
|
+
defaultChild: "inspect",
|
|
1202
|
+
kind: "group",
|
|
1203
|
+
name: "ports",
|
|
1204
|
+
shortcuts: ["port"],
|
|
1205
|
+
summary: "Preview a sandbox's ports"
|
|
1206
|
+
}
|
|
1207
|
+
],
|
|
1208
|
+
kind: "group",
|
|
1209
|
+
name: "sandboxes",
|
|
1210
|
+
shortcuts: ["sandbox", "sbx"],
|
|
1211
|
+
summary: "Create, run, and destroy sandboxes"
|
|
1212
|
+
};
|
|
1213
|
+
const keysCreate = {
|
|
1214
|
+
arguments: [],
|
|
1215
|
+
examples: [{
|
|
1216
|
+
argv: [
|
|
1217
|
+
"keys",
|
|
1218
|
+
"create",
|
|
1219
|
+
"--name",
|
|
1220
|
+
"ci"
|
|
1221
|
+
],
|
|
1222
|
+
summary: "Create an API key for CI"
|
|
1223
|
+
}, {
|
|
1224
|
+
argv: [
|
|
1225
|
+
"keys",
|
|
1226
|
+
"create",
|
|
1227
|
+
"--name",
|
|
1228
|
+
"ci",
|
|
1229
|
+
"--max-ttl",
|
|
1230
|
+
"3600",
|
|
1231
|
+
"--spend-limit",
|
|
1232
|
+
"50",
|
|
1233
|
+
"--json"
|
|
1234
|
+
],
|
|
1235
|
+
summary: "Create a capped API key in a script"
|
|
1236
|
+
}],
|
|
1237
|
+
kind: "leaf",
|
|
1238
|
+
name: "create",
|
|
1239
|
+
notes: ["Prints the secret once. Sandcovery keeps only its first 12 characters, so store it before you close the terminal.", NEEDS_MANAGEMENT],
|
|
1240
|
+
options: [
|
|
1241
|
+
baseUrl,
|
|
1242
|
+
json,
|
|
1243
|
+
...keyPolicyOptions,
|
|
1244
|
+
{
|
|
1245
|
+
defaultText: "api",
|
|
1246
|
+
hint: "<KIND>",
|
|
1247
|
+
kind: "value",
|
|
1248
|
+
name: "kind",
|
|
1249
|
+
summary: "api for sandboxes, or management for keys, usage, and credentials",
|
|
1250
|
+
values: KeyKind.literals
|
|
1251
|
+
},
|
|
1252
|
+
{
|
|
1253
|
+
hint: "<NAME>",
|
|
1254
|
+
kind: "value",
|
|
1255
|
+
name: "name",
|
|
1256
|
+
required: true,
|
|
1257
|
+
summary: "Name to recognize the key by, up to 100 characters"
|
|
1258
|
+
}
|
|
1259
|
+
],
|
|
1260
|
+
result: [...KEY_RESULT, {
|
|
1261
|
+
name: "secret",
|
|
1262
|
+
secret: true,
|
|
1263
|
+
type: "string"
|
|
1264
|
+
}],
|
|
1265
|
+
summary: "Create an API key or management key"
|
|
1266
|
+
};
|
|
1267
|
+
const keysUpdate = {
|
|
1268
|
+
arguments: [keyArgument("update a key")],
|
|
1269
|
+
examples: [{
|
|
1270
|
+
argv: [
|
|
1271
|
+
"keys",
|
|
1272
|
+
"update",
|
|
1273
|
+
"<KEY>",
|
|
1274
|
+
"--max-ttl",
|
|
1275
|
+
"7200"
|
|
1276
|
+
],
|
|
1277
|
+
summary: "Raise a key's longest TTL"
|
|
1278
|
+
}, {
|
|
1279
|
+
argv: [
|
|
1280
|
+
"keys",
|
|
1281
|
+
"update",
|
|
1282
|
+
"<KEY>",
|
|
1283
|
+
"--clear",
|
|
1284
|
+
SPEND_LIMIT
|
|
1285
|
+
],
|
|
1286
|
+
summary: "Remove a key's spend limit"
|
|
1287
|
+
}],
|
|
1288
|
+
kind: "leaf",
|
|
1289
|
+
name: "update",
|
|
1290
|
+
notes: ["Changes only the fields you pass. --clear removes a limit or expiry, so the key has none.", NEEDS_MANAGEMENT],
|
|
1291
|
+
options: [
|
|
1292
|
+
baseUrl,
|
|
1293
|
+
{
|
|
1294
|
+
hint: "<FIELD>",
|
|
1295
|
+
kind: "value",
|
|
1296
|
+
name: "clear",
|
|
1297
|
+
repeat: "append",
|
|
1298
|
+
summary: "Field to remove; repeat for each one",
|
|
1299
|
+
values: Object.keys(CLEARABLE)
|
|
1300
|
+
},
|
|
1301
|
+
json,
|
|
1302
|
+
...keyPolicyOptions,
|
|
1303
|
+
{
|
|
1304
|
+
hint: "<NAME>",
|
|
1305
|
+
kind: "value",
|
|
1306
|
+
name: "name",
|
|
1307
|
+
summary: "New name for the key"
|
|
1308
|
+
}
|
|
1309
|
+
],
|
|
1310
|
+
result: KEY_RESULT,
|
|
1311
|
+
summary: "Change a key's name, expiry, or limits"
|
|
1312
|
+
};
|
|
1313
|
+
const keys = {
|
|
1314
|
+
children: [
|
|
1315
|
+
{
|
|
1316
|
+
arguments: [],
|
|
1317
|
+
examples: [{
|
|
1318
|
+
argv: ["keys", "list"],
|
|
1319
|
+
summary: "List your keys"
|
|
1320
|
+
}],
|
|
1321
|
+
kind: "leaf",
|
|
1322
|
+
name: "list",
|
|
1323
|
+
notes: ["Lists every key, revoked ones included, with the first 12 characters of each secret. Needs a management key."],
|
|
1324
|
+
options: [baseUrl, json],
|
|
1325
|
+
result: [
|
|
1326
|
+
{
|
|
1327
|
+
name: "keys",
|
|
1328
|
+
type: "array"
|
|
1329
|
+
},
|
|
1330
|
+
{
|
|
1331
|
+
name: "keys[].id",
|
|
1332
|
+
type: "string"
|
|
1333
|
+
},
|
|
1334
|
+
{
|
|
1335
|
+
name: "keys[].kind",
|
|
1336
|
+
type: "\"api\" | \"management\""
|
|
1337
|
+
},
|
|
1338
|
+
{
|
|
1339
|
+
name: "keys[].name",
|
|
1340
|
+
type: "string"
|
|
1341
|
+
},
|
|
1342
|
+
{
|
|
1343
|
+
name: "keys[].start",
|
|
1344
|
+
type: "string"
|
|
1345
|
+
}
|
|
1346
|
+
],
|
|
1347
|
+
shortcuts: ["ls"],
|
|
1348
|
+
summary: "List your keys"
|
|
1349
|
+
},
|
|
1350
|
+
keysCreate,
|
|
1351
|
+
{
|
|
1352
|
+
arguments: [keyArgument("show a key")],
|
|
1353
|
+
examples: [{
|
|
1354
|
+
argv: [
|
|
1355
|
+
"keys",
|
|
1356
|
+
"inspect",
|
|
1357
|
+
"<KEY>"
|
|
1358
|
+
],
|
|
1359
|
+
summary: "Show a key and its spend"
|
|
1360
|
+
}],
|
|
1361
|
+
kind: "leaf",
|
|
1362
|
+
name: "inspect",
|
|
1363
|
+
notes: [NEEDS_MANAGEMENT],
|
|
1364
|
+
options: [baseUrl, json],
|
|
1365
|
+
result: KEY_RESULT,
|
|
1366
|
+
summary: "Show one key"
|
|
1367
|
+
},
|
|
1368
|
+
keysUpdate,
|
|
1369
|
+
{
|
|
1370
|
+
arguments: [keyArgument("revoke a key")],
|
|
1371
|
+
examples: [{
|
|
1372
|
+
argv: [
|
|
1373
|
+
"keys",
|
|
1374
|
+
"revoke",
|
|
1375
|
+
"<KEY>"
|
|
1376
|
+
],
|
|
1377
|
+
summary: "Revoke a key after a prompt"
|
|
1378
|
+
}, {
|
|
1379
|
+
argv: [
|
|
1380
|
+
"keys",
|
|
1381
|
+
"revoke",
|
|
1382
|
+
"<KEY>",
|
|
1383
|
+
"--yes"
|
|
1384
|
+
],
|
|
1385
|
+
summary: "Revoke it in a script, after a person approved"
|
|
1386
|
+
}],
|
|
1387
|
+
kind: "leaf",
|
|
1388
|
+
name: "revoke",
|
|
1389
|
+
notes: ["A revoked key stops working at once and cannot be restored. Its sandboxes keep running until their TTL.", "It asks first, and needs --yes without a terminal. Needs a management key."],
|
|
1390
|
+
options: [
|
|
1391
|
+
baseUrl,
|
|
1392
|
+
json,
|
|
1393
|
+
yes
|
|
1394
|
+
],
|
|
1395
|
+
result: KEY_RESULT,
|
|
1396
|
+
shortcuts: ["delete", "rm"],
|
|
1397
|
+
summary: "Revoke a key"
|
|
1398
|
+
}
|
|
1399
|
+
],
|
|
1400
|
+
defaultChild: "list",
|
|
1401
|
+
kind: "group",
|
|
1402
|
+
name: "keys",
|
|
1403
|
+
shortcuts: ["key"],
|
|
1404
|
+
summary: "Manage API keys and management keys"
|
|
1405
|
+
};
|
|
1406
|
+
const credentials = {
|
|
1407
|
+
children: [
|
|
1408
|
+
{
|
|
1409
|
+
arguments: [],
|
|
1410
|
+
examples: [{
|
|
1411
|
+
argv: ["credentials", "list"],
|
|
1412
|
+
summary: "List your provider credentials"
|
|
1413
|
+
}],
|
|
1414
|
+
kind: "leaf",
|
|
1415
|
+
name: "list",
|
|
1416
|
+
notes: ["Shows a hint of each credential, never the credential. Needs a management key."],
|
|
1417
|
+
options: [baseUrl, json],
|
|
1418
|
+
result: [
|
|
1419
|
+
{
|
|
1420
|
+
name: "credentials",
|
|
1421
|
+
type: "array"
|
|
1422
|
+
},
|
|
1423
|
+
{
|
|
1424
|
+
name: "credentials[].provider",
|
|
1425
|
+
type: "string"
|
|
1426
|
+
},
|
|
1427
|
+
{
|
|
1428
|
+
name: "credentials[].hint",
|
|
1429
|
+
type: "string"
|
|
1430
|
+
}
|
|
1431
|
+
],
|
|
1432
|
+
shortcuts: ["ls"],
|
|
1433
|
+
summary: "List your provider credentials"
|
|
1434
|
+
},
|
|
1435
|
+
{
|
|
1436
|
+
arguments: [providerArgument("set a credential")],
|
|
1437
|
+
examples: [{
|
|
1438
|
+
argv: [
|
|
1439
|
+
"credentials",
|
|
1440
|
+
"set",
|
|
1441
|
+
"e2b",
|
|
1442
|
+
"--from",
|
|
1443
|
+
"-"
|
|
1444
|
+
],
|
|
1445
|
+
summary: "Set the E2B credential from a JSON object on stdin"
|
|
1446
|
+
}, {
|
|
1447
|
+
argv: [
|
|
1448
|
+
"credentials",
|
|
1449
|
+
"set",
|
|
1450
|
+
"e2b",
|
|
1451
|
+
"--field",
|
|
1452
|
+
"api_key=<KEY>"
|
|
1453
|
+
],
|
|
1454
|
+
summary: "Set it from an option"
|
|
1455
|
+
}],
|
|
1456
|
+
kind: "leaf",
|
|
1457
|
+
name: "set",
|
|
1458
|
+
notes: ["Each provider names its fields in sandcovery providers inspect. Sandboxes on that provider then run on your account.", "Prefer --from -, since options show in process lists. Sandcovery seals the values and never returns them. Needs a management key."],
|
|
1459
|
+
options: [
|
|
1460
|
+
baseUrl,
|
|
1461
|
+
{
|
|
1462
|
+
hint: "<NAME=VALUE>",
|
|
1463
|
+
kind: "value",
|
|
1464
|
+
name: "field",
|
|
1465
|
+
repeat: "append",
|
|
1466
|
+
summary: "Credential field to set; repeat for each one"
|
|
1467
|
+
},
|
|
1468
|
+
{
|
|
1469
|
+
hint: "<FILE|->",
|
|
1470
|
+
kind: "value",
|
|
1471
|
+
name: "from",
|
|
1472
|
+
stdin: true,
|
|
1473
|
+
summary: "JSON object of the fields, from a file or - for stdin"
|
|
1474
|
+
},
|
|
1475
|
+
json
|
|
1476
|
+
],
|
|
1477
|
+
result: [{
|
|
1478
|
+
name: "credential.provider",
|
|
1479
|
+
type: "string"
|
|
1480
|
+
}, {
|
|
1481
|
+
name: "credential.hint",
|
|
1482
|
+
type: "string"
|
|
1483
|
+
}],
|
|
1484
|
+
summary: "Set or replace a provider credential"
|
|
1485
|
+
},
|
|
1486
|
+
{
|
|
1487
|
+
arguments: [providerArgument("delete a credential")],
|
|
1488
|
+
examples: [{
|
|
1489
|
+
argv: [
|
|
1490
|
+
"credentials",
|
|
1491
|
+
"delete",
|
|
1492
|
+
"e2b"
|
|
1493
|
+
],
|
|
1494
|
+
summary: "Delete the E2B credential after a prompt"
|
|
1495
|
+
}],
|
|
1496
|
+
kind: "leaf",
|
|
1497
|
+
name: "delete",
|
|
1498
|
+
notes: ["New sandboxes on that provider then run on Sandcovery's account. A credential that live sandboxes use cannot be deleted.", "It asks first, and needs --yes without a terminal. Needs a management key."],
|
|
1499
|
+
options: [
|
|
1500
|
+
baseUrl,
|
|
1501
|
+
json,
|
|
1502
|
+
yes
|
|
1503
|
+
],
|
|
1504
|
+
result: [{
|
|
1505
|
+
name: "credential.provider",
|
|
1506
|
+
type: "string"
|
|
1507
|
+
}, {
|
|
1508
|
+
name: "outcome",
|
|
1509
|
+
type: "\"deleted\""
|
|
1510
|
+
}],
|
|
1511
|
+
shortcuts: ["rm"],
|
|
1512
|
+
summary: "Delete a provider credential"
|
|
1513
|
+
}
|
|
1514
|
+
],
|
|
1515
|
+
defaultChild: "list",
|
|
1516
|
+
kind: "group",
|
|
1517
|
+
name: "credentials",
|
|
1518
|
+
shortcuts: ["credential"],
|
|
1519
|
+
summary: "Run sandboxes on your own provider accounts"
|
|
1520
|
+
};
|
|
1521
|
+
const providers = {
|
|
1522
|
+
children: [{
|
|
1523
|
+
arguments: [],
|
|
1524
|
+
examples: [{
|
|
1525
|
+
argv: ["providers", "list"],
|
|
1526
|
+
summary: "Compare the providers' prices and status"
|
|
1527
|
+
}],
|
|
1528
|
+
kind: "leaf",
|
|
1529
|
+
name: "list",
|
|
1530
|
+
notes: ["Lists each provider with its status, 2x4 price per hour, and median create latency."],
|
|
1531
|
+
options: [baseUrl, json],
|
|
1532
|
+
result: [
|
|
1533
|
+
{
|
|
1534
|
+
name: "providers",
|
|
1535
|
+
type: "array"
|
|
1536
|
+
},
|
|
1537
|
+
{
|
|
1538
|
+
name: "providers[].provider",
|
|
1539
|
+
type: "string"
|
|
1540
|
+
},
|
|
1541
|
+
{
|
|
1542
|
+
name: "providers[].status",
|
|
1543
|
+
type: "string"
|
|
1544
|
+
}
|
|
1545
|
+
],
|
|
1546
|
+
shortcuts: ["ls"],
|
|
1547
|
+
summary: "List the providers"
|
|
1548
|
+
}, {
|
|
1549
|
+
arguments: [providerArgument("show a provider")],
|
|
1550
|
+
examples: [{
|
|
1551
|
+
argv: [
|
|
1552
|
+
"providers",
|
|
1553
|
+
"inspect",
|
|
1554
|
+
"e2b"
|
|
1555
|
+
],
|
|
1556
|
+
summary: "Show E2B's prices, limits, and credential fields"
|
|
1557
|
+
}],
|
|
1558
|
+
kind: "leaf",
|
|
1559
|
+
name: "inspect",
|
|
1560
|
+
notes: ["Shows the prices of each size, the features and limits, and the fields sandcovery credentials set takes."],
|
|
1561
|
+
options: [baseUrl, json],
|
|
1562
|
+
result: [
|
|
1563
|
+
{
|
|
1564
|
+
name: "provider.provider",
|
|
1565
|
+
type: "string"
|
|
1566
|
+
},
|
|
1567
|
+
{
|
|
1568
|
+
name: "provider.features",
|
|
1569
|
+
type: "object"
|
|
1570
|
+
},
|
|
1571
|
+
{
|
|
1572
|
+
name: "provider.credential_fields",
|
|
1573
|
+
type: "array"
|
|
1574
|
+
}
|
|
1575
|
+
],
|
|
1576
|
+
summary: "Show one provider"
|
|
1577
|
+
}],
|
|
1578
|
+
defaultChild: "list",
|
|
1579
|
+
kind: "group",
|
|
1580
|
+
name: "providers",
|
|
1581
|
+
shortcuts: ["provider"],
|
|
1582
|
+
summary: "Compare the sandbox providers"
|
|
1583
|
+
};
|
|
1584
|
+
const usage = {
|
|
1585
|
+
children: [{
|
|
1586
|
+
arguments: [],
|
|
1587
|
+
examples: [{
|
|
1588
|
+
argv: ["usage", "inspect"],
|
|
1589
|
+
summary: "Show this month's usage"
|
|
1590
|
+
}, {
|
|
1591
|
+
argv: [
|
|
1592
|
+
"usage",
|
|
1593
|
+
"inspect",
|
|
1594
|
+
"--from",
|
|
1595
|
+
"2026-10-01",
|
|
1596
|
+
"--to",
|
|
1597
|
+
"2026-10-31",
|
|
1598
|
+
"--json"
|
|
1599
|
+
],
|
|
1600
|
+
summary: "Read October's usage in a script"
|
|
1601
|
+
}],
|
|
1602
|
+
kind: "leaf",
|
|
1603
|
+
name: "inspect",
|
|
1604
|
+
notes: ["Shows sandboxes, sandbox time, and estimated cost per UTC day, key, and provider, at most 92 days at once. Needs a management key."],
|
|
1605
|
+
options: [
|
|
1606
|
+
baseUrl,
|
|
1607
|
+
{
|
|
1608
|
+
defaultText: "the first day of this UTC month",
|
|
1609
|
+
hint: "<DAY>",
|
|
1610
|
+
kind: "value",
|
|
1611
|
+
name: "from",
|
|
1612
|
+
summary: "First UTC day, such as 2026-11-01"
|
|
1613
|
+
},
|
|
1614
|
+
json,
|
|
1615
|
+
{
|
|
1616
|
+
hint: "<KEY>",
|
|
1617
|
+
kind: "value",
|
|
1618
|
+
name: "key",
|
|
1619
|
+
summary: "Show only this API key, by its ID"
|
|
1620
|
+
},
|
|
1621
|
+
{
|
|
1622
|
+
defaultText: "today, in UTC",
|
|
1623
|
+
hint: "<DAY>",
|
|
1624
|
+
kind: "value",
|
|
1625
|
+
name: "to",
|
|
1626
|
+
summary: "Last UTC day, such as 2026-11-30"
|
|
1627
|
+
}
|
|
1628
|
+
],
|
|
1629
|
+
result: [
|
|
1630
|
+
{
|
|
1631
|
+
name: "usage",
|
|
1632
|
+
type: "array"
|
|
1633
|
+
},
|
|
1634
|
+
{
|
|
1635
|
+
name: "usage[].date",
|
|
1636
|
+
type: "string"
|
|
1637
|
+
},
|
|
1638
|
+
{
|
|
1639
|
+
name: "usage[].estimated_micro_usd",
|
|
1640
|
+
type: "number"
|
|
1641
|
+
}
|
|
1642
|
+
],
|
|
1643
|
+
summary: "Show usage and cost per day"
|
|
1644
|
+
}, {
|
|
1645
|
+
arguments: [],
|
|
1646
|
+
examples: [{
|
|
1647
|
+
argv: [
|
|
1648
|
+
"usage",
|
|
1649
|
+
"estimate",
|
|
1650
|
+
"--size",
|
|
1651
|
+
"4x8",
|
|
1652
|
+
"--ttl",
|
|
1653
|
+
"3600"
|
|
1654
|
+
],
|
|
1655
|
+
summary: "Price a 4x8 sandbox for an hour"
|
|
1656
|
+
}],
|
|
1657
|
+
kind: "leaf",
|
|
1658
|
+
name: "estimate",
|
|
1659
|
+
notes: ["Prices the spec on each provider that can run it, in routing order, without creating anything."],
|
|
1660
|
+
options: [
|
|
1661
|
+
baseUrl,
|
|
1662
|
+
json,
|
|
1663
|
+
...sandboxSpecOptions
|
|
1664
|
+
],
|
|
1665
|
+
result: [
|
|
1666
|
+
{
|
|
1667
|
+
name: "estimates",
|
|
1668
|
+
type: "array"
|
|
1669
|
+
},
|
|
1670
|
+
{
|
|
1671
|
+
name: "estimates[].provider",
|
|
1672
|
+
type: "string"
|
|
1673
|
+
},
|
|
1674
|
+
{
|
|
1675
|
+
name: "estimates[].ttl_micro_usd",
|
|
1676
|
+
type: "number"
|
|
1677
|
+
}
|
|
1678
|
+
],
|
|
1679
|
+
summary: "Price a sandbox before creating it"
|
|
1680
|
+
}],
|
|
1681
|
+
defaultChild: "inspect",
|
|
1682
|
+
kind: "group",
|
|
1683
|
+
name: "usage",
|
|
1684
|
+
summary: "Show usage and price sandboxes"
|
|
1685
|
+
};
|
|
1686
|
+
const activity = {
|
|
1687
|
+
children: [{
|
|
1688
|
+
arguments: [],
|
|
1689
|
+
examples: [{
|
|
1690
|
+
argv: ["activity", "list"],
|
|
1691
|
+
summary: "List the newest sandbox events"
|
|
1692
|
+
}],
|
|
1693
|
+
kind: "leaf",
|
|
1694
|
+
name: "list",
|
|
1695
|
+
notes: ["Lists creates, create attempts, pauses, snapshots, and ends, newest first, one page per run."],
|
|
1696
|
+
options: [
|
|
1697
|
+
baseUrl,
|
|
1698
|
+
json,
|
|
1699
|
+
limit("events"),
|
|
1700
|
+
next
|
|
1701
|
+
],
|
|
1702
|
+
result: [
|
|
1703
|
+
{
|
|
1704
|
+
name: "activity",
|
|
1705
|
+
type: "array"
|
|
1706
|
+
},
|
|
1707
|
+
{
|
|
1708
|
+
name: "activity[].action",
|
|
1709
|
+
type: "string"
|
|
1710
|
+
},
|
|
1711
|
+
{
|
|
1712
|
+
name: "next_cursor",
|
|
1713
|
+
type: NULLABLE_TEXT
|
|
1714
|
+
}
|
|
1715
|
+
],
|
|
1716
|
+
shortcuts: ["ls"],
|
|
1717
|
+
summary: "List sandbox events, newest first"
|
|
1718
|
+
}],
|
|
1719
|
+
defaultChild: "list",
|
|
1720
|
+
kind: "group",
|
|
1721
|
+
name: "activity",
|
|
1722
|
+
summary: "Read what happened to your sandboxes"
|
|
1723
|
+
};
|
|
1724
|
+
const telemetryLeaf = ({ name, summary }) => ({
|
|
1725
|
+
arguments: [],
|
|
1726
|
+
examples: [{
|
|
1727
|
+
argv: [
|
|
1728
|
+
"cli",
|
|
1729
|
+
"telemetry",
|
|
1730
|
+
name
|
|
1731
|
+
],
|
|
1732
|
+
summary
|
|
1733
|
+
}],
|
|
1734
|
+
kind: "leaf",
|
|
1735
|
+
name,
|
|
1736
|
+
notes: ["Telemetry records command paths, option names, failure reasons, and exit codes, never values, paths, or remote data. SANDCOVERY_TELEMETRY_DISABLED=1 turns it off and wins over this setting."],
|
|
1737
|
+
options: [json],
|
|
1738
|
+
result: [{
|
|
1739
|
+
name: "telemetry.enabled",
|
|
1740
|
+
type: "boolean"
|
|
1741
|
+
}, {
|
|
1742
|
+
name: "telemetry.source",
|
|
1743
|
+
type: "\"default\" | \"environment\" | \"settings\""
|
|
1744
|
+
}],
|
|
1745
|
+
summary
|
|
1746
|
+
});
|
|
1747
|
+
const help = {
|
|
1748
|
+
children: [{
|
|
1749
|
+
arguments: [{
|
|
1750
|
+
missing: {
|
|
1751
|
+
message: "Can't search commands without a query.",
|
|
1752
|
+
reason: "missing_query"
|
|
1753
|
+
},
|
|
1754
|
+
name: "query",
|
|
1755
|
+
summary: "Words to look for",
|
|
1756
|
+
variadic: true
|
|
1757
|
+
}],
|
|
1758
|
+
examples: [{
|
|
1759
|
+
argv: [
|
|
1760
|
+
"help",
|
|
1761
|
+
"search",
|
|
1762
|
+
"destroy"
|
|
1763
|
+
],
|
|
1764
|
+
summary: "Find the command for a task"
|
|
1765
|
+
}],
|
|
1766
|
+
kind: "leaf",
|
|
1767
|
+
name: "search",
|
|
1768
|
+
notes: ["Matches summaries, command names, and examples, works offline, and prints up to 10 commands."],
|
|
1769
|
+
options: [json],
|
|
1770
|
+
result: [{
|
|
1771
|
+
name: "commands[].path",
|
|
1772
|
+
type: "string"
|
|
1773
|
+
}, {
|
|
1774
|
+
name: "commands[].summary",
|
|
1775
|
+
type: "string"
|
|
1776
|
+
}],
|
|
1777
|
+
summary: "Find commands by task"
|
|
1778
|
+
}],
|
|
1779
|
+
kind: "group",
|
|
1780
|
+
name: "help",
|
|
1781
|
+
options: [flag({
|
|
1782
|
+
name: "all",
|
|
1783
|
+
summary: "List every command"
|
|
1784
|
+
})],
|
|
1785
|
+
summary: "Show help for a command"
|
|
1786
|
+
};
|
|
1787
|
+
const CLI = {
|
|
1788
|
+
bin: BIN,
|
|
1789
|
+
globals: [
|
|
1790
|
+
flag({
|
|
1791
|
+
name: "debug",
|
|
1792
|
+
short: "d",
|
|
1793
|
+
summary: "Print diagnostic detail on stderr, with secrets left out"
|
|
1794
|
+
}),
|
|
1795
|
+
{
|
|
1796
|
+
defaultText: "~/.config/sandcovery",
|
|
1797
|
+
hint: "<DIR>",
|
|
1798
|
+
kind: "value",
|
|
1799
|
+
name: "global-config",
|
|
1800
|
+
short: "Q",
|
|
1801
|
+
summary: "Directory that holds the CLI settings"
|
|
1802
|
+
},
|
|
1803
|
+
flag({
|
|
1804
|
+
name: "help",
|
|
1805
|
+
short: "h",
|
|
1806
|
+
summary: "Show help for the command and do nothing else"
|
|
1807
|
+
}),
|
|
1808
|
+
flag({
|
|
1809
|
+
name: "no-color",
|
|
1810
|
+
summary: "Turn off color"
|
|
1811
|
+
}),
|
|
1812
|
+
flag({
|
|
1813
|
+
name: "non-interactive",
|
|
1814
|
+
summary: "Never prompt; fail and name the missing input instead"
|
|
1815
|
+
}),
|
|
1816
|
+
{
|
|
1817
|
+
hint: "<KEY>",
|
|
1818
|
+
kind: "value",
|
|
1819
|
+
name: "token",
|
|
1820
|
+
short: "t",
|
|
1821
|
+
summary: "API key or management key to authenticate with; prefer SANDCOVERY_API_KEY, since options show in process lists"
|
|
1822
|
+
},
|
|
1823
|
+
flag({
|
|
1824
|
+
name: "version",
|
|
1825
|
+
short: "v",
|
|
1826
|
+
summary: "Print the CLI version"
|
|
1827
|
+
})
|
|
1828
|
+
],
|
|
1829
|
+
learnMore: "https://www.sandcovery.com/docs",
|
|
1830
|
+
root: {
|
|
1831
|
+
children: [
|
|
1832
|
+
sandboxes,
|
|
1833
|
+
keys,
|
|
1834
|
+
credentials,
|
|
1835
|
+
providers,
|
|
1836
|
+
usage,
|
|
1837
|
+
activity,
|
|
1838
|
+
help,
|
|
1839
|
+
{
|
|
1840
|
+
children: [{
|
|
1841
|
+
children: [
|
|
1842
|
+
telemetryLeaf({
|
|
1843
|
+
name: "status",
|
|
1844
|
+
summary: "Show whether telemetry is on"
|
|
1845
|
+
}),
|
|
1846
|
+
telemetryLeaf({
|
|
1847
|
+
name: "enable",
|
|
1848
|
+
summary: "Turn telemetry on"
|
|
1849
|
+
}),
|
|
1850
|
+
telemetryLeaf({
|
|
1851
|
+
name: "disable",
|
|
1852
|
+
summary: "Turn telemetry off"
|
|
1853
|
+
})
|
|
1854
|
+
],
|
|
1855
|
+
kind: "group",
|
|
1856
|
+
name: "telemetry",
|
|
1857
|
+
summary: "Turn usage data on or off, or show its status"
|
|
1858
|
+
}],
|
|
1859
|
+
kind: "group",
|
|
1860
|
+
name: "cli",
|
|
1861
|
+
summary: "Change settings of this CLI"
|
|
1862
|
+
}
|
|
1863
|
+
],
|
|
1864
|
+
kind: "group",
|
|
1865
|
+
name: BIN,
|
|
1866
|
+
notes: [
|
|
1867
|
+
"SANDCOVERY_API_KEY holds an API key or management key from the dashboard; --token wins over it, an empty value counts as unset, and the CLI never saves it.",
|
|
1868
|
+
"SANDCOVERY_BASE_URL sets the origin; --base-url wins over it. SANDCOVERY_TELEMETRY_DISABLED=1 turns telemetry off. SANDCOVERY_GUIDANCE_DISABLED=1 hides optional next steps. SANDCOVERY_ACCESSIBLE=1 prints words instead of status glyphs.",
|
|
1869
|
+
"NO_COLOR or --no-color turns color off, FORCE_COLOR turns it on, and CI makes every command non-interactive."
|
|
1870
|
+
],
|
|
1871
|
+
summary: "Create, run, and destroy sandboxes on any provider with one key"
|
|
1872
|
+
},
|
|
1873
|
+
tasks: [
|
|
1874
|
+
{
|
|
1875
|
+
paths: [
|
|
1876
|
+
["sandboxes", "create"],
|
|
1877
|
+
["sandboxes", "exec"],
|
|
1878
|
+
["sandboxes", "list"],
|
|
1879
|
+
["sandboxes", "destroy"],
|
|
1880
|
+
["sandboxes", "files"]
|
|
1881
|
+
],
|
|
1882
|
+
title: "Sandboxes"
|
|
1883
|
+
},
|
|
1884
|
+
{
|
|
1885
|
+
paths: [
|
|
1886
|
+
["providers", "list"],
|
|
1887
|
+
["usage", "estimate"],
|
|
1888
|
+
["usage", "inspect"]
|
|
1889
|
+
],
|
|
1890
|
+
title: "Providers and Cost"
|
|
1891
|
+
},
|
|
1892
|
+
{
|
|
1893
|
+
paths: [
|
|
1894
|
+
["keys"],
|
|
1895
|
+
["credentials"],
|
|
1896
|
+
["activity", "list"]
|
|
1897
|
+
],
|
|
1898
|
+
title: "Account"
|
|
1899
|
+
},
|
|
1900
|
+
{
|
|
1901
|
+
paths: [
|
|
1902
|
+
["help"],
|
|
1903
|
+
["help", "search"],
|
|
1904
|
+
["cli", "telemetry"]
|
|
1905
|
+
],
|
|
1906
|
+
title: "Help and Settings"
|
|
1907
|
+
}
|
|
1908
|
+
]
|
|
1909
|
+
};
|
|
1910
|
+
export { exitCodeOf as A, remoteText as C, isUpper as D, isDigits as E, usageFailure as M, Canceled as N, isWordCharacter as O, remoteLine as S, isDigit as T, plainPrefix as _, closest as a, escapeUnprintable as b, lastValue as c, readOptionToken as d, rerunArgv as f, glyph as g, ellipsis as h, version as i, statusOf as j, CliFailure as k, parseFailure as l, clearLine as m, CLEARABLE as n, flagOf as o, valuesOf as p, CLI as r, isOptionToken as s, BIN as t, parseLeaf as u, spinnerFrame as v, consistsOf as w, remoteCell as x, theme as y };
|