@nimbus-sh/worker 0.12.0 → 0.13.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 (198) hide show
  1. package/dist/esbuild-cli-artifact.generated.d.ts +1 -1
  2. package/dist/esbuild-cli-artifact.generated.js +4 -4
  3. package/dist/esbuild-wasm-bundle.generated.d.ts +11 -10
  4. package/dist/esbuild-wasm-bundle.generated.d.ts.map +1 -1
  5. package/dist/esbuild-wasm-bundle.generated.js +11 -10
  6. package/dist/facets/build-facet.d.ts +53 -0
  7. package/dist/facets/build-facet.d.ts.map +1 -0
  8. package/dist/facets/build-facet.js +346 -0
  9. package/dist/facets/cirrus-real.d.ts +3 -0
  10. package/dist/facets/cirrus-real.d.ts.map +1 -1
  11. package/dist/facets/cirrus-real.js +1 -2
  12. package/dist/facets/compose.d.ts +1 -0
  13. package/dist/facets/compose.d.ts.map +1 -1
  14. package/dist/facets/compose.js +3 -0
  15. package/dist/facets/data-plan.d.ts +14 -30
  16. package/dist/facets/data-plan.d.ts.map +1 -1
  17. package/dist/facets/data-plan.js +153 -13
  18. package/dist/facets/dev-stylesheet.d.ts +27 -0
  19. package/dist/facets/dev-stylesheet.d.ts.map +1 -0
  20. package/dist/facets/dev-stylesheet.js +65 -0
  21. package/dist/facets/esbuild-transform.d.ts +23 -18
  22. package/dist/facets/esbuild-transform.d.ts.map +1 -1
  23. package/dist/facets/esbuild-transform.js +63 -109
  24. package/dist/facets/manager.d.ts +49 -9
  25. package/dist/facets/manager.d.ts.map +1 -1
  26. package/dist/facets/manager.js +238 -69
  27. package/dist/facets/oxc-transform.d.ts +29 -0
  28. package/dist/facets/oxc-transform.d.ts.map +1 -0
  29. package/dist/facets/oxc-transform.js +198 -0
  30. package/dist/facets/prebundle-pool.d.ts +23 -0
  31. package/dist/facets/prebundle-pool.d.ts.map +1 -0
  32. package/dist/facets/prebundle-pool.js +55 -0
  33. package/dist/facets/process.d.ts +13 -6
  34. package/dist/facets/process.d.ts.map +1 -1
  35. package/dist/facets/process.js +37 -31
  36. package/dist/facets/transform-store.d.ts +4 -4
  37. package/dist/facets/transform-store.js +4 -4
  38. package/dist/facets/vite-dev-server.d.ts +89 -12
  39. package/dist/facets/vite-dev-server.d.ts.map +1 -1
  40. package/dist/facets/vite-dev-server.js +66 -43
  41. package/dist/hosted/commands.d.ts.map +1 -1
  42. package/dist/hosted/commands.js +20 -4
  43. package/dist/hosted/runtime.d.ts.map +1 -1
  44. package/dist/hosted/runtime.js +7 -2
  45. package/dist/hosted/services.d.ts +3 -3
  46. package/dist/hosted/services.d.ts.map +1 -1
  47. package/dist/hosted/services.js +102 -95
  48. package/dist/hosted/session.d.ts +1 -0
  49. package/dist/hosted/session.d.ts.map +1 -1
  50. package/dist/loaders/generated-workers.d.ts +3 -0
  51. package/dist/loaders/generated-workers.d.ts.map +1 -1
  52. package/dist/loaders/generated-workers.js +3 -0
  53. package/dist/napi-wasm-artifacts.generated.js +2 -2
  54. package/dist/node-shims-artifact.generated.d.ts +14 -1
  55. package/dist/node-shims-artifact.generated.d.ts.map +1 -1
  56. package/dist/node-shims-artifact.generated.js +23 -10
  57. package/dist/npm/bin-links.d.ts +7 -4
  58. package/dist/npm/bin-links.d.ts.map +1 -1
  59. package/dist/npm/bin-links.js +14 -55
  60. package/dist/npm/cache.d.ts +6 -0
  61. package/dist/npm/cache.d.ts.map +1 -1
  62. package/dist/npm/cache.js +26 -4
  63. package/dist/npm/installer.d.ts +1 -1
  64. package/dist/npm/installer.d.ts.map +1 -1
  65. package/dist/npm/installer.js +26 -52
  66. package/dist/npm/pre-bundle-facet.d.ts +15 -117
  67. package/dist/npm/pre-bundle-facet.d.ts.map +1 -1
  68. package/dist/npm/pre-bundle-facet.js +13 -511
  69. package/dist/oxc-facet-artifact.generated.d.ts +18 -0
  70. package/dist/oxc-facet-artifact.generated.d.ts.map +1 -0
  71. package/dist/oxc-facet-artifact.generated.js +17 -0
  72. package/dist/oxc-wasm-artifact.generated.d.ts +20 -0
  73. package/dist/oxc-wasm-artifact.generated.d.ts.map +1 -0
  74. package/dist/oxc-wasm-artifact.generated.js +19 -0
  75. package/dist/rolldown-facet-artifact.generated.d.ts +18 -0
  76. package/dist/rolldown-facet-artifact.generated.d.ts.map +1 -0
  77. package/dist/rolldown-facet-artifact.generated.js +17 -0
  78. package/dist/router/remote-api.d.ts.map +1 -1
  79. package/dist/router/remote-api.js +9 -0
  80. package/dist/runtime/bash-repl.d.ts.map +1 -1
  81. package/dist/runtime/bash-repl.js +1 -4
  82. package/dist/runtime/cpython-resident.d.ts.map +1 -1
  83. package/dist/runtime/cpython-resident.js +1 -0
  84. package/dist/runtime/esbuild-wasm-bytes.d.ts +25 -23
  85. package/dist/runtime/esbuild-wasm-bytes.d.ts.map +1 -1
  86. package/dist/runtime/esbuild-wasm-bytes.js +30 -25
  87. package/dist/runtime/facet-loader-host.d.ts +5 -4
  88. package/dist/runtime/facet-loader-host.d.ts.map +1 -1
  89. package/dist/runtime/facet-loader-host.js +5 -4
  90. package/dist/runtime/node-runner.d.ts +2 -0
  91. package/dist/runtime/node-runner.d.ts.map +1 -1
  92. package/dist/runtime/node-runner.js +1 -0
  93. package/dist/runtime/node-shims-artifact.d.ts +8 -1
  94. package/dist/runtime/node-shims-artifact.d.ts.map +1 -1
  95. package/dist/runtime/node-shims-artifact.js +32 -4
  96. package/dist/runtime/node-shims.d.ts.map +1 -1
  97. package/dist/runtime/node-shims.js +145 -109
  98. package/dist/runtime/opencode-facet-runner.d.ts.map +1 -1
  99. package/dist/runtime/opencode-facet-runner.js +6 -2
  100. package/dist/runtime/oxc-wasm-bytes.d.ts +19 -0
  101. package/dist/runtime/oxc-wasm-bytes.d.ts.map +1 -0
  102. package/dist/runtime/oxc-wasm-bytes.js +39 -0
  103. package/dist/runtime/package-manager.js +1 -1
  104. package/dist/runtime/process-logs-api.d.ts.map +1 -1
  105. package/dist/runtime/process-logs-api.js +2 -0
  106. package/dist/runtime/project-fs.d.ts +8 -1
  107. package/dist/runtime/project-fs.d.ts.map +1 -1
  108. package/dist/runtime/project-fs.js +15 -1
  109. package/dist/runtime/python-repl.d.ts +40 -1
  110. package/dist/runtime/python-repl.d.ts.map +1 -1
  111. package/dist/runtime/python-repl.js +19 -11
  112. package/dist/runtime/ruby-repl.d.ts +38 -0
  113. package/dist/runtime/ruby-repl.d.ts.map +1 -1
  114. package/dist/runtime/ruby-repl.js +24 -5
  115. package/dist/runtime/ruby-resident.d.ts.map +1 -1
  116. package/dist/runtime/ruby-resident.js +2 -0
  117. package/dist/session/nimbus-session.d.ts +13 -8
  118. package/dist/session/nimbus-session.d.ts.map +1 -1
  119. package/dist/session/nimbus-session.js +11 -5
  120. package/dist/session/programmatic.d.ts +25 -30
  121. package/dist/session/programmatic.d.ts.map +1 -1
  122. package/dist/session/programmatic.js +65 -93
  123. package/dist/session/routes.d.ts.map +1 -1
  124. package/dist/session/routes.js +23 -7
  125. package/dist/session/rpc.d.ts +16 -6
  126. package/dist/session/rpc.d.ts.map +1 -1
  127. package/dist/session/rpc.js +53 -13
  128. package/dist/session/start-real-vite.d.ts +24 -9
  129. package/dist/session/start-real-vite.d.ts.map +1 -1
  130. package/dist/session/start-real-vite.js +40 -4
  131. package/dist/session/supervisor-op.d.ts +14 -0
  132. package/dist/session/supervisor-op.d.ts.map +1 -1
  133. package/dist/session/supervisor-op.js +49 -0
  134. package/dist/session/supervisor-rpc.d.ts +11 -0
  135. package/dist/session/supervisor-rpc.d.ts.map +1 -1
  136. package/dist/session/supervisor-rpc.js +18 -0
  137. package/dist/session/vite-command.d.ts.map +1 -1
  138. package/dist/session/vite-command.js +23 -19
  139. package/dist/session/ws-relay.d.ts.map +1 -1
  140. package/dist/session/ws-relay.js +13 -1
  141. package/dist/shell/npm-bin-entrypoints.d.ts +3 -1
  142. package/dist/shell/npm-bin-entrypoints.d.ts.map +1 -1
  143. package/dist/shell/npm-bin-entrypoints.js +53 -25
  144. package/dist/vfs/facet-resident-store.d.ts.map +1 -1
  145. package/dist/vfs/facet-resident-store.js +11 -5
  146. package/dist/wrangler/nimbus-wrangler.d.ts +8 -0
  147. package/dist/wrangler/nimbus-wrangler.d.ts.map +1 -1
  148. package/dist/wrangler/nimbus-wrangler.js +54 -57
  149. package/package.json +7 -5
  150. package/public/_assets/esbuild-0.24.2.wasm +0 -0
  151. package/public/_assets/napi-wasm/loader/{99efae93dd1dcc2b → ab7e57fe9e8750c2}/napi-wasm-loader.mjs +4 -4
  152. package/public/_assets/napi-wasm/loader/{99efae93dd1dcc2b → ab7e57fe9e8750c2}/provenance.json +2 -2
  153. package/public/_assets/oxc/nimbus-oxc-1aa8c4c7057c6c28.provenance.json +72 -0
  154. package/public/_assets/oxc/nimbus-oxc-1aa8c4c7057c6c28.wasm +0 -0
  155. package/public/_assets/runtime/esbuild-cli-f13e6a112b03ac07.js +1143 -0
  156. package/public/_assets/runtime/js-interpreter-3c37c48024f0f651.js +23 -0
  157. package/public/_assets/runtime/js-interpreter-ops-2f4dfec6798e70fc.js +290 -0
  158. package/public/_assets/runtime/js-interpreter-primordials-e620a61b7e9800fa.js +1 -0
  159. package/public/_assets/runtime/{node-shims-f92f16c7d7c532e9.js → node-shims-e3adc4576da31e6e.js} +651 -103
  160. package/public/_assets/runtime/{esbuild-cli-b7aecffd4c6a36fe.js → oxc-facet-fd86fefcdf16bf9c.js} +217 -1047
  161. package/public/_assets/runtime/{resident-store-92386265e8b306dc.js → resident-store-009f39539ac989fc.js} +11 -5
  162. package/public/_assets/runtime/rolldown-facet-09983434e2dbe93e.js +15165 -0
  163. package/public/_assets/runtime/{vfs-write-ledger-d33ee0034446c3e0.js → vfs-write-ledger-9e9594591425a9b8.js} +4 -1
  164. package/scripts/acorn-primordials.mjs +637 -0
  165. package/scripts/bundle-esbuild-wasm.mjs +42 -50
  166. package/scripts/bundle-facet-workers.mjs +247 -18
  167. package/scripts/bundle-node-shims.mjs +29 -2
  168. package/scripts/bundle-oxc-wasm.mjs +105 -0
  169. package/scripts/interpreter-bundle.mjs +105 -0
  170. package/scripts/napi-wasm/build.mjs +4 -1
  171. package/scripts/napi-wasm/loader/napi-wasm-loader.ts +38 -3
  172. package/scripts/oxc-wasm/Cargo.lock +1246 -0
  173. package/scripts/oxc-wasm/Cargo.toml +30 -0
  174. package/scripts/oxc-wasm/build.mjs +249 -0
  175. package/scripts/oxc-wasm/examples/memory.rs +51 -0
  176. package/scripts/oxc-wasm/examples/transform.rs +20 -0
  177. package/scripts/oxc-wasm/inputs.mjs +32 -0
  178. package/scripts/oxc-wasm/rust-toolchain.toml +5 -0
  179. package/scripts/oxc-wasm/src/abi.rs +136 -0
  180. package/scripts/oxc-wasm/src/diagnostics.rs +49 -0
  181. package/scripts/oxc-wasm/src/helpers.rs +139 -0
  182. package/scripts/oxc-wasm/src/lib.rs +247 -0
  183. package/scripts/oxc-wasm/src/module.rs +978 -0
  184. package/scripts/oxc-wasm/src/names.rs +175 -0
  185. package/scripts/oxc-wasm/src/options.rs +154 -0
  186. package/scripts/parser-audit.mjs +492 -0
  187. package/scripts/rolldown-facet/entry.mjs +21 -0
  188. package/scripts/rolldown-facet/shims.mjs +64 -0
  189. package/dist/facets/esbuild-bundle-pool.d.ts +0 -43
  190. package/dist/facets/esbuild-bundle-pool.d.ts.map +0 -1
  191. package/dist/facets/esbuild-bundle-pool.js +0 -80
  192. package/dist/loaders/pre-bundle-preamble.d.ts +0 -44
  193. package/dist/loaders/pre-bundle-preamble.d.ts.map +0 -1
  194. package/dist/loaders/pre-bundle-preamble.js +0 -116
  195. package/dist/runtime/host-wasm.d.ts +0 -8
  196. package/dist/runtime/host-wasm.d.ts.map +0 -1
  197. package/dist/runtime/host-wasm.js +0 -33
  198. /package/public/_assets/napi-wasm/loader/{99efae93dd1dcc2b → ab7e57fe9e8750c2}/wasi-trampoline.wasm +0 -0
@@ -43,11 +43,12 @@ import { generateSqliteShimCode } from './sqlite-shim.js';
43
43
  import { DECODE_JAVASCRIPT_STRING_LITERAL_SOURCE } from './javascript-string-literal.js';
44
44
  import { generateUndiciShimCode } from '@nimbus-sh/core/runtime/undici-shim.js';
45
45
  import { getExportsResolverJS } from '@nimbus-sh/core/_shared/exports-resolver.js';
46
- import { ESM_RESOLVER_PREAMBLE } from '../loaders/generated-workers.js';
46
+ import { ESM_RESOLVER_PREAMBLE, HTTP2_MODULE_PREAMBLE } from '../loaders/generated-workers.js';
47
47
  import { getTypescriptSpecifiersJS } from '@nimbus-sh/core/_shared/typescript-specifiers.js';
48
48
  import { NIMBUS_AI_CREDENTIAL_HEADERS, NIMBUS_AI_TOKEN_ENV } from '@nimbus-sh/core/_shared/ai-egress.js';
49
49
  import { MAX_RPC_SAFE_PAYLOAD_BYTES } from '@nimbus-sh/platform/limits.js';
50
50
  import { ERRNO_DESCRIPTION } from '@nimbus-sh/core/vfs/vfs-error.js';
51
+ import { DIRENT_TYPES } from '@nimbus-sh/core/vfs/dirent-type.js';
51
52
  import { STDIN_SYNC_READ_BYTES } from '@nimbus-sh/core/runtime/stdin-read.js';
52
53
  import { FACET_PROVIDED_PACKAGES, FS_READ_BATCH_PATH_LIMIT, FS_READ_BATCH_REQUEST_BYTES, NIMBUS_AI_GATEWAY_PORT, NODE_VERSION, NODE_VERSIONS, VFS_CAPACITY, } from '@nimbus-sh/core/constants.js';
53
54
  import { PACKAGE_ABI_POLICY } from '../facets/wasm-swap-registry.js';
@@ -973,7 +974,7 @@ const __fsMod = (() => {
973
974
  const real = __nsResolve(own && own.alias !== undefined ? own.alias : k, true);
974
975
  if (real && real !== "ELOOP") {
975
976
  for (const child of __nsChildren(real.path)) {
976
- names.set(child.name, child.kind === 1 ? "directory" : child.kind === 2 ? "symlink" : "file");
977
+ names.set(child.name, child.kind === 1 ? "directory" : child.kind === 2 ? "symlink" : _direntTypeOfMode(child.mode, "file"));
977
978
  }
978
979
  }
979
980
  }
@@ -1048,8 +1049,9 @@ const __fsMod = (() => {
1048
1049
  function _noteCreation(k) {
1049
1050
  if (_createdHere.has(k)) return;
1050
1051
  const absPath = "/" + k;
1051
- // Known absent: the namespace names everything this credential can see.
1052
- if (_statLadder(absPath) !== undefined) return;
1052
+ // Known absent: the namespace names everything this credential can see,
1053
+ // except on a mount where the launch did not list it, which is unknown.
1054
+ if (_statLadder(absPath) !== undefined || _nsUnlisted(absPath, true, false) !== null) return;
1053
1055
  _createdHere.add(k);
1054
1056
  }
1055
1057
  function _forgetCreation(k) {
@@ -2685,24 +2687,37 @@ const __fsMod = (() => {
2685
2687
  return stat;
2686
2688
  }
2687
2689
 
2690
+ // Each exact dirent type's S_IFMT bits and Node predicate (core's vfs/dirent-type.ts).
2691
+ const _direntTypes = ${JSON.stringify(DIRENT_TYPES)};
2692
+ /** The dirent type a mode's format bits name, or \`fallback\` where they name none. */
2693
+ function _direntTypeOfMode(mode, fallback) {
2694
+ const format = Number(mode) & 0o170000;
2695
+ for (const type in _direntTypes) if (_direntTypes[type].format === format) return type;
2696
+ return fallback;
2697
+ }
2698
+ /** The dirent type an lstat says, for an entry the listing could not type ('unknown'). */
2699
+ function _direntTypeOfStats(st) {
2700
+ return _direntTypeOfMode(st.mode, st.isDirectory() ? "directory" : st.isSymbolicLink() ? "symlink" : "file");
2701
+ }
2702
+
2688
2703
  // The one Dirent shape: readdir({ withFileTypes }) sync and async, and
2689
- // every Dir.read(). \`parentPath\` is Node's field; \`path\` its deprecated
2704
+ // every Dir.read(), for an entry whose type is known (an 'unknown' one is
2705
+ // lstat'ed first). \`parentPath\` is Node's field; \`path\` its deprecated
2690
2706
  // alias that older callers still read.
2691
2707
  class __Dirent {
2692
2708
  constructor(name, type, parentPath) {
2693
2709
  this.name = name;
2694
2710
  this.parentPath = parentPath === undefined ? "" : String(parentPath);
2695
2711
  this.path = this.parentPath;
2696
- this._isDir = type === "directory" || type === "dir";
2697
- this._isSymlink = type === "symlink";
2712
+ this._holds = _direntTypes[type === "dir" ? "directory" : type]?.node;
2698
2713
  }
2699
- isFile() { return !this._isDir && !this._isSymlink; }
2700
- isDirectory() { return this._isDir; }
2701
- isSymbolicLink() { return this._isSymlink; }
2702
- isBlockDevice() { return false; }
2703
- isCharacterDevice() { return false; }
2704
- isFIFO() { return false; }
2705
- isSocket() { return false; }
2714
+ isFile() { return this._holds === "isFile"; }
2715
+ isDirectory() { return this._holds === "isDirectory"; }
2716
+ isSymbolicLink() { return this._holds === "isSymbolicLink"; }
2717
+ isBlockDevice() { return this._holds === "isBlockDevice"; }
2718
+ isCharacterDevice() { return this._holds === "isCharacterDevice"; }
2719
+ isFIFO() { return this._holds === "isFIFO"; }
2720
+ isSocket() { return this._holds === "isSocket"; }
2706
2721
  }
2707
2722
  function _direntObject(name, type, parentPath) { return new __Dirent(name, type, parentPath); }
2708
2723
 
@@ -3105,8 +3120,11 @@ const __fsMod = (() => {
3105
3120
  // listing does not. So it is asked for, never assumed (one lstat per
3106
3121
  // child directory, concurrently).
3107
3122
  if (opts?.withFileTypes) {
3123
+ const base = absPath === "/" ? "" : absPath;
3124
+ const types = await Promise.all(entries.map(async (entry) =>
3125
+ entry.type === "unknown" ? _direntTypeOfStats(await _lstatAsync(base + "/" + entry.name)) : entry.type));
3108
3126
  return entries
3109
- .map((entry) => _direntObject(entry.name, entry.type, absPath))
3127
+ .map((entry, i) => _direntObject(entry.name, types[i], absPath))
3110
3128
  .sort((a, b) => a.name.localeCompare(b.name));
3111
3129
  }
3112
3130
  return entries.map((entry) => entry.name).sort();
@@ -3152,8 +3170,12 @@ const __fsMod = (() => {
3152
3170
 
3153
3171
  async function _writeFileAsync(p, data, opts) {
3154
3172
  const absPath = _resolveFollow(p, "open");
3155
- writeFileSync(p, data, opts);
3156
3173
  const supervisor = _supervisor();
3174
+ // A target this view cannot judge (on a mount, where the launch did not
3175
+ // list it) is the authority's to answer for, as the async rename's
3176
+ // destination is: parked and written back like any other write, and
3177
+ // refused (and the parked bytes dropped) if the authority refuses it.
3178
+ _parkWholeWrite(p, data, supervisor && typeof supervisor.writeFile === "function");
3157
3179
  if (supervisor && typeof supervisor.writeFile === "function") {
3158
3180
  await _announceLocalDirs(absPath, supervisor);
3159
3181
  // The revision comes back so the ledger can stamp the cell: an async
@@ -3574,8 +3596,17 @@ const __fsMod = (() => {
3574
3596
  // (the hot path for source code / package.json / user JS).
3575
3597
  // Anything else is stringified (Node's behaviour for e.g. numbers).
3576
3598
  function writeFileSync(p, data, opts) {
3599
+ _parkWholeWrite(p, data, false);
3600
+ }
3601
+
3602
+ /**
3603
+ * A whole-file write's local effect: the bytes parked for write-back.
3604
+ * \`live\`: the async form, whose write-back the authority answers for a
3605
+ * target this view cannot judge (_ensureWritable).
3606
+ */
3607
+ function _parkWholeWrite(p, data, live) {
3577
3608
  const absPath = _resolveFollow(p, "open");
3578
- _ensureWritable(absPath, "open", p);
3609
+ _ensureWritable(absPath, "open", p, live);
3579
3610
  const k = _strip(absPath);
3580
3611
  let cell;
3581
3612
  if (data instanceof Uint8Array) cell = data;
@@ -6219,31 +6250,20 @@ const __cryptoMod = (() => {
6219
6250
  // execution does not. Documented in W3 retro for W3.5 follow-up
6220
6251
  // (a parser-based vm fallback, or pre-bundle vm-using scripts at
6221
6252
  // install time).
6222
- // ── Runtime code: the async and generator Function constructors ──
6253
+ // ── Runtime code: the Function constructors ──
6223
6254
  //
6224
6255
  // A Worker generates code from strings only while its modules evaluate: at
6225
6256
  // request time — where every program runs — \`new Function(...)\` and its async
6226
6257
  // and generator siblings throw EvalError "Code generation from strings
6227
- // disallowed for this context". The async and generator constructors here ask
6228
- // the native one first and, refused that way, hand the arguments to the
6229
- // launch's runtime-code service (core/_shared/commonjs-cell.ts, RUNTIME CODE),
6230
- // which answers from this launch's module map or records the text for the next
6231
- // launch of the command and throws EvalError code ERR_NIMBUS_CODE_NEXT_LAUNCH.
6232
- // That is the constructor a module runner evaluates with (Vite's SSR runner:
6233
- // \`new AsyncFunction(...)\`), reached as each kind's \`prototype.constructor\`,
6234
- // which is how \`(async function () {}).constructor\` finds it. A facet without
6235
- // the service (opencode's) keeps the native refusal.
6236
- //
6237
- // The plain \`Function\` constructor is routed differently, on evidence: code
6238
- // probes it once and keeps the answer. TypeBox's CanEvaluate (pi 0.87.1) tries
6239
- // \`Function("null")\`, remembers whether it worked, and then compiles every
6240
- // schema check with \`Function\`; staging every text, the next launch staged the
6241
- // probe's text but not the checks' — the probe said yes, the first check threw,
6242
- // and pi's TUI died. So it answers only text an earlier launch staged, keeps
6243
- // the native refusal otherwise, and stages a refused text only when a failed
6244
- // launch is attributable to it (the service's plainFunction, noteFailure and
6245
- // stageFailedLaunch): a probe answers the same in every launch, while depd's
6246
- // wrapper (express 4) and ajv's validators (serve) run from the next launch on.
6258
+ // disallowed for this context". Each constructor here asks the native one
6259
+ // first and, refused that way, hands the arguments to the launch's
6260
+ // runtime-code service (core/_shared/commonjs-cell.ts, RUNTIME CODE), which
6261
+ // answers from this launch's module map when an earlier launch staged the
6262
+ // text, and otherwise records it for the next launch and runs it in the
6263
+ // interpreter. That is the constructor a module runner evaluates with
6264
+ // (Vite's SSR runner: \`new AsyncFunction(...)\`), reached as each kind's
6265
+ // \`prototype.constructor\`, which is how \`(async function () {}).constructor\`
6266
+ // finds it. A facet without the service (opencode's) keeps the native refusal.
6247
6267
  function __nimbusIsCodegenRefusal(e) {
6248
6268
  return e instanceof EvalError && /Code generation from strings disallowed/.test(String(e.message));
6249
6269
  }
@@ -6318,15 +6338,20 @@ const __nimbusDecodeStringLiteral = ${DECODE_JAVASCRIPT_STRING_LITERAL_SOURCE};
6318
6338
  if (Native.__nimbusNative) continue;
6319
6339
  const routed = function (...args) {
6320
6340
  try {
6321
- return Reflect.apply(Native, undefined, args);
6341
+ return new.target === undefined ? Reflect.apply(Native, undefined, args) : Reflect.construct(Native, args, new.target);
6322
6342
  } catch (e) {
6323
6343
  const service = globalThis.__nimbusRuntimeCode;
6324
6344
  if (!__nimbusIsCodegenRefusal(e) || !service) throw e;
6325
6345
  const params = args.slice(0, -1).map(String);
6326
6346
  const body = args.length > 0 ? String(args[args.length - 1]) : "";
6327
- if (kind === "function") return service.plainFunction(params, body, e);
6328
6347
  try {
6329
- return service.compileFunction(kind, params, body);
6348
+ const fn = service.compileFunction(kind, params, body);
6349
+ // A subclass's \`new\` (\`class F extends Function\`) makes an instance of the subclass.
6350
+ if (new.target !== undefined && new.target !== routed) {
6351
+ const proto = new.target.prototype;
6352
+ if (proto !== null && (typeof proto === "object" || typeof proto === "function")) Object.setPrototypeOf(fn, proto);
6353
+ }
6354
+ return fn;
6330
6355
  } catch (refusal) {
6331
6356
  const importAt = params.indexOf("__vite_ssr_import__");
6332
6357
  if (kind !== "async" || importAt < 0 || !refusal || refusal.code !== "ERR_NIMBUS_CODE_NEXT_LAUNCH") throw refusal;
@@ -6359,6 +6384,11 @@ const __nimbusDecodeStringLiteral = ${DECODE_JAVASCRIPT_STRING_LITERAL_SOURCE};
6359
6384
 
6360
6385
  const __vmMod = (() => {
6361
6386
  const real = (typeof __real_vm !== 'undefined') ? (__real_vm.default ?? __real_vm) : null;
6387
+ // What a script's function is called with, as the launch starts: the
6388
+ // program may later replace Reflect.apply or the globalThis property, and
6389
+ // native vm consults neither.
6390
+ const apply = Reflect.apply;
6391
+ const scriptThis = globalThis;
6362
6392
  function honestError(method, originalErr) {
6363
6393
  const e = new Error(
6364
6394
  'vm.' + method + ': workerd does not implement runtime eval. ' +
@@ -6395,12 +6425,16 @@ const __vmMod = (() => {
6395
6425
  isContext: real?.isContext ?? ((o) => !!o),
6396
6426
  runInContext: wrapRuntimeEval('runInContext'),
6397
6427
  runInNewContext: wrapRuntimeEval('runInNewContext'),
6398
- // jiti evaluates a parenthesized (async) CommonJS wrapper expression.
6399
- // Stage that expression as a zero-argument function returning its value;
6400
- // the wrapper itself executes only when the caller invokes it. This is
6401
- // not a vm context or a global-script evaluator: declarations/completion
6402
- // values spanning statements, execution deadlines and context mutation
6403
- // have no equivalent here and remain unsupported.
6428
+ // jiti evaluates a parenthesized (async) CommonJS wrapper expression
6429
+ // statement, \`(function (exports, require, ...) { ... });\`. The service
6430
+ // stages a script that is one expression as a zero-argument function
6431
+ // returning its value (the script's completion value); the wrapper
6432
+ // itself executes only when the caller invokes it. The function is
6433
+ // called with the global object as \`this\`, which is a script's
6434
+ // \`this\` at its top level, strict or not. This is not a vm
6435
+ // context or a global-script evaluator: declarations/completion values
6436
+ // spanning statements, execution deadlines and context mutation have no
6437
+ // equivalent here and remain unsupported.
6404
6438
  runInThisContext: (code, options = {}) => {
6405
6439
  try { return wrapRuntimeEval('runInThisContext')(code, options); }
6406
6440
  catch (e) {
@@ -6408,7 +6442,7 @@ const __vmMod = (() => {
6408
6442
  if (e?.code !== 'ERR_VM_DYNAMIC_EVAL_DISALLOWED' || !service
6409
6443
  || options?.timeout !== undefined || options?.breakOnSigint
6410
6444
  || options?.importModuleDynamically || options?.cachedData) throw e;
6411
- return service.compileFunction("function", [], "return (\\n" + String(code) + "\\n);")();
6445
+ return apply(service.compileExpression(String(code)), scriptThis, []);
6412
6446
  }
6413
6447
  },
6414
6448
  // A function of \`params\` and \`code\` is what the Function constructor
@@ -6434,45 +6468,27 @@ const __vmMod = (() => {
6434
6468
  })();
6435
6469
 
6436
6470
  // ═══════════════════════════════════════════════════════════════════════
6437
- // ── http2 module (W3: stub — non-throwing load, honest connect err) ─
6471
+ // ── http2 module: Node's exports, no HTTP/2 transport ──────────────
6438
6472
  // ═══════════════════════════════════════════════════════════════════════
6439
6473
  //
6440
6474
  // axios's dist/node code does \`var http2 = require('http2')\` at top
6441
- // level, unconditionally. Without this stub the require fails →
6442
- // axios fails to load. The actual HTTP/2 transport is only invoked
6443
- // when user opts in (\`httpVersion: 2\`); otherwise this shim is dormant.
6444
- const __http2Mod = (() => {
6445
- function _err(op) {
6446
- const e = new Error('http2.' + op + ': not implemented in Nimbus. Use fetch() or HTTP/1.1.');
6447
- e.code = 'ERR_HTTP2_NOT_SUPPORTED';
6448
- return e;
6449
- }
6450
- class Http2Session extends __eventsMod {
6451
- constructor() { super(); this.destroyed = false; }
6452
- request() { throw _err('request'); }
6453
- close() { this.destroyed = true; this.emit('close'); }
6454
- destroy(err) { this.destroyed = true; if (err) this.emit('error', err); this.emit('close'); }
6455
- settings() {}
6456
- }
6457
- function connect(/* authority, opts, listener */) {
6458
- const session = new Http2Session();
6459
- queueMicrotask(() => session.emit('error', _err('connect')));
6460
- return session;
6461
- }
6462
- function createServer() { throw _err('createServer'); }
6463
- return {
6464
- connect, createServer,
6465
- createSecureServer: createServer,
6466
- Http2Session,
6467
- constants: {
6468
- NGHTTP2_NO_ERROR: 0, NGHTTP2_PROTOCOL_ERROR: 1,
6469
- HTTP2_HEADER_PATH: ':path', HTTP2_HEADER_METHOD: ':method',
6470
- HTTP2_HEADER_STATUS: ':status', HTTP2_HEADER_AUTHORITY: ':authority',
6471
- HTTP2_HEADER_SCHEME: ':scheme',
6472
- },
6473
- sensitiveHeaders: Symbol('nodejs.http2.sensitiveHeaders'),
6474
- };
6475
- })();
6475
+ // level, unconditionally, and Astro's dev server asks
6476
+ // \`res instanceof Http2ServerResponse\` of every response: the module
6477
+ // loads with every name Node's has, and only opening HTTP/2 refuses.
6478
+ // core/_shared/http2-module.ts, compiled once by
6479
+ // scripts/bundle-facet-workers.mjs, declares createHttp2Module; the
6480
+ // substrate's node-compat imports the same function.
6481
+ ${HTTP2_MODULE_PREAMBLE}
6482
+ const __http2Mod = createHttp2Module({
6483
+ EventEmitter: __eventsMod,
6484
+ Readable: __streamMod.Readable,
6485
+ Stream: __streamMod,
6486
+ Buffer: __BufferMod,
6487
+ emitWarning: (message) => {
6488
+ const proc = globalThis.process;
6489
+ if (proc && typeof proc.emitWarning === "function") proc.emitWarning(message);
6490
+ },
6491
+ });
6476
6492
 
6477
6493
  // ═══════════════════════════════════════════════════════════════════════
6478
6494
  // ── repl module (W3: forward to workerd) ───────────────────────────
@@ -8145,7 +8161,6 @@ function __nimbusFailUnhandledAsync(error, kind) {
8145
8161
  __nimbusReportProcessExit(error.code, "");
8146
8162
  return;
8147
8163
  }
8148
- if (globalThis.__nimbusRuntimeCode) globalThis.__nimbusRuntimeCode.noteFailure(error);
8149
8164
  const label = kind === "rejection"
8150
8165
  ? "Unhandled promise rejection: "
8151
8166
  : "Uncaught exception: ";
@@ -9122,6 +9137,9 @@ builtins.undici = __undiciMod;
9122
9137
  // ── require() — full Node.js module resolution ─────────────────────
9123
9138
  // ═══════════════════════════════════════════════════════════════════════
9124
9139
  const __moduleCache = new Map();
9140
+ // A module cell's evaluation when it completes later (top-level await), by
9141
+ // its evaluation key: what an import of it waits for.
9142
+ const __moduleEvaluations = new Map();
9125
9143
  // package → why the package ABI policy says it cannot run here (wasm-swap-registry.ts).
9126
9144
  const __nimbusAbiAdvisories = new Map(${ABI_ADVISORIES_LITERAL});
9127
9145
 
@@ -9507,6 +9525,22 @@ function __makeLoadingExports(mod) {
9507
9525
  * Nothing here compiles source: request-time code generation is not
9508
9526
  * available in a Worker, so a file the launch did not map cannot run.
9509
9527
  */
9528
+ // import.meta of the module file at \`filename\`, evaluated as \`url\`: an
9529
+ // entry script's or a loaded module's. It lives on the module, not in source
9530
+ // text, so the five CommonJS arguments stay as they are, and
9531
+ // import.meta.resolve keeps its parent even when extracted and called later.
9532
+ // The registry's own import.meta cannot serve: its module URLs all live
9533
+ // under file:///bundle/, never at the file's own path. dirname and filename
9534
+ // name the file, without the URL's query or fragment.
9535
+ function __nimbusFileImportMeta(filename, url = builtins.url.pathToFileURL(filename).href) {
9536
+ return Object.assign(Object.create(null), {
9537
+ dirname: __pathMod.dirname(filename),
9538
+ filename,
9539
+ url,
9540
+ resolve: (specifier) => globalThis.__nimbusImportMetaResolve(specifier, url),
9541
+ });
9542
+ }
9543
+
9510
9544
  function __loadModule(resolvedPath, evaluationKey = resolvedPath) {
9511
9545
  if (globalThis.__nimbusProfileStaged) globalThis.__nimbusProfileStaged.delete(String(resolvedPath).replace(/^\\/+/, ""));
9512
9546
  if (__moduleCache.has(evaluationKey)) return __moduleCache.get(evaluationKey);
@@ -9544,19 +9578,7 @@ function __loadModule(resolvedPath, evaluationKey = resolvedPath) {
9544
9578
  globalThis.__currentModulePath = resolvedPath;
9545
9579
  const moduleUrl = evaluationKey.startsWith("file:")
9546
9580
  ? evaluationKey : builtins.url.pathToFileURL("/" + resolvedPath).href;
9547
- // Evaluation metadata lives on the module, not in source text. Keeping
9548
- // it here preserves the five CommonJS arguments and captures the parent
9549
- // even when import.meta.resolve is extracted and called later. The
9550
- // registry's own import.meta cannot serve: its module URLs all live under
9551
- // file:///bundle/, never at the file's own path.
9552
- // dirname and filename name the file, without the URL's query or fragment.
9553
- const importMeta = Object.assign(Object.create(null), {
9554
- dirname: __pathMod.dirname("/" + resolvedPath),
9555
- filename: "/" + resolvedPath,
9556
- url: moduleUrl,
9557
- resolve: (specifier) => globalThis.__nimbusImportMetaResolve(specifier, moduleUrl),
9558
- });
9559
- Object.defineProperty(mod, "__nimbusImportMeta", { value: importMeta });
9581
+ Object.defineProperty(mod, "__nimbusImportMeta", { value: __nimbusFileImportMeta("/" + resolvedPath, moduleUrl) });
9560
9582
  try {
9561
9583
  const normalizedPath = resolvedPath.replace(/^\\/+/, "");
9562
9584
  let cell = __nimbusModuleCell(normalizedPath);
@@ -9574,7 +9596,11 @@ function __loadModule(resolvedPath, evaluationKey = resolvedPath) {
9574
9596
  cell = __nimbusRuntimeModule(normalizedPath, text);
9575
9597
  globalThis.__nimbusModuleMisses.delete(normalizedPath);
9576
9598
  }
9577
- cell(mod.exports, scopedRequire, mod, "/" + resolvedPath, "/" + modDir);
9599
+ const evaluation = cell(mod.exports, scopedRequire, mod, "/" + resolvedPath, "/" + modDir);
9600
+ // A module with top-level await completes later. require() returns its
9601
+ // exports now (static imports lowered to require cannot wait); import()
9602
+ // waits for it (__esmLoad).
9603
+ if (evaluation && typeof evaluation.then === "function") __moduleEvaluations.set(evaluationKey, evaluation);
9578
9604
  } catch (e) {
9579
9605
  __moduleCache.delete(evaluationKey);
9580
9606
  if (e && typeof e === "object" && !e.__nimbusModulePath) {
@@ -9766,21 +9792,31 @@ function __esmLoad(resolution) {
9766
9792
  // Canonical queryless ESM shares evaluation with require() and static
9767
9793
  // imports lowered to require(). Queries/fragments are distinct jobs.
9768
9794
  const variant = esm && (resolution.url.includes("?") || resolution.url.includes("#"));
9769
- const exports = __loadModule(key, variant ? resolution.url : key);
9770
- if (resolution.format === "json") {
9771
- ns = __esmNamespaceOf(["default"], () => exports);
9772
- } else if (esm) {
9773
- // The ESM→CJS transform's exports: the module's own names, live.
9774
- const names = exports && typeof exports === "object" ? Object.keys(exports).filter((name) => name !== "__esModule") : [];
9775
- ns = __esmNamespaceOf(names, (name) => exports[name]);
9776
- } else {
9795
+ const evaluationKey = variant ? resolution.url : key;
9796
+ const exports = __loadModule(key, evaluationKey);
9797
+ const namespace = () => {
9798
+ if (resolution.format === "json") return __esmNamespaceOf(["default"], () => exports);
9799
+ if (esm) {
9800
+ // The ESM→CJS transform's exports: the module's own names, live.
9801
+ const names = exports && typeof exports === "object" ? Object.keys(exports).filter((name) => name !== "__esModule") : [];
9802
+ return __esmNamespaceOf(names, (name) => exports[name]);
9803
+ }
9777
9804
  // CommonJS: module.exports is the default, its names the named exports.
9778
9805
  const mod = exports;
9779
9806
  const names = new Set(mod && (typeof mod === "object" || typeof mod === "function") ? Object.keys(mod) : []);
9780
9807
  names.delete("default");
9781
9808
  names.add("default");
9782
- ns = __esmNamespaceOf(names, (name) => name === "default" ? mod : mod[name]);
9783
- }
9809
+ return __esmNamespaceOf(names, (name) => name === "default" ? mod : mod[name]);
9810
+ };
9811
+ // A module with top-level await: the import resolves once its evaluation
9812
+ // completes, and rejects with what it throws.
9813
+ const evaluation = __moduleEvaluations.get(evaluationKey);
9814
+ if (evaluation !== undefined) {
9815
+ const pending = evaluation.then(namespace, (error) => { __esmNamespaces.delete(resolution.url); throw error; });
9816
+ __esmNamespaces.set(resolution.url, pending);
9817
+ return pending;
9818
+ }
9819
+ ns = namespace();
9784
9820
  }
9785
9821
  __esmNamespaces.set(resolution.url, ns);
9786
9822
  return ns;
@@ -1 +1 @@
1
- {"version":3,"file":"opencode-facet-runner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,MAAM,CAAA;KAAE,CAAC;IAC7E,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,mFAAmF;IACnF,OAAO,EAAE,gBAAgB,CAAC;IAC1B;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;;;;;;;;;OAeG;IACH,IAAI,EAAE,kBAAkB,CAAC;CAC1B;AAED,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEnE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAsBpC,CAAC;AAqBF,2EAA2E;AAC3E,eAAO,MAAM,wBAAwB,4BAA4B,CAAC;AAElE,2DAA2D;AAC3D,eAAO,MAAM,wBAAwB,oBAAoB,CAAC;AAE1D;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAevC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAmOjC,CAAC;AA2BF;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,qBAAqB,GAAG,MAAM,CA0uB9E"}
@@ -37,6 +37,7 @@
37
37
  */
38
38
  import { generateSqliteFacetPreamble } from './sqlite-shim.js';
39
39
  import { VFS_CURSOR_SEED_SOURCE } from '@nimbus-sh/core/_shared/facet-vfs-cursor.js';
40
+ import { SUPERVISOR_ANSWERING_SRC } from '@nimbus-sh/core/runtime/supervisor-answering.generated.js';
40
41
  import { getRealNodeSharedImportsCode } from '@nimbus-sh/core/_shared/real-node-imports.js';
41
42
  import { ONE_SHOT_STORE_MEMORY_BYTES } from '../vfs/facet-resident-limits.js';
42
43
  import { OPENTUI_BACKEND_FACET_SRC, OPENTUI_BACKEND_GLOBAL, OPENTUI_WASM_MODULE_NAME, generateOpenTUIBackendBootCode, } from './opentui-facet-backend.js';
@@ -688,6 +689,9 @@ let stdout = "";
688
689
  let stderr = "";
689
690
  let exitCode = 0;
690
691
  let __supervisor = null;
692
+ // The SUPERVISOR binding's filesystem calls answer a refusal as a value
693
+ // (core vfs-supervisor.ts answeringSupervisor).
694
+ ${SUPERVISOR_ANSWERING_SRC}
691
695
  // The process's view of the filesystem: the same store and namespace a node
692
696
  // process boots on (vfs/facet-resident-store.ts), in this facet's heap and
693
697
  // bounded there. An opencode facet has no storage allowance of the session's
@@ -1198,7 +1202,7 @@ async function __ocBootStore() {
1198
1202
 
1199
1203
  export class NimbusProcess extends __NimbusDurableObject {
1200
1204
  async startProcess() {
1201
- __supervisor = (this.env && this.env.SUPERVISOR) || null;
1205
+ __supervisor = this.env && this.env.SUPERVISOR ? globalThis.__nimbusAnsweringSupervisor(this.env.SUPERVISOR) : null;
1202
1206
  const __bootFailure = await __ocBootStore();
1203
1207
  if (__bootFailure) throw new Error(__bootFailure);
1204
1208
  // Run the resident lifecycle and hold THIS RPC open until it exits — the
@@ -1282,7 +1286,7 @@ async function __ocRunServe() {
1282
1286
  }
1283
1287
 
1284
1288
  async function __ocOneShotFetch(request, workerEnv) {
1285
- __supervisor = (workerEnv && workerEnv.SUPERVISOR) || null;
1289
+ __supervisor = workerEnv && workerEnv.SUPERVISOR ? globalThis.__nimbusAnsweringSupervisor(workerEnv.SUPERVISOR) : null;
1286
1290
  const __bootFailure = await __ocBootStore();
1287
1291
  if (__bootFailure) {
1288
1292
  return __ocHostResponse.json({ exitCode: 1, stdout: "", stderr: __bootFailure + "\\n" });
@@ -0,0 +1,19 @@
1
+ /**
2
+ * oxc-wasm-bytes.ts — supervisor-side fetcher for what the transform facet is
3
+ * built from: the Oxc wasm (scripts/bundle-oxc-wasm.mjs) and the facet's
4
+ * runtime script (scripts/bundle-facet-workers.mjs). Both are staged in the
5
+ * static-assets layer under names carrying a prefix of their digest, read
6
+ * through the colo cache (runtime/staged-source.ts), and verified against
7
+ * their pins before the loader compiles or evaluates them.
8
+ *
9
+ * Neither is kept in module scope: they are read only when the facet's
10
+ * loader has no worker cached under the facet's id, and that loader holds
11
+ * the only long-lived copy, as compiled code. The host Worker never compiles
12
+ * the wasm.
13
+ */
14
+ import { type StagedSourceEnv } from './staged-source.js';
15
+ /** The Oxc wasm's bytes, for the transform facet's module map. */
16
+ export declare function fetchOxcWasmBytes(env: StagedSourceEnv): Promise<ArrayBuffer>;
17
+ /** The transform facet's runtime: a script that installs the globals its class reads. */
18
+ export declare function fetchOxcFacetRuntime(env: StagedSourceEnv): Promise<string>;
19
+ //# sourceMappingURL=oxc-wasm-bytes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oxc-wasm-bytes.d.ts","sourceRoot":"","sources":["../../src/runtime/oxc-wasm-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAuD,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAuB/G,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC,CAE5E;AAED,yFAAyF;AACzF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAE1E"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * oxc-wasm-bytes.ts — supervisor-side fetcher for what the transform facet is
3
+ * built from: the Oxc wasm (scripts/bundle-oxc-wasm.mjs) and the facet's
4
+ * runtime script (scripts/bundle-facet-workers.mjs). Both are staged in the
5
+ * static-assets layer under names carrying a prefix of their digest, read
6
+ * through the colo cache (runtime/staged-source.ts), and verified against
7
+ * their pins before the loader compiles or evaluates them.
8
+ *
9
+ * Neither is kept in module scope: they are read only when the facet's
10
+ * loader has no worker cached under the facet's id, and that loader holds
11
+ * the only long-lived copy, as compiled code. The host Worker never compiles
12
+ * the wasm.
13
+ */
14
+ import { OXC_WASM_ASSET_PATH, OXC_WASM_SHA256 } from '../oxc-wasm-artifact.generated.js';
15
+ import { OXC_FACET_ASSET_PATH, OXC_FACET_SHA256 } from '../oxc-facet-artifact.generated.js';
16
+ import { fetchStagedBytes, fetchStagedText } from './staged-source.js';
17
+ function oxcAsset(label, path, sha256, contentType, stagedBy) {
18
+ return {
19
+ path,
20
+ l2Key: `https://nimbus-cache.invalid${path}`,
21
+ sha256,
22
+ contentType,
23
+ poisonedCache: 'reject',
24
+ missingBinding: `Nimbus: the transform facet requires an env.ASSETS binding (serves ${path})`,
25
+ fetchFailed: (res) => `${label} asset fetch failed: ${res.status} ${res.statusText} for ${path} — deploy is missing the asset`,
26
+ integrityFailed: (digest, from) => `${label} integrity check failed: expected ${sha256}, got ${digest} (${from}) for ${path} — ` +
27
+ `the staged asset is corrupt or out of sync; rerun ${stagedBy} and redeploy`,
28
+ };
29
+ }
30
+ const OXC_WASM_ASSET = oxcAsset('Oxc wasm', OXC_WASM_ASSET_PATH, OXC_WASM_SHA256, 'application/wasm', 'scripts/bundle-oxc-wasm.mjs');
31
+ const OXC_FACET_ASSET = oxcAsset('transform facet runtime', OXC_FACET_ASSET_PATH, OXC_FACET_SHA256, 'text/javascript; charset=utf-8', 'scripts/bundle-facet-workers.mjs');
32
+ /** The Oxc wasm's bytes, for the transform facet's module map. */
33
+ export function fetchOxcWasmBytes(env) {
34
+ return fetchStagedBytes(env, OXC_WASM_ASSET);
35
+ }
36
+ /** The transform facet's runtime: a script that installs the globals its class reads. */
37
+ export function fetchOxcFacetRuntime(env) {
38
+ return fetchStagedText(env, OXC_FACET_ASSET);
39
+ }
@@ -30,7 +30,7 @@ export async function installRuntimeProgrammatic(deps, spec, opts = {}) {
30
30
  pid: 0,
31
31
  get cred() { return programmaticCred; },
32
32
  setUmask: (umask) => { programmaticCred = { ...programmaticCred, umask }; },
33
- runAs: async () => 126,
33
+ runAs: async () => ({ status: 126, signal: null }),
34
34
  args: [],
35
35
  env: {},
36
36
  cwd: deps.getHome(),
@@ -1 +1 @@
1
- {"version":3,"file":"process-logs-api.d.ts","sourceRoot":"","sources":["../../src/runtime/process-logs-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uDAAuD,CAAC;AAEtG;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,wBAAwB,CAAC;IACpC;;;;OAIG;IACH,GAAG,EAAE;QACH,eAAe,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;KACvD,CAAC;CACH;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,SAAS,GAAG,IAAI,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,YAAY,GAAG,IAAI,EAC7B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,IAAI,CAON;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,iBAAiB,GACtB,QAAQ,CA8EV;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,wBAAwB,EACnC,GAAG,EAAE;IAAE,aAAa,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,CAAA;CAAE,GACjD,IAAI,CA8CN;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,wBAAwB,GAClC,QAAQ,CAsCV;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK7D"}
1
+ {"version":3,"file":"process-logs-api.d.ts","sourceRoot":"","sources":["../../src/runtime/process-logs-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uDAAuD,CAAC;AAGtG;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,wBAAwB,CAAC;IACpC;;;;OAIG;IACH,GAAG,EAAE;QACH,eAAe,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;KACvD,CAAC;CACH;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,SAAS,GAAG,IAAI,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,YAAY,GAAG,IAAI,EAC7B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,IAAI,CAON;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,iBAAiB,GACtB,QAAQ,CA8EV;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,wBAAwB,EACnC,GAAG,EAAE;IAAE,aAAa,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,CAAA;CAAE,GACjD,IAAI,CA8CN;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,wBAAwB,GAClC,QAAQ,CAyCV;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK7D"}
@@ -14,6 +14,7 @@
14
14
  * The ring buffer keeps state for 10 min post-exit so a tab that's still
15
15
  * open after a crash continues to show the final output.
16
16
  */
17
+ import { execIdField } from '@nimbus-sh/core/runtime/process-table.js';
17
18
  /**
18
19
  * Send a structured JSON event to the main terminal WebSocket, if one is
19
20
  * attached. Used for out-of-band process lifecycle notifications
@@ -218,6 +219,7 @@ export function handleProcessesListRequest(processes) {
218
219
  hasLogs: !!snap && snap.chunks > 0,
219
220
  logBytes: snap?.bytes ?? 0,
220
221
  startTime: p.startTime,
222
+ ...execIdField(p),
221
223
  });
222
224
  }
223
225
  // Reaped processes with lingering log buffers (exited >60s ago, not
@@ -9,7 +9,9 @@
9
9
  import { type VfsCred } from '@nimbus-sh/core/runtime/os-contracts.js';
10
10
  import { type ProcessFiles, type ProcessView } from '@nimbus-sh/core/runtime/process-files.js';
11
11
  import type { CredentialedVfs } from '@nimbus-sh/core/vfs/sqlite-vfs.js';
12
- type ProjectFsOp = 'exists' | 'isFile' | 'isDirectory' | 'stat' | 'lstat' | 'readFile' | 'readFileString' | 'readdir' | 'writeFile' | 'mkdir' | 'unlink' | 'rmdir' | 'removeRecursive' | 'symlink' | 'readlink' | 'chmod';
12
+ import type { Awaitable, VfsDirent } from '@nimbus-sh/core/vfs/vfs.js';
13
+ import { type KnownDirentType } from '@nimbus-sh/core/vfs/dirent-type.js';
14
+ type ProjectFsOp = 'exists' | 'isFile' | 'isDirectory' | 'stat' | 'lstat' | 'readFile' | 'readFileString' | 'writeFile' | 'mkdir' | 'unlink' | 'rmdir' | 'removeRecursive' | 'symlink' | 'readlink' | 'chmod';
13
15
  /**
14
16
  * A tool's calls on its tree in the engine's call shape (keys with or
15
17
  * without the leading slash, a stat that throws when absent, failures
@@ -18,7 +20,12 @@ type ProjectFsOp = 'exists' | 'isFile' | 'isDirectory' | 'stat' | 'lstat' | 'rea
18
20
  */
19
21
  export type ProjectFs = {
20
22
  [K in ProjectFsOp]: (...args: Parameters<CredentialedVfs[K]>) => ReturnType<CredentialedVfs[K]> | Promise<ReturnType<CredentialedVfs[K]>>;
23
+ } & {
24
+ /** A directory's entries, typed as the namespace types them: a mount's may name a device, or say it cannot tell. */
25
+ readdir(key: string): Awaitable<Array<Pick<VfsDirent, 'name' | 'type'>>>;
21
26
  };
27
+ /** The exact type of `entry` in `dir`, lstat'ing it where its listing could not type it; null when it has gone. */
28
+ export declare function projectEntryType(fs: Pick<ProjectFs, 'lstat'>, dir: string, entry: Pick<VfsDirent, 'name' | 'type'>): Promise<KnownDirentType | null>;
22
29
  /** The principal's `view` in the engine's call shape. */
23
30
  export declare function projectFs(view: ProcessView): ProjectFs;
24
31
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"project-fs.d.ts","sourceRoot":"","sources":["../../src/runtime/project-fs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAe,KAAK,OAAO,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,EAAa,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAC1G,OAAO,KAAK,EAAE,eAAe,EAAW,MAAM,mCAAmC,CAAC;AAIlF,KAAK,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,gBAAgB,GAAG,SAAS,GACjH,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,iBAAiB,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,CAAC;AAEtG;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG;KACrB,CAAC,IAAI,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;CAC1I,CAAC;AAEF,yDAAyD;AACzD,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,CAgCtD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,kBAAkB,CAAC,UAAU,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,I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AE,MAAM,GAAG,MAAM,CAAC,GACtC,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CASjC;AAED,yDAAyD;AACzD,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,CAgCtD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,kBAAkB,CAAC,UAAU,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAahI"}
@@ -8,8 +8,22 @@
8
8
  */
9
9
  import { CRED_KERNEL } from '@nimbus-sh/core/runtime/os-contracts.js';
10
10
  import { engineKey } from '@nimbus-sh/core/runtime/process-files.js';
11
- import { syscallError } from '@nimbus-sh/core/vfs/vfs-error.js';
11
+ import { isVfsError, syscallError } from '@nimbus-sh/core/vfs/vfs-error.js';
12
+ import { direntTypeOf } from '@nimbus-sh/core/vfs/dirent-type.js';
12
13
  import { normalizeVfsPath } from '@nimbus-sh/core/vfs/path.js';
14
+ /** The exact type of `entry` in `dir`, lstat'ing it where its listing could not type it; null when it has gone. */
15
+ export function projectEntryType(fs, dir, entry) {
16
+ return direntTypeOf(entry, async () => {
17
+ try {
18
+ return await fs.lstat(`${dir}/${entry.name}`);
19
+ }
20
+ catch (error) {
21
+ if (isVfsError(error, 'ENOENT'))
22
+ return null;
23
+ throw error;
24
+ }
25
+ });
26
+ }
13
27
  /** The principal's `view` in the engine's call shape. */
14
28
  export function projectFs(view) {
15
29
  const at = (key) => '/' + normalizeVfsPath(key);