@lizard-build/sdk 0.1.30 → 0.1.31

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.
package/dist/index.d.mts CHANGED
@@ -70,8 +70,12 @@ interface FsOpts {
70
70
  interface FileInfo {
71
71
  name: string;
72
72
  path: string;
73
- type: 'file' | 'dir';
73
+ type: 'file' | 'dir' | 'symlink';
74
74
  size: number;
75
+ /** Permission bits as a string, e.g. `-rw-r--r--`. Absent on older sandboxes. */
76
+ mode?: string;
77
+ /** Last modification time, unix milliseconds. Absent on older sandboxes. */
78
+ modTime?: number;
75
79
  }
76
80
  /**
77
81
  * Read and write files inside a Lizard sandbox microVM.
@@ -126,6 +130,35 @@ declare class Fs {
126
130
  * Create a directory (and any missing parents) inside the microVM.
127
131
  */
128
132
  makeDir(path: string, opts?: FsOpts): Promise<void>;
133
+ /**
134
+ * Metadata for a single path — size, type, permissions, modification time.
135
+ *
136
+ * Saves listing a parent directory and filtering it just to answer "does this
137
+ * exist, and how big is it".
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * const info = await sandbox.fs.stat('/app/out.bin')
142
+ * console.log(info.size, info.type)
143
+ * ```
144
+ *
145
+ * Throws `NotFoundError` if the path does not exist. Sandboxes created before
146
+ * this shipped run a guest agent without it and throw `LizardError` (501) —
147
+ * recreate the sandbox to use it.
148
+ */
149
+ stat(path: string, opts?: FsOpts): Promise<FileInfo>;
150
+ /**
151
+ * Move or rename a path. Creates the destination's parent directories.
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * await sandbox.fs.move('/tmp/build.log', '/app/logs/build.log')
156
+ * ```
157
+ *
158
+ * Sandboxes created before this shipped run a guest agent without it and throw
159
+ * `LizardError` (501) — recreate the sandbox to use it.
160
+ */
161
+ move(from: string, to: string): Promise<void>;
129
162
  private execInternal;
130
163
  }
131
164
 
package/dist/index.d.ts CHANGED
@@ -70,8 +70,12 @@ interface FsOpts {
70
70
  interface FileInfo {
71
71
  name: string;
72
72
  path: string;
73
- type: 'file' | 'dir';
73
+ type: 'file' | 'dir' | 'symlink';
74
74
  size: number;
75
+ /** Permission bits as a string, e.g. `-rw-r--r--`. Absent on older sandboxes. */
76
+ mode?: string;
77
+ /** Last modification time, unix milliseconds. Absent on older sandboxes. */
78
+ modTime?: number;
75
79
  }
76
80
  /**
77
81
  * Read and write files inside a Lizard sandbox microVM.
@@ -126,6 +130,35 @@ declare class Fs {
126
130
  * Create a directory (and any missing parents) inside the microVM.
127
131
  */
128
132
  makeDir(path: string, opts?: FsOpts): Promise<void>;
133
+ /**
134
+ * Metadata for a single path — size, type, permissions, modification time.
135
+ *
136
+ * Saves listing a parent directory and filtering it just to answer "does this
137
+ * exist, and how big is it".
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * const info = await sandbox.fs.stat('/app/out.bin')
142
+ * console.log(info.size, info.type)
143
+ * ```
144
+ *
145
+ * Throws `NotFoundError` if the path does not exist. Sandboxes created before
146
+ * this shipped run a guest agent without it and throw `LizardError` (501) —
147
+ * recreate the sandbox to use it.
148
+ */
149
+ stat(path: string, opts?: FsOpts): Promise<FileInfo>;
150
+ /**
151
+ * Move or rename a path. Creates the destination's parent directories.
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * await sandbox.fs.move('/tmp/build.log', '/app/logs/build.log')
156
+ * ```
157
+ *
158
+ * Sandboxes created before this shipped run a guest agent without it and throw
159
+ * `LizardError` (501) — recreate the sandbox to use it.
160
+ */
161
+ move(from: string, to: string): Promise<void>;
129
162
  private execInternal;
130
163
  }
131
164
 
package/dist/index.js CHANGED
@@ -261,6 +261,49 @@ var Fs = class {
261
261
  async makeDir(path, opts) {
262
262
  await this.execInternal(`mkdir -p ${JSON.stringify(path)}`, opts?.user);
263
263
  }
264
+ /**
265
+ * Metadata for a single path — size, type, permissions, modification time.
266
+ *
267
+ * Saves listing a parent directory and filtering it just to answer "does this
268
+ * exist, and how big is it".
269
+ *
270
+ * @example
271
+ * ```ts
272
+ * const info = await sandbox.fs.stat('/app/out.bin')
273
+ * console.log(info.size, info.type)
274
+ * ```
275
+ *
276
+ * Throws `NotFoundError` if the path does not exist. Sandboxes created before
277
+ * this shipped run a guest agent without it and throw `LizardError` (501) —
278
+ * recreate the sandbox to use it.
279
+ */
280
+ async stat(path, opts) {
281
+ const url = new URL(`${this.config.apiUrl}/api/sandboxes/${this.sandboxId}/files/stat`);
282
+ url.searchParams.set("path", path);
283
+ if (opts?.user) url.searchParams.set("user", opts.user);
284
+ const res = await fetch(url.toString(), { headers: this.config.headers });
285
+ if (!res.ok) await handleApiError(res);
286
+ return res.json();
287
+ }
288
+ /**
289
+ * Move or rename a path. Creates the destination's parent directories.
290
+ *
291
+ * @example
292
+ * ```ts
293
+ * await sandbox.fs.move('/tmp/build.log', '/app/logs/build.log')
294
+ * ```
295
+ *
296
+ * Sandboxes created before this shipped run a guest agent without it and throw
297
+ * `LizardError` (501) — recreate the sandbox to use it.
298
+ */
299
+ async move(from, to) {
300
+ const res = await fetch(`${this.config.apiUrl}/api/sandboxes/${this.sandboxId}/files/move`, {
301
+ method: "POST",
302
+ headers: this.config.headers,
303
+ body: JSON.stringify({ from, to })
304
+ });
305
+ if (!res.ok) await handleApiError(res);
306
+ }
264
307
  async execInternal(cmd, user) {
265
308
  const res = await fetch(`${this.config.apiUrl}/api/sandboxes/${this.sandboxId}/exec`, {
266
309
  method: "POST",
package/dist/index.mjs CHANGED
@@ -225,6 +225,49 @@ var Fs = class {
225
225
  async makeDir(path, opts) {
226
226
  await this.execInternal(`mkdir -p ${JSON.stringify(path)}`, opts?.user);
227
227
  }
228
+ /**
229
+ * Metadata for a single path — size, type, permissions, modification time.
230
+ *
231
+ * Saves listing a parent directory and filtering it just to answer "does this
232
+ * exist, and how big is it".
233
+ *
234
+ * @example
235
+ * ```ts
236
+ * const info = await sandbox.fs.stat('/app/out.bin')
237
+ * console.log(info.size, info.type)
238
+ * ```
239
+ *
240
+ * Throws `NotFoundError` if the path does not exist. Sandboxes created before
241
+ * this shipped run a guest agent without it and throw `LizardError` (501) —
242
+ * recreate the sandbox to use it.
243
+ */
244
+ async stat(path, opts) {
245
+ const url = new URL(`${this.config.apiUrl}/api/sandboxes/${this.sandboxId}/files/stat`);
246
+ url.searchParams.set("path", path);
247
+ if (opts?.user) url.searchParams.set("user", opts.user);
248
+ const res = await fetch(url.toString(), { headers: this.config.headers });
249
+ if (!res.ok) await handleApiError(res);
250
+ return res.json();
251
+ }
252
+ /**
253
+ * Move or rename a path. Creates the destination's parent directories.
254
+ *
255
+ * @example
256
+ * ```ts
257
+ * await sandbox.fs.move('/tmp/build.log', '/app/logs/build.log')
258
+ * ```
259
+ *
260
+ * Sandboxes created before this shipped run a guest agent without it and throw
261
+ * `LizardError` (501) — recreate the sandbox to use it.
262
+ */
263
+ async move(from, to) {
264
+ const res = await fetch(`${this.config.apiUrl}/api/sandboxes/${this.sandboxId}/files/move`, {
265
+ method: "POST",
266
+ headers: this.config.headers,
267
+ body: JSON.stringify({ from, to })
268
+ });
269
+ if (!res.ok) await handleApiError(res);
270
+ }
228
271
  async execInternal(cmd, user) {
229
272
  const res = await fetch(`${this.config.apiUrl}/api/sandboxes/${this.sandboxId}/exec`, {
230
273
  method: "POST",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lizard-build/sdk",
3
- "version": "0.1.30",
3
+ "version": "0.1.31",
4
4
  "description": "Firecracker microVM sandboxes for AI agents — boot Linux in milliseconds, run code, write files, expose ports over HTTPS, then pause a session with memory intact and resume it later. TypeScript SDK for Lizard Sandboxes (lizard.build).",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",