@nimbus-sh/worker 0.12.0 → 0.13.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 (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 +6 -4
  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
@@ -12,7 +12,7 @@
12
12
  * ├── /*.ts,*.tsx,*.jsx → esbuild transform → JS with import rewrites + alias resolution
13
13
  * ├── /*.css → serve as text/css (with @import inlining, @tailwind stripping, @apply expansion)
14
14
  * ├── /*.css?import → wrap CSS in JS that injects <style> tag
15
- * ├── /@modules/<pkg> → resolve from node_modules, bundle via esbuild facet (synthetic-entry for barrels)
15
+ * ├── /@modules/<pkg> → resolve from node_modules, bundle in the build facet (synthetic-entry for barrels)
16
16
  * ├── /@vite/client → HMR client script
17
17
  * ├── /*.json (as module) → export default { ... }
18
18
  * ├── /*.svg,*.png,... (as module) → export default "/preview/path/to/asset"
@@ -22,10 +22,17 @@
22
22
  * messages through the DO WebSocket → frontend dispatches to iframe.
23
23
  */
24
24
  import type { SqliteVFS } from '@nimbus-sh/core/vfs/sqlite-vfs.js';
25
+ import type { VfsCred } from '@nimbus-sh/core/runtime/os-contracts.js';
25
26
  import type { EsbuildService } from '@nimbus-sh/core/runtime/esbuild-service.js';
26
- import type { BundlePoolProvider } from './esbuild-bundle-pool.js';
27
+ import type { BundlePoolProvider } from './prebundle-pool.js';
27
28
  export interface ViteDevServerOptions {
28
29
  vfs: SqliteVFS;
30
+ /**
31
+ * Who the server reads and writes as: the credential of the process it
32
+ * runs under, the command that started it. Everything it serves, bundles
33
+ * or synthesizes goes through the VFS as this principal.
34
+ */
35
+ cred: VfsCred;
29
36
  esbuild: EsbuildService;
30
37
  /** Root directory in VFS (e.g. "home/user/projects") */
31
38
  root: string;
@@ -53,11 +60,11 @@ export interface ViteDevServerOptions {
53
60
  /** Durable Object state. */
54
61
  ctx?: DurableObjectState;
55
62
  /**
56
- * The session's esbuild facet pool, shared with the install-time
57
- * pre-bundler. When provided, /preview/@modules/<spec> misses bundle in
58
- * that pool's isolate instead of the supervisor's EsbuildService.
59
- * Without it, the supervisor falls back to in-process esbuild (legacy
60
- * behaviour used by callers without a LOADER binding).
63
+ * The session's pre-bundle pool (its build facet), shared with the
64
+ * install-time pre-bundler. When provided, /preview/@modules/<spec>
65
+ * misses bundle there from a slice, rather than through the session's
66
+ * EsbuildService and its VFS plugin (the path callers without a LOADER
67
+ * binding take).
61
68
  */
62
69
  bundlePool?: BundlePoolProvider;
63
70
  /**
@@ -73,6 +80,74 @@ export interface ViteDevServerOptions {
73
80
  appendOutput(pid: number, stream: 'stdout' | 'stderr', data: string): void;
74
81
  };
75
82
  }
83
+ /**
84
+ * esbuild, when bundling CJS source with `external` specifiers, leaves the
85
+ * `require("pkg")` calls in the output wrapped in a `__require()` helper that
86
+ * falls back to the global `require`. In the browser there is no global
87
+ * `require`, so every such call throws.
88
+ *
89
+ * The fix: detect all distinct `__require("X")` specifiers in the output,
90
+ * emit a top-level ESM `import * as __ns_X from "X"` for each, and replace
91
+ * every `__require("X")` call with a reference to that namespace (with
92
+ * default-export interop — `__ns_X.default ?? __ns_X`).
93
+ *
94
+ * Before:
95
+ * var __require = ((x) => typeof require !== "undefined" ? require : ...);
96
+ * var React = __require("react");
97
+ *
98
+ * After:
99
+ * import * as __nimbus_ext__react from "react";
100
+ * const __nimbus_req = (id) => {
101
+ * if (id === "react") return __nimbus_ext__react.default ?? __nimbus_ext__react;
102
+ * throw new Error("require: " + id);
103
+ * };
104
+ * var __require = ((x) => typeof require !== "undefined" ? require : ...);
105
+ * var React = __nimbus_req("react");
106
+ *
107
+ * We inject `__nimbus_req` but keep esbuild's `__require` definition so we
108
+ * don't have to rewrite its declaration — we just replace the call-sites.
109
+ */
110
+ export declare function rewriteExternalRequires(code: string, basePath: string): string;
111
+ /**
112
+ * esbuild bundles CJS packages by wrapping them in __commonJS helpers.
113
+ * The resulting ESM bundle only has `export default require_X()` — no named
114
+ * exports. This breaks `import { createRoot } from "react-dom/client"`.
115
+ *
116
+ * We fix this by STATICALLY analyzing the bundled source to find CJS export
117
+ * patterns, then emitting named exports for each found name. We cannot use
118
+ * `new Function()` or `eval()` to get runtime export keys because the
119
+ * Cloudflare Workers runtime disallows string-to-code generation outside of
120
+ * module initialization.
121
+ *
122
+ * Patterns we detect (scanning the entire bundled text, not just the top level):
123
+ * - `exports.NAME = ...`
124
+ * - `exports["NAME"] = ...`
125
+ * - `Object.defineProperty(exports, "NAME", ...)`
126
+ * - `module.exports.NAME = ...`
127
+ * - `module.exports = { NAME, NAME2, ... }` (object literal)
128
+ *
129
+ * Input (esbuild output):
130
+ * var require_X = __commonJS({ "...": function(exports) { exports.jsx = ...; exports.jsxs = ...; } });
131
+ * export default require_X();
132
+ *
133
+ * Output (synthesized):
134
+ * var require_X = __commonJS({...});
135
+ * const __nimbus_ns = require_X();
136
+ * export default __nimbus_ns;
137
+ * export const jsx = __nimbus_ns.jsx;
138
+ * export const jsxs = __nimbus_ns.jsxs;
139
+ *
140
+ * Note: we emit `export const NAME = __nimbus_ns.NAME` per key rather than
141
+ * `export const { NAME, ... } = __nimbus_ns` destructuring. The former
142
+ * preserves live binding semantics slightly better and avoids issues when
143
+ * a key name happens to shadow a keyword or identifier.
144
+ *
145
+ * Returns the original code unchanged if:
146
+ * - The bundle already has named exports (not a CJS-only bundle)
147
+ * - No `export default` pattern found
148
+ * - No CJS export patterns found in the bundle source
149
+ */
150
+ export declare function synthesizeCjsNamedExports(code: string): string;
76
151
  /**
77
152
  * Importer context for `#X` subpath-import resolution. The dev-server
78
153
  * passes this through `rewriteAllImports` whenever it knows the source
@@ -132,7 +207,7 @@ export declare class ViteDevServer {
132
207
  private injectBasename;
133
208
  private env;
134
209
  private ctx;
135
- /** The session's esbuild facet pool; null = legacy in-supervisor esbuild. */
210
+ /** The session's pre-bundle pool; null = bundle through the EsbuildService. */
136
211
  private readonly bundlePool;
137
212
  /**
138
213
  * In-flight on-demand-bundle coalescing map. When the browser fires
@@ -162,11 +237,11 @@ export declare class ViteDevServer {
162
237
  private logSink;
163
238
  constructor(opts: ViteDevServerOptions);
164
239
  /**
165
- * The session's shared esbuild pool for on-demand bundling of
240
+ * The session's pre-bundle pool for on-demand bundling of
166
241
  * /preview/@modules/<spec> requests that miss both the in-memory and
167
- * pkg_esm_bundles caches. Null when no pool was provided (legacy
168
- * in-supervisor fallback). Acquired BEFORE the slice lease — see
169
- * EsbuildBundlePool.acquire.
242
+ * pkg_esm_bundles caches. Null when no pool was provided (the
243
+ * EsbuildService fallback). Acquired BEFORE the slice lease — see
244
+ * PrebundlePool.acquire.
170
245
  */
171
246
  private ensureOnDemandPool;
172
247
  /** Detect TailwindCSS usage in the project */
@@ -182,6 +257,8 @@ export declare class ViteDevServer {
182
257
  private baseUrlValue;
183
258
  /** esbuild define set for a request served under `base`. */
184
259
  private defineFor;
260
+ /** Whether this server's principal may read `path`. */
261
+ private mayRead;
185
262
  /**
186
263
  * Module-cache key for `key` under mount base `base`. The transformed text
187
264
  * embeds the base (module URLs, <base href>, BASE_URL, router basename), so
@@ -1 +1 @@
1
- {"version":3,"file":"vite-dev-server.d.ts","sourceRoot":"","sources":["../../src/facets/vite-dev-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAGpF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAOjF,OAAO,KAAK,EAAc,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAsB/E,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,SAAS,CAAC;IACf,OAAO,EAAE,cAAc,CAAC;IACxB,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;IACjC,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iFAAiF;IACjF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,uFAAuF;IACvF,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,qFAAqF;IACrF,GAAG,CAAC,EAAE,UAAU,CAAC;IACjB;;;;;OAKG;IACH,cAAc,CAA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OAAO,CAAC,SAAS;IAIjB,uDAAuD;IACvD,OAAO,CAAC,OAAO;IASf;;;;;OAKG;IACH,OAAO,CAAC,EAAE;IAIV;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAaxB,8DAA8D;IAC9D,KAAK,IAAI,IAAI;IAWb,2BAA2B;IAC3B,IAAI,IAAI,IAAI;IAMZ,IAAI,SAAS,YAA2B;IAExC;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,OAAO,CAAC,GAAG;IAYX,8CAA8C;IAC9C,OAAO,CAAC,eAAe;IAoEvB,sEAAsE;IACtE,OAAO,CAAC,YAAY;IASpB;;;;;;;;;;OAUG;IACG,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;YAkBhF,mBAAmB;IA8FjC,OAAO,CAAC,cAAc;IAuEtB,OAAO,CAAC,wBAAwB;IAiBhC,OAAO,CAAC,8BAA8B;YAQxB,WAAW;IA8EzB;;;;;;;;;OASG;YACW,eAAe;IAsX7B;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,cAAc;IAyFtB,OAAO,CAAC,cAAc;IAyBtB;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,oBAAoB;IAkE5B;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,eAAe;YAoDT,SAAS;YAsJT,gBAAgB;IAoH9B,IAAI,KAAK;;;;;;;MASR;CACF"}
@@ -12,7 +12,7 @@
12
12
  * ├── /*.ts,*.tsx,*.jsx → esbuild transform → JS with import rewrites + alias resolution
13
13
  * ├── /*.css → serve as text/css (with @import inlining, @tailwind stripping, @apply expansion)
14
14
  * ├── /*.css?import → wrap CSS in JS that injects <style> tag
15
- * ├── /@modules/<pkg> → resolve from node_modules, bundle via esbuild facet (synthetic-entry for barrels)
15
+ * ├── /@modules/<pkg> → resolve from node_modules, bundle in the build facet (synthetic-entry for barrels)
16
16
  * ├── /@vite/client → HMR client script
17
17
  * ├── /*.json (as module) → export default { ... }
18
18
  * ├── /*.svg,*.png,... (as module) → export default "/preview/path/to/asset"
@@ -21,8 +21,9 @@
21
21
  * HMR: VFS events → ViteDevServer detects changes → sends {type:'hmr'}
22
22
  * messages through the DO WebSocket → frontend dispatches to iframe.
23
23
  */
24
- import { CRED_KERNEL } from '@nimbus-sh/core/runtime/os-contracts.js';
25
- import { getSharedRuntimeExternals, BUNDLER_VERSION } from '@nimbus-sh/core/runtime/esbuild-service.js';
24
+ import { getSharedRuntimeExternals, BUNDLER_VERSION, vfsBuildInputs } from '@nimbus-sh/core/runtime/esbuild-service.js';
25
+ import { sliceSources } from '@nimbus-sh/core/runtime/prebundle-slice.js';
26
+ import { R_OK } from '@nimbus-sh/core/runtime/process-files.js';
26
27
  import { NpmCache } from '../npm/cache.js';
27
28
  import { sha256Base64Url } from '@nimbus-sh/core/_shared/crypto.js';
28
29
  import { LruMap } from '@nimbus-sh/core/_shared/lru-map.js';
@@ -32,6 +33,7 @@ import { countPackageFiles, BARREL_PKG_FILE_THRESHOLD, packageNameFromSpecifier
32
33
  import { scanNamedImports, namedImportSignature, buildSyntheticEntry, buildScopedSliceForSynthetic, syntheticEntryPath, } from '../runtime/barrel-synthesizer.js';
33
34
  import { resolvePackageEntry, resolveExports } from '@nimbus-sh/core/_shared/exports-resolver.js';
34
35
  import { injectRouterBasename, shouldProcessForRouter } from '@nimbus-sh/core/runtime/router-basename.js';
36
+ import { devStylesheet } from './dev-stylesheet.js';
35
37
  import { rewriteJavaScriptModuleSource } from '@nimbus-sh/core/runtime/module-source-rewriter.js';
36
38
  import { normalizeVfsPath, stripLeadingSlashes } from '@nimbus-sh/core/vfs/path.js';
37
39
  import { getTailwindPlayBundle, TAILWIND_PLAY_VERSION, } from '../tailwind-play.generated.js';
@@ -162,7 +164,7 @@ const ASSET_EXTS = new Set([
162
164
  * We inject `__nimbus_req` but keep esbuild's `__require` definition so we
163
165
  * don't have to rewrite its declaration — we just replace the call-sites.
164
166
  */
165
- function rewriteExternalRequires(code, basePath) {
167
+ export function rewriteExternalRequires(code, basePath) {
166
168
  // Find all `__require("specifier")` calls where the specifier is bare
167
169
  // (not a relative/absolute path). Bare specifiers are the only ones that
168
170
  // can be external.
@@ -238,7 +240,7 @@ function rewriteExternalRequires(code, basePath) {
238
240
  * - No `export default` pattern found
239
241
  * - No CJS export patterns found in the bundle source
240
242
  */
241
- function synthesizeCjsNamedExports(code) {
243
+ export function synthesizeCjsNamedExports(code) {
242
244
  // Quick check: does the bundle already have named exports?
243
245
  if (/(^|\n)\s*export\s+(?:const|let|var|function|class|\{|\*)\b/.test(code)) {
244
246
  return code;
@@ -1170,7 +1172,7 @@ export class ViteDevServer {
1170
1172
  injectBasename;
1171
1173
  env;
1172
1174
  ctx = null;
1173
- /** The session's esbuild facet pool; null = legacy in-supervisor esbuild. */
1175
+ /** The session's pre-bundle pool; null = bundle through the EsbuildService. */
1174
1176
  bundlePool;
1175
1177
  /**
1176
1178
  * In-flight on-demand-bundle coalescing map. When the browser fires
@@ -1199,7 +1201,7 @@ export class ViteDevServer {
1199
1201
  logPid = null;
1200
1202
  logSink = null;
1201
1203
  constructor(opts) {
1202
- this.vfs = opts.vfs.as(CRED_KERNEL);
1204
+ this.vfs = opts.vfs.as(opts.cred);
1203
1205
  this.vfsEvents = opts.vfs.events;
1204
1206
  this.esbuild = opts.esbuild;
1205
1207
  this.injectBasename = opts.injectBasename !== false;
@@ -1243,11 +1245,11 @@ export class ViteDevServer {
1243
1245
  this.detectTailwind();
1244
1246
  }
1245
1247
  /**
1246
- * The session's shared esbuild pool for on-demand bundling of
1248
+ * The session's pre-bundle pool for on-demand bundling of
1247
1249
  * /preview/@modules/<spec> requests that miss both the in-memory and
1248
- * pkg_esm_bundles caches. Null when no pool was provided (legacy
1249
- * in-supervisor fallback). Acquired BEFORE the slice lease — see
1250
- * EsbuildBundlePool.acquire.
1250
+ * pkg_esm_bundles caches. Null when no pool was provided (the
1251
+ * EsbuildService fallback). Acquired BEFORE the slice lease — see
1252
+ * PrebundlePool.acquire.
1251
1253
  */
1252
1254
  async ensureOnDemandPool() {
1253
1255
  if (!this.bundlePool)
@@ -1310,6 +1312,16 @@ export class ViteDevServer {
1310
1312
  defineFor(base) {
1311
1313
  return { ...this.define, 'import.meta.env.BASE_URL': this.baseUrlValue(base) };
1312
1314
  }
1315
+ /** Whether this server's principal may read `path`. */
1316
+ mayRead(path) {
1317
+ try {
1318
+ this.vfs.access(path, R_OK);
1319
+ return true;
1320
+ }
1321
+ catch {
1322
+ return false;
1323
+ }
1324
+ }
1313
1325
  /**
1314
1326
  * Module-cache key for `key` under mount base `base`. The transformed text
1315
1327
  * embeds the base (module URLs, <base href>, BASE_URL, router basename), so
@@ -1555,7 +1567,8 @@ export class ViteDevServer {
1555
1567
  return new Response(null, { status: 302, headers: { ...headers, 'Location': resolved } });
1556
1568
  }
1557
1569
  }
1558
- return this.serveModule(specifier, headers, base);
1570
+ // Awaited, so a package its principal may not enter answers 403 below.
1571
+ return await this.serveModule(specifier, headers, base);
1559
1572
  }
1560
1573
  // / → serve index.html
1561
1574
  if (pathname === '/' || pathname === '/index.html') {
@@ -1570,10 +1583,18 @@ export class ViteDevServer {
1570
1583
  headers: { ...headers, 'Content-Type': MIME_TYPES[ext] || 'application/octet-stream' },
1571
1584
  });
1572
1585
  }
1573
- // Serve from VFS (with transforms for TS/TSX/JSX)
1574
- return this.serveFile(request, pathname, query, headers, base);
1586
+ // Serve from VFS (with transforms for TS/TSX/JSX). Awaited, so a
1587
+ // read the server's principal is refused lands in the catch below.
1588
+ return await this.serveFile(request, pathname, query, headers, base);
1575
1589
  }
1576
1590
  catch (e) {
1591
+ // The server reads as the principal who started it: a file that
1592
+ // principal may not read is forbidden, not an error of the server's.
1593
+ if (e?.code === 'EACCES' || e?.code === 'EPERM') {
1594
+ return new Response('403 Forbidden: ' + pathname, {
1595
+ status: 403, headers: { ...headers, 'Content-Type': 'text/plain' },
1596
+ });
1597
+ }
1577
1598
  return new Response(`500 Internal Server Error: ${e?.message}`, {
1578
1599
  status: 500, headers: { ...headers, 'Content-Type': 'text/plain' },
1579
1600
  });
@@ -1688,9 +1709,15 @@ export class ViteDevServer {
1688
1709
  // Only use cached bundles built with the current bundler version.
1689
1710
  // Stale bundles (from older bundler versions) are treated as missing
1690
1711
  // and re-bundled on the cold path.
1712
+ // The cache is the workspace's, shared by every server whoever started
1713
+ // it: a bundle is served only to a principal who may read everything it
1714
+ // was built from, so one that names nothing it was built from is never
1715
+ // served. Otherwise this server builds its own, as itself.
1691
1716
  if (esmBundle &&
1692
1717
  esmBundle.bundleHash === BUNDLER_VERSION &&
1693
- this.cachedModuleMatchesBarrelInput(esmBundle.inputHash, barrelInfo)) {
1718
+ this.cachedModuleMatchesBarrelInput(esmBundle.inputHash, barrelInfo) &&
1719
+ esmBundle.sources.length > 0 &&
1720
+ esmBundle.sources.every((path) => this.mayRead(path))) {
1694
1721
  let code = esmBundle.esmCode;
1695
1722
  // The persisted bundle is base-independent raw esbuild output; the
1696
1723
  // base-dependent rewrites (module URLs) are applied here, per request.
@@ -1747,13 +1774,12 @@ export class ViteDevServer {
1747
1774
  // supervisor isolate. For large modules (lucide-react, ~18 MiB
1748
1775
  // unpacked) that OOM'd the supervisor and surfaced as CF error
1749
1776
  // 1101 on /preview/@modules/lucide-react, taking down the entire
1750
- // preview. We now dispatch the bundle work to the session's shared
1751
- // esbuild IsolatePool — the same pool, isolate and 128 MiB heap the
1752
- // install-time pre-bundler uses. Supervisor never bundles esbuild
1753
- // for any path.
1777
+ // preview. We now dispatch the bundle work to the session's build
1778
+ // facet from a slice — the same pool and isolate the install-time
1779
+ // pre-bundler uses. The supervisor never runs a bundler.
1754
1780
  //
1755
- // Falls back to in-supervisor esbuild ONLY if no bundle pool was
1756
- // provided (legacy callers / tests).
1781
+ // Falls back to the EsbuildService (its build host) ONLY if no bundle
1782
+ // pool was provided (legacy callers / tests).
1757
1783
  const resolved = this.resolvePackage(specifier);
1758
1784
  // Barrel packages (lucide-react, @phosphor-icons/react, react-icons,
1759
1785
  // @mui/icons-material, …) ship hundreds/thousands of tiny re-export
@@ -1777,6 +1803,11 @@ export class ViteDevServer {
1777
1803
  // re-exports just the named imports the user's
1778
1804
  // source uses. esbuild tree-shakes the rest.
1779
1805
  let bundleEntryPath = resolved;
1806
+ // A module its principal may not read is refused (403), not bundled
1807
+ // from whatever of its package the principal can see.
1808
+ this.vfs.access(resolved, R_OK);
1809
+ // What the bundle was built from, recorded with it in the shared cache.
1810
+ let bundledSources = [];
1780
1811
  let synthetic = false;
1781
1812
  let syntheticReferencedFiles = null;
1782
1813
  if (isBarrel) {
@@ -1850,9 +1881,9 @@ export class ViteDevServer {
1850
1881
  let sliceLease = null;
1851
1882
  try {
1852
1883
  if (onDemandPool) {
1853
- // Facet path — supervisor stays at 0 esbuild bytes.
1884
+ // Facet path — the supervisor holds no bundler.
1854
1885
  try {
1855
- const { buildSliceForSpecifierWithCap, prebundleOne, BUNDLER_VERSION, } = await import('../npm/pre-bundle-facet.js');
1886
+ const { buildSliceForSpecifierWithCap, BUNDLER_VERSION, } = await import('../npm/pre-bundle-facet.js');
1856
1887
  const SLICE_CAP_BYTES = ON_DEMAND_SLICE_CAP_BYTES;
1857
1888
  const projDir = this.root;
1858
1889
  const nmDir = projDir + '/node_modules';
@@ -1906,6 +1937,7 @@ export class ViteDevServer {
1906
1937
  // completes. Mirrors the install-time runSlot pattern (see
1907
1938
  // commit 40cfc01); the lease above keeps every other budget
1908
1939
  // owner from allocating beside it until the Response exists.
1940
+ const sources = sliceSources(slice.slice);
1909
1941
  let spec = {
1910
1942
  specifier,
1911
1943
  entryPath: bundleEntryPath,
@@ -1920,13 +1952,14 @@ export class ViteDevServer {
1920
1952
  slice = null;
1921
1953
  let result = null;
1922
1954
  try {
1923
- result = await onDemandPool.submit(prebundleOne, spec);
1955
+ result = await onDemandPool.prebundle(spec);
1924
1956
  }
1925
1957
  finally {
1926
1958
  spec = null;
1927
1959
  }
1928
1960
  if (result && result.ok && result.esmCode) {
1929
1961
  bundled = result.esmCode;
1962
+ bundledSources = sources;
1930
1963
  }
1931
1964
  else if (result && result.errorText) {
1932
1965
  this.log('error', '[vite-dev] facet bundle failed for ' + specifier + ': ' + result.errorText);
@@ -1942,8 +1975,8 @@ export class ViteDevServer {
1942
1975
  }
1943
1976
  }
1944
1977
  else {
1945
- // Legacy fallback — in-supervisor esbuild. Used only when no
1946
- // bundle pool was provided.
1978
+ // Fallback — the EsbuildService's build (its build host). Used
1979
+ // only when no bundle pool was provided.
1947
1980
  try {
1948
1981
  const result = await this.esbuild.build([bundleEntryPath], {
1949
1982
  bundle: true,
@@ -1953,9 +1986,11 @@ export class ViteDevServer {
1953
1986
  // Base-neutral (see the pooled build above).
1954
1987
  define: this.defineFor(''),
1955
1988
  external: externals.length > 0 ? externals : undefined,
1989
+ fs: this.vfs,
1956
1990
  });
1957
1991
  if (result.outputFiles?.length) {
1958
1992
  bundled = result.outputFiles[0].contents;
1993
+ bundledSources = vfsBuildInputs(result.metafile);
1959
1994
  }
1960
1995
  }
1961
1996
  catch (e) {
@@ -1970,7 +2005,8 @@ export class ViteDevServer {
1970
2005
  // post-rewrite text instead would pin the bundle to whichever base
1971
2006
  // built it first and 404 the other. Cache ONLY successful bundles;
1972
2007
  // a failed build left `bundled` null and never reaches here.
1973
- if (this.npmCache) {
2008
+ // A bundle whose sources are unknown would never be served from the cache.
2009
+ if (this.npmCache && bundledSources.length > 0) {
1974
2010
  try {
1975
2011
  this.npmCache.putEsmBundle({
1976
2012
  specifier,
@@ -1978,6 +2014,7 @@ export class ViteDevServer {
1978
2014
  esmCode: bundled,
1979
2015
  builtAt: Date.now(),
1980
2016
  inputHash: barrelInfo?.inputHash ?? '',
2017
+ sources: bundledSources,
1981
2018
  });
1982
2019
  }
1983
2020
  catch { /* non-fatal */ }
@@ -2413,22 +2450,8 @@ export class ViteDevServer {
2413
2450
  }
2414
2451
  // CSS handling
2415
2452
  if (ext === '.css') {
2416
- let css = this.vfs.readFileString(vfsPath);
2417
- // Resolve @import "./other.css" (but pass through @import url(...) for Google Fonts etc.)
2418
- const cssDir = vfsPath.includes('/') ? vfsPath.substring(0, vfsPath.lastIndexOf('/')) : this.root;
2419
- css = css.replace(/@import\s+["']([^"']+)["']\s*;/g, (_match, importPath) => {
2420
- if (importPath.startsWith('http'))
2421
- return _match;
2422
- const resolvedPath = importPath.startsWith('/')
2423
- ? this.root + importPath
2424
- : cssDir + '/' + importPath;
2425
- try {
2426
- return this.vfs.readFileString(resolvedPath);
2427
- }
2428
- catch {
2429
- return `/* @import "${importPath}" not found */`;
2430
- }
2431
- });
2453
+ // Its @imports inlined by the CSS layer `vite build` uses, its url()s rooted at `base`.
2454
+ let css = await devStylesheet(this.vfs, this.root, base, vfsPath);
2432
2455
  // Process Tailwind CSS directives if project uses Tailwind
2433
2456
  if (this.hasTailwind) {
2434
2457
  css = processTailwindCss(css);
@@ -1 +1 @@
1
- {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/hosted/commands.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAyB5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAI9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAGvE,oFAAoF;AACpF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,eAAe,EACnD,oBAAoB,GAAG,gBAAgB,GAAG,cAAc,GAAG,eAAe,GAAG,YAAY,GAAG,oBAAoB,GAAG,oBAAoB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,cAAc,GAAG,cAAc,GAAG,WAAW,GAAG,iBAAiB,GAAG,UAAU,GAAG,cAAc,GAAG,eAAe,GAAG,0BAA0B,CAClV,GAAG;IACF,QAAQ,CAAC,GAAG,EAAE,kBAAkB,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC;IAChC,aAAa,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;IAChD,sBAAsB,EAAE,eAAe,CAAC,wBAAwB,CAAC,CAAC;CACnE,CAAC;AAEF,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,kBAAkB,EAAE,SAAS,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAshDhH"}
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/hosted/commands.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AA2B5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAI9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAGvE,oFAAoF;AACpF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,eAAe,EACnD,oBAAoB,GAAG,gBAAgB,GAAG,cAAc,GAAG,eAAe,GAAG,YAAY,GAAG,oBAAoB,GAAG,oBAAoB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,cAAc,GAAG,cAAc,GAAG,WAAW,GAAG,iBAAiB,GAAG,UAAU,GAAG,cAAc,GAAG,eAAe,GAAG,0BAA0B,CAClV,GAAG;IACF,QAAQ,CAAC,GAAG,EAAE,kBAAkB,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC;IAChC,aAAa,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;IAChD,sBAAsB,EAAE,eAAe,CAAC,wBAAwB,CAAC,CAAC;CACnE,CAAC;AAEF,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,kBAAkB,EAAE,SAAS,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAqiDhH"}
@@ -7,9 +7,11 @@ import { engineKey, ProcessView } from '@nimbus-sh/core/runtime/process-files.js
7
7
  import { handKernelArtifact, projectFs } from '../runtime/project-fs.js';
8
8
  import { makeEsbuildCommand } from '@nimbus-sh/core/runtime/esbuild-cli.js';
9
9
  import { runEsbuildCli, supervisorEsbuildService } from '../facets/esbuild-transform.js';
10
+ import { prewarmBuildFacet } from '../facets/build-facet.js';
10
11
  import { runFresh } from '../runtime/node-runner.js';
11
12
  import { runBunScript, BUN_VERSION } from '../runtime/bun-runner.js';
12
13
  import { buildRuntimeHandler, resolveRuntimeScriptPath } from '@nimbus-sh/core/runtime/runtime-registry.js';
14
+ import { resolveContext } from '@nimbus-sh/core/substrate/lifo/commands/registry.js';
13
15
  import { normalizeVfsPath, resolveVfsPath } from '@nimbus-sh/core/vfs/path.js';
14
16
  import { NimbusWrangler } from '../wrangler/nimbus-wrangler.js';
15
17
  import { filterWranglerFlags, detectBundlerBin, checkNodeModulesGuard, detectUnsupportedWranglerConfig, refusedNextSubcommand, NEXT_REFUSAL_MESSAGE } from '../session/helpers.js';
@@ -24,7 +26,7 @@ import { rpcExposeApp, rpcListApps, rpcRemoveApp, rpcRotateLink } from '../sessi
24
26
  import { listInstalledRuntimes } from '@nimbus-sh/core/runtime/installed-runtimes.js';
25
27
  import { notifyTerminalEvent } from '../runtime/process-logs-api.js';
26
28
  import { stripAnsi } from '@nimbus-sh/core/runtime/process-logs.js';
27
- import { NODE_VERSION } from '@nimbus-sh/core/constants.js';
29
+ import { DEFAULT_HOME, NODE_VERSION } from '@nimbus-sh/core/constants.js';
28
30
  import { VITE_CONFIG_KEY } from '../session/keys.js';
29
31
  import { isJsonObject } from '../npm/package-lock.js';
30
32
  import { HeadlessTerminal } from '@nimbus-sh/core/substrate/lifo/index.js';
@@ -139,6 +141,7 @@ export async function registerHostedCommands(self, workspace) {
139
141
  authority: workspace.filesystem,
140
142
  terminal: terminal,
141
143
  installRoot,
144
+ home: ctx.env?.HOME || shell.getEnv().HOME || DEFAULT_HOME,
142
145
  manifest,
143
146
  // REPL-R7-1: thread the shell so ReplSession can drain
144
147
  // shell.pasteQueue on attach (multi-line WS frames like
@@ -147,6 +150,7 @@ export async function registerHostedCommands(self, workspace) {
147
150
  // The supervisor derives the write credential from this; without
148
151
  // it the prompt cannot write to the session filesystem.
149
152
  pid: ctx.pid,
153
+ start: { cwd: ctx.cwd || shell.getCwd(), binName },
150
154
  });
151
155
  }
152
156
  // Args present (one-shot mode: -c, script, -m, -). Fall through
@@ -177,6 +181,11 @@ export async function registerHostedCommands(self, workspace) {
177
181
  authority: workspace.filesystem,
178
182
  terminal: terminal,
179
183
  installRoot,
184
+ // The caller's filesystem and credential, from its working directory.
185
+ pid: ctx.pid,
186
+ home: ctx.env?.HOME || shell.getEnv().HOME || DEFAULT_HOME,
187
+ cwd: ctx.cwd || shell.getCwd(),
188
+ binName,
180
189
  });
181
190
  }
182
191
  const { makeRubyRunnerFactory } = await import('@nimbus-sh/core/runtime/ruby-runner.js');
@@ -187,6 +196,7 @@ export async function registerHostedCommands(self, workspace) {
187
196
  filesystem: workspace.filesystem,
188
197
  registry,
189
198
  startResident: rubyResidentStart(facetMgr),
199
+ getHome: () => workspace.shell.getEnv().HOME ?? DEFAULT_HOME,
190
200
  })(manifest, installRoot, binName, binKind);
191
201
  return runner(ctx);
192
202
  });
@@ -256,7 +266,7 @@ export async function registerHostedCommands(self, workspace) {
256
266
  pid,
257
267
  cred,
258
268
  setUmask: (mask) => ctx.setUmask(mask),
259
- runAs: (targetCred, argv) => ctx.runAs(targetCred, argv),
269
+ runAs: (targetCred, argv, options) => ctx.runAs(targetCred, argv, options),
260
270
  vfs: new ProcessView(workspace.filesystem.bind({ pid, cred })),
261
271
  signal: new AbortController().signal,
262
272
  stdout,
@@ -271,6 +281,7 @@ export async function registerHostedCommands(self, workspace) {
271
281
  facetMgr,
272
282
  authority: workspace.filesystem,
273
283
  installRoot: target.root,
284
+ home: ctx.env?.HOME || shell.getEnv().HOME || DEFAULT_HOME,
274
285
  manifest: target.manifest,
275
286
  });
276
287
  ctx.stdout.write('[python] ready\n');
@@ -453,6 +464,9 @@ export async function registerHostedCommands(self, workspace) {
453
464
  env: ctx.env,
454
465
  onStdout: textSink((d) => ctx.stdout.write(d)),
455
466
  onStderr: textSink((d) => ctx.stderr.write(d)),
467
+ // The script runs as the process that ran `bun run`, as an
468
+ // `npm run` script does, not as the workspace shell.
469
+ commandContext: { pid: ctx.pid, cred: ctx.cred, setUmask: ctx.setUmask },
456
470
  });
457
471
  return shellResult.exitCode;
458
472
  }
@@ -590,11 +604,13 @@ export async function registerHostedCommands(self, workspace) {
590
604
  ctx.stderr.write(`Unknown command: ${args[0]}. Use "${invokedAs} dev" or "${invokedAs} --help".\n`);
591
605
  return 1;
592
606
  }
607
+ // Its first build waits on the build facet: start loading it now.
608
+ prewarmBuildFacet(self.ctx, self.env);
593
609
  // First-run banner — only when invoked as `wrangler`, and only once
594
610
  // per session. Makes it OBVIOUS to the user that they're not running
595
611
  // real wrangler, and that Nimbus is doing something different.
596
612
  if (invokedAs === 'wrangler' && !self.wranglerAliasBannerShown) {
597
- ctx.stdout.write('\x1b[2m\u2388 wrangler (Nimbus DO-in-DO mode) — bundling via esbuild-wasm, running via env.LOADER\x1b[0m\n');
613
+ ctx.stdout.write('\x1b[2m\u2388 wrangler (Nimbus DO-in-DO mode) — bundling via rolldown, running via env.LOADER\x1b[0m\n');
598
614
  self.wranglerAliasBannerShown = true;
599
615
  }
600
616
  // Report ignored flags (also one-shot — if user sees it once per
@@ -1279,7 +1295,7 @@ export async function registerHostedCommands(self, workspace) {
1279
1295
  }
1280
1296
  const cmd = getNpxCommandWord(npxArgs);
1281
1297
  // Check if it's a built-in command (vite, esbuild, etc.)
1282
- const resolved = cmd ? await registry.resolve(cmd, { cwd: ctx.cwd }) : null;
1298
+ const resolved = cmd ? await registry.resolve(cmd, resolveContext(ctx.cwd, ctx.env, ctx.vfs)) : null;
1283
1299
  if (resolved) {
1284
1300
  return await resolved({ ...ctx, args: getNpxCommandArgs(npxArgs) });
1285
1301
  }
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"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7C,sGAAsG;sBACrF,kBAAkB;wBAIf,iBAAiB;wBACjB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAjCV,MAAM,YAAY,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAiBrC,SAAS;wBACV,SAAS,WAAW,MAAM,GAAG,WAAW;;;;;GAkB/D;AAED,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC"}
@@ -3,7 +3,7 @@ import { ProcessView } from '@nimbus-sh/core/runtime/process-files.js';
3
3
  import { SUPERVISOR_OP_ROUTES, createSupervisorBridgeStore } from '@nimbus-sh/core/workspace/supervisor-op.js';
4
4
  import { openSupervisorDeliveries } from '@nimbus-sh/core/workspace/supervisor-delivery.js';
5
5
  import { WebSocketTerminal } from '../facets/ws-terminal.js';
6
- import { buildSessionSupervisorOps } from '../session/supervisor-op.js';
6
+ import { answerSupervisorOp, buildSessionSupervisorOps } from '../session/supervisor-op.js';
7
7
  import { armLogJanitor, armResidentKeepalive, installLogPersistence, logJanitorFired, noteResidentClient, residentKeepaliveFired } from '../session/hibernation.js';
8
8
  import { takeLegacyResetNotice } from '../session/legacy-reset.js';
9
9
  import { appendScrollback, ensureSessionStateSchema, loadScrollback, loadShellState, persistShellState } from '../session/state-store.js';
@@ -26,7 +26,7 @@ class RuntimeOwner {
26
26
  options;
27
27
  terminal;
28
28
  _cpRegistry;
29
- _programmaticShellQueues = new Map();
29
+ _storedShellsAdopted;
30
30
  _hostedProcesses = new Map();
31
31
  _hostedProcessWaiters = new Map();
32
32
  _cirrusHmrWsClients = new Map();
@@ -92,6 +92,7 @@ class RuntimeOwner {
92
92
  get ctx() { return this.options.ctx; }
93
93
  get _w1SessionDestroyed() { return this.closing !== null; }
94
94
  get env() { return this.options.env; }
95
+ get runtimeWorkspace() { return this.options.workspace; }
95
96
  get sqliteFs() { return this.options.workspace.vfs; }
96
97
  get kernel() { return this.options.workspace.kernel; }
97
98
  get shell() { return this.options.workspace.shell; }
@@ -186,7 +187,11 @@ class RuntimeOwner {
186
187
  })));
187
188
  return this.supervisor;
188
189
  }
190
+ /** What host stubs call: an answer leaving the runtime, counted (answerSupervisorOp). */
189
191
  supervisorOp(envelope) {
192
+ return answerSupervisorOp((served) => this.serveSupervisorOp(served), envelope);
193
+ }
194
+ serveSupervisorOp(envelope) {
190
195
  this.assertOpen();
191
196
  return this.supervisorOps().dispatch(envelope);
192
197
  }
@@ -1,6 +1,6 @@
1
1
  import { type ComposedFacetManager, type FacetManagerHostHooks } from "../facets/compose.js";
2
2
  import { type NimbusFilesystemAuthority } from "@nimbus-sh/core/runtime/os-contracts.js";
3
- import { EsbuildBundlePool } from "../facets/esbuild-bundle-pool.js";
3
+ import { PrebundlePool } from "../facets/prebundle-pool.js";
4
4
  import type { NpmInstaller } from "../npm/installer.js";
5
5
  import { WebSocketRelay } from "../session/ws-relay.js";
6
6
  import type { SessionInternal } from '../session/internal.js';
@@ -28,7 +28,7 @@ export interface RuntimeServiceContext {
28
28
  /** The host's own authority: a session has exactly one, and this is it. */
29
29
  filesystem: () => NimbusFilesystemAuthority;
30
30
  }
31
- export declare function ensureBundlePool(self: RuntimeServiceHost, runtimeContext: RuntimeServiceContext): EsbuildBundlePool;
31
+ export declare function ensureBundlePool(self: RuntimeServiceHost, runtimeContext: RuntimeServiceContext): PrebundlePool;
32
32
  export declare function ensureFacetManager(self: RuntimeServiceHost, runtimeContext: RuntimeServiceContext): ComposedFacetManager;
33
33
  export declare function _ensureWebSocketRelay(self: RuntimeServiceHost, runtimeContext: RuntimeServiceContext): WebSocketRelay;
34
34
  export declare function _ensureFacetProcessManager(self: RuntimeServiceHost, runtimeContext: RuntimeServiceContext): any;
@@ -38,7 +38,7 @@ export declare function ensureNpmInstaller(self: RuntimeServiceHost, runtimeCont
38
38
  export declare function _envFlagDefaultOn(self: RuntimeServiceHost, runtimeContext: RuntimeServiceContext, name: string): boolean;
39
39
  export declare function ensureGlobalPrefixDirs(self: RuntimeServiceHost, runtimeContext: RuntimeServiceContext, prefix: string): void;
40
40
  export declare function bindRuntimeServices(host: RuntimeServiceHost, context: RuntimeServiceContext): {
41
- ensureBundlePool: () => EsbuildBundlePool;
41
+ ensureBundlePool: () => PrebundlePool;
42
42
  ensureFacetManager: () => ComposedFacetManager;
43
43
  _ensureWebSocketRelay: () => WebSocketRelay;
44
44
  _ensureFacetProcessManager: () => any;