@nimbus-sh/worker 0.9.0 → 0.10.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/dist/esbuild-wasm-bundle.generated.d.ts +24 -24
- package/dist/esbuild-wasm-bundle.generated.d.ts.map +1 -1
- package/dist/esbuild-wasm-bundle.generated.js +24 -24
- package/dist/facets/cirrus-real.js +3 -3
- package/dist/facets/compose.js +9 -2
- package/dist/facets/esbuild-bundle-pool.d.ts +1 -1
- package/dist/facets/esbuild-bundle-pool.js +3 -3
- package/dist/facets/esbuild-transform.d.ts +6 -2
- package/dist/facets/esbuild-transform.d.ts.map +1 -1
- package/dist/facets/esbuild-transform.js +8 -4
- package/dist/facets/manager.d.ts +28 -0
- package/dist/facets/manager.d.ts.map +1 -1
- package/dist/facets/manager.js +89 -37
- package/dist/facets/real-vite-hmr.d.ts +2 -0
- package/dist/facets/real-vite-hmr.d.ts.map +1 -1
- package/dist/facets/real-vite-hmr.js +3 -2
- package/dist/git/commands.d.ts +17 -1
- package/dist/git/commands.d.ts.map +1 -1
- package/dist/git/commands.js +73 -9
- package/dist/git/network-facet.d.ts +2 -0
- package/dist/git/network-facet.d.ts.map +1 -1
- package/dist/git/network-facet.js +10 -5
- package/dist/hosted/commands.d.ts.map +1 -1
- package/dist/hosted/commands.js +2 -2
- package/dist/hosted/runtime.d.ts +3 -2
- package/dist/hosted/runtime.d.ts.map +1 -1
- package/dist/hosted/runtime.js +1 -0
- package/dist/hosted/services.d.ts +8 -0
- package/dist/hosted/services.d.ts.map +1 -1
- package/dist/hosted/services.js +3 -0
- 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 +4 -4
- package/dist/loaders/pre-bundle-preamble.d.ts +6 -3
- package/dist/loaders/pre-bundle-preamble.d.ts.map +1 -1
- package/dist/loaders/pre-bundle-preamble.js +13 -8
- package/dist/node-shims-artifact.generated.js +3 -3
- package/dist/npm/cache.d.ts +6 -1
- package/dist/npm/cache.d.ts.map +1 -1
- package/dist/npm/cache.js +8 -6
- package/dist/npm/install-batch-facet.d.ts +2 -0
- package/dist/npm/install-batch-facet.d.ts.map +1 -1
- package/dist/npm/install-batch-facet.js +29 -15
- package/dist/npm/installer.d.ts +8 -4
- package/dist/npm/installer.d.ts.map +1 -1
- package/dist/npm/installer.js +173 -113
- package/dist/npm/npx-install.d.ts +3 -1
- package/dist/npm/npx-install.d.ts.map +1 -1
- package/dist/npm/npx-install.js +4 -1
- package/dist/npm/placement.d.ts +16 -0
- package/dist/npm/placement.d.ts.map +1 -0
- package/dist/npm/placement.js +33 -0
- package/dist/npm/r2-cache.d.ts +10 -6
- package/dist/npm/r2-cache.d.ts.map +1 -1
- package/dist/npm/r2-cache.js +32 -16
- package/dist/npm/resolve-one-facet.d.ts +3 -0
- package/dist/npm/resolve-one-facet.d.ts.map +1 -1
- package/dist/npm/resolve-one-facet.js +1 -0
- package/dist/npm/resolver.d.ts +11 -6
- package/dist/npm/resolver.d.ts.map +1 -1
- package/dist/npm/resolver.js +12 -3
- package/dist/runtime/cpython-resident.d.ts.map +1 -1
- package/dist/runtime/cpython-resident.js +2 -10
- package/dist/runtime/esbuild-wasm-bytes.d.ts +25 -18
- package/dist/runtime/esbuild-wasm-bytes.d.ts.map +1 -1
- package/dist/runtime/esbuild-wasm-bytes.js +55 -30
- package/dist/runtime/facet-loader-host.d.ts.map +1 -1
- package/dist/runtime/facet-loader-host.js +0 -7
- package/dist/runtime/node-shims.d.ts.map +1 -1
- package/dist/runtime/node-shims.js +839 -180
- package/dist/runtime/python-repl.d.ts.map +1 -1
- package/dist/runtime/python-repl.js +2 -33
- package/dist/runtime/ruby-resident.d.ts.map +1 -1
- package/dist/runtime/ruby-resident.js +5 -16
- package/dist/runtime/wasi/preamble.d.ts +0 -22
- package/dist/runtime/wasi/preamble.d.ts.map +1 -1
- package/dist/runtime/wasi/preamble.js +98 -1401
- package/dist/session/hibernation.d.ts +45 -2
- package/dist/session/hibernation.d.ts.map +1 -1
- package/dist/session/hibernation.js +78 -1
- package/dist/session/nimbus-session.d.ts +10 -2
- package/dist/session/nimbus-session.d.ts.map +1 -1
- package/dist/session/nimbus-session.js +13 -1
- package/dist/session/npm-install-port.d.ts.map +1 -1
- package/dist/session/npm-install-port.js +1 -0
- package/dist/session/routes.d.ts.map +1 -1
- package/dist/session/routes.js +4 -2
- package/dist/session/rpc.d.ts +5 -2
- package/dist/session/rpc.d.ts.map +1 -1
- package/dist/session/rpc.js +10 -2
- package/dist/session/supervisor-rpc.d.ts +17 -9
- package/dist/session/supervisor-rpc.d.ts.map +1 -1
- package/dist/session/supervisor-rpc.js +15 -22
- package/dist/workspace-host.d.ts +1 -1
- package/dist/workspace-host.d.ts.map +1 -1
- package/dist/wrangler/nimbus-wrangler.d.ts.map +1 -1
- package/dist/wrangler/nimbus-wrangler.js +3 -0
- package/package.json +30 -4
- package/public/_assets/esbuild-0.24.2.js +2380 -0
- package/public/_assets/runtime/{node-shims-acaa037e6d26ec0d.js → node-shims-7b4dd7a76d95d21e.js} +838 -179
- package/scripts/bundle-esbuild-wasm.mjs +55 -39
- package/scripts/bundle-facet-workers.mjs +45 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"python-repl.d.ts","sourceRoot":"","sources":["../../src/runtime/python-repl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"python-repl.d.ts","sourceRoot":"","sources":["../../src/runtime/python-repl.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+CAA+C,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAMnF,OAAO,EAAe,KAAK,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AActG,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,YAAY,CAAC;IACvB,sEAAsE;IACtE,SAAS,EAAE,yBAAyB,CAAC;IACrC,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,mFAAmF;IACnF,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,eAAe,CAAC;IAC1B;;;;;;;;;OASG;IACH,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;IACvC;;;;;;;;OAQG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAgRD,wBAAsB,aAAa,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAIzE;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,WAAW,GAAG,aAAa,GAAG,UAAU,CAAC,GAChF,OAAO,CAAC,IAAI,CAAC,CAIf"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IsolatePool } from '@nimbus-sh/fabric/isolate-pool.js';
|
|
2
|
-
import { manifestVfs } from '@nimbus-sh/core/runtime/vfs-manifest.js';
|
|
3
2
|
import { withHostFilesystem } from '@nimbus-sh/core/shell/execution-fs.js';
|
|
4
3
|
import { z } from 'zod/v4';
|
|
5
4
|
import { ReplSession } from './repl-session.js';
|
|
@@ -76,7 +75,6 @@ class PythonReplAdapter {
|
|
|
76
75
|
poolUsesSci = false;
|
|
77
76
|
deps;
|
|
78
77
|
wasmBytes = null;
|
|
79
|
-
fsSnapshot = null;
|
|
80
78
|
pythonHome = '/usr/local';
|
|
81
79
|
ps1 = '>>> ';
|
|
82
80
|
ps2 = '... ';
|
|
@@ -151,7 +149,6 @@ class PythonReplAdapter {
|
|
|
151
149
|
const pool = this.pool;
|
|
152
150
|
this.pool = null;
|
|
153
151
|
this.wasmBytes = null;
|
|
154
|
-
this.fsSnapshot = null;
|
|
155
152
|
pool?.dispose();
|
|
156
153
|
}
|
|
157
154
|
async interrupt() {
|
|
@@ -189,25 +186,6 @@ class PythonReplAdapter {
|
|
|
189
186
|
throw new Error(`python313.zip missing at ${stdlibPath} (run 'nimbus install python')`);
|
|
190
187
|
}
|
|
191
188
|
this.wasmBytes = toArrayBuffer(await vfs.readFile(wasmPath));
|
|
192
|
-
// The install root is the Python prefix, so the manifest covers lib/ and
|
|
193
|
-
// etc/ as they are — nothing is aliased into a path the supervisor could
|
|
194
|
-
// not serve.
|
|
195
|
-
const built = await manifestVfs(vfs.authority, CRED_KERNEL, 'home/user', { extraRoots: [installRoot.replace(/^\/+/, '')] });
|
|
196
|
-
if ('error' in built)
|
|
197
|
-
throw new Error(built.error);
|
|
198
|
-
// Same workaround as cpython-runner, and it belongs to the same open
|
|
199
|
-
// defect: the guest cannot consume the stdlib as a manifest-only
|
|
200
|
-
// demand-load, though the transport delivers it byte-identically. Seeding
|
|
201
|
-
// it by value is what makes the interpreter start. Remove both together.
|
|
202
|
-
const snapshot = built.snapshot;
|
|
203
|
-
const zipBytes = await vfs.readFile(stdlibPath);
|
|
204
|
-
let bin = '';
|
|
205
|
-
const CH = 32768;
|
|
206
|
-
for (let i = 0; i < zipBytes.length; i += CH) {
|
|
207
|
-
bin += String.fromCharCode.apply(null, Array.from(zipBytes.subarray(i, i + CH)));
|
|
208
|
-
}
|
|
209
|
-
snapshot.files[stdlibPath.replace(/^\/+/, '')] = btoa(bin);
|
|
210
|
-
this.fsSnapshot = snapshot;
|
|
211
189
|
this.pythonHome = `/${installRoot.replace(/^\/+/, '')}`;
|
|
212
190
|
const host = getFacetManagerLoaderHost(facetMgr);
|
|
213
191
|
// A prompt where `open(path, "w")` silently does nothing is worse than one
|
|
@@ -236,7 +214,7 @@ class PythonReplAdapter {
|
|
|
236
214
|
active = null;
|
|
237
215
|
async submit(userCode, signal) {
|
|
238
216
|
const pool = this.pool;
|
|
239
|
-
if (!pool
|
|
217
|
+
if (!pool)
|
|
240
218
|
throw new Error('Python REPL is not initialized');
|
|
241
219
|
const response = await pool.submitRequest(pythonReplStepRequestFn, new Request('https://facet.internal/python-repl-step', {
|
|
242
220
|
method: 'POST',
|
|
@@ -247,7 +225,6 @@ class PythonReplAdapter {
|
|
|
247
225
|
userEnv: { HOME: '/home/user', PYTHONUNBUFFERED: '1' },
|
|
248
226
|
progName: 'python',
|
|
249
227
|
cwd: '/home/user',
|
|
250
|
-
fsSnapshot: this.fsSnapshot,
|
|
251
228
|
}),
|
|
252
229
|
signal,
|
|
253
230
|
}), { timeoutMs: 60_000 });
|
|
@@ -281,7 +258,6 @@ async function pythonReplStepRequestFn(request, facetEnv) {
|
|
|
281
258
|
});
|
|
282
259
|
}
|
|
283
260
|
const adopt = Reflect.get(globalThis, '__wasiAdoptSupervisor');
|
|
284
|
-
const drain = Reflect.get(globalThis, '__wasiDrainPersist');
|
|
285
261
|
const supervisor = facetEnv && facetEnv.SUPERVISOR;
|
|
286
262
|
// Published where the boot re-adopts it after the mount, because
|
|
287
263
|
// __wasiInitFS clears the adoption on purpose. Omitting this here — while
|
|
@@ -291,14 +267,7 @@ async function pythonReplStepRequestFn(request, facetEnv) {
|
|
|
291
267
|
Reflect.set(globalThis, '__nimbusPySupervisor', supervisor);
|
|
292
268
|
if (typeof adopt === 'function')
|
|
293
269
|
Reflect.apply(adopt, undefined, [supervisor ?? null]);
|
|
294
|
-
|
|
295
|
-
return Response.json(await run(args));
|
|
296
|
-
}
|
|
297
|
-
finally {
|
|
298
|
-
// A line that wrote a file and then raised still wrote the file.
|
|
299
|
-
if (typeof drain === 'function')
|
|
300
|
-
await drain();
|
|
301
|
-
}
|
|
270
|
+
return Response.json(await run(args));
|
|
302
271
|
}
|
|
303
272
|
export async function runPythonRepl(deps) {
|
|
304
273
|
const adapter = new PythonReplAdapter(deps);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ruby-resident.d.ts","sourceRoot":"","sources":["../../src/runtime/ruby-resident.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAezD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,GAAG,iBAAiB,CAgF3E;AAED,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"ruby-resident.d.ts","sourceRoot":"","sources":["../../src/runtime/ruby-resident.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAezD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,GAAG,iBAAiB,CAgF3E;AAED,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAsKrE"}
|
|
@@ -216,7 +216,6 @@ export function buildRubySocketProcessWorker(preamble) {
|
|
|
216
216
|
' userEnv: args.userEnv || {},',
|
|
217
217
|
' progName: args.progName || "ruby",',
|
|
218
218
|
' cwd: args.cwd || "/home/user",',
|
|
219
|
-
' fsSnapshot: args.fsSnapshot,',
|
|
220
219
|
' };',
|
|
221
220
|
' globalThis.__nimbusRubyProcessPromise = globalThis.__rubyRun(globalThis.__nimbusRubyProcessArgs).then((result) => {',
|
|
222
221
|
' globalThis.__nimbusRubyProcessResult = result;',
|
|
@@ -244,25 +243,15 @@ export function buildRubySocketProcessWorker(preamble) {
|
|
|
244
243
|
'function __nimbusAdoptRubySupervisor(env) {',
|
|
245
244
|
' const supervisor = env && env.SUPERVISOR;',
|
|
246
245
|
' if (supervisor) globalThis.__nimbusRubySupervisor = supervisor;',
|
|
247
|
-
// The WASI filesystem takes the same stub
|
|
248
|
-
//
|
|
249
|
-
//
|
|
246
|
+
// The WASI filesystem takes the same stub: every file syscall the server
|
|
247
|
+
// makes reads and writes the session VFS directly, so a server that never
|
|
248
|
+
// exits has nothing to flush between requests.
|
|
250
249
|
' __wasiAdoptSupervisor(supervisor);',
|
|
251
250
|
'}',
|
|
252
|
-
// A resident process parks between requests, and parking is the only
|
|
253
|
-
// moment "durable while running" can be made true: by the time the caller
|
|
254
|
-
// holds a response, everything the request wrote has reached the VFS.
|
|
255
|
-
'async function __nimbusParkRuby(value) {',
|
|
256
|
-
// Revalidate drains first, then spends ONE round trip on the subtree
|
|
257
|
-
// revision. An unchanged subtree keeps the whole cache; a changed one
|
|
258
|
-
// drops the clean half so the next read sees another process's writes.
|
|
259
|
-
' await __wasiRevalidateFS();',
|
|
260
|
-
' return value;',
|
|
261
|
-
'}',
|
|
262
251
|
'export class NimbusProcess extends DurableObject {',
|
|
263
252
|
' async startProcess(args) {',
|
|
264
253
|
' __nimbusAdoptRubySupervisor(this.env);',
|
|
265
|
-
' return
|
|
254
|
+
' return __nimbusStartRubyProcess(args || {});',
|
|
266
255
|
' }',
|
|
267
256
|
' async fetch(request) {',
|
|
268
257
|
' __nimbusAdoptRubySupervisor(this.env);',
|
|
@@ -273,7 +262,7 @@ export function buildRubySocketProcessWorker(preamble) {
|
|
|
273
262
|
' const hinted = Number(request.headers.get("X-Nimbus-Port") || 0);',
|
|
274
263
|
' const port = hinted || Array.from(globalThis.__nimbusVirtualSockets.listeners.keys())[0];',
|
|
275
264
|
' if (!port) return new Response("Nimbus Ruby process has no listening virtual socket", { status: 502 });',
|
|
276
|
-
' return
|
|
265
|
+
' return globalThis.__nimbusVirtualSockets.handleHttpRequest(port, request);',
|
|
277
266
|
' }',
|
|
278
267
|
'}',
|
|
279
268
|
].join('\n');
|
|
@@ -1,28 +1,6 @@
|
|
|
1
1
|
import type { FdEntry, WasiInitOptions, WasiInstanceBundle, WasiMakeImportsOptions, WasiRunResult, WasiStartInstance, WasiSupervisorStub } from '@nimbus-sh/core/runtime/wasi/types.js';
|
|
2
2
|
export declare function __wasiAdoptSupervisor(sup: WasiSupervisorStub | null): void;
|
|
3
|
-
/**
|
|
4
|
-
* Re-sync the cache with the session VFS. A resident process (a server) must
|
|
5
|
-
* see files that other processes created or changed after it spawned, so the
|
|
6
|
-
* cached content is dropped and metadata re-read on next access.
|
|
7
|
-
*/
|
|
8
|
-
export declare function __wasiRevalidateFS(): Promise<string[]>;
|
|
9
|
-
/**
|
|
10
|
-
* Await every queued mutation. Callers drain before returning a result to the
|
|
11
|
-
* supervisor and before any live read, so the supervisor's view always
|
|
12
|
-
* includes this process's own writes.
|
|
13
|
-
*/
|
|
14
|
-
export declare function __wasiDrainPersist(): Promise<void>;
|
|
15
3
|
export declare function __wasiInitFS(opts: WasiInitOptions): void;
|
|
16
|
-
/**
|
|
17
|
-
* Read named files back out as base64.
|
|
18
|
-
*
|
|
19
|
-
* A process with a supervisor has already written everything through as it
|
|
20
|
-
* happened and never calls this. A SEALED one — no supervisor, by design,
|
|
21
|
-
* because it must not be able to reach the session VFS at all — has no other
|
|
22
|
-
* channel, so its caller names the paths it wants and gets exactly those.
|
|
23
|
-
* A path with no file is simply absent from the result.
|
|
24
|
-
*/
|
|
25
|
-
export declare function __wasiReadFilesB64(paths: string[]): Record<string, string>;
|
|
26
4
|
export declare const fdTable: Map<number, FdEntry>;
|
|
27
5
|
export declare function __wasiMakeImports(opts: WasiMakeImportsOptions): WasiInstanceBundle;
|
|
28
6
|
export declare function __wasiRunStart(instance: WasiStartInstance, ctx?: unknown): WasiRunResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preamble.d.ts","sourceRoot":"","sources":["../../../src/runtime/wasi/preamble.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"preamble.d.ts","sourceRoot":"","sources":["../../../src/runtime/wasi/preamble.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAEV,OAAO,EAMP,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EAGtB,aAAa,EAEb,iBAAiB,EACjB,kBAAkB,EAInB,MAAM,uCAAuC,CAAC;AAmJ/C,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,kBAAkB,GAAG,IAAI,GAAG,IAAI,CAE1E;AAiBD,wBAAgB,YAAY,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CA0BxD;AAwOD,eAAO,MAAM,OAAO,sBAA6B,CAAC;AAsElD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,sBAAsB,GAAG,kBAAkB,CAikClF;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,aAAa,CAcxF;AAeD,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAyB5G"}
|