@nimbus-sh/worker 0.2.0 → 0.2.1

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.
Files changed (63) hide show
  1. package/dist/facets/manager.d.ts +47 -2
  2. package/dist/facets/manager.d.ts.map +1 -1
  3. package/dist/facets/manager.js +139 -15
  4. package/dist/runtime/bash-repl.d.ts +1 -1
  5. package/dist/runtime/bash-repl.d.ts.map +1 -1
  6. package/dist/runtime/bash-repl.js +3 -2
  7. package/dist/runtime/clang-runner.d.ts +1 -1
  8. package/dist/runtime/clang-runner.d.ts.map +1 -1
  9. package/dist/runtime/cpython-resident.d.ts +27 -0
  10. package/dist/runtime/cpython-resident.d.ts.map +1 -0
  11. package/dist/runtime/cpython-resident.js +133 -0
  12. package/dist/runtime/facet-loader-host.d.ts +15 -1
  13. package/dist/runtime/facet-loader-host.d.ts.map +1 -1
  14. package/dist/runtime/facet-loader-host.js +41 -0
  15. package/dist/runtime/package-manager.d.ts +3 -58
  16. package/dist/runtime/package-manager.d.ts.map +1 -1
  17. package/dist/runtime/package-manager.js +6 -143
  18. package/dist/runtime/python-repl.d.ts +1 -1
  19. package/dist/runtime/python-repl.d.ts.map +1 -1
  20. package/dist/runtime/python-repl.js +2 -2
  21. package/dist/runtime/ruby-runner.d.ts +1 -1
  22. package/dist/runtime/ruby-runner.d.ts.map +1 -1
  23. package/dist/runtime/ruby-runner.js +1 -1
  24. package/dist/runtime/runtime-catalog.d.ts +4 -80
  25. package/dist/runtime/runtime-catalog.d.ts.map +1 -1
  26. package/dist/runtime/runtime-catalog.js +4 -67
  27. package/dist/session/init.d.ts.map +1 -1
  28. package/dist/session/init.js +29 -41
  29. package/dist/session/keys.d.ts +13 -0
  30. package/dist/session/keys.d.ts.map +1 -1
  31. package/dist/session/keys.js +13 -0
  32. package/dist/session/nimbus-session.d.ts +19 -1
  33. package/dist/session/nimbus-session.d.ts.map +1 -1
  34. package/dist/session/nimbus-session.js +36 -1
  35. package/dist/session/programmatic.d.ts +2 -2
  36. package/dist/session/programmatic.d.ts.map +1 -1
  37. package/dist/session/programmatic.js +2 -1
  38. package/dist/session/supervisor-rpc.d.ts +6 -13
  39. package/dist/session/supervisor-rpc.d.ts.map +1 -1
  40. package/dist/session/supervisor-rpc.js +7 -17
  41. package/package.json +2 -2
  42. package/scripts/bundle-facet-workers.mjs +5 -5
  43. package/dist/runtime/bash-runner.d.ts +0 -63
  44. package/dist/runtime/bash-runner.d.ts.map +0 -1
  45. package/dist/runtime/bash-runner.generated.d.ts +0 -14
  46. package/dist/runtime/bash-runner.generated.d.ts.map +0 -1
  47. package/dist/runtime/bash-runner.generated.js +0 -13
  48. package/dist/runtime/bash-runner.js +0 -291
  49. package/dist/runtime/cpython-runner.d.ts +0 -71
  50. package/dist/runtime/cpython-runner.d.ts.map +0 -1
  51. package/dist/runtime/cpython-runner.js +0 -535
  52. package/dist/runtime/python-pip.d.ts +0 -38
  53. package/dist/runtime/python-pip.d.ts.map +0 -1
  54. package/dist/runtime/python-pip.js +0 -1063
  55. package/dist/runtime/runtime-registry.d.ts +0 -162
  56. package/dist/runtime/runtime-registry.d.ts.map +0 -1
  57. package/dist/runtime/runtime-registry.js +0 -364
  58. package/dist/runtime/virtual-socket-kernel.generated.d.ts +0 -14
  59. package/dist/runtime/virtual-socket-kernel.generated.d.ts.map +0 -1
  60. package/dist/runtime/virtual-socket-kernel.generated.js +0 -13
  61. package/dist/runtime/wasm-runner.d.ts +0 -70
  62. package/dist/runtime/wasm-runner.d.ts.map +0 -1
  63. package/dist/runtime/wasm-runner.js +0 -664
@@ -1,3 +1,39 @@
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
+ });
25
+ },
26
+ };
27
+ }
28
+ /**
29
+ * The two objects a NimbusLoaderPool needs from a FacetManager.
30
+ *
31
+ * FacetManager does not expose its `env` and `ctx` in its type, but a loader
32
+ * pool is constructed from exactly those, so every runtime that spawns facets
33
+ * needs the same reach-through. Reflect.get rather than a cast: the shape is
34
+ * checked here once, and a FacetManager built on something other than a
35
+ * DurableObjectState fails with a sentence instead of at the first RPC.
36
+ */
1
37
  export function getFacetManagerLoaderHost(facetMgr) {
2
38
  const env = Reflect.get(facetMgr, 'env');
3
39
  const ctx = Reflect.get(facetMgr, 'ctx');
@@ -6,6 +42,11 @@ export function getFacetManagerLoaderHost(facetMgr) {
6
42
  }
7
43
  return { env, ctx };
8
44
  }
45
+ /** The facet host a runtime reached through a FacetManager runs on. */
46
+ export function facetHostForManager(facetMgr) {
47
+ const { env, ctx } = getFacetManagerLoaderHost(facetMgr);
48
+ return loaderFacetHost(env, ctx);
49
+ }
9
50
  function isDurableObjectState(value) {
10
51
  if (typeof value !== 'object' || value === null)
11
52
  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, type RuntimeManifest, type ManifestEntrypoint } from './runtime-catalog.js';
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,EAAgE,KAAK,iBAAiB,EAAuB,KAAK,eAAe,EAAE,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAChM,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAA+E,KAAK,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC9J,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAEvF,wEAAwE;AACxE,MAAM,WAAW,QAAS,SAAQ,IAAI,CAAC,cAAc,EAAE,KAAK,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC;IAC3F,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE;QAAE,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IACnC,MAAM,EAAE;QAAE,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;CACpC;AAED,iDAAiD;AACjD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACrE,UAAU,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,OAAO,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;CAC7B;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAA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f,QAAQ,EAAE,gBAAgB,CAAC;IAC3B;+CAC2C;IAC3C,OAAO,IAAI,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,CAqBhC"}
@@ -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, parseRuntimeManifest } from './runtime-catalog.js';
29
- import { CRED_KERNEL, NIMBUS_ABI_TARGET, NIMBUS_RUNTIME_ABIS, NATIVE_UNSUPPORTED_ABI } from '@nimbus-sh/core/runtime/os-contracts.js';
30
- /** Map of runner-key → factory. Populated by init.ts before install. */
31
- const runnerFactories = {};
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 = runnerFactories[ep.runner];
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 './runtime-catalog.js';
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,sBAAsB,CAAC;AAoB5D,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"}
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 './python-pip.js';
24
- import { buildCPythonPreamble } from './cpython-runner.js';
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. */
@@ -33,7 +33,7 @@
33
33
  * ruby-init-loadpath, rb-eval-string-protect, cabi_realloc,
34
34
  * canonical_abi_drop_rb-abi-value, memory.
35
35
  */
36
- import type { RuntimeManifest } from './runtime-catalog.js';
36
+ import type { RuntimeManifest } from '@nimbus-sh/core/runtime/runtime-manifest.js';
37
37
  import type { SqliteVFS } from '@nimbus-sh/core/vfs/sqlite-vfs.js';
38
38
  import type { FacetManager } from '../facets/manager.js';
39
39
  import type { Command } from '@nimbus-sh/core/substrate/lifo/commands/types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"ruby-runner.d.ts","sourceRoot":"","sources":["../../src/runtime/ruby-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAkB,MAAM,kDAAkD,CAAC;AAwBhG,KAAK,iBAAiB,GAAG,CACvB,QAAQ,EAAE,eAAe,EACzB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GAAG,SAAS,KACxB,OAAO,CAAC;AAEb;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAC1C,QAAQ,EAAE,YAAY,CAAC;IACvB,GAAG,EAAE,SAAS,CAAC;IACf,QAAQ,CAAC,EAAE;QACT,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;QAC/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AI,GAAG,SAAS,CAAC;KAC1F,CAAC;CACH,GAAG,iBAAiB,CA8KpB;AAkcD,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAiLrE;AA6FD;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CA2B1C;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,0jjCAmqBrC,CAAC"}
@@ -40,7 +40,7 @@ import { CRED_KERNEL, requireVfsCred } from '@nimbus-sh/core/runtime/os-contract
40
40
  import { WASI_INSTANCE_PREAMBLE_SRC } from '@nimbus-sh/core/runtime/wasi-instance.js';
41
41
  import { manifestVfs } from '@nimbus-sh/core/runtime/vfs-manifest.js';
42
42
  import { resolveVfsPath } from '@nimbus-sh/core/vfs/path.js';
43
- import { VIRTUAL_SOCKET_KERNEL_SRC } from './virtual-socket-kernel.generated.js';
43
+ import { VIRTUAL_SOCKET_KERNEL_SRC } from '@nimbus-sh/core/runtime/virtual-socket-kernel.generated.js';
44
44
  import { RUBY_SOCKET_SHIM } from '@nimbus-sh/core/runtime/ruby-socket-shim.js';
45
45
  import { RUBY_GREEN_THREADS } from '@nimbus-sh/core/runtime/ruby-green-threads.js';
46
46
  import { defaultGemHome, installRubyBundle, installRubyGems, installedGemBins, installedGemLibRoots, parseRubyGemRequirements, } from './ruby-gems.js';
@@ -15,17 +15,9 @@
15
15
  * Catalog schema (RuntimeCatalog):
16
16
  * { version: 1, runtimes: { <name>: { default, versions: { <ver>: { manifest, manifest_sha256, size_bytes, license } } } } }
17
17
  *
18
- * Manifest schema (RuntimeManifest):
19
- * { name, version, license, wasi_namespace,
20
- * files: [{ path, content, sha256, size, mode? }],
21
- * entrypoints: [{ binName, runner, args[], kind? }],
22
- * runtime_artifacts?: [
23
- * { path, kind: "workerd-adapter", id, source_sha256?, sha256 },
24
- * { path, kind: "python-package", id, language: "python", packageName,
25
- * version, abi, pyodideVersion, pythonVersion, wheelFileName,
26
- * wheelSha256, loadMode: "startup-module", imports[], dependencies[],
27
- * extensionModules[] }
28
- * ] }
18
+ * Manifest schema: `@nimbus-sh/core` runtime/runtime-manifest.ts. What a
19
+ * runtime IS does not depend on which tier served it, so this module only
20
+ * fetches and verifies manifests; it does not describe them.
29
21
  *
30
22
  * R2 and Cache API failures throw; the shell verb formats the diagnostic for
31
23
  * the user.
@@ -53,8 +45,7 @@
53
45
  * that happens — there is no "trust the key instead" fallback. That also
54
46
  * makes a stale pin a cache miss rather than an outage.
55
47
  */
56
- import { z } from 'zod/v4';
57
- import { PYODIDE_PACKAGE_ABI } from '@nimbus-sh/core/runtime/os-contracts.js';
48
+ import { type ManifestFile, type RuntimeManifest } from '@nimbus-sh/core/runtime/runtime-manifest.js';
58
49
  /** Minimal R2Bucket shape we depend on. */
59
50
  type R2BucketLike = {
60
51
  get(key: string): Promise<{
@@ -82,74 +73,7 @@ export interface RuntimeCatalog {
82
73
  version: 1;
83
74
  runtimes: Record<string, CatalogRuntimeEntry>;
84
75
  }
85
- export interface ManifestFile {
86
- /** VFS path relative to ~/.nimbus/runtimes/<name>/<version>/. */
87
- path: string;
88
- /** R2 key for the content blob. */
89
- content: string;
90
- /** Hex sha256 of the content blob bytes. */
91
- sha256: string;
92
- /** Byte size. */
93
- size: number;
94
- /** Optional file mode hint ("exec" → registered as a shell bin). */
95
- mode?: 'exec';
96
- }
97
- export interface ManifestEntrypoint {
98
- /** Shell command name. */
99
- binName: string;
100
- /** Runner key (e.g. "clang-runner") — package manager dispatches to
101
- * the right runner factory by this. */
102
- runner: string;
103
- /** Default args prepended to user args at invocation. */
104
- args: string[];
105
- /** Optional secondary classification (e.g. "linker" for wasm-ld). */
106
- kind?: string;
107
- }
108
- export interface RuntimeArtifactMetadata {
109
- path: string;
110
- kind: string;
111
- id: string;
112
- source_sha256?: string;
113
- sha256: string;
114
- }
115
- export type RuntimePythonPackageAbi = typeof PYODIDE_PACKAGE_ABI;
116
- export interface RuntimePythonExtensionModuleMetadata {
117
- /** Path inside Python site-packages, as stored in the wheel. */
118
- path: string;
119
- /** Path inside the installed Nimbus runtime root. */
120
- runtimePath: string;
121
- sha256: string;
122
- }
123
- export interface RuntimePythonPackageArtifactMetadata extends RuntimeArtifactMetadata {
124
- kind: 'python-package';
125
- language: 'python';
126
- packageName: string;
127
- version: string;
128
- abi: RuntimePythonPackageAbi;
129
- pyodideVersion: string;
130
- pythonVersion: string;
131
- wheelFileName: string;
132
- wheelSha256: string;
133
- loadMode: 'startup-module';
134
- imports: string[];
135
- dependencies: string[];
136
- extensionModules: RuntimePythonExtensionModuleMetadata[];
137
- }
138
- export interface RuntimeManifest {
139
- name: string;
140
- version: string;
141
- license: string;
142
- /** Which WASI namespace the binaries import — `wasi_unstable` for
143
- * binji clang. `null` for non-WASI runtimes (e.g. Pyodide). */
144
- wasi_namespace: string | null;
145
- files: ManifestFile[];
146
- entrypoints: ManifestEntrypoint[];
147
- runtime_artifacts?: RuntimeArtifactMetadata[];
148
- }
149
- export declare const RuntimePythonPackageArtifactMetadataSchema: z.ZodType<RuntimePythonPackageArtifactMetadata>;
150
76
  export declare function parseRuntimeCatalog(value: unknown): RuntimeCatalog;
151
- export declare function parseRuntimeManifest(value: unknown): RuntimeManifest;
152
- export declare function isRuntimePythonPackageArtifactMetadata(artifact: RuntimeArtifactMetadata): artifact is RuntimePythonPackageArtifactMetadata;
153
77
  /**
154
78
  * Fetch the top-level catalog, verified against the build-time pin.
155
79
  *
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-catalog.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAG3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E,2CAA2C;AAC3C,KAAK,YAAY,GAAG;IAClB,GAAG,CAAC,GAAG,E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IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,CAAC,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;CAC/C;AAiBD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAElE;AA4DD;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CAuBlF;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,iBAAiB,EACtB,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,eAAe,CAAC,CA8B1B;AAED;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAC7B,GAAG,EAAE,iBAAiB,EACtB,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,UAAU,CAAC,CA4BrB"}
@@ -15,17 +15,9 @@
15
15
  * Catalog schema (RuntimeCatalog):
16
16
  * { version: 1, runtimes: { <name>: { default, versions: { <ver>: { manifest, manifest_sha256, size_bytes, license } } } } }
17
17
  *
18
- * Manifest schema (RuntimeManifest):
19
- * { name, version, license, wasi_namespace,
20
- * files: [{ path, content, sha256, size, mode? }],
21
- * entrypoints: [{ binName, runner, args[], kind? }],
22
- * runtime_artifacts?: [
23
- * { path, kind: "workerd-adapter", id, source_sha256?, sha256 },
24
- * { path, kind: "python-package", id, language: "python", packageName,
25
- * version, abi, pyodideVersion, pythonVersion, wheelFileName,
26
- * wheelSha256, loadMode: "startup-module", imports[], dependencies[],
27
- * extensionModules[] }
28
- * ] }
18
+ * Manifest schema: `@nimbus-sh/core` runtime/runtime-manifest.ts. What a
19
+ * runtime IS does not depend on which tier served it, so this module only
20
+ * fetches and verifies manifests; it does not describe them.
29
21
  *
30
22
  * R2 and Cache API failures throw; the shell verb formats the diagnostic for
31
23
  * the user.
@@ -56,8 +48,7 @@
56
48
  import { z } from 'zod/v4';
57
49
  import { sha256Hex } from '@nimbus-sh/core/_shared/crypto.js';
58
50
  import { RUNTIME_CATALOG_SHA256 } from '../runtime-catalog.generated.js';
59
- import { PYODIDE_PACKAGE_ABI } from '@nimbus-sh/core/runtime/os-contracts.js';
60
- const HexSha256Schema = z.string().regex(/^[a-f0-9]{64}$/);
51
+ import { HexSha256Schema, parseRuntimeManifest, } from '@nimbus-sh/core/runtime/runtime-manifest.js';
61
52
  const CatalogVersionEntrySchema = z.object({
62
53
  manifest: z.string().min(1),
63
54
  manifest_sha256: HexSha256Schema.optional(),
@@ -71,63 +62,9 @@ const RuntimeCatalogSchema = z.object({
71
62
  versions: z.record(z.string(), CatalogVersionEntrySchema),
72
63
  })),
73
64
  });
74
- const ManifestFileSchema = z.object({
75
- path: z.string().min(1),
76
- content: z.string().min(1),
77
- sha256: HexSha256Schema,
78
- size: z.number().int().nonnegative(),
79
- mode: z.literal('exec').optional(),
80
- });
81
- const ManifestEntrypointSchema = z.object({
82
- binName: z.string().min(1),
83
- runner: z.string().min(1),
84
- args: z.array(z.string()),
85
- kind: z.string().optional(),
86
- });
87
- const RuntimeArtifactMetadataSchema = z.object({
88
- path: z.string().min(1),
89
- kind: z.string().min(1),
90
- id: z.string().min(1),
91
- source_sha256: HexSha256Schema.optional(),
92
- sha256: HexSha256Schema,
93
- }).passthrough();
94
- export const RuntimePythonPackageArtifactMetadataSchema = RuntimeArtifactMetadataSchema.and(z.object({
95
- kind: z.literal('python-package'),
96
- language: z.literal('python'),
97
- packageName: z.string().min(1),
98
- version: z.string().min(1),
99
- abi: z.literal(PYODIDE_PACKAGE_ABI),
100
- pyodideVersion: z.string().min(1),
101
- pythonVersion: z.string().min(1),
102
- wheelFileName: z.string().min(1),
103
- wheelSha256: HexSha256Schema,
104
- loadMode: z.literal('startup-module'),
105
- imports: z.array(z.string()),
106
- dependencies: z.array(z.string()),
107
- extensionModules: z.array(z.object({
108
- path: z.string().min(1),
109
- runtimePath: z.string().min(1),
110
- sha256: HexSha256Schema,
111
- })),
112
- }));
113
- const RuntimeManifestSchema = z.object({
114
- name: z.string().min(1),
115
- version: z.string().min(1),
116
- license: z.string(),
117
- wasi_namespace: z.string().nullable(),
118
- files: z.array(ManifestFileSchema),
119
- entrypoints: z.array(ManifestEntrypointSchema),
120
- runtime_artifacts: z.array(RuntimeArtifactMetadataSchema).optional(),
121
- });
122
65
  export function parseRuntimeCatalog(value) {
123
66
  return RuntimeCatalogSchema.parse(value);
124
67
  }
125
- export function parseRuntimeManifest(value) {
126
- return RuntimeManifestSchema.parse(value);
127
- }
128
- export function isRuntimePythonPackageArtifactMetadata(artifact) {
129
- return RuntimePythonPackageArtifactMetadataSchema.safeParse(artifact).success;
130
- }
131
68
  // ── L2 content addressing ────────────────────────────────────────────
132
69
  /** R2 key of the top-level catalog. */
133
70
  const CATALOG_R2_KEY = 'catalog/v1.json';
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/session/init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAkFH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;;;GAQG;AACH,KAAK,QAAQ,GAAG,eAAe,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA;CAAE,CAAC;AAa3E,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,GAAG,IAAI,CAivF/D"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/session/init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAoFH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;;;GAQG;AACH,KAAK,QAAQ,GAAG,eAAe,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA;CAAE,CAAC;AAa3E,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,GAAG,IAAI,CAguF/D"}