smolmachines 1.29.1 → 1.31.5

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/binding.d.ts CHANGED
@@ -182,6 +182,13 @@ export interface VmResourcesConfig {
182
182
  gpu?: boolean
183
183
  /** GPU VRAM in MiB (default: engine default when GPU is enabled). */
184
184
  gpuVramMib?: number
185
+ /**
186
+ * Disk durability: `"full"` (default), a guest flush waits for the host's
187
+ * disk; or `"deferred"`, guest writes reach the host's disk on the host's
188
+ * schedule, so fsync-heavy work (database commits) runs much faster and a
189
+ * host crash can lose recent writes.
190
+ */
191
+ diskDurability?: string
185
192
  /**
186
193
  * Run the guest's unmodified CUDA/PyTorch code on the host's NVIDIA GPU by
187
194
  * remoting CUDA calls over vsock (distinct from `gpu`, which is Vulkan; no
@@ -427,6 +434,11 @@ export declare class NapiMachine {
427
434
  forkBatch(names: Array<string>, ports?: Array<PortMappingConfig> | undefined | null, parallel?: number | undefined | null, freezeSource?: boolean | undefined | null): Promise<Array<NapiMachine>>
428
435
  /** Execute a command directly in the VM (not in a container). */
429
436
  exec(command: Array<string>, options?: ExecOptions | undefined | null): Promise<ExecResult>
437
+ /**
438
+ * Start a command without waiting for it and return its guest pid. It
439
+ * keeps running after this returns; it takes no stdin and no timeout.
440
+ */
441
+ execBackground(command: Array<string>, options?: ExecOptions | undefined | null): Promise<number>
430
442
  /**
431
443
  * Pull an OCI image and run a command inside it.
432
444
  *
package/dist/native.d.ts CHANGED
@@ -42,6 +42,7 @@ export interface NativeResources {
42
42
  overlayGib?: number | undefined;
43
43
  gpu?: boolean | undefined;
44
44
  gpuVramMib?: number | undefined;
45
+ diskDurability?: "full" | "deferred" | undefined;
45
46
  cuda?: boolean | undefined;
46
47
  networkBackend?: string | undefined;
47
48
  }
@@ -145,6 +146,7 @@ export interface NapiMachine {
145
146
  fork(name: string, ports?: NativePortMapping[], checkpointable?: boolean, freezeSource?: boolean): Promise<NapiMachine>;
146
147
  forkBatch(names: string[], ports?: NativePortMapping[], parallel?: number, freezeSource?: boolean): Promise<NapiMachine[]>;
147
148
  exec(command: string[], options?: NativeExecOptions): Promise<NativeExecResult>;
149
+ execBackground(command: string[], options?: NativeExecOptions): Promise<number>;
148
150
  run(image: string, command: string[], options?: NativeExecOptions): Promise<NativeExecResult>;
149
151
  pullImage(image: string): Promise<NativeImageInfo>;
150
152
  listImages(): Promise<NativeImageInfo[]>;
package/dist/transport.js CHANGED
@@ -319,6 +319,7 @@ function toNativeConfig(name, config) {
319
319
  overlayGib: config.resources?.overlayGb,
320
320
  gpu: config.resources?.gpu,
321
321
  gpuVramMib: config.resources?.gpuVramMib,
322
+ diskDurability: config.resources?.diskDurability,
322
323
  cuda: config.resources?.cuda,
323
324
  networkBackend: config.resources?.networkBackend,
324
325
  }
@@ -425,6 +426,8 @@ class LocalTransport {
425
426
  return null;
426
427
  }
427
428
  async exec(command, opts) {
429
+ if (opts?.background)
430
+ return this.execBackground(command, opts);
428
431
  if (opts?.signal)
429
432
  return collectExec(this.execStream(command, opts), opts.signal);
430
433
  try {
@@ -434,6 +437,21 @@ class LocalTransport {
434
437
  throw (0, errors_1.wrapNativeError)(e);
435
438
  }
436
439
  }
440
+ /** Start a command and return at once, as the cloud does: its pid in `pid`
441
+ * and as `pid=<n>` on stdout. */
442
+ async execBackground(command, opts) {
443
+ if (opts.signal) {
444
+ throw new errors_1.InvalidConfigError("a background command cannot be cancelled; kill its pid instead");
445
+ }
446
+ let pid;
447
+ try {
448
+ pid = await this.inner.execBackground(command, toNativeExecOptions(opts));
449
+ }
450
+ catch (e) {
451
+ throw (0, errors_1.wrapNativeError)(e);
452
+ }
453
+ return { pid, exitCode: 0, stdout: `pid=${pid}\n`, stderr: "" };
454
+ }
437
455
  async run(image, command, opts) {
438
456
  if (opts?.signal) {
439
457
  throw new errors_1.NotSupportedError("signal is not supported by run(); use exec on an image machine.");
@@ -1809,6 +1827,9 @@ async function makeTransport(config, conn) {
1809
1827
  ? { memoryMb: config.resources.memoryMb }
1810
1828
  : {}),
1811
1829
  diskGb: config.resources?.storageGb ?? null,
1830
+ ...(config.resources?.diskDurability !== undefined
1831
+ ? { diskDurability: config.resources.diskDurability }
1832
+ : {}),
1812
1833
  },
1813
1834
  ...(config.resources?.allowCidrs?.length ||
1814
1835
  config.resources?.allowHosts?.length
package/dist/types.d.ts CHANGED
@@ -41,6 +41,14 @@ export interface ResourceSpec {
41
41
  gpu?: boolean;
42
42
  /** GPU VRAM in MiB (default: engine default when GPU is enabled). Local target only. */
43
43
  gpuVramMib?: number;
44
+ /**
45
+ * Disk durability. `"full"` (default): a guest `fsync` waits for the host's
46
+ * disk. `"deferred"`: guest writes reach the host's disk on the host's
47
+ * schedule, so fsync-heavy work such as database commits runs far faster
48
+ * (Postgres commits about 19x on Linux), and a crash of the host, not of the
49
+ * machine, can lose the most recent writes. Local and cloud targets.
50
+ */
51
+ diskDurability?: "full" | "deferred";
44
52
  /**
45
53
  * Run the guest's unmodified CUDA/PyTorch code on the host's NVIDIA GPU by
46
54
  * remoting CUDA Driver-API calls over vsock (distinct from `gpu`, which is
@@ -395,8 +403,9 @@ export interface ExecOptions {
395
403
  * Ignored (both families, as before) on older control planes and on the
396
404
  * local target. */
397
405
  output?: "text" | "b64" | "both";
398
- /** Cloud only: start the command detached and return at once with its
399
- * `pid`, leaving it running (a dev server, an agent) after the call ends. */
406
+ /** Start the command detached and return at once with its `pid`, leaving
407
+ * it running (a dev server, an agent) after the call ends. It takes no
408
+ * stdin and no timeout. */
400
409
  background?: boolean;
401
410
  }
402
411
  /** Result of a command execution. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smolmachines",
3
- "version": "1.29.1",
3
+ "version": "1.31.5",
4
4
  "description": "Embed isolated microVM sandboxes directly in your code — no server to run.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "smol-machines",
@@ -65,8 +65,8 @@
65
65
  "typescript": "^5.6.0"
66
66
  },
67
67
  "optionalDependencies": {
68
- "smolmachines-darwin-arm64": "1.29.1",
69
- "smolmachines-linux-x64-gnu": "1.29.1",
70
- "smolmachines-linux-arm64-gnu": "1.29.1"
68
+ "smolmachines-darwin-arm64": "1.31.5",
69
+ "smolmachines-linux-x64-gnu": "1.31.5",
70
+ "smolmachines-linux-arm64-gnu": "1.31.5"
71
71
  }
72
72
  }