@nimbus-sh/worker 0.2.0 → 0.2.2
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/facets/manager.d.ts +47 -2
- package/dist/facets/manager.d.ts.map +1 -1
- package/dist/facets/manager.js +139 -15
- 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/runtime/bash-repl.d.ts +1 -1
- package/dist/runtime/bash-repl.d.ts.map +1 -1
- package/dist/runtime/bash-repl.js +3 -2
- package/dist/runtime/cpython-resident.d.ts +27 -0
- package/dist/runtime/cpython-resident.d.ts.map +1 -0
- package/dist/runtime/cpython-resident.js +133 -0
- package/dist/runtime/facet-loader-host.d.ts +16 -1
- package/dist/runtime/facet-loader-host.d.ts.map +1 -1
- package/dist/runtime/facet-loader-host.js +42 -0
- package/dist/runtime/package-manager.d.ts +3 -58
- package/dist/runtime/package-manager.d.ts.map +1 -1
- package/dist/runtime/package-manager.js +6 -143
- package/dist/runtime/python-repl.d.ts +1 -1
- package/dist/runtime/python-repl.d.ts.map +1 -1
- package/dist/runtime/python-repl.js +2 -2
- package/dist/runtime/ruby-repl.js +1 -1
- package/dist/runtime/ruby-resident.d.ts +20 -0
- package/dist/runtime/ruby-resident.d.ts.map +1 -0
- package/dist/runtime/ruby-resident.js +278 -0
- package/dist/runtime/runtime-catalog.d.ts +4 -80
- package/dist/runtime/runtime-catalog.d.ts.map +1 -1
- package/dist/runtime/runtime-catalog.js +4 -67
- package/dist/session/init.d.ts +16 -7
- package/dist/session/init.d.ts.map +1 -1
- package/dist/session/init.js +210 -249
- package/dist/session/keys.d.ts +13 -0
- package/dist/session/keys.d.ts.map +1 -1
- package/dist/session/keys.js +13 -0
- package/dist/session/nimbus-session.d.ts +30 -2
- package/dist/session/nimbus-session.d.ts.map +1 -1
- package/dist/session/nimbus-session.js +49 -58
- package/dist/session/programmatic.d.ts +3 -3
- package/dist/session/programmatic.d.ts.map +1 -1
- package/dist/session/programmatic.js +3 -2
- package/dist/session/routes.js +1 -1
- package/dist/session/supervisor-rpc.d.ts +6 -13
- package/dist/session/supervisor-rpc.d.ts.map +1 -1
- package/dist/session/supervisor-rpc.js +7 -17
- package/package.json +2 -2
- package/scripts/bundle-facet-workers.mjs +9 -8
- package/scripts/bundle-runtime.mjs +276 -44
- package/dist/npm/tarball-stream.d.ts +0 -93
- package/dist/npm/tarball-stream.d.ts.map +0 -1
- package/dist/npm/tarball-stream.js +0 -235
- package/dist/npm/tarball.d.ts +0 -34
- package/dist/npm/tarball.d.ts.map +0 -1
- package/dist/npm/tarball.js +0 -97
- package/dist/runtime/bash-runner.d.ts +0 -63
- package/dist/runtime/bash-runner.d.ts.map +0 -1
- package/dist/runtime/bash-runner.generated.d.ts +0 -14
- package/dist/runtime/bash-runner.generated.d.ts.map +0 -1
- package/dist/runtime/bash-runner.generated.js +0 -13
- package/dist/runtime/bash-runner.js +0 -291
- package/dist/runtime/clang-runner.d.ts +0 -37
- package/dist/runtime/clang-runner.d.ts.map +0 -1
- package/dist/runtime/clang-runner.js +0 -865
- package/dist/runtime/cpython-runner.d.ts +0 -71
- package/dist/runtime/cpython-runner.d.ts.map +0 -1
- package/dist/runtime/cpython-runner.js +0 -535
- package/dist/runtime/python-pip.d.ts +0 -38
- package/dist/runtime/python-pip.d.ts.map +0 -1
- package/dist/runtime/python-pip.js +0 -1063
- package/dist/runtime/ruby-gems.d.ts +0 -30
- package/dist/runtime/ruby-gems.d.ts.map +0 -1
- package/dist/runtime/ruby-gems.js +0 -636
- package/dist/runtime/ruby-runner.d.ts +0 -75
- package/dist/runtime/ruby-runner.d.ts.map +0 -1
- package/dist/runtime/ruby-runner.js +0 -1577
- package/dist/runtime/runtime-registry.d.ts +0 -162
- package/dist/runtime/runtime-registry.d.ts.map +0 -1
- package/dist/runtime/runtime-registry.js +0 -364
- package/dist/runtime/virtual-socket-kernel.generated.d.ts +0 -14
- package/dist/runtime/virtual-socket-kernel.generated.d.ts.map +0 -1
- package/dist/runtime/virtual-socket-kernel.generated.js +0 -13
- package/dist/runtime/wasm-runner.d.ts +0 -70
- package/dist/runtime/wasm-runner.d.ts.map +0 -1
- package/dist/runtime/wasm-runner.js +0 -664
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cpython-resident.ts — a Python program that keeps serving, as a Durable
|
|
3
|
+
* Object facet.
|
|
4
|
+
*
|
|
5
|
+
* The half of the CPython runtime that names workerd. Everything about running
|
|
6
|
+
* the interpreter is in `@nimbus-sh/core`; this is the substrate a program that
|
|
7
|
+
* outlives its invocation needs — an actor that stays alive between requests,
|
|
8
|
+
* with inbound HTTP routed into the socket the program bound. A host without
|
|
9
|
+
* one supplies no {@link CPythonResidentStart} and such a program is refused
|
|
10
|
+
* rather than quietly run as a one-shot that dies with the call.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod/v4';
|
|
13
|
+
import { buildCPythonPreamble, } from '@nimbus-sh/core/runtime/cpython-runner.js';
|
|
14
|
+
/**
|
|
15
|
+
* The worker source for a resident Python process. Same shape as
|
|
16
|
+
* buildRubySocketProcessWorker: the socket kernel and the interpreter live in a
|
|
17
|
+
* DurableObject, startProcess runs the program until it stops, and inbound
|
|
18
|
+
* requests arrive on handleHttpRequest and are dispatched into the server the
|
|
19
|
+
* program registered before exiting.
|
|
20
|
+
*/
|
|
21
|
+
export function buildCPythonSocketProcessWorker(preamble) {
|
|
22
|
+
return [
|
|
23
|
+
'import { DurableObject } from "cloudflare:workers";',
|
|
24
|
+
// The module arrives by path (vfsWasmModules) and has to be published where
|
|
25
|
+
// the preamble looks for it. Without this the facet boots and the first
|
|
26
|
+
// thing it says is "python.wasm was not supplied to this facet".
|
|
27
|
+
"import __NIMBUS_WASM_python from './python.wasm';",
|
|
28
|
+
'globalThis.__NIMBUS_WASM = globalThis.__NIMBUS_WASM || {};',
|
|
29
|
+
"globalThis.__NIMBUS_WASM['python.wasm'] = __NIMBUS_WASM_python;",
|
|
30
|
+
'',
|
|
31
|
+
preamble,
|
|
32
|
+
'',
|
|
33
|
+
// Only adopt a real binding: routed fetch hops resolve the entrypoint
|
|
34
|
+
// without a supervisor, and overwriting with undefined would drop the live
|
|
35
|
+
// stub the process needs for its whole lifetime.
|
|
36
|
+
'function __nimbusAdoptPySupervisor(env) {',
|
|
37
|
+
' const supervisor = env && env.SUPERVISOR;',
|
|
38
|
+
' if (supervisor) globalThis.__nimbusPySupervisor = supervisor;',
|
|
39
|
+
' __wasiAdoptSupervisor(supervisor);',
|
|
40
|
+
'}',
|
|
41
|
+
// A resident process answers between requests, and that is the only moment
|
|
42
|
+
// "durable while running" can be made true: by the time the caller holds a
|
|
43
|
+
// response, everything the request wrote has reached the VFS.
|
|
44
|
+
'async function __nimbusParkPy(value) {',
|
|
45
|
+
' await __wasiDrainPersist();',
|
|
46
|
+
' await __wasiRevalidateFS();',
|
|
47
|
+
' return value;',
|
|
48
|
+
'}',
|
|
49
|
+
'async function __nimbusStartPyProcess(args) {',
|
|
50
|
+
' const result = await globalThis.__cpythonStartProcess(args || {});',
|
|
51
|
+
' const ports = await globalThis.__cpythonListeningPorts();',
|
|
52
|
+
' const registrations = globalThis.__nimbusVirtualPortRegistrationPromises || [];',
|
|
53
|
+
' if (registrations.length > 0) await Promise.allSettled(registrations.splice(0));',
|
|
54
|
+
' if (ports.length > 0) {',
|
|
55
|
+
' return { state: "listening", port: ports[0], stdout: result.stdout, stderr: result.stderr };',
|
|
56
|
+
' }',
|
|
57
|
+
' return { state: "exited", result, stdout: result.stdout, stderr: result.stderr };',
|
|
58
|
+
'}',
|
|
59
|
+
'export class NimbusProcess extends DurableObject {',
|
|
60
|
+
' async startProcess(args) {',
|
|
61
|
+
' __nimbusAdoptPySupervisor(this.env);',
|
|
62
|
+
' return __nimbusParkPy(await __nimbusStartPyProcess(args || {}));',
|
|
63
|
+
' }',
|
|
64
|
+
' async fetch(request) {',
|
|
65
|
+
' __nimbusAdoptPySupervisor(this.env);',
|
|
66
|
+
' return this.handleHttpRequest(request);',
|
|
67
|
+
' }',
|
|
68
|
+
' async handleHttpRequest(request) {',
|
|
69
|
+
' __nimbusAdoptPySupervisor(this.env);',
|
|
70
|
+
' const hinted = Number(request.headers.get("X-Nimbus-Port") || 0);',
|
|
71
|
+
' const port = hinted || Array.from(globalThis.__nimbusVirtualSockets.listeners.keys())[0];',
|
|
72
|
+
' if (!port) return new Response("Nimbus Python process has no listening virtual socket", { status: 502 });',
|
|
73
|
+
' return __nimbusParkPy(await globalThis.__nimbusVirtualSockets.handleHttpRequest(port, request));',
|
|
74
|
+
' }',
|
|
75
|
+
'}',
|
|
76
|
+
].join('\n');
|
|
77
|
+
}
|
|
78
|
+
const CPythonBootSchema = z.object({
|
|
79
|
+
state: z.string().optional(),
|
|
80
|
+
port: z.number().optional(),
|
|
81
|
+
stdout: z.string().optional(),
|
|
82
|
+
stderr: z.string().optional(),
|
|
83
|
+
result: z.object({ exitCode: z.number().optional() }).passthrough().optional(),
|
|
84
|
+
}).passthrough();
|
|
85
|
+
/**
|
|
86
|
+
* Start a program that binds a port as its own process, so it outlives the
|
|
87
|
+
* invocation that started it. Mirrors spawnRubySocketProcess.
|
|
88
|
+
*/
|
|
89
|
+
export function cpythonResidentStart(facetMgr) {
|
|
90
|
+
return async function startResidentCPython(args) {
|
|
91
|
+
const command = args.command;
|
|
92
|
+
const workerCode = buildCPythonSocketProcessWorker(buildCPythonPreamble());
|
|
93
|
+
const spawned = await facetMgr.spawnWorker(workerCode, command, args.cwd, {
|
|
94
|
+
compatibilityFlags: ['nodejs_compat'],
|
|
95
|
+
// By path, not by value: the interpreter is 10.6 MiB, more than a single
|
|
96
|
+
// RPC value may carry, so whichever host runs this process reads it itself.
|
|
97
|
+
vfsWasmModules: { 'python.wasm': args.wasmVfsPath },
|
|
98
|
+
startArgs: args.startArgs,
|
|
99
|
+
}).catch(() => null);
|
|
100
|
+
if (!spawned)
|
|
101
|
+
return { exitCode: 1, stdout: '', stderr: 'python process boot failed\n' };
|
|
102
|
+
const boot = CPythonBootSchema.safeParse(spawned.boot);
|
|
103
|
+
if (!boot.success) {
|
|
104
|
+
facetMgr.finishProcess(spawned.pid, 1, 'python process boot failed');
|
|
105
|
+
return { exitCode: 1, stdout: '', stderr: 'python process boot failed\n' };
|
|
106
|
+
}
|
|
107
|
+
const data = boot.data;
|
|
108
|
+
if (data.state === 'listening' && typeof data.port === 'number' && data.port > 0) {
|
|
109
|
+
facetMgr.registerPort(spawned.pid, data.port);
|
|
110
|
+
const routeable = await facetMgr.waitForRouteablePorts(spawned.pid);
|
|
111
|
+
const port = routeable.includes(data.port) ? data.port : routeable[0];
|
|
112
|
+
if (!port) {
|
|
113
|
+
facetMgr.kill(spawned.pid);
|
|
114
|
+
return {
|
|
115
|
+
exitCode: 1,
|
|
116
|
+
stdout: data.stdout || '',
|
|
117
|
+
stderr: `${data.stderr || ''}python: virtual socket port ${data.port} failed to attach a route handler\n`,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
exitCode: 0,
|
|
122
|
+
stdout: `${data.stdout || ''}\x1b[2m[started (long-running): pid=${spawned.pid} cmd="${command}" port=${port}]\x1b[0m\n`,
|
|
123
|
+
stderr: data.stderr || '',
|
|
124
|
+
spawnedPid: spawned.pid,
|
|
125
|
+
port,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
const result = data.result;
|
|
129
|
+
const exitCode = typeof result?.exitCode === 'number' ? result.exitCode : 0;
|
|
130
|
+
facetMgr.finishProcess(spawned.pid, exitCode, data.stderr || 'python process exited');
|
|
131
|
+
return { exitCode, stdout: data.stdout || '', stderr: data.stderr || '' };
|
|
132
|
+
};
|
|
133
|
+
}
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workerd {@link FacetHost}: a facet is a dynamic worker.
|
|
3
|
+
*
|
|
4
|
+
* The whole adapter is the option renames below, because `NimbusLoaderPool`
|
|
5
|
+
* already IS the port's shape — `submit` and `dispose`, with the same meanings.
|
|
6
|
+
* The one thing it spells differently is the supervisor capability, which it
|
|
7
|
+
* takes as a pid plus a separate flag saying whether to bind one at all; the
|
|
8
|
+
* port collapses the pair, since a facet with the binding and no pid can read
|
|
9
|
+
* the session and never write to it. `reuse` is the pool's `cacheScope` under
|
|
10
|
+
* the name the port gives it: who a warm facet may answer for.
|
|
11
|
+
*/
|
|
12
|
+
import type { FacetHost } from '@nimbus-sh/core/runtime/facet-host.js';
|
|
13
|
+
import type { FacetManager } from '../facets/manager.js';
|
|
14
|
+
export declare function loaderFacetHost(env: unknown, ctx: DurableObjectState): FacetHost;
|
|
1
15
|
/**
|
|
2
16
|
* The two objects a NimbusLoaderPool needs from a FacetManager.
|
|
3
17
|
*
|
|
@@ -7,9 +21,10 @@
|
|
|
7
21
|
* checked here once, and a FacetManager built on something other than a
|
|
8
22
|
* DurableObjectState fails with a sentence instead of at the first RPC.
|
|
9
23
|
*/
|
|
10
|
-
import type { FacetManager } from '../facets/manager.js';
|
|
11
24
|
export declare function getFacetManagerLoaderHost(facetMgr: FacetManager): {
|
|
12
25
|
env: unknown;
|
|
13
26
|
ctx: DurableObjectState;
|
|
14
27
|
};
|
|
28
|
+
/** The facet host a runtime reached through a FacetManager runs on. */
|
|
29
|
+
export declare function facetHostForManager(facetMgr: FacetManager): FacetHost;
|
|
15
30
|
//# sourceMappingURL=facet-loader-host.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facet-loader-host.d.ts","sourceRoot":"","sources":["../../src/runtime/facet-loader-host.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"facet-loader-host.d.ts","sourceRoot":"","sources":["../../src/runtime/facet-loader-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAIV,SAAS,EAEV,MAAM,uCAAuC,CAAC;AAG/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,kBAAkB,GAAG,SAAS,CA6BhF;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,YAAY,GACrB;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,kBAAkB,CAAA;CAAE,CAO3C;AAED,uEAAuE;AACvE,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAGrE"}
|
|
@@ -1,3 +1,40 @@
|
|
|
1
|
+
import { manifestVfs } from '@nimbus-sh/core/runtime/vfs-manifest.js';
|
|
2
|
+
import { NimbusLoaderPool } from '../loaders/loader-pool.js';
|
|
3
|
+
export function loaderFacetHost(env, ctx) {
|
|
4
|
+
return {
|
|
5
|
+
// workerd suspends a guest through JSPI, which is what lets a syscall reach
|
|
6
|
+
// back to the session mid-instruction.
|
|
7
|
+
parking: 'jspi',
|
|
8
|
+
/**
|
|
9
|
+
* A manifest, not a copy: sizes and modes, with the facet demand-loading
|
|
10
|
+
* whatever the program opens through its supervisor. It has to be — the
|
|
11
|
+
* whole seed crosses one RPC, and a session filesystem does not fit in one.
|
|
12
|
+
*/
|
|
13
|
+
seedFilesystem(vfs, root, options) {
|
|
14
|
+
return manifestVfs(vfs, root, options);
|
|
15
|
+
},
|
|
16
|
+
open(spec) {
|
|
17
|
+
return new NimbusLoaderPool(env, ctx, {
|
|
18
|
+
tag: spec.tag,
|
|
19
|
+
concurrency: spec.concurrency,
|
|
20
|
+
preamble: spec.preamble,
|
|
21
|
+
wasmModules: spec.wasmModules,
|
|
22
|
+
omitSupervisor: spec.syscalls === undefined,
|
|
23
|
+
supervisorPid: spec.syscalls?.pid,
|
|
24
|
+
cacheScope: spec.reuse,
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The two objects a NimbusLoaderPool needs from a FacetManager.
|
|
31
|
+
*
|
|
32
|
+
* FacetManager does not expose its `env` and `ctx` in its type, but a loader
|
|
33
|
+
* pool is constructed from exactly those, so every runtime that spawns facets
|
|
34
|
+
* needs the same reach-through. Reflect.get rather than a cast: the shape is
|
|
35
|
+
* checked here once, and a FacetManager built on something other than a
|
|
36
|
+
* DurableObjectState fails with a sentence instead of at the first RPC.
|
|
37
|
+
*/
|
|
1
38
|
export function getFacetManagerLoaderHost(facetMgr) {
|
|
2
39
|
const env = Reflect.get(facetMgr, 'env');
|
|
3
40
|
const ctx = Reflect.get(facetMgr, 'ctx');
|
|
@@ -6,6 +43,11 @@ export function getFacetManagerLoaderHost(facetMgr) {
|
|
|
6
43
|
}
|
|
7
44
|
return { env, ctx };
|
|
8
45
|
}
|
|
46
|
+
/** The facet host a runtime reached through a FacetManager runs on. */
|
|
47
|
+
export function facetHostForManager(facetMgr) {
|
|
48
|
+
const { env, ctx } = getFacetManagerLoaderHost(facetMgr);
|
|
49
|
+
return loaderFacetHost(env, ctx);
|
|
50
|
+
}
|
|
9
51
|
function isDurableObjectState(value) {
|
|
10
52
|
if (typeof value !== 'object' || value === null)
|
|
11
53
|
return false;
|
|
@@ -25,9 +25,11 @@
|
|
|
25
25
|
*
|
|
26
26
|
* Errors throw and bubble up to the user as a single diagnostic line.
|
|
27
27
|
*/
|
|
28
|
-
import { type RuntimeCatalogEnv
|
|
28
|
+
import { type RuntimeCatalogEnv } from './runtime-catalog.js';
|
|
29
|
+
import { type RuntimeManifest } from '@nimbus-sh/core/runtime/runtime-manifest.js';
|
|
29
30
|
import type { SqliteVFS } from '@nimbus-sh/core/vfs/sqlite-vfs.js';
|
|
30
31
|
import { type RuntimePackageAbi } from '@nimbus-sh/core/runtime/os-contracts.js';
|
|
32
|
+
import { type MinShellRegistry } from '@nimbus-sh/core/runtime/installed-runtimes.js';
|
|
31
33
|
import type { CommandContext } from '@nimbus-sh/core/substrate/lifo/commands/types.js';
|
|
32
34
|
/** Minimal shell ctx shape we depend on (matches existing handlers). */
|
|
33
35
|
export interface ShellCtx extends Pick<CommandContext, 'pid' | 'cred' | 'setUmask' | 'runAs'> {
|
|
@@ -41,12 +43,6 @@ export interface ShellCtx extends Pick<CommandContext, 'pid' | 'cred' | 'setUmas
|
|
|
41
43
|
write(s: string): void;
|
|
42
44
|
};
|
|
43
45
|
}
|
|
44
|
-
/** Minimal shell-registry shape we depend on. */
|
|
45
|
-
export interface MinShellRegistry {
|
|
46
|
-
register(name: string, handler: (ctx: any) => Promise<number>): void;
|
|
47
|
-
unregister?(name: string): void;
|
|
48
|
-
resolve?(name: string): any;
|
|
49
|
-
}
|
|
50
46
|
export interface RuntimeWarmTarget {
|
|
51
47
|
name: string;
|
|
52
48
|
version: string;
|
|
@@ -54,29 +50,12 @@ export interface RuntimeWarmTarget {
|
|
|
54
50
|
manifest: RuntimeManifest;
|
|
55
51
|
}
|
|
56
52
|
export type RuntimeWarmHook = (target: RuntimeWarmTarget, ctx: ShellCtx) => Promise<void>;
|
|
57
|
-
/** Runner-factory contract. Each registered runner produces a shell-
|
|
58
|
-
* command handler given the manifest + the installed root dir. The
|
|
59
|
-
* package manager invokes the factory at install-time + at boot-time
|
|
60
|
-
* rehydration. */
|
|
61
|
-
export type RunnerFactory = (manifest: RuntimeManifest, installRoot: string, binName: string, binKind: string | undefined) => (ctx: any) => Promise<number>;
|
|
62
|
-
export declare function registerRunnerFactory(key: string, factory: RunnerFactory): void;
|
|
63
|
-
export declare function getRegisteredRunners(): string[];
|
|
64
53
|
export interface RuntimeInstallSummary {
|
|
65
54
|
spec: string;
|
|
66
55
|
exitCode: number;
|
|
67
56
|
stdout: string;
|
|
68
57
|
stderr: string;
|
|
69
58
|
}
|
|
70
|
-
export interface RuntimeSummary {
|
|
71
|
-
name: string;
|
|
72
|
-
version: string;
|
|
73
|
-
root: string;
|
|
74
|
-
abi: RuntimePackageAbi;
|
|
75
|
-
bins: string[];
|
|
76
|
-
sizeBytes: number;
|
|
77
|
-
license: string;
|
|
78
|
-
}
|
|
79
|
-
export declare function runtimeAbiForManifest(manifest: RuntimeManifest): RuntimePackageAbi;
|
|
80
59
|
export interface RuntimeInstallTarget {
|
|
81
60
|
runtimeName: string;
|
|
82
61
|
versionOverride: string | null;
|
|
@@ -87,41 +66,7 @@ export interface RuntimeCommandHint {
|
|
|
87
66
|
runtimeName: string;
|
|
88
67
|
installSpec: string;
|
|
89
68
|
}
|
|
90
|
-
/**
|
|
91
|
-
* Commands a runtime provides beyond its manifest entrypoints. The
|
|
92
|
-
* python/ruby package-manager front-ends (pip, gem, bundler) ride the
|
|
93
|
-
* language runner rather than shipping as manifest files, and already-
|
|
94
|
-
* deployed R2 manifests cannot retroactively declare them.
|
|
95
|
-
*
|
|
96
|
-
* This is the ONE hand-maintained command table: install aliasing
|
|
97
|
-
* (`nimbus install pip` → python), command-not-found hints, and bin
|
|
98
|
-
* registration all derive from `runtimeEntrypoints`, which merges this
|
|
99
|
-
* with the catalog manifest. Catalog-declared aliases (python3, ruby3,
|
|
100
|
-
* wasm-ld, …) come from manifest entrypoints and must NOT be repeated
|
|
101
|
-
* here. Mechanically validated against `NIMBUS_RUNTIME_ABIS` by
|
|
102
|
-
* tests/unit/runtime-command-aliases.mjs.
|
|
103
|
-
*/
|
|
104
|
-
export declare const RUNTIME_EXTRA_ENTRYPOINTS: Readonly<Record<string, readonly ManifestEntrypoint[]>>;
|
|
105
69
|
export declare function createRuntimeCommandHintResolver(env: RuntimeCatalogEnv): (command: string) => Promise<RuntimeCommandHint | null>;
|
|
106
|
-
/** Compute the per-user install root for (name, version). Uses
|
|
107
|
-
* `process.env.HOME` if present; falls back to `/home/user`. */
|
|
108
|
-
export declare function installRoot(homeDir: string, name: string, version: string): string;
|
|
109
|
-
/** Read all installed manifests off SqliteFS. Used by both `--list`
|
|
110
|
-
* and boot-time rehydration. */
|
|
111
|
-
export declare function listInstalledManifests(vfs: SqliteVFS, homeDir: string): Array<{
|
|
112
|
-
root: string;
|
|
113
|
-
manifest: RuntimeManifest;
|
|
114
|
-
}>;
|
|
115
|
-
/**
|
|
116
|
-
* Re-register every installed runtime's entrypoints in the shell
|
|
117
|
-
* registry. Call once at session-init time after all runner factories
|
|
118
|
-
* are registered (init.ts:registerRunnerFactory blocks).
|
|
119
|
-
*/
|
|
120
|
-
export declare function rehydrateInstalledRuntimes(vfs: SqliteVFS, registry: MinShellRegistry, homeDir: string): {
|
|
121
|
-
count: number;
|
|
122
|
-
bins: string[];
|
|
123
|
-
};
|
|
124
|
-
export declare function listInstalledRuntimes(vfs: SqliteVFS, homeDir: string): RuntimeSummary[];
|
|
125
70
|
export declare function listAvailableRuntimes(env: RuntimeCatalogEnv): Promise<Array<{
|
|
126
71
|
name: string;
|
|
127
72
|
abi: RuntimePackageAbi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../../src/runtime/package-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../../src/runtime/package-manager.ts"],"names":[],"mappings":"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"}
|
|
@@ -25,73 +25,13 @@
|
|
|
25
25
|
*
|
|
26
26
|
* Errors throw and bubble up to the user as a single diagnostic line.
|
|
27
27
|
*/
|
|
28
|
-
import { fetchCatalog, fetchManifest, fetchBlob
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
export function registerRunnerFactory(key, factory) {
|
|
33
|
-
runnerFactories[key] = factory;
|
|
34
|
-
}
|
|
35
|
-
export function getRegisteredRunners() {
|
|
36
|
-
return Object.keys(runnerFactories);
|
|
37
|
-
}
|
|
38
|
-
export function runtimeAbiForManifest(manifest) {
|
|
39
|
-
const byName = NIMBUS_RUNTIME_ABIS[manifest.name];
|
|
40
|
-
if (byName)
|
|
41
|
-
return byName;
|
|
42
|
-
if (manifest.wasi_namespace)
|
|
43
|
-
return NIMBUS_ABI_TARGET;
|
|
44
|
-
if (manifest.entrypoints.some((entrypoint) => entrypoint.runner === 'clang-runner')) {
|
|
45
|
-
return NIMBUS_ABI_TARGET;
|
|
46
|
-
}
|
|
47
|
-
return NATIVE_UNSUPPORTED_ABI;
|
|
48
|
-
}
|
|
28
|
+
import { fetchCatalog, fetchManifest, fetchBlob } from './runtime-catalog.js';
|
|
29
|
+
import { parseRuntimeManifest } from '@nimbus-sh/core/runtime/runtime-manifest.js';
|
|
30
|
+
import { CRED_KERNEL, NIMBUS_RUNTIME_ABIS, NATIVE_UNSUPPORTED_ABI } from '@nimbus-sh/core/runtime/os-contracts.js';
|
|
31
|
+
import { installRoot, listInstalledManifestsView, rehydrateInstalledRuntimesView, runnerFactoryFor, runtimeAbiForManifest, runtimeEntrypoints, } from '@nimbus-sh/core/runtime/installed-runtimes.js';
|
|
49
32
|
function runtimeAbiForCatalogName(name) {
|
|
50
33
|
return NIMBUS_RUNTIME_ABIS[name] ?? NATIVE_UNSUPPORTED_ABI;
|
|
51
34
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Commands a runtime provides beyond its manifest entrypoints. The
|
|
54
|
-
* python/ruby package-manager front-ends (pip, gem, bundler) ride the
|
|
55
|
-
* language runner rather than shipping as manifest files, and already-
|
|
56
|
-
* deployed R2 manifests cannot retroactively declare them.
|
|
57
|
-
*
|
|
58
|
-
* This is the ONE hand-maintained command table: install aliasing
|
|
59
|
-
* (`nimbus install pip` → python), command-not-found hints, and bin
|
|
60
|
-
* registration all derive from `runtimeEntrypoints`, which merges this
|
|
61
|
-
* with the catalog manifest. Catalog-declared aliases (python3, ruby3,
|
|
62
|
-
* wasm-ld, …) come from manifest entrypoints and must NOT be repeated
|
|
63
|
-
* here. Mechanically validated against `NIMBUS_RUNTIME_ABIS` by
|
|
64
|
-
* tests/unit/runtime-command-aliases.mjs.
|
|
65
|
-
*/
|
|
66
|
-
export const RUNTIME_EXTRA_ENTRYPOINTS = {
|
|
67
|
-
bash: [
|
|
68
|
-
{ binName: '/bin/bash', runner: 'bash-runner', args: [] },
|
|
69
|
-
{ binName: '/usr/bin/bash', runner: 'bash-runner', args: [] },
|
|
70
|
-
],
|
|
71
|
-
// `pip` belongs to whichever runtime provides the interpreter, and only one
|
|
72
|
-
// may claim it. The python row went with python-runner: Pyodide's manifest
|
|
73
|
-
// still names that runner, so it could not serve pip even if it were listed.
|
|
74
|
-
cpython: [
|
|
75
|
-
{ binName: 'pip', runner: 'cpython-runner', kind: 'pip', args: [] },
|
|
76
|
-
{ binName: 'pip3', runner: 'cpython-runner', kind: 'pip', args: [] },
|
|
77
|
-
],
|
|
78
|
-
ruby: [
|
|
79
|
-
{ binName: 'gem', runner: 'ruby-runner', kind: 'gem', args: [] },
|
|
80
|
-
{ binName: 'bundle', runner: 'ruby-runner', kind: 'bundle', args: [] },
|
|
81
|
-
{ binName: 'bundler', runner: 'ruby-runner', kind: 'bundle', args: [] },
|
|
82
|
-
],
|
|
83
|
-
};
|
|
84
|
-
function runtimeEntrypoints(manifest) {
|
|
85
|
-
const out = [...manifest.entrypoints];
|
|
86
|
-
const seen = new Set(out.map((ep) => ep.binName));
|
|
87
|
-
for (const ep of RUNTIME_EXTRA_ENTRYPOINTS[manifest.name] ?? []) {
|
|
88
|
-
if (seen.has(ep.binName))
|
|
89
|
-
continue;
|
|
90
|
-
out.push({ ...ep });
|
|
91
|
-
seen.add(ep.binName);
|
|
92
|
-
}
|
|
93
|
-
return out;
|
|
94
|
-
}
|
|
95
35
|
function splitRuntimeSpec(spec) {
|
|
96
36
|
const atIdx = spec.indexOf('@');
|
|
97
37
|
return {
|
|
@@ -212,83 +152,6 @@ export function createRuntimeCommandHintResolver(env) {
|
|
|
212
152
|
return hints.get(command) ?? null;
|
|
213
153
|
};
|
|
214
154
|
}
|
|
215
|
-
/** Compute the per-user install root for (name, version). Uses
|
|
216
|
-
* `process.env.HOME` if present; falls back to `/home/user`. */
|
|
217
|
-
export function installRoot(homeDir, name, version) {
|
|
218
|
-
// Strip leading slash so SqliteFS sees a relative-looking VFS path,
|
|
219
|
-
// matching the convention used elsewhere in src/session/init.ts.
|
|
220
|
-
const home = homeDir.replace(/^\/+/, '').replace(/\/+$/, '');
|
|
221
|
-
return `${home}/.nimbus/runtimes/${name}/${version}`;
|
|
222
|
-
}
|
|
223
|
-
/** Read all installed manifests off SqliteFS. Used by both `--list`
|
|
224
|
-
* and boot-time rehydration. */
|
|
225
|
-
export function listInstalledManifests(vfs, homeDir) {
|
|
226
|
-
return listInstalledManifestsView(vfs.as(CRED_KERNEL), homeDir);
|
|
227
|
-
}
|
|
228
|
-
function listInstalledManifestsView(fs, homeDir) {
|
|
229
|
-
const home = homeDir.replace(/^\/+/, '').replace(/\/+$/, '');
|
|
230
|
-
const runtimesRoot = `${home}/.nimbus/runtimes`;
|
|
231
|
-
const out = [];
|
|
232
|
-
if (!fs.exists(runtimesRoot))
|
|
233
|
-
return out;
|
|
234
|
-
// Each entry under runtimesRoot is a <name>; each entry under that
|
|
235
|
-
// is a <version>; each <version> dir has a manifest.json.
|
|
236
|
-
for (const nameEntry of fs.readdir(runtimesRoot)) {
|
|
237
|
-
if (nameEntry.type !== 'directory')
|
|
238
|
-
continue;
|
|
239
|
-
const nameDir = `${runtimesRoot}/${nameEntry.name}`;
|
|
240
|
-
for (const verEntry of fs.readdir(nameDir)) {
|
|
241
|
-
if (verEntry.type !== 'directory')
|
|
242
|
-
continue;
|
|
243
|
-
const verDir = `${nameDir}/${verEntry.name}`;
|
|
244
|
-
const manifestPath = `${verDir}/manifest.json`;
|
|
245
|
-
if (!fs.exists(manifestPath))
|
|
246
|
-
continue;
|
|
247
|
-
try {
|
|
248
|
-
const manifest = parseRuntimeManifest(JSON.parse(fs.readFileString(manifestPath)));
|
|
249
|
-
out.push({ root: verDir, manifest });
|
|
250
|
-
}
|
|
251
|
-
catch {
|
|
252
|
-
// Malformed manifest — skip silently. Surfacing via stderr
|
|
253
|
-
// would require a ctx we don't have at boot-time rehydration.
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
return out;
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Re-register every installed runtime's entrypoints in the shell
|
|
261
|
-
* registry. Call once at session-init time after all runner factories
|
|
262
|
-
* are registered (init.ts:registerRunnerFactory blocks).
|
|
263
|
-
*/
|
|
264
|
-
export function rehydrateInstalledRuntimes(vfs, registry, homeDir) {
|
|
265
|
-
return rehydrateInstalledRuntimesView(vfs.as(CRED_KERNEL), registry, homeDir);
|
|
266
|
-
}
|
|
267
|
-
function rehydrateInstalledRuntimesView(vfs, registry, homeDir) {
|
|
268
|
-
const bins = [];
|
|
269
|
-
for (const { root, manifest } of listInstalledManifestsView(vfs, homeDir)) {
|
|
270
|
-
for (const ep of runtimeEntrypoints(manifest)) {
|
|
271
|
-
const factory = runnerFactories[ep.runner];
|
|
272
|
-
if (!factory)
|
|
273
|
-
continue; // runner not registered yet — skip
|
|
274
|
-
const handler = factory(manifest, root, ep.binName, ep.kind);
|
|
275
|
-
registry.register(ep.binName, handler);
|
|
276
|
-
bins.push(ep.binName);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
return { count: bins.length, bins };
|
|
280
|
-
}
|
|
281
|
-
export function listInstalledRuntimes(vfs, homeDir) {
|
|
282
|
-
return listInstalledManifests(vfs, homeDir).map(({ root, manifest }) => ({
|
|
283
|
-
name: manifest.name,
|
|
284
|
-
version: manifest.version,
|
|
285
|
-
root,
|
|
286
|
-
abi: runtimeAbiForManifest(manifest),
|
|
287
|
-
bins: runtimeEntrypoints(manifest).map((e) => e.binName),
|
|
288
|
-
sizeBytes: manifest.files.reduce((a, f) => a + f.size, 0),
|
|
289
|
-
license: manifest.license,
|
|
290
|
-
}));
|
|
291
|
-
}
|
|
292
155
|
export async function listAvailableRuntimes(env) {
|
|
293
156
|
const catalog = await fetchCatalog(env);
|
|
294
157
|
return Object.entries(catalog.runtimes)
|
|
@@ -409,7 +272,7 @@ async function runInstall(args, ctx, deps) {
|
|
|
409
272
|
// manifest's presence implies the install completed; we trust it.
|
|
410
273
|
ctx.stdout.write(`[${name}] already installed at ${root} (use --reinstall to refetch)\n`);
|
|
411
274
|
// Still re-register bins in case the registry lost them — idempotent.
|
|
412
|
-
rehydrateInstalledRuntimesView(deps.vfs, deps.registry, home);
|
|
275
|
+
rehydrateInstalledRuntimesView(deps.vfs, deps.registry, home, runnerFactoryFor);
|
|
413
276
|
let manifest = null;
|
|
414
277
|
try {
|
|
415
278
|
manifest = parseRuntimeManifest(JSON.parse(deps.vfs.readFileString(`${root}/manifest.json`)));
|
|
@@ -505,7 +368,7 @@ async function runInstall(args, ctx, deps) {
|
|
|
505
368
|
await Promise.all(workers);
|
|
506
369
|
// Register entrypoints.
|
|
507
370
|
for (const ep of runtimeEntrypoints(manifest)) {
|
|
508
|
-
const factory =
|
|
371
|
+
const factory = runnerFactoryFor(ep.runner);
|
|
509
372
|
if (!factory) {
|
|
510
373
|
ctx.stderr.write(`[${name}] warning: runner '${ep.runner}' not registered; bin '${ep.binName}' will not be invokable\n`);
|
|
511
374
|
continue;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
import type { SqliteVFS } from '@nimbus-sh/core/vfs/sqlite-vfs.js';
|
|
23
23
|
import type { FacetManager } from '../facets/manager.js';
|
|
24
24
|
import type { WebSocketTerminal } from '../facets/ws-terminal.js';
|
|
25
|
-
import type { RuntimeManifest } from '
|
|
25
|
+
import type { RuntimeManifest } from '@nimbus-sh/core/runtime/runtime-manifest.js';
|
|
26
26
|
export interface PythonReplDeps {
|
|
27
27
|
facetMgr: FacetManager;
|
|
28
28
|
vfs: SqliteVFS;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"python-repl.d.ts","sourceRoot":"","sources":["../../src/runtime/python-repl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"python-repl.d.ts","sourceRoot":"","sources":["../../src/runtime/python-repl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACnE,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;AAoBnF,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,YAAY,CAAC;IACvB,GAAG,EAAE,SAAS,CAAC;IACf,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,mFAAmF;IACnF,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,eAAe,CAAC;IAC1B;;;;;;;;;OASG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;;;;OAQG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AA0QD,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,KAAK,GAAG,aAAa,GAAG,UAAU,CAAC,GAC1E,OAAO,CAAC,IAAI,CAAC,CAIf"}
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
* deciding what counts as a result.
|
|
21
21
|
*/
|
|
22
22
|
import { ReplSession } from './repl-session.js';
|
|
23
|
-
import { sessionUsesSciVariant } from '
|
|
24
|
-
import { buildCPythonPreamble } from '
|
|
23
|
+
import { sessionUsesSciVariant } from '@nimbus-sh/core/runtime/python-pip.js';
|
|
24
|
+
import { buildCPythonPreamble } from '@nimbus-sh/core/runtime/cpython-runner.js';
|
|
25
25
|
import { getFacetManagerLoaderHost } from './facet-loader-host.js';
|
|
26
26
|
import { CRED_KERNEL } from '@nimbus-sh/core/runtime/os-contracts.js';
|
|
27
27
|
/** Written by the driver when the source so far cannot yet be run. */
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* - irb history pickling.
|
|
26
26
|
*/
|
|
27
27
|
import { ReplSession } from './repl-session.js';
|
|
28
|
-
import { buildRubyPreamble } from '
|
|
28
|
+
import { buildRubyPreamble } from '@nimbus-sh/core/runtime/ruby-runner.js';
|
|
29
29
|
import { CRED_KERNEL } from '@nimbus-sh/core/runtime/os-contracts.js';
|
|
30
30
|
class RubyReplAdapter {
|
|
31
31
|
pool = null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ruby-resident.ts — a Ruby program that keeps serving, as a Durable Object
|
|
3
|
+
* facet.
|
|
4
|
+
*
|
|
5
|
+
* The half of the Ruby runtime that names workerd. Everything about running
|
|
6
|
+
* the interpreter is in `@nimbus-sh/core`; this is the substrate a program
|
|
7
|
+
* that outlives its invocation needs — an actor that stays alive between
|
|
8
|
+
* requests, with inbound HTTP routed into the socket the program bound. A
|
|
9
|
+
* host without one supplies no {@link RubyResidentStart}, and such a program
|
|
10
|
+
* is refused rather than quietly run as a one-shot that dies with the call.
|
|
11
|
+
*/
|
|
12
|
+
import { type RubyResidentStart } from '@nimbus-sh/core/runtime/ruby-runner.js';
|
|
13
|
+
import type { FacetManager } from '../facets/manager.js';
|
|
14
|
+
/**
|
|
15
|
+
* Start a Ruby program that binds a port as its own process, so it outlives
|
|
16
|
+
* the invocation that started it.
|
|
17
|
+
*/
|
|
18
|
+
export declare function rubyResidentStart(facetMgr: FacetManager): RubyResidentStart;
|
|
19
|
+
export declare function buildRubySocketProcessWorker(preamble: string): string;
|
|
20
|
+
//# sourceMappingURL=ruby-resident.d.ts.map
|
|
@@ -0,0 +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,CA8E3E;AAED,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAiLrE"}
|