@nimbus-sh/worker 0.1.5 → 0.1.6
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 +37 -0
- package/dist/_shared/crypto.d.ts +15 -0
- package/dist/_shared/crypto.d.ts.map +1 -0
- package/dist/_shared/crypto.js +122 -0
- package/dist/facets/manager.d.ts +24 -0
- package/dist/facets/manager.d.ts.map +1 -1
- package/dist/facets/manager.js +279 -70
- package/dist/facets/process.d.ts +11 -2
- package/dist/facets/process.d.ts.map +1 -1
- package/dist/facets/process.js +187 -21
- package/dist/facets/vite-dev-server.d.ts +2 -0
- package/dist/facets/vite-dev-server.d.ts.map +1 -1
- package/dist/facets/vite-dev-server.js +39 -12
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/loaders/child-process/spawn-facet.d.ts +1 -3
- package/dist/loaders/child-process/spawn-facet.d.ts.map +1 -1
- package/dist/loaders/child-process/spawn-facet.js +1 -12
- package/dist/loaders/child-process/spawn-pool.d.ts +1 -1
- package/dist/loaders/child-process/spawn-pool.d.ts.map +1 -1
- package/dist/loaders/child-process/spawn-pool.js +1 -6
- package/dist/npm/installer.d.ts.map +1 -1
- package/dist/npm/installer.js +47 -27
- package/dist/npm/pre-bundle-facet.d.ts.map +1 -1
- package/dist/npm/pre-bundle-facet.js +2 -1
- package/dist/npm/resolve-one-facet.d.ts.map +1 -1
- package/dist/npm/resolve-one-facet.js +41 -13
- package/dist/npm/resolver.d.ts.map +1 -1
- package/dist/npm/resolver.js +70 -35
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +45 -21
- package/dist/router/remote-api.d.ts.map +1 -1
- package/dist/router/remote-api.js +29 -8
- package/dist/runtime/barrel-synthesizer.d.ts +7 -0
- package/dist/runtime/barrel-synthesizer.d.ts.map +1 -1
- package/dist/runtime/barrel-synthesizer.js +11 -0
- package/dist/runtime/clang-runner.d.ts.map +1 -1
- package/dist/runtime/clang-runner.js +1 -8
- package/dist/runtime/esbuild-service.d.ts +12 -5
- package/dist/runtime/esbuild-service.d.ts.map +1 -1
- package/dist/runtime/esbuild-service.js +28 -14
- package/dist/runtime/node-runner.d.ts +2 -0
- package/dist/runtime/node-runner.d.ts.map +1 -1
- package/dist/runtime/node-shims.d.ts +4 -2
- package/dist/runtime/node-shims.d.ts.map +1 -1
- package/dist/runtime/node-shims.js +404 -55
- package/dist/runtime/os-contracts.d.ts +128 -0
- package/dist/runtime/os-contracts.d.ts.map +1 -0
- package/dist/runtime/os-contracts.js +1 -0
- package/dist/runtime/package-manager.d.ts.map +1 -1
- package/dist/runtime/package-manager.js +32 -7
- package/dist/runtime/port-registry.d.ts +5 -0
- package/dist/runtime/port-registry.d.ts.map +1 -1
- package/dist/runtime/port-registry.js +22 -1
- package/dist/runtime/pyodide-runtime-assets.d.ts +19 -0
- package/dist/runtime/pyodide-runtime-assets.d.ts.map +1 -0
- package/dist/runtime/pyodide-runtime-assets.js +44 -0
- package/dist/runtime/python-repl.d.ts +3 -1
- package/dist/runtime/python-repl.d.ts.map +1 -1
- package/dist/runtime/python-repl.js +11 -29
- package/dist/runtime/python-runner.d.ts +8 -9
- package/dist/runtime/python-runner.d.ts.map +1 -1
- package/dist/runtime/python-runner.js +897 -61
- package/dist/runtime/python-socket-shim.d.ts +11 -0
- package/dist/runtime/python-socket-shim.d.ts.map +1 -0
- package/dist/runtime/python-socket-shim.js +526 -0
- package/dist/runtime/require-resolver.d.ts.map +1 -1
- package/dist/runtime/require-resolver.js +2 -11
- package/dist/runtime/ruby-gems.d.ts +25 -0
- package/dist/runtime/ruby-gems.d.ts.map +1 -0
- package/dist/runtime/ruby-gems.js +582 -0
- package/dist/runtime/ruby-runner.d.ts +2 -4
- package/dist/runtime/ruby-runner.d.ts.map +1 -1
- package/dist/runtime/ruby-runner.js +335 -34
- package/dist/runtime/runtime-catalog.d.ts +16 -4
- package/dist/runtime/runtime-catalog.d.ts.map +1 -1
- package/dist/runtime/runtime-catalog.js +21 -10
- package/dist/runtime/runtime-registry.d.ts +3 -0
- package/dist/runtime/runtime-registry.d.ts.map +1 -1
- package/dist/runtime/runtime-registry.js +4 -0
- package/dist/runtime/sqlite-runtime-fs-bridge.d.ts +43 -0
- package/dist/runtime/sqlite-runtime-fs-bridge.d.ts.map +1 -0
- package/dist/runtime/sqlite-runtime-fs-bridge.js +224 -0
- package/dist/runtime/static-server.d.ts +3 -0
- package/dist/runtime/static-server.d.ts.map +1 -0
- package/dist/runtime/static-server.js +121 -0
- package/dist/runtime/vfs-snapshot.d.ts +57 -0
- package/dist/runtime/vfs-snapshot.d.ts.map +1 -0
- package/dist/runtime/vfs-snapshot.js +141 -0
- package/dist/runtime/virtual-socket-kernel.d.ts +16 -0
- package/dist/runtime/virtual-socket-kernel.d.ts.map +1 -0
- package/dist/runtime/virtual-socket-kernel.js +360 -0
- package/dist/runtime/wasi-instance.d.ts +6 -3
- package/dist/runtime/wasi-instance.d.ts.map +1 -1
- package/dist/runtime/wasm-runner.d.ts +1 -25
- package/dist/runtime/wasm-runner.d.ts.map +1 -1
- package/dist/runtime/wasm-runner.js +1 -160
- package/dist/session/agent.d.ts +43 -0
- package/dist/session/agent.d.ts.map +1 -0
- package/dist/session/agent.js +1252 -0
- package/dist/session/init.d.ts.map +1 -1
- package/dist/session/init.js +15 -16
- package/dist/session/nimbus-session.d.ts +13 -2
- package/dist/session/nimbus-session.d.ts.map +1 -1
- package/dist/session/nimbus-session.js +55 -7
- package/dist/session/programmatic.d.ts +10 -0
- package/dist/session/programmatic.d.ts.map +1 -1
- package/dist/session/programmatic.js +121 -0
- package/dist/session/routes.d.ts.map +1 -1
- package/dist/session/routes.js +19 -1
- package/dist/session/rpc.d.ts +11 -0
- package/dist/session/rpc.d.ts.map +1 -1
- package/dist/session/rpc.js +56 -43
- package/dist/session/supervisor-rpc.d.ts +15 -0
- package/dist/session/supervisor-rpc.d.ts.map +1 -1
- package/dist/session/supervisor-rpc.js +32 -0
- package/dist/session/ws.d.ts +4 -3
- package/dist/session/ws.d.ts.map +1 -1
- package/dist/session/ws.js +11 -1
- package/dist/shell/unix-commands.js +12 -16
- package/dist/vfs/path.d.ts +8 -4
- package/dist/vfs/path.d.ts.map +1 -1
- package/dist/vfs/path.js +16 -4
- package/dist/vfs/sqlite-vfs.d.ts +2 -0
- package/dist/vfs/sqlite-vfs.d.ts.map +1 -1
- package/dist/vfs/sqlite-vfs.js +11 -0
- package/dist/vfs/symlink-registry.d.ts +7 -1
- package/dist/vfs/symlink-registry.d.ts.map +1 -1
- package/dist/vfs/symlink-registry.js +16 -11
- package/package.json +4 -1
- package/public/index.html +240 -0
- package/public/s/index.html +1172 -146
- package/runtime-contracts/pyodide-workerd-adapter.json +18 -0
- package/scripts/bundle-runtime.mjs +99 -24
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { VfsEvent } from '../vfs/events.js';
|
|
2
|
+
export type RuntimeFileType = 'file' | 'directory' | 'symlink';
|
|
3
|
+
export interface RuntimeVfsStat {
|
|
4
|
+
type: RuntimeFileType;
|
|
5
|
+
size: number;
|
|
6
|
+
ctime: number;
|
|
7
|
+
mtime: number;
|
|
8
|
+
mode: number;
|
|
9
|
+
revision: number;
|
|
10
|
+
}
|
|
11
|
+
export interface RuntimeVfsDirEntry {
|
|
12
|
+
name: string;
|
|
13
|
+
type: RuntimeFileType;
|
|
14
|
+
}
|
|
15
|
+
export interface RuntimeOpenFlags {
|
|
16
|
+
read?: boolean;
|
|
17
|
+
write?: boolean;
|
|
18
|
+
append?: boolean;
|
|
19
|
+
create?: boolean;
|
|
20
|
+
truncate?: boolean;
|
|
21
|
+
followSymlinks?: boolean;
|
|
22
|
+
expectedRevision?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface RuntimeFileHandle {
|
|
25
|
+
id: number;
|
|
26
|
+
path: string;
|
|
27
|
+
flags: Required<Omit<RuntimeOpenFlags, 'expectedRevision'>> & {
|
|
28
|
+
expectedRevision?: number;
|
|
29
|
+
};
|
|
30
|
+
position: number;
|
|
31
|
+
baseRevision: number;
|
|
32
|
+
closed: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface RuntimeFsBridge {
|
|
35
|
+
stat(path: string, options?: {
|
|
36
|
+
followSymlinks?: boolean;
|
|
37
|
+
}): Promise<RuntimeVfsStat | null>;
|
|
38
|
+
readFile(path: string, options?: {
|
|
39
|
+
followSymlinks?: boolean;
|
|
40
|
+
}): Promise<Uint8Array | null>;
|
|
41
|
+
writeFile(path: string, bytes: string | Uint8Array, options?: {
|
|
42
|
+
createParents?: boolean;
|
|
43
|
+
expectedRevision?: number;
|
|
44
|
+
}): Promise<void>;
|
|
45
|
+
open(path: string, flags: RuntimeOpenFlags): Promise<RuntimeFileHandle>;
|
|
46
|
+
read(handleId: number, offset: number | null, length: number): Promise<Uint8Array>;
|
|
47
|
+
write(handleId: number, offset: number | null, bytes: Uint8Array): Promise<number>;
|
|
48
|
+
close(handleId: number): Promise<void>;
|
|
49
|
+
readdir(path: string, options?: {
|
|
50
|
+
followSymlinks?: boolean;
|
|
51
|
+
}): Promise<RuntimeVfsDirEntry[]>;
|
|
52
|
+
mkdir(path: string, options?: {
|
|
53
|
+
recursive?: boolean;
|
|
54
|
+
mode?: number;
|
|
55
|
+
}): Promise<void>;
|
|
56
|
+
unlink(path: string): Promise<void>;
|
|
57
|
+
rmdir(path: string): Promise<void>;
|
|
58
|
+
rename(from: string, to: string): Promise<void>;
|
|
59
|
+
readlink(path: string): Promise<string | null>;
|
|
60
|
+
symlink(target: string, path: string): Promise<void>;
|
|
61
|
+
fsync(handleId?: number): Promise<void>;
|
|
62
|
+
revision(path?: string): Promise<number>;
|
|
63
|
+
subscribe?(path: string, listener: (event: VfsEvent) => void): () => void;
|
|
64
|
+
}
|
|
65
|
+
export interface RuntimeProcessBridge {
|
|
66
|
+
spawn(command: string, args: string[], options?: {
|
|
67
|
+
cwd?: string;
|
|
68
|
+
env?: Record<string, string>;
|
|
69
|
+
tty?: RuntimeTtyOptions;
|
|
70
|
+
}): Promise<{
|
|
71
|
+
pid: number;
|
|
72
|
+
}>;
|
|
73
|
+
writeStdin(pid: number, bytes: string | Uint8Array): Promise<void>;
|
|
74
|
+
endStdin(pid: number): Promise<void>;
|
|
75
|
+
kill(pid: number, signal?: string): Promise<void>;
|
|
76
|
+
wait(pid: number, timeoutMs?: number): Promise<{
|
|
77
|
+
exitCode: number | null;
|
|
78
|
+
}>;
|
|
79
|
+
}
|
|
80
|
+
export interface RuntimeTtyOptions {
|
|
81
|
+
stdinIsTTY?: boolean;
|
|
82
|
+
stdoutIsTTY?: boolean;
|
|
83
|
+
stderrIsTTY?: boolean;
|
|
84
|
+
columns?: number;
|
|
85
|
+
rows?: number;
|
|
86
|
+
raw?: boolean;
|
|
87
|
+
}
|
|
88
|
+
export interface RuntimePortBridge {
|
|
89
|
+
register(port: number, processId: number, handler: (request: Request) => Promise<Response>): Promise<void>;
|
|
90
|
+
unregister(port: number, processId?: number): Promise<void>;
|
|
91
|
+
list(): Promise<Array<{
|
|
92
|
+
port: number;
|
|
93
|
+
processId: number;
|
|
94
|
+
registeredAt: number;
|
|
95
|
+
}>>;
|
|
96
|
+
}
|
|
97
|
+
export type RuntimePackageAbi = 'javascript' | 'wasm32-wasi-nimbus' | 'pyodide' | 'ruby-wasm' | 'native-unsupported';
|
|
98
|
+
export interface RuntimeCommandProvider {
|
|
99
|
+
runtimeName: string;
|
|
100
|
+
version: string;
|
|
101
|
+
abi: RuntimePackageAbi;
|
|
102
|
+
commands: string[];
|
|
103
|
+
packageManagers?: string[];
|
|
104
|
+
libraries?: string[];
|
|
105
|
+
}
|
|
106
|
+
export type RuntimeDiagnosticEvent = {
|
|
107
|
+
type: 'fs-cache';
|
|
108
|
+
hit: boolean;
|
|
109
|
+
path: string;
|
|
110
|
+
bytes?: number;
|
|
111
|
+
revision?: number;
|
|
112
|
+
} | {
|
|
113
|
+
type: 'fs-flush';
|
|
114
|
+
path?: string;
|
|
115
|
+
bytes: number;
|
|
116
|
+
durationMs: number;
|
|
117
|
+
} | {
|
|
118
|
+
type: 'fs-invalidation';
|
|
119
|
+
path: string;
|
|
120
|
+
revision: number;
|
|
121
|
+
lagMs?: number;
|
|
122
|
+
} | {
|
|
123
|
+
type: 'unsupported-abi';
|
|
124
|
+
packageName?: string;
|
|
125
|
+
abi: string;
|
|
126
|
+
message: string;
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=os-contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"os-contracts.d.ts","sourceRoot":"","sources":["../../src/runtime/os-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;AAE/D,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,eAAe,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,QAAQ,CAAC,IAAI,C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3: 'python',
|
|
39
|
+
pip: 'python',
|
|
40
|
+
pip3: 'python',
|
|
39
41
|
ruby3: 'ruby',
|
|
42
|
+
gem: 'ruby',
|
|
43
|
+
bundle: 'ruby',
|
|
44
|
+
bundler: 'ruby',
|
|
40
45
|
'wasm-ld': 'clang',
|
|
41
46
|
};
|
|
47
|
+
function runtimeEntrypoints(manifest) {
|
|
48
|
+
const out = [...manifest.entrypoints];
|
|
49
|
+
const seen = new Set(out.map((ep) => ep.binName));
|
|
50
|
+
const add = (binName, runner, kind) => {
|
|
51
|
+
if (seen.has(binName))
|
|
52
|
+
return;
|
|
53
|
+
out.push({ binName, runner, kind, args: [] });
|
|
54
|
+
seen.add(binName);
|
|
55
|
+
};
|
|
56
|
+
if (manifest.name === 'python') {
|
|
57
|
+
add('pip', 'python-runner', 'pip');
|
|
58
|
+
add('pip3', 'python-runner', 'pip');
|
|
59
|
+
}
|
|
60
|
+
if (manifest.name === 'ruby') {
|
|
61
|
+
add('gem', 'ruby-runner', 'gem');
|
|
62
|
+
add('bundle', 'ruby-runner', 'bundle');
|
|
63
|
+
add('bundler', 'ruby-runner', 'bundle');
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
42
67
|
function splitRuntimeSpec(spec) {
|
|
43
68
|
const atIdx = spec.indexOf('@');
|
|
44
69
|
return {
|
|
@@ -63,7 +88,7 @@ async function resolveRuntimeInstallTarget(env, catalog, spec) {
|
|
|
63
88
|
continue;
|
|
64
89
|
try {
|
|
65
90
|
const manifest = await fetchManifest(env, versionEntry.manifest);
|
|
66
|
-
if (manifest.
|
|
91
|
+
if (runtimeEntrypoints(manifest).some((ep) => ep.binName === parsed.name)) {
|
|
67
92
|
return {
|
|
68
93
|
runtimeName,
|
|
69
94
|
versionOverride: parsed.versionOverride,
|
|
@@ -103,7 +128,7 @@ export function createRuntimeCommandHintResolver(env) {
|
|
|
103
128
|
continue;
|
|
104
129
|
try {
|
|
105
130
|
const manifest = await fetchManifest(env, versionEntry.manifest);
|
|
106
|
-
for (const ep of manifest
|
|
131
|
+
for (const ep of runtimeEntrypoints(manifest))
|
|
107
132
|
add(ep.binName, runtimeName);
|
|
108
133
|
}
|
|
109
134
|
catch {
|
|
@@ -175,7 +200,7 @@ export function listInstalledManifests(vfs, homeDir) {
|
|
|
175
200
|
export function rehydrateInstalledRuntimes(vfs, registry, homeDir) {
|
|
176
201
|
const bins = [];
|
|
177
202
|
for (const { root, manifest } of listInstalledManifests(vfs, homeDir)) {
|
|
178
|
-
for (const ep of manifest
|
|
203
|
+
for (const ep of runtimeEntrypoints(manifest)) {
|
|
179
204
|
const factory = runnerFactories[ep.runner];
|
|
180
205
|
if (!factory)
|
|
181
206
|
continue; // runner not registered yet — skip
|
|
@@ -191,7 +216,7 @@ export function listInstalledRuntimes(vfs, homeDir) {
|
|
|
191
216
|
name: manifest.name,
|
|
192
217
|
version: manifest.version,
|
|
193
218
|
root,
|
|
194
|
-
bins: manifest.
|
|
219
|
+
bins: runtimeEntrypoints(manifest).map((e) => e.binName),
|
|
195
220
|
sizeBytes: manifest.files.reduce((a, f) => a + f.size, 0),
|
|
196
221
|
license: manifest.license,
|
|
197
222
|
}));
|
|
@@ -406,7 +431,7 @@ async function runInstall(args, ctx, deps) {
|
|
|
406
431
|
});
|
|
407
432
|
await Promise.all(workers);
|
|
408
433
|
// Register entrypoints.
|
|
409
|
-
for (const ep of manifest
|
|
434
|
+
for (const ep of runtimeEntrypoints(manifest)) {
|
|
410
435
|
const factory = runnerFactories[ep.runner];
|
|
411
436
|
if (!factory) {
|
|
412
437
|
ctx.stderr.write(`[${name}] warning: runner '${ep.runner}' not registered; bin '${ep.binName}' will not be invokable\n`);
|
|
@@ -445,7 +470,7 @@ async function runList(ctx, deps) {
|
|
|
445
470
|
ctx.stdout.write(`installed runtimes (${installed.length}):\n`);
|
|
446
471
|
for (const { root, manifest } of installed) {
|
|
447
472
|
const totalBytes = manifest.files.reduce((a, f) => a + f.size, 0);
|
|
448
|
-
const bins = manifest.
|
|
473
|
+
const bins = runtimeEntrypoints(manifest).map((e) => e.binName).join(', ');
|
|
449
474
|
ctx.stdout.write(` ${manifest.name}@${manifest.version} ${(totalBytes / 1024 / 1024).toFixed(1)} MiB bins=[${bins}] ${root}\n`);
|
|
450
475
|
}
|
|
451
476
|
return 0;
|
|
@@ -496,7 +521,7 @@ async function runUninstall(args, ctx, deps) {
|
|
|
496
521
|
}
|
|
497
522
|
for (const m of matches) {
|
|
498
523
|
// Unregister bins.
|
|
499
|
-
for (const ep of m.manifest
|
|
524
|
+
for (const ep of runtimeEntrypoints(m.manifest)) {
|
|
500
525
|
// We don't have a guaranteed `unregister`; bins shadowing is OK
|
|
501
526
|
// because boot-rehydration only re-registers what's still on disk.
|
|
502
527
|
if (typeof deps.registry.unregister === 'function') {
|
|
@@ -38,6 +38,9 @@ export interface PortEntry {
|
|
|
38
38
|
}
|
|
39
39
|
export declare class PortRegistry {
|
|
40
40
|
private ports;
|
|
41
|
+
private facetStubsByPid;
|
|
42
|
+
/** Remember the routeable facet stub for a running process. */
|
|
43
|
+
bindFacetStub(pid: number, facetStub: any): void;
|
|
41
44
|
/** Register a facet as listening on a port. */
|
|
42
45
|
register(port: number, pid: number, facetStub: any): void;
|
|
43
46
|
/** Unregister a port. */
|
|
@@ -46,6 +49,8 @@ export declare class PortRegistry {
|
|
|
46
49
|
unregisterByPid(pid: number): number;
|
|
47
50
|
/** Look up a port entry. */
|
|
48
51
|
get(port: number): PortEntry | undefined;
|
|
52
|
+
/** Attach a routeable facet stub to ports previously reserved by a PID. */
|
|
53
|
+
attachFacetStubByPid(pid: number, facetStub: any): number[];
|
|
49
54
|
/** Check if a port is registered. */
|
|
50
55
|
has(port: number): boolean;
|
|
51
56
|
/** Get all registered ports. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"port-registry.d.ts","sourceRoot":"","sources":["../../src/runtime/port-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA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OAiBG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IA8F9F,IAAI,KAAK;;;;;;MAKR;CACF"}
|
|
@@ -27,9 +27,18 @@
|
|
|
27
27
|
*/
|
|
28
28
|
export class PortRegistry {
|
|
29
29
|
ports = new Map();
|
|
30
|
+
facetStubsByPid = new Map();
|
|
31
|
+
/** Remember the routeable facet stub for a running process. */
|
|
32
|
+
bindFacetStub(pid, facetStub) {
|
|
33
|
+
if (!facetStub)
|
|
34
|
+
return;
|
|
35
|
+
this.facetStubsByPid.set(pid, facetStub);
|
|
36
|
+
this.attachFacetStubByPid(pid, facetStub);
|
|
37
|
+
}
|
|
30
38
|
/** Register a facet as listening on a port. */
|
|
31
39
|
register(port, pid, facetStub) {
|
|
32
|
-
|
|
40
|
+
const routeableStub = facetStub || this.facetStubsByPid.get(pid) || null;
|
|
41
|
+
this.ports.set(port, { port, pid, facetStub: routeableStub, registeredAt: Date.now() });
|
|
33
42
|
}
|
|
34
43
|
/** Unregister a port. */
|
|
35
44
|
unregister(port) {
|
|
@@ -44,12 +53,24 @@ export class PortRegistry {
|
|
|
44
53
|
count++;
|
|
45
54
|
}
|
|
46
55
|
}
|
|
56
|
+
this.facetStubsByPid.delete(pid);
|
|
47
57
|
return count;
|
|
48
58
|
}
|
|
49
59
|
/** Look up a port entry. */
|
|
50
60
|
get(port) {
|
|
51
61
|
return this.ports.get(port);
|
|
52
62
|
}
|
|
63
|
+
/** Attach a routeable facet stub to ports previously reserved by a PID. */
|
|
64
|
+
attachFacetStubByPid(pid, facetStub) {
|
|
65
|
+
const ports = [];
|
|
66
|
+
for (const entry of this.ports.values()) {
|
|
67
|
+
if (entry.pid !== pid || entry.facetStub)
|
|
68
|
+
continue;
|
|
69
|
+
entry.facetStub = facetStub;
|
|
70
|
+
ports.push(entry.port);
|
|
71
|
+
}
|
|
72
|
+
return ports;
|
|
73
|
+
}
|
|
53
74
|
/** Check if a port is registered. */
|
|
54
75
|
has(port) {
|
|
55
76
|
return this.ports.has(port);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RuntimeManifest } from './runtime-catalog.js';
|
|
2
|
+
import type { SqliteVFS } from '../vfs/sqlite-vfs.js';
|
|
3
|
+
export interface PyodideRuntimeAssetPaths {
|
|
4
|
+
asmWasmVfs: string | null;
|
|
5
|
+
asmJsVfs: string | null;
|
|
6
|
+
stdlibVfs: string | null;
|
|
7
|
+
lockfileVfs: string | null;
|
|
8
|
+
manifest: RuntimeManifest;
|
|
9
|
+
vfs: SqliteVFS;
|
|
10
|
+
}
|
|
11
|
+
export interface PyodideRuntimeFiles {
|
|
12
|
+
asmWasmBytes: Uint8Array;
|
|
13
|
+
asmJsSrc: string;
|
|
14
|
+
stdlibB64: string;
|
|
15
|
+
lockfileText: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function readPyodideRuntimeFiles(args: PyodideRuntimeAssetPaths): PyodideRuntimeFiles;
|
|
18
|
+
export declare function uint8ToBase64(u8: Uint8Array): string;
|
|
19
|
+
//# sourceMappingURL=pyodide-runtime-assets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pyodide-runtime-assets.d.ts","sourceRoot":"","sources":["../../src/runtime/pyodide-runtime-assets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAWtD,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,eAAe,CAAC;IAC1B,GAAG,EAAE,SAAS,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,UAAU,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,wBAAwB,GAAG,mBAAmB,CAoB3F;AA6BD,wBAAgB,aAAa,CAAC,EAAE,EAAE,UAAU,GAAG,MAAM,CAUpD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import pyodideWorkerdAdapter from '../../runtime-contracts/pyodide-workerd-adapter.json';
|
|
2
|
+
const WORKERD_ADAPTER = pyodideWorkerdAdapter;
|
|
3
|
+
export function readPyodideRuntimeFiles(args) {
|
|
4
|
+
if (!args.asmWasmVfs || !args.asmJsVfs || !args.stdlibVfs) {
|
|
5
|
+
throw new Error('installed Pyodide manifest is missing required files');
|
|
6
|
+
}
|
|
7
|
+
const asmWasmBytes = args.vfs.readFile(args.asmWasmVfs);
|
|
8
|
+
const asmJsSrc = new TextDecoder('utf-8').decode(args.vfs.readFile(args.asmJsVfs));
|
|
9
|
+
const stdlibBytes = args.vfs.readFile(args.stdlibVfs);
|
|
10
|
+
const lockfileText = args.lockfileVfs && args.vfs.exists(args.lockfileVfs)
|
|
11
|
+
? new TextDecoder('utf-8').decode(args.vfs.readFile(args.lockfileVfs))
|
|
12
|
+
: '{"packages":{}}';
|
|
13
|
+
assertPyodideWorkerdAdapter(args.manifest, asmJsSrc);
|
|
14
|
+
return {
|
|
15
|
+
asmWasmBytes,
|
|
16
|
+
asmJsSrc,
|
|
17
|
+
stdlibB64: uint8ToBase64(stdlibBytes),
|
|
18
|
+
lockfileText,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function assertPyodideWorkerdAdapter(manifest, asmJsSrc) {
|
|
22
|
+
const metadata = (manifest.runtime_artifacts || []).find((entry) => entry.path === WORKERD_ADAPTER.artifactPath && entry.kind === 'workerd-adapter');
|
|
23
|
+
if (!metadata) {
|
|
24
|
+
throw new Error(`pyodide.asm.js is missing Nimbus workerd adapter metadata (${WORKERD_ADAPTER.id}); ` +
|
|
25
|
+
`sync the python runtime and reinstall it with 'nimbus install python --reinstall'`);
|
|
26
|
+
}
|
|
27
|
+
if (metadata.id !== WORKERD_ADAPTER.id) {
|
|
28
|
+
throw new Error(`pyodide.asm.js adapter mismatch: installed ${metadata.id}, expected ${WORKERD_ADAPTER.id}`);
|
|
29
|
+
}
|
|
30
|
+
if (manifest.version !== WORKERD_ADAPTER.pyodideVersion) {
|
|
31
|
+
throw new Error(`Pyodide version mismatch: installed ${manifest.version}, expected ${WORKERD_ADAPTER.pyodideVersion}`);
|
|
32
|
+
}
|
|
33
|
+
if (!asmJsSrc.startsWith(WORKERD_ADAPTER.sentinel)) {
|
|
34
|
+
throw new Error(`pyodide.asm.js does not contain the Nimbus workerd adapter sentinel (${WORKERD_ADAPTER.id})`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function uint8ToBase64(u8) {
|
|
38
|
+
const chunk = 0x8000;
|
|
39
|
+
let s = '';
|
|
40
|
+
for (let i = 0; i < u8.length; i += chunk) {
|
|
41
|
+
s += String.fromCharCode.apply(null, Array.from(u8.subarray(i, Math.min(i + chunk, u8.length))));
|
|
42
|
+
}
|
|
43
|
+
return btoa(s);
|
|
44
|
+
}
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
import type { SqliteVFS } from '../vfs/sqlite-vfs.js';
|
|
30
30
|
import type { FacetManager } from '../facets/manager.js';
|
|
31
31
|
import type { WebSocketTerminal } from '../facets/ws-terminal.js';
|
|
32
|
+
import type { RuntimeManifest } from './runtime-catalog.js';
|
|
32
33
|
/** Inputs needed to bootstrap a Pyodide REPL session. */
|
|
33
34
|
export interface PythonReplDeps {
|
|
34
35
|
facetMgr: FacetManager;
|
|
@@ -36,6 +37,7 @@ export interface PythonReplDeps {
|
|
|
36
37
|
terminal: WebSocketTerminal;
|
|
37
38
|
/** Per-user-VFS install dir, e.g. 'home/user/.nimbus/runtimes/python/0.29.4'. */
|
|
38
39
|
installRoot: string;
|
|
40
|
+
manifest: RuntimeManifest;
|
|
39
41
|
/**
|
|
40
42
|
* REPL-R7-1 (2026-05-12): optional lifo-sh Shell reference.
|
|
41
43
|
*
|
|
@@ -62,5 +64,5 @@ export interface PythonReplDeps {
|
|
|
62
64
|
* runs `python` with no args.
|
|
63
65
|
*/
|
|
64
66
|
export declare function runPythonRepl(deps: PythonReplDeps): Promise<number>;
|
|
65
|
-
export declare function warmPythonRepl(deps: Pick<PythonReplDeps, 'facetMgr' | 'vfs' | 'installRoot'>): Promise<void>;
|
|
67
|
+
export declare function warmPythonRepl(deps: Pick<PythonReplDeps, 'facetMgr' | 'vfs' | 'installRoot' | 'manifest'>): Promise<void>;
|
|
66
68
|
//# sourceMappingURL=python-repl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"python-repl.d.ts","sourceRoot":"","sources":["../../src/runtime/python-repl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"python-repl.d.ts","sourceRoot":"","sources":["../../src/runtime/python-repl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAK5D,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,YAAY,CAAC;IACvB,GAAG,EAAE,SAAS,CAAC;IACf,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,iFAAiF;IACjF,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,eAAe,CAAC;IAC1B;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,EAAE,GAAG,CAAC;CACb;AA8fD;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAOzE;AAED,wBAAsB,cAAc,CAClC,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,KAAK,GAAG,aAAa,GAAG,UAAU,CAAC,GAC1E,OAAO,CAAC,IAAI,CAAC,CAIf"}
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
*/
|
|
29
29
|
import { ReplSession } from './repl-session.js';
|
|
30
30
|
import { buildPyodidePreamble } from './python-runner.js';
|
|
31
|
+
import { readPyodideRuntimeFiles } from './pyodide-runtime-assets.js';
|
|
31
32
|
/**
|
|
32
33
|
* Adapter that owns a NimbusLoaderPool for the lifetime of the REPL
|
|
33
34
|
* session. Each push(line) is a fresh pool.submit() into the cached
|
|
@@ -124,24 +125,15 @@ class PythonReplAdapter {
|
|
|
124
125
|
if (!vfs.exists(stdlibPath)) {
|
|
125
126
|
throw new Error(`python_stdlib.zip missing at ${stdlibPath}`);
|
|
126
127
|
}
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
const HEAD_NEEDLE = 'if(d.IN_BROWSER_MAIN_THREAD)';
|
|
138
|
-
const HEAD_REPLACE = 'if(true||d.IN_BROWSER_MAIN_THREAD)';
|
|
139
|
-
if (asmJsSrc.includes(HEAD_NEEDLE)) {
|
|
140
|
-
asmJsSrc = asmJsSrc.replace(HEAD_NEEDLE, HEAD_REPLACE);
|
|
141
|
-
}
|
|
142
|
-
// Encode stdlib bytes to base64 for splice into preamble.
|
|
143
|
-
const stdlibB64 = uint8ToBase64(stdlibBytes);
|
|
144
|
-
const preamble = buildPyodidePreamble(asmJsSrc, stdlibB64);
|
|
128
|
+
const files = readPyodideRuntimeFiles({
|
|
129
|
+
asmWasmVfs: wasmPath,
|
|
130
|
+
asmJsVfs: jsPath,
|
|
131
|
+
stdlibVfs: stdlibPath,
|
|
132
|
+
lockfileVfs: `${installRoot}/share/pyodide/pyodide-lock.json`,
|
|
133
|
+
manifest: this.deps.manifest,
|
|
134
|
+
vfs,
|
|
135
|
+
});
|
|
136
|
+
const preamble = buildPyodidePreamble(files.asmJsSrc, files.stdlibB64, files.lockfileText);
|
|
145
137
|
// Create the pool. Tag MUST differ from 'python-runner' so REPL
|
|
146
138
|
// sessions don't collide with one-shot dispatches in the loader
|
|
147
139
|
// slot cache (different fnHash + different tag = separate slot).
|
|
@@ -154,7 +146,7 @@ class PythonReplAdapter {
|
|
|
154
146
|
omitSupervisor: true,
|
|
155
147
|
preamble,
|
|
156
148
|
wasmModules: {
|
|
157
|
-
'pyodide.asm.wasm': toAB(
|
|
149
|
+
'pyodide.asm.wasm': toAB(files.asmWasmBytes),
|
|
158
150
|
},
|
|
159
151
|
});
|
|
160
152
|
}
|
|
@@ -534,16 +526,6 @@ function replStepFacetFn(args) {
|
|
|
534
526
|
function toAB(u8) {
|
|
535
527
|
return u8.buffer.slice(u8.byteOffset, u8.byteOffset + u8.byteLength);
|
|
536
528
|
}
|
|
537
|
-
/** Encode Uint8Array → base64 in chunks to avoid stack overflow on
|
|
538
|
-
* ~2 MiB stdlib payload. Mirrors python-runner.ts's helper. */
|
|
539
|
-
function uint8ToBase64(u8) {
|
|
540
|
-
const CHUNK = 0x8000;
|
|
541
|
-
let s = '';
|
|
542
|
-
for (let i = 0; i < u8.length; i += CHUNK) {
|
|
543
|
-
s += String.fromCharCode.apply(null, Array.from(u8.subarray(i, Math.min(i + CHUNK, u8.length))));
|
|
544
|
-
}
|
|
545
|
-
return btoa(s);
|
|
546
|
-
}
|
|
547
529
|
/**
|
|
548
530
|
* Top-level wrapper: builds a Python REPL adapter, drives a
|
|
549
531
|
* ReplSession to completion, returns the exit code.
|
|
@@ -8,18 +8,17 @@
|
|
|
8
8
|
* - exit code via sys.exit(N) or unhandled exception → 1
|
|
9
9
|
* - argv passed through to sys.argv
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* Current limits:
|
|
12
12
|
* - REPL mode (`python` with no args)
|
|
13
|
-
* -
|
|
14
|
-
* - `pip install` / `loadPackage` / native-extension packages
|
|
13
|
+
* - Native Linux wheels, runtime-loaded extension modules, and extension builds
|
|
15
14
|
* - Sync HTTP (urllib3 / requests blocked without JSPI)
|
|
16
15
|
*
|
|
17
16
|
* Architecture: SAME LOADER-modules transport as clang-runner/wasm-
|
|
18
17
|
* runner. The Pyodide wasm bytes ship via the LOADER `modules` map
|
|
19
18
|
* (CSP allows wasm code-gen at module-load time, not at request
|
|
20
|
-
* time). The Pyodide.asm.js
|
|
21
|
-
* `context` field (JSON-stringified into the inner worker.js
|
|
22
|
-
* module-load).
|
|
19
|
+
* time). The workerd-adapted Pyodide.asm.js artifact and stdlib zip ride via
|
|
20
|
+
* the loader-pool `context` field (JSON-stringified into the inner worker.js
|
|
21
|
+
* at module-load).
|
|
23
22
|
*
|
|
24
23
|
* Per wasm-csp/findings.md §4b: Pyodide.asm.wasm (10.1 MB on disk)
|
|
25
24
|
* compiles in 314 ms via LOADER on PROD. With our v1 deployment of
|
|
@@ -39,11 +38,11 @@ export declare function makePythonRunnerFactory(deps: {
|
|
|
39
38
|
vfs: SqliteVFS;
|
|
40
39
|
}): (manifest: RuntimeManifest, installRoot: string, binName: string, binKind: string | undefined) => (ctx: any) => Promise<number>;
|
|
41
40
|
/**
|
|
42
|
-
* Compose the per-call preamble by splicing the
|
|
43
|
-
*
|
|
41
|
+
* Compose the per-call preamble by splicing the workerd-adapted
|
|
42
|
+
* pyodide.asm.js source ahead of the __pyodideRun helper. Workerd compiles this
|
|
44
43
|
* blob as JS at module-load time (where `var` declarations + globals
|
|
45
44
|
* assignment are allowed), then the asm.js's `var _createPyodideModule`
|
|
46
45
|
* is hoisted onto globalThis.
|
|
47
46
|
*/
|
|
48
|
-
export declare function buildPyodidePreamble(asmJsSrc: string, stdlibB64: string): string;
|
|
47
|
+
export declare function buildPyodidePreamble(asmJsSrc: string, stdlibB64: string, lockfileContents?: string): string;
|
|
49
48
|
//# sourceMappingURL=python-runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"python-runner.d.ts","sourceRoot":"","sources":["../../src/runtime/python-runner.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"python-runner.d.ts","sourceRoot":"","sources":["../../src/runtime/python-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAsCzD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE;IAC5C,QAAQ,EAAE,YAAY,CAAC;IACvB,GAAG,EAAE,SAAS,CAAC;CAChB,GAAG,CAAC,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,KAC7F,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,CAgNhC;AAqzBD;;;;;;GAMG;AAKH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,SAAoB,GAAG,MAAM,CAyFtH"}
|