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