@cloudflare/sandbox 0.5.2 → 0.5.3
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 +9 -9
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +19 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +56 -13
- package/dist/index.js.map +1 -1
- package/dist/openai/index.d.ts +1 -1
- package/dist/{sandbox-B3vJ541e.d.ts → sandbox-HQazw9bn.d.ts} +24 -12
- package/dist/sandbox-HQazw9bn.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/clients/command-client.ts +31 -13
- package/src/clients/process-client.ts +20 -2
- package/src/sandbox.ts +56 -9
- package/src/version.ts +1 -1
- package/tests/sandbox.test.ts +48 -24
- package/dist/sandbox-B3vJ541e.d.ts.map +0 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @cloudflare/sandbox@0.5.
|
|
2
|
+
> @cloudflare/sandbox@0.5.3 build
|
|
3
3
|
> rm -rf dist && tsdown --config tsdown.config.ts
|
|
4
4
|
|
|
5
5
|
[34mℹ[39m tsdown [2mv0.16.6[22m powered by rolldown [2mv1.0.0-beta.51[22m
|
|
@@ -7,17 +7,17 @@
|
|
|
7
7
|
[34mℹ[39m entry: [34msrc/index.ts, src/openai/index.ts[39m
|
|
8
8
|
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
9
9
|
[34mℹ[39m Build start
|
|
10
|
-
[34mℹ[39m [2mdist/[22m[1mindex.js[22m [
|
|
10
|
+
[34mℹ[39m [2mdist/[22m[1mindex.js[22m [2m102.82 kB[22m [2m│ gzip: 23.33 kB[22m
|
|
11
11
|
[34mℹ[39m [2mdist/[22m[1mopenai/index.js[22m [2m 10.42 kB[22m [2m│ gzip: 2.63 kB[22m
|
|
12
|
-
[34mℹ[39m [2mdist/[22mindex.js.map [
|
|
13
|
-
[34mℹ[39m [2mdist/[22msandbox-
|
|
12
|
+
[34mℹ[39m [2mdist/[22mindex.js.map [2m219.05 kB[22m [2m│ gzip: 48.46 kB[22m
|
|
13
|
+
[34mℹ[39m [2mdist/[22msandbox-HQazw9bn.d.ts.map [2m 61.69 kB[22m [2m│ gzip: 16.89 kB[22m
|
|
14
14
|
[34mℹ[39m [2mdist/[22mdist-gVyG2H2h.js.map [2m 30.14 kB[22m [2m│ gzip: 8.31 kB[22m
|
|
15
15
|
[34mℹ[39m [2mdist/[22mopenai/index.js.map [2m 21.00 kB[22m [2m│ gzip: 5.13 kB[22m
|
|
16
16
|
[34mℹ[39m [2mdist/[22mdist-gVyG2H2h.js [2m 17.03 kB[22m [2m│ gzip: 5.39 kB[22m
|
|
17
|
-
[34mℹ[39m [2mdist/[22mindex.d.ts.map [2m
|
|
17
|
+
[34mℹ[39m [2mdist/[22mindex.d.ts.map [2m 9.22 kB[22m [2m│ gzip: 2.82 kB[22m
|
|
18
18
|
[34mℹ[39m [2mdist/[22mopenai/index.d.ts.map [2m 0.72 kB[22m [2m│ gzip: 0.37 kB[22m
|
|
19
|
-
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.ts[22m[39m [2m
|
|
19
|
+
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.ts[22m[39m [2m 11.11 kB[22m [2m│ gzip: 3.32 kB[22m
|
|
20
20
|
[34mℹ[39m [2mdist/[22m[32m[1mopenai/index.d.ts[22m[39m [2m 2.10 kB[22m [2m│ gzip: 0.81 kB[22m
|
|
21
|
-
[34mℹ[39m [2mdist/[22m[32msandbox-
|
|
22
|
-
[34mℹ[39m 12 files, total:
|
|
23
|
-
[32m✔[39m Build complete in [
|
|
21
|
+
[34mℹ[39m [2mdist/[22m[32msandbox-HQazw9bn.d.ts[39m [2m 51.36 kB[22m [2m│ gzip: 11.79 kB[22m
|
|
22
|
+
[34mℹ[39m 12 files, total: 536.66 kB
|
|
23
|
+
[32m✔[39m Build complete in [32m3733ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @cloudflare/sandbox
|
|
2
2
|
|
|
3
|
+
## 0.5.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#204](https://github.com/cloudflare/sandbox-sdk/pull/204) [`55981f8`](https://github.com/cloudflare/sandbox-sdk/commit/55981f8802b4e0d3b65b947ef8ba7ae2bae183d7) Thanks [@whoiskatrin](https://github.com/whoiskatrin)! - add environment variables and working directory support to command exec
|
|
8
|
+
|
|
3
9
|
## 0.5.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as ProcessInfoResult, A as RequestConfig, B as FileChunk, C as WriteFileRequest, D as ContainerStub, E as BaseApiResponse, F as BucketProvider, G as ListFilesOptions, H as FileStreamEvent, I as ExecEvent, J as PortCloseResult, K as LogEvent, L as ExecOptions, M as SessionRequest, N as BaseExecOptions, O as ErrorResponse, P as BucketCredentials, Q as ProcessCleanupResult, R as ExecResult, S as ReadFileRequest, T as ExecuteResponse, U as GitCheckoutResult, V as FileMetadata, W as ISandbox, X as PortListResult, Y as PortExposeResult, Z as Process, _ as GitCheckoutRequest, a as CreateSessionRequest, at as ProcessStatus, b as FileOperationRequest, c as DeleteSessionResponse, ct as StreamOptions, d as ProcessClient, dt as isProcessStatus, et as ProcessKillResult, f as ExposePortRequest, ft as CodeContext, g as InterpreterClient, gt as RunCodeOptions, h as ExecutionCallbacks, ht as ExecutionResult, i as CommandsResponse, it as ProcessStartResult, j as ResponseHandler, k as HttpClientOptions, l as PingResponse, lt as isExecResult, m as UnexposePortRequest, mt as Execution, n as getSandbox, nt as ProcessLogsResult, o as CreateSessionResponse, ot as SandboxOptions, p as PortClient, pt as CreateContextOptions, q as MountBucketOptions, r as SandboxClient, rt as ProcessOptions, s as DeleteSessionRequest, st as SessionOptions, t as Sandbox, tt as ProcessListResult, u as UtilityClient, ut as isProcess, v as GitClient, w as CommandClient, x as MkdirRequest, y as FileClient, z as ExecutionSession } from "./sandbox-HQazw9bn.js";
|
|
2
2
|
|
|
3
3
|
//#region ../shared/dist/request-types.d.ts
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Request types for API calls to the container
|
|
7
|
+
* These types enforce the contract between the Durable Object client and container handlers
|
|
8
|
+
*
|
|
9
|
+
* IMPORTANT: These types must match the Zod schemas in:
|
|
10
|
+
* @repo/sandbox-container/src/validation/schemas.ts
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Request to execute a command
|
|
14
|
+
*/
|
|
15
|
+
interface ExecuteRequest {
|
|
16
|
+
command: string;
|
|
17
|
+
sessionId?: string;
|
|
18
|
+
background?: boolean;
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
env?: Record<string, string>;
|
|
21
|
+
cwd?: string;
|
|
22
|
+
}
|
|
5
23
|
/**
|
|
6
24
|
* Request to start a background process
|
|
7
25
|
* Uses flat structure consistent with other endpoints
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["ExecuteRequest","
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["ExecuteRequest","Record","StartProcessRequest","ReadFileRequest","WriteFileRequest","DeleteFileRequest","RenameFileRequest","MoveFileRequest","MkdirRequest","FileExistsRequest","ExposePortRequest","GitCheckoutRequest","SessionCreateRequest","SessionDeleteRequest","ErrorCode"],"sources":["../../shared/dist/request-types.d.ts","../src/file-stream.ts","../src/interpreter.ts","../src/request-handler.ts","../src/sse-parser.ts","../../shared/dist/errors/codes.d.ts","../src/storage-mount/errors.ts"],"sourcesContent":["/**\n * Request types for API calls to the container\n * These types enforce the contract between the Durable Object client and container handlers\n *\n * IMPORTANT: These types must match the Zod schemas in:\n * @repo/sandbox-container/src/validation/schemas.ts\n */\n/**\n * Request to execute a command\n */\nexport interface ExecuteRequest {\n command: string;\n sessionId?: string;\n background?: boolean;\n timeoutMs?: number;\n env?: Record<string, string>;\n cwd?: string;\n}\n/**\n * Request to start a background process\n * Uses flat structure consistent with other endpoints\n */\nexport interface StartProcessRequest {\n command: string;\n sessionId?: string;\n processId?: string;\n timeoutMs?: number;\n env?: Record<string, string>;\n cwd?: string;\n encoding?: string;\n autoCleanup?: boolean;\n}\n/**\n * Request to read a file\n */\nexport interface ReadFileRequest {\n path: string;\n encoding?: string;\n sessionId?: string;\n}\n/**\n * Request to write a file\n */\nexport interface WriteFileRequest {\n path: string;\n content: string;\n encoding?: string;\n sessionId?: string;\n}\n/**\n * Request to delete a file\n */\nexport interface DeleteFileRequest {\n path: string;\n sessionId?: string;\n}\n/**\n * Request to rename a file\n */\nexport interface RenameFileRequest {\n oldPath: string;\n newPath: string;\n sessionId?: string;\n}\n/**\n * Request to move a file\n */\nexport interface MoveFileRequest {\n sourcePath: string;\n destinationPath: string;\n sessionId?: string;\n}\n/**\n * Request to create a directory\n */\nexport interface MkdirRequest {\n path: string;\n recursive?: boolean;\n sessionId?: string;\n}\n/**\n * Request to check if a file or directory exists\n */\nexport interface FileExistsRequest {\n path: string;\n sessionId?: string;\n}\n/**\n * Request to expose a port\n */\nexport interface ExposePortRequest {\n port: number;\n name?: string;\n}\n/**\n * Request to clone a Git repository\n */\nexport interface GitCheckoutRequest {\n repoUrl: string;\n branch?: string;\n targetDir?: string;\n sessionId?: string;\n}\n/**\n * Request to create a session\n */\nexport interface SessionCreateRequest {\n id?: string;\n name?: string;\n env?: Record<string, string>;\n cwd?: string;\n}\n/**\n * Request to delete a session\n */\nexport interface SessionDeleteRequest {\n sessionId: string;\n}\n//# sourceMappingURL=request-types.d.ts.map","/**\n * Centralized error code registry\n * Each code maps to a specific error type with consistent semantics\n */\nexport declare const ErrorCode: {\n readonly FILE_NOT_FOUND: \"FILE_NOT_FOUND\";\n readonly PERMISSION_DENIED: \"PERMISSION_DENIED\";\n readonly FILE_EXISTS: \"FILE_EXISTS\";\n readonly IS_DIRECTORY: \"IS_DIRECTORY\";\n readonly NOT_DIRECTORY: \"NOT_DIRECTORY\";\n readonly NO_SPACE: \"NO_SPACE\";\n readonly TOO_MANY_FILES: \"TOO_MANY_FILES\";\n readonly RESOURCE_BUSY: \"RESOURCE_BUSY\";\n readonly READ_ONLY: \"READ_ONLY\";\n readonly NAME_TOO_LONG: \"NAME_TOO_LONG\";\n readonly TOO_MANY_LINKS: \"TOO_MANY_LINKS\";\n readonly FILESYSTEM_ERROR: \"FILESYSTEM_ERROR\";\n readonly COMMAND_NOT_FOUND: \"COMMAND_NOT_FOUND\";\n readonly COMMAND_PERMISSION_DENIED: \"COMMAND_PERMISSION_DENIED\";\n readonly INVALID_COMMAND: \"INVALID_COMMAND\";\n readonly COMMAND_EXECUTION_ERROR: \"COMMAND_EXECUTION_ERROR\";\n readonly STREAM_START_ERROR: \"STREAM_START_ERROR\";\n readonly PROCESS_NOT_FOUND: \"PROCESS_NOT_FOUND\";\n readonly PROCESS_PERMISSION_DENIED: \"PROCESS_PERMISSION_DENIED\";\n readonly PROCESS_ERROR: \"PROCESS_ERROR\";\n readonly PORT_ALREADY_EXPOSED: \"PORT_ALREADY_EXPOSED\";\n readonly PORT_IN_USE: \"PORT_IN_USE\";\n readonly PORT_NOT_EXPOSED: \"PORT_NOT_EXPOSED\";\n readonly INVALID_PORT_NUMBER: \"INVALID_PORT_NUMBER\";\n readonly INVALID_PORT: \"INVALID_PORT\";\n readonly SERVICE_NOT_RESPONDING: \"SERVICE_NOT_RESPONDING\";\n readonly PORT_OPERATION_ERROR: \"PORT_OPERATION_ERROR\";\n readonly CUSTOM_DOMAIN_REQUIRED: \"CUSTOM_DOMAIN_REQUIRED\";\n readonly GIT_REPOSITORY_NOT_FOUND: \"GIT_REPOSITORY_NOT_FOUND\";\n readonly GIT_BRANCH_NOT_FOUND: \"GIT_BRANCH_NOT_FOUND\";\n readonly GIT_AUTH_FAILED: \"GIT_AUTH_FAILED\";\n readonly GIT_NETWORK_ERROR: \"GIT_NETWORK_ERROR\";\n readonly INVALID_GIT_URL: \"INVALID_GIT_URL\";\n readonly GIT_CLONE_FAILED: \"GIT_CLONE_FAILED\";\n readonly GIT_CHECKOUT_FAILED: \"GIT_CHECKOUT_FAILED\";\n readonly GIT_OPERATION_FAILED: \"GIT_OPERATION_FAILED\";\n readonly BUCKET_MOUNT_ERROR: \"BUCKET_MOUNT_ERROR\";\n readonly S3FS_MOUNT_ERROR: \"S3FS_MOUNT_ERROR\";\n readonly MISSING_CREDENTIALS: \"MISSING_CREDENTIALS\";\n readonly INVALID_MOUNT_CONFIG: \"INVALID_MOUNT_CONFIG\";\n readonly INTERPRETER_NOT_READY: \"INTERPRETER_NOT_READY\";\n readonly CONTEXT_NOT_FOUND: \"CONTEXT_NOT_FOUND\";\n readonly CODE_EXECUTION_ERROR: \"CODE_EXECUTION_ERROR\";\n readonly VALIDATION_FAILED: \"VALIDATION_FAILED\";\n readonly INVALID_JSON_RESPONSE: \"INVALID_JSON_RESPONSE\";\n readonly UNKNOWN_ERROR: \"UNKNOWN_ERROR\";\n readonly INTERNAL_ERROR: \"INTERNAL_ERROR\";\n};\nexport type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n//# sourceMappingURL=codes.d.ts.map"],"mappings":";;;;;;;AAUA;AAYA;;;;ACyCA;;AACU,UDtDOA,cAAAA,CCsDP;EACQ,OAAA,EAAA,MAAA;EAAW,SAAA,CAAA,EAAA,MAAA;EAA1B,UAAA,CAAA,EAAA,OAAA;EAAc,SAAA,CAAA,EAAA,MAAA;EA6DK,GAAA,CAAA,ED/GZC,MC+GY,CAAA,MAAW,EAAA,MAAA,CAAA;EAAwB,GAAA,CAAA,EAAA,MAAA;;;;;;UDxGxCC,mBAAAA;;;EERJ,SAAA,CAAA,EAAA,MAAe;EAIL,SAAA,CAAA,EAAA,MAAA;EAUV,GAAA,CAAA,EFDHD,MECG,CAAA,MAAA,EAAA,MAAA,CAAA;EACA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SAAA,oBAAA,EAAA,sBAAA;EAAR,SAAA,sBAAA,EAAA,wBAAA;EA6CQ,SAAA,wBAAA,EAAA,0BAAA;EACA,SAAA,oBAAA,EAAA,sBAAA;EAAR,SAAA,eAAA,EAAA,iBAAA;EA6C+B,SAAA,iBAAA,EAAA,mBAAA;EAAR,SAAA,eAAA,EAAA,iBAAA;EAckB,SAAA,gBAAA,EAAA,kBAAA;EAAO,SAAA,mBAAA,EAAA,qBAAA;;;;EChJpC,SAAA,mBACiB,EAAA,qBAAvB;EAGM,SAAA,oBAAS,EAAA,sBAAA;EAOJ,SAAA,qBAAc,EAAA,uBAAA;EAAW,SAAA,iBAAA,EAAA,mBAAA;EACpC,SAAA,oBAAA,EAAA,sBAAA;EACJ,SAAA,iBAAA,EAAA,mBAAA;EACI,SAAA,qBAAA,EAAA,uBAAA;EAAR,SAAA,aAAA,EAAA,eAAA;EAAO,SAAA,cAAA,EAAA,gBAAA;;KEkCEA,SAAAA,WAAoBA,wBAAwBA;;;;AJUxD;;AACU,cKpDG,gBAAA,SAAyB,KAAA,CLoD5B;EACQ,SAAA,IAAA,EKpDM,SLoDN;EAAW,WAAA,CAAA,OAAA,EAAA,MAAA,EAAA,IAAA,CAAA,EKlDQ,SLkDR;;;AA6D7B;;AAA0C,cKrG7B,cAAA,SAAuB,gBAAA,CLqGM;EACtB,WAAA,CAAA,OAAA,EAAA,MAAA;;;;;cK5FP,uBAAA,SAAgC,gBAAA;;AJrB7C;;;;AAeK,cIgBQ,uBAAA,SAAgC,gBAAA,CJhBxC;EAcQ,WAAA,CAAA,OAAA,EAAA,MAAA"}
|
package/dist/index.js
CHANGED
|
@@ -834,13 +834,17 @@ var CommandClient = class extends BaseHttpClient {
|
|
|
834
834
|
* @param command - The command to execute
|
|
835
835
|
* @param sessionId - The session ID for this command execution
|
|
836
836
|
* @param timeoutMs - Optional timeout in milliseconds (unlimited by default)
|
|
837
|
+
* @param env - Optional environment variables for this command
|
|
838
|
+
* @param cwd - Optional working directory for this command
|
|
837
839
|
*/
|
|
838
|
-
async execute(command, sessionId,
|
|
840
|
+
async execute(command, sessionId, options) {
|
|
839
841
|
try {
|
|
840
842
|
const data = {
|
|
841
843
|
command,
|
|
842
844
|
sessionId,
|
|
843
|
-
...timeoutMs !== void 0 && { timeoutMs }
|
|
845
|
+
...options?.timeoutMs !== void 0 && { timeoutMs: options.timeoutMs },
|
|
846
|
+
...options?.env !== void 0 && { env: options.env },
|
|
847
|
+
...options?.cwd !== void 0 && { cwd: options.cwd }
|
|
844
848
|
};
|
|
845
849
|
const response = await this.post("/api/execute", data);
|
|
846
850
|
this.logSuccess("Command executed", `${command}, Success: ${response.success}`);
|
|
@@ -856,12 +860,16 @@ var CommandClient = class extends BaseHttpClient {
|
|
|
856
860
|
* Execute a command and return a stream of events
|
|
857
861
|
* @param command - The command to execute
|
|
858
862
|
* @param sessionId - The session ID for this command execution
|
|
863
|
+
* @param options - Optional per-command execution settings
|
|
859
864
|
*/
|
|
860
|
-
async executeStream(command, sessionId) {
|
|
865
|
+
async executeStream(command, sessionId, options) {
|
|
861
866
|
try {
|
|
862
867
|
const data = {
|
|
863
868
|
command,
|
|
864
|
-
sessionId
|
|
869
|
+
sessionId,
|
|
870
|
+
...options?.timeoutMs !== void 0 && { timeoutMs: options.timeoutMs },
|
|
871
|
+
...options?.env !== void 0 && { env: options.env },
|
|
872
|
+
...options?.cwd !== void 0 && { cwd: options.cwd }
|
|
865
873
|
};
|
|
866
874
|
const response = await this.doFetch("/api/execute/stream", {
|
|
867
875
|
method: "POST",
|
|
@@ -1377,7 +1385,12 @@ var ProcessClient = class extends BaseHttpClient {
|
|
|
1377
1385
|
const data = {
|
|
1378
1386
|
command,
|
|
1379
1387
|
sessionId,
|
|
1380
|
-
processId: options
|
|
1388
|
+
...options?.processId !== void 0 && { processId: options.processId },
|
|
1389
|
+
...options?.timeoutMs !== void 0 && { timeoutMs: options.timeoutMs },
|
|
1390
|
+
...options?.env !== void 0 && { env: options.env },
|
|
1391
|
+
...options?.cwd !== void 0 && { cwd: options.cwd },
|
|
1392
|
+
...options?.encoding !== void 0 && { encoding: options.encoding },
|
|
1393
|
+
...options?.autoCleanup !== void 0 && { autoCleanup: options.autoCleanup }
|
|
1381
1394
|
};
|
|
1382
1395
|
const response = await this.post("/api/process/start", data);
|
|
1383
1396
|
this.logSuccess("Process started", `${command} (ID: ${response.processId})`);
|
|
@@ -2042,7 +2055,7 @@ function resolveS3fsOptions(provider, userOptions) {
|
|
|
2042
2055
|
* This file is auto-updated by .github/changeset-version.ts during releases
|
|
2043
2056
|
* DO NOT EDIT MANUALLY - Changes will be overwritten on the next version bump
|
|
2044
2057
|
*/
|
|
2045
|
-
const SDK_VERSION = "0.5.
|
|
2058
|
+
const SDK_VERSION = "0.5.3";
|
|
2046
2059
|
|
|
2047
2060
|
//#endregion
|
|
2048
2061
|
//#region src/sandbox.ts
|
|
@@ -2527,7 +2540,12 @@ var Sandbox = class extends Container {
|
|
|
2527
2540
|
let result;
|
|
2528
2541
|
if (options?.stream && options?.onOutput) result = await this.executeWithStreaming(command, sessionId, options, startTime, timestamp);
|
|
2529
2542
|
else {
|
|
2530
|
-
const
|
|
2543
|
+
const commandOptions = options && (options.timeout !== void 0 || options.env !== void 0 || options.cwd !== void 0) ? {
|
|
2544
|
+
timeoutMs: options.timeout,
|
|
2545
|
+
env: options.env,
|
|
2546
|
+
cwd: options.cwd
|
|
2547
|
+
} : void 0;
|
|
2548
|
+
const response = await this.client.commands.execute(command, sessionId, commandOptions);
|
|
2531
2549
|
const duration = Date.now() - startTime;
|
|
2532
2550
|
result = this.mapExecuteResponseToExecResult(response, duration, sessionId);
|
|
2533
2551
|
}
|
|
@@ -2542,7 +2560,11 @@ var Sandbox = class extends Container {
|
|
|
2542
2560
|
let stdout = "";
|
|
2543
2561
|
let stderr = "";
|
|
2544
2562
|
try {
|
|
2545
|
-
const stream = await this.client.commands.executeStream(command, sessionId
|
|
2563
|
+
const stream = await this.client.commands.executeStream(command, sessionId, {
|
|
2564
|
+
timeoutMs: options.timeout,
|
|
2565
|
+
env: options.env,
|
|
2566
|
+
cwd: options.cwd
|
|
2567
|
+
});
|
|
2546
2568
|
for await (const event of parseSSEStream(stream)) {
|
|
2547
2569
|
if (options.signal?.aborted) throw new Error("Operation was aborted");
|
|
2548
2570
|
switch (event.type) {
|
|
@@ -2621,7 +2643,15 @@ var Sandbox = class extends Container {
|
|
|
2621
2643
|
async startProcess(command, options, sessionId) {
|
|
2622
2644
|
try {
|
|
2623
2645
|
const session = sessionId ?? await this.ensureDefaultSession();
|
|
2624
|
-
const
|
|
2646
|
+
const requestOptions = {
|
|
2647
|
+
...options?.processId !== void 0 && { processId: options.processId },
|
|
2648
|
+
...options?.timeout !== void 0 && { timeoutMs: options.timeout },
|
|
2649
|
+
...options?.env !== void 0 && { env: options.env },
|
|
2650
|
+
...options?.cwd !== void 0 && { cwd: options.cwd },
|
|
2651
|
+
...options?.encoding !== void 0 && { encoding: options.encoding },
|
|
2652
|
+
...options?.autoCleanup !== void 0 && { autoCleanup: options.autoCleanup }
|
|
2653
|
+
};
|
|
2654
|
+
const response = await this.client.processes.startProcess(command, session, requestOptions);
|
|
2625
2655
|
const processObj = this.createProcessFromDTO({
|
|
2626
2656
|
id: response.processId,
|
|
2627
2657
|
pid: response.pid,
|
|
@@ -2685,14 +2715,22 @@ var Sandbox = class extends Container {
|
|
|
2685
2715
|
async execStream(command, options) {
|
|
2686
2716
|
if (options?.signal?.aborted) throw new Error("Operation was aborted");
|
|
2687
2717
|
const session = await this.ensureDefaultSession();
|
|
2688
|
-
return this.client.commands.executeStream(command, session
|
|
2718
|
+
return this.client.commands.executeStream(command, session, {
|
|
2719
|
+
timeoutMs: options?.timeout,
|
|
2720
|
+
env: options?.env,
|
|
2721
|
+
cwd: options?.cwd
|
|
2722
|
+
});
|
|
2689
2723
|
}
|
|
2690
2724
|
/**
|
|
2691
2725
|
* Internal session-aware execStream implementation
|
|
2692
2726
|
*/
|
|
2693
2727
|
async execStreamWithSession(command, sessionId, options) {
|
|
2694
2728
|
if (options?.signal?.aborted) throw new Error("Operation was aborted");
|
|
2695
|
-
return this.client.commands.executeStream(command, sessionId
|
|
2729
|
+
return this.client.commands.executeStream(command, sessionId, {
|
|
2730
|
+
timeoutMs: options?.timeout,
|
|
2731
|
+
env: options?.env,
|
|
2732
|
+
cwd: options?.cwd
|
|
2733
|
+
});
|
|
2696
2734
|
}
|
|
2697
2735
|
/**
|
|
2698
2736
|
* Stream logs from a background process as a ReadableStream.
|
|
@@ -2852,10 +2890,15 @@ var Sandbox = class extends Container {
|
|
|
2852
2890
|
*/
|
|
2853
2891
|
async createSession(options) {
|
|
2854
2892
|
const sessionId = options?.id || `session-${Date.now()}`;
|
|
2893
|
+
const mergedEnv = {
|
|
2894
|
+
...this.envVars,
|
|
2895
|
+
...options?.env ?? {}
|
|
2896
|
+
};
|
|
2897
|
+
const envPayload = Object.keys(mergedEnv).length > 0 ? mergedEnv : void 0;
|
|
2855
2898
|
await this.client.utils.createSession({
|
|
2856
2899
|
id: sessionId,
|
|
2857
|
-
env:
|
|
2858
|
-
cwd: options
|
|
2900
|
+
...envPayload && { env: envPayload },
|
|
2901
|
+
...options?.cwd && { cwd: options.cwd }
|
|
2859
2902
|
});
|
|
2860
2903
|
return this.getSessionWrapper(sessionId);
|
|
2861
2904
|
}
|