@nimbus-sh/worker 0.9.0 → 0.11.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 (286) hide show
  1. package/NOTICE.md +5 -0
  2. package/README.md +10 -0
  3. package/dist/_shared/session-router.d.ts +7 -0
  4. package/dist/_shared/session-router.d.ts.map +1 -1
  5. package/dist/_shared/session-router.js +7 -0
  6. package/dist/bindings/body.d.ts +6 -0
  7. package/dist/bindings/body.d.ts.map +1 -0
  8. package/dist/bindings/body.js +37 -0
  9. package/dist/bindings/kv.d.ts +0 -2
  10. package/dist/bindings/kv.d.ts.map +1 -1
  11. package/dist/bindings/kv.js +3 -42
  12. package/dist/bindings/r2.d.ts +0 -2
  13. package/dist/bindings/r2.d.ts.map +1 -1
  14. package/dist/bindings/r2.js +4 -44
  15. package/dist/esbuild-cli-artifact.generated.d.ts +18 -0
  16. package/dist/esbuild-cli-artifact.generated.d.ts.map +1 -0
  17. package/dist/esbuild-cli-artifact.generated.js +17 -0
  18. package/dist/esbuild-wasm-bundle.generated.d.ts +24 -24
  19. package/dist/esbuild-wasm-bundle.generated.d.ts.map +1 -1
  20. package/dist/esbuild-wasm-bundle.generated.js +24 -24
  21. package/dist/facets/cirrus-real.d.ts.map +1 -1
  22. package/dist/facets/cirrus-real.js +11 -6
  23. package/dist/facets/compose.d.ts +11 -7
  24. package/dist/facets/compose.d.ts.map +1 -1
  25. package/dist/facets/compose.js +8 -31
  26. package/dist/facets/data-plan.d.ts +79 -0
  27. package/dist/facets/data-plan.d.ts.map +1 -0
  28. package/dist/facets/data-plan.js +477 -0
  29. package/dist/facets/esbuild-bundle-pool.d.ts +1 -1
  30. package/dist/facets/esbuild-bundle-pool.js +3 -3
  31. package/dist/facets/esbuild-transform.d.ts +38 -8
  32. package/dist/facets/esbuild-transform.d.ts.map +1 -1
  33. package/dist/facets/esbuild-transform.js +219 -19
  34. package/dist/facets/exec-telemetry.d.ts +7 -3
  35. package/dist/facets/exec-telemetry.d.ts.map +1 -1
  36. package/dist/facets/manager.d.ts +198 -69
  37. package/dist/facets/manager.d.ts.map +1 -1
  38. package/dist/facets/manager.js +1276 -652
  39. package/dist/facets/opencode-staging.d.ts +0 -2
  40. package/dist/facets/opencode-staging.d.ts.map +1 -1
  41. package/dist/facets/opencode-staging.js +5 -11
  42. package/dist/facets/process.d.ts +4 -0
  43. package/dist/facets/process.d.ts.map +1 -1
  44. package/dist/facets/process.js +3 -0
  45. package/dist/facets/read-profile.d.ts +149 -0
  46. package/dist/facets/read-profile.d.ts.map +1 -0
  47. package/dist/facets/read-profile.js +483 -0
  48. package/dist/facets/real-vite-hmr.d.ts +2 -0
  49. package/dist/facets/real-vite-hmr.d.ts.map +1 -1
  50. package/dist/facets/real-vite-hmr.js +3 -2
  51. package/dist/facets/resident-identity.d.ts +0 -1
  52. package/dist/facets/resident-identity.d.ts.map +1 -1
  53. package/dist/facets/resident-identity.js +0 -3
  54. package/dist/facets/wasm-swap-registry.d.ts +34 -25
  55. package/dist/facets/wasm-swap-registry.d.ts.map +1 -1
  56. package/dist/facets/wasm-swap-registry.js +62 -56
  57. package/dist/facets/ws-terminal.d.ts +4 -4
  58. package/dist/facets/ws-terminal.d.ts.map +1 -1
  59. package/dist/facets/ws-terminal.js +4 -5
  60. package/dist/git/commands.d.ts +33 -10
  61. package/dist/git/commands.d.ts.map +1 -1
  62. package/dist/git/commands.js +1891 -197
  63. package/dist/git/network-facet.d.ts +12 -2
  64. package/dist/git/network-facet.d.ts.map +1 -1
  65. package/dist/git/network-facet.js +69 -18
  66. package/dist/git/unified-diff.d.ts +74 -0
  67. package/dist/git/unified-diff.d.ts.map +1 -0
  68. package/dist/git/unified-diff.js +676 -0
  69. package/dist/git-bundle.generated.d.ts +7 -11
  70. package/dist/git-bundle.generated.d.ts.map +1 -1
  71. package/dist/git-bundle.generated.js +7 -11
  72. package/dist/hosted/commands.d.ts.map +1 -1
  73. package/dist/hosted/commands.js +64 -245
  74. package/dist/hosted/runtime.d.ts +22 -15
  75. package/dist/hosted/runtime.d.ts.map +1 -1
  76. package/dist/hosted/runtime.js +72 -14
  77. package/dist/hosted/services.d.ts +8 -1
  78. package/dist/hosted/services.d.ts.map +1 -1
  79. package/dist/hosted/services.js +12 -13
  80. package/dist/hosted/session.d.ts +165 -0
  81. package/dist/hosted/session.d.ts.map +1 -0
  82. package/dist/hosted/session.js +132 -0
  83. package/dist/loaders/generated-workers.d.ts +6 -3
  84. package/dist/loaders/generated-workers.d.ts.map +1 -1
  85. package/dist/loaders/generated-workers.js +8 -5
  86. package/dist/loaders/npm-resolve-preamble.d.ts.map +1 -1
  87. package/dist/loaders/npm-resolve-preamble.js +0 -27
  88. package/dist/loaders/pre-bundle-preamble.d.ts +6 -3
  89. package/dist/loaders/pre-bundle-preamble.d.ts.map +1 -1
  90. package/dist/loaders/pre-bundle-preamble.js +13 -8
  91. package/dist/node-shims-artifact.generated.d.ts +13 -4
  92. package/dist/node-shims-artifact.generated.d.ts.map +1 -1
  93. package/dist/node-shims-artifact.generated.js +16 -7
  94. package/dist/npm/bin-links.d.ts +3 -1
  95. package/dist/npm/bin-links.d.ts.map +1 -1
  96. package/dist/npm/bin-links.js +32 -8
  97. package/dist/npm/cache.d.ts +11 -1
  98. package/dist/npm/cache.d.ts.map +1 -1
  99. package/dist/npm/cache.js +21 -7
  100. package/dist/npm/install-batch-facet.d.ts +4 -2
  101. package/dist/npm/install-batch-facet.d.ts.map +1 -1
  102. package/dist/npm/install-batch-facet.js +32 -18
  103. package/dist/npm/installer.d.ts +23 -3
  104. package/dist/npm/installer.d.ts.map +1 -1
  105. package/dist/npm/installer.js +330 -131
  106. package/dist/npm/npx-install.d.ts +3 -1
  107. package/dist/npm/npx-install.d.ts.map +1 -1
  108. package/dist/npm/npx-install.js +4 -1
  109. package/dist/npm/package-lock.d.ts +32 -0
  110. package/dist/npm/package-lock.d.ts.map +1 -0
  111. package/dist/npm/package-lock.js +65 -0
  112. package/dist/npm/placement.d.ts +16 -0
  113. package/dist/npm/placement.d.ts.map +1 -0
  114. package/dist/npm/placement.js +33 -0
  115. package/dist/npm/pre-bundle-facet.d.ts +1 -30
  116. package/dist/npm/pre-bundle-facet.d.ts.map +1 -1
  117. package/dist/npm/pre-bundle-facet.js +3 -5
  118. package/dist/npm/r2-cache.d.ts +12 -6
  119. package/dist/npm/r2-cache.d.ts.map +1 -1
  120. package/dist/npm/r2-cache.js +34 -16
  121. package/dist/npm/resolve-one-facet.d.ts +3 -0
  122. package/dist/npm/resolve-one-facet.d.ts.map +1 -1
  123. package/dist/npm/resolve-one-facet.js +15 -3
  124. package/dist/npm/resolver.d.ts +11 -13
  125. package/dist/npm/resolver.d.ts.map +1 -1
  126. package/dist/npm/resolver.js +12 -25
  127. package/dist/opencode-artifact.generated.js +2 -2
  128. package/dist/replica/routing.d.ts +2 -38
  129. package/dist/replica/routing.d.ts.map +1 -1
  130. package/dist/replica/routing.js +3 -55
  131. package/dist/router/index.d.ts.map +1 -1
  132. package/dist/router/index.js +15 -2
  133. package/dist/router/public-directory.d.ts +18 -0
  134. package/dist/router/public-directory.d.ts.map +1 -1
  135. package/dist/router/public-directory.js +1 -1
  136. package/dist/router/remote-api.d.ts +3 -1
  137. package/dist/router/remote-api.d.ts.map +1 -1
  138. package/dist/router/remote-api.js +42 -79
  139. package/dist/runtime/bash-repl.js +2 -2
  140. package/dist/runtime/bun-repl.d.ts.map +1 -1
  141. package/dist/runtime/bun-repl.js +2 -13
  142. package/dist/runtime/cpython-resident.d.ts.map +1 -1
  143. package/dist/runtime/cpython-resident.js +2 -10
  144. package/dist/runtime/esbuild-wasm-bytes.d.ts +37 -18
  145. package/dist/runtime/esbuild-wasm-bytes.d.ts.map +1 -1
  146. package/dist/runtime/esbuild-wasm-bytes.js +66 -92
  147. package/dist/runtime/facet-loader-host.d.ts.map +1 -1
  148. package/dist/runtime/facet-loader-host.js +0 -7
  149. package/dist/runtime/git-bundle-artifact.d.ts +17 -0
  150. package/dist/runtime/git-bundle-artifact.d.ts.map +1 -0
  151. package/dist/runtime/git-bundle-artifact.js +25 -0
  152. package/dist/runtime/node-repl.d.ts.map +1 -1
  153. package/dist/runtime/node-repl.js +2 -13
  154. package/dist/runtime/node-shims-artifact.d.ts +22 -23
  155. package/dist/runtime/node-shims-artifact.d.ts.map +1 -1
  156. package/dist/runtime/node-shims-artifact.js +48 -78
  157. package/dist/runtime/node-shims.d.ts.map +1 -1
  158. package/dist/runtime/node-shims.js +2358 -996
  159. package/dist/runtime/opencode-artifact.d.ts.map +1 -1
  160. package/dist/runtime/opencode-artifact.js +17 -53
  161. package/dist/runtime/opencode-facet-runner.d.ts +3 -6
  162. package/dist/runtime/opencode-facet-runner.d.ts.map +1 -1
  163. package/dist/runtime/opencode-facet-runner.js +45 -10
  164. package/dist/runtime/opentui-wasm-bytes.d.ts.map +1 -1
  165. package/dist/runtime/opentui-wasm-bytes.js +16 -49
  166. package/dist/runtime/package-manager.d.ts +0 -2
  167. package/dist/runtime/package-manager.d.ts.map +1 -1
  168. package/dist/runtime/package-manager.js +0 -3
  169. package/dist/runtime/python-repl.d.ts.map +1 -1
  170. package/dist/runtime/python-repl.js +4 -35
  171. package/dist/runtime/repl-session.d.ts +10 -0
  172. package/dist/runtime/repl-session.d.ts.map +1 -1
  173. package/dist/runtime/repl-session.js +7 -0
  174. package/dist/runtime/ruby-repl.d.ts.map +1 -1
  175. package/dist/runtime/ruby-repl.js +2 -2
  176. package/dist/runtime/ruby-resident.d.ts.map +1 -1
  177. package/dist/runtime/ruby-resident.js +41 -51
  178. package/dist/runtime/runtime-catalog.d.ts +10 -3
  179. package/dist/runtime/runtime-catalog.d.ts.map +1 -1
  180. package/dist/runtime/runtime-catalog.js +125 -15
  181. package/dist/runtime/sqlite-wasm-bytes.d.ts +4 -4
  182. package/dist/runtime/sqlite-wasm-bytes.d.ts.map +1 -1
  183. package/dist/runtime/sqlite-wasm-bytes.js +21 -57
  184. package/dist/runtime/staged-source.d.ts +67 -0
  185. package/dist/runtime/staged-source.d.ts.map +1 -0
  186. package/dist/runtime/staged-source.js +113 -0
  187. package/dist/runtime/wasi/preamble.d.ts +0 -22
  188. package/dist/runtime/wasi/preamble.d.ts.map +1 -1
  189. package/dist/runtime/wasi/preamble.js +98 -1425
  190. package/dist/runtime-catalog.generated.js +1 -1
  191. package/dist/session/agent.d.ts +14 -2
  192. package/dist/session/agent.d.ts.map +1 -1
  193. package/dist/session/agent.js +57 -19
  194. package/dist/session/ai.d.ts +0 -11
  195. package/dist/session/ai.d.ts.map +1 -1
  196. package/dist/session/ai.js +0 -4
  197. package/dist/session/fs-watch.d.ts +0 -11
  198. package/dist/session/fs-watch.d.ts.map +1 -1
  199. package/dist/session/fs-watch.js +0 -21
  200. package/dist/session/hibernation.d.ts +68 -2
  201. package/dist/session/hibernation.d.ts.map +1 -1
  202. package/dist/session/hibernation.js +95 -1
  203. package/dist/session/init-phases.d.ts +1 -2
  204. package/dist/session/init-phases.d.ts.map +1 -1
  205. package/dist/session/init-phases.js +1 -2
  206. package/dist/session/init.d.ts.map +1 -1
  207. package/dist/session/init.js +7 -20
  208. package/dist/session/keys.d.ts +0 -3
  209. package/dist/session/keys.d.ts.map +1 -1
  210. package/dist/session/keys.js +0 -3
  211. package/dist/session/legacy-reset.d.ts +11 -0
  212. package/dist/session/legacy-reset.d.ts.map +1 -0
  213. package/dist/session/legacy-reset.js +16 -0
  214. package/dist/session/nimbus-session.d.ts +50 -16
  215. package/dist/session/nimbus-session.d.ts.map +1 -1
  216. package/dist/session/nimbus-session.js +77 -71
  217. package/dist/session/npm-install-port.d.ts.map +1 -1
  218. package/dist/session/npm-install-port.js +2 -0
  219. package/dist/session/programmatic.d.ts +13 -18
  220. package/dist/session/programmatic.d.ts.map +1 -1
  221. package/dist/session/programmatic.js +53 -39
  222. package/dist/session/replica-routes.d.ts +2 -3
  223. package/dist/session/replica-routes.d.ts.map +1 -1
  224. package/dist/session/replica-routes.js +3 -10
  225. package/dist/session/routes.d.ts.map +1 -1
  226. package/dist/session/routes.js +11 -12
  227. package/dist/session/rpc.d.ts +108 -21
  228. package/dist/session/rpc.d.ts.map +1 -1
  229. package/dist/session/rpc.js +194 -39
  230. package/dist/session/start-real-vite.js +2 -2
  231. package/dist/session/state-store.d.ts +1 -17
  232. package/dist/session/state-store.d.ts.map +1 -1
  233. package/dist/session/state-store.js +3 -53
  234. package/dist/session/supervisor-op.d.ts +7 -0
  235. package/dist/session/supervisor-op.d.ts.map +1 -1
  236. package/dist/session/supervisor-op.js +6 -1
  237. package/dist/session/supervisor-rpc.d.ts +116 -19
  238. package/dist/session/supervisor-rpc.d.ts.map +1 -1
  239. package/dist/session/supervisor-rpc.js +194 -84
  240. package/dist/session/vite-command.d.ts.map +1 -1
  241. package/dist/session/vite-command.js +17 -14
  242. package/dist/session/ws.d.ts.map +1 -1
  243. package/dist/session/ws.js +20 -8
  244. package/dist/shell/npm-bin-entrypoints.d.ts.map +1 -1
  245. package/dist/shell/npm-bin-entrypoints.js +30 -5
  246. package/dist/vfs/facet-resident-limits.d.ts +33 -0
  247. package/dist/vfs/facet-resident-limits.d.ts.map +1 -0
  248. package/dist/vfs/facet-resident-limits.js +33 -0
  249. package/dist/vfs/facet-resident-store.d.ts +2 -10
  250. package/dist/vfs/facet-resident-store.d.ts.map +1 -1
  251. package/dist/vfs/facet-resident-store.js +1594 -219
  252. package/dist/workspace-host.d.ts +3 -1
  253. package/dist/workspace-host.d.ts.map +1 -1
  254. package/dist/workspace-host.js +2 -0
  255. package/dist/wrangler/nimbus-wrangler.d.ts +0 -2
  256. package/dist/wrangler/nimbus-wrangler.d.ts.map +1 -1
  257. package/dist/wrangler/nimbus-wrangler.js +8 -22
  258. package/package.json +34 -7
  259. package/public/_assets/esbuild-0.24.2.js +2380 -0
  260. package/public/_assets/opencode/1.16.2/index-attach.js +2 -2
  261. package/public/_assets/runtime/esbuild-cli-c4fda380d52befc1.js +6892 -0
  262. package/public/_assets/runtime/git-de3e60c9f3ff006a.js +103 -0
  263. package/public/_assets/runtime/{node-shims-acaa037e6d26ec0d.js → node-shims-06565b121555c194.js} +2879 -992
  264. package/public/_assets/runtime/resident-store-6ffb1939c53d982f.js +2264 -0
  265. package/public/_assets/runtime/vfs-write-ledger-e501e8fc793bc2c1.js +889 -0
  266. package/scripts/build-opencode-attach-entry.mjs +51 -1
  267. package/scripts/bundle-esbuild-wasm.mjs +55 -39
  268. package/scripts/bundle-facet-workers.mjs +159 -10
  269. package/scripts/bundle-git.mjs +88 -27
  270. package/scripts/bundle-node-shims.mjs +72 -46
  271. package/scripts/bundle-runtime.mjs +18 -421
  272. package/scripts/cf-git-patch.mjs +137 -0
  273. package/scripts/patch-install-deps.mjs +49 -96
  274. package/scripts/runtime-specs.mjs +435 -0
  275. package/vendor/git-http.generated.d.ts +82 -0
  276. package/vendor/git-upstream.generated.d.ts +4378 -0
  277. package/vendor/git.LICENSE +7 -0
  278. package/vendor/git.generated.d.mts +21 -0
  279. package/vendor/git.generated.mjs +103 -0
  280. package/dist/replica/suspension.d.ts +0 -36
  281. package/dist/replica/suspension.d.ts.map +0 -1
  282. package/dist/replica/suspension.js +0 -49
  283. package/dist/runtime/static-server.d.ts +0 -3
  284. package/dist/runtime/static-server.d.ts.map +0 -1
  285. package/dist/runtime/static-server.js +0 -133
  286. package/scripts/clean-dist.mjs +0 -7
@@ -1 +1 @@
1
- {"version":3,"file":"cpython-resident.d.ts","sourceRoot":"","sources":["../../src/runtime/cpython-resident.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAwDxE;AAeD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,YAAY,GAAG,oBAAoB,CAgDjF"}
1
+ {"version":3,"file":"cpython-resident.d.ts","sourceRoot":"","sources":["../../src/runtime/cpython-resident.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAgDxE;AAeD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,YAAY,GAAG,oBAAoB,CAgDjF"}
@@ -38,14 +38,6 @@ export function buildCPythonSocketProcessWorker(preamble) {
38
38
  ' if (supervisor) globalThis.__nimbusPySupervisor = supervisor;',
39
39
  ' __wasiAdoptSupervisor(supervisor);',
40
40
  '}',
41
- // A resident process answers between requests, and that is the only moment
42
- // "durable while running" can be made true: by the time the caller holds a
43
- // response, everything the request wrote has reached the VFS.
44
- 'async function __nimbusParkPy(value) {',
45
- ' await __wasiDrainPersist();',
46
- ' await __wasiRevalidateFS();',
47
- ' return value;',
48
- '}',
49
41
  'async function __nimbusStartPyProcess(args) {',
50
42
  ' const result = await globalThis.__cpythonStartProcess(args || {});',
51
43
  ' const ports = await globalThis.__cpythonListeningPorts();',
@@ -59,7 +51,7 @@ export function buildCPythonSocketProcessWorker(preamble) {
59
51
  'export class NimbusProcess extends DurableObject {',
60
52
  ' async startProcess(args) {',
61
53
  ' __nimbusAdoptPySupervisor(this.env);',
62
- ' return __nimbusParkPy(await __nimbusStartPyProcess(args || {}));',
54
+ ' return __nimbusStartPyProcess(args || {});',
63
55
  ' }',
64
56
  ' async fetch(request) {',
65
57
  ' __nimbusAdoptPySupervisor(this.env);',
@@ -70,7 +62,7 @@ export function buildCPythonSocketProcessWorker(preamble) {
70
62
  ' const hinted = Number(request.headers.get("X-Nimbus-Port") || 0);',
71
63
  ' const port = hinted || Array.from(globalThis.__nimbusVirtualSockets.listeners.keys())[0];',
72
64
  ' if (!port) return new Response("Nimbus Python process has no listening virtual socket", { status: 502 });',
73
- ' return __nimbusParkPy(await globalThis.__nimbusVirtualSockets.handleHttpRequest(port, request));',
65
+ ' return globalThis.__nimbusVirtualSockets.handleHttpRequest(port, request);',
74
66
  ' }',
75
67
  '}',
76
68
  ].join('\n');
@@ -1,14 +1,16 @@
1
1
  /**
2
- * esbuild-wasm-bytes.ts — supervisor-side fetcher for the esbuild-wasm
3
- * binary. The bytes live in the static-assets layer (env.ASSETS); this
4
- * module hands them to the caller as an ArrayBuffer when needed.
2
+ * esbuild-wasm-bytes.ts — supervisor-side fetcher for the artifacts the
3
+ * esbuild facet is built from: the wasm binary, the JS adapter that drives
4
+ * it, and the runner of the `esbuild` command. All three live in the
5
+ * static-assets layer (env.ASSETS); this module hands them to the caller when
6
+ * needed.
5
7
  *
6
8
  * Cache strategy
7
9
  * ──────────────
8
10
  * - NO module-scope cache (would pin 16 MiB in supervisor heap; the
9
11
  * reason this module exists, see Phase 2 A'.5 below).
10
12
  * - L2 colo cache via `caches.default` (cache-and-scrub W-D): the bytes
11
- * are version-pinned by URL (`/_assets/esbuild-<ESBUILD_VERSION>.wasm`),
13
+ * are version-pinned by URL (`/_assets/esbuild-<ESBUILD_VERSION>.*`),
12
14
  * so an `immutable` cache entry is correct. The Cache API holds its
13
15
  * OWN reference outside the supervisor heap, so this does not
14
16
  * re-introduce the residency that A'.5 removed.
@@ -28,6 +30,14 @@
28
30
  * are stored OUTSIDE the supervisor heap (workerd manages them), so
29
31
  * adding L2 wrap doesn't undo this.
30
32
  *
33
+ * The JS adapter followed the wasm for the same reason at a smaller
34
+ * scale: the supervisor already imports esbuild-wasm's browser build as a
35
+ * module for its own transforms, so carrying the same 117 KiB again as a
36
+ * string literal for facets doubled it in the Worker bundle. The CLI runner
37
+ * (32 KiB of Go glue and fs shim) only ever runs in the facet, so it is
38
+ * staged too; its name carries a prefix of its digest, because unlike the
39
+ * other two it changes without an esbuild upgrade.
40
+ *
31
41
  * Each call to `fetchEsbuildWasmBytes(env)` now does:
32
42
  * - one `caches.default.match()` — sub-millisecond on hit
33
43
  * - on miss: one env.ASSETS.fetch() + one cache write-back
@@ -39,16 +49,9 @@
39
49
  * Cache lookup failure (any throw) → fall through to ASSETS.
40
50
  * ASSETS fetch returning non-200 → throw (deploy bug, surface loudly).
41
51
  * Digest mismatch on either tier → throw (the bytes are compiled as a wasm
42
- * module, so they are verified against ESBUILD_WASM_SHA256 before returning).
43
- */
44
- /**
45
- * Path inside env.ASSETS where the esbuild-wasm binary lives.
46
- * Versioned so a future esbuild-wasm bump produces a different asset
47
- * name and forces a fresh fetch (no stale-cache risk). The matching
48
- * file is staged at public/_assets/esbuild-<version>.wasm by
49
- * scripts/bundle-esbuild-wasm.mjs at predeploy time.
52
+ * module or evaluated as facet code, so they are verified against the
53
+ * digest the generator recorded before returning).
50
54
  */
51
- export declare const ESBUILD_WASM_ASSET_PATH = "/_assets/esbuild-0.24.2.wasm";
52
55
  /**
53
56
  * The minimal env shape this module needs. Defined narrowly so the
54
57
  * caller can pass any env with an ASSETS Fetcher binding without
@@ -60,16 +63,20 @@ export interface EsbuildWasmFetchEnv {
60
63
  };
61
64
  }
62
65
  /**
63
- * Synthetic L2 cache key for the esbuild-wasm asset. Versioned via
64
- * ESBUILD_WASM_ASSET_PATH so each esbuild upgrade lands a fresh entry
65
- * and old entries naturally evict on TTL.
66
+ * Synthetic L2 cache keys for the esbuild-wasm assets, staged at
67
+ * public/_assets/esbuild-<version>.{wasm,js} by scripts/bundle-esbuild-wasm.mjs
68
+ * at predeploy time. Versioned via the asset paths so each esbuild upgrade
69
+ * lands fresh entries and old ones naturally evict on TTL.
66
70
  *
67
71
  * Exported so the test endpoint at /api/_test/cache/wasm/reset can
68
- * purge the entry between probe runs (otherwise wrangler dev's
72
+ * purge the entries between probe runs (otherwise wrangler dev's
69
73
  * persistent caches.default.state preserves the L2 hit across sessions
70
74
  * and the cold path is unobservable).
71
75
  */
72
- export declare const ESBUILD_WASM_L2_KEY = "https://nimbus-cache.invalid/_assets/esbuild-0.24.2.wasm";
76
+ export declare const ESBUILD_WASM_L2_KEY: string;
77
+ export declare const ESBUILD_JS_L2_KEY: string;
78
+ /** The CLI runner's key names its build id, so each rebuild lands a fresh entry. */
79
+ export declare const ESBUILD_CLI_L2_KEY: string;
73
80
  /**
74
81
  * Fetch the esbuild-wasm bytes from the static-assets layer.
75
82
  *
@@ -84,4 +91,16 @@ export declare const ESBUILD_WASM_L2_KEY = "https://nimbus-cache.invalid/_assets
84
91
  * always the correct source of truth.
85
92
  */
86
93
  export declare function fetchEsbuildWasmBytes(env: EsbuildWasmFetchEnv): Promise<ArrayBuffer>;
94
+ /**
95
+ * Fetch the esbuild-wasm JS adapter: the function body that, wrapped in
96
+ * `new Function(...)()`, returns the esbuild namespace. Facet sources
97
+ * splice it in verbatim, so it is verified like the wasm it drives.
98
+ */
99
+ export declare function fetchEsbuildJsFnBody(env: EsbuildWasmFetchEnv): Promise<string>;
100
+ /**
101
+ * Fetch the `esbuild` command's runner: Go's wasm_exec.js and the typed fs
102
+ * shim, a script that installs `globalThis.__esbuildCliRun` when the esbuild
103
+ * facet evaluates it. Verified like the adapter it sits beside.
104
+ */
105
+ export declare function fetchEsbuildCliRunner(env: EsbuildWasmFetchEnv): Promise<string>;
87
106
  //# sourceMappingURL=esbuild-wasm-bytes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"esbuild-wasm-bytes.d.ts","sourceRoot":"","sources":["../../src/runtime/esbuild-wasm-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAOH;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,iCAA6C,CAAC;AAElF;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE;QAAE,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;KAAE,CAAC;CACpD;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,6DAAyE,CAAC;AAE1G;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC,CA2E1F"}
1
+ {"version":3,"file":"esbuild-wasm-bytes.d.ts","sourceRoot":"","sources":["../../src/runtime/esbuild-wasm-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAWH;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE;QAAE,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;KAAE,CAAC;CACpD;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,QAA2D,CAAC;AAC5F,eAAO,MAAM,iBAAiB,QAAyD,CAAC;AACxF,oFAAoF;AACpF,eAAO,MAAM,kBAAkB,QAA0D,CAAC;AAmC1F;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC,CAEpF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAE9E;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAE/E"}
@@ -1,14 +1,16 @@
1
1
  /**
2
- * esbuild-wasm-bytes.ts — supervisor-side fetcher for the esbuild-wasm
3
- * binary. The bytes live in the static-assets layer (env.ASSETS); this
4
- * module hands them to the caller as an ArrayBuffer when needed.
2
+ * esbuild-wasm-bytes.ts — supervisor-side fetcher for the artifacts the
3
+ * esbuild facet is built from: the wasm binary, the JS adapter that drives
4
+ * it, and the runner of the `esbuild` command. All three live in the
5
+ * static-assets layer (env.ASSETS); this module hands them to the caller when
6
+ * needed.
5
7
  *
6
8
  * Cache strategy
7
9
  * ──────────────
8
10
  * - NO module-scope cache (would pin 16 MiB in supervisor heap; the
9
11
  * reason this module exists, see Phase 2 A'.5 below).
10
12
  * - L2 colo cache via `caches.default` (cache-and-scrub W-D): the bytes
11
- * are version-pinned by URL (`/_assets/esbuild-<ESBUILD_VERSION>.wasm`),
13
+ * are version-pinned by URL (`/_assets/esbuild-<ESBUILD_VERSION>.*`),
12
14
  * so an `immutable` cache entry is correct. The Cache API holds its
13
15
  * OWN reference outside the supervisor heap, so this does not
14
16
  * re-introduce the residency that A'.5 removed.
@@ -28,6 +30,14 @@
28
30
  * are stored OUTSIDE the supervisor heap (workerd manages them), so
29
31
  * adding L2 wrap doesn't undo this.
30
32
  *
33
+ * The JS adapter followed the wasm for the same reason at a smaller
34
+ * scale: the supervisor already imports esbuild-wasm's browser build as a
35
+ * module for its own transforms, so carrying the same 117 KiB again as a
36
+ * string literal for facets doubled it in the Worker bundle. The CLI runner
37
+ * (32 KiB of Go glue and fs shim) only ever runs in the facet, so it is
38
+ * staged too; its name carries a prefix of its digest, because unlike the
39
+ * other two it changes without an esbuild upgrade.
40
+ *
31
41
  * Each call to `fetchEsbuildWasmBytes(env)` now does:
32
42
  * - one `caches.default.match()` — sub-millisecond on hit
33
43
  * - on miss: one env.ASSETS.fetch() + one cache write-back
@@ -39,31 +49,47 @@
39
49
  * Cache lookup failure (any throw) → fall through to ASSETS.
40
50
  * ASSETS fetch returning non-200 → throw (deploy bug, surface loudly).
41
51
  * Digest mismatch on either tier → throw (the bytes are compiled as a wasm
42
- * module, so they are verified against ESBUILD_WASM_SHA256 before returning).
43
- */
44
- import { ESBUILD_VERSION } from '@nimbus-sh/core/constants.js';
45
- import { ESBUILD_WASM_SHA256 } from '../esbuild-wasm-bundle.generated.js';
46
- import { disposeRpcResource } from '@nimbus-sh/platform/rpc-dispose.js';
47
- import { sha256Hex } from '@nimbus-sh/core/_shared/crypto.js';
48
- /**
49
- * Path inside env.ASSETS where the esbuild-wasm binary lives.
50
- * Versioned so a future esbuild-wasm bump produces a different asset
51
- * name and forces a fresh fetch (no stale-cache risk). The matching
52
- * file is staged at public/_assets/esbuild-<version>.wasm by
53
- * scripts/bundle-esbuild-wasm.mjs at predeploy time.
52
+ * module or evaluated as facet code, so they are verified against the
53
+ * digest the generator recorded before returning).
54
54
  */
55
- export const ESBUILD_WASM_ASSET_PATH = `/_assets/esbuild-${ESBUILD_VERSION}.wasm`;
55
+ import { ESBUILD_JS_ASSET_PATH, ESBUILD_JS_SHA256, ESBUILD_WASM_ASSET_PATH, ESBUILD_WASM_SHA256, } from '../esbuild-wasm-bundle.generated.js';
56
+ import { ESBUILD_CLI_ASSET_PATH, ESBUILD_CLI_SHA256 } from '../esbuild-cli-artifact.generated.js';
57
+ import { fetchStagedBytes, fetchStagedText } from './staged-source.js';
56
58
  /**
57
- * Synthetic L2 cache key for the esbuild-wasm asset. Versioned via
58
- * ESBUILD_WASM_ASSET_PATH so each esbuild upgrade lands a fresh entry
59
- * and old entries naturally evict on TTL.
59
+ * Synthetic L2 cache keys for the esbuild-wasm assets, staged at
60
+ * public/_assets/esbuild-<version>.{wasm,js} by scripts/bundle-esbuild-wasm.mjs
61
+ * at predeploy time. Versioned via the asset paths so each esbuild upgrade
62
+ * lands fresh entries and old ones naturally evict on TTL.
60
63
  *
61
64
  * Exported so the test endpoint at /api/_test/cache/wasm/reset can
62
- * purge the entry between probe runs (otherwise wrangler dev's
65
+ * purge the entries between probe runs (otherwise wrangler dev's
63
66
  * persistent caches.default.state preserves the L2 hit across sessions
64
67
  * and the cold path is unobservable).
65
68
  */
66
- export const ESBUILD_WASM_L2_KEY = `https://nimbus-cache.invalid/_assets/esbuild-${ESBUILD_VERSION}.wasm`;
69
+ export const ESBUILD_WASM_L2_KEY = `https://nimbus-cache.invalid${ESBUILD_WASM_ASSET_PATH}`;
70
+ export const ESBUILD_JS_L2_KEY = `https://nimbus-cache.invalid${ESBUILD_JS_ASSET_PATH}`;
71
+ /** The CLI runner's key names its build id, so each rebuild lands a fresh entry. */
72
+ export const ESBUILD_CLI_L2_KEY = `https://nimbus-cache.invalid${ESBUILD_CLI_ASSET_PATH}`;
73
+ /** One esbuild artifact, verified against its pin (runtime/staged-source.ts). */
74
+ function esbuildAsset(label, path, l2Key, sha256, contentType, stagedBy) {
75
+ return {
76
+ path,
77
+ l2Key,
78
+ sha256,
79
+ contentType,
80
+ poisonedCache: 'reject',
81
+ missingBinding: `Nimbus: the esbuild facet requires an env.ASSETS binding (serves ${path})`,
82
+ fetchFailed: (res) => `${label} asset fetch failed: ${res.status} ${res.statusText} ` +
83
+ `for ${path} — deploy is missing the asset`,
84
+ integrityFailed: (digest, from) => `${label} integrity check failed: expected ${sha256}, got ` +
85
+ `${digest} (${from}) for ${path} — ` +
86
+ 'the staged asset is corrupt or out of sync; rerun ' +
87
+ `${stagedBy} and redeploy`,
88
+ };
89
+ }
90
+ const ESBUILD_WASM_ASSET = esbuildAsset('esbuild-wasm', ESBUILD_WASM_ASSET_PATH, ESBUILD_WASM_L2_KEY, ESBUILD_WASM_SHA256, 'application/wasm', 'scripts/bundle-esbuild-wasm.mjs');
91
+ const ESBUILD_JS_ASSET = esbuildAsset('esbuild-wasm JS adapter', ESBUILD_JS_ASSET_PATH, ESBUILD_JS_L2_KEY, ESBUILD_JS_SHA256, 'text/javascript; charset=utf-8', 'scripts/bundle-esbuild-wasm.mjs');
92
+ const ESBUILD_CLI_ASSET = esbuildAsset('esbuild CLI runner', ESBUILD_CLI_ASSET_PATH, ESBUILD_CLI_L2_KEY, ESBUILD_CLI_SHA256, 'text/javascript; charset=utf-8', 'scripts/bundle-facet-workers.mjs');
67
93
  /**
68
94
  * Fetch the esbuild-wasm bytes from the static-assets layer.
69
95
  *
@@ -77,74 +103,22 @@ export const ESBUILD_WASM_L2_KEY = `https://nimbus-cache.invalid/_assets/esbuild
77
103
  * to env.ASSETS and write-back. Cache failures are silent — ASSETS is
78
104
  * always the correct source of truth.
79
105
  */
80
- export async function fetchEsbuildWasmBytes(env) {
81
- const caches = globalThis.caches;
82
- // ── L2 fast path ────────────────────────────────────────────────
83
- let ab = null;
84
- try {
85
- if (caches?.default) {
86
- const hit = await caches.default.match(new Request(ESBUILD_WASM_L2_KEY));
87
- if (hit && hit.ok)
88
- ab = await hit.arrayBuffer();
89
- }
90
- }
91
- catch { /* fall through to ASSETS */ }
92
- const fromCache = ab !== null;
93
- if (!ab) {
94
- // ── L4 path (env.ASSETS) ──────────────────────────────────────
95
- // Construct a synthetic request — env.ASSETS routes by pathname only;
96
- // the host is ignored. Using `.invalid` per RFC-2606 makes it
97
- // unambiguous that this URL is internal-binding-only.
98
- const url = `https://nimbus-internal.invalid${ESBUILD_WASM_ASSET_PATH}`;
99
- const res = await env.ASSETS.fetch(new Request(url));
100
- try {
101
- if (!res.ok) {
102
- throw new Error(`esbuild-wasm asset fetch failed: ${res.status} ${res.statusText} ` +
103
- `for ${ESBUILD_WASM_ASSET_PATH} — deploy is missing the wasm asset`);
104
- }
105
- // Read the bytes once (Response body is a one-shot stream). The
106
- // caller needs the ArrayBuffer to hand to workerd's LOADER; we
107
- // also use it to write through to L2.
108
- ab = await res.arrayBuffer();
109
- }
110
- finally {
111
- disposeRpcResource(res);
112
- }
113
- }
114
- const digest = await sha256Hex(ab);
115
- if (digest !== ESBUILD_WASM_SHA256) {
116
- throw new Error(`esbuild-wasm integrity check failed: expected ${ESBUILD_WASM_SHA256}, got ` +
117
- `${digest} (${fromCache ? 'L2 cache' : 'ASSETS'}) for ${ESBUILD_WASM_ASSET_PATH} — ` +
118
- 'the staged asset is corrupt or out of sync; rerun ' +
119
- 'scripts/bundle-esbuild-wasm.mjs and redeploy');
120
- }
121
- if (!fromCache) {
122
- // ── L2 write-back ────────────────────────────────────────────
123
- // Eternal immutable TTL: the URL is version-pinned so a new
124
- // ESBUILD_VERSION lands a fresh cache entry; the old one naturally
125
- // evicts on TTL. The cache layer holds its own copy (workerd
126
- // structured-clones the body during put), so the supervisor's
127
- // reference to `ab` is unaffected.
128
- // Best-effort: a write failure does NOT block the caller.
129
- try {
130
- if (caches?.default) {
131
- // We pass a fresh Uint8Array view over the same buffer; the
132
- // cache stores a copy at put time. Returning `ab` to the
133
- // caller stays valid because Response constructor doesn't
134
- // detach the buffer (only ReadableStream consumption would).
135
- const writeBack = new Response(new Uint8Array(ab), {
136
- headers: {
137
- 'Content-Type': 'application/wasm',
138
- 'Cache-Control': 'public, max-age=31536000, immutable',
139
- },
140
- });
141
- // Awaited so subsequent reads strictly hit L2 (no
142
- // double-fetch race). The wasm payload is 12 MiB; workerd
143
- // structured-clones it into the cache, ~1-5 ms locally.
144
- await caches.default.put(new Request(ESBUILD_WASM_L2_KEY), writeBack);
145
- }
146
- }
147
- catch { /* silent */ }
148
- }
149
- return ab;
106
+ export function fetchEsbuildWasmBytes(env) {
107
+ return fetchStagedBytes(env, ESBUILD_WASM_ASSET);
108
+ }
109
+ /**
110
+ * Fetch the esbuild-wasm JS adapter: the function body that, wrapped in
111
+ * `new Function(...)()`, returns the esbuild namespace. Facet sources
112
+ * splice it in verbatim, so it is verified like the wasm it drives.
113
+ */
114
+ export function fetchEsbuildJsFnBody(env) {
115
+ return fetchStagedText(env, ESBUILD_JS_ASSET);
116
+ }
117
+ /**
118
+ * Fetch the `esbuild` command's runner: Go's wasm_exec.js and the typed fs
119
+ * shim, a script that installs `globalThis.__esbuildCliRun` when the esbuild
120
+ * facet evaluates it. Verified like the adapter it sits beside.
121
+ */
122
+ export function fetchEsbuildCliRunner(env) {
123
+ return fetchStagedText(env, ESBUILD_CLI_ASSET);
150
124
  }
@@ -1 +1 @@
1
- {"version":3,"file":"facet-loader-host.d.ts","sourceRoot":"","sources":["../../src/runtime/facet-loader-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAS,SAAS,EAAa,MAAM,uCAAuC,CAAC;AAEzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,kBAAkB,GAAG,SAAS,CAuBhF;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,YAAY,GACrB;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,kBAAkB,CAAA;CAAE,CAM3C;AAED,uEAAuE;AACvE,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAGrE"}
1
+ {"version":3,"file":"facet-loader-host.d.ts","sourceRoot":"","sources":["../../src/runtime/facet-loader-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAS,SAAS,EAAa,MAAM,uCAAuC,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,kBAAkB,GAAG,SAAS,CAiBhF;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,YAAY,GACrB;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,kBAAkB,CAAA;CAAE,CAM3C;AAED,uEAAuE;AACvE,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAGrE"}
@@ -1,16 +1,9 @@
1
- import { manifestVfs } from '@nimbus-sh/core/runtime/vfs-manifest.js';
2
1
  import { IsolatePool } from '@nimbus-sh/fabric/isolate-pool.js';
3
2
  export function loaderFacetHost(env, ctx) {
4
3
  return {
5
4
  // workerd suspends a guest through JSPI, which is what lets a syscall reach
6
5
  // back to the session mid-instruction.
7
6
  parking: 'jspi',
8
- /**
9
- * A manifest, not a copy: sizes and modes, with the facet demand-loading
10
- * whatever the program opens through its supervisor. It has to be — the
11
- * whole seed crosses one RPC, and a session filesystem does not fit in one.
12
- */
13
- seedFilesystem(vfs, root, options) { return manifestVfs(vfs, options.cred, root, options); },
14
7
  open(spec) {
15
8
  return new IsolatePool(env, ctx, {
16
9
  tag: spec.tag,
@@ -0,0 +1,17 @@
1
+ /**
2
+ * git-bundle-artifact.ts — supervisor-side fetcher for the staged git module
3
+ * the git network facet imports as `git-bundle.js`.
4
+ *
5
+ * scripts/bundle-git.mjs builds one module: vendor/git.generated.mjs, which the
6
+ * supervisor imports, and a byte-identical copy staged under
7
+ * public/_assets/runtime/ for the facet, which only receives modules as source
8
+ * text. Staging keeps that text out of the Worker bundle's size gate.
9
+ */
10
+ import { type StagedSourceEnv } from './staged-source.js';
11
+ /**
12
+ * The git module's source text for the network facet's `modules` record.
13
+ * Memoized per isolate; a failed fetch clears the memo so the next git
14
+ * operation retries instead of pinning the error.
15
+ */
16
+ export declare const fetchGitBundleSource: (env: StagedSourceEnv) => Promise<string>;
17
+ //# sourceMappingURL=git-bundle-artifact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-bundle-artifact.d.ts","sourceRoot":"","sources":["../../src/runtime/git-bundle-artifact.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,oBAAoB,CAAC;AAW5B;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,MAAM,CACO,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * git-bundle-artifact.ts — supervisor-side fetcher for the staged git module
3
+ * the git network facet imports as `git-bundle.js`.
4
+ *
5
+ * scripts/bundle-git.mjs builds one module: vendor/git.generated.mjs, which the
6
+ * supervisor imports, and a byte-identical copy staged under
7
+ * public/_assets/runtime/ for the facet, which only receives modules as source
8
+ * text. Staging keeps that text out of the Worker bundle's size gate.
9
+ */
10
+ import { GIT_BUNDLE_BUILD_ID, GIT_BUNDLE_ENTRY, GIT_BUNDLE_SHA256 } from '../git-bundle.generated.js';
11
+ import { fetchStagedText, memoizeUntilRejected, stagedRuntimeSource, } from './staged-source.js';
12
+ const GIT_BUNDLE = stagedRuntimeSource({
13
+ label: 'git-bundle',
14
+ entry: GIT_BUNDLE_ENTRY,
15
+ buildId: GIT_BUNDLE_BUILD_ID,
16
+ sha256: GIT_BUNDLE_SHA256,
17
+ stagedBy: 'scripts/bundle-git.mjs',
18
+ requiredBy: 'the git network facet',
19
+ });
20
+ /**
21
+ * The git module's source text for the network facet's `modules` record.
22
+ * Memoized per isolate; a failed fetch clears the memo so the next git
23
+ * operation retries instead of pinning the error.
24
+ */
25
+ export const fetchGitBundleSource = memoizeUntilRejected((env) => fetchStagedText(env, GIT_BUNDLE));
@@ -1 +1 @@
1
- {"version":3,"file":"node-repl.d.ts","sourceRoot":"","sources":["../../src/runtime/node-repl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAKlE,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AA2RD;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAIrE"}
1
+ {"version":3,"file":"node-repl.d.ts","sourceRoot":"","sources":["../../src/runtime/node-repl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAKlE,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAuQD;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAIrE"}
@@ -21,7 +21,7 @@
21
21
  * - Tab-completion
22
22
  * - History pickling
23
23
  */
24
- import { ReplSession } from './repl-session.js';
24
+ import { ReplSession, replPushResult } from './repl-session.js';
25
25
  import { NODE_VERSION } from '@nimbus-sh/core/constants.js';
26
26
  class NodeReplAdapter {
27
27
  pool = null;
@@ -84,18 +84,7 @@ class NodeReplAdapter {
84
84
  catch (e) {
85
85
  return { kind: 'error', stderr: `[node-repl] push dispatch failed: ${e?.message || e}\n` };
86
86
  }
87
- if (result.exit) {
88
- return {
89
- kind: 'exit',
90
- exitCode: result.exitCode || 0,
91
- stdout: result.stdout,
92
- stderr: result.stderr,
93
- };
94
- }
95
- if (result.incomplete) {
96
- return { kind: 'incomplete' };
97
- }
98
- return { kind: 'output', stdout: result.stdout || '', stderr: result.stderr || '' };
87
+ return replPushResult(result);
99
88
  }
100
89
  async close() {
101
90
  if (this.pool) {
@@ -1,30 +1,29 @@
1
1
  /**
2
- * node-shims-artifact.ts — supervisor-side fetcher for the staged node-compat
3
- * shim source.
2
+ * node-shims-artifact.ts — supervisor-side fetcher for the staged sources of
3
+ * the node-compat layer: the shims, the VFS write ledger and the resident store.
4
4
  *
5
- * The ~230 KiB generateShimsCode() output is staged as a static asset by
6
- * scripts/bundle-node-shims.mjs (promoted out of the worker bundle for the
7
- * ≤6 MiB bundle gate). Every node facet's generated worker text interpolates
8
- * it, so this fetch sits on the exec hot path: the result is memoized at
9
- * module scope (one fetch per isolate), fronted by L2 (caches.default) keyed
10
- * on the content-hash build id, with ASSETS as the source of truth and a
11
- * sha-256 integrity check so a stale or partial asset can never reach a facet.
12
- *
13
- * Mirrors opencode-artifact.ts / sqlite-wasm-bytes.ts. ASSETS is already a
14
- * mandatory embed binding (it serves the shell, sqlite wasm, opencode
15
- * artifacts); a missing binding fails loud here rather than producing a
16
- * facet with no node-compat layer.
5
+ * All three are staged as static assets by scripts/bundle-node-shims.mjs and
6
+ * promoted out of the worker bundle for its size gate: only a node facet ever
7
+ * runs them, and every node facet's generated worker text splices them. This
8
+ * fetch therefore sits on the exec hot path: the result is memoized at module
9
+ * scope (one fetch per isolate); each source is read and verified by
10
+ * runtime/staged-source.ts. A missing ASSETS binding fails loud rather than
11
+ * producing a facet with no node-compat layer.
17
12
  */
18
- /** Minimal env shape — any env with an ASSETS Fetcher binding. */
19
- export interface NodeShimsAssetEnv {
20
- ASSETS?: {
21
- fetch(req: Request): Promise<Response>;
22
- };
13
+ import { type StagedSourceEnv } from './staged-source.js';
14
+ /** What a node facet's generated worker text splices around the program. */
15
+ export interface NodeFacetSources {
16
+ /** The node-compat shims: node-shims.ts generateShimsCode(). */
17
+ shims: string;
18
+ /** The write ledger the shims' filesystem writes go through: core VFS_WRITE_LEDGER_SOURCE. */
19
+ ledger: string;
20
+ /** A resident facet's SQLite-backed resident set: vfs/facet-resident-store.ts FACET_RESIDENT_STORE_SOURCE. */
21
+ residentStore: string;
23
22
  }
24
23
  /**
25
- * The node-compat shim source for facet worker codegen. Memoized per isolate;
26
- * a failed fetch clears the memo so the next exec retries instead of pinning
27
- * the error.
24
+ * The node-compat layer's sources for facet worker codegen. Memoized per
25
+ * isolate; a failed fetch clears the memo so the next exec retries instead of
26
+ * pinning the error.
28
27
  */
29
- export declare function fetchNodeShimsCode(env: NodeShimsAssetEnv): Promise<string>;
28
+ export declare const fetchNodeFacetSources: (env: StagedSourceEnv) => Promise<NodeFacetSources>;
30
29
  //# sourceMappingURL=node-shims-artifact.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-shims-artifact.d.ts","sourceRoot":"","sources":["../../src/runtime/node-shims-artifact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAUH,kEAAkE;AAClE,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;KAAE,CAAC;CACrD;AAgED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ1E"}
1
+ {"version":3,"file":"node-shims-artifact.d.ts","sourceRoot":"","sources":["../../src/runtime/node-shims-artifact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAaH,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,oBAAoB,CAAC;AAE5B,4EAA4E;AAC5E,MAAM,WAAW,gBAAgB;IAC/B,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IACd,8FAA8F;IAC9F,MAAM,EAAE,MAAM,CAAC;IACf,8GAA8G;IAC9G,aAAa,EAAE,MAAM,CAAC;CACvB;AA8BD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,gBAAgB,CAQlF,CAAC"}