@nimbus-sh/worker 0.3.0 → 0.5.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/README.md +46 -43
- package/dist/_shared/preview-host.d.ts +14 -1
- package/dist/_shared/preview-host.d.ts.map +1 -1
- package/dist/_shared/preview-host.js +28 -3
- package/dist/_shared/session-router.d.ts +43 -0
- package/dist/_shared/session-router.d.ts.map +1 -1
- package/dist/_shared/session-router.js +59 -12
- package/dist/esbuild-wasm-bundle.generated.d.ts +1 -1
- package/dist/esbuild-wasm-bundle.generated.js +1 -1
- package/dist/facets/cirrus-real.js +1 -1
- package/dist/facets/durable-images.d.ts +50 -0
- package/dist/facets/durable-images.d.ts.map +1 -0
- package/dist/facets/durable-images.js +75 -0
- package/dist/facets/durable-slots.d.ts +45 -0
- package/dist/facets/durable-slots.d.ts.map +1 -0
- package/dist/facets/durable-slots.js +94 -0
- package/dist/facets/esbuild-transform.d.ts +10 -0
- package/dist/facets/esbuild-transform.d.ts.map +1 -0
- package/dist/facets/esbuild-transform.js +36 -0
- package/dist/facets/manager.d.ts +167 -12
- package/dist/facets/manager.d.ts.map +1 -1
- package/dist/facets/manager.js +575 -113
- package/dist/facets/opencode-staging.d.ts.map +1 -1
- package/dist/facets/opencode-staging.js +3 -4
- package/dist/facets/real-vite-hmr.js +1 -1
- package/dist/facets/vite-dev-server.d.ts +4 -4
- package/dist/facets/vite-dev-server.js +5 -5
- package/dist/git/commands.d.ts +22 -0
- package/dist/git/commands.d.ts.map +1 -1
- package/dist/git/commands.js +431 -424
- package/dist/git/network-facet.d.ts.map +1 -1
- package/dist/git/network-facet.js +6 -5
- package/dist/git-bundle.generated.d.ts +2 -2
- package/dist/git-bundle.generated.d.ts.map +1 -1
- package/dist/git-bundle.generated.js +3 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -2
- package/dist/loaders/child-process/spawn-facet.js +1 -1
- package/dist/loaders/child-process/spawn-pool.d.ts.map +1 -1
- package/dist/loaders/child-process/spawn-pool.js +2 -2
- package/dist/loaders/generated-workers.d.ts +2 -2
- package/dist/loaders/generated-workers.d.ts.map +1 -1
- package/dist/loaders/generated-workers.js +3 -3
- package/dist/loaders/npm-resolve-preamble.d.ts +3 -3
- package/dist/loaders/npm-resolve-preamble.js +3 -3
- package/dist/loaders/pre-bundle-preamble.d.ts +5 -5
- package/dist/loaders/pre-bundle-preamble.js +6 -6
- package/dist/node-shims-artifact.generated.js +3 -3
- package/dist/npm/install-batch-facet.d.ts +1 -1
- package/dist/npm/install-batch-facet.js +1 -1
- package/dist/npm/installer.d.ts +6 -6
- package/dist/npm/installer.d.ts.map +1 -1
- package/dist/npm/installer.js +28 -27
- package/dist/npm/pre-bundle-facet.d.ts +2 -2
- package/dist/npm/pre-bundle-facet.js +5 -5
- package/dist/npm/r2-cache.d.ts +1 -1
- package/dist/npm/resolve-facet.d.ts +1 -1
- package/dist/npm/resolve-facet.js +1 -1
- package/dist/npm/resolve-one-facet.d.ts +5 -5
- package/dist/npm/resolve-one-facet.js +5 -5
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +61 -4
- package/dist/router/public-directory-do.d.ts +17 -0
- package/dist/router/public-directory-do.d.ts.map +1 -0
- package/dist/router/public-directory-do.js +16 -0
- package/dist/router/public-directory.d.ts +75 -0
- package/dist/router/public-directory.d.ts.map +1 -0
- package/dist/router/public-directory.js +115 -0
- package/dist/router/remote-api.d.ts +9 -1
- package/dist/router/remote-api.d.ts.map +1 -1
- package/dist/router/remote-api.js +20 -3
- package/dist/runtime/bun-repl.d.ts +1 -1
- package/dist/runtime/bun-repl.js +3 -3
- package/dist/runtime/esbuild-wasm-bytes.js +1 -1
- package/dist/runtime/facet-loader-host.d.ts +2 -2
- package/dist/runtime/facet-loader-host.js +3 -3
- package/dist/runtime/node-repl.js +2 -2
- package/dist/runtime/node-shims-artifact.js +1 -1
- package/dist/runtime/node-shims.d.ts +4 -1
- package/dist/runtime/node-shims.d.ts.map +1 -1
- package/dist/runtime/node-shims.js +326 -7
- package/dist/runtime/opencode-artifact.js +1 -1
- package/dist/runtime/opentui-wasm-bytes.js +1 -1
- package/dist/runtime/python-repl.js +3 -3
- package/dist/runtime/ruby-repl.js +2 -2
- package/dist/runtime/sqlite-wasm-bytes.js +1 -1
- package/dist/session/agent.d.ts +11 -0
- package/dist/session/agent.d.ts.map +1 -1
- package/dist/session/diag.js +1 -1
- package/dist/session/helpers.js +1 -1
- package/dist/session/hibernation.d.ts +8 -8
- package/dist/session/hibernation.d.ts.map +1 -1
- package/dist/session/hibernation.js +15 -15
- package/dist/session/init-phases.d.ts +19 -26
- package/dist/session/init-phases.d.ts.map +1 -1
- package/dist/session/init-phases.js +20 -43
- package/dist/session/init.d.ts.map +1 -1
- package/dist/session/init.js +24 -19
- package/dist/session/keys.d.ts +8 -0
- package/dist/session/keys.d.ts.map +1 -1
- package/dist/session/keys.js +12 -3
- package/dist/session/nimbus-session.d.ts +33 -19
- package/dist/session/nimbus-session.d.ts.map +1 -1
- package/dist/session/nimbus-session.js +78 -37
- package/dist/session/port-capability.d.ts +95 -8
- package/dist/session/port-capability.d.ts.map +1 -1
- package/dist/session/port-capability.js +165 -8
- package/dist/session/programmatic.d.ts +50 -4
- package/dist/session/programmatic.d.ts.map +1 -1
- package/dist/session/programmatic.js +112 -15
- package/dist/session/routes.d.ts +17 -0
- package/dist/session/routes.d.ts.map +1 -1
- package/dist/session/routes.js +111 -43
- package/dist/session/rpc.d.ts +7 -7
- package/dist/session/rpc.d.ts.map +1 -1
- package/dist/session/rpc.js +34 -23
- package/dist/session/shell-socket.d.ts +76 -0
- package/dist/session/shell-socket.d.ts.map +1 -0
- package/dist/session/shell-socket.js +172 -0
- package/dist/session/start-real-vite.js +2 -2
- package/dist/session/supervisor-op.d.ts +5 -0
- package/dist/session/supervisor-op.d.ts.map +1 -0
- package/dist/session/supervisor-op.js +74 -0
- package/dist/session/supervisor-rpc.d.ts +6 -10
- package/dist/session/supervisor-rpc.d.ts.map +1 -1
- package/dist/session/supervisor-rpc.js +98 -79
- package/dist/session/ws.d.ts +1 -3
- package/dist/session/ws.d.ts.map +1 -1
- package/dist/session/ws.js +23 -7
- package/package.json +4 -3
- package/public/_assets/runtime/{node-shims-fea906843f6d594e.js → node-shims-9e1380d9ee430fcc.js} +320 -5
- package/public/s/index.html +101 -5
- package/scripts/bundle-esbuild-wasm.mjs +2 -2
- package/scripts/bundle-facet-workers.mjs +5 -7
- package/scripts/bundle-sqlite-wasm.mjs +1 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* public-directory.ts — capability → session routing for public preview hosts.
|
|
3
|
+
*
|
|
4
|
+
* The public capability host form `<cap>--<port>--<sid>.<suffix>` carries
|
|
5
|
+
* no session:attach credential, so the router has no verified tenant to
|
|
6
|
+
* name the session DO with. This singleton Durable Object is the one
|
|
7
|
+
* lookup that answers it: keyed by the unguessable 24-hex capability,
|
|
8
|
+
* it says which tenant segment + sid + port the capability belongs to.
|
|
9
|
+
* Rows are written by the session the moment a port goes public and are
|
|
10
|
+
* deleted on unexpose/clear/remove — there is no listing API, so the
|
|
11
|
+
* directory is never an enumeration surface.
|
|
12
|
+
*/
|
|
13
|
+
const BINDING_NAME = 'NIMBUS_PUBLIC_DIRECTORY';
|
|
14
|
+
const DIRECTORY_NAME = 'public-directory';
|
|
15
|
+
const ROW_PREFIX = 'public-capability:';
|
|
16
|
+
function rowKey(capability) {
|
|
17
|
+
return `${ROW_PREFIX}${capability}`;
|
|
18
|
+
}
|
|
19
|
+
/** The DO body, usable with any `{ storage }` the tests hand it. */
|
|
20
|
+
export class PublicDirectoryStore {
|
|
21
|
+
ctx;
|
|
22
|
+
constructor(ctx) {
|
|
23
|
+
this.ctx = ctx;
|
|
24
|
+
}
|
|
25
|
+
async bind(capability, entry) {
|
|
26
|
+
if (!/^[a-f0-9]{24}$/.test(capability)) {
|
|
27
|
+
throw new Error('NimbusPublicDirectory.bind: capability must be 24 lowercase hex');
|
|
28
|
+
}
|
|
29
|
+
if (typeof entry.tenantSegment !== 'string' || entry.tenantSegment.length === 0
|
|
30
|
+
|| typeof entry.sid !== 'string' || entry.sid.length === 0
|
|
31
|
+
|| !Number.isInteger(entry.port) || entry.port < 1 || entry.port > 65535) {
|
|
32
|
+
throw new Error('NimbusPublicDirectory.bind: entry needs tenantSegment, sid, and a real port');
|
|
33
|
+
}
|
|
34
|
+
await this.ctx.storage.put(rowKey(capability), {
|
|
35
|
+
tenantSegment: entry.tenantSegment,
|
|
36
|
+
sid: entry.sid,
|
|
37
|
+
port: entry.port,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async unbind(capability) {
|
|
41
|
+
await this.ctx.storage.delete(rowKey(capability));
|
|
42
|
+
}
|
|
43
|
+
async resolve(capability) {
|
|
44
|
+
const stored = await this.ctx.storage.get(rowKey(capability));
|
|
45
|
+
if (!stored)
|
|
46
|
+
return null;
|
|
47
|
+
return stored;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The stub the router and the session share: one name, one binding, one
|
|
52
|
+
* instance. A missing binding on an enforce-mode deployment is loud at the
|
|
53
|
+
* caller — this helper returns null and the caller decides.
|
|
54
|
+
*/
|
|
55
|
+
export function publicDirectoryStub(env) {
|
|
56
|
+
const namespace = env?.[BINDING_NAME];
|
|
57
|
+
if (!namespace || typeof namespace.idFromName !== 'function')
|
|
58
|
+
return null;
|
|
59
|
+
return namespace.get(namespace.idFromName(DIRECTORY_NAME));
|
|
60
|
+
}
|
|
61
|
+
// ── Session side ─────────────────────────────────────────────────────────────
|
|
62
|
+
import { LEGACY_PUBLIC_DO_SEGMENT } from '../_shared/session-router.js';
|
|
63
|
+
/**
|
|
64
|
+
* `{ tenantSegment, sid }` for the session DO this host is, read off its own
|
|
65
|
+
* DO name — `tn:sub:sid` (or `legacy:public:_:sid`), no request header
|
|
66
|
+
* needed. A host without a DO id (a unit-test stub) may carry the fields on
|
|
67
|
+
* itself.
|
|
68
|
+
*/
|
|
69
|
+
function sessionIdentity(host) {
|
|
70
|
+
const name = host.ctx?.id?.name;
|
|
71
|
+
if (typeof name === 'string' && name.length > 0) {
|
|
72
|
+
const cut = name.lastIndexOf(':');
|
|
73
|
+
if (cut > 0)
|
|
74
|
+
return { tenantSegment: name.slice(0, cut), sid: name.slice(cut + 1) };
|
|
75
|
+
}
|
|
76
|
+
if (typeof host.tenantSegment === 'string' && typeof host.sessionId === 'string'
|
|
77
|
+
&& host.tenantSegment.length > 0 && host.sessionId.length > 0) {
|
|
78
|
+
return { tenantSegment: host.tenantSegment, sid: host.sessionId };
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Publish a public port's capability to the routing directory. A legacy-
|
|
84
|
+
* public deployment needs no directory — its DO name is already the one
|
|
85
|
+
* the public form resolves to — and is allowed to run without the binding.
|
|
86
|
+
* Anything else MUST bind, and a missing `NIMBUS_PUBLIC_DIRECTORY` binding
|
|
87
|
+
* on a non-legacy deployment is a loud error: the exposure would be half-
|
|
88
|
+
* public — stored as public, unroutable in practice.
|
|
89
|
+
*/
|
|
90
|
+
export async function bindPublicPortCapability(host, capability, port) {
|
|
91
|
+
const identity = sessionIdentity(host);
|
|
92
|
+
if (identity === null)
|
|
93
|
+
return;
|
|
94
|
+
if (identity.tenantSegment === LEGACY_PUBLIC_DO_SEGMENT)
|
|
95
|
+
return;
|
|
96
|
+
const stub = publicDirectoryStub(host.env);
|
|
97
|
+
if (stub === null) {
|
|
98
|
+
throw new Error('Nimbus: a public port exposure needs the NIMBUS_PUBLIC_DIRECTORY binding '
|
|
99
|
+
+ '— without it the capability URL cannot resolve to this session. '
|
|
100
|
+
+ 'Add the binding and the NimbusPublicDirectory migration to wrangler.jsonc.');
|
|
101
|
+
}
|
|
102
|
+
await stub.bind(capability, { tenantSegment: identity.tenantSegment, sid: identity.sid, port });
|
|
103
|
+
}
|
|
104
|
+
/** Retire a public port's capability from the routing directory. */
|
|
105
|
+
export async function unbindPublicPortCapability(host, capability) {
|
|
106
|
+
const identity = sessionIdentity(host);
|
|
107
|
+
if (identity === null)
|
|
108
|
+
return;
|
|
109
|
+
if (identity.tenantSegment === LEGACY_PUBLIC_DO_SEGMENT)
|
|
110
|
+
return;
|
|
111
|
+
const stub = publicDirectoryStub(host.env);
|
|
112
|
+
if (stub === null)
|
|
113
|
+
return; // unbind of a bind that never happened is not an error
|
|
114
|
+
await stub.unbind(capability);
|
|
115
|
+
}
|
|
@@ -81,7 +81,15 @@ interface NimbusSessionRpcStub {
|
|
|
81
81
|
bytes?: number;
|
|
82
82
|
}): Promise<unknown>;
|
|
83
83
|
_rpcListPorts(): Promise<unknown>;
|
|
84
|
-
_rpcExposePort(port: number
|
|
84
|
+
_rpcExposePort(port: number, options?: {
|
|
85
|
+
visibility?: 'scoped' | 'public';
|
|
86
|
+
}): Promise<unknown>;
|
|
87
|
+
_rpcEnsureDurableApp(input: {
|
|
88
|
+
owner?: string;
|
|
89
|
+
preferredPort?: number;
|
|
90
|
+
visibility?: 'scoped' | 'public';
|
|
91
|
+
}): Promise<unknown>;
|
|
92
|
+
_rpcRemoveDurableApp(owner: string): Promise<unknown>;
|
|
85
93
|
_rpcUnexposePort(port: number): Promise<unknown>;
|
|
86
94
|
_rpcDestroy(options?: Record<string, unknown>): Promise<unknown>;
|
|
87
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-api.d.ts","sourceRoot":"","sources":["../../src/router/remote-api.ts"],"names":[],"mappings":"AAIA,OAAO,EAML,KAAK,aAAa,EAEnB,MAAM,kBAAkB,CAAC;AAG1B,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN,KAAK,GACL,KAAK,GACL,KAAK,GACL,QAAQ,GACR,MAAM,GACN,OAAO,GACP,OAAO,GACP,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,MAAM,WAAW,mBAAmB;IACl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U,sBAAsB;IAC9B,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC;IAC1C,GAAG,CAAC,EAAE,EAAE,eAAe,GAAG,oBAAoB,CAAC;CAChD;AAED,UAAU,eAAgB,SAAQ,OAAO,CAAC,aAAa,CAAC;IACtD,cAAc,CAAC,EAAE,sBAAsB,CAAC;CACzC;AAmCD,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,qBAAqB,GAAG,SAAS,GACrC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CA2E1B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LEGACY_PUBLIC_DO_SEGMENT, } from '../_shared/session-router.js';
|
|
2
2
|
import { z } from 'zod/v4';
|
|
3
3
|
import { requireScopes, requireSessionPin, verifyRequestToken, NimbusAuthError, isNimbusIdComponent, } from '../auth/index.js';
|
|
4
|
-
import { useRpcResource } from '@nimbus-sh/
|
|
4
|
+
import { useRpcResource } from '@nimbus-sh/platform/rpc-dispose.js';
|
|
5
5
|
const DEFAULT_REMOTE_BASE_PATH = '/api/nimbus/v1';
|
|
6
6
|
const RemoteRpcBodySchema = z.object({
|
|
7
7
|
profile: z.string().optional(),
|
|
@@ -221,8 +221,25 @@ async function dispatchRemoteRpc(ctx) {
|
|
|
221
221
|
return ctx.stub._rpcProcessLogs(numberArg(args[0], 'pid'), processLogOptions(args[1]));
|
|
222
222
|
case 'listPorts':
|
|
223
223
|
return ctx.stub._rpcListPorts();
|
|
224
|
-
case 'exposePort':
|
|
225
|
-
|
|
224
|
+
case 'exposePort': {
|
|
225
|
+
const options = args[1] === undefined ? undefined : objectArg(args[1]);
|
|
226
|
+
return ctx.stub._rpcExposePort(numberArg(args[0], 'port'), options === undefined ? undefined : {
|
|
227
|
+
visibility: options.visibility === undefined ? undefined
|
|
228
|
+
: options.visibility === 'public' ? 'public' : 'scoped',
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
case 'ensureDurableApp': {
|
|
232
|
+
const input = objectArg(args[0]);
|
|
233
|
+
return ctx.stub._rpcEnsureDurableApp({
|
|
234
|
+
owner: stringArg(input.owner, 'owner'),
|
|
235
|
+
...(input.preferredPort === undefined ? {} : { preferredPort: numberArg(input.preferredPort, 'preferredPort') }),
|
|
236
|
+
...(input.visibility === undefined ? {} : { visibility: input.visibility === 'public' ? 'public' : 'scoped' }),
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
case 'removeDurableApp': {
|
|
240
|
+
const input = objectArg(args[0]);
|
|
241
|
+
return ctx.stub._rpcRemoveDurableApp(stringArg(input.owner, 'owner'));
|
|
242
|
+
}
|
|
226
243
|
case 'unexposePort':
|
|
227
244
|
return ctx.stub._rpcUnexposePort(numberArg(args[0], 'port'));
|
|
228
245
|
case 'destroy':
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* functions / imports persist.
|
|
8
8
|
*
|
|
9
9
|
* Design:
|
|
10
|
-
* - One child-facet per REPL session (
|
|
10
|
+
* - One child-facet per REPL session (IsolatePool with
|
|
11
11
|
* concurrency=1, omitSupervisor=true).
|
|
12
12
|
* - Facet-side: globalThis.__nimbus_bun_ctx caches a vm.createContext()
|
|
13
13
|
* dict; each push() runs vm.runInContext(line, ctx) and returns
|
package/dist/runtime/bun-repl.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* functions / imports persist.
|
|
8
8
|
*
|
|
9
9
|
* Design:
|
|
10
|
-
* - One child-facet per REPL session (
|
|
10
|
+
* - One child-facet per REPL session (IsolatePool with
|
|
11
11
|
* concurrency=1, omitSupervisor=true).
|
|
12
12
|
* - Facet-side: globalThis.__nimbus_bun_ctx caches a vm.createContext()
|
|
13
13
|
* dict; each push() runs vm.runInContext(line, ctx) and returns
|
|
@@ -125,8 +125,8 @@ class BunReplAdapter {
|
|
|
125
125
|
// Preamble: install the Bun shim global at facet startup so the
|
|
126
126
|
// REPL context has Bun.* available like real Bun does.
|
|
127
127
|
const preamble = BUN_SHIM_PREAMBLE;
|
|
128
|
-
const {
|
|
129
|
-
this.pool = new
|
|
128
|
+
const { IsolatePool } = await import('@nimbus-sh/fabric/isolate-pool.js');
|
|
129
|
+
this.pool = new IsolatePool(env, ctx, {
|
|
130
130
|
tag: 'bun-repl',
|
|
131
131
|
concurrency: 1,
|
|
132
132
|
omitSupervisor: true,
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
*/
|
|
44
44
|
import { ESBUILD_VERSION } from '@nimbus-sh/core/constants.js';
|
|
45
45
|
import { ESBUILD_WASM_SHA256 } from '../esbuild-wasm-bundle.generated.js';
|
|
46
|
-
import { disposeRpcResource } from '@nimbus-sh/
|
|
46
|
+
import { disposeRpcResource } from '@nimbus-sh/platform/rpc-dispose.js';
|
|
47
47
|
import { sha256Hex } from '@nimbus-sh/core/_shared/crypto.js';
|
|
48
48
|
/**
|
|
49
49
|
* Path inside env.ASSETS where the esbuild-wasm binary lives.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The workerd {@link FacetHost}: a facet is a dynamic worker.
|
|
3
3
|
*
|
|
4
|
-
* The whole adapter is the option renames below, because `
|
|
4
|
+
* The whole adapter is the option renames below, because `IsolatePool`
|
|
5
5
|
* already IS the port's shape — `submit` and `dispose`, with the same meanings.
|
|
6
6
|
* The one thing it spells differently is the supervisor capability, which it
|
|
7
7
|
* takes as a pid plus a separate flag saying whether to bind one at all; the
|
|
@@ -13,7 +13,7 @@ import type { FacetHost } from '@nimbus-sh/core/runtime/facet-host.js';
|
|
|
13
13
|
import type { FacetManager } from '../facets/manager.js';
|
|
14
14
|
export declare function loaderFacetHost(env: unknown, ctx: DurableObjectState): FacetHost;
|
|
15
15
|
/**
|
|
16
|
-
* The two objects a
|
|
16
|
+
* The two objects a IsolatePool needs from a FacetManager, via the manager's
|
|
17
17
|
* own `loaderHost()` accessor. The runtime guard stays: harnesses build
|
|
18
18
|
* FacetManagers on mock contexts, and one built on something other than a
|
|
19
19
|
* DurableObjectState should fail with a sentence instead of at the first RPC.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { manifestVfs } from '@nimbus-sh/core/runtime/vfs-manifest.js';
|
|
2
|
-
import {
|
|
2
|
+
import { IsolatePool } from '@nimbus-sh/fabric/isolate-pool.js';
|
|
3
3
|
export function loaderFacetHost(env, ctx) {
|
|
4
4
|
return {
|
|
5
5
|
// workerd suspends a guest through JSPI, which is what lets a syscall reach
|
|
@@ -14,7 +14,7 @@ export function loaderFacetHost(env, ctx) {
|
|
|
14
14
|
return manifestVfs(vfs, root, options);
|
|
15
15
|
},
|
|
16
16
|
open(spec) {
|
|
17
|
-
return new
|
|
17
|
+
return new IsolatePool(env, ctx, {
|
|
18
18
|
tag: spec.tag,
|
|
19
19
|
concurrency: spec.concurrency,
|
|
20
20
|
preamble: spec.preamble,
|
|
@@ -27,7 +27,7 @@ export function loaderFacetHost(env, ctx) {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
* The two objects a
|
|
30
|
+
* The two objects a IsolatePool needs from a FacetManager, via the manager's
|
|
31
31
|
* own `loaderHost()` accessor. The runtime guard stays: harnesses build
|
|
32
32
|
* FacetManagers on mock contexts, and one built on something other than a
|
|
33
33
|
* DurableObjectState should fail with a sentence instead of at the first RPC.
|
|
@@ -113,8 +113,8 @@ class NodeReplAdapter {
|
|
|
113
113
|
const { facetMgr } = this.deps;
|
|
114
114
|
const env = facetMgr.env;
|
|
115
115
|
const ctx = facetMgr.ctx;
|
|
116
|
-
const {
|
|
117
|
-
this.pool = new
|
|
116
|
+
const { IsolatePool } = await import('@nimbus-sh/fabric/isolate-pool.js');
|
|
117
|
+
this.pool = new IsolatePool(env, ctx, {
|
|
118
118
|
tag: 'node-repl',
|
|
119
119
|
concurrency: 1,
|
|
120
120
|
omitSupervisor: true,
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* facet with no node-compat layer.
|
|
17
17
|
*/
|
|
18
18
|
import { NODE_SHIMS_BUILD_ID, NODE_SHIMS_ENTRY, NODE_SHIMS_SHA256, } from '../node-shims-artifact.generated.js';
|
|
19
|
-
import { disposeRpcResource } from '@nimbus-sh/
|
|
19
|
+
import { disposeRpcResource } from '@nimbus-sh/platform/rpc-dispose.js';
|
|
20
20
|
import { sha256Hex } from '@nimbus-sh/core/_shared/crypto.js';
|
|
21
21
|
const L2_KEY = `https://nimbus-cache.invalid${NODE_SHIMS_ENTRY}?build=${NODE_SHIMS_BUILD_ID}`;
|
|
22
22
|
const ASSET_URL = `https://nimbus-internal.invalid${NODE_SHIMS_ENTRY}`;
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
* - events: full EventEmitter
|
|
10
10
|
* - stream: real Readable/Writable/Transform/Duplex with backpressure
|
|
11
11
|
* - crypto: createHash (FNV-1a sync, SubtleCrypto async), randomBytes/UUID
|
|
12
|
-
* - zlib:
|
|
12
|
+
* - zlib: forward to workerd's native node:zlib when the facet real-import
|
|
13
|
+
* block materialised (full sync/brotli/stream surface; results are the
|
|
14
|
+
* host realm's own Buffers, recognized by the widened isBuffer);
|
|
15
|
+
* CompressionStream fallback with honest sync refusal
|
|
13
16
|
* - dns: real DNS resolution via Cloudflare DNS-over-HTTPS
|
|
14
17
|
* - http: virtual server with port registry for supervisor routing
|
|
15
18
|
* - https: fetch()-backed request/get
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-shims.d.ts","sourceRoot":"","sources":["../../src/runtime/node-shims.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"node-shims.d.ts","sourceRoot":"","sources":["../../src/runtime/node-shims.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAgDH,wBAAgB,iBAAiB,IAAI,MAAM,CA+vO1C"}
|