eve 0.36.0 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +1 -0
  3. package/dist/src/cli/commands/agent-instructions.d.ts +4 -4
  4. package/dist/src/cli/commands/init-confirm.d.ts +12 -0
  5. package/dist/src/cli/commands/init-confirm.js +1 -0
  6. package/dist/src/cli/commands/init.d.ts +6 -5
  7. package/dist/src/cli/commands/init.js +1 -1
  8. package/dist/src/cli/run.d.ts +1 -0
  9. package/dist/src/cli/run.js +3 -3
  10. package/dist/src/compiled/.vendor-stamp.json +2 -1
  11. package/dist/src/compiled/@vercel/sandbox/api-client/api-client.d.ts +339 -0
  12. package/dist/src/compiled/@vercel/sandbox/api-client/index.d.ts +1 -1
  13. package/dist/src/compiled/@vercel/sandbox/api-client/validators.d.ts +25 -1
  14. package/dist/src/compiled/@vercel/sandbox/drive.d.ts +140 -0
  15. package/dist/src/compiled/@vercel/sandbox/index.d.ts +3 -2
  16. package/dist/src/compiled/@vercel/sandbox/index.js +13 -13
  17. package/dist/src/compiled/@vercel/sandbox/sandbox.d.ts +55 -18
  18. package/dist/src/compiled/@vercel/sandbox-stable/LICENSE +201 -0
  19. package/dist/src/compiled/@vercel/sandbox-stable/_async-retry.d.ts +8 -0
  20. package/dist/src/compiled/@vercel/sandbox-stable/_workflow-serde.d.ts +5 -0
  21. package/dist/src/compiled/@vercel/sandbox-stable/api-client/api-client.d.ts +1456 -0
  22. package/dist/src/compiled/@vercel/sandbox-stable/api-client/api-error.d.ts +29 -0
  23. package/dist/src/compiled/@vercel/sandbox-stable/api-client/base-client.d.ts +39 -0
  24. package/dist/src/compiled/@vercel/sandbox-stable/api-client/file-writer.d.ts +66 -0
  25. package/dist/src/compiled/@vercel/sandbox-stable/api-client/index.d.ts +2 -0
  26. package/dist/src/compiled/@vercel/sandbox-stable/api-client/validators.d.ts +899 -0
  27. package/dist/src/compiled/@vercel/sandbox-stable/api-client/with-retry.d.ts +10 -0
  28. package/dist/src/compiled/@vercel/sandbox-stable/auth/error.d.ts +15 -0
  29. package/dist/src/compiled/@vercel/sandbox-stable/auth/file.d.ts +18 -0
  30. package/dist/src/compiled/@vercel/sandbox-stable/auth/index.d.ts +6 -0
  31. package/dist/src/compiled/@vercel/sandbox-stable/auth/oauth.d.ts +111 -0
  32. package/dist/src/compiled/@vercel/sandbox-stable/auth/poll-for-token.d.ts +28 -0
  33. package/dist/src/compiled/@vercel/sandbox-stable/auth/project.d.ts +40 -0
  34. package/dist/src/compiled/@vercel/sandbox-stable/command.d.ts +292 -0
  35. package/dist/src/compiled/@vercel/sandbox-stable/constants.d.ts +5 -0
  36. package/dist/src/compiled/@vercel/sandbox-stable/execution-context.d.ts +116 -0
  37. package/dist/src/compiled/@vercel/sandbox-stable/filesystem.d.ts +258 -0
  38. package/dist/src/compiled/@vercel/sandbox-stable/index.d.ts +12 -0
  39. package/dist/src/compiled/@vercel/sandbox-stable/index.js +1 -0
  40. package/dist/src/compiled/@vercel/sandbox-stable/network-policy.d.ts +169 -0
  41. package/dist/src/compiled/@vercel/sandbox-stable/proxy.d.ts +55 -0
  42. package/dist/src/compiled/@vercel/sandbox-stable/sandbox-user.d.ts +212 -0
  43. package/dist/src/compiled/@vercel/sandbox-stable/sandbox.d.ts +1216 -0
  44. package/dist/src/compiled/@vercel/sandbox-stable/session.d.ts +433 -0
  45. package/dist/src/compiled/@vercel/sandbox-stable/snapshot.d.ts +229 -0
  46. package/dist/src/compiled/@vercel/sandbox-stable/utils/get-credentials.d.ts +21 -0
  47. package/dist/src/compiled/@vercel/sandbox-stable/utils/paginator.d.ts +16 -0
  48. package/dist/src/compiled/@vercel/sandbox-stable/utils/resolveSignal.d.ts +15 -0
  49. package/dist/src/compiled/@vercel/sandbox-stable/utils/sandbox-snapshot.d.ts +11 -0
  50. package/dist/src/compiled/@vercel/sandbox-stable/utils/types.d.ts +11 -0
  51. package/dist/src/compiled/_chunks/node/{auth-BS3UoyvT.js → auth-BaNbsImr.js} +1 -1
  52. package/dist/src/compiled/_chunks/node/version-BYHw-SDY.js +1 -0
  53. package/dist/src/execution/sandbox/bindings/vercel.d.ts +2 -1
  54. package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
  55. package/dist/src/internal/application/package.js +1 -1
  56. package/dist/src/packages/eve-catalog/src/index.js +1 -1
  57. package/dist/src/public/sandbox/backends/vercel.d.ts +5 -4
  58. package/dist/src/public/sandbox/backends/vercel.js +1 -1
  59. package/dist/src/public/sandbox/vercel-sandbox.d.ts +25 -1
  60. package/dist/src/public/sandbox/vercel.d.ts +2 -1
  61. package/dist/src/public/sandbox/vercel.js +1 -1
  62. package/dist/src/setup/scaffold/create/project.js +1 -1
  63. package/dist/src/setup/scaffold/create/web-template.d.ts +1 -1
  64. package/dist/src/setup/scaffold/create/web-template.js +0 -1
  65. package/dist/src/shared/sandbox-network-policy.d.ts +1 -1
  66. package/docs/reference/cli.md +10 -6
  67. package/package.json +2 -1
  68. package/dist/src/compiled/_chunks/node/version-Cztrk7z6.js +0 -1
@@ -0,0 +1,10 @@
1
+ import { Options } from "../_async-retry.js";
2
+
3
+ //#region src/api-client/with-retry.d.ts
4
+ interface RequestOptions {
5
+ onRetry?(error: any, options: RequestOptions): void;
6
+ retry?: Partial<Options>;
7
+ }
8
+ //#endregion
9
+ export { RequestOptions };
10
+ //# sourceMappingURL=with-retry.d.ts.map
@@ -0,0 +1,15 @@
1
+ //#region src/auth/error.d.ts
2
+ declare class NotOk extends Error {
3
+ name: string;
4
+ response: {
5
+ statusCode: number;
6
+ responseText: string;
7
+ };
8
+ constructor(response: {
9
+ statusCode: number;
10
+ responseText: string;
11
+ });
12
+ }
13
+ //#endregion
14
+ export { NotOk };
15
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1,18 @@
1
+ import { z } from "#compiled/zod/index.js";
2
+
3
+ //#region src/auth/file.d.ts
4
+ declare const AuthFile: z.ZodObject<{
5
+ token: z.ZodOptional<z.ZodString>;
6
+ refreshToken: z.ZodOptional<z.ZodString>;
7
+ expiresAt: z.ZodOptional<z.ZodPipe<z.ZodNumber, z.ZodTransform<Date, number>>>;
8
+ }, z.core.$strip>;
9
+ type AuthFile = z.infer<typeof AuthFile>;
10
+ declare const getAuth: () => {
11
+ token?: string | undefined;
12
+ refreshToken?: string | undefined;
13
+ expiresAt?: Date | undefined;
14
+ } | null;
15
+ declare function updateAuthConfig(config: AuthFile): void;
16
+ //#endregion
17
+ export { getAuth, updateAuthConfig };
18
+ //# sourceMappingURL=file.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { getAuth, updateAuthConfig } from "./file.js";
2
+ import { DeviceAuthorizationRequest, OAuth, isOAuthError } from "./oauth.js";
3
+ import { pollForToken } from "./poll-for-token.js";
4
+ import { inferScope } from "./project.js";
5
+ import { NotOk } from "./error.js";
6
+ export { DeviceAuthorizationRequest, NotOk, OAuth, getAuth, inferScope, isOAuthError, pollForToken, updateAuthConfig };
@@ -0,0 +1,111 @@
1
+ import { z } from "#compiled/zod/index.js";
2
+
3
+ //#region src/auth/oauth.d.ts
4
+ declare const IntrospectionResponse: z.ZodUnion<[z.ZodObject<{
5
+ active: z.ZodLiteral<true>;
6
+ client_id: z.ZodString;
7
+ session_id: z.ZodString;
8
+ }, z.core.$strip>, z.ZodObject<{
9
+ active: z.ZodLiteral<false>;
10
+ }, z.core.$strip>]>;
11
+ declare function OAuth(): Promise<{
12
+ /**
13
+ * Perform the Device Authorization Request
14
+ *
15
+ * @see https://datatracker.ietf.org/doc/html/rfc8628#section-3.1
16
+ * @see https://datatracker.ietf.org/doc/html/rfc8628#section-3.2
17
+ */
18
+ deviceAuthorizationRequest(): Promise<DeviceAuthorizationRequest>;
19
+ /**
20
+ * Perform the Device Access Token Request
21
+ *
22
+ * @see https://datatracker.ietf.org/doc/html/rfc8628#section-3.4
23
+ */
24
+ deviceAccessTokenRequest(device_code: string): Promise<[Error] | [null, Response]>;
25
+ /**
26
+ * Process the Token request Response
27
+ *
28
+ * @see https://datatracker.ietf.org/doc/html/rfc8628#section-3.5
29
+ */
30
+ processTokenResponse(response: Response): Promise<[OAuthError] | [null, TokenSet]>;
31
+ /**
32
+ * Perform a Token Revocation Request.
33
+ *
34
+ * @see https://datatracker.ietf.org/doc/html/rfc7009#section-2.1
35
+ * @see https://datatracker.ietf.org/doc/html/rfc7009#section-2.2
36
+ */
37
+ revokeToken(token: string): Promise<OAuthError | void>;
38
+ /**
39
+ * Perform Refresh Token Request.
40
+ *
41
+ * @see https://datatracker.ietf.org/doc/html/rfc6749#section-6
42
+ */
43
+ refreshToken(token: string): Promise<TokenSet>;
44
+ /**
45
+ * Perform Token Introspection Request.
46
+ *
47
+ * @see https://datatracker.ietf.org/doc/html/rfc7662#section-2.1
48
+ */
49
+ introspectToken(token: string): Promise<z.infer<typeof IntrospectionResponse>>;
50
+ }>;
51
+ type OAuth = Awaited<ReturnType<typeof OAuth>>;
52
+ declare const TokenSet: z.ZodObject<{
53
+ access_token: z.ZodString;
54
+ token_type: z.ZodLiteral<"Bearer">;
55
+ expires_in: z.ZodNumber;
56
+ refresh_token: z.ZodOptional<z.ZodString>;
57
+ scope: z.ZodOptional<z.ZodString>;
58
+ }, z.core.$strip>;
59
+ type TokenSet = z.infer<typeof TokenSet>;
60
+ declare const OAuthErrorResponse: z.ZodObject<{
61
+ error: z.ZodEnum<{
62
+ invalid_request: "invalid_request";
63
+ invalid_client: "invalid_client";
64
+ invalid_grant: "invalid_grant";
65
+ unauthorized_client: "unauthorized_client";
66
+ unsupported_grant_type: "unsupported_grant_type";
67
+ invalid_scope: "invalid_scope";
68
+ server_error: "server_error";
69
+ authorization_pending: "authorization_pending";
70
+ slow_down: "slow_down";
71
+ access_denied: "access_denied";
72
+ expired_token: "expired_token";
73
+ unsupported_token_type: "unsupported_token_type";
74
+ }>;
75
+ error_description: z.ZodOptional<z.ZodString>;
76
+ error_uri: z.ZodOptional<z.ZodString>;
77
+ }, z.core.$strip>;
78
+ type OAuthErrorResponse = z.infer<typeof OAuthErrorResponse>;
79
+ declare class OAuthError extends Error {
80
+ name: string;
81
+ code: OAuthErrorResponse["error"];
82
+ cause: Error;
83
+ constructor(message: string, response: unknown);
84
+ }
85
+ declare function isOAuthError(error: unknown): error is OAuthError;
86
+ interface DeviceAuthorizationRequest {
87
+ /** The device verification code. */
88
+ device_code: string;
89
+ /** The end-user verification code. */
90
+ user_code: string;
91
+ /**
92
+ * The minimum amount of time in seconds that the client
93
+ * SHOULD wait between polling requests to the token endpoint.
94
+ */
95
+ interval: number;
96
+ /** The end-user verification URI on the authorization server. */
97
+ verification_uri: string;
98
+ /**
99
+ * The end-user verification URI on the authorization server,
100
+ * including the `user_code`, without redirection.
101
+ */
102
+ verification_uri_complete: string;
103
+ /**
104
+ * The absolute lifetime of the `device_code` and `user_code`.
105
+ * Calculated from `expires_in`.
106
+ */
107
+ expiresAt: number;
108
+ }
109
+ //#endregion
110
+ export { DeviceAuthorizationRequest, OAuth, isOAuthError };
111
+ //# sourceMappingURL=oauth.d.ts.map
@@ -0,0 +1,28 @@
1
+ import { DeviceAuthorizationRequest, OAuth } from "./oauth.js";
2
+
3
+ //#region src/auth/poll-for-token.d.ts
4
+ type PollTokenItem = {
5
+ _tag: "Timeout";
6
+ newInterval: number;
7
+ } | {
8
+ _tag: "SlowDown";
9
+ newInterval: number;
10
+ } | {
11
+ _tag: "Error";
12
+ error: Error;
13
+ } | {
14
+ _tag: "Response";
15
+ response: {
16
+ text(): Promise<string>;
17
+ };
18
+ };
19
+ declare function pollForToken({
20
+ request,
21
+ oauth
22
+ }: {
23
+ request: DeviceAuthorizationRequest;
24
+ oauth: OAuth;
25
+ }): AsyncGenerator<PollTokenItem, void, void>;
26
+ //#endregion
27
+ export { pollForToken };
28
+ //# sourceMappingURL=poll-for-token.d.ts.map
@@ -0,0 +1,40 @@
1
+ //#region src/auth/project.d.ts
2
+ /**
3
+ * Resolves the team and project scope for sandbox operations.
4
+ *
5
+ * First checks for a locally linked project in `.vercel/project.json`.
6
+ * If found, uses the `projectId` and `orgId` from there.
7
+ *
8
+ * Otherwise, if `teamId` is not provided, builds an ordered list of candidate
9
+ * teams to try: the user's `defaultTeamId` first (if set), then hobby-plan
10
+ * teams where the user has an OWNER role (preferring the personal team matching
11
+ * the username, then the most recently updated). Tries each candidate until one
12
+ * succeeds.
13
+ *
14
+ * @param opts.token - Vercel API authentication token.
15
+ * @param opts.teamId - Optional team slug. If omitted, candidate teams are resolved automatically.
16
+ * @param opts.cwd - Optional directory to search for `.vercel/project.json`. Defaults to `process.cwd()`.
17
+ * @returns The resolved scope with `projectId`, `teamId`, and whether the project was `created`.
18
+ *
19
+ * @throws {NotOk} If the API returns an error other than 404 when checking the project.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * const scope = await inferScope({ token: "vercel_..." });
24
+ * // => { projectId: "vercel-sandbox-default-project", teamId: "my-team", created: false }
25
+ * ```
26
+ */
27
+ declare function inferScope(opts: {
28
+ token: string;
29
+ teamId?: string;
30
+ cwd?: string;
31
+ }): Promise<{
32
+ projectId: string;
33
+ teamId: string;
34
+ created: boolean;
35
+ teamSlug?: string;
36
+ projectSlug?: string;
37
+ }>;
38
+ //#endregion
39
+ export { inferScope };
40
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1,292 @@
1
+ import { CommandData, LogOutputLine } 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.js";
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
+ durationMs?: number;
30
+ }
31
+ /**
32
+ * A command executed in a Sandbox.
33
+ *
34
+ * For detached commands, you can {@link wait} to get a {@link CommandFinished} instance
35
+ * with the populated exit code. For non-detached commands, {@link Sandbox.runCommand}
36
+ * automatically waits and returns a {@link CommandFinished} instance.
37
+ *
38
+ * You can iterate over command output with {@link logs}.
39
+ *
40
+ * @see {@link Sandbox.runCommand} to start a command.
41
+ *
42
+ * @hideconstructor
43
+ */
44
+ declare class Command {
45
+ /**
46
+ * Cached API client instance.
47
+ * @internal
48
+ */
49
+ protected _client: APIClient | null;
50
+ /**
51
+ * Lazily resolve credentials and construct an API client.
52
+ * @internal
53
+ */
54
+ protected ensureClient(): Promise<APIClient>;
55
+ /**
56
+ * ID of the session this command is running in.
57
+ */
58
+ protected sessionId: string;
59
+ /**
60
+ * Data for the command execution.
61
+ */
62
+ protected cmd: CommandData;
63
+ exitCode: number | null;
64
+ durationMs?: number;
65
+ protected outputCache: Promise<{
66
+ stdout: string;
67
+ stderr: string;
68
+ both: string;
69
+ }> | null;
70
+ /**
71
+ * Synchronously accessible resolved output, populated after output is fetched.
72
+ * Used for serialization.
73
+ * @internal
74
+ */
75
+ protected _resolvedOutput: CommandOutput | null;
76
+ /**
77
+ * ID of the command execution.
78
+ */
79
+ get cmdId(): string;
80
+ get cwd(): string;
81
+ get startedAt(): number;
82
+ /**
83
+ * @param params - Object containing the client, sandbox ID, and command data.
84
+ * @param params.client - Optional API client. If not provided, will be lazily created using global credentials.
85
+ * @param params.sessionId - The ID of the session where the command is running.
86
+ * @param params.cmd - The command data.
87
+ * @param params.output - Optional cached output to restore (used during deserialization).
88
+ */
89
+ constructor({
90
+ client,
91
+ sessionId,
92
+ cmd,
93
+ output
94
+ }: {
95
+ client?: APIClient;
96
+ sessionId: string;
97
+ cmd: CommandData;
98
+ output?: CommandOutput;
99
+ });
100
+ /**
101
+ * Serialize a Command instance to plain data for @workflow/serde.
102
+ *
103
+ * @param instance - The Command instance to serialize
104
+ * @returns A plain object containing the sandbox ID, command data, and output if fetched
105
+ */
106
+ static [WORKFLOW_SERIALIZE](instance: Command): SerializedCommand;
107
+ /**
108
+ * Deserialize plain data back into a Command instance for @workflow/serde.
109
+ *
110
+ * The deserialized instance will lazily create an API client using
111
+ * OIDC or environment credentials when needed.
112
+ *
113
+ * @param data - The serialized command data
114
+ * @returns The reconstructed Command instance
115
+ */
116
+ static [WORKFLOW_DESERIALIZE](data: SerializedCommand): Command;
117
+ /**
118
+ * Iterate over the output of this command.
119
+ *
120
+ * ```
121
+ * for await (const log of cmd.logs()) {
122
+ * if (log.stream === "stdout") {
123
+ * process.stdout.write(log.data);
124
+ * } else {
125
+ * process.stderr.write(log.data);
126
+ * }
127
+ * }
128
+ * ```
129
+ *
130
+ * @param opts - Optional parameters.
131
+ * @param opts.signal - An AbortSignal to cancel log streaming.
132
+ * @returns An async iterable of log entries from the command output.
133
+ *
134
+ * @see {@link Command.stdout}, {@link Command.stderr}, and {@link Command.output}
135
+ * to access output as a string.
136
+ */
137
+ logs(opts?: {
138
+ signal?: AbortSignal;
139
+ }): AsyncGenerator<LogOutputLine, void, void> & Disposable & {
140
+ close(): void;
141
+ };
142
+ /**
143
+ * Wait for a command to exit and populate its exit code.
144
+ *
145
+ * This method is useful for detached commands where you need to wait
146
+ * for completion. For non-detached commands, {@link Sandbox.runCommand}
147
+ * automatically waits and returns a {@link CommandFinished} instance.
148
+ *
149
+ * ```
150
+ * const detachedCmd = await sandbox.runCommand({ cmd: 'sleep', args: ['5'], detached: true });
151
+ * const result = await detachedCmd.wait();
152
+ * if (result.exitCode !== 0) {
153
+ * console.error("Something went wrong...")
154
+ * }
155
+ * ```
156
+ *
157
+ * @param params - Optional parameters.
158
+ * @param params.signal - An AbortSignal to cancel waiting.
159
+ * @returns A {@link CommandFinished} instance with populated exit code.
160
+ */
161
+ wait(params?: {
162
+ signal?: AbortSignal;
163
+ }): Promise<CommandFinished>;
164
+ /**
165
+ * Get cached output, fetching logs only once and reusing for concurrent calls.
166
+ * This prevents race conditions when stdout() and stderr() are called in parallel.
167
+ */
168
+ protected getCachedOutput(opts?: {
169
+ signal?: AbortSignal;
170
+ }): Promise<{
171
+ stdout: string;
172
+ stderr: string;
173
+ both: string;
174
+ }>;
175
+ /**
176
+ * Get the output of `stdout`, `stderr`, or both as a string.
177
+ *
178
+ * NOTE: This may throw string conversion errors if the command does
179
+ * not output valid Unicode.
180
+ *
181
+ * @param stream - The output stream to read: "stdout", "stderr", or "both".
182
+ * @param opts - Optional parameters.
183
+ * @param opts.signal - An AbortSignal to cancel output streaming.
184
+ * @returns The output of the specified stream(s) as a string.
185
+ */
186
+ output(stream?: "stdout" | "stderr" | "both", opts?: {
187
+ signal?: AbortSignal;
188
+ }): Promise<string>;
189
+ /**
190
+ * Get the output of `stdout` as a string.
191
+ *
192
+ * NOTE: This may throw string conversion errors if the command does
193
+ * not output valid Unicode.
194
+ *
195
+ * @param opts - Optional parameters.
196
+ * @param opts.signal - An AbortSignal to cancel output streaming.
197
+ * @returns The standard output of the command.
198
+ */
199
+ stdout(opts?: {
200
+ signal?: AbortSignal;
201
+ }): Promise<string>;
202
+ /**
203
+ * Get the output of `stderr` as a string.
204
+ *
205
+ * NOTE: This may throw string conversion errors if the command does
206
+ * not output valid Unicode.
207
+ *
208
+ * @param opts - Optional parameters.
209
+ * @param opts.signal - An AbortSignal to cancel output streaming.
210
+ * @returns The standard error output of the command.
211
+ */
212
+ stderr(opts?: {
213
+ signal?: AbortSignal;
214
+ }): Promise<string>;
215
+ /**
216
+ * Kill a running command in a sandbox.
217
+ *
218
+ * @param signal - The signal to send the running process. Defaults to SIGTERM.
219
+ * @param opts - Optional parameters.
220
+ * @param opts.abortSignal - An AbortSignal to cancel the kill operation.
221
+ * @returns Promise<void>.
222
+ */
223
+ kill(signal?: Signal, opts?: {
224
+ abortSignal?: AbortSignal;
225
+ }): Promise<void>;
226
+ }
227
+ /**
228
+ * A command that has finished executing.
229
+ *
230
+ * The exit code is immediately available and populated upon creation.
231
+ * Unlike {@link Command}, you don't need to call wait() - the command
232
+ * has already completed execution.
233
+ *
234
+ * @hideconstructor
235
+ */
236
+ declare class CommandFinished extends Command {
237
+ /**
238
+ * The exit code of the command. This is always populated for
239
+ * CommandFinished instances.
240
+ */
241
+ exitCode: number;
242
+ /**
243
+ * The duration of the command execution in milliseconds.
244
+ */
245
+ durationMs?: 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.sessionId - The ID of the session 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.durationMs - Optional duration of the command execution in milliseconds.
253
+ * @param params.output - Optional cached output to restore (used during deserialization).
254
+ */
255
+ constructor(params: {
256
+ client?: APIClient;
257
+ sessionId: string;
258
+ cmd: CommandData;
259
+ exitCode: number;
260
+ durationMs?: number;
261
+ output?: CommandOutput;
262
+ });
263
+ /**
264
+ * Serialize a CommandFinished instance to plain data for @workflow/serde.
265
+ *
266
+ * @param instance - The CommandFinished instance to serialize
267
+ * @returns A plain object containing the sandbox ID, command data, exit code, and output if fetched
268
+ */
269
+ static [WORKFLOW_SERIALIZE](instance: CommandFinished): SerializedCommandFinished;
270
+ /**
271
+ * Deserialize plain data back into a CommandFinished instance for @workflow/serde.
272
+ *
273
+ * The deserialized instance will lazily create an API client using
274
+ * OIDC or environment credentials when needed.
275
+ *
276
+ * @param data - The serialized command finished data
277
+ * @returns The reconstructed CommandFinished instance
278
+ */
279
+ static [WORKFLOW_DESERIALIZE](data: SerializedCommandFinished): CommandFinished;
280
+ /**
281
+ * The wait method is not needed for CommandFinished instances since
282
+ * the command has already completed and exitCode is populated.
283
+ *
284
+ * @deprecated This method is redundant for CommandFinished instances.
285
+ * The exitCode is already available.
286
+ * @returns This CommandFinished instance.
287
+ */
288
+ wait(): Promise<CommandFinished>;
289
+ }
290
+ //#endregion
291
+ export { Command, CommandFinished, CommandOutput, SerializedCommand, SerializedCommandFinished };
292
+ //# sourceMappingURL=command.d.ts.map
@@ -0,0 +1,5 @@
1
+ //#region src/constants.d.ts
2
+ type RUNTIMES = "node26" | "node24" | "node22" | "python3.13";
3
+ //#endregion
4
+ export { RUNTIMES };
5
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1,116 @@
1
+ import { Command, CommandFinished } from "./command.js";
2
+ import { RunCommandParams } from "./session.js";
3
+
4
+ //#region src/execution-context.d.ts
5
+
6
+ /**
7
+ * The common surface for running commands and performing file operations in
8
+ * a sandbox, regardless of scope.
9
+ *
10
+ * Implemented by {@link Sandbox}, {@link Session}, and {@link SandboxUser},
11
+ * so code can be written against "somewhere to run commands" without caring
12
+ * whether it targets the whole sandbox or a specific user's context.
13
+ *
14
+ * Implementations may scope the operations: for example, {@link SandboxUser}
15
+ * runs commands as its user and resolves relative paths against the user's
16
+ * home directory.
17
+ */
18
+ interface ExecutionContext {
19
+ /**
20
+ * Start executing a command in this context.
21
+ *
22
+ * @param command - The command to execute.
23
+ * @param args - Arguments to pass to the command.
24
+ * @param opts - Optional parameters.
25
+ * @returns A {@link CommandFinished} result once execution is done.
26
+ */
27
+ runCommand(command: string, args?: string[], opts?: {
28
+ signal?: AbortSignal;
29
+ timeoutMs?: number;
30
+ }): Promise<CommandFinished>;
31
+ /**
32
+ * Start executing a command in this context in detached mode.
33
+ *
34
+ * @param params - The command parameters.
35
+ * @returns A {@link Command} instance for the running command.
36
+ */
37
+ runCommand(params: RunCommandParams & {
38
+ detached: true;
39
+ }): Promise<Command>;
40
+ /**
41
+ * Start executing a command in this context.
42
+ *
43
+ * @param params - The command parameters.
44
+ * @returns A {@link CommandFinished} result once execution is done.
45
+ */
46
+ runCommand(params: RunCommandParams): Promise<CommandFinished>;
47
+ /**
48
+ * Create a directory in the filesystem of this context.
49
+ *
50
+ * @param path - Path of the directory to create
51
+ * @param opts - Optional parameters.
52
+ */
53
+ mkDir(path: string, opts?: {
54
+ signal?: AbortSignal;
55
+ }): Promise<void>;
56
+ /**
57
+ * Read a file from this context as a stream.
58
+ *
59
+ * @param file - File to read, with path and optional cwd
60
+ * @param opts - Optional parameters.
61
+ * @returns A ReadableStream of the file contents, or null if not found
62
+ */
63
+ readFile(file: {
64
+ path: string;
65
+ cwd?: string;
66
+ }, opts?: {
67
+ signal?: AbortSignal;
68
+ }): Promise<NodeJS.ReadableStream | null>;
69
+ /**
70
+ * Read a file from this context as a Buffer.
71
+ *
72
+ * @param file - File to read, with path and optional cwd
73
+ * @param opts - Optional parameters.
74
+ * @returns The file contents as a Buffer, or null if not found
75
+ */
76
+ readFileToBuffer(file: {
77
+ path: string;
78
+ cwd?: string;
79
+ }, opts?: {
80
+ signal?: AbortSignal;
81
+ }): Promise<Buffer | null>;
82
+ /**
83
+ * Download a file from this context to the local filesystem.
84
+ *
85
+ * @param src - Source file in the sandbox
86
+ * @param dst - Destination on the local machine
87
+ * @param opts - Optional parameters.
88
+ * @returns The absolute path to the written file, or null if not found
89
+ */
90
+ downloadFile(src: {
91
+ path: string;
92
+ cwd?: string;
93
+ }, dst: {
94
+ path: string;
95
+ cwd?: string;
96
+ }, opts?: {
97
+ mkdirRecursive?: boolean;
98
+ signal?: AbortSignal;
99
+ }): Promise<string | null>;
100
+ /**
101
+ * Write files to the filesystem of this context.
102
+ *
103
+ * @param files - Array of files with path, content, and optional mode
104
+ * @param opts - Optional parameters.
105
+ */
106
+ writeFiles(files: {
107
+ path: string;
108
+ content: string | Uint8Array;
109
+ mode?: number;
110
+ }[], opts?: {
111
+ signal?: AbortSignal;
112
+ }): Promise<void>;
113
+ }
114
+ //#endregion
115
+ export { ExecutionContext };
116
+ //# sourceMappingURL=execution-context.d.ts.map