@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
package/NOTICE.md
CHANGED
|
@@ -4,3 +4,8 @@ This package is part of Nimbus. It includes the Worker runtime, generated
|
|
|
4
4
|
browser assets, runtime packaging scripts, and integration code for third-party
|
|
5
5
|
runtime components. See the project notices at
|
|
6
6
|
https://github.com/AshishKumar4/Nimbus/blob/main/NOTICE.md.
|
|
7
|
+
|
|
8
|
+
The generated Git module in `vendor/git.generated.mjs` contains the cf-git
|
|
9
|
+
fork of isomorphic-git, with Nimbus' tracked build-time patch. Its MIT license
|
|
10
|
+
is included in `vendor/git.LICENSE`; bundled dependency notices are retained
|
|
11
|
+
in the generated module.
|
package/README.md
CHANGED
|
@@ -83,6 +83,8 @@ export default createNimbusHandler({
|
|
|
83
83
|
"compatibility_date": "2026-04-01",
|
|
84
84
|
"compatibility_flags": ["nodejs_compat"],
|
|
85
85
|
"placement": { "mode": "smart" },
|
|
86
|
+
// Shell commands run in the session DO. The 30 s default kills long ones.
|
|
87
|
+
"limits": { "cpu_ms": 300000 },
|
|
86
88
|
"assets": {
|
|
87
89
|
"directory": "node_modules/@nimbus-sh/worker/public",
|
|
88
90
|
"binding": "ASSETS",
|
|
@@ -213,6 +215,13 @@ Applications normally call it through `Nimbus.connect({ endpoint, token,
|
|
|
213
215
|
config })`. The route requires a valid Nimbus JWT and `sandbox:use` scope.
|
|
214
216
|
`box.destroy()` additionally requires `session:destroy` or `session:admin`.
|
|
215
217
|
|
|
218
|
+
With the remote API enabled, `DELETE /s/<id>/` is the same operation under
|
|
219
|
+
the same authorization as `box.destroy()`, and answers
|
|
220
|
+
`{ ok: true, result: { ok, killed, destroyedAt, reason } }`. An
|
|
221
|
+
`X-Nimbus-Cleanup-Reason` header supplies the reason. The session root
|
|
222
|
+
serves the UI only to `GET` and `HEAD`; any other method is `405`, and so is
|
|
223
|
+
`DELETE` when the remote API is off.
|
|
224
|
+
|
|
216
225
|
For an app server, start the process and expose its virtual port:
|
|
217
226
|
|
|
218
227
|
```ts
|
|
@@ -288,6 +297,7 @@ npx wrangler secret put NIMBUS_CLOUDFLARE_API_TOKEN
|
|
|
288
297
|
| `@nimbus-sh/worker` | Runtime implementation package used by the SDK entrypoint. |
|
|
289
298
|
| `@nimbus-sh/worker/router` | Runtime router implementation and hook types. |
|
|
290
299
|
| `@nimbus-sh/worker/auth` | Runtime auth implementation re-exported by `@nimbus-sh/sdk/token`. |
|
|
300
|
+
| `@nimbus-sh/worker/workspace-host` | `composeHostedRuntime`: the runtime over a `NimbusWorkspace` in your own Durable Object. Its `lifecycle.schedule` must be backed by an alarm; see [Use as a library](https://nimbus-os.dev/docs/sdk/library/). |
|
|
291
301
|
|
|
292
302
|
## Required bindings
|
|
293
303
|
|
|
@@ -75,6 +75,13 @@ export declare const CALLER_SCOPES_HEADER = "x-nimbus-caller-scopes";
|
|
|
75
75
|
* starting with that exact prefix-then-colon when JWT_SECRET is set).
|
|
76
76
|
*/
|
|
77
77
|
export declare const LEGACY_PUBLIC_DO_SEGMENT = "legacy:public:_";
|
|
78
|
+
/**
|
|
79
|
+
* The tenant of every anonymous session a deployment hands out (the hosted
|
|
80
|
+
* demo's `anon:anon:<sid>`). Anyone can mint such sessions, so they are one
|
|
81
|
+
* principal, and one that may read what verified tenants share but never
|
|
82
|
+
* write to it (read-profile.ts).
|
|
83
|
+
*/
|
|
84
|
+
export declare const ANONYMOUS_TENANT = "anon";
|
|
78
85
|
export interface ParsedSessionRoute {
|
|
79
86
|
/** Session ID portion (unverified until `isValidSessionId` check). */
|
|
80
87
|
sessionId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-router.d.ts","sourceRoot":"","sources":["../../src/_shared/session-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAIH,8EAA8E;AAC9E,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAEzC,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,aAAa,oBAAoB,CAAC;AAE/C;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,gCAAgC,CAAC;AAEvE;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAE7D;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAE7D;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"session-router.d.ts","sourceRoot":"","sources":["../../src/_shared/session-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAIH,8EAA8E;AAC9E,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAEzC,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,aAAa,oBAAoB,CAAC;AAE/C;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,gCAAgC,CAAC;AAEvE;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAE7D;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAE7D;;;;;GAKG;AACH,eAA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 'x-nimbus-caller-scopes';
|
|
|
76
76
|
* starting with that exact prefix-then-colon when JWT_SECRET is set).
|
|
77
77
|
*/
|
|
78
78
|
export const LEGACY_PUBLIC_DO_SEGMENT = 'legacy:public:_';
|
|
79
|
+
/**
|
|
80
|
+
* The tenant of every anonymous session a deployment hands out (the hosted
|
|
81
|
+
* demo's `anon:anon:<sid>`). Anyone can mint such sessions, so they are one
|
|
82
|
+
* principal, and one that may read what verified tenants share but never
|
|
83
|
+
* write to it (read-profile.ts).
|
|
84
|
+
*/
|
|
85
|
+
export const ANONYMOUS_TENANT = 'anon';
|
|
79
86
|
/**
|
|
80
87
|
* Match `/s/<id>(/<rest>)?` with `<id>` being ANY lowercase-letters-digits-
|
|
81
88
|
* dashes token. Shape validation happens in a second step so we can return
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CredentialedVfs } from '@nimbus-sh/core/vfs/sqlite-vfs.js';
|
|
2
|
+
type BindingBody = string | ArrayBuffer | ArrayBufferView | ReadableStream<Uint8Array | ArrayBuffer> | Blob | null | undefined;
|
|
3
|
+
export declare function ensureBindingDir(vfs: Pick<CredentialedVfs, 'exists' | 'mkdir'>, path: string): void;
|
|
4
|
+
export declare function coerceBindingBody(value: BindingBody): Promise<Uint8Array>;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=body.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../src/bindings/body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEzE,KAAK,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,eAAe,GAAG,cAAc,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;AAE/H,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAEnG;AAED,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAuB/E"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export function ensureBindingDir(vfs, path) {
|
|
2
|
+
if (!vfs.exists(path))
|
|
3
|
+
vfs.mkdir(path, { recursive: true });
|
|
4
|
+
}
|
|
5
|
+
export async function coerceBindingBody(value) {
|
|
6
|
+
if (value == null)
|
|
7
|
+
return new Uint8Array(0);
|
|
8
|
+
if (typeof value === 'string')
|
|
9
|
+
return new TextEncoder().encode(value);
|
|
10
|
+
if (value instanceof Uint8Array)
|
|
11
|
+
return value;
|
|
12
|
+
if (value instanceof ArrayBuffer)
|
|
13
|
+
return new Uint8Array(value);
|
|
14
|
+
if (ArrayBuffer.isView(value))
|
|
15
|
+
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
16
|
+
if (typeof value === 'object' && 'getReader' in value && typeof value.getReader === 'function') {
|
|
17
|
+
const chunks = [];
|
|
18
|
+
let total = 0;
|
|
19
|
+
const reader = value.getReader();
|
|
20
|
+
for (;;) {
|
|
21
|
+
const { value: chunk, done } = await reader.read();
|
|
22
|
+
if (done)
|
|
23
|
+
break;
|
|
24
|
+
const bytes = chunk instanceof Uint8Array ? chunk : new Uint8Array(chunk);
|
|
25
|
+
chunks.push(bytes);
|
|
26
|
+
total += bytes.length;
|
|
27
|
+
}
|
|
28
|
+
const out = new Uint8Array(total);
|
|
29
|
+
let offset = 0;
|
|
30
|
+
for (const chunk of chunks) {
|
|
31
|
+
out.set(chunk, offset);
|
|
32
|
+
offset += chunk.length;
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
return new TextEncoder().encode(String(value));
|
|
37
|
+
}
|
package/dist/bindings/kv.d.ts
CHANGED
|
@@ -70,8 +70,6 @@ export declare class KvEmulator {
|
|
|
70
70
|
put(key: string, value: string | ArrayBuffer | ArrayBufferView | ReadableStream | Uint8Array | null, options?: KvPutOptions): Promise<void>;
|
|
71
71
|
delete(key: string): Promise<void>;
|
|
72
72
|
list(options?: KvListOptions): Promise<KvListResult>;
|
|
73
|
-
private _ensureDir;
|
|
74
|
-
private _coerceBody;
|
|
75
73
|
private _project;
|
|
76
74
|
private _readResolved;
|
|
77
75
|
private _readMeta;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kv.d.ts","sourceRoot":"","sources":["../../src/bindings/kv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"kv.d.ts","sourceRoot":"","sources":["../../src/bindings/kv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAGzE,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,eAAe,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,GAAG,QAAQ,CAAC;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,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Aa;IAa3B,OAAO,CAAC,SAAS;IAejB,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,aAAa;CAOtB"}
|
package/dist/bindings/kv.js
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
* Test seam: `_setKvNow(() => ts)` replaces the wall clock (Date.now/1000)
|
|
24
24
|
* for TTL probes. Production reads Date.now() / 1000.
|
|
25
25
|
*/
|
|
26
|
+
import { coerceBindingBody, ensureBindingDir } from './body.js';
|
|
26
27
|
// ── Test seam: clock ────────────────────────────────────────────────────
|
|
27
28
|
let _kvNow = () => Math.floor(Date.now() / 1000);
|
|
28
29
|
export function _setKvNow(fn) { _kvNow = fn; }
|
|
@@ -70,8 +71,8 @@ export class KvEmulator {
|
|
|
70
71
|
}
|
|
71
72
|
async put(key, value, options) {
|
|
72
73
|
const enc = encKey(key);
|
|
73
|
-
const bodyBlob = await
|
|
74
|
-
this.
|
|
74
|
+
const bodyBlob = await coerceBindingBody(value);
|
|
75
|
+
ensureBindingDir(this.vfs, this.dir);
|
|
75
76
|
this.vfs.writeFile(this.dir + '/' + enc, bodyBlob);
|
|
76
77
|
// Build sidecar
|
|
77
78
|
const meta = { v: 1 };
|
|
@@ -160,46 +161,6 @@ export class KvEmulator {
|
|
|
160
161
|
return out;
|
|
161
162
|
}
|
|
162
163
|
// ── internals ─────────────────────────────────────────────────────────
|
|
163
|
-
_ensureDir() {
|
|
164
|
-
if (!this.vfs.exists(this.dir)) {
|
|
165
|
-
this.vfs.mkdir(this.dir, { recursive: true });
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
async _coerceBody(value) {
|
|
169
|
-
if (value == null)
|
|
170
|
-
return new Uint8Array(0);
|
|
171
|
-
if (typeof value === 'string')
|
|
172
|
-
return new TextEncoder().encode(value);
|
|
173
|
-
if (value instanceof Uint8Array)
|
|
174
|
-
return value;
|
|
175
|
-
if (value instanceof ArrayBuffer)
|
|
176
|
-
return new Uint8Array(value);
|
|
177
|
-
if (ArrayBuffer.isView(value))
|
|
178
|
-
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
179
|
-
if (typeof value === 'object' && typeof value.getReader === 'function') {
|
|
180
|
-
// ReadableStream — drain
|
|
181
|
-
const chunks = [];
|
|
182
|
-
let total = 0;
|
|
183
|
-
const reader = value.getReader();
|
|
184
|
-
while (true) {
|
|
185
|
-
const { value: chunk, done } = await reader.read();
|
|
186
|
-
if (done)
|
|
187
|
-
break;
|
|
188
|
-
const u = chunk instanceof Uint8Array ? chunk : new Uint8Array(chunk);
|
|
189
|
-
chunks.push(u);
|
|
190
|
-
total += u.length;
|
|
191
|
-
}
|
|
192
|
-
const out = new Uint8Array(total);
|
|
193
|
-
let off = 0;
|
|
194
|
-
for (const c of chunks) {
|
|
195
|
-
out.set(c, off);
|
|
196
|
-
off += c.length;
|
|
197
|
-
}
|
|
198
|
-
return out;
|
|
199
|
-
}
|
|
200
|
-
// Fallback — try toString
|
|
201
|
-
return new TextEncoder().encode(String(value));
|
|
202
|
-
}
|
|
203
164
|
_project(body, type) {
|
|
204
165
|
const t = type || 'text';
|
|
205
166
|
if (t === 'text')
|
package/dist/bindings/r2.d.ts
CHANGED
|
@@ -120,8 +120,6 @@ export declare class R2Emulator {
|
|
|
120
120
|
}>;
|
|
121
121
|
createMultipartUpload(_key: string, _options?: any): Promise<never>;
|
|
122
122
|
resumeMultipartUpload(_key: string, _uploadId: string): Promise<never>;
|
|
123
|
-
private _ensureDir;
|
|
124
|
-
private _coerceBody;
|
|
125
123
|
private _readSide;
|
|
126
124
|
private _readSideEnc;
|
|
127
125
|
private _readBody;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"r2.d.ts","sourceRoot":"","sources":["../../src/bindings/r2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|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,CAAC;IAQ5E,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,WAAW;YAWL,UAAU;IAUxB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,aAAa;CAOtB"}
|
package/dist/bindings/r2.js
CHANGED
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
* every call (the body is one-shot per real-R2 contract), plus convenience
|
|
28
28
|
* helpers text() / arrayBuffer() / json() / blob().
|
|
29
29
|
*/
|
|
30
|
+
import { coerceBindingBody, ensureBindingDir } from './body.js';
|
|
30
31
|
// ── Path helpers ────────────────────────────────────────────────────────
|
|
31
32
|
function encKey(key) {
|
|
32
33
|
return encodeURIComponent(key);
|
|
@@ -136,7 +137,8 @@ export class R2Emulator {
|
|
|
136
137
|
return null;
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
|
-
const body =
|
|
140
|
+
const body = typeof Blob !== 'undefined' && value instanceof Blob
|
|
141
|
+
? new Uint8Array(await value.arrayBuffer()) : await coerceBindingBody(value);
|
|
140
142
|
const etag = await this._sha256Hex(body);
|
|
141
143
|
// Verify integrity hashes if supplied
|
|
142
144
|
if (options?.md5 || options?.sha1 || options?.sha256 || options?.sha512) {
|
|
@@ -160,7 +162,7 @@ export class R2Emulator {
|
|
|
160
162
|
side.httpMetadata = options.httpMetadata;
|
|
161
163
|
if (options?.customMetadata)
|
|
162
164
|
side.customMetadata = options.customMetadata;
|
|
163
|
-
this.
|
|
165
|
+
ensureBindingDir(this.vfs, this.dir);
|
|
164
166
|
const enc = encKey(key);
|
|
165
167
|
this.vfs.writeFile(this.dir + '/' + enc, body);
|
|
166
168
|
this.vfs.writeFile(this.dir + '/' + enc + '.meta', JSON.stringify(side));
|
|
@@ -248,48 +250,6 @@ export class R2Emulator {
|
|
|
248
250
|
throw new Error('R2 multipart uploads not supported in nimbus-wrangler dev (W10.5 candidate)');
|
|
249
251
|
}
|
|
250
252
|
// ── internals ─────────────────────────────────────────────────────────
|
|
251
|
-
_ensureDir() {
|
|
252
|
-
if (!this.vfs.exists(this.dir)) {
|
|
253
|
-
this.vfs.mkdir(this.dir, { recursive: true });
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
async _coerceBody(value) {
|
|
257
|
-
if (value == null)
|
|
258
|
-
return new Uint8Array(0);
|
|
259
|
-
if (typeof value === 'string')
|
|
260
|
-
return new TextEncoder().encode(value);
|
|
261
|
-
if (value instanceof Uint8Array)
|
|
262
|
-
return value;
|
|
263
|
-
if (value instanceof ArrayBuffer)
|
|
264
|
-
return new Uint8Array(value);
|
|
265
|
-
if (ArrayBuffer.isView(value))
|
|
266
|
-
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
267
|
-
if (typeof value === 'object' && typeof value.getReader === 'function') {
|
|
268
|
-
const chunks = [];
|
|
269
|
-
let total = 0;
|
|
270
|
-
const reader = value.getReader();
|
|
271
|
-
while (true) {
|
|
272
|
-
const { value: chunk, done } = await reader.read();
|
|
273
|
-
if (done)
|
|
274
|
-
break;
|
|
275
|
-
const u = chunk instanceof Uint8Array ? chunk : new Uint8Array(chunk);
|
|
276
|
-
chunks.push(u);
|
|
277
|
-
total += u.length;
|
|
278
|
-
}
|
|
279
|
-
const out = new Uint8Array(total);
|
|
280
|
-
let off = 0;
|
|
281
|
-
for (const c of chunks) {
|
|
282
|
-
out.set(c, off);
|
|
283
|
-
off += c.length;
|
|
284
|
-
}
|
|
285
|
-
return out;
|
|
286
|
-
}
|
|
287
|
-
if (typeof Blob !== 'undefined' && value instanceof Blob) {
|
|
288
|
-
const ab = await value.arrayBuffer();
|
|
289
|
-
return new Uint8Array(ab);
|
|
290
|
-
}
|
|
291
|
-
return new TextEncoder().encode(String(value));
|
|
292
|
-
}
|
|
293
253
|
_readSide(key) {
|
|
294
254
|
return this._readSideEnc(encKey(key));
|
|
295
255
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* esbuild-cli-artifact.generated.ts — AUTO-GENERATED by
|
|
3
|
+
* scripts/bundle-facet-workers.mjs. DO NOT EDIT.
|
|
4
|
+
*
|
|
5
|
+
* Pins the staged runner of the `esbuild` command: esbuild-wasm/wasm_exec.js
|
|
6
|
+
* (Go js/wasm glue, as __esbuildGoRuntime) followed by @nimbus-sh/core
|
|
7
|
+
* src/runtime/esbuild-cli/preamble.ts as an IIFE. Only the session's esbuild
|
|
8
|
+
* facet evaluates it, so src/runtime/esbuild-wasm-bytes.ts fetches it from
|
|
9
|
+
* ASSETS when that facet is built, instead of the Worker bundle carrying it.
|
|
10
|
+
* ESBUILD_CLI_BUILD_ID is a content-hash prefix, ESBUILD_CLI_SHA256 the
|
|
11
|
+
* digest every fetch is verified against.
|
|
12
|
+
*
|
|
13
|
+
* Size: 244.86 KiB
|
|
14
|
+
*/
|
|
15
|
+
export declare const ESBUILD_CLI_ASSET_PATH: string;
|
|
16
|
+
export declare const ESBUILD_CLI_BUILD_ID: string;
|
|
17
|
+
export declare const ESBUILD_CLI_SHA256: string;
|
|
18
|
+
//# sourceMappingURL=esbuild-cli-artifact.generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild-cli-artifact.generated.d.ts","sourceRoot":"","sources":["../src/esbuild-cli-artifact.generated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,sBAAsB,EAAE,MAA2D,CAAC;AACjG,eAAO,MAAM,oBAAoB,EAAE,MAA2B,CAAC;AAC/D,eAAO,MAAM,kBAAkB,EAAE,MAA2E,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* esbuild-cli-artifact.generated.ts — AUTO-GENERATED by
|
|
3
|
+
* scripts/bundle-facet-workers.mjs. DO NOT EDIT.
|
|
4
|
+
*
|
|
5
|
+
* Pins the staged runner of the `esbuild` command: esbuild-wasm/wasm_exec.js
|
|
6
|
+
* (Go js/wasm glue, as __esbuildGoRuntime) followed by @nimbus-sh/core
|
|
7
|
+
* src/runtime/esbuild-cli/preamble.ts as an IIFE. Only the session's esbuild
|
|
8
|
+
* facet evaluates it, so src/runtime/esbuild-wasm-bytes.ts fetches it from
|
|
9
|
+
* ASSETS when that facet is built, instead of the Worker bundle carrying it.
|
|
10
|
+
* ESBUILD_CLI_BUILD_ID is a content-hash prefix, ESBUILD_CLI_SHA256 the
|
|
11
|
+
* digest every fetch is verified against.
|
|
12
|
+
*
|
|
13
|
+
* Size: 244.86 KiB
|
|
14
|
+
*/
|
|
15
|
+
export const ESBUILD_CLI_ASSET_PATH = "/_assets/runtime/esbuild-cli-c4fda380d52befc1.js";
|
|
16
|
+
export const ESBUILD_CLI_BUILD_ID = "c4fda380d52befc1";
|
|
17
|
+
export const ESBUILD_CLI_SHA256 = "c4fda380d52befc178dc8202897f14f04117662f2611d0c2f6e6c55c1fffb78f";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cirrus-real.d.ts","sourceRoot":"","sources":["../../src/facets/cirrus-real.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;
|
|
1
|
+
{"version":3,"file":"cirrus-real.d.ts","sourceRoot":"","sources":["../../src/facets/cirrus-real.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AA2BH,OAAO,EACL,SAAS,EAIV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAEpF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AAmBtF;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CAAC;QACjC,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC9C;IAWD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,IAAI,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgBnC;IAED;;;iEAG6D;IAC7D,OAAO,CAAC,YAAY,CAAc;IAE5B,KAAK,CAAC,GAAG,EAAE,kBAAkB,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuQhE,IAAI,CAAC,GAAG,CAAC,EAAE,kBAAkB,GAAG,IAAI;IAqBpC;;;;OAIG;IACH,eAAe,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM;IAItC,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAIjC,uBAAuB,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAItD;;;;OAIG;IACG,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IA8C1E;;;;;;OAMG;IACG,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAsBzD"}
|
|
@@ -58,6 +58,8 @@ import { CIRRUS_PLUGIN_REACT_VERSION, getCirrusPluginReactBundle, } from '../cir
|
|
|
58
58
|
import { CIRRUS_NPM_CJS_VERSIONS, getCirrusNpmCjsBundles } from '../cirrus-npm-cjs.generated.js';
|
|
59
59
|
import { CF_COMPAT_DATE } from '@nimbus-sh/core/constants.js';
|
|
60
60
|
import { getCtxExports, hostRoute } from '@nimbus-sh/fabric/composition.js';
|
|
61
|
+
import { supervisorBindingProps, supervisorLoaderKey } from '@nimbus-sh/fabric/supervisor-props.js';
|
|
62
|
+
import { deleteFacetStorage } from '@nimbus-sh/fabric/workerd-facet-host.js';
|
|
61
63
|
import { buildFsSnapshot, generateFsShimModuleCode, generateFsPromisesShimModuleCode, generateSyntheticModuleCode, } from './real-vite-fs-shim.js';
|
|
62
64
|
import { HmrBridge, registerHmrBridge, generateWsShimModuleCode, generateChokidarShimModuleCode, } from './real-vite-hmr.js';
|
|
63
65
|
import { CRED_KERNEL } from '@nimbus-sh/core/runtime/os-contracts.js';
|
|
@@ -725,8 +727,9 @@ export class CirrusReal {
|
|
|
725
727
|
viteEnvMjs: VITE_ENV_MJS,
|
|
726
728
|
});
|
|
727
729
|
const ctxExports = getCtxExports();
|
|
730
|
+
const supervisorProps = supervisorBindingProps(ctx, pid);
|
|
728
731
|
const supervisorBinding = ctxExports?.SupervisorRPC
|
|
729
|
-
? ctxExports.SupervisorRPC({ props:
|
|
732
|
+
? ctxExports.SupervisorRPC({ props: supervisorProps })
|
|
730
733
|
: undefined;
|
|
731
734
|
// Phase 2: separate HMR binding so we don't need to modify
|
|
732
735
|
// supervisor-rpc.ts (off-limits). The CirrusHmrRPC class lives in
|
|
@@ -749,7 +752,7 @@ export class CirrusReal {
|
|
|
749
752
|
// exist". Two restarts on the same pid hit the warm cache.
|
|
750
753
|
// Step B: worker.getDurableObjectClass('CirrusRealVite') → the
|
|
751
754
|
// class constructor from the dynamic worker's exports. Same
|
|
752
|
-
// pattern
|
|
755
|
+
// pattern facets/manager.ts uses for NodeProcess.
|
|
753
756
|
//
|
|
754
757
|
// Step C: ctx.facets.get('cirrus-real-vite', { class }) → DO Facet
|
|
755
758
|
// stub. The facet has its own SQLite (used by the cookie row),
|
|
@@ -757,7 +760,9 @@ export class CirrusReal {
|
|
|
757
760
|
// DO so eviction is coherent. The same name returns the same
|
|
758
761
|
// facet on subsequent calls — that's what makes the cookie
|
|
759
762
|
// persist across supervisor reconnects.
|
|
760
|
-
|
|
763
|
+
// The loader outlives this instance, and a warm worker keeps the
|
|
764
|
+
// SUPERVISOR binding in its env.
|
|
765
|
+
const stableLoaderId = supervisorLoaderKey(`${ctx.id.toString()}:cirrus-real-vite:${REAL_VITE_VERSION}:${pid}`, supervisorProps);
|
|
761
766
|
const facetName = 'cirrus-real-vite';
|
|
762
767
|
try {
|
|
763
768
|
const worker = this.env.LOADER.get(stableLoaderId, async () => ({
|
|
@@ -888,7 +893,7 @@ export class CirrusReal {
|
|
|
888
893
|
// until the supervisor itself is evicted).
|
|
889
894
|
if (this._facetName && ctx) {
|
|
890
895
|
try {
|
|
891
|
-
ctx
|
|
896
|
+
deleteFacetStorage(ctx, this._facetName);
|
|
892
897
|
}
|
|
893
898
|
catch { }
|
|
894
899
|
}
|
package/dist/facets/compose.d.ts
CHANGED
|
@@ -21,10 +21,11 @@
|
|
|
21
21
|
*
|
|
22
22
|
* What the factory owns and the host does not:
|
|
23
23
|
*
|
|
24
|
-
* -
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
24
|
+
* - the manager's esbuild, when the host shares none: its transforms run
|
|
25
|
+
* in a loader-backed facet that owns the esbuild wasm heap, because that
|
|
26
|
+
* heap is never released and the host's isolate is memory-constrained.
|
|
27
|
+
* It needs `env.LOADER`, `env.ASSETS` and `ctx.facets` and nothing of
|
|
28
|
+
* any host, so it is the factory's default rather than every host's copy.
|
|
28
29
|
* - `resolveWorkerLaunchFallback`: the durable image-store resolver a
|
|
29
30
|
* self-owned worker launch (the session's python/ruby residents, or an
|
|
30
31
|
* embedder spawn that let the manager persist its image) re-drives
|
|
@@ -33,12 +34,12 @@
|
|
|
33
34
|
* for its recipes (see `WorkerRecipe.resident`).
|
|
34
35
|
*/
|
|
35
36
|
import type { SqliteVFS } from '@nimbus-sh/core/vfs/sqlite-vfs.js';
|
|
36
|
-
import type { NimbusFilesystemAuthority } from '@nimbus-sh/core/runtime/os-contracts.js';
|
|
37
37
|
import type { PortRegistry } from '@nimbus-sh/core/runtime/port-registry.js';
|
|
38
38
|
import type { SessionProcessSupervisor } from '@nimbus-sh/core/runtime/session-process-supervisor.js';
|
|
39
39
|
import type { EsbuildService } from '@nimbus-sh/core/runtime/esbuild-service.js';
|
|
40
40
|
import { FacetManager, type FacetManagerHooks } from './manager.js';
|
|
41
41
|
import { type PortVisibility } from '../session/port-capability.js';
|
|
42
|
+
import type { ProcessFiles } from '@nimbus-sh/core/runtime/process-files.js';
|
|
42
43
|
export type { FacetManagerHooks, LongRunningWorkerSpawnOptions, ResidentSpawnOptions, ResolvedWorkerLaunch, ResidentAppSummary, ResidentIdentity, ResidentRestartPolicy, SpawnedWorker, WorkerFacet, WorkerRecipe, } from './manager.js';
|
|
43
44
|
export { FacetManager, DEFAULT_WORKER_MAIN_MODULE } from './manager.js';
|
|
44
45
|
/**
|
|
@@ -65,8 +66,11 @@ export interface FacetManagerDeps {
|
|
|
65
66
|
portRegistry: PortRegistry;
|
|
66
67
|
vfs: SqliteVFS;
|
|
67
68
|
/** The session's one authority — the manager never constructs a second. */
|
|
68
|
-
filesystem:
|
|
69
|
-
/**
|
|
69
|
+
filesystem: ProcessFiles;
|
|
70
|
+
/**
|
|
71
|
+
* A host's esbuild, shared with the manager. Absent: one whose transforms
|
|
72
|
+
* run in the loader-backed transform facet, never in this isolate.
|
|
73
|
+
*/
|
|
70
74
|
esbuild?: EsbuildService;
|
|
71
75
|
hooks: FacetManagerHostHooks;
|
|
72
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/facets/compose.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/facets/compose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAEnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uDAAuD,CAAC;AACtG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;A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
|
-
*
|
|
27
|
-
*
|
|
24
|
+
* - the manager's esbuild, when the host shares none: its transforms run
|
|
25
|
+
* in a loader-backed facet that owns the esbuild wasm heap, because that
|
|
26
|
+
* heap is never released and the host's isolate is memory-constrained.
|
|
27
|
+
* It needs `env.LOADER`, `env.ASSETS` and `ctx.facets` and nothing of
|
|
28
|
+
* any host, so it is the factory's default rather than every host's copy.
|
|
28
29
|
* - `resolveWorkerLaunchFallback`: the durable image-store resolver a
|
|
29
30
|
* self-owned worker launch (the session's python/ruby residents, or an
|
|
30
31
|
* embedder spawn that let the manager persist its image) re-drives
|
|
@@ -32,14 +33,14 @@
|
|
|
32
33
|
* content store answers `resolveWorkerLaunch` and this is never reached
|
|
33
34
|
* for its recipes (see `WorkerRecipe.resident`).
|
|
34
35
|
*/
|
|
36
|
+
import { CRED_KERNEL } from '@nimbus-sh/core/runtime/os-contracts.js';
|
|
35
37
|
import { createPortCapability } from '@nimbus-sh/core/runtime/port-registry.js';
|
|
36
38
|
import { FacetManager } from './manager.js';
|
|
37
39
|
import { processHostFor } from '../loaders/process-host.js';
|
|
38
40
|
import { resolveDurableWorkerImage } from './durable-images.js';
|
|
39
41
|
import { persistPortCapability, readPortReservation, readPortReservationByOwner, reservePort, routeCapabilityPort, } from '../session/port-capability.js';
|
|
40
42
|
import { bindPublicPortCapability } from '../router/public-directory.js';
|
|
41
|
-
import {
|
|
42
|
-
import { fetchEsbuildJsFnBody, fetchEsbuildWasmBytes } from '../runtime/esbuild-wasm-bytes.js';
|
|
43
|
+
import { supervisorEsbuildService } from './esbuild-transform.js';
|
|
43
44
|
export { FacetManager, DEFAULT_WORKER_MAIN_MODULE } from './manager.js';
|
|
44
45
|
/**
|
|
45
46
|
* Compose a FacetManager over a host's own ctx, env, process supervisor, port
|
|
@@ -55,13 +56,11 @@ export function composeFacetManager(deps) {
|
|
|
55
56
|
...(deps.hooks.resolveWorkerLaunch !== undefined
|
|
56
57
|
? { resolveWorkerLaunch: deps.hooks.resolveWorkerLaunch }
|
|
57
58
|
: {}),
|
|
58
|
-
transformLargeEsm: isolatedEsmTransform(ctx, env),
|
|
59
59
|
resolveWorkerLaunchFallback: (recipe) => resolveDurableWorkerImage(vfs, recipe),
|
|
60
60
|
};
|
|
61
61
|
const manager = new FacetManager(ctx, env, deps.processes, deps.portRegistry, processHostFor, hooks);
|
|
62
62
|
manager.setVfs(vfs, deps.filesystem);
|
|
63
|
-
|
|
64
|
-
manager.setEsbuildService(deps.esbuild);
|
|
63
|
+
manager.setEsbuildService(deps.esbuild ?? supervisorEsbuildService(ctx, env, deps.filesystem.namespaceFs(CRED_KERNEL)));
|
|
65
64
|
const { portRegistry } = deps;
|
|
66
65
|
const capabilityHost = { ctx, portRegistry };
|
|
67
66
|
return {
|
|
@@ -122,32 +121,3 @@ export function composeFacetManager(deps) {
|
|
|
122
121
|
},
|
|
123
122
|
};
|
|
124
123
|
}
|
|
125
|
-
/**
|
|
126
|
-
* The isolated esbuild transform: module text past the in-isolate bound is
|
|
127
|
-
* transformed in a loader-backed facet that owns the esbuild wasm heap, so the
|
|
128
|
-
* host isolate never pays for it. Session-independent by construction —
|
|
129
|
-
* `env.LOADER`, `env.ASSETS` and `ctx.facets` are all it reads.
|
|
130
|
-
*/
|
|
131
|
-
function isolatedEsmTransform(ctx, env) {
|
|
132
|
-
return async (code, options) => {
|
|
133
|
-
const loader = Reflect.get(Object(env), 'LOADER');
|
|
134
|
-
if (!loader || typeof loader.get !== 'function') {
|
|
135
|
-
throw new Error('Nimbus: env.LOADER unavailable for isolated esbuild transform');
|
|
136
|
-
}
|
|
137
|
-
const assets = Reflect.get(Object(env), 'ASSETS');
|
|
138
|
-
if (!assets || typeof assets.fetch !== 'function') {
|
|
139
|
-
throw new Error('Nimbus: env.ASSETS unavailable for isolated esbuild transform');
|
|
140
|
-
}
|
|
141
|
-
const worker = await loader.get(ESBUILD_TRANSFORM_WORKER_ID, async () => {
|
|
142
|
-
const assetsEnv = { ASSETS: assets };
|
|
143
|
-
const [wasmBytes, jsFnBody] = await Promise.all([
|
|
144
|
-
fetchEsbuildWasmBytes(assetsEnv),
|
|
145
|
-
fetchEsbuildJsFnBody(assetsEnv),
|
|
146
|
-
]);
|
|
147
|
-
return esbuildTransformWorkerCode(wasmBytes, jsFnBody);
|
|
148
|
-
});
|
|
149
|
-
const transformClass = worker.getDurableObjectClass('EsbuildTransformFacet');
|
|
150
|
-
const facet = ctx.facets.get(`esbuild-transform-${ESBUILD_TRANSFORM_WORKER_ID}`, async () => ({ class: transformClass }));
|
|
151
|
-
return facet.transform(code, options);
|
|
152
|
-
};
|
|
153
|
-
}
|