eve 0.12.1 → 0.12.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.
Files changed (126) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/src/cli/commands/agent-instructions.d.ts +15 -3
  3. package/dist/src/cli/commands/agent-instructions.js +3 -1
  4. package/dist/src/cli/commands/agent-prompt/build-and-verify.md +33 -0
  5. package/dist/src/cli/commands/agent-prompt/collect-intent.md +18 -0
  6. package/dist/src/cli/commands/agent-prompt/intro-handoff.md +4 -0
  7. package/dist/src/cli/commands/agent-prompt/intro-setup.md +5 -0
  8. package/dist/src/cli/commands/agent-prompt/scaffold.md +19 -0
  9. package/dist/src/cli/commands/agent-prompt/vercel-connect.md +3 -0
  10. package/dist/src/cli/commands/init-repl.d.ts +79 -0
  11. package/dist/src/cli/commands/init-repl.js +1 -0
  12. package/dist/src/cli/commands/init.d.ts +6 -0
  13. package/dist/src/cli/commands/init.js +1 -1
  14. package/dist/src/cli/dev/tui/line-editor.d.ts +2 -0
  15. package/dist/src/cli/dev/tui/line-editor.js +2 -2
  16. package/dist/src/cli/dev/tui/prompt-command-handler.js +1 -1
  17. package/dist/src/cli/dev/tui/setup-commands.d.ts +26 -7
  18. package/dist/src/cli/dev/tui/setup-commands.js +2 -2
  19. package/dist/src/cli/dev/tui/setup-flow.d.ts +5 -3
  20. package/dist/src/cli/dev/tui/setup-panel.d.ts +12 -7
  21. package/dist/src/cli/dev/tui/setup-panel.js +3 -3
  22. package/dist/src/cli/dev/tui/terminal-renderer.js +10 -10
  23. package/dist/src/cli/dev/tui/terminal-text.d.ts +11 -0
  24. package/dist/src/cli/dev/tui/terminal-text.js +1 -1
  25. package/dist/src/cli/run.d.ts +1 -0
  26. package/dist/src/cli/run.js +2 -2
  27. package/dist/src/cli/ui/live-row.js +1 -1
  28. package/dist/src/cli/ui/progress-pulse.d.ts +10 -0
  29. package/dist/src/cli/ui/progress-pulse.js +1 -0
  30. package/dist/src/compiled/.vendor-stamp.json +1 -1
  31. package/dist/src/compiled/@vercel/sandbox/_async-retry.d.ts +8 -0
  32. package/dist/src/compiled/@vercel/sandbox/_workflow-serde.d.ts +5 -0
  33. package/dist/src/compiled/@vercel/sandbox/api-client/api-client.d.ts +1442 -0
  34. package/dist/src/compiled/@vercel/sandbox/api-client/api-error.d.ts +29 -0
  35. package/dist/src/compiled/@vercel/sandbox/api-client/base-client.d.ts +39 -0
  36. package/dist/src/compiled/@vercel/sandbox/api-client/file-writer.d.ts +66 -0
  37. package/dist/src/compiled/@vercel/sandbox/api-client/index.d.ts +2 -0
  38. package/dist/src/compiled/@vercel/sandbox/api-client/validators.d.ts +878 -0
  39. package/dist/src/compiled/@vercel/sandbox/api-client/with-retry.d.ts +10 -0
  40. package/dist/src/compiled/@vercel/sandbox/auth/error.d.ts +15 -0
  41. package/dist/src/compiled/@vercel/sandbox/auth/file.d.ts +18 -0
  42. package/dist/src/compiled/@vercel/sandbox/auth/index.d.ts +6 -0
  43. package/dist/src/compiled/@vercel/sandbox/auth/oauth.d.ts +111 -0
  44. package/dist/src/compiled/@vercel/sandbox/auth/poll-for-token.d.ts +28 -0
  45. package/dist/src/compiled/@vercel/sandbox/auth/project.d.ts +40 -0
  46. package/dist/src/compiled/@vercel/sandbox/command.d.ts +290 -0
  47. package/dist/src/compiled/@vercel/sandbox/constants.d.ts +5 -0
  48. package/dist/src/compiled/@vercel/sandbox/filesystem.d.ts +258 -0
  49. package/dist/src/compiled/@vercel/sandbox/index.d.ts +10 -129
  50. package/dist/src/compiled/@vercel/sandbox/proxy.d.ts +55 -0
  51. package/dist/src/compiled/@vercel/sandbox/sandbox.d.ts +1058 -0
  52. package/dist/src/compiled/@vercel/sandbox/session.d.ts +432 -0
  53. package/dist/src/compiled/@vercel/sandbox/snapshot.d.ts +229 -0
  54. package/dist/src/compiled/@vercel/sandbox/utils/get-credentials.d.ts +21 -0
  55. package/dist/src/compiled/@vercel/sandbox/utils/paginator.d.ts +16 -0
  56. package/dist/src/compiled/@vercel/sandbox/utils/resolveSignal.d.ts +15 -0
  57. package/dist/src/compiled/@vercel/sandbox/utils/sandbox-snapshot.d.ts +11 -0
  58. package/dist/src/compiled/@vercel/sandbox/utils/types.d.ts +11 -0
  59. package/dist/src/compiled/chat/_workflow-serde.d.ts +3 -0
  60. package/dist/src/compiled/chat/index.d.ts +1 -1
  61. package/dist/src/discover/discover-agent.js +1 -1
  62. package/dist/src/evals/target.js +1 -1
  63. package/dist/src/execution/node-step.js +1 -1
  64. package/dist/src/execution/sandbox/bindings/just-bash-runtime.js +1 -1
  65. package/dist/src/execution/sandbox/bindings/vercel-base-runtime.d.ts +3 -3
  66. package/dist/src/execution/sandbox/bindings/vercel-create-sdk.d.ts +8 -13
  67. package/dist/src/execution/sandbox/bindings/vercel-credentials.d.ts +3 -3
  68. package/dist/src/execution/sandbox/bindings/vercel-lookup.d.ts +4 -5
  69. package/dist/src/execution/sandbox/bindings/vercel-read-stream.d.ts +5 -0
  70. package/dist/src/execution/sandbox/bindings/vercel-read-stream.js +1 -0
  71. package/dist/src/execution/sandbox/bindings/vercel-sdk-types.d.ts +5 -0
  72. package/dist/src/execution/sandbox/bindings/vercel-sdk-types.js +1 -0
  73. package/dist/src/execution/sandbox/bindings/vercel.d.ts +4 -4
  74. package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
  75. package/dist/src/execution/sandbox/multiplexed-command.d.ts +22 -0
  76. package/dist/src/execution/sandbox/multiplexed-command.js +1 -0
  77. package/dist/src/execution/tool-auth.d.ts +13 -3
  78. package/dist/src/execution/tool-auth.js +1 -1
  79. package/dist/src/execution/workflow-steps.js +1 -1
  80. package/dist/src/harness/tool-loop.js +1 -1
  81. package/dist/src/internal/application/package.js +1 -1
  82. package/dist/src/internal/authored-module-loader.js +2 -2
  83. package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
  84. package/dist/src/public/channels/slack/connections.d.ts +16 -18
  85. package/dist/src/public/channels/slack/defaults.d.ts +1 -1
  86. package/dist/src/public/channels/slack/defaults.js +1 -1
  87. package/dist/src/public/channels/slack/slackChannel.d.ts +6 -7
  88. package/dist/src/public/definitions/tool.d.ts +64 -20
  89. package/dist/src/public/sandbox/vercel-sandbox.d.ts +12 -9
  90. package/dist/src/public/tools/index.d.ts +1 -1
  91. package/dist/src/runtime/connections/scoped-authorization.js +1 -1
  92. package/dist/src/runtime/connections/validate-authorization.js +1 -1
  93. package/dist/src/runtime/framework-tools/connection-search-dynamic.js +1 -1
  94. package/dist/src/setup/ai-gateway-api-key.d.ts +15 -0
  95. package/dist/src/setup/ai-gateway-api-key.js +1 -0
  96. package/dist/src/setup/boxes/apply-ai-gateway-credential.js +1 -1
  97. package/dist/src/setup/boxes/detect-ai-gateway.js +2 -2
  98. package/dist/src/setup/boxes/resolve-provisioning.js +1 -1
  99. package/dist/src/setup/flows/channels.js +1 -1
  100. package/dist/src/setup/flows/deploy.js +1 -1
  101. package/dist/src/setup/flows/install-vercel-cli.js +1 -1
  102. package/dist/src/setup/flows/link.d.ts +2 -1
  103. package/dist/src/setup/flows/link.js +1 -1
  104. package/dist/src/setup/flows/login.js +1 -1
  105. package/dist/src/setup/flows/model.d.ts +3 -2
  106. package/dist/src/setup/flows/model.js +1 -1
  107. package/dist/src/setup/flows/vercel.js +2 -2
  108. package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
  109. package/dist/src/setup/scaffold/create/project.js +1 -1
  110. package/dist/src/setup/vercel-project.d.ts +2 -6
  111. package/dist/src/setup/vercel-project.js +1 -1
  112. package/dist/src/setup/with-spinner.d.ts +3 -0
  113. package/dist/src/setup/with-spinner.js +1 -0
  114. package/dist/src/shared/package-name.d.ts +4 -0
  115. package/dist/src/shared/package-name.js +1 -0
  116. package/dist/src/shared/sandbox-network-policy.d.ts +2 -2
  117. package/docs/channels/slack.mdx +1 -1
  118. package/docs/connections.mdx +9 -6
  119. package/docs/getting-started.mdx +8 -3
  120. package/docs/guides/auth-and-route-protection.md +59 -10
  121. package/docs/guides/dev-tui.md +2 -2
  122. package/docs/reference/cli.md +2 -2
  123. package/docs/reference/typescript-api.md +9 -7
  124. package/package.json +1 -1
  125. package/dist/src/cli/commands/init-agent-handoff.md +0 -12
  126. package/dist/src/cli/commands/init-agent-instructions.md +0 -16
@@ -0,0 +1,432 @@
1
+ import { SandboxMetaData, SandboxRouteData, SessionMetaData, SnapshotMetadata } from "./api-client/validators.js";
2
+ import { NetworkPolicy, NetworkPolicyRule, NetworkTransformer } from "./network-policy.js";
3
+ import { APIClient } from "./api-client/api-client.js";
4
+ import "./api-client/index.js";
5
+ import { Command, CommandFinished } from "./command.js";
6
+ import { Snapshot } from "./snapshot.js";
7
+ import { SandboxSnapshot } from "./utils/sandbox-snapshot.js";
8
+ import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE } from "./_workflow-serde.js";
9
+ import { Writable } from "stream";
10
+
11
+ //#region src/session.d.ts
12
+ /**
13
+ * Serialized representation of a Session for @workflow/serde.
14
+ */
15
+ interface SerializedSession {
16
+ session: SandboxSnapshot;
17
+ routes: SandboxRouteData[];
18
+ }
19
+ /** @inline */
20
+ interface RunCommandParams {
21
+ /**
22
+ * The command to execute
23
+ */
24
+ cmd: string;
25
+ /**
26
+ * Arguments to pass to the command
27
+ */
28
+ args?: string[];
29
+ /**
30
+ * Working directory to execute the command in
31
+ */
32
+ cwd?: string;
33
+ /**
34
+ * Environment variables to set for this command
35
+ */
36
+ env?: Record<string, string>;
37
+ /**
38
+ * If true, execute this command with root privileges. Defaults to false.
39
+ */
40
+ sudo?: boolean;
41
+ /**
42
+ * If true, the command will return without waiting for `exitCode`
43
+ */
44
+ detached?: boolean;
45
+ /**
46
+ * A `Writable` stream where `stdout` from the command will be piped
47
+ */
48
+ stdout?: Writable;
49
+ /**
50
+ * A `Writable` stream where `stderr` from the command will be piped
51
+ */
52
+ stderr?: Writable;
53
+ /**
54
+ * An AbortSignal to cancel the command execution
55
+ */
56
+ signal?: AbortSignal;
57
+ /**
58
+ * Maximum time in milliseconds the command may run before it is killed with
59
+ * SIGKILL. The timeout is enforced by the sandbox at exec time, so it applies
60
+ * whether or not the command is awaited (including `detached: true`).
61
+ */
62
+ timeoutMs?: number;
63
+ }
64
+ /**
65
+ * A Session represents a running VM instance within a {@link Sandbox}.
66
+ *
67
+ * Obtain a session via {@link Sandbox.currentSession}.
68
+ */
69
+ declare class Session {
70
+ private _client;
71
+ /**
72
+ * Lazily resolve credentials and construct an API client.
73
+ * This is used in step contexts where the Sandbox was deserialized
74
+ * without a client (e.g. when crossing workflow/step boundaries).
75
+ * Uses getCredentials() which resolves from OIDC or env vars.
76
+ * @internal
77
+ */
78
+ private ensureClient;
79
+ /**
80
+ * Routes from ports to subdomains.
81
+ * @hidden
82
+ */
83
+ readonly routes: SandboxRouteData[];
84
+ /**
85
+ * Internal metadata about the current session.
86
+ */
87
+ private session;
88
+ private get client();
89
+ /** @internal */
90
+ get _sessionSnapshot(): SandboxSnapshot;
91
+ /**
92
+ * Unique ID of this session.
93
+ */
94
+ get sessionId(): string;
95
+ get interactivePort(): number | undefined;
96
+ /**
97
+ * The status of this session.
98
+ */
99
+ get status(): SessionMetaData["status"];
100
+ /**
101
+ * The creation date of this session.
102
+ */
103
+ get createdAt(): Date;
104
+ /**
105
+ * The timeout of this session in milliseconds.
106
+ */
107
+ get timeout(): number;
108
+ /**
109
+ * The network policy of this session.
110
+ */
111
+ get networkPolicy(): NetworkPolicy | undefined;
112
+ /**
113
+ * If the session was created from a snapshot, the ID of that snapshot.
114
+ */
115
+ get sourceSnapshotId(): string | undefined;
116
+ /**
117
+ * Memory allocated to this session in MB.
118
+ */
119
+ get memory(): number;
120
+ /**
121
+ * Number of vCPUs allocated to this session.
122
+ */
123
+ get vcpus(): number;
124
+ /**
125
+ * The region where this session is hosted.
126
+ */
127
+ get region(): string;
128
+ /**
129
+ * Runtime identifier (e.g. "node24", "python3.13").
130
+ */
131
+ get runtime(): string;
132
+ /**
133
+ * The working directory of this session.
134
+ */
135
+ get cwd(): string;
136
+ /**
137
+ * When this session was requested.
138
+ */
139
+ get requestedAt(): Date;
140
+ /**
141
+ * When this session started running.
142
+ */
143
+ get startedAt(): Date | undefined;
144
+ /**
145
+ * When this session was requested to stop.
146
+ */
147
+ get requestedStopAt(): Date | undefined;
148
+ /**
149
+ * When this session was stopped.
150
+ */
151
+ get stoppedAt(): Date | undefined;
152
+ /**
153
+ * When this session was aborted.
154
+ */
155
+ get abortedAt(): Date | undefined;
156
+ /**
157
+ * The wall-clock duration of this session in milliseconds.
158
+ */
159
+ get duration(): number | undefined;
160
+ /**
161
+ * When a snapshot was requested for this session.
162
+ */
163
+ get snapshottedAt(): Date | undefined;
164
+ /**
165
+ * When this session was last updated.
166
+ */
167
+ get updatedAt(): Date;
168
+ /**
169
+ * The amount of active CPU used by the session. Only reported once the VM is
170
+ * stopped.
171
+ */
172
+ get activeCpuUsageMs(): number | undefined;
173
+ /**
174
+ * The amount of network data used by the session. Only reported once the VM
175
+ * is stopped.
176
+ */
177
+ get networkTransfer(): {
178
+ ingress: number;
179
+ egress: number;
180
+ } | undefined;
181
+ /**
182
+ * Serialize a Session instance to plain data for @workflow/serde.
183
+ *
184
+ * Although Sandbox handles top-level serialization, Session needs these
185
+ * methods so the Workflow SWC compiler can resolve the class by name.
186
+ * The `new Session(...)` self-reference in WORKFLOW_DESERIALIZE forces
187
+ * rolldown to preserve the class name in the compiled output.
188
+ */
189
+ static [WORKFLOW_SERIALIZE](instance: Session): SerializedSession;
190
+ static [WORKFLOW_DESERIALIZE](data: SerializedSession): Session;
191
+ constructor(params: {
192
+ client: APIClient;
193
+ routes: SandboxRouteData[];
194
+ session: SessionMetaData;
195
+ } | {
196
+ /** @internal – used during deserialization with an already-converted snapshot */
197
+ routes: SandboxRouteData[];
198
+ snapshot: SandboxSnapshot;
199
+ });
200
+ /** @internal */
201
+ updateRoutes(routes: SandboxRouteData[]): void;
202
+ /**
203
+ * Get a previously run command by its ID.
204
+ *
205
+ * @param cmdId - ID of the command to retrieve
206
+ * @param opts - Optional parameters.
207
+ * @param opts.signal - An AbortSignal to cancel the operation.
208
+ * @returns A {@link Command} instance representing the command
209
+ */
210
+ getCommand(cmdId: string, opts?: {
211
+ signal?: AbortSignal;
212
+ }): Promise<Command>;
213
+ /**
214
+ * Start executing a command in this session.
215
+ *
216
+ * @param command - The command to execute.
217
+ * @param args - Arguments to pass to the command.
218
+ * @param opts - Optional parameters.
219
+ * @param opts.signal - An AbortSignal to cancel the command execution.
220
+ * @param opts.timeoutMs - Maximum time in milliseconds to wait for the
221
+ * command to complete. On expiry the process is killed with SIGKILL.
222
+ * @returns A {@link CommandFinished} result once execution is done.
223
+ */
224
+ runCommand(command: string, args?: string[], opts?: {
225
+ signal?: AbortSignal;
226
+ timeoutMs?: number;
227
+ }): Promise<CommandFinished>;
228
+ /**
229
+ * Start executing a command in detached mode.
230
+ *
231
+ * @param params - The command parameters.
232
+ * @returns A {@link Command} instance for the running command.
233
+ */
234
+ runCommand(params: RunCommandParams & {
235
+ detached: true;
236
+ }): Promise<Command>;
237
+ /**
238
+ * Start executing a command in this session.
239
+ *
240
+ * @param params - The command parameters.
241
+ * @returns A {@link CommandFinished} result once execution is done.
242
+ */
243
+ runCommand(params: RunCommandParams): Promise<CommandFinished>;
244
+ /**
245
+ * Create a directory in the filesystem of this session.
246
+ *
247
+ * @param path - Path of the directory to create
248
+ * @param opts - Optional parameters.
249
+ * @param opts.signal - An AbortSignal to cancel the operation.
250
+ */
251
+ mkDir(path: string, opts?: {
252
+ signal?: AbortSignal;
253
+ }): Promise<void>;
254
+ /**
255
+ * Open an interactive shell session. Returns the WebSocket URL and token the
256
+ * client uses to connect to the controller-hosted PTY.
257
+ *
258
+ * @param opts - Optional parameters.
259
+ * @param opts.signal - An AbortSignal to cancel the operation.
260
+ */
261
+ openInteractive(opts?: {
262
+ signal?: AbortSignal;
263
+ }): Promise<{
264
+ url: string;
265
+ token: string;
266
+ }>;
267
+ /**
268
+ * Read a file from the filesystem of this session as a stream.
269
+ *
270
+ * @param file - File to read, with path and optional cwd
271
+ * @param opts - Optional parameters.
272
+ * @param opts.signal - An AbortSignal to cancel the operation.
273
+ * @returns A promise that resolves to a ReadableStream containing the file contents, or null if file not found
274
+ */
275
+ readFile(file: {
276
+ path: string;
277
+ cwd?: string;
278
+ }, opts?: {
279
+ signal?: AbortSignal;
280
+ }): Promise<NodeJS.ReadableStream | null>;
281
+ /**
282
+ * Read a file from the filesystem of this session as a Buffer.
283
+ *
284
+ * @param file - File to read, with path and optional cwd
285
+ * @param opts - Optional parameters.
286
+ * @param opts.signal - An AbortSignal to cancel the operation.
287
+ * @returns A promise that resolves to the file contents as a Buffer, or null if file not found
288
+ */
289
+ readFileToBuffer(file: {
290
+ path: string;
291
+ cwd?: string;
292
+ }, opts?: {
293
+ signal?: AbortSignal;
294
+ }): Promise<Buffer | null>;
295
+ /**
296
+ * Download a file from the session to the local filesystem.
297
+ *
298
+ * @param src - Source file on the session, with path and optional cwd
299
+ * @param dst - Destination file on the local machine, with path and optional cwd
300
+ * @param opts - Optional parameters.
301
+ * @param opts.mkdirRecursive - If true, create parent directories for the destination if they don't exist.
302
+ * @param opts.signal - An AbortSignal to cancel the operation.
303
+ * @returns The absolute path to the written file, or null if the source file was not found
304
+ */
305
+ downloadFile(src: {
306
+ path: string;
307
+ cwd?: string;
308
+ }, dst: {
309
+ path: string;
310
+ cwd?: string;
311
+ }, opts?: {
312
+ mkdirRecursive?: boolean;
313
+ signal?: AbortSignal;
314
+ }): Promise<string | null>;
315
+ /**
316
+ * Write files to the filesystem of this session.
317
+ * Defaults to writing to /vercel/sandbox unless an absolute path is specified.
318
+ * Writes files using the `vercel-sandbox` user.
319
+ *
320
+ * @param files - Array of files with path and stream/buffer contents
321
+ * @param opts - Optional parameters.
322
+ * @param opts.signal - An AbortSignal to cancel the operation.
323
+ * @returns A promise that resolves when the files are written
324
+ */
325
+ writeFiles(files: {
326
+ path: string;
327
+ content: string | Uint8Array;
328
+ mode?: number;
329
+ }[], opts?: {
330
+ signal?: AbortSignal;
331
+ }): Promise<void>;
332
+ /**
333
+ * Get the public domain of a port of this session.
334
+ *
335
+ * @param p - Port number to resolve
336
+ * @returns A full domain (e.g. `https://subdomain.vercel.run`)
337
+ * @throws If the port has no associated route
338
+ */
339
+ domain(p: number): string;
340
+ /**
341
+ * Stop this session.
342
+ *
343
+ * @param opts - Optional parameters.
344
+ * @param opts.signal - An AbortSignal to cancel the operation.
345
+ * @returns The final session state and optional sandbox metadata.
346
+ */
347
+ stop(opts?: {
348
+ signal?: AbortSignal;
349
+ }): Promise<{
350
+ session: SandboxSnapshot;
351
+ sandbox?: SandboxMetaData;
352
+ snapshot?: SnapshotMetadata;
353
+ }>;
354
+ /**
355
+ * Update the current session's settings.
356
+ *
357
+ * @param params - Fields to update.
358
+ * @param params.networkPolicy - The new network policy to apply.
359
+ * @param opts - Optional parameters.
360
+ * @param opts.signal - An AbortSignal to cancel the operation.
361
+ *
362
+ * @example
363
+ * // Restrict to specific domains
364
+ * await session.update({
365
+ * networkPolicy: {
366
+ * allow: ["*.npmjs.org", "github.com"],
367
+ * }
368
+ * });
369
+ *
370
+ * @example
371
+ * // Inject credentials with per-domain transformers
372
+ * await session.update({
373
+ * networkPolicy: {
374
+ * allow: {
375
+ * "ai-gateway.vercel.sh": [{
376
+ * transform: [{
377
+ * headers: { authorization: "Bearer ..." }
378
+ * }]
379
+ * }],
380
+ * "*": []
381
+ * }
382
+ * }
383
+ * });
384
+ *
385
+ * @example
386
+ * // Deny all network access
387
+ * await session.update({ networkPolicy: "deny-all" });
388
+ */
389
+ update(params: {
390
+ networkPolicy?: NetworkPolicy;
391
+ }, opts?: {
392
+ signal?: AbortSignal;
393
+ }): Promise<void>;
394
+ /**
395
+ * Extend the timeout of the session by the specified duration.
396
+ *
397
+ * This allows you to extend the lifetime of a session up until the maximum
398
+ * execution timeout for your plan.
399
+ *
400
+ * @param duration - The duration in milliseconds to extend the timeout by
401
+ * @param opts - Optional parameters.
402
+ * @param opts.signal - An AbortSignal to cancel the operation.
403
+ * @returns A promise that resolves when the timeout is extended
404
+ *
405
+ * @example
406
+ * const sandbox = await Sandbox.create({ timeout: ms('10m') });
407
+ * const session = sandbox.currentSession();
408
+ * // Extends timeout by 5 minutes, to a total of 15 minutes.
409
+ * await session.extendTimeout(ms('5m'));
410
+ */
411
+ extendTimeout(duration: number, opts?: {
412
+ signal?: AbortSignal;
413
+ }): Promise<void>;
414
+ /**
415
+ * Create a snapshot from this currently running session. New sandboxes can
416
+ * then be created from this snapshot using {@link Sandbox.create}.
417
+ *
418
+ * Note: this session will be stopped as part of the snapshot creation process.
419
+ *
420
+ * @param opts - Optional parameters.
421
+ * @param opts.expiration - Optional expiration time in milliseconds. Use 0 for no expiration at all.
422
+ * @param opts.signal - An AbortSignal to cancel the operation.
423
+ * @returns A promise that resolves to the Snapshot instance
424
+ */
425
+ snapshot(opts?: {
426
+ expiration?: number;
427
+ signal?: AbortSignal;
428
+ }): Promise<Snapshot>;
429
+ }
430
+ //#endregion
431
+ export { RunCommandParams, Session };
432
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1,229 @@
1
+ import { Paginator } from "./utils/paginator.js";
2
+ import { SnapshotMetadata } from "./api-client/validators.js";
3
+ import { APIClient, WithFetchOptions } from "./api-client/api-client.js";
4
+ import "./api-client/index.js";
5
+ import { Credentials } from "./utils/get-credentials.js";
6
+ import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE } from "./_workflow-serde.js";
7
+
8
+ //#region src/snapshot.d.ts
9
+ interface SerializedSnapshot {
10
+ snapshot: SnapshotMetadata;
11
+ }
12
+ /** @inline */
13
+ interface GetSnapshotParams {
14
+ /**
15
+ * Unique identifier of the snapshot.
16
+ */
17
+ snapshotId: string;
18
+ /**
19
+ * An AbortSignal to cancel the operation.
20
+ */
21
+ signal?: AbortSignal;
22
+ }
23
+ /**
24
+ * A Snapshot is a saved state of a Sandbox that can be used to create new Sandboxes
25
+ *
26
+ * Use {@link Sandbox.snapshot} or {@link Snapshot.get} to construct.
27
+ * @hideconstructor
28
+ */
29
+ declare class Snapshot {
30
+ private _client;
31
+ /**
32
+ * Lazily resolve credentials and construct an API client.
33
+ * This is used in step contexts where the Snapshot was deserialized
34
+ * without a client (e.g. when crossing workflow/step boundaries).
35
+ * @internal
36
+ */
37
+ private ensureClient;
38
+ /**
39
+ * Unique ID of this snapshot.
40
+ */
41
+ get snapshotId(): string;
42
+ /**
43
+ * The ID of the session from which this snapshot was created.
44
+ */
45
+ get sourceSessionId(): string;
46
+ /**
47
+ * The status of the snapshot.
48
+ */
49
+ get status(): SnapshotMetadata["status"];
50
+ /**
51
+ * The size of the snapshot in bytes, or null if not available.
52
+ */
53
+ get sizeBytes(): number;
54
+ /**
55
+ * The creation date of this snapshot.
56
+ */
57
+ get createdAt(): Date;
58
+ /**
59
+ * When this snapshot was last updated.
60
+ */
61
+ get updatedAt(): Date;
62
+ /**
63
+ * The expiration date of this snapshot, or undefined if it does not expire.
64
+ */
65
+ get expiresAt(): Date | undefined;
66
+ /**
67
+ * Internal metadata about this snapshot.
68
+ */
69
+ private snapshot;
70
+ /**
71
+ * Serialize a Snapshot instance to plain data for @workflow/serde.
72
+ *
73
+ * @param instance - The Snapshot instance to serialize
74
+ * @returns A plain object containing snapshot metadata
75
+ */
76
+ static [WORKFLOW_SERIALIZE](instance: Snapshot): SerializedSnapshot;
77
+ /**
78
+ * Deserialize a Snapshot from serialized data.
79
+ *
80
+ * The deserialized instance uses the serialized metadata synchronously and
81
+ * lazily creates an API client only when methods perform API requests.
82
+ *
83
+ * @param data - The serialized snapshot data
84
+ * @returns The reconstructed Snapshot instance
85
+ */
86
+ static [WORKFLOW_DESERIALIZE](data: SerializedSnapshot): Snapshot;
87
+ constructor({
88
+ client,
89
+ snapshot
90
+ }: {
91
+ client?: APIClient;
92
+ snapshot: SnapshotMetadata;
93
+ });
94
+ /**
95
+ * Allow to get a list of snapshots for a team narrowed to the given params.
96
+ * It returns both the snapshots and the pagination metadata to allow getting
97
+ * the next page of results.
98
+ *
99
+ * The returned object is async-iterable to auto-paginate through all pages:
100
+ *
101
+ * ```ts
102
+ * const result = await Snapshot.list({ name: "my-sandbox" });
103
+ * for await (const snapshot of result) { ... }
104
+ * // or: await result.toArray();
105
+ * // or: for await (const page of result.pages()) { ... }
106
+ * ```
107
+ */
108
+ static list(params?: Partial<Parameters<APIClient["listSnapshots"]>[0]> & Partial<Credentials> & WithFetchOptions): Promise<Paginator<{
109
+ snapshots: {
110
+ id: string;
111
+ sourceSessionId: string;
112
+ region: string;
113
+ status: "created" | "deleted" | "failed";
114
+ sizeBytes: number;
115
+ createdAt: number;
116
+ updatedAt: number;
117
+ expiresAt?: number | undefined;
118
+ lastUsedAt?: number | undefined;
119
+ creationMethod?: string | undefined;
120
+ parentId?: string | undefined;
121
+ }[];
122
+ pagination: {
123
+ count: number;
124
+ next: string | null;
125
+ };
126
+ }, "snapshots">>;
127
+ /**
128
+ * Fetch the snapshot ancestry tree anchored on a given snapshot.
129
+ * It returns both the tree nodes and the pagination metadata to allow
130
+ * walking the next page of results in the same direction.
131
+ *
132
+ * The returned object is async-iterable to auto-paginate through all pages
133
+ * in the direction set by `sortOrder` (`"desc"` walks ancestors, `"asc"`
134
+ * walks descendants):
135
+ *
136
+ * ```ts
137
+ * const result = await Snapshot.tree({ snapshotId: "snap_abc", sortOrder: "desc" });
138
+ * for await (const node of result) { ... }
139
+ * // or: await result.toArray();
140
+ * // or: for await (const page of result.pages()) { ... }
141
+ * ```
142
+ */
143
+ static tree(params: {
144
+ snapshotId: string;
145
+ } & Partial<Parameters<APIClient["getSnapshotTree"]>[0]> & Partial<Credentials> & WithFetchOptions): Promise<Paginator<{
146
+ snapshots: {
147
+ snapshot: {
148
+ id: string;
149
+ sourceSessionId: string;
150
+ region: string;
151
+ status: "created" | "deleted" | "failed";
152
+ sizeBytes: number;
153
+ createdAt: number;
154
+ updatedAt: number;
155
+ expiresAt?: number | undefined;
156
+ lastUsedAt?: number | undefined;
157
+ creationMethod?: string | undefined;
158
+ parentId?: string | undefined;
159
+ };
160
+ siblings: {
161
+ id: string;
162
+ sourceSessionId: string;
163
+ region: string;
164
+ status: "created" | "deleted" | "failed";
165
+ sizeBytes: number;
166
+ createdAt: number;
167
+ updatedAt: number;
168
+ expiresAt?: number | undefined;
169
+ lastUsedAt?: number | undefined;
170
+ creationMethod?: string | undefined;
171
+ parentId?: string | undefined;
172
+ }[];
173
+ count: string;
174
+ }[];
175
+ pagination: {
176
+ count: number;
177
+ next: string | null;
178
+ };
179
+ anchor?: {
180
+ snapshot: {
181
+ id: string;
182
+ sourceSessionId: string;
183
+ region: string;
184
+ status: "created" | "deleted" | "failed";
185
+ sizeBytes: number;
186
+ createdAt: number;
187
+ updatedAt: number;
188
+ expiresAt?: number | undefined;
189
+ lastUsedAt?: number | undefined;
190
+ creationMethod?: string | undefined;
191
+ parentId?: string | undefined;
192
+ };
193
+ siblings: {
194
+ id: string;
195
+ sourceSessionId: string;
196
+ region: string;
197
+ status: "created" | "deleted" | "failed";
198
+ sizeBytes: number;
199
+ createdAt: number;
200
+ updatedAt: number;
201
+ expiresAt?: number | undefined;
202
+ lastUsedAt?: number | undefined;
203
+ creationMethod?: string | undefined;
204
+ parentId?: string | undefined;
205
+ }[];
206
+ count: string;
207
+ } | undefined;
208
+ }, "snapshots">>;
209
+ /**
210
+ * Retrieve an existing snapshot.
211
+ *
212
+ * @param params - Get parameters and optional credentials.
213
+ * @returns A promise resolving to the {@link Sandbox}.
214
+ */
215
+ static get(params: GetSnapshotParams | (GetSnapshotParams & Credentials)): Promise<Snapshot>;
216
+ /**
217
+ * Delete this snapshot.
218
+ *
219
+ * @param opts - Optional parameters.
220
+ * @param opts.signal - An AbortSignal to cancel the operation.
221
+ * @returns A promise that resolves once the snapshot has been deleted.
222
+ */
223
+ delete(opts?: {
224
+ signal?: AbortSignal;
225
+ }): Promise<void>;
226
+ }
227
+ //#endregion
228
+ export { SerializedSnapshot, Snapshot };
229
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1,21 @@
1
+ import { z } from "#compiled/zod/index.js";
2
+
3
+ //#region src/utils/get-credentials.d.ts
4
+ interface Credentials {
5
+ /**
6
+ * Authentication token for the Vercel API. It could be an OIDC token
7
+ * or a personal access token.
8
+ */
9
+ token: string;
10
+ /**
11
+ * The ID of the project to associate Sandbox operations.
12
+ */
13
+ projectId: string;
14
+ /**
15
+ * The ID of the team to associate Sandbox operations.
16
+ */
17
+ teamId: string;
18
+ }
19
+ //#endregion
20
+ export { Credentials };
21
+ //# sourceMappingURL=get-credentials.d.ts.map
@@ -0,0 +1,16 @@
1
+ //#region src/utils/paginator.d.ts
2
+ type CursorPaginationMeta = {
3
+ count: number;
4
+ next: string | null;
5
+ };
6
+ type HasPagination = {
7
+ pagination: CursorPaginationMeta;
8
+ };
9
+ type ItemOf<Page, Key extends keyof Page> = Page[Key] extends Array<infer Item> ? Item : never;
10
+ type Paginator<Page extends HasPagination, Key extends keyof Page> = Page & AsyncIterable<ItemOf<Page, Key>> & {
11
+ pages(): AsyncIterable<Page>;
12
+ toArray(): Promise<ItemOf<Page, Key>[]>;
13
+ };
14
+ //#endregion
15
+ export { Paginator };
16
+ //# sourceMappingURL=paginator.d.ts.map