@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.
Files changed (60) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1 -0
  4. package/dist/runtime/bash-runner.d.ts +63 -0
  5. package/dist/runtime/bash-runner.d.ts.map +1 -0
  6. package/dist/runtime/bash-runner.generated.d.ts +14 -0
  7. package/dist/runtime/bash-runner.generated.d.ts.map +1 -0
  8. package/dist/runtime/bash-runner.generated.js +13 -0
  9. package/dist/runtime/bash-runner.js +290 -0
  10. package/dist/runtime/cpython-runner.d.ts +86 -0
  11. package/dist/runtime/cpython-runner.d.ts.map +1 -0
  12. package/dist/runtime/cpython-runner.js +425 -0
  13. package/dist/runtime/facet-host.d.ts +159 -0
  14. package/dist/runtime/facet-host.d.ts.map +1 -0
  15. package/dist/runtime/facet-host.js +22 -0
  16. package/dist/runtime/installed-runtimes.d.ts +99 -0
  17. package/dist/runtime/installed-runtimes.d.ts.map +1 -0
  18. package/dist/runtime/installed-runtimes.js +162 -0
  19. package/dist/runtime/local-facet-host.d.ts +38 -0
  20. package/dist/runtime/local-facet-host.d.ts.map +1 -0
  21. package/dist/runtime/local-facet-host.js +171 -0
  22. package/dist/runtime/python-pip.d.ts +38 -0
  23. package/dist/runtime/python-pip.d.ts.map +1 -0
  24. package/dist/runtime/python-pip.js +1063 -0
  25. package/dist/runtime/runtime-manifest.d.ts +86 -0
  26. package/dist/runtime/runtime-manifest.d.ts.map +1 -0
  27. package/dist/runtime/runtime-manifest.js +72 -0
  28. package/dist/runtime/runtime-registry.d.ts +161 -0
  29. package/dist/runtime/runtime-registry.d.ts.map +1 -0
  30. package/dist/runtime/runtime-registry.js +363 -0
  31. package/dist/runtime/vfs-snapshot.d.ts.map +1 -1
  32. package/dist/runtime/vfs-snapshot.js +15 -1
  33. package/dist/runtime/vfs-supervisor.d.ts +22 -0
  34. package/dist/runtime/vfs-supervisor.d.ts.map +1 -0
  35. package/dist/runtime/vfs-supervisor.js +65 -0
  36. package/dist/runtime/virtual-socket-kernel.generated.d.ts +14 -0
  37. package/dist/runtime/virtual-socket-kernel.generated.d.ts.map +1 -0
  38. package/dist/runtime/virtual-socket-kernel.generated.js +13 -0
  39. package/dist/runtime/wasm-runner.d.ts +80 -0
  40. package/dist/runtime/wasm-runner.d.ts.map +1 -0
  41. package/dist/runtime/wasm-runner.js +686 -0
  42. package/dist/workspace/nimbus-workspace.d.ts +16 -0
  43. package/dist/workspace/nimbus-workspace.d.ts.map +1 -1
  44. package/dist/workspace/nimbus-workspace.js +57 -2
  45. package/package.json +4 -2
  46. package/src/index.ts +9 -0
  47. package/src/runtime/bash-runner.generated.ts +14 -0
  48. package/src/runtime/bash-runner.ts +347 -0
  49. package/src/runtime/cpython-runner.ts +504 -0
  50. package/src/runtime/facet-host.ts +170 -0
  51. package/src/runtime/installed-runtimes.ts +235 -0
  52. package/src/runtime/local-facet-host.ts +205 -0
  53. package/src/runtime/python-pip.ts +1211 -0
  54. package/src/runtime/runtime-manifest.ts +155 -0
  55. package/src/runtime/runtime-registry.ts +510 -0
  56. package/src/runtime/vfs-snapshot.ts +15 -1
  57. package/src/runtime/vfs-supervisor.ts +67 -0
  58. package/src/runtime/virtual-socket-kernel.generated.ts +14 -0
  59. package/src/runtime/wasm-runner.ts +835 -0
  60. 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"}