@vercel/sandbox 1.8.1 → 1.9.1
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/README.md +8 -0
- package/dist/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/api-client/api-client.cjs +375 -0
- package/dist/api-client/api-client.cjs.map +1 -0
- package/dist/api-client/api-client.d.cts +403 -0
- package/dist/api-client/api-client.d.ts +397 -391
- package/dist/api-client/api-client.js +365 -404
- package/dist/api-client/api-client.js.map +1 -1
- package/dist/api-client/api-error.cjs +31 -0
- package/dist/api-client/api-error.cjs.map +1 -0
- package/dist/api-client/api-error.d.cts +27 -0
- package/dist/api-client/api-error.d.ts +19 -16
- package/dist/api-client/api-error.js +27 -32
- package/dist/api-client/api-error.js.map +1 -1
- package/dist/api-client/base-client.cjs +113 -0
- package/dist/api-client/base-client.cjs.map +1 -0
- package/dist/api-client/base-client.d.cts +38 -0
- package/dist/api-client/base-client.d.ts +31 -36
- package/dist/api-client/base-client.js +101 -118
- package/dist/api-client/base-client.js.map +1 -1
- package/dist/api-client/file-writer.cjs +62 -0
- package/dist/api-client/file-writer.cjs.map +1 -0
- package/dist/api-client/file-writer.d.cts +66 -0
- package/dist/api-client/file-writer.d.ts +56 -42
- package/dist/api-client/file-writer.js +57 -61
- package/dist/api-client/file-writer.js.map +1 -1
- package/dist/api-client/index.cjs +2 -0
- package/dist/api-client/index.d.ts +2 -2
- package/dist/api-client/index.js +4 -21
- package/dist/api-client/validators.cjs +149 -0
- package/dist/api-client/validators.cjs.map +1 -0
- package/dist/api-client/validators.d.cts +1677 -0
- package/dist/api-client/validators.d.ts +1501 -2412
- package/dist/api-client/validators.js +124 -154
- package/dist/api-client/validators.js.map +1 -1
- package/dist/api-client/with-retry.cjs +89 -0
- package/dist/api-client/with-retry.cjs.map +1 -0
- package/dist/api-client/with-retry.d.cts +10 -0
- package/dist/api-client/with-retry.d.ts +9 -13
- package/dist/api-client/with-retry.js +81 -102
- package/dist/api-client/with-retry.js.map +1 -1
- package/dist/auth/api.cjs +29 -0
- package/dist/auth/api.cjs.map +1 -0
- package/dist/auth/api.js +26 -25
- package/dist/auth/api.js.map +1 -1
- package/dist/auth/error.cjs +13 -0
- package/dist/auth/error.cjs.map +1 -0
- package/dist/auth/error.js +11 -11
- package/dist/auth/error.js.map +1 -1
- package/dist/auth/file.cjs +64 -0
- package/dist/auth/file.cjs.map +1 -0
- package/dist/auth/file.d.cts +26 -0
- package/dist/auth/file.d.ts +19 -15
- package/dist/auth/file.js +49 -64
- package/dist/auth/file.js.map +1 -1
- package/dist/auth/index.cjs +12 -0
- package/dist/auth/index.d.cts +5 -0
- package/dist/auth/index.d.ts +5 -6
- package/dist/auth/index.js +6 -27
- package/dist/auth/linked-project.cjs +38 -0
- package/dist/auth/linked-project.cjs.map +1 -0
- package/dist/auth/linked-project.js +30 -64
- package/dist/auth/linked-project.js.map +1 -1
- package/dist/auth/oauth.cjs +205 -0
- package/dist/auth/oauth.cjs.map +1 -0
- package/dist/auth/oauth.d.cts +135 -0
- package/dist/auth/oauth.d.ts +113 -109
- package/dist/auth/oauth.js +185 -252
- package/dist/auth/oauth.js.map +1 -1
- package/dist/auth/poll-for-token.cjs +82 -0
- package/dist/auth/poll-for-token.cjs.map +1 -0
- package/dist/auth/poll-for-token.d.cts +28 -0
- package/dist/auth/poll-for-token.d.ts +23 -15
- package/dist/auth/poll-for-token.js +79 -64
- package/dist/auth/poll-for-token.js.map +1 -1
- package/dist/auth/project.cjs +80 -0
- package/dist/auth/project.cjs.map +1 -0
- package/dist/auth/project.d.cts +44 -0
- package/dist/auth/project.d.ts +12 -8
- package/dist/auth/project.js +70 -72
- package/dist/auth/project.js.map +1 -1
- package/dist/auth/zod.cjs +22 -0
- package/dist/auth/zod.cjs.map +1 -0
- package/dist/auth/zod.js +18 -17
- package/dist/auth/zod.js.map +1 -1
- package/dist/command.cjs +326 -0
- package/dist/command.cjs.map +1 -0
- package/dist/command.d.cts +289 -0
- package/dist/command.d.ts +265 -171
- package/dist/command.js +321 -226
- package/dist/command.js.map +1 -1
- package/dist/constants.d.cts +5 -0
- package/dist/constants.d.ts +5 -1
- package/dist/index.cjs +11 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +6 -15
- package/dist/network-policy.d.cts +100 -0
- package/dist/network-policy.d.ts +32 -28
- package/dist/sandbox.cjs +543 -0
- package/dist/sandbox.cjs.map +1 -0
- package/dist/sandbox.d.cts +538 -0
- package/dist/sandbox.d.ts +521 -472
- package/dist/sandbox.js +539 -506
- package/dist/sandbox.js.map +1 -1
- package/dist/snapshot.cjs +116 -0
- package/dist/snapshot.cjs.map +1 -0
- package/dist/snapshot.d.cts +109 -0
- package/dist/snapshot.d.ts +100 -92
- package/dist/snapshot.js +114 -114
- package/dist/snapshot.js.map +1 -1
- package/dist/utils/array.cjs +17 -0
- package/dist/utils/array.cjs.map +1 -0
- package/dist/utils/array.js +12 -15
- package/dist/utils/array.js.map +1 -1
- package/dist/utils/consume-readable.cjs +18 -0
- package/dist/utils/consume-readable.cjs.map +1 -0
- package/dist/utils/consume-readable.js +13 -12
- package/dist/utils/consume-readable.js.map +1 -1
- package/dist/utils/decode-base64-url.cjs +15 -0
- package/dist/utils/decode-base64-url.cjs.map +1 -0
- package/dist/utils/decode-base64-url.js +10 -9
- package/dist/utils/decode-base64-url.js.map +1 -1
- package/dist/utils/dev-credentials.cjs +142 -0
- package/dist/utils/dev-credentials.cjs.map +1 -0
- package/dist/utils/dev-credentials.js +126 -184
- package/dist/utils/dev-credentials.js.map +1 -1
- package/dist/utils/get-credentials.cjs +123 -0
- package/dist/utils/get-credentials.cjs.map +1 -0
- package/dist/utils/get-credentials.d.cts +21 -0
- package/dist/utils/get-credentials.d.ts +19 -61
- package/dist/utils/get-credentials.js +106 -140
- package/dist/utils/get-credentials.js.map +1 -1
- package/dist/utils/log.cjs +25 -0
- package/dist/utils/log.cjs.map +1 -0
- package/dist/utils/log.js +15 -17
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/network-policy.cjs +65 -0
- package/dist/utils/network-policy.cjs.map +1 -0
- package/dist/utils/network-policy.js +58 -77
- package/dist/utils/network-policy.js.map +1 -1
- package/dist/utils/normalizePath.cjs +27 -0
- package/dist/utils/normalizePath.cjs.map +1 -0
- package/dist/utils/normalizePath.js +21 -28
- package/dist/utils/normalizePath.js.map +1 -1
- package/dist/utils/resolveSignal.cjs +20 -0
- package/dist/utils/resolveSignal.cjs.map +1 -0
- package/dist/utils/resolveSignal.d.cts +15 -0
- package/dist/utils/resolveSignal.d.ts +12 -10
- package/dist/utils/resolveSignal.js +14 -17
- package/dist/utils/resolveSignal.js.map +1 -1
- package/dist/utils/sandbox-snapshot.cjs +14 -0
- package/dist/utils/sandbox-snapshot.cjs.map +1 -0
- package/dist/utils/sandbox-snapshot.d.cts +10 -0
- package/dist/utils/sandbox-snapshot.d.ts +11 -0
- package/dist/utils/sandbox-snapshot.js +14 -0
- package/dist/utils/sandbox-snapshot.js.map +1 -0
- package/dist/utils/types.cjs +13 -0
- package/dist/utils/types.cjs.map +1 -0
- package/dist/utils/types.d.cts +11 -0
- package/dist/utils/types.d.ts +5 -7
- package/dist/utils/types.js +8 -8
- package/dist/utils/types.js.map +1 -1
- package/dist/version.cjs +7 -0
- package/dist/version.cjs.map +1 -0
- package/dist/version.js +5 -5
- package/dist/version.js.map +1 -1
- package/package.json +23 -3
- package/dist/api-client/index.js.map +0 -1
- package/dist/auth/api.d.ts +0 -6
- package/dist/auth/error.d.ts +0 -11
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/linked-project.d.ts +0 -10
- package/dist/auth/zod.d.ts +0 -5
- package/dist/constants.js +0 -3
- package/dist/constants.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/network-policy.js +0 -3
- package/dist/network-policy.js.map +0 -1
- package/dist/utils/array.d.ts +0 -9
- package/dist/utils/consume-readable.d.ts +0 -5
- package/dist/utils/convert-sandbox.d.ts +0 -6
- package/dist/utils/convert-sandbox.js +0 -14
- package/dist/utils/convert-sandbox.js.map +0 -1
- package/dist/utils/decode-base64-url.d.ts +0 -7
- package/dist/utils/dev-credentials.d.ts +0 -37
- package/dist/utils/log.d.ts +0 -2
- package/dist/utils/network-policy.d.ts +0 -7
- package/dist/utils/normalizePath.d.ts +0 -17
- package/dist/version.d.ts +0 -1
package/dist/command.d.ts
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CommandData } from "./api-client/validators.js";
|
|
2
|
+
import { APIClient } from "./api-client/api-client.js";
|
|
3
|
+
import "./api-client/index.js";
|
|
4
|
+
import { Signal } from "./utils/resolveSignal.js";
|
|
5
|
+
import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE } from "@workflow/serde";
|
|
6
|
+
|
|
7
|
+
//#region src/command.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Cached output from a command execution.
|
|
10
|
+
*/
|
|
11
|
+
interface CommandOutput {
|
|
12
|
+
stdout: string;
|
|
13
|
+
stderr: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Serialized representation of a Command for @workflow/serde.
|
|
17
|
+
*/
|
|
18
|
+
interface SerializedCommand {
|
|
19
|
+
sandboxId: string;
|
|
20
|
+
cmd: CommandData;
|
|
21
|
+
/** Cached output, included if output was fetched before serialization */
|
|
22
|
+
output?: CommandOutput;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Serialized representation of a CommandFinished for @workflow/serde.
|
|
26
|
+
*/
|
|
27
|
+
interface SerializedCommandFinished extends SerializedCommand {
|
|
28
|
+
exitCode: number;
|
|
29
|
+
}
|
|
3
30
|
/**
|
|
4
31
|
* A command executed in a Sandbox.
|
|
5
32
|
*
|
|
@@ -13,148 +40,193 @@ import { Signal } from "./utils/resolveSignal";
|
|
|
13
40
|
*
|
|
14
41
|
* @hideconstructor
|
|
15
42
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
43
|
+
declare class Command {
|
|
44
|
+
/**
|
|
45
|
+
* Cached API client instance.
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
protected _client: APIClient | null;
|
|
49
|
+
/**
|
|
50
|
+
* Lazily resolve credentials and construct an API client.
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
protected ensureClient(): Promise<APIClient>;
|
|
54
|
+
/**
|
|
55
|
+
* ID of the sandbox this command is running in.
|
|
56
|
+
*/
|
|
57
|
+
protected sandboxId: string;
|
|
58
|
+
/**
|
|
59
|
+
* Data for the command execution.
|
|
60
|
+
*/
|
|
61
|
+
protected cmd: CommandData;
|
|
62
|
+
exitCode: number | null;
|
|
63
|
+
protected outputCache: Promise<{
|
|
64
|
+
stdout: string;
|
|
65
|
+
stderr: string;
|
|
66
|
+
both: string;
|
|
67
|
+
}> | null;
|
|
68
|
+
/**
|
|
69
|
+
* Synchronously accessible resolved output, populated after output is fetched.
|
|
70
|
+
* Used for serialization.
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
protected _resolvedOutput: CommandOutput | null;
|
|
74
|
+
/**
|
|
75
|
+
* ID of the command execution.
|
|
76
|
+
*/
|
|
77
|
+
get cmdId(): string;
|
|
78
|
+
get cwd(): string;
|
|
79
|
+
get startedAt(): number;
|
|
80
|
+
/**
|
|
81
|
+
* @param params - Object containing the client, sandbox ID, and command data.
|
|
82
|
+
* @param params.client - Optional API client. If not provided, will be lazily created using global credentials.
|
|
83
|
+
* @param params.sandboxId - The ID of the sandbox where the command is running.
|
|
84
|
+
* @param params.cmd - The command data.
|
|
85
|
+
* @param params.output - Optional cached output to restore (used during deserialization).
|
|
86
|
+
*/
|
|
87
|
+
constructor({
|
|
88
|
+
client,
|
|
89
|
+
sandboxId,
|
|
90
|
+
cmd,
|
|
91
|
+
output
|
|
92
|
+
}: {
|
|
93
|
+
client?: APIClient;
|
|
94
|
+
sandboxId: string;
|
|
95
|
+
cmd: CommandData;
|
|
96
|
+
output?: CommandOutput;
|
|
97
|
+
});
|
|
98
|
+
/**
|
|
99
|
+
* Serialize a Command instance to plain data for @workflow/serde.
|
|
100
|
+
*
|
|
101
|
+
* @param instance - The Command instance to serialize
|
|
102
|
+
* @returns A plain object containing the sandbox ID, command data, and output if fetched
|
|
103
|
+
*/
|
|
104
|
+
static [WORKFLOW_SERIALIZE](instance: Command): SerializedCommand;
|
|
105
|
+
/**
|
|
106
|
+
* Deserialize plain data back into a Command instance for @workflow/serde.
|
|
107
|
+
*
|
|
108
|
+
* The deserialized instance will lazily create an API client using
|
|
109
|
+
* OIDC or environment credentials when needed.
|
|
110
|
+
*
|
|
111
|
+
* @param data - The serialized command data
|
|
112
|
+
* @returns The reconstructed Command instance
|
|
113
|
+
*/
|
|
114
|
+
static [WORKFLOW_DESERIALIZE](data: SerializedCommand): Command;
|
|
115
|
+
/**
|
|
116
|
+
* Iterate over the output of this command.
|
|
117
|
+
*
|
|
118
|
+
* ```
|
|
119
|
+
* for await (const log of cmd.logs()) {
|
|
120
|
+
* if (log.stream === "stdout") {
|
|
121
|
+
* process.stdout.write(log.data);
|
|
122
|
+
* } else {
|
|
123
|
+
* process.stderr.write(log.data);
|
|
124
|
+
* }
|
|
125
|
+
* }
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* @param opts - Optional parameters.
|
|
129
|
+
* @param opts.signal - An AbortSignal to cancel log streaming.
|
|
130
|
+
* @returns An async iterable of log entries from the command output.
|
|
131
|
+
*
|
|
132
|
+
* @see {@link Command.stdout}, {@link Command.stderr}, and {@link Command.output}
|
|
133
|
+
* to access output as a string.
|
|
134
|
+
*/
|
|
135
|
+
logs(opts?: {
|
|
136
|
+
signal?: AbortSignal;
|
|
137
|
+
}): AsyncGenerator<{
|
|
138
|
+
data: string;
|
|
139
|
+
stream: "stdout";
|
|
140
|
+
} | {
|
|
141
|
+
data: string;
|
|
142
|
+
stream: "stderr";
|
|
143
|
+
}, void, void> & Disposable & {
|
|
144
|
+
close(): void;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Wait for a command to exit and populate its exit code.
|
|
148
|
+
*
|
|
149
|
+
* This method is useful for detached commands where you need to wait
|
|
150
|
+
* for completion. For non-detached commands, {@link Sandbox.runCommand}
|
|
151
|
+
* automatically waits and returns a {@link CommandFinished} instance.
|
|
152
|
+
*
|
|
153
|
+
* ```
|
|
154
|
+
* const detachedCmd = await sandbox.runCommand({ cmd: 'sleep', args: ['5'], detached: true });
|
|
155
|
+
* const result = await detachedCmd.wait();
|
|
156
|
+
* if (result.exitCode !== 0) {
|
|
157
|
+
* console.error("Something went wrong...")
|
|
158
|
+
* }
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* @param params - Optional parameters.
|
|
162
|
+
* @param params.signal - An AbortSignal to cancel waiting.
|
|
163
|
+
* @returns A {@link CommandFinished} instance with populated exit code.
|
|
164
|
+
*/
|
|
165
|
+
wait(params?: {
|
|
166
|
+
signal?: AbortSignal;
|
|
167
|
+
}): Promise<CommandFinished>;
|
|
168
|
+
/**
|
|
169
|
+
* Get cached output, fetching logs only once and reusing for concurrent calls.
|
|
170
|
+
* This prevents race conditions when stdout() and stderr() are called in parallel.
|
|
171
|
+
*/
|
|
172
|
+
protected getCachedOutput(opts?: {
|
|
173
|
+
signal?: AbortSignal;
|
|
174
|
+
}): Promise<{
|
|
175
|
+
stdout: string;
|
|
176
|
+
stderr: string;
|
|
177
|
+
both: string;
|
|
178
|
+
}>;
|
|
179
|
+
/**
|
|
180
|
+
* Get the output of `stdout`, `stderr`, or both as a string.
|
|
181
|
+
*
|
|
182
|
+
* NOTE: This may throw string conversion errors if the command does
|
|
183
|
+
* not output valid Unicode.
|
|
184
|
+
*
|
|
185
|
+
* @param stream - The output stream to read: "stdout", "stderr", or "both".
|
|
186
|
+
* @param opts - Optional parameters.
|
|
187
|
+
* @param opts.signal - An AbortSignal to cancel output streaming.
|
|
188
|
+
* @returns The output of the specified stream(s) as a string.
|
|
189
|
+
*/
|
|
190
|
+
output(stream?: "stdout" | "stderr" | "both", opts?: {
|
|
191
|
+
signal?: AbortSignal;
|
|
192
|
+
}): Promise<string>;
|
|
193
|
+
/**
|
|
194
|
+
* Get the output of `stdout` as a string.
|
|
195
|
+
*
|
|
196
|
+
* NOTE: This may throw string conversion errors if the command does
|
|
197
|
+
* not output valid Unicode.
|
|
198
|
+
*
|
|
199
|
+
* @param opts - Optional parameters.
|
|
200
|
+
* @param opts.signal - An AbortSignal to cancel output streaming.
|
|
201
|
+
* @returns The standard output of the command.
|
|
202
|
+
*/
|
|
203
|
+
stdout(opts?: {
|
|
204
|
+
signal?: AbortSignal;
|
|
205
|
+
}): Promise<string>;
|
|
206
|
+
/**
|
|
207
|
+
* Get the output of `stderr` as a string.
|
|
208
|
+
*
|
|
209
|
+
* NOTE: This may throw string conversion errors if the command does
|
|
210
|
+
* not output valid Unicode.
|
|
211
|
+
*
|
|
212
|
+
* @param opts - Optional parameters.
|
|
213
|
+
* @param opts.signal - An AbortSignal to cancel output streaming.
|
|
214
|
+
* @returns The standard error output of the command.
|
|
215
|
+
*/
|
|
216
|
+
stderr(opts?: {
|
|
217
|
+
signal?: AbortSignal;
|
|
218
|
+
}): Promise<string>;
|
|
219
|
+
/**
|
|
220
|
+
* Kill a running command in a sandbox.
|
|
221
|
+
*
|
|
222
|
+
* @param signal - The signal to send the running process. Defaults to SIGTERM.
|
|
223
|
+
* @param opts - Optional parameters.
|
|
224
|
+
* @param opts.abortSignal - An AbortSignal to cancel the kill operation.
|
|
225
|
+
* @returns Promise<void>.
|
|
226
|
+
*/
|
|
227
|
+
kill(signal?: Signal, opts?: {
|
|
228
|
+
abortSignal?: AbortSignal;
|
|
229
|
+
}): Promise<void>;
|
|
158
230
|
}
|
|
159
231
|
/**
|
|
160
232
|
* A command that has finished executing.
|
|
@@ -165,32 +237,54 @@ export declare class Command {
|
|
|
165
237
|
*
|
|
166
238
|
* @hideconstructor
|
|
167
239
|
*/
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
240
|
+
declare class CommandFinished extends Command {
|
|
241
|
+
/**
|
|
242
|
+
* The exit code of the command. This is always populated for
|
|
243
|
+
* CommandFinished instances.
|
|
244
|
+
*/
|
|
245
|
+
exitCode: number;
|
|
246
|
+
/**
|
|
247
|
+
* @param params - Object containing client, sandbox ID, command data, and exit code.
|
|
248
|
+
* @param params.client - Optional API client. If not provided, will be lazily created using global credentials.
|
|
249
|
+
* @param params.sandboxId - The ID of the sandbox where the command ran.
|
|
250
|
+
* @param params.cmd - The command data.
|
|
251
|
+
* @param params.exitCode - The exit code of the completed command.
|
|
252
|
+
* @param params.output - Optional cached output to restore (used during deserialization).
|
|
253
|
+
*/
|
|
254
|
+
constructor(params: {
|
|
255
|
+
client?: APIClient;
|
|
256
|
+
sandboxId: string;
|
|
257
|
+
cmd: CommandData;
|
|
173
258
|
exitCode: number;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
259
|
+
output?: CommandOutput;
|
|
260
|
+
});
|
|
261
|
+
/**
|
|
262
|
+
* Serialize a CommandFinished instance to plain data for @workflow/serde.
|
|
263
|
+
*
|
|
264
|
+
* @param instance - The CommandFinished instance to serialize
|
|
265
|
+
* @returns A plain object containing the sandbox ID, command data, exit code, and output if fetched
|
|
266
|
+
*/
|
|
267
|
+
static [WORKFLOW_SERIALIZE](instance: CommandFinished): SerializedCommandFinished;
|
|
268
|
+
/**
|
|
269
|
+
* Deserialize plain data back into a CommandFinished instance for @workflow/serde.
|
|
270
|
+
*
|
|
271
|
+
* The deserialized instance will lazily create an API client using
|
|
272
|
+
* OIDC or environment credentials when needed.
|
|
273
|
+
*
|
|
274
|
+
* @param data - The serialized command finished data
|
|
275
|
+
* @returns The reconstructed CommandFinished instance
|
|
276
|
+
*/
|
|
277
|
+
static [WORKFLOW_DESERIALIZE](data: SerializedCommandFinished): CommandFinished;
|
|
278
|
+
/**
|
|
279
|
+
* The wait method is not needed for CommandFinished instances since
|
|
280
|
+
* the command has already completed and exitCode is populated.
|
|
281
|
+
*
|
|
282
|
+
* @deprecated This method is redundant for CommandFinished instances.
|
|
283
|
+
* The exitCode is already available.
|
|
284
|
+
* @returns This CommandFinished instance.
|
|
285
|
+
*/
|
|
286
|
+
wait(): Promise<CommandFinished>;
|
|
196
287
|
}
|
|
288
|
+
//#endregion
|
|
289
|
+
export { Command, CommandFinished, CommandOutput, SerializedCommand, SerializedCommandFinished };
|
|
290
|
+
//# sourceMappingURL=command.d.ts.map
|