smolmachines 1.29.0 → 1.31.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.
package/dist/binding.d.ts CHANGED
@@ -427,6 +427,11 @@ export declare class NapiMachine {
427
427
  forkBatch(names: Array<string>, ports?: Array<PortMappingConfig> | undefined | null, parallel?: number | undefined | null, freezeSource?: boolean | undefined | null): Promise<Array<NapiMachine>>
428
428
  /** Execute a command directly in the VM (not in a container). */
429
429
  exec(command: Array<string>, options?: ExecOptions | undefined | null): Promise<ExecResult>
430
+ /**
431
+ * Start a command without waiting for it and return its guest pid. It
432
+ * keeps running after this returns; it takes no stdin and no timeout.
433
+ */
434
+ execBackground(command: Array<string>, options?: ExecOptions | undefined | null): Promise<number>
430
435
  /**
431
436
  * Pull an OCI image and run a command inside it.
432
437
  *
package/dist/native.d.ts CHANGED
@@ -145,6 +145,7 @@ export interface NapiMachine {
145
145
  fork(name: string, ports?: NativePortMapping[], checkpointable?: boolean, freezeSource?: boolean): Promise<NapiMachine>;
146
146
  forkBatch(names: string[], ports?: NativePortMapping[], parallel?: number, freezeSource?: boolean): Promise<NapiMachine[]>;
147
147
  exec(command: string[], options?: NativeExecOptions): Promise<NativeExecResult>;
148
+ execBackground(command: string[], options?: NativeExecOptions): Promise<number>;
148
149
  run(image: string, command: string[], options?: NativeExecOptions): Promise<NativeExecResult>;
149
150
  pullImage(image: string): Promise<NativeImageInfo>;
150
151
  listImages(): Promise<NativeImageInfo[]>;
package/dist/transport.js CHANGED
@@ -425,6 +425,8 @@ class LocalTransport {
425
425
  return null;
426
426
  }
427
427
  async exec(command, opts) {
428
+ if (opts?.background)
429
+ return this.execBackground(command, opts);
428
430
  if (opts?.signal)
429
431
  return collectExec(this.execStream(command, opts), opts.signal);
430
432
  try {
@@ -434,6 +436,21 @@ class LocalTransport {
434
436
  throw (0, errors_1.wrapNativeError)(e);
435
437
  }
436
438
  }
439
+ /** Start a command and return at once, as the cloud does: its pid in `pid`
440
+ * and as `pid=<n>` on stdout. */
441
+ async execBackground(command, opts) {
442
+ if (opts.signal) {
443
+ throw new errors_1.InvalidConfigError("a background command cannot be cancelled; kill its pid instead");
444
+ }
445
+ let pid;
446
+ try {
447
+ pid = await this.inner.execBackground(command, toNativeExecOptions(opts));
448
+ }
449
+ catch (e) {
450
+ throw (0, errors_1.wrapNativeError)(e);
451
+ }
452
+ return { pid, exitCode: 0, stdout: `pid=${pid}\n`, stderr: "" };
453
+ }
437
454
  async run(image, command, opts) {
438
455
  if (opts?.signal) {
439
456
  throw new errors_1.NotSupportedError("signal is not supported by run(); use exec on an image machine.");
package/dist/types.d.ts CHANGED
@@ -395,8 +395,9 @@ export interface ExecOptions {
395
395
  * Ignored (both families, as before) on older control planes and on the
396
396
  * local target. */
397
397
  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. */
398
+ /** Start the command detached and return at once with its `pid`, leaving
399
+ * it running (a dev server, an agent) after the call ends. It takes no
400
+ * stdin and no timeout. */
400
401
  background?: boolean;
401
402
  }
402
403
  /** Result of a command execution. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smolmachines",
3
- "version": "1.29.0",
3
+ "version": "1.31.0",
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.0",
69
- "smolmachines-linux-x64-gnu": "1.29.0",
70
- "smolmachines-linux-arm64-gnu": "1.29.0"
68
+ "smolmachines-darwin-arm64": "1.31.0",
69
+ "smolmachines-linux-x64-gnu": "1.31.0",
70
+ "smolmachines-linux-arm64-gnu": "1.31.0"
71
71
  }
72
72
  }