@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.
Files changed (190) hide show
  1. package/README.md +8 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  3. package/dist/api-client/api-client.cjs +375 -0
  4. package/dist/api-client/api-client.cjs.map +1 -0
  5. package/dist/api-client/api-client.d.cts +403 -0
  6. package/dist/api-client/api-client.d.ts +397 -391
  7. package/dist/api-client/api-client.js +365 -404
  8. package/dist/api-client/api-client.js.map +1 -1
  9. package/dist/api-client/api-error.cjs +31 -0
  10. package/dist/api-client/api-error.cjs.map +1 -0
  11. package/dist/api-client/api-error.d.cts +27 -0
  12. package/dist/api-client/api-error.d.ts +19 -16
  13. package/dist/api-client/api-error.js +27 -32
  14. package/dist/api-client/api-error.js.map +1 -1
  15. package/dist/api-client/base-client.cjs +113 -0
  16. package/dist/api-client/base-client.cjs.map +1 -0
  17. package/dist/api-client/base-client.d.cts +38 -0
  18. package/dist/api-client/base-client.d.ts +31 -36
  19. package/dist/api-client/base-client.js +101 -118
  20. package/dist/api-client/base-client.js.map +1 -1
  21. package/dist/api-client/file-writer.cjs +62 -0
  22. package/dist/api-client/file-writer.cjs.map +1 -0
  23. package/dist/api-client/file-writer.d.cts +66 -0
  24. package/dist/api-client/file-writer.d.ts +56 -42
  25. package/dist/api-client/file-writer.js +57 -61
  26. package/dist/api-client/file-writer.js.map +1 -1
  27. package/dist/api-client/index.cjs +2 -0
  28. package/dist/api-client/index.d.ts +2 -2
  29. package/dist/api-client/index.js +4 -21
  30. package/dist/api-client/validators.cjs +149 -0
  31. package/dist/api-client/validators.cjs.map +1 -0
  32. package/dist/api-client/validators.d.cts +1677 -0
  33. package/dist/api-client/validators.d.ts +1501 -2412
  34. package/dist/api-client/validators.js +124 -154
  35. package/dist/api-client/validators.js.map +1 -1
  36. package/dist/api-client/with-retry.cjs +89 -0
  37. package/dist/api-client/with-retry.cjs.map +1 -0
  38. package/dist/api-client/with-retry.d.cts +10 -0
  39. package/dist/api-client/with-retry.d.ts +9 -13
  40. package/dist/api-client/with-retry.js +81 -102
  41. package/dist/api-client/with-retry.js.map +1 -1
  42. package/dist/auth/api.cjs +29 -0
  43. package/dist/auth/api.cjs.map +1 -0
  44. package/dist/auth/api.js +26 -25
  45. package/dist/auth/api.js.map +1 -1
  46. package/dist/auth/error.cjs +13 -0
  47. package/dist/auth/error.cjs.map +1 -0
  48. package/dist/auth/error.js +11 -11
  49. package/dist/auth/error.js.map +1 -1
  50. package/dist/auth/file.cjs +64 -0
  51. package/dist/auth/file.cjs.map +1 -0
  52. package/dist/auth/file.d.cts +26 -0
  53. package/dist/auth/file.d.ts +19 -15
  54. package/dist/auth/file.js +49 -64
  55. package/dist/auth/file.js.map +1 -1
  56. package/dist/auth/index.cjs +12 -0
  57. package/dist/auth/index.d.cts +5 -0
  58. package/dist/auth/index.d.ts +5 -6
  59. package/dist/auth/index.js +6 -27
  60. package/dist/auth/linked-project.cjs +38 -0
  61. package/dist/auth/linked-project.cjs.map +1 -0
  62. package/dist/auth/linked-project.js +30 -64
  63. package/dist/auth/linked-project.js.map +1 -1
  64. package/dist/auth/oauth.cjs +205 -0
  65. package/dist/auth/oauth.cjs.map +1 -0
  66. package/dist/auth/oauth.d.cts +135 -0
  67. package/dist/auth/oauth.d.ts +113 -109
  68. package/dist/auth/oauth.js +185 -252
  69. package/dist/auth/oauth.js.map +1 -1
  70. package/dist/auth/poll-for-token.cjs +82 -0
  71. package/dist/auth/poll-for-token.cjs.map +1 -0
  72. package/dist/auth/poll-for-token.d.cts +28 -0
  73. package/dist/auth/poll-for-token.d.ts +23 -15
  74. package/dist/auth/poll-for-token.js +79 -64
  75. package/dist/auth/poll-for-token.js.map +1 -1
  76. package/dist/auth/project.cjs +80 -0
  77. package/dist/auth/project.cjs.map +1 -0
  78. package/dist/auth/project.d.cts +44 -0
  79. package/dist/auth/project.d.ts +12 -8
  80. package/dist/auth/project.js +70 -72
  81. package/dist/auth/project.js.map +1 -1
  82. package/dist/auth/zod.cjs +22 -0
  83. package/dist/auth/zod.cjs.map +1 -0
  84. package/dist/auth/zod.js +18 -17
  85. package/dist/auth/zod.js.map +1 -1
  86. package/dist/command.cjs +326 -0
  87. package/dist/command.cjs.map +1 -0
  88. package/dist/command.d.cts +289 -0
  89. package/dist/command.d.ts +265 -171
  90. package/dist/command.js +321 -226
  91. package/dist/command.js.map +1 -1
  92. package/dist/constants.d.cts +5 -0
  93. package/dist/constants.d.ts +5 -1
  94. package/dist/index.cjs +11 -0
  95. package/dist/index.d.cts +6 -0
  96. package/dist/index.d.ts +6 -5
  97. package/dist/index.js +6 -15
  98. package/dist/network-policy.d.cts +100 -0
  99. package/dist/network-policy.d.ts +32 -28
  100. package/dist/sandbox.cjs +543 -0
  101. package/dist/sandbox.cjs.map +1 -0
  102. package/dist/sandbox.d.cts +538 -0
  103. package/dist/sandbox.d.ts +521 -472
  104. package/dist/sandbox.js +539 -506
  105. package/dist/sandbox.js.map +1 -1
  106. package/dist/snapshot.cjs +116 -0
  107. package/dist/snapshot.cjs.map +1 -0
  108. package/dist/snapshot.d.cts +109 -0
  109. package/dist/snapshot.d.ts +100 -92
  110. package/dist/snapshot.js +114 -114
  111. package/dist/snapshot.js.map +1 -1
  112. package/dist/utils/array.cjs +17 -0
  113. package/dist/utils/array.cjs.map +1 -0
  114. package/dist/utils/array.js +12 -15
  115. package/dist/utils/array.js.map +1 -1
  116. package/dist/utils/consume-readable.cjs +18 -0
  117. package/dist/utils/consume-readable.cjs.map +1 -0
  118. package/dist/utils/consume-readable.js +13 -12
  119. package/dist/utils/consume-readable.js.map +1 -1
  120. package/dist/utils/decode-base64-url.cjs +15 -0
  121. package/dist/utils/decode-base64-url.cjs.map +1 -0
  122. package/dist/utils/decode-base64-url.js +10 -9
  123. package/dist/utils/decode-base64-url.js.map +1 -1
  124. package/dist/utils/dev-credentials.cjs +142 -0
  125. package/dist/utils/dev-credentials.cjs.map +1 -0
  126. package/dist/utils/dev-credentials.js +126 -184
  127. package/dist/utils/dev-credentials.js.map +1 -1
  128. package/dist/utils/get-credentials.cjs +123 -0
  129. package/dist/utils/get-credentials.cjs.map +1 -0
  130. package/dist/utils/get-credentials.d.cts +21 -0
  131. package/dist/utils/get-credentials.d.ts +19 -61
  132. package/dist/utils/get-credentials.js +106 -140
  133. package/dist/utils/get-credentials.js.map +1 -1
  134. package/dist/utils/log.cjs +25 -0
  135. package/dist/utils/log.cjs.map +1 -0
  136. package/dist/utils/log.js +15 -17
  137. package/dist/utils/log.js.map +1 -1
  138. package/dist/utils/network-policy.cjs +65 -0
  139. package/dist/utils/network-policy.cjs.map +1 -0
  140. package/dist/utils/network-policy.js +58 -77
  141. package/dist/utils/network-policy.js.map +1 -1
  142. package/dist/utils/normalizePath.cjs +27 -0
  143. package/dist/utils/normalizePath.cjs.map +1 -0
  144. package/dist/utils/normalizePath.js +21 -28
  145. package/dist/utils/normalizePath.js.map +1 -1
  146. package/dist/utils/resolveSignal.cjs +20 -0
  147. package/dist/utils/resolveSignal.cjs.map +1 -0
  148. package/dist/utils/resolveSignal.d.cts +15 -0
  149. package/dist/utils/resolveSignal.d.ts +12 -10
  150. package/dist/utils/resolveSignal.js +14 -17
  151. package/dist/utils/resolveSignal.js.map +1 -1
  152. package/dist/utils/sandbox-snapshot.cjs +14 -0
  153. package/dist/utils/sandbox-snapshot.cjs.map +1 -0
  154. package/dist/utils/sandbox-snapshot.d.cts +10 -0
  155. package/dist/utils/sandbox-snapshot.d.ts +11 -0
  156. package/dist/utils/sandbox-snapshot.js +14 -0
  157. package/dist/utils/sandbox-snapshot.js.map +1 -0
  158. package/dist/utils/types.cjs +13 -0
  159. package/dist/utils/types.cjs.map +1 -0
  160. package/dist/utils/types.d.cts +11 -0
  161. package/dist/utils/types.d.ts +5 -7
  162. package/dist/utils/types.js +8 -8
  163. package/dist/utils/types.js.map +1 -1
  164. package/dist/version.cjs +7 -0
  165. package/dist/version.cjs.map +1 -0
  166. package/dist/version.js +5 -5
  167. package/dist/version.js.map +1 -1
  168. package/package.json +23 -3
  169. package/dist/api-client/index.js.map +0 -1
  170. package/dist/auth/api.d.ts +0 -6
  171. package/dist/auth/error.d.ts +0 -11
  172. package/dist/auth/index.js.map +0 -1
  173. package/dist/auth/linked-project.d.ts +0 -10
  174. package/dist/auth/zod.d.ts +0 -5
  175. package/dist/constants.js +0 -3
  176. package/dist/constants.js.map +0 -1
  177. package/dist/index.js.map +0 -1
  178. package/dist/network-policy.js +0 -3
  179. package/dist/network-policy.js.map +0 -1
  180. package/dist/utils/array.d.ts +0 -9
  181. package/dist/utils/consume-readable.d.ts +0 -5
  182. package/dist/utils/convert-sandbox.d.ts +0 -6
  183. package/dist/utils/convert-sandbox.js +0 -14
  184. package/dist/utils/convert-sandbox.js.map +0 -1
  185. package/dist/utils/decode-base64-url.d.ts +0 -7
  186. package/dist/utils/dev-credentials.d.ts +0 -37
  187. package/dist/utils/log.d.ts +0 -2
  188. package/dist/utils/network-policy.d.ts +0 -7
  189. package/dist/utils/normalizePath.d.ts +0 -17
  190. package/dist/version.d.ts +0 -1
package/dist/command.d.ts CHANGED
@@ -1,5 +1,32 @@
1
- import { APIClient, type CommandData } from "./api-client";
2
- import { Signal } from "./utils/resolveSignal";
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
- export declare class Command {
17
- /**
18
- * @internal
19
- * @private
20
- */
21
- protected client: APIClient;
22
- /**
23
- * ID of the sandbox this command is running in.
24
- */
25
- private sandboxId;
26
- /**
27
- * Data for the command execution.
28
- */
29
- private cmd;
30
- exitCode: number | null;
31
- private outputCache;
32
- /**
33
- * ID of the command execution.
34
- */
35
- get cmdId(): string;
36
- get cwd(): string;
37
- get startedAt(): number;
38
- /**
39
- * @param params - Object containing the client, sandbox ID, and command ID.
40
- * @param params.client - API client used to interact with the backend.
41
- * @param params.sandboxId - The ID of the sandbox where the command is running.
42
- * @param params.cmdId - The ID of the command execution.
43
- */
44
- constructor({ client, sandboxId, cmd, }: {
45
- client: APIClient;
46
- sandboxId: string;
47
- cmd: CommandData;
48
- });
49
- /**
50
- * Iterate over the output of this command.
51
- *
52
- * ```
53
- * for await (const log of cmd.logs()) {
54
- * if (log.stream === "stdout") {
55
- * process.stdout.write(log.data);
56
- * } else {
57
- * process.stderr.write(log.data);
58
- * }
59
- * }
60
- * ```
61
- *
62
- * @param opts - Optional parameters.
63
- * @param opts.signal - An AbortSignal to cancel log streaming.
64
- * @returns An async iterable of log entries from the command output.
65
- *
66
- * @see {@link Command.stdout}, {@link Command.stderr}, and {@link Command.output}
67
- * to access output as a string.
68
- */
69
- logs(opts?: {
70
- signal?: AbortSignal;
71
- }): AsyncGenerator<{
72
- data: string;
73
- stream: "stdout";
74
- } | {
75
- data: string;
76
- stream: "stderr";
77
- }, void, void> & Disposable & {
78
- close(): void;
79
- };
80
- /**
81
- * Wait for a command to exit and populate its exit code.
82
- *
83
- * This method is useful for detached commands where you need to wait
84
- * for completion. For non-detached commands, {@link Sandbox.runCommand}
85
- * automatically waits and returns a {@link CommandFinished} instance.
86
- *
87
- * ```
88
- * const detachedCmd = await sandbox.runCommand({ cmd: 'sleep', args: ['5'], detached: true });
89
- * const result = await detachedCmd.wait();
90
- * if (result.exitCode !== 0) {
91
- * console.error("Something went wrong...")
92
- * }
93
- * ```
94
- *
95
- * @param params - Optional parameters.
96
- * @param params.signal - An AbortSignal to cancel waiting.
97
- * @returns A {@link CommandFinished} instance with populated exit code.
98
- */
99
- wait(params?: {
100
- signal?: AbortSignal;
101
- }): Promise<CommandFinished>;
102
- /**
103
- * Get cached output, fetching logs only once and reusing for concurrent calls.
104
- * This prevents race conditions when stdout() and stderr() are called in parallel.
105
- */
106
- private getCachedOutput;
107
- /**
108
- * Get the output of `stdout`, `stderr`, or both as a string.
109
- *
110
- * NOTE: This may throw string conversion errors if the command does
111
- * not output valid Unicode.
112
- *
113
- * @param stream - The output stream to read: "stdout", "stderr", or "both".
114
- * @param opts - Optional parameters.
115
- * @param opts.signal - An AbortSignal to cancel output streaming.
116
- * @returns The output of the specified stream(s) as a string.
117
- */
118
- output(stream?: "stdout" | "stderr" | "both", opts?: {
119
- signal?: AbortSignal;
120
- }): Promise<string>;
121
- /**
122
- * Get the output of `stdout` as a string.
123
- *
124
- * NOTE: This may throw string conversion errors if the command does
125
- * not output valid Unicode.
126
- *
127
- * @param opts - Optional parameters.
128
- * @param opts.signal - An AbortSignal to cancel output streaming.
129
- * @returns The standard output of the command.
130
- */
131
- stdout(opts?: {
132
- signal?: AbortSignal;
133
- }): Promise<string>;
134
- /**
135
- * Get the output of `stderr` as a string.
136
- *
137
- * NOTE: This may throw string conversion errors if the command does
138
- * not output valid Unicode.
139
- *
140
- * @param opts - Optional parameters.
141
- * @param opts.signal - An AbortSignal to cancel output streaming.
142
- * @returns The standard error output of the command.
143
- */
144
- stderr(opts?: {
145
- signal?: AbortSignal;
146
- }): Promise<string>;
147
- /**
148
- * Kill a running command in a sandbox.
149
- *
150
- * @param signal - The signal to send the running process. Defaults to SIGTERM.
151
- * @param opts - Optional parameters.
152
- * @param opts.abortSignal - An AbortSignal to cancel the kill operation.
153
- * @returns Promise<void>.
154
- */
155
- kill(signal?: Signal, opts?: {
156
- abortSignal?: AbortSignal;
157
- }): Promise<void>;
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
- export declare class CommandFinished extends Command {
169
- /**
170
- * The exit code of the command. This is always populated for
171
- * CommandFinished instances.
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
- * @param params - Object containing client, sandbox ID, command ID, and exit code.
176
- * @param params.client - API client used to interact with the backend.
177
- * @param params.sandboxId - The ID of the sandbox where the command ran.
178
- * @param params.cmdId - The ID of the command execution.
179
- * @param params.exitCode - The exit code of the completed command.
180
- */
181
- constructor(params: {
182
- client: APIClient;
183
- sandboxId: string;
184
- cmd: CommandData;
185
- exitCode: number;
186
- });
187
- /**
188
- * The wait method is not needed for CommandFinished instances since
189
- * the command has already completed and exitCode is populated.
190
- *
191
- * @deprecated This method is redundant for CommandFinished instances.
192
- * The exitCode is already available.
193
- * @returns This CommandFinished instance.
194
- */
195
- wait(): Promise<CommandFinished>;
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