@blaxel/core 0.3.8-preview.233 → 0.3.8-preview.234

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.
@@ -30,8 +30,8 @@ function missingCredentialsMessage() {
30
30
  return "No Blaxel credentials found. Set the BL_API_KEY and BL_WORKSPACE environment variables, or run `bl login`.";
31
31
  }
32
32
  // Build info - these placeholders are replaced at build time by build:replace-imports
33
- const BUILD_VERSION = "0.3.8-preview.233";
34
- const BUILD_COMMIT = "816aea9abd2e04956ff3e83f01b8f838e9486f71";
33
+ const BUILD_VERSION = "0.3.8-preview.234";
34
+ const BUILD_COMMIT = "640ca44f9533691231a7903a1685eb57c244a43d";
35
35
  const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
36
36
  const BLAXEL_API_VERSION = "2026-04-28";
37
37
  // Bun < 1.3.11 never sends connection-level WINDOW_UPDATE: the pooled h2
@@ -164,6 +164,64 @@ class SandboxInstance {
164
164
  async fetch(port, path = "/", init) {
165
165
  return this.network.fetch(port, path, init);
166
166
  }
167
+ /**
168
+ * Create a point-in-time snapshot of this sandbox. Snapshots capture the
169
+ * sandbox state and can be forked into new sandboxes or applications.
170
+ *
171
+ * @param name - Optional human-readable name for the snapshot.
172
+ */
173
+ async snapshot(name) {
174
+ const { data } = await (0, index_js_1.createSandboxSnapshot)({
175
+ path: { sandboxName: this.metadata.name },
176
+ body: name ? { name } : {},
177
+ throwOnError: true,
178
+ });
179
+ return data;
180
+ }
181
+ /**
182
+ * List the snapshots of this sandbox.
183
+ */
184
+ async listSnapshots() {
185
+ const { data } = await (0, index_js_1.listSandboxSnapshots)({
186
+ path: { sandboxName: this.metadata.name },
187
+ throwOnError: true,
188
+ });
189
+ return data;
190
+ }
191
+ /**
192
+ * Delete a snapshot of this sandbox by its ID.
193
+ */
194
+ async deleteSnapshot(snapshotId) {
195
+ await (0, index_js_1.deleteSandboxSnapshot)({
196
+ path: { sandboxName: this.metadata.name, snapshotId },
197
+ throwOnError: true,
198
+ });
199
+ }
200
+ /**
201
+ * Fork this sandbox into a new sandbox or application.
202
+ *
203
+ * Pass `snapshotId` to fork from a specific snapshot (create a sandbox from a
204
+ * snapshot) instead of the sandbox's live state.
205
+ *
206
+ * @param targetName - Name of the sandbox/application to create.
207
+ * @param options - Fork options (target type, port, traffic, snapshot, ...).
208
+ */
209
+ async fork(targetName, options = {}) {
210
+ const { data } = await (0, index_js_1.forkSandbox)({
211
+ path: { sandboxName: this.metadata.name },
212
+ body: {
213
+ targetName,
214
+ targetType: options.targetType ?? "sandbox",
215
+ ...(options.port !== undefined ? { port: options.port } : {}),
216
+ ...(options.traffic !== undefined ? { traffic: options.traffic } : {}),
217
+ ...(options.customDomain !== undefined ? { customDomain: options.customDomain } : {}),
218
+ ...(options.prefix !== undefined ? { prefix: options.prefix } : {}),
219
+ ...(options.snapshotId !== undefined ? { snapshotId: options.snapshotId } : {}),
220
+ },
221
+ throwOnError: true,
222
+ });
223
+ return data;
224
+ }
167
225
  /* eslint-disable */
168
226
  async wait({ maxWait = 60000, interval = 1000 } = {}) {
169
227
  logger_js_1.logger.warn("⚠️ Warning: sandbox.wait() is deprecated. You don't need to wait for the sandbox to be deployed anymore.");
@@ -1,5 +1,5 @@
1
1
  import type http2 from "http2";
2
- import { type ListSandboxesData, type SandboxLifecycle, type Sandbox as SandboxModel } from "../client/index.js";
2
+ import { type ListSandboxesData, type SandboxForkResponse, type SandboxLifecycle, type Sandbox as SandboxModel, type SandboxSnapshot, type SandboxSnapshots } from "../client/index.js";
3
3
  import { SandboxCodegen } from "./codegen/index.js";
4
4
  import { SandboxDrive } from "./drive/index.js";
5
5
  import { SandboxFileSystem } from "./filesystem/index.js";
@@ -11,6 +11,24 @@ import { SandboxSessions } from "./session.js";
11
11
  import { SandboxSystem } from "./system.js";
12
12
  import { SandboxConfiguration, SandboxCreateConfiguration, SandboxUpdateMetadata, SandboxUpdateNetwork, SessionWithToken } from "./types.js";
13
13
  export type SandboxListQuery = NonNullable<ListSandboxesData["query"]>;
14
+ export type SandboxForkOptions = {
15
+ /** Resource type to fork into. Defaults to "sandbox". */
16
+ targetType?: "sandbox" | "application";
17
+ /** Port to expose from the fork. */
18
+ port?: number;
19
+ /** Canary traffic percentage (0-100) when forking into an application. */
20
+ traffic?: number;
21
+ /** Custom domain for the application fork. */
22
+ customDomain?: string;
23
+ /** URL prefix for the application fork. */
24
+ prefix?: string;
25
+ /**
26
+ * Snapshot ID to fork from. When set, the fork is created from this snapshot
27
+ * instead of the source sandbox's live state — this is how you create a
28
+ * sandbox from a snapshot.
29
+ */
30
+ snapshotId?: string;
31
+ };
14
32
  export declare class SandboxInstance {
15
33
  private sandbox;
16
34
  fs: SandboxFileSystem;
@@ -45,6 +63,31 @@ export declare class SandboxInstance {
45
63
  * @param init - Standard RequestInit options forwarded to fetch
46
64
  */
47
65
  fetch(port: number, path?: string, init?: RequestInit): Promise<Response>;
66
+ /**
67
+ * Create a point-in-time snapshot of this sandbox. Snapshots capture the
68
+ * sandbox state and can be forked into new sandboxes or applications.
69
+ *
70
+ * @param name - Optional human-readable name for the snapshot.
71
+ */
72
+ snapshot(name?: string): Promise<SandboxSnapshot>;
73
+ /**
74
+ * List the snapshots of this sandbox.
75
+ */
76
+ listSnapshots(): Promise<SandboxSnapshots>;
77
+ /**
78
+ * Delete a snapshot of this sandbox by its ID.
79
+ */
80
+ deleteSnapshot(snapshotId: string): Promise<void>;
81
+ /**
82
+ * Fork this sandbox into a new sandbox or application.
83
+ *
84
+ * Pass `snapshotId` to fork from a specific snapshot (create a sandbox from a
85
+ * snapshot) instead of the sandbox's live state.
86
+ *
87
+ * @param targetName - Name of the sandbox/application to create.
88
+ * @param options - Fork options (target type, port, traffic, snapshot, ...).
89
+ */
90
+ fork(targetName: string, options?: SandboxForkOptions): Promise<SandboxForkResponse>;
48
91
  wait({ maxWait, interval }?: {
49
92
  maxWait?: number;
50
93
  interval?: number;