@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,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wasm-runner.ts — native-WASM runner over the facet host.
|
|
3
|
+
*
|
|
4
|
+
* The runner never compiles the user's bytes itself: it hands them to a facet
|
|
5
|
+
* ({@link ./facet-host.js}) as `user.wasm` and reads the compiled
|
|
6
|
+
* `WebAssembly.Module` back off `globalThis.__NIMBUS_WASM['user.wasm']`. On
|
|
7
|
+
* workerd that indirection is not stylistic — direct
|
|
8
|
+
* `WebAssembly.instantiate(bytes)` is refused by CSP at request time in both
|
|
9
|
+
* the supervisor and facet isolates, and the modules map is the one path where
|
|
10
|
+
* the compile happens during module load, which is permitted.
|
|
11
|
+
*
|
|
12
|
+
* Shell command shape
|
|
13
|
+
* ───────────────────
|
|
14
|
+
*
|
|
15
|
+
* wasm-runner --version
|
|
16
|
+
* wasm-runner <file.wasm> <exportName> [int args...]
|
|
17
|
+
*
|
|
18
|
+
* Each invocation:
|
|
19
|
+
* 1. Reads bytes from VFS (or any caller-supplied source).
|
|
20
|
+
* 2. Allocates a PID via the process supervisor (Process tab integration).
|
|
21
|
+
* 3. Facet.submit() with wasmModules: { 'user.wasm': bytes } — the
|
|
22
|
+
* host compiles the image and publishes it on the facet's
|
|
23
|
+
* `globalThis.__NIMBUS_WASM`.
|
|
24
|
+
* 4. The submitted fn runs inside the inner facet:
|
|
25
|
+
* - reads globalThis.__NIMBUS_WASM['user.wasm'] (the precompiled
|
|
26
|
+
* Module the facet host registered)
|
|
27
|
+
* - WebAssembly.instantiate(module, {}) — allowed because the
|
|
28
|
+
* Module is precompiled
|
|
29
|
+
* - looks up the export, calls with parsed integer args, returns
|
|
30
|
+
* the result + the export list
|
|
31
|
+
* 5. Supervisor formats and writes stdout/stderr; exit code 0/1.
|
|
32
|
+
*
|
|
33
|
+
* Limitations (documented in --help):
|
|
34
|
+
* - Function args are integers only (parseInt). Float / string /
|
|
35
|
+
* multi-arg-shapes need a wrapper module.
|
|
36
|
+
* - Only WebAssembly.Memory and integer return values are surfaced.
|
|
37
|
+
* - WASI imports are NOT provided. Modules expecting wasi_snapshot
|
|
38
|
+
* won't instantiate (fail at the in-facet instantiate step).
|
|
39
|
+
*
|
|
40
|
+
* Dispatch constraints
|
|
41
|
+
* ────────────────────
|
|
42
|
+
* - No sleeps, caller-side retries, or catch-and-continue around facet
|
|
43
|
+
* failures. The host owns retry behavior.
|
|
44
|
+
* - The try/catch around vfs.readFile is a legitimate I/O boundary;
|
|
45
|
+
* the diagnostic propagates as exitCode 1 + stderr line.
|
|
46
|
+
* - NO direct WebAssembly.instantiate(bytes) at request time — workerd
|
|
47
|
+
* CSP rejects that path, and the facet host exists to make it moot.
|
|
48
|
+
*/
|
|
49
|
+
import type { RuntimeRunOpts, RuntimeRunResult, RuntimeSpec } from './runtime-registry.js';
|
|
50
|
+
import type { FacetHost } from './facet-host.js';
|
|
51
|
+
import type { SessionProcessSupervisor } from './session-process-supervisor.js';
|
|
52
|
+
import type { SqliteVFS } from '../vfs/sqlite-vfs.js';
|
|
53
|
+
export declare const WASM_RUNNER_VERSION = "0.3.0";
|
|
54
|
+
export declare const WASM_RUNNER_HELP: string;
|
|
55
|
+
export declare function formatWasmRunnerWasiInfo(): string;
|
|
56
|
+
/**
|
|
57
|
+
* Build a `run` function suitable for RuntimeSpec.run(). Parameterised
|
|
58
|
+
* over the VFS, the facet host the module is compiled and run on, and the
|
|
59
|
+
* session process supervisor (for `ps` / `logs <pid>` / Process tab
|
|
60
|
+
* integration). Returns a fn that matches the runtime-registry's contract.
|
|
61
|
+
*/
|
|
62
|
+
export declare function makeWasmRunner(deps: {
|
|
63
|
+
vfs: SqliteVFS;
|
|
64
|
+
facets: FacetHost;
|
|
65
|
+
processes: SessionProcessSupervisor;
|
|
66
|
+
}): (_code: string, opts: RuntimeRunOpts) => Promise<RuntimeRunResult>;
|
|
67
|
+
/**
|
|
68
|
+
* The `wasm-runner` command, whole.
|
|
69
|
+
*
|
|
70
|
+
* Its name, its version, its help and its `--wasi-info` verb belong to the
|
|
71
|
+
* runner, not to whoever registers it. Two callers restating them — a Durable
|
|
72
|
+
* Object session and an embedded workspace — is two places for the help text
|
|
73
|
+
* to drift from the shim it describes.
|
|
74
|
+
*/
|
|
75
|
+
export declare function wasmRunnerSpec(deps: {
|
|
76
|
+
vfs: SqliteVFS;
|
|
77
|
+
facets: FacetHost;
|
|
78
|
+
processes: SessionProcessSupervisor;
|
|
79
|
+
}): RuntimeSpec;
|
|
80
|
+
//# sourceMappingURL=wasm-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm-runner.d.ts","sourceRoot":"","sources":["../../src/runtime/wasm-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC3F,OAAO,KAAK,EAAS,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAkDtD,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAE3C,eAAO,MAAM,gBAAgB,QAoCwC,CAAC;AAEtE,wBAAgB,wBAAwB,IAAI,MAAM,CASjD;AAyCD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE;IACnC,GAAG,EAAE,SAAS,CAAC;IACf,MAAM,EAAE,SAAS,CAAC;IAClB,SAAS,EAAE,wBAAwB,CAAC;CACrC,IAEG,OAAO,MAAM,EACb,MAAM,cAAc,KACnB,OAAO,CAAC,gBAAgB,CAAC,CAslB7B;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE;IACnC,GAAG,EAAE,SAAS,CAAC;IACf,MAAM,EAAE,SAAS,CAAC;IAClB,SAAS,EAAE,wBAAwB,CAAC;CACrC,GAAG,WAAW,CAgBd"}
|