@nimbus-sh/core 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/runtime/bash-runner.d.ts +63 -0
- package/dist/runtime/bash-runner.d.ts.map +1 -0
- package/dist/runtime/bash-runner.generated.d.ts +14 -0
- package/dist/runtime/bash-runner.generated.d.ts.map +1 -0
- package/dist/runtime/bash-runner.generated.js +13 -0
- package/dist/runtime/bash-runner.js +290 -0
- package/dist/runtime/cpython-runner.d.ts +86 -0
- package/dist/runtime/cpython-runner.d.ts.map +1 -0
- package/dist/runtime/cpython-runner.js +425 -0
- package/dist/runtime/facet-host.d.ts +159 -0
- package/dist/runtime/facet-host.d.ts.map +1 -0
- package/dist/runtime/facet-host.js +22 -0
- package/dist/runtime/installed-runtimes.d.ts +99 -0
- package/dist/runtime/installed-runtimes.d.ts.map +1 -0
- package/dist/runtime/installed-runtimes.js +162 -0
- package/dist/runtime/local-facet-host.d.ts +38 -0
- package/dist/runtime/local-facet-host.d.ts.map +1 -0
- package/dist/runtime/local-facet-host.js +171 -0
- package/dist/runtime/python-pip.d.ts +38 -0
- package/dist/runtime/python-pip.d.ts.map +1 -0
- package/dist/runtime/python-pip.js +1063 -0
- package/dist/runtime/runtime-manifest.d.ts +86 -0
- package/dist/runtime/runtime-manifest.d.ts.map +1 -0
- package/dist/runtime/runtime-manifest.js +72 -0
- package/dist/runtime/runtime-registry.d.ts +161 -0
- package/dist/runtime/runtime-registry.d.ts.map +1 -0
- package/dist/runtime/runtime-registry.js +363 -0
- package/dist/runtime/vfs-snapshot.d.ts.map +1 -1
- package/dist/runtime/vfs-snapshot.js +15 -1
- package/dist/runtime/vfs-supervisor.d.ts +22 -0
- package/dist/runtime/vfs-supervisor.d.ts.map +1 -0
- package/dist/runtime/vfs-supervisor.js +65 -0
- package/dist/runtime/virtual-socket-kernel.generated.d.ts +14 -0
- package/dist/runtime/virtual-socket-kernel.generated.d.ts.map +1 -0
- package/dist/runtime/virtual-socket-kernel.generated.js +13 -0
- package/dist/runtime/wasm-runner.d.ts +80 -0
- package/dist/runtime/wasm-runner.d.ts.map +1 -0
- package/dist/runtime/wasm-runner.js +686 -0
- package/dist/workspace/nimbus-workspace.d.ts +16 -0
- package/dist/workspace/nimbus-workspace.d.ts.map +1 -1
- package/dist/workspace/nimbus-workspace.js +57 -2
- package/package.json +4 -2
- package/src/index.ts +9 -0
- package/src/runtime/bash-runner.generated.ts +14 -0
- package/src/runtime/bash-runner.ts +347 -0
- package/src/runtime/cpython-runner.ts +504 -0
- package/src/runtime/facet-host.ts +170 -0
- package/src/runtime/installed-runtimes.ts +235 -0
- package/src/runtime/local-facet-host.ts +205 -0
- package/src/runtime/python-pip.ts +1211 -0
- package/src/runtime/runtime-manifest.ts +155 -0
- package/src/runtime/runtime-registry.ts +510 -0
- package/src/runtime/vfs-snapshot.ts +15 -1
- package/src/runtime/vfs-supervisor.ts +67 -0
- package/src/runtime/virtual-socket-kernel.generated.ts +14 -0
- package/src/runtime/wasm-runner.ts +835 -0
- package/src/workspace/nimbus-workspace.ts +102 -3
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* runtime-manifest.ts — what an installed language runtime IS.
|
|
3
|
+
*
|
|
4
|
+
* A manifest names the files a runtime is made of, the shell commands it
|
|
5
|
+
* provides, and the runner that answers them. `nimbus install <name>` writes
|
|
6
|
+
* one into `~/.nimbus/runtimes/<name>/<version>/manifest.json`; every runner
|
|
7
|
+
* reads its own out of the session filesystem from there.
|
|
8
|
+
*
|
|
9
|
+
* The data contract only. Where the bytes come FROM is the publisher's
|
|
10
|
+
* problem, and the Cloudflare deployment's answer to it — an R2 bucket, a
|
|
11
|
+
* per-colo cache, and a digest chain rooted at a build-time pin — lives in
|
|
12
|
+
* `@nimbus-sh/worker`'s `runtime/runtime-catalog.ts`. A runtime that has been
|
|
13
|
+
* installed is the same runtime whichever tier fetched it, so nothing below
|
|
14
|
+
* this point knows there were tiers.
|
|
15
|
+
*/
|
|
16
|
+
import { z } from 'zod/v4';
|
|
17
|
+
import { PYODIDE_PACKAGE_ABI } from './os-contracts.js';
|
|
18
|
+
export interface ManifestFile {
|
|
19
|
+
/** VFS path relative to ~/.nimbus/runtimes/<name>/<version>/. */
|
|
20
|
+
path: string;
|
|
21
|
+
/** Publisher-side key for the content blob. */
|
|
22
|
+
content: string;
|
|
23
|
+
/** Hex sha256 of the content blob bytes. */
|
|
24
|
+
sha256: string;
|
|
25
|
+
/** Byte size. */
|
|
26
|
+
size: number;
|
|
27
|
+
/** Optional file mode hint ("exec" → registered as a shell bin). */
|
|
28
|
+
mode?: 'exec';
|
|
29
|
+
}
|
|
30
|
+
export interface ManifestEntrypoint {
|
|
31
|
+
/** Shell command name. */
|
|
32
|
+
binName: string;
|
|
33
|
+
/** Runner key (e.g. "clang-runner") — package manager dispatches to
|
|
34
|
+
* the right runner factory by this. */
|
|
35
|
+
runner: string;
|
|
36
|
+
/** Default args prepended to user args at invocation. */
|
|
37
|
+
args: string[];
|
|
38
|
+
/** Optional secondary classification (e.g. "linker" for wasm-ld). */
|
|
39
|
+
kind?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface RuntimeArtifactMetadata {
|
|
42
|
+
path: string;
|
|
43
|
+
kind: string;
|
|
44
|
+
id: string;
|
|
45
|
+
source_sha256?: string;
|
|
46
|
+
sha256: string;
|
|
47
|
+
}
|
|
48
|
+
export type RuntimePythonPackageAbi = typeof PYODIDE_PACKAGE_ABI;
|
|
49
|
+
export interface RuntimePythonExtensionModuleMetadata {
|
|
50
|
+
/** Path inside Python site-packages, as stored in the wheel. */
|
|
51
|
+
path: string;
|
|
52
|
+
/** Path inside the installed Nimbus runtime root. */
|
|
53
|
+
runtimePath: string;
|
|
54
|
+
sha256: string;
|
|
55
|
+
}
|
|
56
|
+
export interface RuntimePythonPackageArtifactMetadata extends RuntimeArtifactMetadata {
|
|
57
|
+
kind: 'python-package';
|
|
58
|
+
language: 'python';
|
|
59
|
+
packageName: string;
|
|
60
|
+
version: string;
|
|
61
|
+
abi: RuntimePythonPackageAbi;
|
|
62
|
+
pyodideVersion: string;
|
|
63
|
+
pythonVersion: string;
|
|
64
|
+
wheelFileName: string;
|
|
65
|
+
wheelSha256: string;
|
|
66
|
+
loadMode: 'startup-module';
|
|
67
|
+
imports: string[];
|
|
68
|
+
dependencies: string[];
|
|
69
|
+
extensionModules: RuntimePythonExtensionModuleMetadata[];
|
|
70
|
+
}
|
|
71
|
+
export interface RuntimeManifest {
|
|
72
|
+
name: string;
|
|
73
|
+
version: string;
|
|
74
|
+
license: string;
|
|
75
|
+
/** Which WASI namespace the binaries import — `wasi_unstable` for
|
|
76
|
+
* binji clang. `null` for non-WASI runtimes (e.g. Pyodide). */
|
|
77
|
+
wasi_namespace: string | null;
|
|
78
|
+
files: ManifestFile[];
|
|
79
|
+
entrypoints: ManifestEntrypoint[];
|
|
80
|
+
runtime_artifacts?: RuntimeArtifactMetadata[];
|
|
81
|
+
}
|
|
82
|
+
export declare const HexSha256Schema: z.ZodString;
|
|
83
|
+
export declare const RuntimePythonPackageArtifactMetadataSchema: z.ZodType<RuntimePythonPackageArtifactMetadata>;
|
|
84
|
+
export declare function parseRuntimeManifest(value: unknown): RuntimeManifest;
|
|
85
|
+
export declare function isRuntimePythonPackageArtifactMetadata(artifact: RuntimeArtifactMetadata): artifact is RuntimePythonPackageArtifactMetadata;
|
|
86
|
+
//# sourceMappingURL=runtime-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-manifest.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEx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MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,oCAAoC,EAAE,CAAC;CAC1D;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB;oEACgE;IAChE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAClC,iBAAiB,CAAC,EAAE,uBAAuB,EAAE,CAAC;CAC/C;AAED,eAAO,MAAM,eAAe,aAAqC,CAAC;AAyBlE,eAAO,MAAM,0CAA0C,EAAE,CAAC,CAAC,OAAO,CAAC,oCAAoC,CAmBlG,CAAC;AAYN,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAEpE;AAED,wBAAgB,sCAAsC,CACpD,QAAQ,EAAE,uBAAuB,GAChC,QAAQ,IAAI,oCAAoC,CAElD"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* runtime-manifest.ts — what an installed language runtime IS.
|
|
3
|
+
*
|
|
4
|
+
* A manifest names the files a runtime is made of, the shell commands it
|
|
5
|
+
* provides, and the runner that answers them. `nimbus install <name>` writes
|
|
6
|
+
* one into `~/.nimbus/runtimes/<name>/<version>/manifest.json`; every runner
|
|
7
|
+
* reads its own out of the session filesystem from there.
|
|
8
|
+
*
|
|
9
|
+
* The data contract only. Where the bytes come FROM is the publisher's
|
|
10
|
+
* problem, and the Cloudflare deployment's answer to it — an R2 bucket, a
|
|
11
|
+
* per-colo cache, and a digest chain rooted at a build-time pin — lives in
|
|
12
|
+
* `@nimbus-sh/worker`'s `runtime/runtime-catalog.ts`. A runtime that has been
|
|
13
|
+
* installed is the same runtime whichever tier fetched it, so nothing below
|
|
14
|
+
* this point knows there were tiers.
|
|
15
|
+
*/
|
|
16
|
+
import { z } from 'zod/v4';
|
|
17
|
+
import { PYODIDE_PACKAGE_ABI } from './os-contracts.js';
|
|
18
|
+
export const HexSha256Schema = z.string().regex(/^[a-f0-9]{64}$/);
|
|
19
|
+
const ManifestFileSchema = z.object({
|
|
20
|
+
path: z.string().min(1),
|
|
21
|
+
content: z.string().min(1),
|
|
22
|
+
sha256: HexSha256Schema,
|
|
23
|
+
size: z.number().int().nonnegative(),
|
|
24
|
+
mode: z.literal('exec').optional(),
|
|
25
|
+
});
|
|
26
|
+
const ManifestEntrypointSchema = z.object({
|
|
27
|
+
binName: z.string().min(1),
|
|
28
|
+
runner: z.string().min(1),
|
|
29
|
+
args: z.array(z.string()),
|
|
30
|
+
kind: z.string().optional(),
|
|
31
|
+
});
|
|
32
|
+
const RuntimeArtifactMetadataSchema = z.object({
|
|
33
|
+
path: z.string().min(1),
|
|
34
|
+
kind: z.string().min(1),
|
|
35
|
+
id: z.string().min(1),
|
|
36
|
+
source_sha256: HexSha256Schema.optional(),
|
|
37
|
+
sha256: HexSha256Schema,
|
|
38
|
+
}).passthrough();
|
|
39
|
+
export const RuntimePythonPackageArtifactMetadataSchema = RuntimeArtifactMetadataSchema.and(z.object({
|
|
40
|
+
kind: z.literal('python-package'),
|
|
41
|
+
language: z.literal('python'),
|
|
42
|
+
packageName: z.string().min(1),
|
|
43
|
+
version: z.string().min(1),
|
|
44
|
+
abi: z.literal(PYODIDE_PACKAGE_ABI),
|
|
45
|
+
pyodideVersion: z.string().min(1),
|
|
46
|
+
pythonVersion: z.string().min(1),
|
|
47
|
+
wheelFileName: z.string().min(1),
|
|
48
|
+
wheelSha256: HexSha256Schema,
|
|
49
|
+
loadMode: z.literal('startup-module'),
|
|
50
|
+
imports: z.array(z.string()),
|
|
51
|
+
dependencies: z.array(z.string()),
|
|
52
|
+
extensionModules: z.array(z.object({
|
|
53
|
+
path: z.string().min(1),
|
|
54
|
+
runtimePath: z.string().min(1),
|
|
55
|
+
sha256: HexSha256Schema,
|
|
56
|
+
})),
|
|
57
|
+
}));
|
|
58
|
+
const RuntimeManifestSchema = z.object({
|
|
59
|
+
name: z.string().min(1),
|
|
60
|
+
version: z.string().min(1),
|
|
61
|
+
license: z.string(),
|
|
62
|
+
wasi_namespace: z.string().nullable(),
|
|
63
|
+
files: z.array(ManifestFileSchema),
|
|
64
|
+
entrypoints: z.array(ManifestEntrypointSchema),
|
|
65
|
+
runtime_artifacts: z.array(RuntimeArtifactMetadataSchema).optional(),
|
|
66
|
+
});
|
|
67
|
+
export function parseRuntimeManifest(value) {
|
|
68
|
+
return RuntimeManifestSchema.parse(value);
|
|
69
|
+
}
|
|
70
|
+
export function isRuntimePythonPackageArtifactMetadata(artifact) {
|
|
71
|
+
return RuntimePythonPackageArtifactMetadataSchema.safeParse(artifact).success;
|
|
72
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* runtime-registry.ts — shared shell-command factory for runtime
|
|
3
|
+
* dispatchers (node, bun, and future native-WASM / Python / Ruby /
|
|
4
|
+
* AssemblyScript runtimes).
|
|
5
|
+
*
|
|
6
|
+
* Why this exists
|
|
7
|
+
* ───────────────
|
|
8
|
+
* `node` and `bun` shell-command handlers in src/session/init.ts
|
|
9
|
+
* shared ~85% of their code: argv parsing for --version / --help /
|
|
10
|
+
* -e / script-path, VFS lookup, shebang strip, esbuild transform for
|
|
11
|
+
* .ts/.tsx/.jsx, dispatch to the runner. The duplication had drifted
|
|
12
|
+
* — only `node` had the primitive #1 nodeFlagSpan fix
|
|
13
|
+
* (init.ts:233-243), only `node` had primitive-#2 binSpawn ctx
|
|
14
|
+
* propagation (init.ts:391-403), only `bun` had install / run
|
|
15
|
+
* subcommand routing.
|
|
16
|
+
*
|
|
17
|
+
* `buildRuntimeHandler` returns a single shell-handler function that
|
|
18
|
+
* encodes the shared contract. Per-runtime variation is supplied
|
|
19
|
+
* via the `RuntimeSpec` parameter:
|
|
20
|
+
*
|
|
21
|
+
* - name + version + helpText
|
|
22
|
+
* - run(): runner fn (runFresh / runBunScript / wasm-runner)
|
|
23
|
+
* - subcommands: optional map of `<verb> → handler` for
|
|
24
|
+
* bun-style `bun install`, `bun run` (node has none today)
|
|
25
|
+
* - transform(): optional code rewriter (bun prepends BUN_SHIM_PREAMBLE)
|
|
26
|
+
* - supportsBinSpawn: true for node (the .bin handler propagates
|
|
27
|
+
* a callerPid); other runtimes use a plain spawn flow.
|
|
28
|
+
*
|
|
29
|
+
* Anti-requirements observed
|
|
30
|
+
* ──────────────────────────
|
|
31
|
+
* - NO setTimeout / NO retry / NO defensive-catch added.
|
|
32
|
+
* - NO behavioral change vs the pre-refactor handlers — every
|
|
33
|
+
* runtime-specific quirk is preserved exactly.
|
|
34
|
+
* - Per-runtime test parity: existing runtime-primitives probes
|
|
35
|
+
* (#1 npx / #2 .bin) and runtime-pkg probes (G1-G4) MUST still
|
|
36
|
+
* pass against the refactored handlers — the contract is
|
|
37
|
+
* observable behaviour, not implementation shape.
|
|
38
|
+
*/
|
|
39
|
+
import type { SqliteVFS } from '../vfs/sqlite-vfs.js';
|
|
40
|
+
import { type VfsCred } from './os-contracts.js';
|
|
41
|
+
import type { EsbuildService } from './esbuild-service.js';
|
|
42
|
+
import { type FacetBundleProfile } from './bundle-profile.js';
|
|
43
|
+
/**
|
|
44
|
+
* Result shape that runtime-registry expects from a runner. Mirrors
|
|
45
|
+
* the existing RunFreshResult / RunBunResult shapes — kept narrow so
|
|
46
|
+
* future runtimes don't have to plumb runtime-internal state.
|
|
47
|
+
*/
|
|
48
|
+
export interface RuntimeRunResult {
|
|
49
|
+
exitCode: number;
|
|
50
|
+
stdout: string;
|
|
51
|
+
stderr: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Options the handler passes to the runner. Mirrors RunFreshOpts.
|
|
55
|
+
*/
|
|
56
|
+
export interface RuntimeRunOpts {
|
|
57
|
+
argv: string[];
|
|
58
|
+
env: Record<string, string> | undefined;
|
|
59
|
+
cwd: string | undefined;
|
|
60
|
+
filename: string;
|
|
61
|
+
dirname: string;
|
|
62
|
+
command: string;
|
|
63
|
+
/** Primitive #1/G4 hooks. node-runner consumes these; other
|
|
64
|
+
* runtimes ignore them safely. */
|
|
65
|
+
skipSpawn?: boolean;
|
|
66
|
+
callerPid?: number;
|
|
67
|
+
/** Capture stdout/stderr in the result instead of streaming to the
|
|
68
|
+
* terminal supervisor. Used by child_process pipe semantics. */
|
|
69
|
+
captureOutput?: boolean;
|
|
70
|
+
forceLongRunning?: boolean;
|
|
71
|
+
attachedTty?: boolean;
|
|
72
|
+
bundleProfile?: FacetBundleProfile;
|
|
73
|
+
/** Invoking process credentials for credential-bound runtime snapshots. */
|
|
74
|
+
cred?: VfsCred;
|
|
75
|
+
}
|
|
76
|
+
/** The VFS surface script resolution needs. */
|
|
77
|
+
export interface ScriptResolutionFs {
|
|
78
|
+
isFile(path: string): boolean;
|
|
79
|
+
readFileString(path: string): string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Resolve a runtime target — `./cli.ts`, `sub/x`, `.`, or a bare name — to a
|
|
83
|
+
* canonical VFS key, or null when nothing runnable sits there.
|
|
84
|
+
*
|
|
85
|
+
* A directory never resolves to itself: it falls through to the index
|
|
86
|
+
* candidates, so `bun ./tools` finds `tools/index.js` the way real bun does
|
|
87
|
+
* rather than trying to read the directory as source.
|
|
88
|
+
*/
|
|
89
|
+
export declare function resolveRuntimeScriptPath(fs: ScriptResolutionFs, cwd: string, target: string, opts?: {
|
|
90
|
+
preferModuleField?: boolean;
|
|
91
|
+
}): string | null;
|
|
92
|
+
/**
|
|
93
|
+
* A subcommand handler. `runAsRuntime` re-enters the standard flow — flag
|
|
94
|
+
* span, script resolution, transform, exec — with a rewritten argv, as if
|
|
95
|
+
* the verb had never been typed. `bun run <file>` uses it to hand a path
|
|
96
|
+
* to the very same execution path `bun <file>` takes, rather than growing
|
|
97
|
+
* a second one.
|
|
98
|
+
*/
|
|
99
|
+
export type RuntimeSubcommand = (ctx: any, registry: ShellRegistry, runAsRuntime: (args: string[]) => Promise<number>) => Promise<number>;
|
|
100
|
+
export interface RuntimeSpec {
|
|
101
|
+
/** Shell-command name: 'node' / 'bun' / 'wasm-runner' / 'python'. */
|
|
102
|
+
name: string;
|
|
103
|
+
/** Output of `<name> --version`. Includes the leading 'v' if the
|
|
104
|
+
* runtime convention does (Node: 'v20.0.0'; Bun: '1.1.42'). */
|
|
105
|
+
version: string;
|
|
106
|
+
/** Multi-line help text for `<name> --help`. */
|
|
107
|
+
helpText: string;
|
|
108
|
+
/**
|
|
109
|
+
* Runner function. Closes over whatever substrate the runtime executes on —
|
|
110
|
+
* a FacetManager for node and bun, a {@link ./facet-host.js FacetHost} for
|
|
111
|
+
* wasm-runner — because this factory never inspects it. It used to travel
|
|
112
|
+
* through here as a first parameter, which is the only thing that tied the
|
|
113
|
+
* shared handler to a Durable Object.
|
|
114
|
+
*/
|
|
115
|
+
run(code: string, opts: RuntimeRunOpts): Promise<RuntimeRunResult>;
|
|
116
|
+
/**
|
|
117
|
+
* Subcommand router. When the first positional arg is a key in
|
|
118
|
+
* this map, the handler is invoked instead of the standard
|
|
119
|
+
* script-execution flow. Used by `bun install`, `bun run <script>`.
|
|
120
|
+
*/
|
|
121
|
+
subcommands?: Record<string, RuntimeSubcommand>;
|
|
122
|
+
/**
|
|
123
|
+
* When true, the runtime treats the args list as a binary file
|
|
124
|
+
* path (NOT a JS script). Used by `wasm-runner` — the args[0] is a
|
|
125
|
+
* .wasm path, args[1+] are the function name + integer args.
|
|
126
|
+
* The handler skips the read-and-transform-script flow and calls
|
|
127
|
+
* `run()` with a synthetic empty `code` — runtimes that set this
|
|
128
|
+
* flag implement the actual bytes-load inside their runner.
|
|
129
|
+
*/
|
|
130
|
+
bypassesScriptRead?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Primitive #1 / G4 — when true, the script-execution branch
|
|
133
|
+
* propagates `ctx.__nimbusBinSpawn` into RuntimeRunOpts. Only
|
|
134
|
+
* `node` enables this; bun's runFresh chain doesn't share PID
|
|
135
|
+
* state with the .bin handler today. Future runtimes set this
|
|
136
|
+
* iff they share the runFresh contract.
|
|
137
|
+
*/
|
|
138
|
+
supportsBinSpawn?: boolean;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Minimal registry shape we depend on. Avoids importing the full vendored
|
|
142
|
+
* shell registry type tree when the runtime path only needs resolve().
|
|
143
|
+
*/
|
|
144
|
+
export interface ShellRegistry {
|
|
145
|
+
resolve(name: string): Promise<any> | any;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Build a shell-handler function for a runtime. The returned function
|
|
149
|
+
* is the value passed to `registry.register('<name>', handler)`.
|
|
150
|
+
*
|
|
151
|
+
* Captures `vfs`, `getEsbuild` (for lazy init) + the spec. The same factory is used for every runtime; the only
|
|
152
|
+
* runtime-specific code lives in `spec`.
|
|
153
|
+
*/
|
|
154
|
+
export declare function buildRuntimeHandler(spec: RuntimeSpec, ctx0: {
|
|
155
|
+
vfs: SqliteVFS;
|
|
156
|
+
/** Lazy esbuild initialiser. Called once per first .ts/.tsx/.jsx
|
|
157
|
+
* invocation — the host owns the init lifecycle. */
|
|
158
|
+
getEsbuild(): EsbuildService;
|
|
159
|
+
registry: ShellRegistry;
|
|
160
|
+
}): (ctx: any) => Promise<number>;
|
|
161
|
+
//# sourceMappingURL=runtime-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-registry.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAe,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,E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