@nimbus-sh/worker 0.10.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/facets/cirrus-real.d.ts.map +1 -1
- package/dist/facets/cirrus-real.js +9 -4
- package/dist/facets/compose.d.ts +11 -7
- package/dist/facets/compose.d.ts.map +1 -1
- package/dist/facets/compose.js +8 -38
- 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-transform.d.ts +36 -10
- package/dist/facets/esbuild-transform.d.ts.map +1 -1
- package/dist/facets/esbuild-transform.js +216 -20
- 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 +179 -78
- package/dist/facets/manager.d.ts.map +1 -1
- package/dist/facets/manager.js +1221 -649
- 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/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 +16 -9
- package/dist/git/commands.d.ts.map +1 -1
- package/dist/git/commands.js +1818 -188
- package/dist/git/network-facet.d.ts +10 -2
- package/dist/git/network-facet.d.ts.map +1 -1
- package/dist/git/network-facet.js +62 -16
- 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 +62 -243
- package/dist/hosted/runtime.d.ts +19 -13
- package/dist/hosted/runtime.d.ts.map +1 -1
- package/dist/hosted/runtime.js +71 -14
- package/dist/hosted/services.d.ts +6 -7
- package/dist/hosted/services.d.ts.map +1 -1
- package/dist/hosted/services.js +10 -14
- 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 +5 -2
- package/dist/loaders/generated-workers.d.ts.map +1 -1
- package/dist/loaders/generated-workers.js +6 -3
- package/dist/loaders/npm-resolve-preamble.d.ts.map +1 -1
- package/dist/loaders/npm-resolve-preamble.js +0 -27
- 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 +5 -0
- package/dist/npm/cache.d.ts.map +1 -1
- package/dist/npm/cache.js +13 -1
- package/dist/npm/install-batch-facet.d.ts +2 -2
- package/dist/npm/install-batch-facet.js +3 -3
- package/dist/npm/installer.d.ts +17 -1
- package/dist/npm/installer.d.ts.map +1 -1
- package/dist/npm/installer.js +159 -20
- 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/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 +2 -0
- package/dist/npm/r2-cache.d.ts.map +1 -1
- package/dist/npm/r2-cache.js +2 -0
- package/dist/npm/resolve-one-facet.d.ts.map +1 -1
- package/dist/npm/resolve-one-facet.js +14 -3
- package/dist/npm/resolver.d.ts +0 -7
- package/dist/npm/resolver.d.ts.map +1 -1
- package/dist/npm/resolver.js +0 -22
- 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/esbuild-wasm-bytes.d.ts +17 -5
- package/dist/runtime/esbuild-wasm-bytes.d.ts.map +1 -1
- package/dist/runtime/esbuild-wasm-bytes.js +43 -94
- 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 +1567 -864
- 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 +2 -2
- 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 +36 -35
- 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.map +1 -1
- package/dist/runtime/wasi/preamble.js +0 -24
- 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 +34 -11
- package/dist/session/hibernation.d.ts.map +1 -1
- package/dist/session/hibernation.js +46 -29
- 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 +41 -15
- package/dist/session/nimbus-session.d.ts.map +1 -1
- package/dist/session/nimbus-session.js +64 -70
- package/dist/session/npm-install-port.d.ts.map +1 -1
- package/dist/session/npm-install-port.js +1 -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 +7 -10
- package/dist/session/rpc.d.ts +104 -20
- package/dist/session/rpc.d.ts.map +1 -1
- package/dist/session/rpc.js +184 -37
- 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 +104 -15
- package/dist/session/supervisor-rpc.d.ts.map +1 -1
- package/dist/session/supervisor-rpc.js +188 -71
- 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 +2 -0
- 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 +5 -22
- package/package.json +8 -7
- 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-7b4dd7a76d95d21e.js → node-shims-06565b121555c194.js} +2089 -861
- 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-facet-workers.mjs +114 -3
- 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,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* esbuild-wasm-bytes.ts — supervisor-side fetcher for the
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* (env.ASSETS); this module hands them to the caller when
|
|
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.
|
|
6
7
|
*
|
|
7
8
|
* Cache strategy
|
|
8
9
|
* ──────────────
|
|
@@ -32,7 +33,10 @@
|
|
|
32
33
|
* The JS adapter followed the wasm for the same reason at a smaller
|
|
33
34
|
* scale: the supervisor already imports esbuild-wasm's browser build as a
|
|
34
35
|
* module for its own transforms, so carrying the same 117 KiB again as a
|
|
35
|
-
* string literal for facets doubled it in the Worker bundle.
|
|
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.
|
|
36
40
|
*
|
|
37
41
|
* Each call to `fetchEsbuildWasmBytes(env)` now does:
|
|
38
42
|
* - one `caches.default.match()` — sub-millisecond on hit
|
|
@@ -49,8 +53,8 @@
|
|
|
49
53
|
* digest the generator recorded before returning).
|
|
50
54
|
*/
|
|
51
55
|
import { ESBUILD_JS_ASSET_PATH, ESBUILD_JS_SHA256, ESBUILD_WASM_ASSET_PATH, ESBUILD_WASM_SHA256, } from '../esbuild-wasm-bundle.generated.js';
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
56
|
+
import { ESBUILD_CLI_ASSET_PATH, ESBUILD_CLI_SHA256 } from '../esbuild-cli-artifact.generated.js';
|
|
57
|
+
import { fetchStagedBytes, fetchStagedText } from './staged-source.js';
|
|
54
58
|
/**
|
|
55
59
|
* Synthetic L2 cache keys for the esbuild-wasm assets, staged at
|
|
56
60
|
* public/_assets/esbuild-<version>.{wasm,js} by scripts/bundle-esbuild-wasm.mjs
|
|
@@ -64,20 +68,28 @@ import { sha256Hex } from '@nimbus-sh/core/_shared/crypto.js';
|
|
|
64
68
|
*/
|
|
65
69
|
export const ESBUILD_WASM_L2_KEY = `https://nimbus-cache.invalid${ESBUILD_WASM_ASSET_PATH}`;
|
|
66
70
|
export const ESBUILD_JS_L2_KEY = `https://nimbus-cache.invalid${ESBUILD_JS_ASSET_PATH}`;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
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');
|
|
81
93
|
/**
|
|
82
94
|
* Fetch the esbuild-wasm bytes from the static-assets layer.
|
|
83
95
|
*
|
|
@@ -92,84 +104,21 @@ const ESBUILD_JS_ASSET = {
|
|
|
92
104
|
* always the correct source of truth.
|
|
93
105
|
*/
|
|
94
106
|
export function fetchEsbuildWasmBytes(env) {
|
|
95
|
-
return
|
|
107
|
+
return fetchStagedBytes(env, ESBUILD_WASM_ASSET);
|
|
96
108
|
}
|
|
97
109
|
/**
|
|
98
110
|
* Fetch the esbuild-wasm JS adapter: the function body that, wrapped in
|
|
99
111
|
* `new Function(...)()`, returns the esbuild namespace. Facet sources
|
|
100
112
|
* splice it in verbatim, so it is verified like the wasm it drives.
|
|
101
113
|
*/
|
|
102
|
-
export
|
|
103
|
-
return
|
|
114
|
+
export function fetchEsbuildJsFnBody(env) {
|
|
115
|
+
return fetchStagedText(env, ESBUILD_JS_ASSET);
|
|
104
116
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (hit && hit.ok)
|
|
113
|
-
ab = await hit.arrayBuffer();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
catch { /* fall through to ASSETS */ }
|
|
117
|
-
const fromCache = ab !== null;
|
|
118
|
-
if (!ab) {
|
|
119
|
-
// ── L4 path (env.ASSETS) ──────────────────────────────────────
|
|
120
|
-
// Construct a synthetic request — env.ASSETS routes by pathname only;
|
|
121
|
-
// the host is ignored. Using `.invalid` per RFC-2606 makes it
|
|
122
|
-
// unambiguous that this URL is internal-binding-only.
|
|
123
|
-
const url = `https://nimbus-internal.invalid${asset.path}`;
|
|
124
|
-
const res = await env.ASSETS.fetch(new Request(url));
|
|
125
|
-
try {
|
|
126
|
-
if (!res.ok) {
|
|
127
|
-
throw new Error(`${asset.label} asset fetch failed: ${res.status} ${res.statusText} ` +
|
|
128
|
-
`for ${asset.path} — deploy is missing the asset`);
|
|
129
|
-
}
|
|
130
|
-
// Read the bytes once (Response body is a one-shot stream). The
|
|
131
|
-
// caller needs the ArrayBuffer to hand to workerd's LOADER; we
|
|
132
|
-
// also use it to write through to L2.
|
|
133
|
-
ab = await res.arrayBuffer();
|
|
134
|
-
}
|
|
135
|
-
finally {
|
|
136
|
-
disposeRpcResource(res);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
const digest = await sha256Hex(ab);
|
|
140
|
-
if (digest !== asset.sha256) {
|
|
141
|
-
throw new Error(`${asset.label} integrity check failed: expected ${asset.sha256}, got ` +
|
|
142
|
-
`${digest} (${fromCache ? 'L2 cache' : 'ASSETS'}) for ${asset.path} — ` +
|
|
143
|
-
'the staged asset is corrupt or out of sync; rerun ' +
|
|
144
|
-
'scripts/bundle-esbuild-wasm.mjs and redeploy');
|
|
145
|
-
}
|
|
146
|
-
if (!fromCache) {
|
|
147
|
-
// ── L2 write-back ────────────────────────────────────────────
|
|
148
|
-
// Eternal immutable TTL: the URL is version-pinned so a new
|
|
149
|
-
// ESBUILD_VERSION lands a fresh cache entry; the old one naturally
|
|
150
|
-
// evicts on TTL. The cache layer holds its own copy (workerd
|
|
151
|
-
// structured-clones the body during put), so the supervisor's
|
|
152
|
-
// reference to `ab` is unaffected.
|
|
153
|
-
// Best-effort: a write failure does NOT block the caller.
|
|
154
|
-
try {
|
|
155
|
-
if (caches?.default) {
|
|
156
|
-
// We pass a fresh Uint8Array view over the same buffer; the
|
|
157
|
-
// cache stores a copy at put time. Returning `ab` to the
|
|
158
|
-
// caller stays valid because Response constructor doesn't
|
|
159
|
-
// detach the buffer (only ReadableStream consumption would).
|
|
160
|
-
const writeBack = new Response(new Uint8Array(ab), {
|
|
161
|
-
headers: {
|
|
162
|
-
'Content-Type': asset.contentType,
|
|
163
|
-
'Cache-Control': 'public, max-age=31536000, immutable',
|
|
164
|
-
},
|
|
165
|
-
});
|
|
166
|
-
// Awaited so subsequent reads strictly hit L2 (no
|
|
167
|
-
// double-fetch race). The wasm payload is 12 MiB; workerd
|
|
168
|
-
// structured-clones it into the cache, ~1-5 ms locally.
|
|
169
|
-
await caches.default.put(new Request(asset.l2Key), writeBack);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
catch { /* silent */ }
|
|
173
|
-
}
|
|
174
|
-
return ab;
|
|
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);
|
|
175
124
|
}
|
|
@@ -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"}
|
|
@@ -1,83 +1,53 @@
|
|
|
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
|
-
import { NODE_SHIMS_BUILD_ID, NODE_SHIMS_ENTRY, NODE_SHIMS_SHA256, } from '../node-shims-artifact.generated.js';
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
`(run scripts/bundle-node-shims.mjs)`);
|
|
47
|
-
}
|
|
48
|
-
text = await res.text();
|
|
49
|
-
}
|
|
50
|
-
finally {
|
|
51
|
-
disposeRpcResource(res);
|
|
52
|
-
}
|
|
53
|
-
try {
|
|
54
|
-
if (caches?.default) {
|
|
55
|
-
await caches.default.put(new Request(L2_KEY), new Response(text, {
|
|
56
|
-
headers: { 'Cache-Control': 'public, max-age=31536000, immutable' },
|
|
57
|
-
}));
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
catch { /* silent */ }
|
|
61
|
-
}
|
|
62
|
-
const digest = await sha256Hex(text);
|
|
63
|
-
if (digest !== NODE_SHIMS_SHA256) {
|
|
64
|
-
throw new Error(`node-shims asset integrity mismatch for ${NODE_SHIMS_ENTRY}: ` +
|
|
65
|
-
`expected ${NODE_SHIMS_SHA256.slice(0, 16)}…, got ${digest.slice(0, 16)}… — ` +
|
|
66
|
-
'the staged asset is stale; rerun scripts/bundle-node-shims.mjs and redeploy');
|
|
67
|
-
}
|
|
68
|
-
return text;
|
|
69
|
-
}
|
|
13
|
+
import { NODE_SHIMS_BUILD_ID, NODE_SHIMS_ENTRY, NODE_SHIMS_SHA256, RESIDENT_STORE_BUILD_ID, RESIDENT_STORE_ENTRY, RESIDENT_STORE_SHA256, VFS_WRITE_LEDGER_BUILD_ID, VFS_WRITE_LEDGER_ENTRY, VFS_WRITE_LEDGER_SHA256, } from '../node-shims-artifact.generated.js';
|
|
14
|
+
import { fetchStagedText, memoizeUntilRejected, stagedRuntimeSource, } from './staged-source.js';
|
|
15
|
+
const STAGED_BY = 'scripts/bundle-node-shims.mjs';
|
|
16
|
+
const REQUIRED_BY = 'the node runtime';
|
|
17
|
+
const NODE_SHIMS = stagedRuntimeSource({
|
|
18
|
+
label: 'node-shims',
|
|
19
|
+
entry: NODE_SHIMS_ENTRY,
|
|
20
|
+
buildId: NODE_SHIMS_BUILD_ID,
|
|
21
|
+
sha256: NODE_SHIMS_SHA256,
|
|
22
|
+
stagedBy: STAGED_BY,
|
|
23
|
+
requiredBy: REQUIRED_BY,
|
|
24
|
+
});
|
|
25
|
+
const VFS_WRITE_LEDGER = stagedRuntimeSource({
|
|
26
|
+
label: 'vfs-write-ledger',
|
|
27
|
+
entry: VFS_WRITE_LEDGER_ENTRY,
|
|
28
|
+
buildId: VFS_WRITE_LEDGER_BUILD_ID,
|
|
29
|
+
sha256: VFS_WRITE_LEDGER_SHA256,
|
|
30
|
+
stagedBy: STAGED_BY,
|
|
31
|
+
requiredBy: REQUIRED_BY,
|
|
32
|
+
});
|
|
33
|
+
const RESIDENT_STORE = stagedRuntimeSource({
|
|
34
|
+
label: 'resident-store',
|
|
35
|
+
entry: RESIDENT_STORE_ENTRY,
|
|
36
|
+
buildId: RESIDENT_STORE_BUILD_ID,
|
|
37
|
+
sha256: RESIDENT_STORE_SHA256,
|
|
38
|
+
stagedBy: STAGED_BY,
|
|
39
|
+
requiredBy: REQUIRED_BY,
|
|
40
|
+
});
|
|
70
41
|
/**
|
|
71
|
-
* The node-compat
|
|
72
|
-
* a failed fetch clears the memo so the next exec retries instead of
|
|
73
|
-
* the error.
|
|
42
|
+
* The node-compat layer's sources for facet worker codegen. Memoized per
|
|
43
|
+
* isolate; a failed fetch clears the memo so the next exec retries instead of
|
|
44
|
+
* pinning the error.
|
|
74
45
|
*/
|
|
75
|
-
export
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
}
|
|
46
|
+
export const fetchNodeFacetSources = memoizeUntilRejected(async (env) => {
|
|
47
|
+
const [shims, ledger, residentStore] = await Promise.all([
|
|
48
|
+
fetchStagedText(env, NODE_SHIMS),
|
|
49
|
+
fetchStagedText(env, VFS_WRITE_LEDGER),
|
|
50
|
+
fetchStagedText(env, RESIDENT_STORE),
|
|
51
|
+
]);
|
|
52
|
+
return { shims, ledger, residentStore };
|
|
53
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-shims.d.ts","sourceRoot":"","sources":["../../src/runtime/node-shims.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;
|
|
1
|
+
{"version":3,"file":"node-shims.d.ts","sourceRoot":"","sources":["../../src/runtime/node-shims.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AA2DH,wBAAgB,iBAAiB,IAAI,MAAM,CA22R1C"}
|