@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.
- package/NOTICE.md +5 -0
- package/README.md +10 -0
- package/dist/_shared/session-router.d.ts +7 -0
- package/dist/_shared/session-router.d.ts.map +1 -1
- package/dist/_shared/session-router.js +7 -0
- package/dist/bindings/body.d.ts +6 -0
- package/dist/bindings/body.d.ts.map +1 -0
- package/dist/bindings/body.js +37 -0
- package/dist/bindings/kv.d.ts +0 -2
- package/dist/bindings/kv.d.ts.map +1 -1
- package/dist/bindings/kv.js +3 -42
- package/dist/bindings/r2.d.ts +0 -2
- package/dist/bindings/r2.d.ts.map +1 -1
- package/dist/bindings/r2.js +4 -44
- package/dist/esbuild-cli-artifact.generated.d.ts +18 -0
- package/dist/esbuild-cli-artifact.generated.d.ts.map +1 -0
- package/dist/esbuild-cli-artifact.generated.js +17 -0
- package/dist/esbuild-wasm-bundle.generated.d.ts +24 -24
- package/dist/esbuild-wasm-bundle.generated.d.ts.map +1 -1
- package/dist/esbuild-wasm-bundle.generated.js +24 -24
- package/dist/facets/cirrus-real.d.ts.map +1 -1
- package/dist/facets/cirrus-real.js +11 -6
- package/dist/facets/compose.d.ts +11 -7
- package/dist/facets/compose.d.ts.map +1 -1
- package/dist/facets/compose.js +8 -31
- package/dist/facets/data-plan.d.ts +79 -0
- package/dist/facets/data-plan.d.ts.map +1 -0
- package/dist/facets/data-plan.js +477 -0
- package/dist/facets/esbuild-bundle-pool.d.ts +1 -1
- package/dist/facets/esbuild-bundle-pool.js +3 -3
- package/dist/facets/esbuild-transform.d.ts +38 -8
- package/dist/facets/esbuild-transform.d.ts.map +1 -1
- package/dist/facets/esbuild-transform.js +219 -19
- package/dist/facets/exec-telemetry.d.ts +7 -3
- package/dist/facets/exec-telemetry.d.ts.map +1 -1
- package/dist/facets/manager.d.ts +198 -69
- package/dist/facets/manager.d.ts.map +1 -1
- package/dist/facets/manager.js +1276 -652
- package/dist/facets/opencode-staging.d.ts +0 -2
- package/dist/facets/opencode-staging.d.ts.map +1 -1
- package/dist/facets/opencode-staging.js +5 -11
- package/dist/facets/process.d.ts +4 -0
- package/dist/facets/process.d.ts.map +1 -1
- package/dist/facets/process.js +3 -0
- package/dist/facets/read-profile.d.ts +149 -0
- package/dist/facets/read-profile.d.ts.map +1 -0
- package/dist/facets/read-profile.js +483 -0
- package/dist/facets/real-vite-hmr.d.ts +2 -0
- package/dist/facets/real-vite-hmr.d.ts.map +1 -1
- package/dist/facets/real-vite-hmr.js +3 -2
- package/dist/facets/resident-identity.d.ts +0 -1
- package/dist/facets/resident-identity.d.ts.map +1 -1
- package/dist/facets/resident-identity.js +0 -3
- package/dist/facets/wasm-swap-registry.d.ts +34 -25
- package/dist/facets/wasm-swap-registry.d.ts.map +1 -1
- package/dist/facets/wasm-swap-registry.js +62 -56
- package/dist/facets/ws-terminal.d.ts +4 -4
- package/dist/facets/ws-terminal.d.ts.map +1 -1
- package/dist/facets/ws-terminal.js +4 -5
- package/dist/git/commands.d.ts +33 -10
- package/dist/git/commands.d.ts.map +1 -1
- package/dist/git/commands.js +1891 -197
- package/dist/git/network-facet.d.ts +12 -2
- package/dist/git/network-facet.d.ts.map +1 -1
- package/dist/git/network-facet.js +69 -18
- package/dist/git/unified-diff.d.ts +74 -0
- package/dist/git/unified-diff.d.ts.map +1 -0
- package/dist/git/unified-diff.js +676 -0
- package/dist/git-bundle.generated.d.ts +7 -11
- package/dist/git-bundle.generated.d.ts.map +1 -1
- package/dist/git-bundle.generated.js +7 -11
- package/dist/hosted/commands.d.ts.map +1 -1
- package/dist/hosted/commands.js +64 -245
- package/dist/hosted/runtime.d.ts +22 -15
- package/dist/hosted/runtime.d.ts.map +1 -1
- package/dist/hosted/runtime.js +72 -14
- package/dist/hosted/services.d.ts +8 -1
- package/dist/hosted/services.d.ts.map +1 -1
- package/dist/hosted/services.js +12 -13
- package/dist/hosted/session.d.ts +165 -0
- package/dist/hosted/session.d.ts.map +1 -0
- package/dist/hosted/session.js +132 -0
- package/dist/loaders/generated-workers.d.ts +6 -3
- package/dist/loaders/generated-workers.d.ts.map +1 -1
- package/dist/loaders/generated-workers.js +8 -5
- package/dist/loaders/npm-resolve-preamble.d.ts.map +1 -1
- package/dist/loaders/npm-resolve-preamble.js +0 -27
- package/dist/loaders/pre-bundle-preamble.d.ts +6 -3
- package/dist/loaders/pre-bundle-preamble.d.ts.map +1 -1
- package/dist/loaders/pre-bundle-preamble.js +13 -8
- package/dist/node-shims-artifact.generated.d.ts +13 -4
- package/dist/node-shims-artifact.generated.d.ts.map +1 -1
- package/dist/node-shims-artifact.generated.js +16 -7
- package/dist/npm/bin-links.d.ts +3 -1
- package/dist/npm/bin-links.d.ts.map +1 -1
- package/dist/npm/bin-links.js +32 -8
- package/dist/npm/cache.d.ts +11 -1
- package/dist/npm/cache.d.ts.map +1 -1
- package/dist/npm/cache.js +21 -7
- package/dist/npm/install-batch-facet.d.ts +4 -2
- package/dist/npm/install-batch-facet.d.ts.map +1 -1
- package/dist/npm/install-batch-facet.js +32 -18
- package/dist/npm/installer.d.ts +23 -3
- package/dist/npm/installer.d.ts.map +1 -1
- package/dist/npm/installer.js +330 -131
- package/dist/npm/npx-install.d.ts +3 -1
- package/dist/npm/npx-install.d.ts.map +1 -1
- package/dist/npm/npx-install.js +4 -1
- package/dist/npm/package-lock.d.ts +32 -0
- package/dist/npm/package-lock.d.ts.map +1 -0
- package/dist/npm/package-lock.js +65 -0
- package/dist/npm/placement.d.ts +16 -0
- package/dist/npm/placement.d.ts.map +1 -0
- package/dist/npm/placement.js +33 -0
- package/dist/npm/pre-bundle-facet.d.ts +1 -30
- package/dist/npm/pre-bundle-facet.d.ts.map +1 -1
- package/dist/npm/pre-bundle-facet.js +3 -5
- package/dist/npm/r2-cache.d.ts +12 -6
- package/dist/npm/r2-cache.d.ts.map +1 -1
- package/dist/npm/r2-cache.js +34 -16
- package/dist/npm/resolve-one-facet.d.ts +3 -0
- package/dist/npm/resolve-one-facet.d.ts.map +1 -1
- package/dist/npm/resolve-one-facet.js +15 -3
- package/dist/npm/resolver.d.ts +11 -13
- package/dist/npm/resolver.d.ts.map +1 -1
- package/dist/npm/resolver.js +12 -25
- package/dist/opencode-artifact.generated.js +2 -2
- package/dist/replica/routing.d.ts +2 -38
- package/dist/replica/routing.d.ts.map +1 -1
- package/dist/replica/routing.js +3 -55
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +15 -2
- package/dist/router/public-directory.d.ts +18 -0
- package/dist/router/public-directory.d.ts.map +1 -1
- package/dist/router/public-directory.js +1 -1
- package/dist/router/remote-api.d.ts +3 -1
- package/dist/router/remote-api.d.ts.map +1 -1
- package/dist/router/remote-api.js +42 -79
- package/dist/runtime/bash-repl.js +2 -2
- package/dist/runtime/bun-repl.d.ts.map +1 -1
- package/dist/runtime/bun-repl.js +2 -13
- package/dist/runtime/cpython-resident.d.ts.map +1 -1
- package/dist/runtime/cpython-resident.js +2 -10
- package/dist/runtime/esbuild-wasm-bytes.d.ts +37 -18
- package/dist/runtime/esbuild-wasm-bytes.d.ts.map +1 -1
- package/dist/runtime/esbuild-wasm-bytes.js +66 -92
- package/dist/runtime/facet-loader-host.d.ts.map +1 -1
- package/dist/runtime/facet-loader-host.js +0 -7
- package/dist/runtime/git-bundle-artifact.d.ts +17 -0
- package/dist/runtime/git-bundle-artifact.d.ts.map +1 -0
- package/dist/runtime/git-bundle-artifact.js +25 -0
- package/dist/runtime/node-repl.d.ts.map +1 -1
- package/dist/runtime/node-repl.js +2 -13
- package/dist/runtime/node-shims-artifact.d.ts +22 -23
- package/dist/runtime/node-shims-artifact.d.ts.map +1 -1
- package/dist/runtime/node-shims-artifact.js +48 -78
- package/dist/runtime/node-shims.d.ts.map +1 -1
- package/dist/runtime/node-shims.js +2358 -996
- package/dist/runtime/opencode-artifact.d.ts.map +1 -1
- package/dist/runtime/opencode-artifact.js +17 -53
- package/dist/runtime/opencode-facet-runner.d.ts +3 -6
- package/dist/runtime/opencode-facet-runner.d.ts.map +1 -1
- package/dist/runtime/opencode-facet-runner.js +45 -10
- package/dist/runtime/opentui-wasm-bytes.d.ts.map +1 -1
- package/dist/runtime/opentui-wasm-bytes.js +16 -49
- package/dist/runtime/package-manager.d.ts +0 -2
- package/dist/runtime/package-manager.d.ts.map +1 -1
- package/dist/runtime/package-manager.js +0 -3
- package/dist/runtime/python-repl.d.ts.map +1 -1
- package/dist/runtime/python-repl.js +4 -35
- package/dist/runtime/repl-session.d.ts +10 -0
- package/dist/runtime/repl-session.d.ts.map +1 -1
- package/dist/runtime/repl-session.js +7 -0
- package/dist/runtime/ruby-repl.d.ts.map +1 -1
- package/dist/runtime/ruby-repl.js +2 -2
- package/dist/runtime/ruby-resident.d.ts.map +1 -1
- package/dist/runtime/ruby-resident.js +41 -51
- package/dist/runtime/runtime-catalog.d.ts +10 -3
- package/dist/runtime/runtime-catalog.d.ts.map +1 -1
- package/dist/runtime/runtime-catalog.js +125 -15
- package/dist/runtime/sqlite-wasm-bytes.d.ts +4 -4
- package/dist/runtime/sqlite-wasm-bytes.d.ts.map +1 -1
- package/dist/runtime/sqlite-wasm-bytes.js +21 -57
- package/dist/runtime/staged-source.d.ts +67 -0
- package/dist/runtime/staged-source.d.ts.map +1 -0
- package/dist/runtime/staged-source.js +113 -0
- package/dist/runtime/wasi/preamble.d.ts +0 -22
- package/dist/runtime/wasi/preamble.d.ts.map +1 -1
- package/dist/runtime/wasi/preamble.js +98 -1425
- package/dist/runtime-catalog.generated.js +1 -1
- package/dist/session/agent.d.ts +14 -2
- package/dist/session/agent.d.ts.map +1 -1
- package/dist/session/agent.js +57 -19
- package/dist/session/ai.d.ts +0 -11
- package/dist/session/ai.d.ts.map +1 -1
- package/dist/session/ai.js +0 -4
- package/dist/session/fs-watch.d.ts +0 -11
- package/dist/session/fs-watch.d.ts.map +1 -1
- package/dist/session/fs-watch.js +0 -21
- package/dist/session/hibernation.d.ts +68 -2
- package/dist/session/hibernation.d.ts.map +1 -1
- package/dist/session/hibernation.js +95 -1
- package/dist/session/init-phases.d.ts +1 -2
- package/dist/session/init-phases.d.ts.map +1 -1
- package/dist/session/init-phases.js +1 -2
- package/dist/session/init.d.ts.map +1 -1
- package/dist/session/init.js +7 -20
- package/dist/session/keys.d.ts +0 -3
- package/dist/session/keys.d.ts.map +1 -1
- package/dist/session/keys.js +0 -3
- package/dist/session/legacy-reset.d.ts +11 -0
- package/dist/session/legacy-reset.d.ts.map +1 -0
- package/dist/session/legacy-reset.js +16 -0
- package/dist/session/nimbus-session.d.ts +50 -16
- package/dist/session/nimbus-session.d.ts.map +1 -1
- package/dist/session/nimbus-session.js +77 -71
- package/dist/session/npm-install-port.d.ts.map +1 -1
- package/dist/session/npm-install-port.js +2 -0
- package/dist/session/programmatic.d.ts +13 -18
- package/dist/session/programmatic.d.ts.map +1 -1
- package/dist/session/programmatic.js +53 -39
- package/dist/session/replica-routes.d.ts +2 -3
- package/dist/session/replica-routes.d.ts.map +1 -1
- package/dist/session/replica-routes.js +3 -10
- package/dist/session/routes.d.ts.map +1 -1
- package/dist/session/routes.js +11 -12
- package/dist/session/rpc.d.ts +108 -21
- package/dist/session/rpc.d.ts.map +1 -1
- package/dist/session/rpc.js +194 -39
- package/dist/session/start-real-vite.js +2 -2
- package/dist/session/state-store.d.ts +1 -17
- package/dist/session/state-store.d.ts.map +1 -1
- package/dist/session/state-store.js +3 -53
- package/dist/session/supervisor-op.d.ts +7 -0
- package/dist/session/supervisor-op.d.ts.map +1 -1
- package/dist/session/supervisor-op.js +6 -1
- package/dist/session/supervisor-rpc.d.ts +116 -19
- package/dist/session/supervisor-rpc.d.ts.map +1 -1
- package/dist/session/supervisor-rpc.js +194 -84
- package/dist/session/vite-command.d.ts.map +1 -1
- package/dist/session/vite-command.js +17 -14
- package/dist/session/ws.d.ts.map +1 -1
- package/dist/session/ws.js +20 -8
- package/dist/shell/npm-bin-entrypoints.d.ts.map +1 -1
- package/dist/shell/npm-bin-entrypoints.js +30 -5
- package/dist/vfs/facet-resident-limits.d.ts +33 -0
- package/dist/vfs/facet-resident-limits.d.ts.map +1 -0
- package/dist/vfs/facet-resident-limits.js +33 -0
- package/dist/vfs/facet-resident-store.d.ts +2 -10
- package/dist/vfs/facet-resident-store.d.ts.map +1 -1
- package/dist/vfs/facet-resident-store.js +1594 -219
- package/dist/workspace-host.d.ts +3 -1
- package/dist/workspace-host.d.ts.map +1 -1
- package/dist/workspace-host.js +2 -0
- package/dist/wrangler/nimbus-wrangler.d.ts +0 -2
- package/dist/wrangler/nimbus-wrangler.d.ts.map +1 -1
- package/dist/wrangler/nimbus-wrangler.js +8 -22
- package/package.json +34 -7
- package/public/_assets/esbuild-0.24.2.js +2380 -0
- package/public/_assets/opencode/1.16.2/index-attach.js +2 -2
- package/public/_assets/runtime/esbuild-cli-c4fda380d52befc1.js +6892 -0
- package/public/_assets/runtime/git-de3e60c9f3ff006a.js +103 -0
- package/public/_assets/runtime/{node-shims-acaa037e6d26ec0d.js → node-shims-06565b121555c194.js} +2879 -992
- package/public/_assets/runtime/resident-store-6ffb1939c53d982f.js +2264 -0
- package/public/_assets/runtime/vfs-write-ledger-e501e8fc793bc2c1.js +889 -0
- package/scripts/build-opencode-attach-entry.mjs +51 -1
- package/scripts/bundle-esbuild-wasm.mjs +55 -39
- package/scripts/bundle-facet-workers.mjs +159 -10
- package/scripts/bundle-git.mjs +88 -27
- package/scripts/bundle-node-shims.mjs +72 -46
- package/scripts/bundle-runtime.mjs +18 -421
- package/scripts/cf-git-patch.mjs +137 -0
- package/scripts/patch-install-deps.mjs +49 -96
- package/scripts/runtime-specs.mjs +435 -0
- package/vendor/git-http.generated.d.ts +82 -0
- package/vendor/git-upstream.generated.d.ts +4378 -0
- package/vendor/git.LICENSE +7 -0
- package/vendor/git.generated.d.mts +21 -0
- package/vendor/git.generated.mjs +103 -0
- package/dist/replica/suspension.d.ts +0 -36
- package/dist/replica/suspension.d.ts.map +0 -1
- package/dist/replica/suspension.js +0 -49
- package/dist/runtime/static-server.d.ts +0 -3
- package/dist/runtime/static-server.d.ts.map +0 -1
- package/dist/runtime/static-server.js +0 -133
- 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,
|
|
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
|
|
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
|
|
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
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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
|
|
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
|
|
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
|
|
64
|
-
*
|
|
65
|
-
*
|
|
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
|
|
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
|
|
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
|
|
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
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
58
|
-
*
|
|
59
|
-
*
|
|
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
|
|
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
|
|
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
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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;
|
|
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;
|
|
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
|
-
|
|
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
|
|
3
|
-
*
|
|
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
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
26
|
-
* a failed fetch clears the memo so the next exec retries instead of
|
|
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
|
|
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
|
|
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"}
|