@webpodjs/sdk 0.2.7 → 0.3.1

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.
Files changed (74) hide show
  1. package/README.md +93 -15
  2. package/dist/agent/backend.d.ts +18 -1
  3. package/dist/agent/backend.js +275 -76
  4. package/dist/agent/backend.js.map +1 -1
  5. package/dist/agent/fs.d.ts +2 -2
  6. package/dist/agent/fs.js +3 -2
  7. package/dist/agent/fs.js.map +1 -1
  8. package/dist/agent/protocol.d.ts +40 -1
  9. package/dist/agent/protocol.js +39 -3
  10. package/dist/agent/protocol.js.map +1 -1
  11. package/dist/errors.d.ts +1 -1
  12. package/dist/errors.js.map +1 -1
  13. package/dist/exec/client.js +21 -6
  14. package/dist/exec/client.js.map +1 -1
  15. package/dist/exec/frame.js +5 -0
  16. package/dist/exec/frame.js.map +1 -1
  17. package/dist/fs/tar.d.ts +1 -1
  18. package/dist/fs/tar.js +8 -2
  19. package/dist/fs/tar.js.map +1 -1
  20. package/dist/fs/workspace.js +61 -30
  21. package/dist/fs/workspace.js.map +1 -1
  22. package/dist/host/backend.d.ts +11 -0
  23. package/dist/host/backend.js +71 -14
  24. package/dist/host/backend.js.map +1 -1
  25. package/dist/host/channel.js +4 -1
  26. package/dist/host/channel.js.map +1 -1
  27. package/dist/host/controller.d.ts +2 -0
  28. package/dist/host/controller.js +11 -4
  29. package/dist/host/controller.js.map +1 -1
  30. package/dist/host/devices.d.ts +28 -2
  31. package/dist/host/devices.js +55 -7
  32. package/dist/host/devices.js.map +1 -1
  33. package/dist/host/pump-worker.js +12 -4
  34. package/dist/host/pump-worker.js.map +1 -1
  35. package/dist/host-exec/controller.d.ts +161 -4
  36. package/dist/host-exec/controller.js +1041 -70
  37. package/dist/host-exec/controller.js.map +1 -1
  38. package/dist/host-exec/protocol.d.ts +337 -4
  39. package/dist/host-exec/protocol.js +34 -0
  40. package/dist/host-exec/protocol.js.map +1 -1
  41. package/dist/host-exec/route.js +74 -13
  42. package/dist/host-exec/route.js.map +1 -1
  43. package/dist/host-exec/shim.d.ts +8 -2
  44. package/dist/host-exec/shim.js +77 -12
  45. package/dist/host-exec/shim.js.map +1 -1
  46. package/dist/index.d.ts +3 -1
  47. package/dist/index.js +1 -0
  48. package/dist/index.js.map +1 -1
  49. package/dist/net/client.d.ts +5 -1
  50. package/dist/net/client.js +8 -4
  51. package/dist/net/client.js.map +1 -1
  52. package/dist/net/options.d.ts +14 -0
  53. package/dist/net/options.js +1 -1
  54. package/dist/net/options.js.map +1 -1
  55. package/dist/net/preview.d.ts +15 -1
  56. package/dist/net/preview.js +24 -4
  57. package/dist/net/preview.js.map +1 -1
  58. package/dist/output.d.ts +23 -0
  59. package/dist/output.js +161 -0
  60. package/dist/output.js.map +1 -0
  61. package/dist/pod.d.ts +21 -7
  62. package/dist/pod.js +165 -29
  63. package/dist/pod.js.map +1 -1
  64. package/dist/preview-relay.js +24 -7
  65. package/dist/preview-relay.js.map +1 -1
  66. package/dist/preview-serviceworker.js +71 -8
  67. package/dist/preview-serviceworker.js.map +1 -1
  68. package/dist/tools.d.ts +79 -0
  69. package/dist/tools.js +47 -0
  70. package/dist/tools.js.map +1 -0
  71. package/dist/types.d.ts +62 -2
  72. package/dist/version.d.ts +1 -1
  73. package/dist/version.js +1 -1
  74. package/package.json +1 -1
@@ -6,6 +6,9 @@
6
6
  * pool), then started once. A top-level process reports on the Worker itself; a child of another
7
7
  * host process on the MessagePort it was started with (its owner: the parent Worker, or the
8
8
  * controller for spawnSync and guest children).
9
+ *
10
+ * A wasm child (ChildSpec runner "wasi", T244) is a Worker of host-exec's dist/wasi-worker.js instead: the same boot and
11
+ * start (start's wasm: the module), no node in it.
9
12
  */
10
13
  /** One 9P session of the FS Worker's workspace (T80, amber #2342). */
11
14
  export interface HostSessionRef {
@@ -55,8 +58,20 @@ export interface BootMessage {
55
58
  wasmModules?: Record<string, WebAssembly.Module>;
56
59
  /** spawnSync and listen results (see SYNC_HEADER). */
57
60
  ctl: SharedArrayBuffer;
58
- /** Int32 [0]: the next pid, shared by every process of the pod (children take theirs with Atomics.add). */
61
+ /**
62
+ * Int32 [0]: the next pid, shared by every process of the pod (children take theirs with Atomics.add); [1]: the
63
+ * controller's session, a random number not 0 (host-exec's file locks: an owner of another session is gone).
64
+ */
59
65
  pids: SharedArrayBuffer;
66
+ /** The CPUs the process reports (os.cpus(), os.availableParallelism(), navigator.hardwareConcurrency). */
67
+ cpus?: number;
68
+ /** The guest's network interfaces besides loopback (IPv4), as the process reports them (os.networkInterfaces()). */
69
+ ifaces?: {
70
+ name: string;
71
+ address: string;
72
+ netmask: string;
73
+ mac: string;
74
+ }[];
60
75
  /** Read-only tree mounted at "/" (npm-tree.bin format). */
61
76
  tree?: SharedArrayBuffer | ArrayBuffer;
62
77
  /** node-lib.json's UTF-8 bytes, one copy for every Worker (else the Worker fetches it). */
@@ -76,6 +91,22 @@ export interface BootMessage {
76
91
  tid: number;
77
92
  name: string;
78
93
  };
94
+ /** The controller starts wasm children on dist/wasi-worker.js (ChildSpec runner "wasi"): the route may pick them. */
95
+ wasi?: boolean;
96
+ /**
97
+ * A wasi Worker's stop (T358): Int32 [0] set to 1 (and notified) before the controller terminates it; its program
98
+ * ends at its next call or in its wait (Chromium lets a Worker that does not return to its event loop run 2 s more).
99
+ */
100
+ stop?: SharedArrayBuffer;
101
+ }
102
+ /**
103
+ * An fd of 3 and up a host process gives its child (spawn's stdio, both ways as libuv's socketpair): `sab` the pipe
104
+ * of what the child reads there (see pipe.ts); what it writes goes to its port as out messages with `fd`, its close as
105
+ * fd-end.
106
+ */
107
+ export interface FdPipe {
108
+ fd: number;
109
+ sab: SharedArrayBuffer;
79
110
  }
80
111
  export interface StartMessage {
81
112
  type: "start";
@@ -91,10 +122,17 @@ export interface StartMessage {
91
122
  stdin: SharedArrayBuffer | null;
92
123
  /** Owner of a child process; absent for a top-level one. */
93
124
  port?: MessagePort;
125
+ /** A wasi Worker's program: its module's path (argv is the program's, argv[0] included). */
126
+ wasm?: string;
127
+ /** A wasi Worker's program: the MB its tool's manifest declares (memoryMB, T258), reserved before it starts, and for whom. */
128
+ memoryMB?: number;
129
+ what?: string;
94
130
  /** Fallback tables' patterns: node children whose script they name run in the guest (spawn-route.js listedIn). */
95
131
  guest?: string[];
96
132
  /** A child with an IPC channel (fork): its fd (NODE_CHANNEL_FD), carried on `port` as ipc / ipc-end messages. */
97
133
  ipc?: number;
134
+ /** A child's fds 3 and up (spawn's stdio): what it writes there goes to `port` as out messages with that fd. */
135
+ fds?: FdPipe[];
98
136
  /** The guest shim's processes: which of fds 0-2 are terminals, and its size. */
99
137
  tty?: [boolean, boolean, boolean];
100
138
  size?: {
@@ -103,6 +141,13 @@ export interface StartMessage {
103
141
  };
104
142
  /** Each read of an empty stdin pipe reports stdin-want (stdin is handed over as it is read). */
105
143
  stdinDemand?: boolean;
144
+ /** A detached child: its exit (or fallback) is reported here too (detached-exit), for when its owner is gone. */
145
+ detached?: boolean;
146
+ /**
147
+ * The bytes of its out messages (stdout, stderr, fds 3 and up) its owner took (OutCredit): its writes wait while it is
148
+ * OUT_WINDOW ahead, as on a pipe that is full (T287). Without it nothing waits.
149
+ */
150
+ outCredit?: SharedArrayBuffer;
106
151
  /** A thread: its environment port (node's internal port to the parent), the process's thread ids and prefix. */
107
152
  thread?: {
108
153
  envPort: MessagePort;
@@ -111,7 +156,31 @@ export interface StartMessage {
111
156
  threadIds: SharedArrayBuffer;
112
157
  bcPrefix: string;
113
158
  shareEnv?: SharedArrayBuffer;
159
+ nodeOptions?: string;
114
160
  };
161
+ /** The controller relays its ports' messages to its process's other threads (relay). */
162
+ relay?: boolean;
163
+ /** A WASIX program's wasm thread (a wasi Worker, wasix-thread): its program comes on `port` from the process. */
164
+ wasixThread?: boolean;
165
+ /** The signal dispositions its WASIX parent gave it (ChildSpec.signals): a WASIX program's proc_signals_get. */
166
+ signals?: {
167
+ sig: number;
168
+ disp: number;
169
+ }[];
170
+ /**
171
+ * Files of the guest's root put over the read-only tree as it starts (host-exec's ro-tree.js add): the pod's CA, its
172
+ * system bundle and the agent's hash directory as the guest has them (T330: a WASIX program's TLS, curl's), on one
173
+ * SharedArrayBuffer for every process.
174
+ */
175
+ rootFiles?: RootFile[];
176
+ /** wasm Modules compiled since its boot (BootMessage.wasmModules'), by the same keys: a Worker of the pool booted ahead. */
177
+ wasmModules?: Record<string, WebAssembly.Module>;
178
+ }
179
+ /** A file of the guest's root (StartMessage.rootFiles): its absolute path, mode (S_IFREG and the bits) and bytes; or a link (S_IFLNK), its target's. */
180
+ export interface RootFile {
181
+ path: string;
182
+ mode: number;
183
+ data: Uint8Array;
115
184
  }
116
185
  /** After start (the guest shim's processes): a signal for its handlers, the terminal's size, a stream without reader. */
117
186
  export type ControlMessage = {
@@ -124,13 +193,33 @@ export type ControlMessage = {
124
193
  } | {
125
194
  type: "out-closed";
126
195
  fd: 1 | 2;
196
+ }
197
+ /** A node child of the process that another process's kill (kill-pid) ended: its exit by that signal. */
198
+ | {
199
+ type: "child-exit";
200
+ pid: number;
201
+ signal: string;
202
+ }
203
+ /** A port's message another thread of its process relayed (relay); one of its own back, no thread has its end. */
204
+ | {
205
+ type: "relay" | "relay-bounced";
206
+ msg: unknown;
207
+ }
208
+ /** What the Worker's memory is (T289): answered with a mem message of the same id, at any time (before its start too). */
209
+ | {
210
+ type: "mem";
211
+ id: number;
212
+ }
213
+ /** A thread that ended, before it is terminated: answered (drained) once what came before is done. */
214
+ | {
215
+ type: "drain";
127
216
  };
128
217
  export type PageToWorker = BootMessage | StartMessage | ControlMessage;
129
218
  /** A child process a host process starts; `runner` is the route its spawn-route.js chose. */
130
219
  export interface ChildSpec {
131
220
  pid: number;
132
221
  ppid: number;
133
- runner: "node" | "guest";
222
+ runner: "node" | "wasi" | "guest";
134
223
  file: string;
135
224
  argv: string[];
136
225
  env: Record<string, string>;
@@ -140,8 +229,31 @@ export interface ChildSpec {
140
229
  stdin?: SharedArrayBuffer | null;
141
230
  /** node children: the fd of an IPC channel to the parent (fork), on the child's port. */
142
231
  ipc?: number;
232
+ /** node children: fds 3 and up (spawn's stdio), each with the pipe of what comes in on it (see FdPipe). */
233
+ fds?: FdPipe[];
234
+ /** wasi children: the module's path. */
235
+ wasm?: string;
236
+ /** wasi children: the memory their tool's manifest declares (T258), and what they are (its reserve's words). */
237
+ memoryMB?: number;
238
+ what?: string;
239
+ /**
240
+ * Its stdin is its parent's, which comes on demand (T361: the guest shim's, StartMessage.stdinDemand): it asks for it
241
+ * too (stdin-want), on its port (its owner passes it on) or, a spawnSync child, to the controller.
242
+ */
243
+ stdinDemand?: boolean;
244
+ /** A WASIX parent's dispositions for it (T326: proc_spawn's; disp 1 ignore), as its start passes them on. */
245
+ signals?: {
246
+ sig: number;
247
+ disp: number;
248
+ }[];
143
249
  /** Why a guest child is not a host one (the Worker's route). */
144
250
  reason?: string;
251
+ /** spawn's detached: the child does not end with its parent (it is adopted, as by init). */
252
+ detached?: boolean;
253
+ /** node children: StartMessage.outCredit, which the owner (this spec's process) advances. */
254
+ outCredit?: SharedArrayBuffer;
255
+ /** guest children: the owner acknowledges their out messages (out-ack), and the controller sends OUT_WINDOW ahead. */
256
+ outAcks?: boolean;
145
257
  }
146
258
  /** A cross-thread port's two mailboxes, as its thread's end sees them. */
147
259
  export interface ThreadBoxes {
@@ -159,6 +271,8 @@ export interface ThreadSpec {
159
271
  /** null: SHARE_ENV (shareEnv). */
160
272
  env: Record<string, string> | null;
161
273
  execArgv: string[];
274
+ /** The thread's NODE_OPTIONS, as node's Worker takes them (its env's, else its process's, else its parent's own). */
275
+ nodeOptions?: string;
162
276
  cwd: string;
163
277
  envPort: MessagePort;
164
278
  /** The environment port's mailboxes (receiveMessageOnPort while the thread cannot take realm messages). */
@@ -204,10 +318,42 @@ export type WorkerToPage = {
204
318
  } & ChildSpec) | {
205
319
  type: "reap";
206
320
  pid: number;
321
+ }
322
+ /** A detached child ended (StartMessage.detached): what its owner got on its port, for when the owner is gone. */
323
+ | {
324
+ type: "detached-exit";
207
325
  } | {
208
326
  type: "kill";
209
327
  pid: number;
210
328
  signal?: string;
329
+ }
330
+ /**
331
+ * process.kill of a pid that is not the process's own child, blocking on ctl for a KillResult: signal (a name; null
332
+ * for 0, the check) and its number. The guest's kill(2) checks the uid the controller started the process with.
333
+ */
334
+ | {
335
+ type: "kill-pid";
336
+ pid: number;
337
+ signal: string | null;
338
+ signum: number;
339
+ }
340
+ /**
341
+ * A program the host has not got (spawn-route: not found on the host): which of the paths its PATH gives (in order)
342
+ * the guest has one it can run of, blocking on ctl for a WhichResult. None: the spawn is ENOENT, as node's.
343
+ */
344
+ | {
345
+ type: "guest-which";
346
+ candidates: string[];
347
+ }
348
+ /**
349
+ * The process will hold mb MB more than a node process (a tool's manifest memoryMB, T258: Pyodide's 220), blocking
350
+ * on ctl for a ReserveResult: granted within hostExec.memoryBudgetMB, or an error after hostExec.memoryWaitMs.
351
+ * `what` names it in that error. Only when the boot said `memory`.
352
+ */
353
+ | {
354
+ type: "reserve";
355
+ mb: number;
356
+ what?: string;
211
357
  } | {
212
358
  type: "error";
213
359
  message: string;
@@ -233,6 +379,12 @@ export type WorkerToPage = {
233
379
  | {
234
380
  type: "stdin-want";
235
381
  bytes: number;
382
+ }
383
+ /** The answer to a mem message (host-exec's src/mem-report.js). */
384
+ | {
385
+ type: "mem";
386
+ id: number;
387
+ report: HostMemWorkerReport;
236
388
  } | {
237
389
  type: "trace";
238
390
  pid: number;
@@ -272,12 +424,126 @@ export type WorkerToPage = {
272
424
  type: "unix-close";
273
425
  cid: number;
274
426
  }
275
- /** worker_threads: start a thread; it ended (its exit, terminate()). */
427
+ /**
428
+ * UDP between host processes (host-exec's src/udp-socket.js, T270): a socket bound where host processes reach it (the
429
+ * wildcard or the loopback; port 0: an ephemeral one), blocking on ctl for a UdpBindResult; its close; a datagram to
430
+ * the socket bound at address:port (the pod's loopback), handed over as a UdpToWorker.
431
+ */
432
+ | {
433
+ type: "udp-bind";
434
+ family: 4 | 6;
435
+ address: string;
436
+ port: number;
437
+ reuse: boolean;
438
+ v6only: boolean;
439
+ } | {
440
+ type: "udp-close";
441
+ sid: number;
442
+ } | {
443
+ type: "udp-send";
444
+ sid: number;
445
+ family: 4 | 6;
446
+ address: string;
447
+ port: number;
448
+ data: Uint8Array;
449
+ }
450
+ /** worker_threads: start a thread; it ended (its exit, terminate(): terminated, its parent waits until it stopped). */
276
451
  | ({
277
452
  type: "thread";
278
- } & ThreadSpec) | {
453
+ } & ThreadSpec)
454
+ /** (terminated: by terminate() or its process's end, not by itself) */
455
+ | {
279
456
  type: "thread-end";
280
457
  tid: number;
458
+ terminated?: boolean;
459
+ }
460
+ /**
461
+ * A port's message (and what it transfers: realm ports) for thread tid (0: the main one) of its process; -1, or where
462
+ * that one is gone or ending: the one its msg.box's header says has the port's end (controller.ts #relay).
463
+ */
464
+ | {
465
+ type: "relay";
466
+ tid: number;
467
+ msg: unknown;
468
+ transfer: Transferable[];
469
+ }
470
+ /** A thread's answer to drain. */
471
+ | {
472
+ type: "drained";
473
+ }
474
+ /**
475
+ * A WASIX program's process (a wasi Worker, host-exec's wasi-worker.js, T315): start its wasm thread, a wasi Worker
476
+ * with the process's pid and sessions of its own, which ends with it (or at thread-end); `port` goes to its start.
477
+ */
478
+ | {
479
+ type: "wasix-thread";
480
+ tid: number;
481
+ port: MessagePort;
482
+ }
483
+ /**
484
+ * WebCrypto calls the page runs while the process blocks on ctl for their CryptoResult (host-exec's impl-crypto.js:
485
+ * what node does synchronously, createSign, crypto.sign, generateKeyPairSync, publicEncrypt, ...).
486
+ */
487
+ | {
488
+ type: "crypto";
489
+ calls: WebCryptoCall[];
490
+ }
491
+ /**
492
+ * One of host-exec's files next to the Worker (HOST_ASSETS) that a binding needs synchronously, which the Worker
493
+ * cannot fetch itself (its CSP is connect-src 'none'): the page fetches it while the process blocks on ctl for an
494
+ * AssetResult, the bytes after it.
495
+ */
496
+ | {
497
+ type: "asset";
498
+ name: string;
499
+ };
500
+ /**
501
+ * host-node.js's chunks (host-exec's src/lazy.js, its dist/host-node-chunks.json): parts of it a process loads when it
502
+ * first needs one (pako, coverage, the dlopen bindings), which the controller fetches ahead once the pod is idle.
503
+ */
504
+ export declare const HOST_CHUNKS: readonly string[];
505
+ /** The files an asset message may ask for: wasm builds a process loads when it first needs one (node:sqlite's, zlib's brotli and zstd), host-node.js's chunks. */
506
+ export declare const HOST_ASSETS: readonly string[];
507
+ /** An asset message's answer in ctl, in the layout of a SyncResult: its bytes as the one segment, or why there are none. */
508
+ export type AssetResult = {
509
+ size: number;
510
+ } | {
511
+ error: string;
512
+ };
513
+ /**
514
+ * A SubtleCrypto call (importKey, exportKey, generateKey, sign, verify, encrypt, decrypt, deriveBits); an argument
515
+ * { ref: i, part? } is call i's result (a CryptoKey, or a key pair's publicKey / privateKey).
516
+ */
517
+ export interface WebCryptoCall {
518
+ op: string;
519
+ args: unknown[];
520
+ }
521
+ /** A crypto message's answer in ctl: each call's result (ArrayBuffers as { b64 }, JWKs, booleans; CryptoKeys null), or the first error. */
522
+ export type CryptoResult = {
523
+ results: unknown[];
524
+ } | {
525
+ error: {
526
+ name: string;
527
+ message: string;
528
+ };
529
+ };
530
+ /** A udp-bind's answer in ctl: the socket and its port, or an errno (EADDRINUSE, EADDRNOTAVAIL). */
531
+ export type UdpBindResult = {
532
+ sid: number;
533
+ port: number;
534
+ } | {
535
+ error: number;
536
+ };
537
+ /** To a host process: a datagram for its socket sid, from a host process's socket. */
538
+ export type UdpToWorker = {
539
+ type: "udp-message";
540
+ sid: number;
541
+ data: Uint8Array;
542
+ from: {
543
+ address: string;
544
+ family: 4 | 6;
545
+ port: number;
546
+ };
281
547
  };
282
548
  /** A unix-listen's answer in ctl. */
283
549
  export type UnixListenResult = {
@@ -311,12 +577,32 @@ export type UnixToWorker = {
311
577
  export type OwnerToGuestChild = {
312
578
  type: "stdin";
313
579
  data: Uint8Array;
580
+ ack?: boolean;
314
581
  } | {
315
582
  type: "stdin-end";
316
583
  } | {
317
584
  type: "kill";
318
585
  signal: string;
586
+ } | {
587
+ type: "out-ack";
588
+ bytes: number;
319
589
  };
590
+ /** On a guest child's port, to an owner that acknowledges its output (ChildSpec.outAcks): stdin writes marked ack are. */
591
+ export type GuestChildAcks = {
592
+ type: "acks";
593
+ } | {
594
+ type: "stdin-ack";
595
+ };
596
+ /**
597
+ * StartMessage.outCredit (T287): Int32 [0] the bytes of out messages the owner took (wrapping), [1] 1 once nobody takes
598
+ * them any more (a detached child's owner gone): the process's writes wait while OUT_WINDOW bytes are not taken.
599
+ */
600
+ export declare const OUT_WINDOW: number;
601
+ export declare function outCredit(): SharedArrayBuffer;
602
+ /** The owner took bytes of a process's out messages (StartMessage.outCredit). */
603
+ export declare function outTaken(credit: SharedArrayBuffer | undefined, bytes: number): void;
604
+ /** Nobody takes a process's out messages any more: its writes do not wait. */
605
+ export declare function outUntaken(credit: SharedArrayBuffer | undefined): void;
320
606
  /**
321
607
  * spawnSync result in BootMessage.ctl: Int32 [0] set to 1 when done, [1] bytes used; from byte 8
322
608
  * [u32 json length][json SyncResult][segments], each segment's bytes in order.
@@ -329,6 +615,21 @@ export type ListenResult = {
329
615
  } | {
330
616
  error: number;
331
617
  };
618
+ /** kill-pid's answer, as kill(2)'s: errno 0, or ESRCH (no such process), EPERM, EINVAL. */
619
+ export type KillResult = {
620
+ errno: number;
621
+ };
622
+ /** guest-which's answer: whether the guest has one of the candidates (a file with an x bit). */
623
+ export type WhichResult = {
624
+ found: boolean;
625
+ };
626
+ /** A reserve's answer: granted (over: alone above the budget), or why not. */
627
+ export type ReserveResult = {
628
+ granted: true;
629
+ over?: boolean;
630
+ } | {
631
+ error: string;
632
+ };
332
633
  export interface SyncResult {
333
634
  pid: number;
334
635
  status: number | null;
@@ -338,3 +639,35 @@ export interface SyncResult {
338
639
  /** [kind, length]: kind 1 / 2 the pipes, -1 / -2 output the parent writes to its own fd. */
339
640
  segs: [number, number][];
340
641
  }
642
+ /** A WebAssembly.Memory alive in a host Worker (bytes; initial and maximum as its limits say, null where unknown). */
643
+ export interface HostMemWasm {
644
+ /** The package (or script) that made it, else that of the module using it; null when the stack does not tell (WebKit). */
645
+ label: string | null;
646
+ /** Made by new WebAssembly.Memory, a module's own (an instance's export), or imported (another Worker made it). */
647
+ origin: "new" | "instance" | "import";
648
+ shared: boolean;
649
+ initial: number | null;
650
+ maximum: number | null;
651
+ /** Its buffer's byteLength now. */
652
+ bytes: number;
653
+ }
654
+ /** A host Worker's memory (T289): whose it is, its JS heap where the engine tells it (Chromium), its wasm Memories. */
655
+ export interface HostMemWorkerReport {
656
+ /** A pre-warmed Worker that started nothing yet. */
657
+ warm?: boolean;
658
+ pid?: number;
659
+ ppid?: number;
660
+ argv?: string[];
661
+ /** A worker_threads thread: its threadId and name. */
662
+ tid?: number;
663
+ name?: string;
664
+ uptimeMs: number;
665
+ heap: {
666
+ used: number;
667
+ total: number;
668
+ limit: number;
669
+ } | null;
670
+ memories: HostMemWasm[];
671
+ /** Its Web Workers (napi-rs substitutes' threads, light threads), not terminated. */
672
+ webWorkers: number;
673
+ }
@@ -6,8 +6,42 @@
6
6
  * pool), then started once. A top-level process reports on the Worker itself; a child of another
7
7
  * host process on the MessagePort it was started with (its owner: the parent Worker, or the
8
8
  * controller for spawnSync and guest children).
9
+ *
10
+ * A wasm child (ChildSpec runner "wasi", T244) is a Worker of host-exec's dist/wasi-worker.js instead: the same boot and
11
+ * start (start's wasm: the module), no node in it.
9
12
  */
10
13
  export const PROTOCOL = 1;
14
+ /**
15
+ * host-node.js's chunks (host-exec's src/lazy.js, its dist/host-node-chunks.json): parts of it a process loads when it
16
+ * first needs one (pako, coverage, the dlopen bindings), which the controller fetches ahead once the pod is idle.
17
+ */
18
+ export const HOST_CHUNKS = ["host-node-pako.js", "host-node-better-sqlite3.js", "host-node-node-sqlite3.js", "host-node-lmdb.js", "host-node-parcel.js", "host-node-sharp.js", "host-node-password-hash.js", "host-node-extract-zip.js", "host-node-prisma-engine.js", "host-node-coverage.js"];
19
+ /** The files an asset message may ask for: wasm builds a process loads when it first needs one (node:sqlite's, zlib's brotli and zstd), host-node.js's chunks. */
20
+ export const HOST_ASSETS = ["sqlite3.wasm", "brotli.wasm", "zstd.wasm", ...HOST_CHUNKS];
21
+ /**
22
+ * StartMessage.outCredit (T287): Int32 [0] the bytes of out messages the owner took (wrapping), [1] 1 once nobody takes
23
+ * them any more (a detached child's owner gone): the process's writes wait while OUT_WINDOW bytes are not taken.
24
+ */
25
+ export const OUT_WINDOW = 1 << 20;
26
+ export function outCredit() {
27
+ return new SharedArrayBuffer(8);
28
+ }
29
+ /** The owner took bytes of a process's out messages (StartMessage.outCredit). */
30
+ export function outTaken(credit, bytes) {
31
+ if (!credit || !bytes)
32
+ return;
33
+ const i = new Int32Array(credit);
34
+ Atomics.add(i, 0, bytes);
35
+ Atomics.notify(i, 0);
36
+ }
37
+ /** Nobody takes a process's out messages any more: its writes do not wait. */
38
+ export function outUntaken(credit) {
39
+ if (!credit)
40
+ return;
41
+ const i = new Int32Array(credit);
42
+ Atomics.store(i, 1, 1);
43
+ Atomics.notify(i, 0);
44
+ }
11
45
  /**
12
46
  * spawnSync result in BootMessage.ctl: Int32 [0] set to 1 when done, [1] bytes used; from byte 8
13
47
  * [u32 json length][json SyncResult][segments], each segment's bytes in order.
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/host-exec/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAyCH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC;AAkK1B;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC"}
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/host-exec/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAyCH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC;AAkS1B;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAsB,CAAC,mBAAmB,EAAE,6BAA6B,EAAE,2BAA2B,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,uBAAuB,CAAC,CAAC;AAEnT,kKAAkK;AAClK,MAAM,CAAC,MAAM,WAAW,GAAsB,CAAC,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,WAAW,CAAC,CAAC;AAyC3G;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,CAAC;AAClC,MAAM,UAAU,SAAS;IACvB,OAAO,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAClC,CAAC;AACD,iFAAiF;AACjF,MAAM,UAAU,QAAQ,CAAC,MAAqC,EAAE,KAAa;IAC3E,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK;QAAE,OAAO;IAC9B,MAAM,CAAC,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IACzB,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvB,CAAC;AACD,8EAA8E;AAC9E,MAAM,UAAU,UAAU,CAAC,MAAqC;IAC9D,IAAI,CAAC,MAAM;QAAE,OAAO;IACpB,MAAM,CAAC,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACvB,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC"}
@@ -1,5 +1,73 @@
1
- /** node options the host cannot honour (design §11.1): such a process runs in the guest. */
2
- const GUEST_OPTIONS = /^--(?:inspect|debug|prof|cpu-prof|heap-prof|build-snapshot|experimental-sea-config|perf-|jitless|interpreted-frames-native-stack)/;
1
+ /**
2
+ * The node options host mode runs with: the shim's allowlist (crates/webpod-agent/src/shim.rs plan()), as
3
+ * host-exec's spawn-route.js has it for a host process's children. Any other option (--inspect, --check, ...)
4
+ * runs the process in the guest instead of being ignored on the host. With a value (`--opt v` or
5
+ * `--opt=v`), without, or `--opt=v` only.
6
+ */
7
+ const WITH_VALUE = new Set(["-e", "--eval", "-p", "--print", "-r", "--require", "--import", "--experimental-loader", "--loader", "--input-type", "-C", "--conditions", "--title", "--disable-warning", "--unhandled-rejections", "--dns-result-order", "--experimental-default-type", "--redirect-warnings", "--env-file", "--env-file-if-exists",
8
+ // node:test's runner (--test) and what it passes on to its children; watch mode (--watch) (T181)
9
+ "--test-reporter", "--test-reporter-destination", "--test-name-pattern", "--test-skip-pattern", "--test-concurrency", "--test-timeout", "--test-shard", "--test-coverage-include", "--test-coverage-exclude", "--test-coverage-branches", "--test-coverage-functions", "--test-coverage-lines", "--experimental-test-isolation", "--watch-path", "--watch-kill-signal"]);
10
+ const FLAGS = new Set(["--enable-source-maps", "--no-warnings", "--trace-warnings", "--no-deprecation", "--trace-deprecation", "--throw-deprecation", "--pending-deprecation", "--trace-uncaught", "--preserve-symlinks", "--preserve-symlinks-main", "--experimental-require-module", "--no-experimental-require-module", "--experimental-detect-module", "--no-experimental-detect-module", "--experimental-import-meta-resolve", "--no-maglev", "--no-sparkplug",
11
+ "--test", "--test-only", "--test-force-exit", "--test-update-snapshots", "--experimental-test-coverage", "--experimental-test-snapshots", "--experimental-test-module-mocks", "--watch", "--watch-preserve-output"]);
12
+ const WITH_EQUALS = new Set(["--invocation-count-for-turbofan", "--invocation-count-for-osr", "--max-old-space-size", "--max-semi-space-size", "--stack-size"]);
13
+ /** Options that print and exit (host-exec's boot prints them as node does), on the command line only (not NODE_OPTIONS). */
14
+ const INFO = new Set(["-v", "--version", "-h", "--help", "--completion-bash"]);
15
+ /** NODE_OPTIONS' words as node splits them: at spaces, a double-quoted part one word, a backslash in it escaping the next character. */
16
+ function nodeOptionsWords(text) {
17
+ const words = [];
18
+ let quoted = false;
19
+ let fresh = true;
20
+ for (let i = 0; i < text.length; i++) {
21
+ let c = text[i];
22
+ if (c === "\\" && quoted && i + 1 < text.length)
23
+ c = text[++i];
24
+ else if (c === " " && !quoted) {
25
+ fresh = true;
26
+ continue;
27
+ }
28
+ else if (c === '"') {
29
+ quoted = !quoted;
30
+ continue;
31
+ }
32
+ if (fresh) {
33
+ words.push(c);
34
+ fresh = false;
35
+ }
36
+ else
37
+ words[words.length - 1] += c;
38
+ }
39
+ return words;
40
+ }
41
+ /**
42
+ * The option of argv (node's own, before the script) or NODE_OPTIONS that sends node to the guest, as the reason. In
43
+ * argv a word that is no option is the script. In NODE_OPTIONS node stops at one and ignores the rest; this passes over
44
+ * it and checks the rest, so that in doubt the process runs in the guest.
45
+ */
46
+ function guestNodeOption(args, nodeOptions) {
47
+ const check = (opts, inEnv) => {
48
+ for (let i = 0; i < opts.length; i++) {
49
+ const a = opts[i];
50
+ if (inEnv && (!a.startsWith("-") || a === "-"))
51
+ continue;
52
+ if (a === "--" || !a.startsWith("-") || a === "-")
53
+ return null;
54
+ const eq = a.indexOf("=");
55
+ let name = eq > 0 ? a.slice(0, eq) : a;
56
+ if (name === "-pe")
57
+ name = "-e";
58
+ if (WITH_VALUE.has(name)) {
59
+ if (eq < 0)
60
+ i++;
61
+ continue;
62
+ }
63
+ if (eq < 0 ? FLAGS.has(name) || (!inEnv && INFO.has(name)) : WITH_EQUALS.has(name))
64
+ continue;
65
+ return `node option ${name}${inEnv ? " (NODE_OPTIONS)" : ""}`;
66
+ }
67
+ return null;
68
+ };
69
+ return (nodeOptions ? check(nodeOptionsWords(nodeOptions), true) : null) ?? check(args, false);
70
+ }
3
71
  const inside = (path, dir) => path === dir || path.startsWith(dir.endsWith("/") ? dir : `${dir}/`);
4
72
  /**
5
73
  * Where a process the app starts (`pod.spawn`) runs, once at its start (e4-integration.md §3.1);
@@ -21,17 +89,10 @@ export function routeTopLevel(req, ctx) {
21
89
  const cwd = req.cwd ?? ctx.workspace;
22
90
  if (!cwd.startsWith("/") || ![ctx.workspace, ...(ctx.shares ?? [])].some((d) => inside(cwd, d)))
23
91
  return guest(`cwd outside ${ctx.workspace}`);
24
- // node's own options come before the script (or -e / -p); npm's argv has none of node's.
25
- if (name === "node") {
26
- for (const a of req.args) {
27
- if (!a.startsWith("-"))
28
- break;
29
- if (GUEST_OPTIONS.test(a))
30
- return guest(`node option ${a.split("=")[0]}`);
31
- if (a === "-e" || a === "-p" || a === "--eval" || a === "--print" || a === "-r" || a === "--require" || a === "--")
32
- break;
33
- }
34
- }
92
+ // node's own options come before the script (or -e / -p); npm's argv has none of node's, NODE_OPTIONS may.
93
+ const option = guestNodeOption(name === "node" ? req.args : [], req.env?.NODE_OPTIONS);
94
+ if (option)
95
+ return guest(option);
35
96
  return { runner: "host", argv: [ctx.execPath, ...prefix, ...req.args], cwd };
36
97
  }
37
98
  //# sourceMappingURL=route.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.js","sourceRoot":"","sources":["../../src/host-exec/route.ts"],"names":[],"mappings":"AAEA,4FAA4F;AAC5F,MAAM,aAAa,GAAG,mIAAmI,CAAC;AAa1J,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,GAAW,EAAE,EAAE,CAAC,IAAI,KAAK,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;AAEnH;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAwB,EAAE,GAAiB;IACvE,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,KAAK,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC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ge {
18
18
  _send(msg: HostModeMsg): void;
19
19
  /** @internal */
20
20
  _done(id: number): void;
21
- /** @internal Records the entry in $HOME/.cache/webpod/host-exec-fallback.json, which the shim reads. */
22
- _learn(m: HostSpawnMsg, pattern: string): void;
21
+ /** @internal Records the entry's package in $HOME/.cache/webpod/host-exec-fallback.json, which the shim reads. */
22
+ _learn(m: HostSpawnMsg, entry: string): void;
23
23
  }
24
24
  /**
25
25
  * The directories the read-only tree serves, for HostExecInfo's mounts: each package it holds (a node_modules
26
26
  * entry), else each file's directory. execPath (always there, empty) is not one.
27
27
  */
28
28
  export declare function treeRoots(tree: SharedArrayBuffer | ArrayBuffer | undefined, execPath: string): string[];
29
+ /**
30
+ * Packages a fallback of one of their commands does not send to the guest for good: corepack's `enable` writes its shims
31
+ * to the image's /usr/local/bin, outside the host's shares, while the package managers it runs, its pnpm and yarn
32
+ * shims too, run on the host (T371: once learned, `corepack pnpm --version` took 19 s in the guest, 1 s on the host).
33
+ */
34
+ export declare const NOT_LEARNED: ReadonlySet<string>;