virtual-machine 0.1.4 → 0.1.6

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/build/index.d.ts CHANGED
@@ -30,6 +30,14 @@ declare class WasmVm {
30
30
  * Print a status message to UART output (visible in browser).
31
31
  */
32
32
  print_status(message: string): void;
33
+ /**
34
+ * Get CPU count (from kernel-reported value).
35
+ */
36
+ get_cpu_count(): number;
37
+ /**
38
+ * Get system uptime in milliseconds (from kernel-reported value).
39
+ */
40
+ get_uptime_ms(): bigint;
33
41
  /**
34
42
  * Start worker threads for secondary harts (1..num_harts).
35
43
  *
@@ -40,6 +48,16 @@ declare class WasmVm {
40
48
  * * `worker_url` - URL to the worker script (e.g., "/worker.js")
41
49
  */
42
50
  start_workers(worker_url: string): void;
51
+ /**
52
+ * Get disk usage from the guest kernel.
53
+ * Returns (used_bytes, total_bytes).
54
+ */
55
+ get_disk_usage(): Array<any>;
56
+ /**
57
+ * Get heap memory usage from the guest kernel.
58
+ * Returns (used_bytes, total_bytes).
59
+ */
60
+ get_heap_usage(): Array<any>;
43
61
  /**
44
62
  * Get the current network connection status.
45
63
  * This checks the actual connection state by seeing if an IP was assigned.
@@ -57,6 +75,11 @@ declare class WasmVm {
57
75
  * Get current memory usage (DRAM size) in bytes.
58
76
  */
59
77
  get_memory_usage(): bigint;
78
+ /**
79
+ * Get the total disk capacity from attached VirtIO block devices.
80
+ * Returns total bytes across all block devices.
81
+ */
82
+ get_disk_capacity(): bigint;
60
83
  /**
61
84
  * Get the SharedArrayBuffer for external worker management.
62
85
  * Returns None if not in SMP mode.
@@ -271,9 +294,14 @@ interface InitOutput {
271
294
  readonly wasmvm_external_network_tx_pending: (a: number) => number;
272
295
  readonly wasmvm_extract_all_network_packets: (a: number) => any;
273
296
  readonly wasmvm_extract_network_packet: (a: number) => any;
297
+ readonly wasmvm_get_cpu_count: (a: number) => number;
298
+ readonly wasmvm_get_disk_capacity: (a: number) => bigint;
299
+ readonly wasmvm_get_disk_usage: (a: number) => any;
300
+ readonly wasmvm_get_heap_usage: (a: number) => any;
274
301
  readonly wasmvm_get_memory_usage: (a: number) => bigint;
275
302
  readonly wasmvm_get_output: (a: number) => number;
276
303
  readonly wasmvm_get_shared_buffer: (a: number) => any;
304
+ readonly wasmvm_get_uptime_ms: (a: number) => bigint;
277
305
  readonly wasmvm_halt_code: (a: number) => bigint;
278
306
  readonly wasmvm_inject_network_packet: (a: number, b: any) => number;
279
307
  readonly wasmvm_input: (a: number, b: number) => void;
@@ -300,12 +328,12 @@ interface InitOutput {
300
328
  readonly workerstate_new: (a: number, b: any, c: bigint) => number;
301
329
  readonly workerstate_step_batch: (a: number, b: number) => number;
302
330
  readonly workerstate_step_count: (a: number) => bigint;
303
- readonly wasm_bindgen__convert__closures_____invoke__h02b024c830faf3c0: (a: number, b: number, c: any) => void;
304
- readonly wasm_bindgen__closure__destroy__h6be55d916a7a567c: (a: number, b: number) => void;
305
331
  readonly wasm_bindgen__convert__closures_____invoke__h39d3e89751b07765: (a: number, b: number, c: any) => void;
306
332
  readonly wasm_bindgen__closure__destroy__hf225e18fc5ab9bc1: (a: number, b: number) => void;
307
- readonly wasm_bindgen__convert__closures_____invoke__h9493c87185cf2d12: (a: number, b: number) => void;
308
- readonly wasm_bindgen__convert__closures_____invoke__hec486a7a364d96de: (a: number, b: number) => void;
333
+ readonly wasm_bindgen__convert__closures_____invoke__h2fb143e274d04750: (a: number, b: number) => void;
334
+ readonly wasm_bindgen__closure__destroy__h4023f714f00bdc1f: (a: number, b: number) => void;
335
+ readonly wasm_bindgen__convert__closures_____invoke__hf4f72b1758a638c0: (a: number, b: number) => void;
336
+ readonly wasm_bindgen__convert__closures_____invoke__habdd714824245bd8: (a: number, b: number, c: any) => void;
309
337
  readonly __wbindgen_malloc: (a: number, b: number) => number;
310
338
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
311
339
  readonly __wbindgen_exn_store: (a: number) => void;
@@ -420,10 +448,11 @@ interface VmOptions {
420
448
  *
421
449
  * NOTE: In WASM, multi-hart mode is significantly slower due to
422
450
  * SharedArrayBuffer/Atomics overhead (see tasks/improvements.md).
423
- * Default is 1 hart unless explicitly specified.
451
+ * Default is auto-detect (cpu/2) unless explicitly specified.
424
452
  *
425
453
  * @param kernelData - ELF kernel binary
426
454
  * @param options - VM configuration options
455
+ * @param options.harts - Number of harts: undefined/0 = auto-detect (cpu/2), >= 1 = explicit count
427
456
  * @returns WasmVm instance
428
457
  */
429
458
  declare function createVM(kernelData: Uint8Array, options?: VmOptions): Promise<WasmVm>;