@nimbus-sh/core 0.3.0 → 0.5.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.
Files changed (155) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +140 -0
  3. package/dist/_shared/error-text.d.ts +15 -0
  4. package/dist/_shared/error-text.d.ts.map +1 -0
  5. package/dist/_shared/error-text.js +21 -0
  6. package/dist/_shared/exports-resolver.d.ts +19 -7
  7. package/dist/_shared/exports-resolver.d.ts.map +1 -1
  8. package/dist/_shared/exports-resolver.js +1 -1
  9. package/dist/_shared/retry.d.ts.map +1 -1
  10. package/dist/_shared/retry.js +3 -1
  11. package/dist/_shared/tarball-stream.d.ts +93 -0
  12. package/dist/_shared/tarball-stream.d.ts.map +1 -0
  13. package/dist/_shared/tarball-stream.js +235 -0
  14. package/dist/_shared/tarball.d.ts +17 -0
  15. package/dist/_shared/tarball.d.ts.map +1 -0
  16. package/dist/_shared/tarball.js +39 -0
  17. package/dist/_shared/w7-frame.js +2 -1
  18. package/dist/constants.d.ts.map +1 -1
  19. package/dist/constants.js +30 -16
  20. package/dist/observability/oom-classify.d.ts +1 -1
  21. package/dist/observability/oom-classify.d.ts.map +1 -1
  22. package/dist/observability/oom-classify.js +7 -0
  23. package/dist/observability/oom-discriminator.d.ts +1 -1
  24. package/dist/runtime/clang-runner.d.ts +38 -0
  25. package/dist/runtime/clang-runner.d.ts.map +1 -0
  26. package/dist/runtime/clang-runner.js +866 -0
  27. package/dist/runtime/esbuild-service.d.ts +4 -3
  28. package/dist/runtime/esbuild-service.d.ts.map +1 -1
  29. package/dist/runtime/esbuild-service.js +9 -4
  30. package/dist/runtime/facet-host.d.ts +12 -0
  31. package/dist/runtime/facet-host.d.ts.map +1 -1
  32. package/dist/runtime/installed-runtimes.d.ts +4 -3
  33. package/dist/runtime/installed-runtimes.d.ts.map +1 -1
  34. package/dist/runtime/local-facet-host.d.ts.map +1 -1
  35. package/dist/runtime/local-facet-host.js +29 -9
  36. package/dist/runtime/long-running-handle.d.ts +3 -3
  37. package/dist/runtime/long-running-handle.d.ts.map +1 -1
  38. package/dist/runtime/os-contracts.d.ts +7 -5
  39. package/dist/runtime/os-contracts.d.ts.map +1 -1
  40. package/dist/runtime/port-registry.d.ts +28 -0
  41. package/dist/runtime/port-registry.d.ts.map +1 -1
  42. package/dist/runtime/port-registry.js +79 -9
  43. package/dist/runtime/process-logs.d.ts +9 -1
  44. package/dist/runtime/process-logs.d.ts.map +1 -1
  45. package/dist/runtime/project-detect.d.ts +6 -1
  46. package/dist/runtime/project-detect.d.ts.map +1 -1
  47. package/dist/runtime/require-resolver.d.ts.map +1 -1
  48. package/dist/runtime/require-resolver.js +3 -4
  49. package/dist/runtime/ruby-gems.d.ts +30 -0
  50. package/dist/runtime/ruby-gems.d.ts.map +1 -0
  51. package/dist/runtime/ruby-gems.js +636 -0
  52. package/dist/runtime/ruby-runner.d.ts +127 -0
  53. package/dist/runtime/ruby-runner.d.ts.map +1 -0
  54. package/dist/runtime/ruby-runner.js +1357 -0
  55. package/dist/runtime/runtime-registry.d.ts +4 -3
  56. package/dist/runtime/runtime-registry.d.ts.map +1 -1
  57. package/dist/runtime/runtime-registry.js +2 -1
  58. package/dist/runtime/session-process-supervisor.d.ts +15 -0
  59. package/dist/runtime/session-process-supervisor.d.ts.map +1 -1
  60. package/dist/runtime/session-process-supervisor.js +30 -0
  61. package/dist/runtime/sqlite-runtime-fs-bridge.js +1 -5
  62. package/dist/runtime/virtual-socket-kernel.d.ts.map +1 -1
  63. package/dist/runtime/virtual-socket-kernel.generated.d.ts +1 -1
  64. package/dist/runtime/virtual-socket-kernel.generated.d.ts.map +1 -1
  65. package/dist/runtime/virtual-socket-kernel.generated.js +2 -2
  66. package/dist/runtime/virtual-socket-kernel.js +10 -5
  67. package/dist/runtime/wasm-runner.d.ts.map +1 -1
  68. package/dist/runtime/wasm-runner.js +22 -14
  69. package/dist/shell/features.d.ts.map +1 -1
  70. package/dist/shell/features.js +5 -4
  71. package/dist/shell/unix-commands.d.ts +14 -1
  72. package/dist/shell/unix-commands.d.ts.map +1 -1
  73. package/dist/shell/unix-commands.js +115 -69
  74. package/dist/substrate/lifo/commands/net/ip.d.ts.map +1 -1
  75. package/dist/substrate/lifo/commands/system/ps.d.ts +2 -1
  76. package/dist/substrate/lifo/commands/system/ps.d.ts.map +1 -1
  77. package/dist/substrate/lifo/kernel/ServiceManager.d.ts.map +1 -1
  78. package/dist/substrate/lifo/kernel/ServiceManager.js +0 -2
  79. package/dist/substrate/lifo/kernel/network/NetworkStack.d.ts +22 -11
  80. package/dist/substrate/lifo/kernel/network/NetworkStack.d.ts.map +1 -1
  81. package/dist/substrate/lifo/kernel/network/NetworkStack.js +0 -2
  82. package/dist/substrate/lifo/kernel/network/tunnel/WebSocketTunnel.d.ts +2 -1
  83. package/dist/substrate/lifo/kernel/network/tunnel/WebSocketTunnel.d.ts.map +1 -1
  84. package/dist/substrate/lifo/kernel/network/tunnel/WebSocketTunnel.js +3 -4
  85. package/dist/substrate/lifo/kernel/vfs/VFS.d.ts +17 -0
  86. package/dist/substrate/lifo/kernel/vfs/VFS.d.ts.map +1 -1
  87. package/dist/substrate/lifo/kernel/vfs/VFS.js +33 -0
  88. package/dist/substrate/lifo/node-compat/esbuild.d.ts.map +1 -1
  89. package/dist/substrate/lifo/node-compat/esbuild.js +2 -4
  90. package/dist/substrate/lifo/node-compat/index.d.ts.map +1 -1
  91. package/dist/substrate/lifo/node-compat/index.js +3 -2
  92. package/dist/substrate/lifo/node-compat/loose-equality.d.ts +19 -0
  93. package/dist/substrate/lifo/node-compat/loose-equality.d.ts.map +1 -0
  94. package/dist/substrate/lifo/node-compat/loose-equality.js +91 -0
  95. package/dist/substrate/lifo/node-compat/process.d.ts.map +1 -1
  96. package/dist/substrate/lifo/node-compat/process.js +6 -3
  97. package/dist/substrate/lifo/shell/Shell.d.ts +19 -0
  98. package/dist/substrate/lifo/shell/Shell.d.ts.map +1 -1
  99. package/dist/substrate/lifo/shell/Shell.js +86 -75
  100. package/dist/substrate/lifo/shell/lexer.d.ts +9 -0
  101. package/dist/substrate/lifo/shell/lexer.d.ts.map +1 -1
  102. package/dist/substrate/lifo/shell/lexer.js +40 -0
  103. package/dist/vfs/seed-project.d.ts.map +1 -1
  104. package/dist/vfs/seed-project.js +8 -2
  105. package/dist/vfs/sqlite-vfs.d.ts +61 -1
  106. package/dist/vfs/sqlite-vfs.d.ts.map +1 -1
  107. package/dist/vfs/sqlite-vfs.js +199 -35
  108. package/dist/workspace/nimbus-workspace.d.ts.map +1 -1
  109. package/dist/workspace/nimbus-workspace.js +9 -2
  110. package/package.json +4 -2
  111. package/src/_shared/error-text.ts +21 -0
  112. package/src/_shared/exports-resolver.ts +24 -4
  113. package/src/_shared/retry.ts +4 -2
  114. package/src/_shared/tarball-stream.ts +263 -0
  115. package/src/_shared/tarball.ts +46 -0
  116. package/src/_shared/w7-frame.ts +2 -1
  117. package/src/constants.ts +30 -16
  118. package/src/observability/oom-classify.ts +7 -0
  119. package/src/observability/oom-discriminator.ts +1 -1
  120. package/src/runtime/clang-runner.ts +924 -0
  121. package/src/runtime/esbuild-service.ts +16 -11
  122. package/src/runtime/facet-host.ts +12 -0
  123. package/src/runtime/installed-runtimes.ts +4 -3
  124. package/src/runtime/local-facet-host.ts +28 -8
  125. package/src/runtime/long-running-handle.ts +3 -3
  126. package/src/runtime/os-contracts.ts +7 -5
  127. package/src/runtime/port-registry.ts +97 -9
  128. package/src/runtime/process-logs.ts +12 -3
  129. package/src/runtime/project-detect.ts +7 -1
  130. package/src/runtime/require-resolver.ts +7 -7
  131. package/src/runtime/ruby-gems.ts +682 -0
  132. package/src/runtime/ruby-runner.ts +1484 -0
  133. package/src/runtime/runtime-registry.ts +9 -7
  134. package/src/runtime/session-process-supervisor.ts +27 -0
  135. package/src/runtime/sqlite-runtime-fs-bridge.ts +9 -6
  136. package/src/runtime/virtual-socket-kernel.generated.ts +2 -2
  137. package/src/runtime/virtual-socket-kernel.ts +10 -5
  138. package/src/runtime/wasm-runner.ts +55 -29
  139. package/src/shell/features.ts +5 -4
  140. package/src/shell/unix-commands.ts +273 -128
  141. package/src/substrate/lifo/commands/net/ip.ts +15 -15
  142. package/src/substrate/lifo/commands/system/ps.ts +2 -1
  143. package/src/substrate/lifo/kernel/ServiceManager.ts +0 -2
  144. package/src/substrate/lifo/kernel/network/NetworkStack.ts +24 -17
  145. package/src/substrate/lifo/kernel/network/tunnel/WebSocketTunnel.ts +37 -12
  146. package/src/substrate/lifo/kernel/vfs/VFS.ts +34 -0
  147. package/src/substrate/lifo/node-compat/esbuild.ts +16 -8
  148. package/src/substrate/lifo/node-compat/index.ts +3 -2
  149. package/src/substrate/lifo/node-compat/loose-equality.ts +81 -0
  150. package/src/substrate/lifo/node-compat/process.ts +5 -2
  151. package/src/substrate/lifo/shell/Shell.ts +92 -70
  152. package/src/substrate/lifo/shell/lexer.ts +38 -0
  153. package/src/vfs/seed-project.ts +10 -3
  154. package/src/vfs/sqlite-vfs.ts +209 -36
  155. package/src/workspace/nimbus-workspace.ts +10 -1
@@ -0,0 +1,39 @@
1
+ /**
2
+ * tarball.ts — a whole tarball, in memory, as a path→bytes map.
3
+ *
4
+ * The streaming primitives it walks with (`parseTarHeader`, `streamTarEntries`,
5
+ * `readableStreamToAsyncIterable`) live in `./tarball-stream.ts` — a
6
+ * dependency-free leaf, because `bundle-facet-workers.mjs` esbuilds that file
7
+ * into a string the loader pool injects into dynamic workers, where an import
8
+ * would not resolve.
9
+ *
10
+ * This half is for a caller that already holds the bytes: `gem install`, which
11
+ * fetches a `.gem` (a tar holding a gzipped tar) and needs both layers open at
12
+ * once. An installer streaming a tarball it is still downloading should drive
13
+ * `streamTarEntries` itself and never hold the whole thing.
14
+ */
15
+ import { streamTarEntries, readableStreamToAsyncIterable, } from './tarball-stream.js';
16
+ /** Extract every regular file. Gzipped input is decompressed first. */
17
+ export async function extractTarball(tarball) {
18
+ const files = new Map();
19
+ const raw = new Uint8Array(tarball);
20
+ // Adapter: wrap the single buffer as an async iterable. If gzipped, pipe
21
+ // through DecompressionStream so the streaming parser still sees tar bytes.
22
+ let source;
23
+ if (raw[0] === 0x1f && raw[1] === 0x8b) {
24
+ const rs = new Blob([tarball]).stream().pipeThrough(new DecompressionStream('gzip'));
25
+ source = readableStreamToAsyncIterable(rs);
26
+ }
27
+ else {
28
+ source = (async function* () { yield raw; })();
29
+ }
30
+ try {
31
+ for await (const entry of streamTarEntries(source)) {
32
+ files.set(entry.name, entry.data);
33
+ }
34
+ }
35
+ catch {
36
+ return files;
37
+ }
38
+ return files;
39
+ }
@@ -724,7 +724,8 @@ function updateRecordCheck(seed, ...parts) {
724
724
  const CRC_SEED = 0xffff_ffff;
725
725
  let crcTable = null;
726
726
  function crc32Update(check, bytes) {
727
- const table = crcTable ??= createCrcTable();
727
+ crcTable ??= createCrcTable();
728
+ const table = crcTable;
728
729
  let value = check;
729
730
  for (const byte of bytes)
730
731
  value = table[(value ^ byte) & 0xff] ^ (value >>> 8);
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,eAAO,MAAM,cAAc,UAAU,CAAC;AA+BtC,eAAO,MAAM,YAAY,aAAa,CAAC;AACvC,eAAO,MAAM,aAAa;;;;CAAyD,CAAC;AACpF,eAAO,MAAM,eAAe,WAAW,CAAC;AAQxC,eAAO,MAAM,aAAa,WAAW,CAAC;AAQtC,eAAO,MAAM,gBAAgB,WAAW,CAAC;AAGzC,eAAO,MAAM,UAAU,QAAS,CAAC;AACjC,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,eAAO,MAAM,YAAY,QAA0B,CAAC;AACpD,eAAO,MAAM,iBAAiB,QAAkB,CAAC;AACjD,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,oC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AAmB,CAAC;AAiBzD,eAAO,MAAM,wBAAwB,QAAmB,CAAC;AAoBzD,eAAO,MAAM,2BAA2B,QAAkB,CAAC;AAG3D,eAAO,MAAM,YAAY,+BAA+B,CAAC;AACzD,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAC7C,eAAO,MAAM,0BAA0B,QAA6B,CAAC;AACrE,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAGxC,eAAO,MAAM,iBAAiB,OAAO,CAAC;AACtC,eAAO,MAAM,oBAAoB,aAAa,CAAC;AAC/C,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAC7C,eAAO,MAAM,oBAAoB,MAAM,CAAC;AASxC,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAG3C,eAAO,MAAM,cAAc,eAAe,CAAC;AA6B3C,eAAO,MAAM,6BAA6B,QAAmB,CAAC;AAO9D,eAAO,MAAM,4CAA4C,QAAmB,CAAC;AAY7E,eAAO,MAAM,6BAA6B,QAAc,CAAC;AAGzD,eAAO,MAAM,gBAAgB,WAAW,CAAC;AACzC,eAAO,MAAM,YAAY,eAAe,CAAC;AACzC,eAAO,MAAM,YAAY,SAAS,CAAC;AACnC,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,YAAY,2EAA2E,CAAC;AACrG,eAAO,MAAM,oBAAoB,UAAqD,CAAC;AAiBvF,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAAe,CAAC"}
package/dist/constants.js CHANGED
@@ -132,10 +132,13 @@ export const FACET_TIMEOUT_MS = 30_000; // 30s execution timeout
132
132
  // JavaScript, so workerd's per-module text-size limit applies to the
133
133
  // JSON-escaped form (each `\n` / `\"` / `\u` adds bytes, plus the
134
134
  // per-key string-quote overhead).
135
- // raw → boots, 8 MiB raw fails. Encoded as JSON that's roughly 18-25 MiB
136
- // of module text. We target 22 MiB encoded as the hard ceiling, leaving
137
- // ~2-3 MiB of headroom for the rest of the worker module (shims, runner
138
- // boot code) and any minor drift in the eviction loop's accounting.
135
+ // Measured: 8 MiB raw failed to boot; the passing raw bound was measured
136
+ // too, but the number was lost to comment truncation before it ever
137
+ // reached git, so only the failing side is known. Encoded as JSON that's
138
+ // roughly 18-25 MiB of module text. We target 22 MiB encoded as the hard
139
+ // ceiling, leaving ~2-3 MiB of headroom for the rest of the worker module
140
+ // (shims, runner boot code) and any minor drift in the eviction loop's
141
+ // accounting.
139
142
  //
140
143
  // facet-manager.ts:buildPrefetchBundle uses TextEncoder().encode().length
141
144
  // to measure exact UTF-8 bytes (not JS string .length, which counts UTF-16
@@ -207,20 +210,31 @@ export const NIMBUS_AI_GATEWAY_PORT = 8790;
207
210
  export const CF_COMPAT_DATE = '2026-04-01';
208
211
  // ── Supervisor heap budget [C'.1] ───────────────────────────────────────
209
212
  //
210
- // The supervisor isolate's 128 MiB workerd cap is a HARD platform ceiling
211
- // (per docs/research/cf-primitives-dossier.md §6 invariant I1 — 128 MiB
212
- // per V8 isolate, may be shared across same-class peer DOs co-tenanting in
213
- // one process). Nimbus targets HALF of that as a self-imposed soft ceiling
214
- // so the supervisor always has runway when workerd LRU-evicts neighbours
215
- // or AIR (Asynchronous Isolate Recreation) folds growing isolates.
213
+ // Three distinct memory regimes, not one shared pool:
216
214
  //
217
- // 64 MiB is a budget, not a measurement, and nothing enforces it.
215
+ // - Supervisor DO isolate: 128 MiB HARD platform ceiling ("Each isolate
216
+ // can consume up to 128 MB of memory" —
217
+ // https://developers.cloudflare.com/workers/platform/limits/).
218
+ // - Facets: ~208-256 MiB EACH, measured — memory independent of the
219
+ // supervisor and of each other (1,664 MiB live across 8 facets +
220
+ // parent) but CPU SHARED across the actor thread. See
221
+ // packages/worker/src/loaders/process-fabric.ts.
222
+ // - Peer DOs: independent memory AND CPU budgets, measured 1.2 GiB
223
+ // live across 8 peers.
224
+ //
225
+ // Nimbus targets HALF of the supervisor's 128 MiB as a self-imposed soft
226
+ // ceiling so the supervisor always has runway when workerd LRU-evicts
227
+ // neighbours or AIR (Asynchronous Isolate Recreation) folds growing
228
+ // isolates.
229
+ //
230
+ // 64 MiB is a soft admission budget, not a measurement — the right value
231
+ // is unmeasured — and nothing enforces it directly.
218
232
  // src/observability/heap-estimate.ts sums the INSTRUMENTED contributors —
219
- // the supervisor baseline, VFS LRU and in-flight writes, pre-bundle slices,
220
- // and streaming RPC buffers which is a lower bound, not full coverage.
221
- // The prefetch-bundle path in facets/manager.ts allocates against this
222
- // budget without accounting for it; see HEAP_BLIND_SPOTS for the current
223
- // gap. Read a low percentOfCeiling accordingly.
233
+ // the supervisor baseline, VFS LRU and in-flight writes, pre-bundle
234
+ // slices, streaming RPC buffers, and the prefetch-bundle build lease and
235
+ // cache gauge which is a lower bound, not full coverage; allocation
236
+ // sites known to be missing are listed in HEAP_BLIND_SPOTS. Read a low
237
+ // percentOfCeiling accordingly.
224
238
  export const SUPERVISOR_HEAP_CEILING_BYTES = 64 * 1024 * 1024;
225
239
  // Shared allowance for transient allocations in the supervisor DO. With the
226
240
  // VFS LRU shrunk to 8 MiB during an active reservation, 40 MiB of admitted
@@ -60,7 +60,7 @@
60
60
  * the union narrow and additive — adding a new value is fine, but
61
61
  * never re-purpose an existing one.
62
62
  */
63
- declare const OOM_CAUSES: readonly ["sqlite_nomem", "oom", "cpu_exceeded", "clone_refused", "rpc_timeout", "subrequest_cap", "condemnation", "hard_evict", "unknown"];
63
+ declare const OOM_CAUSES: readonly ["sqlite_nomem", "oom", "cpu_exceeded", "clone_refused", "rpc_timeout", "subrequest_cap", "dynamic_worker_cap", "condemnation", "hard_evict", "unknown"];
64
64
  export type OomCause = typeof OOM_CAUSES[number];
65
65
  export declare function isOomCause(input: unknown): input is OomCause;
66
66
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"oom-classify.d.ts","sourceRoot":"","sources":["../../src/observability/oom-classify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AK,EAAE,OAAO,GAAG,OAAO,CAO1D;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEtD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAgBpD"}
@@ -67,6 +67,7 @@ const OOM_CAUSES = [
67
67
  'clone_refused',
68
68
  'rpc_timeout',
69
69
  'subrequest_cap',
70
+ 'dynamic_worker_cap',
70
71
  'condemnation',
71
72
  'hard_evict',
72
73
  'unknown',
@@ -115,6 +116,12 @@ export function classifyMessage(msg) {
115
116
  // Subrequest cap (Cloudflare platform)
116
117
  if (m.includes('too many subrequests'))
117
118
  return 'subrequest_cap';
119
+ // Worker Loader concurrency cap (Cloudflare platform): a Durable Object
120
+ // admits ~5-6 concurrent dynamic workers, and loader-cache entries are
121
+ // never released — every distinct loader.get(id) permanently consumes a
122
+ // slot, so this cap recurs until the DO itself is replaced.
123
+ if (m.includes('too many concurrent dynamic workers'))
124
+ return 'dynamic_worker_cap';
118
125
  // Memory exhaustion. workerd trace outcome `exceededMemory`; in-band it
119
126
  // arrives as a `broken.exceededMemory` actor break, a "…exceeded [its]
120
127
  // memory limit" kill, or the "Memory limit exceeded" RangeError.
@@ -116,7 +116,7 @@ export interface DiagRecoveryEvent {
116
116
  toState: SessionState;
117
117
  /** Human-readable trigger ('ws-close', 'isolate-evicted', etc.). */
118
118
  trigger: string;
119
- /** _w9IsolateGen at the time of the event. Lets a probe detect the
119
+ /** _isolateGen at the time of the event. Lets a probe detect the
120
120
  * difference between an in-isolate transition and a cross-isolate one
121
121
  * (the latter implies workerd recycled the DO). */
122
122
  isolateGen: number;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * clang-runner.ts — compile, link, and execute C programs for Nimbus WASI.
3
+ *
4
+ * Architecture (compile-link-run, two facet calls):
5
+ *
6
+ * compile : clang.wasm + sysroot subset for C includes + user .c
7
+ * → produces .o bytes (returned to supervisor).
8
+ * link : lld.wasm + sysroot subset for link (crt1.o + libc.a)
9
+ * + .o from compile → produces .wasm executable.
10
+ * write : final .wasm flushed to user VFS at the requested path.
11
+ *
12
+ * The filesystem both halves see is the one WASI layer every other
13
+ * non-node runtime uses (wasi-instance.ts), seeded and sealed.
14
+ *
15
+ * Splitting compile and link into separate facet calls keeps each
16
+ * call under the empirical payload ceiling. Each ships:
17
+ *
18
+ * - compile: 31 MiB clang.wasm + ~1.3 MiB sysroot subset (C includes).
19
+ * - link : 19 MiB lld.wasm + ~0.75 MiB libs + tiny .o.
20
+ *
21
+ * Sysroot subset extraction happens supervisor-side via a small ustar
22
+ * parser. The full sysroot.tar is parsed once when the clang runtime
23
+ * warms for a session; compile/link calls reuse the filtered subsets.
24
+ *
25
+ * Dispatch stays direct: no sleeps, no caller-side retries, and no
26
+ * catch-and-continue around loader failures.
27
+ */
28
+ import type { RuntimeManifest } from './runtime-manifest.js';
29
+ import type { SqliteVFS } from '../vfs/sqlite-vfs.js';
30
+ import type { Command } from '../substrate/lifo/commands/types.js';
31
+ import type { FacetHost } from './facet-host.js';
32
+ /** Build the runner factory. Closes over the facet host + vfs. */
33
+ export declare function makeClangRunnerFactory(deps: {
34
+ facets: FacetHost;
35
+ vfs: SqliteVFS;
36
+ }): (manifest: RuntimeManifest, installRoot: string, binName: string, binKind: string | undefined) => Command;
37
+ export declare const CLANG_RUNNER_PREAMBLE: string;
38
+ //# sourceMappingURL=clang-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clang-runner.d.ts","sourceRoot":"","sources":["../../src/runtime/clang-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,OAAO,EAAkB,MAAM,qCAAqC,CAAC;AACnF,OAAO,KAAK,EAAS,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQxD,kEAAkE;AAClE,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,MAAM,EAAE,SAAS,CAAC;IAClB,GAAG,EAAE,SAAS,CAAC;CAChB,GAAG,CAAC,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,KAC7F,OAAO,CAiTV;AA8jBD,eAAO,MAAM,qBAAqB,QAAiE,CAAC"}