@vercel/sandbox 1.1.9 → 1.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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +13 -13
- package/.turbo/turbo-typecheck.log +1 -1
- package/CHANGELOG.md +10 -0
- package/dist/api-client/api-client.d.ts +18 -13
- package/dist/api-client/api-client.js +39 -0
- package/dist/api-client/api-client.js.map +1 -1
- package/dist/api-client/validators.d.ts +1 -0
- package/dist/api-client/validators.js.map +1 -1
- package/dist/sandbox.d.ts +39 -5
- package/dist/sandbox.js +111 -23
- package/dist/sandbox.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/api-client/api-client.test.ts +52 -0
- package/src/api-client/api-client.ts +73 -1
- package/src/api-client/validators.ts +2 -0
- package/src/sandbox.test.ts +79 -1
- package/src/sandbox.ts +129 -24
- package/src/version.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
|
|
2
|
-
> @vercel/sandbox@1.
|
|
2
|
+
> @vercel/sandbox@1.2.0 test /home/runner/work/sandbox-sdk/sandbox-sdk/packages/vercel-sandbox
|
|
3
3
|
> vitest run
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
[1m[46m RUN [49m[22m [36mv3.2.1 [39m[90m/home/runner/work/sandbox-sdk/sandbox-sdk/packages/vercel-sandbox[39m
|
|
7
7
|
|
|
8
|
-
[32m✓[39m src/utils/dev-credentials.test.ts [2m([22m[2m7 tests[22m[2m)[22m[33m
|
|
9
|
-
[33m[2m✓[22m[39m signInAndGetToken[2m > [22mtimes out after provided timeout [33m
|
|
10
|
-
[32m✓[39m src/api-client/api-client.test.ts [2m([22m[
|
|
11
|
-
[
|
|
12
|
-
[32m✓[39m src/
|
|
13
|
-
[
|
|
14
|
-
[32m✓[39m src/utils/normalizePath.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m
|
|
8
|
+
[32m✓[39m src/utils/dev-credentials.test.ts [2m([22m[2m7 tests[22m[2m)[22m[33m 579[2mms[22m[39m
|
|
9
|
+
[33m[2m✓[22m[39m signInAndGetToken[2m > [22mtimes out after provided timeout [33m 548[2mms[22m[39m
|
|
10
|
+
[32m✓[39m src/api-client/api-client.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 105[2mms[22m[39m
|
|
11
|
+
[2m[90m↓[39m[22m src/sandbox.test.ts [2m([22m[2m9 tests[22m[2m | [22m[33m9 skipped[39m[2m)[22m
|
|
12
|
+
[32m✓[39m src/auth/infer-scope.test.ts [2m([22m[2m9 tests[22m[2m)[22m[32m 41[2mms[22m[39m
|
|
13
|
+
[32m✓[39m src/utils/jwt-expiry.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m 33[2mms[22m[39m
|
|
14
|
+
[32m✓[39m src/utils/normalizePath.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 35[2mms[22m[39m
|
|
15
15
|
[2m[90m↓[39m[22m src/command.test.ts [2m([22m[2m5 tests[22m[2m | [22m[33m5 skipped[39m[2m)[22m
|
|
16
16
|
[32m✓[39m src/auth/linked-project.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 31[2mms[22m[39m
|
|
17
|
-
[32m✓[39m src/utils/get-credentials.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m
|
|
18
|
-
[32m✓[39m src/utils/types.test.js [2m([22m[2m1 test[22m[2m)[22m[32m
|
|
17
|
+
[32m✓[39m src/utils/get-credentials.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 36[2mms[22m[39m
|
|
18
|
+
[32m✓[39m src/utils/types.test.js [2m([22m[2m1 test[22m[2m)[22m[32m 8[2mms[22m[39m
|
|
19
19
|
|
|
20
20
|
[2m Test Files [22m [1m[32m8 passed[39m[22m[2m | [22m[33m2 skipped[39m[90m (10)[39m
|
|
21
|
-
[2m Tests [22m [1m[
|
|
22
|
-
[2m Start at [22m
|
|
23
|
-
[2m Duration [22m 12.
|
|
21
|
+
[2m Tests [22m [1m[32m49 passed[39m[22m[2m | [22m[33m14 skipped[39m[90m (63)[39m
|
|
22
|
+
[2m Start at [22m 13:53:38
|
|
23
|
+
[2m Duration [22m 12.73s[2m (transform 1.03s, setup 337ms, collect 3.25s, tests 868ms, environment 3ms, prepare 3.00s)[22m
|
|
24
24
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @vercel/sandbox
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Adds two methods for interacting with files: `Sandbox#readFileToBuffer` and `Sandbox#downloadFile` ([#236](https://github.com/vercel/sandbox-sdk/pull/236))
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Improve performance of `runCommand` when not using `detached` ([#243](https://github.com/vercel/sandbox-sdk/pull/243))
|
|
12
|
+
|
|
3
13
|
## 1.1.9
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BaseClient, type Parsed, type RequestParams } from "./base-client";
|
|
2
|
-
import { SandboxResponse, CommandResponse, CommandFinishedResponse, LogLineStdout, LogLineStderr, ExtendTimeoutResponse, SnapshotResponse, CreateSnapshotResponse } from "./validators";
|
|
2
|
+
import { CommandFinishedData, SandboxResponse, CommandResponse, CommandFinishedResponse, LogLineStdout, LogLineStderr, ExtendTimeoutResponse, SnapshotResponse, CreateSnapshotResponse, type CommandData } from "./validators";
|
|
3
3
|
import { FileWriter } from "./file-writer";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
+
import { Readable } from "stream";
|
|
5
6
|
import { WithPrivate } from "../utils/types";
|
|
6
7
|
import { RUNTIMES } from "../constants";
|
|
7
8
|
export interface WithFetchOptions {
|
|
@@ -105,18 +106,22 @@ export declare class APIClient extends BaseClient {
|
|
|
105
106
|
args: string[];
|
|
106
107
|
env: Record<string, string>;
|
|
107
108
|
sudo: boolean;
|
|
109
|
+
wait: true;
|
|
108
110
|
signal?: AbortSignal;
|
|
109
|
-
}): Promise<
|
|
110
|
-
command:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
}): Promise<{
|
|
112
|
+
command: CommandData;
|
|
113
|
+
finished: Promise<CommandFinishedData>;
|
|
114
|
+
}>;
|
|
115
|
+
runCommand(params: {
|
|
116
|
+
sandboxId: string;
|
|
117
|
+
cwd?: string;
|
|
118
|
+
command: string;
|
|
119
|
+
args: string[];
|
|
120
|
+
env: Record<string, string>;
|
|
121
|
+
sudo: boolean;
|
|
122
|
+
wait?: false;
|
|
123
|
+
signal?: AbortSignal;
|
|
124
|
+
}): Promise<Parsed<z.infer<typeof CommandResponse>>>;
|
|
120
125
|
getCommand(params: {
|
|
121
126
|
sandboxId: string;
|
|
122
127
|
cmdId: string;
|
|
@@ -207,7 +212,7 @@ export declare class APIClient extends BaseClient {
|
|
|
207
212
|
path: string;
|
|
208
213
|
cwd?: string;
|
|
209
214
|
signal?: AbortSignal;
|
|
210
|
-
}): Promise<
|
|
215
|
+
}): Promise<Readable | null>;
|
|
211
216
|
killCommand(params: {
|
|
212
217
|
sandboxId: string;
|
|
213
218
|
commandId: string;
|
|
@@ -78,6 +78,45 @@ class APIClient extends base_client_1.BaseClient {
|
|
|
78
78
|
}));
|
|
79
79
|
}
|
|
80
80
|
async runCommand(params) {
|
|
81
|
+
if (params.wait) {
|
|
82
|
+
const response = await this.request(`/v1/sandboxes/${params.sandboxId}/cmd`, {
|
|
83
|
+
method: "POST",
|
|
84
|
+
body: JSON.stringify({
|
|
85
|
+
command: params.command,
|
|
86
|
+
args: params.args,
|
|
87
|
+
cwd: params.cwd,
|
|
88
|
+
env: params.env,
|
|
89
|
+
sudo: params.sudo,
|
|
90
|
+
wait: true,
|
|
91
|
+
}),
|
|
92
|
+
signal: params.signal,
|
|
93
|
+
});
|
|
94
|
+
if (response.headers.get("content-type") !== "application/x-ndjson") {
|
|
95
|
+
throw new api_error_1.APIError(response, {
|
|
96
|
+
message: "Expected a stream of command data",
|
|
97
|
+
sandboxId: params.sandboxId,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (response.body === null) {
|
|
101
|
+
throw new api_error_1.APIError(response, {
|
|
102
|
+
message: "No response body",
|
|
103
|
+
sandboxId: params.sandboxId,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const jsonlinesStream = jsonlines_1.default.parse();
|
|
107
|
+
pipe(response.body, jsonlinesStream).catch((err) => {
|
|
108
|
+
console.error("Error piping command stream:", err);
|
|
109
|
+
});
|
|
110
|
+
const iterator = jsonlinesStream[Symbol.asyncIterator]();
|
|
111
|
+
const commandChunk = await iterator.next();
|
|
112
|
+
const { command } = validators_1.CommandResponse.parse(commandChunk.value);
|
|
113
|
+
const finished = (async () => {
|
|
114
|
+
const finishedChunk = await iterator.next();
|
|
115
|
+
const { command } = validators_1.CommandFinishedResponse.parse(finishedChunk.value);
|
|
116
|
+
return command;
|
|
117
|
+
})();
|
|
118
|
+
return { command, finished };
|
|
119
|
+
}
|
|
81
120
|
return (0, base_client_1.parseOrThrow)(validators_1.CommandResponse, await this.request(`/v1/sandboxes/${params.sandboxId}/cmd`, {
|
|
82
121
|
method: "POST",
|
|
83
122
|
body: JSON.stringify({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../src/api-client/api-client.ts"],"names":[],"mappings":";;;;;;AAAA,+CAKuB;AACvB,6CAasB;AACtB,2CAAoD;AACpD,+CAA2C;AAC3C,wCAAqC;AACrC,gEAA4D;AAE5D,0DAAkC;AAClC,4CAAoB;AACpB,mCAAkC;AAClC,0DAAuD;AACvD,oDA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AAE,CAAC;QACb,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC5B,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,GAAG,EAAE,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,GAAG,OAAwC;IAC/D,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,UAAU,CAAC,KAAK,EAAE,CAAC;QACnB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC,CAAC;IACF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,UAAU,CAAC,KAAK,EAAE,CAAC;YACnB,MAAM;QACR,CAAC;QACD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,UAAU,CAAC,MAAM,CAAC;AAC3B,CAAC"}
|
|
@@ -427,6 +427,7 @@ export declare const CommandResponse: z.ZodObject<{
|
|
|
427
427
|
exitCode: number | null;
|
|
428
428
|
};
|
|
429
429
|
}>;
|
|
430
|
+
export type CommandFinishedData = z.infer<typeof CommandFinishedResponse>["command"];
|
|
430
431
|
export declare const CommandFinishedResponse: z.ZodObject<{
|
|
431
432
|
command: z.ZodObject<{
|
|
432
433
|
id: z.ZodString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/api-client/validators.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAIX,QAAA,OAAO,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9B,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;IACd,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;IAClB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AAI,EAAE,OAAC,CAAC,MAAM,CAAC;QACb,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;QAChB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;KACpB,CAAC;CACH,CAAC,CAAC;AAEU,QAAA,OAAO,GAAG,OAAC,CAAC,kBAAkB,CAAC,QAAQ,EAAE;IACpD,qBAAa;IACb,qBAAa;IACb,gBAAQ;CACT,CAAC,CAAC;AAEU,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,SAAS,EAAE,OAAC,CAAC,KAAK,CAAC,eAAO,CAAC;IAC3B,UAAU,EAAE,kBAAU;CACvB,CAAC,CAAC;AAEU,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,OAAO,EAAE,eAAO;CACjB,CAAC,CAAC;AAEU,QAAA,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC7C,QAAQ,EAAE,gBAAQ;IAClB,OAAO,EAAE,eAAO;CACjB,CAAC,CAAC;AAEU,QAAA,gBAAgB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,QAAQ,EAAE,gBAAQ;CACnB,CAAC,CAAC"}
|
package/dist/sandbox.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SandboxMetaData, SandboxRouteData } from "./api-client";
|
|
2
|
-
import type
|
|
2
|
+
import { type Writable } from "stream";
|
|
3
3
|
import { APIClient } from "./api-client";
|
|
4
|
-
import { Command,
|
|
4
|
+
import { Command, CommandFinished } from "./command";
|
|
5
5
|
import { type Credentials } from "./utils/get-credentials";
|
|
6
6
|
import { WithPrivate } from "./utils/types";
|
|
7
7
|
import { WithFetchOptions } from "./api-client/api-client";
|
|
@@ -266,7 +266,7 @@ export declare class Sandbox {
|
|
|
266
266
|
* @returns A {@link Command} or {@link CommandFinished}, depending on `detached`.
|
|
267
267
|
* @internal
|
|
268
268
|
*/
|
|
269
|
-
_runCommand(params: RunCommandParams): Promise<Command
|
|
269
|
+
_runCommand(params: RunCommandParams): Promise<Command>;
|
|
270
270
|
/**
|
|
271
271
|
* Create a directory in the filesystem of this sandbox.
|
|
272
272
|
*
|
|
@@ -278,12 +278,12 @@ export declare class Sandbox {
|
|
|
278
278
|
signal?: AbortSignal;
|
|
279
279
|
}): Promise<void>;
|
|
280
280
|
/**
|
|
281
|
-
* Read a file from the filesystem of this sandbox.
|
|
281
|
+
* Read a file from the filesystem of this sandbox as a stream.
|
|
282
282
|
*
|
|
283
283
|
* @param file - File to read, with path and optional cwd
|
|
284
284
|
* @param opts - Optional parameters.
|
|
285
285
|
* @param opts.signal - An AbortSignal to cancel the operation.
|
|
286
|
-
* @returns A promise that resolves to a ReadableStream containing the file contents
|
|
286
|
+
* @returns A promise that resolves to a ReadableStream containing the file contents, or null if file not found
|
|
287
287
|
*/
|
|
288
288
|
readFile(file: {
|
|
289
289
|
path: string;
|
|
@@ -291,6 +291,40 @@ export declare class Sandbox {
|
|
|
291
291
|
}, opts?: {
|
|
292
292
|
signal?: AbortSignal;
|
|
293
293
|
}): Promise<NodeJS.ReadableStream | null>;
|
|
294
|
+
/**
|
|
295
|
+
* Read a file from the filesystem of this sandbox as a Buffer.
|
|
296
|
+
*
|
|
297
|
+
* @param file - File to read, with path and optional cwd
|
|
298
|
+
* @param opts - Optional parameters.
|
|
299
|
+
* @param opts.signal - An AbortSignal to cancel the operation.
|
|
300
|
+
* @returns A promise that resolves to the file contents as a Buffer, or null if file not found
|
|
301
|
+
*/
|
|
302
|
+
readFileToBuffer(file: {
|
|
303
|
+
path: string;
|
|
304
|
+
cwd?: string;
|
|
305
|
+
}, opts?: {
|
|
306
|
+
signal?: AbortSignal;
|
|
307
|
+
}): Promise<Buffer | null>;
|
|
308
|
+
/**
|
|
309
|
+
* Download a file from the sandbox to the local filesystem.
|
|
310
|
+
*
|
|
311
|
+
* @param src - Source file on the sandbox, with path and optional cwd
|
|
312
|
+
* @param dst - Destination file on the local machine, with path and optional cwd
|
|
313
|
+
* @param opts - Optional parameters.
|
|
314
|
+
* @param opts.mkdirRecursive - If true, create parent directories for the destination if they don't exist.
|
|
315
|
+
* @param opts.signal - An AbortSignal to cancel the operation.
|
|
316
|
+
* @returns The absolute path to the written file, or null if the source file was not found
|
|
317
|
+
*/
|
|
318
|
+
downloadFile(src: {
|
|
319
|
+
path: string;
|
|
320
|
+
cwd?: string;
|
|
321
|
+
}, dst: {
|
|
322
|
+
path: string;
|
|
323
|
+
cwd?: string;
|
|
324
|
+
}, opts?: {
|
|
325
|
+
mkdirRecursive?: boolean;
|
|
326
|
+
signal?: AbortSignal;
|
|
327
|
+
}): Promise<string | null>;
|
|
294
328
|
/**
|
|
295
329
|
* Write files to the filesystem of this sandbox.
|
|
296
330
|
* Defaults to writing to /vercel/sandbox unless an absolute path is specified.
|
package/dist/sandbox.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Sandbox = void 0;
|
|
4
|
+
const promises_1 = require("stream/promises");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const promises_2 = require("fs/promises");
|
|
7
|
+
const path_1 = require("path");
|
|
4
8
|
const api_client_1 = require("./api-client");
|
|
5
9
|
const command_1 = require("./command");
|
|
6
10
|
const get_credentials_1 = require("./utils/get-credentials");
|
|
7
11
|
const types_1 = require("./utils/types");
|
|
8
12
|
const snapshot_1 = require("./snapshot");
|
|
13
|
+
const consume_readable_1 = require("./utils/consume-readable");
|
|
9
14
|
/**
|
|
10
15
|
* A Sandbox is an isolated Linux MicroVM to run commands in.
|
|
11
16
|
*
|
|
@@ -169,6 +174,54 @@ class Sandbox {
|
|
|
169
174
|
* @internal
|
|
170
175
|
*/
|
|
171
176
|
async _runCommand(params) {
|
|
177
|
+
const wait = params.detached ? false : true;
|
|
178
|
+
const getLogs = (command) => {
|
|
179
|
+
if (params.stdout || params.stderr) {
|
|
180
|
+
(async () => {
|
|
181
|
+
try {
|
|
182
|
+
for await (const log of command.logs({ signal: params.signal })) {
|
|
183
|
+
if (log.stream === "stdout") {
|
|
184
|
+
params.stdout?.write(log.data);
|
|
185
|
+
}
|
|
186
|
+
else if (log.stream === "stderr") {
|
|
187
|
+
params.stderr?.write(log.data);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
catch (err) {
|
|
192
|
+
if (params.signal?.aborted) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
throw err;
|
|
196
|
+
}
|
|
197
|
+
})();
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
if (wait) {
|
|
201
|
+
const commandStream = await this.client.runCommand({
|
|
202
|
+
sandboxId: this.sandbox.id,
|
|
203
|
+
command: params.cmd,
|
|
204
|
+
args: params.args ?? [],
|
|
205
|
+
cwd: params.cwd,
|
|
206
|
+
env: params.env ?? {},
|
|
207
|
+
sudo: params.sudo ?? false,
|
|
208
|
+
wait: true,
|
|
209
|
+
signal: params.signal,
|
|
210
|
+
});
|
|
211
|
+
const command = new command_1.Command({
|
|
212
|
+
client: this.client,
|
|
213
|
+
sandboxId: this.sandbox.id,
|
|
214
|
+
cmd: commandStream.command,
|
|
215
|
+
});
|
|
216
|
+
getLogs(command);
|
|
217
|
+
const finished = await commandStream.finished;
|
|
218
|
+
return new command_1.CommandFinished({
|
|
219
|
+
client: this.client,
|
|
220
|
+
sandboxId: this.sandbox.id,
|
|
221
|
+
cmd: finished,
|
|
222
|
+
exitCode: finished.exitCode ?? 0,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
172
225
|
const commandResponse = await this.client.runCommand({
|
|
173
226
|
sandboxId: this.sandbox.id,
|
|
174
227
|
command: params.cmd,
|
|
@@ -183,27 +236,8 @@ class Sandbox {
|
|
|
183
236
|
sandboxId: this.sandbox.id,
|
|
184
237
|
cmd: commandResponse.json.command,
|
|
185
238
|
});
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
try {
|
|
189
|
-
for await (const log of command.logs({ signal: params.signal })) {
|
|
190
|
-
if (log.stream === "stdout") {
|
|
191
|
-
params.stdout?.write(log.data);
|
|
192
|
-
}
|
|
193
|
-
else if (log.stream === "stderr") {
|
|
194
|
-
params.stderr?.write(log.data);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
catch (err) {
|
|
199
|
-
if (params.signal?.aborted) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
throw err;
|
|
203
|
-
}
|
|
204
|
-
})();
|
|
205
|
-
}
|
|
206
|
-
return params.detached ? command : command.wait({ signal: params.signal });
|
|
239
|
+
getLogs(command);
|
|
240
|
+
return command;
|
|
207
241
|
}
|
|
208
242
|
/**
|
|
209
243
|
* Create a directory in the filesystem of this sandbox.
|
|
@@ -220,12 +254,12 @@ class Sandbox {
|
|
|
220
254
|
});
|
|
221
255
|
}
|
|
222
256
|
/**
|
|
223
|
-
* Read a file from the filesystem of this sandbox.
|
|
257
|
+
* Read a file from the filesystem of this sandbox as a stream.
|
|
224
258
|
*
|
|
225
259
|
* @param file - File to read, with path and optional cwd
|
|
226
260
|
* @param opts - Optional parameters.
|
|
227
261
|
* @param opts.signal - An AbortSignal to cancel the operation.
|
|
228
|
-
* @returns A promise that resolves to a ReadableStream containing the file contents
|
|
262
|
+
* @returns A promise that resolves to a ReadableStream containing the file contents, or null if file not found
|
|
229
263
|
*/
|
|
230
264
|
async readFile(file, opts) {
|
|
231
265
|
return this.client.readFile({
|
|
@@ -235,6 +269,60 @@ class Sandbox {
|
|
|
235
269
|
signal: opts?.signal,
|
|
236
270
|
});
|
|
237
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* Read a file from the filesystem of this sandbox as a Buffer.
|
|
274
|
+
*
|
|
275
|
+
* @param file - File to read, with path and optional cwd
|
|
276
|
+
* @param opts - Optional parameters.
|
|
277
|
+
* @param opts.signal - An AbortSignal to cancel the operation.
|
|
278
|
+
* @returns A promise that resolves to the file contents as a Buffer, or null if file not found
|
|
279
|
+
*/
|
|
280
|
+
async readFileToBuffer(file, opts) {
|
|
281
|
+
const stream = await this.client.readFile({
|
|
282
|
+
sandboxId: this.sandbox.id,
|
|
283
|
+
path: file.path,
|
|
284
|
+
cwd: file.cwd,
|
|
285
|
+
signal: opts?.signal,
|
|
286
|
+
});
|
|
287
|
+
if (stream === null) {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
return (0, consume_readable_1.consumeReadable)(stream);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Download a file from the sandbox to the local filesystem.
|
|
294
|
+
*
|
|
295
|
+
* @param src - Source file on the sandbox, with path and optional cwd
|
|
296
|
+
* @param dst - Destination file on the local machine, with path and optional cwd
|
|
297
|
+
* @param opts - Optional parameters.
|
|
298
|
+
* @param opts.mkdirRecursive - If true, create parent directories for the destination if they don't exist.
|
|
299
|
+
* @param opts.signal - An AbortSignal to cancel the operation.
|
|
300
|
+
* @returns The absolute path to the written file, or null if the source file was not found
|
|
301
|
+
*/
|
|
302
|
+
async downloadFile(src, dst, opts) {
|
|
303
|
+
const stream = await this.client.readFile({
|
|
304
|
+
sandboxId: this.sandbox.id,
|
|
305
|
+
path: src.path,
|
|
306
|
+
cwd: src.cwd,
|
|
307
|
+
signal: opts?.signal,
|
|
308
|
+
});
|
|
309
|
+
if (stream === null) {
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
try {
|
|
313
|
+
const dstPath = (0, path_1.resolve)(dst.cwd ?? "", dst.path);
|
|
314
|
+
if (opts?.mkdirRecursive) {
|
|
315
|
+
await (0, promises_2.mkdir)((0, path_1.dirname)(dstPath), { recursive: true });
|
|
316
|
+
}
|
|
317
|
+
await (0, promises_1.pipeline)(stream, (0, fs_1.createWriteStream)(dstPath), {
|
|
318
|
+
signal: opts?.signal,
|
|
319
|
+
});
|
|
320
|
+
return dstPath;
|
|
321
|
+
}
|
|
322
|
+
finally {
|
|
323
|
+
stream.destroy();
|
|
324
|
+
}
|
|
325
|
+
}
|
|
238
326
|
/**
|
|
239
327
|
* Write files to the filesystem of this sandbox.
|
|
240
328
|
* Defaults to writing to /vercel/sandbox unless an absolute path is specified.
|
package/dist/sandbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":";;;AAEA,6CAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":";;;AAEA,8CAA2C;AAC3C,2BAAuC;AACvC,0CAAoC;AACpC,+BAA8C;AAC9C,6CAAyC;AACzC,uCAAqD;AACrD,6DAA2E;AAC3E,yCAA8D;AAG9D,yCAAsC;AACtC,+DAA2D;AAoH3D;;;;;GAKG;AACH,MAAa,OAAO;IASlB;;OAEG;IACH,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;IACzB,CAAC;IAED,IAAW,eAAe;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,IAAI,SAAS,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAClB,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAW,gBAAgB;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC;IACvC,CAAC;IAOD;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,CACf,MAEkB;QAElB,MAAM,WAAW,GAAG,MAAM,IAAA,gCAAc,EAAC,MAAM,CAAC,CAAC;QACjD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C,OAAO,CAAC;IACvC,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,QAAQ,CAAC,IAA+B;QAC5C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;YAChD,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE;YAC1B,MAAM,EAAE,IAAI,EAAE,MAAM;SACrB,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;QAErC,OAAO,IAAI,mBAAQ,CAAC;YAClB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;SACjC,CAAC,CAAC;IACL,CAAC;CACF;AA9gBD,0BA8gBC;AAED;;;;;;;;GAQG;AACH,MAAM,iBAAkB,SAAQ,OAAO;IACrC,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;IACpB,CAAC;CACF"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.2.0";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -173,4 +173,56 @@ describe("APIClient", () => {
|
|
|
173
173
|
}
|
|
174
174
|
});
|
|
175
175
|
});
|
|
176
|
+
|
|
177
|
+
describe("runCommand", () => {
|
|
178
|
+
let client: APIClient;
|
|
179
|
+
let mockFetch: ReturnType<typeof vi.fn>;
|
|
180
|
+
|
|
181
|
+
beforeEach(() => {
|
|
182
|
+
mockFetch = vi.fn();
|
|
183
|
+
client = new APIClient({
|
|
184
|
+
teamId: "team_123",
|
|
185
|
+
token: "1234",
|
|
186
|
+
fetch: mockFetch,
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it("streams command data when wait is true", async () => {
|
|
191
|
+
const first = {
|
|
192
|
+
command: {
|
|
193
|
+
id: "cmd_123",
|
|
194
|
+
name: "echo",
|
|
195
|
+
args: ["hello"],
|
|
196
|
+
cwd: "/",
|
|
197
|
+
sandboxId: "sbx_123",
|
|
198
|
+
exitCode: null,
|
|
199
|
+
startedAt: 1,
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
const second = {
|
|
203
|
+
command: {
|
|
204
|
+
...first.command,
|
|
205
|
+
exitCode: 0,
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
mockFetch.mockResolvedValue(
|
|
210
|
+
new Response(createNdjsonStream([first, second]), {
|
|
211
|
+
headers: { "content-type": "application/x-ndjson" },
|
|
212
|
+
}),
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
const result = await client.runCommand({
|
|
216
|
+
sandboxId: "sbx_123",
|
|
217
|
+
command: "echo",
|
|
218
|
+
args: ["hello"],
|
|
219
|
+
env: {},
|
|
220
|
+
sudo: false,
|
|
221
|
+
wait: true,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
expect(result.command.exitCode).toBeNull();
|
|
225
|
+
await expect(result.finished).resolves.toMatchObject({ exitCode: 0 });
|
|
226
|
+
});
|
|
227
|
+
});
|
|
176
228
|
});
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
type RequestParams,
|
|
6
6
|
} from "./base-client";
|
|
7
7
|
import {
|
|
8
|
+
CommandFinishedData,
|
|
8
9
|
SandboxAndRoutesResponse,
|
|
9
10
|
SandboxResponse,
|
|
10
11
|
CommandResponse,
|
|
@@ -17,6 +18,7 @@ import {
|
|
|
17
18
|
ExtendTimeoutResponse,
|
|
18
19
|
SnapshotResponse,
|
|
19
20
|
CreateSnapshotResponse,
|
|
21
|
+
type CommandData,
|
|
20
22
|
} from "./validators";
|
|
21
23
|
import { APIError, StreamError } from "./api-error";
|
|
22
24
|
import { FileWriter } from "./file-writer";
|
|
@@ -148,8 +150,78 @@ export class APIClient extends BaseClient {
|
|
|
148
150
|
args: string[];
|
|
149
151
|
env: Record<string, string>;
|
|
150
152
|
sudo: boolean;
|
|
153
|
+
wait: true;
|
|
154
|
+
signal?: AbortSignal;
|
|
155
|
+
}): Promise<{ command: CommandData; finished: Promise<CommandFinishedData> }>;
|
|
156
|
+
async runCommand(params: {
|
|
157
|
+
sandboxId: string;
|
|
158
|
+
cwd?: string;
|
|
159
|
+
command: string;
|
|
160
|
+
args: string[];
|
|
161
|
+
env: Record<string, string>;
|
|
162
|
+
sudo: boolean;
|
|
163
|
+
wait?: false;
|
|
164
|
+
signal?: AbortSignal;
|
|
165
|
+
}): Promise<Parsed<z.infer<typeof CommandResponse>>>;
|
|
166
|
+
async runCommand(params: {
|
|
167
|
+
sandboxId: string;
|
|
168
|
+
cwd?: string;
|
|
169
|
+
command: string;
|
|
170
|
+
args: string[];
|
|
171
|
+
env: Record<string, string>;
|
|
172
|
+
sudo: boolean;
|
|
173
|
+
wait?: boolean;
|
|
151
174
|
signal?: AbortSignal;
|
|
152
175
|
}) {
|
|
176
|
+
if (params.wait) {
|
|
177
|
+
const response = await this.request(
|
|
178
|
+
`/v1/sandboxes/${params.sandboxId}/cmd`,
|
|
179
|
+
{
|
|
180
|
+
method: "POST",
|
|
181
|
+
body: JSON.stringify({
|
|
182
|
+
command: params.command,
|
|
183
|
+
args: params.args,
|
|
184
|
+
cwd: params.cwd,
|
|
185
|
+
env: params.env,
|
|
186
|
+
sudo: params.sudo,
|
|
187
|
+
wait: true,
|
|
188
|
+
}),
|
|
189
|
+
signal: params.signal,
|
|
190
|
+
},
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
if (response.headers.get("content-type") !== "application/x-ndjson") {
|
|
194
|
+
throw new APIError(response, {
|
|
195
|
+
message: "Expected a stream of command data",
|
|
196
|
+
sandboxId: params.sandboxId,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (response.body === null) {
|
|
201
|
+
throw new APIError(response, {
|
|
202
|
+
message: "No response body",
|
|
203
|
+
sandboxId: params.sandboxId,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const jsonlinesStream = jsonlines.parse();
|
|
208
|
+
pipe(response.body, jsonlinesStream).catch((err) => {
|
|
209
|
+
console.error("Error piping command stream:", err);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
const iterator = jsonlinesStream[Symbol.asyncIterator]();
|
|
213
|
+
const commandChunk = await iterator.next();
|
|
214
|
+
const {Â command } = CommandResponse.parse(commandChunk.value);
|
|
215
|
+
|
|
216
|
+
const finished = (async () => {
|
|
217
|
+
const finishedChunk = await iterator.next();
|
|
218
|
+
const { command } = CommandFinishedResponse.parse(finishedChunk.value);
|
|
219
|
+
return command;
|
|
220
|
+
})();
|
|
221
|
+
|
|
222
|
+
return { command, finished };
|
|
223
|
+
}
|
|
224
|
+
|
|
153
225
|
return parseOrThrow(
|
|
154
226
|
CommandResponse,
|
|
155
227
|
await this.request(`/v1/sandboxes/${params.sandboxId}/cmd`, {
|
|
@@ -316,7 +388,7 @@ export class APIClient extends BaseClient {
|
|
|
316
388
|
path: string;
|
|
317
389
|
cwd?: string;
|
|
318
390
|
signal?: AbortSignal;
|
|
319
|
-
}): Promise<
|
|
391
|
+
}): Promise<Readable | null> {
|
|
320
392
|
const response = await this.request(
|
|
321
393
|
`/v1/sandboxes/${params.sandboxId}/fs/read`,
|
|
322
394
|
{
|
|
@@ -97,6 +97,8 @@ export const CommandResponse = z.object({
|
|
|
97
97
|
command: Command,
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
+
export type CommandFinishedData = z.infer<typeof CommandFinishedResponse>["command"];
|
|
101
|
+
|
|
100
102
|
export const CommandFinishedResponse = z.object({
|
|
101
103
|
command: CommandFinished,
|
|
102
104
|
});
|
package/src/sandbox.test.ts
CHANGED
|
@@ -2,6 +2,9 @@ import { it, beforeEach, afterEach, expect, describe } from "vitest";
|
|
|
2
2
|
import { consumeReadable } from "./utils/consume-readable";
|
|
3
3
|
import { Sandbox } from "./sandbox";
|
|
4
4
|
import { APIError } from "./api-client/api-error";
|
|
5
|
+
import { mkdtemp, readFile, rm } from "fs/promises";
|
|
6
|
+
import { tmpdir } from "os";
|
|
7
|
+
import { join, resolve } from "path";
|
|
5
8
|
import ms from "ms";
|
|
6
9
|
|
|
7
10
|
describe.skipIf(process.env.RUN_INTEGRATION_TESTS !== "1")("Sandbox", () => {
|
|
@@ -16,7 +19,7 @@ describe.skipIf(process.env.RUN_INTEGRATION_TESTS !== "1")("Sandbox", () => {
|
|
|
16
19
|
await sandbox.stop();
|
|
17
20
|
});
|
|
18
21
|
|
|
19
|
-
it("allows to write files and then read them", async () => {
|
|
22
|
+
it("allows to write files and then read them as a stream", async () => {
|
|
20
23
|
await sandbox.writeFiles([
|
|
21
24
|
{ path: "hello1.txt", content: Buffer.from("Hello 1") },
|
|
22
25
|
{ path: "hello2.txt", content: Buffer.from("Hello 2") },
|
|
@@ -28,6 +31,81 @@ describe.skipIf(process.env.RUN_INTEGRATION_TESTS !== "1")("Sandbox", () => {
|
|
|
28
31
|
expect((await consumeReadable(content2!)).toString()).toBe("Hello 2");
|
|
29
32
|
});
|
|
30
33
|
|
|
34
|
+
it("allows to write files and then read them to a buffer", async () => {
|
|
35
|
+
await sandbox.writeFiles([
|
|
36
|
+
{ path: "hello1.txt", content: Buffer.from("Hello 1") },
|
|
37
|
+
{ path: "hello2.txt", content: Buffer.from("Hello 2") },
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
const content1 = await sandbox.readFileToBuffer({ path: "hello1.txt" });
|
|
41
|
+
const content2 = await sandbox.readFileToBuffer({ path: "hello2.txt" });
|
|
42
|
+
expect(content1?.toString()).toBe("Hello 1");
|
|
43
|
+
expect(content2?.toString()).toBe("Hello 2");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("returns null when reading a non-existent file to buffer", async () => {
|
|
47
|
+
const content = await sandbox.readFileToBuffer({
|
|
48
|
+
path: "non-existent.txt",
|
|
49
|
+
});
|
|
50
|
+
expect(content).toBeNull();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("allows downloading a file from the sandbox", async () => {
|
|
54
|
+
const fileContent = "Hello from sandbox";
|
|
55
|
+
await sandbox.writeFiles([
|
|
56
|
+
{ path: "download-test.txt", content: Buffer.from(fileContent) },
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
const tmpDir = await mkdtemp(join(tmpdir(), "sandbox-test-"));
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
const result = await sandbox.downloadFile(
|
|
63
|
+
{ path: "download-test.txt" },
|
|
64
|
+
{ path: "downloaded.txt", cwd: tmpDir },
|
|
65
|
+
);
|
|
66
|
+
expect(result).toBe(resolve(tmpDir, "downloaded.txt"));
|
|
67
|
+
expect(await readFile(result!, "utf-8")).toBe(fileContent);
|
|
68
|
+
} finally {
|
|
69
|
+
await rm(tmpDir, { recursive: true });
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("returns null when downloading a non-existent file", async () => {
|
|
74
|
+
const tmpDir = await mkdtemp(join(tmpdir(), "sandbox-test-"));
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
const result = await sandbox.downloadFile(
|
|
78
|
+
{ path: "non-existent.txt" },
|
|
79
|
+
{ path: "should-not-exist.txt", cwd: tmpDir },
|
|
80
|
+
);
|
|
81
|
+
expect(result).toBeNull();
|
|
82
|
+
} finally {
|
|
83
|
+
await rm(tmpDir, { recursive: true });
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("creates parent directories when mkdirRecursive is true", async () => {
|
|
88
|
+
const fileContent = "Hello from sandbox";
|
|
89
|
+
await sandbox.writeFiles([
|
|
90
|
+
{ path: "download-test.txt", content: Buffer.from(fileContent) },
|
|
91
|
+
]);
|
|
92
|
+
|
|
93
|
+
const tmpDir = await mkdtemp(join(tmpdir(), "sandbox-test-"));
|
|
94
|
+
const nestedPath = join(tmpDir, "nested", "dir", "downloaded.txt");
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
const result = await sandbox.downloadFile(
|
|
98
|
+
{ path: "download-test.txt" },
|
|
99
|
+
{ path: nestedPath },
|
|
100
|
+
{ mkdirRecursive: true },
|
|
101
|
+
);
|
|
102
|
+
expect(result).toBe(nestedPath);
|
|
103
|
+
expect(await readFile(result!, "utf-8")).toBe(fileContent);
|
|
104
|
+
} finally {
|
|
105
|
+
await rm(tmpDir, { recursive: true });
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
31
109
|
it("verifies port forwarding works correctly", async () => {
|
|
32
110
|
const serverScript = `
|
|
33
111
|
const http = require('http');
|
package/src/sandbox.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import type { SandboxMetaData, SandboxRouteData } from "./api-client";
|
|
2
|
-
import type
|
|
2
|
+
import { type Writable } from "stream";
|
|
3
|
+
import { pipeline } from "stream/promises";
|
|
4
|
+
import { createWriteStream } from "fs";
|
|
5
|
+
import { mkdir } from "fs/promises";
|
|
6
|
+
import { dirname, join, resolve } from "path";
|
|
3
7
|
import { APIClient } from "./api-client";
|
|
4
|
-
import { Command,
|
|
8
|
+
import { Command, CommandFinished } from "./command";
|
|
5
9
|
import { type Credentials, getCredentials } from "./utils/get-credentials";
|
|
6
10
|
import { getPrivateParams, WithPrivate } from "./utils/types";
|
|
7
11
|
import { WithFetchOptions } from "./api-client/api-client";
|
|
8
12
|
import { RUNTIMES } from "./constants";
|
|
9
13
|
import { Snapshot } from "./snapshot";
|
|
14
|
+
import { consumeReadable } from "./utils/consume-readable";
|
|
10
15
|
|
|
11
16
|
/** @inline */
|
|
12
17
|
export interface BaseCreateSandboxParams {
|
|
@@ -375,6 +380,57 @@ export class Sandbox {
|
|
|
375
380
|
* @internal
|
|
376
381
|
*/
|
|
377
382
|
async _runCommand(params: RunCommandParams) {
|
|
383
|
+
const wait = params.detached ? false : true;
|
|
384
|
+
const getLogs = (command: Command) => {
|
|
385
|
+
if (params.stdout || params.stderr) {
|
|
386
|
+
(async () => {
|
|
387
|
+
try {
|
|
388
|
+
for await (const log of command.logs({ signal: params.signal })) {
|
|
389
|
+
if (log.stream === "stdout") {
|
|
390
|
+
params.stdout?.write(log.data);
|
|
391
|
+
} else if (log.stream === "stderr") {
|
|
392
|
+
params.stderr?.write(log.data);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
} catch (err) {
|
|
396
|
+
if (params.signal?.aborted) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
throw err;
|
|
400
|
+
}
|
|
401
|
+
})();
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
if (wait) {
|
|
406
|
+
const commandStream = await this.client.runCommand({
|
|
407
|
+
sandboxId: this.sandbox.id,
|
|
408
|
+
command: params.cmd,
|
|
409
|
+
args: params.args ?? [],
|
|
410
|
+
cwd: params.cwd,
|
|
411
|
+
env: params.env ?? {},
|
|
412
|
+
sudo: params.sudo ?? false,
|
|
413
|
+
wait: true,
|
|
414
|
+
signal: params.signal,
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
const command = new Command({
|
|
418
|
+
client: this.client,
|
|
419
|
+
sandboxId: this.sandbox.id,
|
|
420
|
+
cmd: commandStream.command,
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
getLogs(command);
|
|
424
|
+
|
|
425
|
+
const finished = await commandStream.finished;
|
|
426
|
+
return new CommandFinished({
|
|
427
|
+
client: this.client,
|
|
428
|
+
sandboxId: this.sandbox.id,
|
|
429
|
+
cmd: finished,
|
|
430
|
+
exitCode: finished.exitCode ?? 0,
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
|
|
378
434
|
const commandResponse = await this.client.runCommand({
|
|
379
435
|
sandboxId: this.sandbox.id,
|
|
380
436
|
command: params.cmd,
|
|
@@ -391,26 +447,9 @@ export class Sandbox {
|
|
|
391
447
|
cmd: commandResponse.json.command,
|
|
392
448
|
});
|
|
393
449
|
|
|
394
|
-
|
|
395
|
-
(async () => {
|
|
396
|
-
try {
|
|
397
|
-
for await (const log of command.logs({ signal: params.signal })) {
|
|
398
|
-
if (log.stream === "stdout") {
|
|
399
|
-
params.stdout?.write(log.data);
|
|
400
|
-
} else if (log.stream === "stderr") {
|
|
401
|
-
params.stderr?.write(log.data);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
} catch (err) {
|
|
405
|
-
if (params.signal?.aborted) {
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
throw err;
|
|
409
|
-
}
|
|
410
|
-
})();
|
|
411
|
-
}
|
|
450
|
+
getLogs(command);
|
|
412
451
|
|
|
413
|
-
return
|
|
452
|
+
return command;
|
|
414
453
|
}
|
|
415
454
|
|
|
416
455
|
/**
|
|
@@ -429,17 +468,17 @@ export class Sandbox {
|
|
|
429
468
|
}
|
|
430
469
|
|
|
431
470
|
/**
|
|
432
|
-
* Read a file from the filesystem of this sandbox.
|
|
471
|
+
* Read a file from the filesystem of this sandbox as a stream.
|
|
433
472
|
*
|
|
434
473
|
* @param file - File to read, with path and optional cwd
|
|
435
474
|
* @param opts - Optional parameters.
|
|
436
475
|
* @param opts.signal - An AbortSignal to cancel the operation.
|
|
437
|
-
* @returns A promise that resolves to a ReadableStream containing the file contents
|
|
476
|
+
* @returns A promise that resolves to a ReadableStream containing the file contents, or null if file not found
|
|
438
477
|
*/
|
|
439
478
|
async readFile(
|
|
440
479
|
file: { path: string; cwd?: string },
|
|
441
480
|
opts?: { signal?: AbortSignal },
|
|
442
|
-
) {
|
|
481
|
+
): Promise<NodeJS.ReadableStream | null> {
|
|
443
482
|
return this.client.readFile({
|
|
444
483
|
sandboxId: this.sandbox.id,
|
|
445
484
|
path: file.path,
|
|
@@ -448,6 +487,72 @@ export class Sandbox {
|
|
|
448
487
|
});
|
|
449
488
|
}
|
|
450
489
|
|
|
490
|
+
/**
|
|
491
|
+
* Read a file from the filesystem of this sandbox as a Buffer.
|
|
492
|
+
*
|
|
493
|
+
* @param file - File to read, with path and optional cwd
|
|
494
|
+
* @param opts - Optional parameters.
|
|
495
|
+
* @param opts.signal - An AbortSignal to cancel the operation.
|
|
496
|
+
* @returns A promise that resolves to the file contents as a Buffer, or null if file not found
|
|
497
|
+
*/
|
|
498
|
+
async readFileToBuffer(
|
|
499
|
+
file: { path: string; cwd?: string },
|
|
500
|
+
opts?: { signal?: AbortSignal },
|
|
501
|
+
): Promise<Buffer | null> {
|
|
502
|
+
const stream = await this.client.readFile({
|
|
503
|
+
sandboxId: this.sandbox.id,
|
|
504
|
+
path: file.path,
|
|
505
|
+
cwd: file.cwd,
|
|
506
|
+
signal: opts?.signal,
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
if (stream === null) {
|
|
510
|
+
return null;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
return consumeReadable(stream);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Download a file from the sandbox to the local filesystem.
|
|
518
|
+
*
|
|
519
|
+
* @param src - Source file on the sandbox, with path and optional cwd
|
|
520
|
+
* @param dst - Destination file on the local machine, with path and optional cwd
|
|
521
|
+
* @param opts - Optional parameters.
|
|
522
|
+
* @param opts.mkdirRecursive - If true, create parent directories for the destination if they don't exist.
|
|
523
|
+
* @param opts.signal - An AbortSignal to cancel the operation.
|
|
524
|
+
* @returns The absolute path to the written file, or null if the source file was not found
|
|
525
|
+
*/
|
|
526
|
+
async downloadFile(
|
|
527
|
+
src: { path: string; cwd?: string },
|
|
528
|
+
dst: { path: string; cwd?: string },
|
|
529
|
+
opts?: { mkdirRecursive?: boolean; signal?: AbortSignal },
|
|
530
|
+
): Promise<string | null> {
|
|
531
|
+
const stream = await this.client.readFile({
|
|
532
|
+
sandboxId: this.sandbox.id,
|
|
533
|
+
path: src.path,
|
|
534
|
+
cwd: src.cwd,
|
|
535
|
+
signal: opts?.signal,
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
if (stream === null) {
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
try {
|
|
543
|
+
const dstPath = resolve(dst.cwd ?? "", dst.path);
|
|
544
|
+
if (opts?.mkdirRecursive) {
|
|
545
|
+
await mkdir(dirname(dstPath), { recursive: true });
|
|
546
|
+
}
|
|
547
|
+
await pipeline(stream, createWriteStream(dstPath), {
|
|
548
|
+
signal: opts?.signal,
|
|
549
|
+
});
|
|
550
|
+
return dstPath;
|
|
551
|
+
} finally {
|
|
552
|
+
stream.destroy()
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
451
556
|
/**
|
|
452
557
|
* Write files to the filesystem of this sandbox.
|
|
453
558
|
* Defaults to writing to /vercel/sandbox unless an absolute path is specified.
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Autogenerated by inject-version.ts
|
|
2
|
-
export const VERSION = "1.
|
|
2
|
+
export const VERSION = "1.2.0";
|