@nimbus-sh/worker 0.10.0 → 0.11.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 (260) hide show
  1. package/NOTICE.md +5 -0
  2. package/README.md +10 -0
  3. package/dist/_shared/session-router.d.ts +7 -0
  4. package/dist/_shared/session-router.d.ts.map +1 -1
  5. package/dist/_shared/session-router.js +7 -0
  6. package/dist/bindings/body.d.ts +6 -0
  7. package/dist/bindings/body.d.ts.map +1 -0
  8. package/dist/bindings/body.js +37 -0
  9. package/dist/bindings/kv.d.ts +0 -2
  10. package/dist/bindings/kv.d.ts.map +1 -1
  11. package/dist/bindings/kv.js +3 -42
  12. package/dist/bindings/r2.d.ts +0 -2
  13. package/dist/bindings/r2.d.ts.map +1 -1
  14. package/dist/bindings/r2.js +4 -44
  15. package/dist/esbuild-cli-artifact.generated.d.ts +18 -0
  16. package/dist/esbuild-cli-artifact.generated.d.ts.map +1 -0
  17. package/dist/esbuild-cli-artifact.generated.js +17 -0
  18. package/dist/facets/cirrus-real.d.ts.map +1 -1
  19. package/dist/facets/cirrus-real.js +9 -4
  20. package/dist/facets/compose.d.ts +11 -7
  21. package/dist/facets/compose.d.ts.map +1 -1
  22. package/dist/facets/compose.js +8 -38
  23. package/dist/facets/data-plan.d.ts +79 -0
  24. package/dist/facets/data-plan.d.ts.map +1 -0
  25. package/dist/facets/data-plan.js +477 -0
  26. package/dist/facets/esbuild-transform.d.ts +36 -10
  27. package/dist/facets/esbuild-transform.d.ts.map +1 -1
  28. package/dist/facets/esbuild-transform.js +216 -20
  29. package/dist/facets/exec-telemetry.d.ts +7 -3
  30. package/dist/facets/exec-telemetry.d.ts.map +1 -1
  31. package/dist/facets/manager.d.ts +179 -78
  32. package/dist/facets/manager.d.ts.map +1 -1
  33. package/dist/facets/manager.js +1221 -649
  34. package/dist/facets/opencode-staging.d.ts +0 -2
  35. package/dist/facets/opencode-staging.d.ts.map +1 -1
  36. package/dist/facets/opencode-staging.js +5 -11
  37. package/dist/facets/process.d.ts +4 -0
  38. package/dist/facets/process.d.ts.map +1 -1
  39. package/dist/facets/process.js +3 -0
  40. package/dist/facets/read-profile.d.ts +149 -0
  41. package/dist/facets/read-profile.d.ts.map +1 -0
  42. package/dist/facets/read-profile.js +483 -0
  43. package/dist/facets/resident-identity.d.ts +0 -1
  44. package/dist/facets/resident-identity.d.ts.map +1 -1
  45. package/dist/facets/resident-identity.js +0 -3
  46. package/dist/facets/wasm-swap-registry.d.ts +34 -25
  47. package/dist/facets/wasm-swap-registry.d.ts.map +1 -1
  48. package/dist/facets/wasm-swap-registry.js +62 -56
  49. package/dist/facets/ws-terminal.d.ts +4 -4
  50. package/dist/facets/ws-terminal.d.ts.map +1 -1
  51. package/dist/facets/ws-terminal.js +4 -5
  52. package/dist/git/commands.d.ts +16 -9
  53. package/dist/git/commands.d.ts.map +1 -1
  54. package/dist/git/commands.js +1818 -188
  55. package/dist/git/network-facet.d.ts +10 -2
  56. package/dist/git/network-facet.d.ts.map +1 -1
  57. package/dist/git/network-facet.js +62 -16
  58. package/dist/git/unified-diff.d.ts +74 -0
  59. package/dist/git/unified-diff.d.ts.map +1 -0
  60. package/dist/git/unified-diff.js +676 -0
  61. package/dist/git-bundle.generated.d.ts +7 -11
  62. package/dist/git-bundle.generated.d.ts.map +1 -1
  63. package/dist/git-bundle.generated.js +7 -11
  64. package/dist/hosted/commands.d.ts.map +1 -1
  65. package/dist/hosted/commands.js +62 -243
  66. package/dist/hosted/runtime.d.ts +19 -13
  67. package/dist/hosted/runtime.d.ts.map +1 -1
  68. package/dist/hosted/runtime.js +71 -14
  69. package/dist/hosted/services.d.ts +6 -7
  70. package/dist/hosted/services.d.ts.map +1 -1
  71. package/dist/hosted/services.js +10 -14
  72. package/dist/hosted/session.d.ts +165 -0
  73. package/dist/hosted/session.d.ts.map +1 -0
  74. package/dist/hosted/session.js +132 -0
  75. package/dist/loaders/generated-workers.d.ts +5 -2
  76. package/dist/loaders/generated-workers.d.ts.map +1 -1
  77. package/dist/loaders/generated-workers.js +6 -3
  78. package/dist/loaders/npm-resolve-preamble.d.ts.map +1 -1
  79. package/dist/loaders/npm-resolve-preamble.js +0 -27
  80. package/dist/node-shims-artifact.generated.d.ts +13 -4
  81. package/dist/node-shims-artifact.generated.d.ts.map +1 -1
  82. package/dist/node-shims-artifact.generated.js +16 -7
  83. package/dist/npm/bin-links.d.ts +3 -1
  84. package/dist/npm/bin-links.d.ts.map +1 -1
  85. package/dist/npm/bin-links.js +32 -8
  86. package/dist/npm/cache.d.ts +5 -0
  87. package/dist/npm/cache.d.ts.map +1 -1
  88. package/dist/npm/cache.js +13 -1
  89. package/dist/npm/install-batch-facet.d.ts +2 -2
  90. package/dist/npm/install-batch-facet.js +3 -3
  91. package/dist/npm/installer.d.ts +17 -1
  92. package/dist/npm/installer.d.ts.map +1 -1
  93. package/dist/npm/installer.js +159 -20
  94. package/dist/npm/package-lock.d.ts +32 -0
  95. package/dist/npm/package-lock.d.ts.map +1 -0
  96. package/dist/npm/package-lock.js +65 -0
  97. package/dist/npm/pre-bundle-facet.d.ts +1 -30
  98. package/dist/npm/pre-bundle-facet.d.ts.map +1 -1
  99. package/dist/npm/pre-bundle-facet.js +3 -5
  100. package/dist/npm/r2-cache.d.ts +2 -0
  101. package/dist/npm/r2-cache.d.ts.map +1 -1
  102. package/dist/npm/r2-cache.js +2 -0
  103. package/dist/npm/resolve-one-facet.d.ts.map +1 -1
  104. package/dist/npm/resolve-one-facet.js +14 -3
  105. package/dist/npm/resolver.d.ts +0 -7
  106. package/dist/npm/resolver.d.ts.map +1 -1
  107. package/dist/npm/resolver.js +0 -22
  108. package/dist/opencode-artifact.generated.js +2 -2
  109. package/dist/replica/routing.d.ts +2 -38
  110. package/dist/replica/routing.d.ts.map +1 -1
  111. package/dist/replica/routing.js +3 -55
  112. package/dist/router/index.d.ts.map +1 -1
  113. package/dist/router/index.js +15 -2
  114. package/dist/router/public-directory.d.ts +18 -0
  115. package/dist/router/public-directory.d.ts.map +1 -1
  116. package/dist/router/public-directory.js +1 -1
  117. package/dist/router/remote-api.d.ts +3 -1
  118. package/dist/router/remote-api.d.ts.map +1 -1
  119. package/dist/router/remote-api.js +42 -79
  120. package/dist/runtime/bash-repl.js +2 -2
  121. package/dist/runtime/bun-repl.d.ts.map +1 -1
  122. package/dist/runtime/bun-repl.js +2 -13
  123. package/dist/runtime/esbuild-wasm-bytes.d.ts +17 -5
  124. package/dist/runtime/esbuild-wasm-bytes.d.ts.map +1 -1
  125. package/dist/runtime/esbuild-wasm-bytes.js +43 -94
  126. package/dist/runtime/git-bundle-artifact.d.ts +17 -0
  127. package/dist/runtime/git-bundle-artifact.d.ts.map +1 -0
  128. package/dist/runtime/git-bundle-artifact.js +25 -0
  129. package/dist/runtime/node-repl.d.ts.map +1 -1
  130. package/dist/runtime/node-repl.js +2 -13
  131. package/dist/runtime/node-shims-artifact.d.ts +22 -23
  132. package/dist/runtime/node-shims-artifact.d.ts.map +1 -1
  133. package/dist/runtime/node-shims-artifact.js +48 -78
  134. package/dist/runtime/node-shims.d.ts.map +1 -1
  135. package/dist/runtime/node-shims.js +1567 -864
  136. package/dist/runtime/opencode-artifact.d.ts.map +1 -1
  137. package/dist/runtime/opencode-artifact.js +17 -53
  138. package/dist/runtime/opencode-facet-runner.d.ts +3 -6
  139. package/dist/runtime/opencode-facet-runner.d.ts.map +1 -1
  140. package/dist/runtime/opencode-facet-runner.js +45 -10
  141. package/dist/runtime/opentui-wasm-bytes.d.ts.map +1 -1
  142. package/dist/runtime/opentui-wasm-bytes.js +16 -49
  143. package/dist/runtime/package-manager.d.ts +0 -2
  144. package/dist/runtime/package-manager.d.ts.map +1 -1
  145. package/dist/runtime/package-manager.js +0 -3
  146. package/dist/runtime/python-repl.d.ts.map +1 -1
  147. package/dist/runtime/python-repl.js +2 -2
  148. package/dist/runtime/repl-session.d.ts +10 -0
  149. package/dist/runtime/repl-session.d.ts.map +1 -1
  150. package/dist/runtime/repl-session.js +7 -0
  151. package/dist/runtime/ruby-repl.d.ts.map +1 -1
  152. package/dist/runtime/ruby-repl.js +2 -2
  153. package/dist/runtime/ruby-resident.d.ts.map +1 -1
  154. package/dist/runtime/ruby-resident.js +36 -35
  155. package/dist/runtime/runtime-catalog.d.ts +10 -3
  156. package/dist/runtime/runtime-catalog.d.ts.map +1 -1
  157. package/dist/runtime/runtime-catalog.js +125 -15
  158. package/dist/runtime/sqlite-wasm-bytes.d.ts +4 -4
  159. package/dist/runtime/sqlite-wasm-bytes.d.ts.map +1 -1
  160. package/dist/runtime/sqlite-wasm-bytes.js +21 -57
  161. package/dist/runtime/staged-source.d.ts +67 -0
  162. package/dist/runtime/staged-source.d.ts.map +1 -0
  163. package/dist/runtime/staged-source.js +113 -0
  164. package/dist/runtime/wasi/preamble.d.ts.map +1 -1
  165. package/dist/runtime/wasi/preamble.js +0 -24
  166. package/dist/runtime-catalog.generated.js +1 -1
  167. package/dist/session/agent.d.ts +14 -2
  168. package/dist/session/agent.d.ts.map +1 -1
  169. package/dist/session/agent.js +57 -19
  170. package/dist/session/ai.d.ts +0 -11
  171. package/dist/session/ai.d.ts.map +1 -1
  172. package/dist/session/ai.js +0 -4
  173. package/dist/session/fs-watch.d.ts +0 -11
  174. package/dist/session/fs-watch.d.ts.map +1 -1
  175. package/dist/session/fs-watch.js +0 -21
  176. package/dist/session/hibernation.d.ts +34 -11
  177. package/dist/session/hibernation.d.ts.map +1 -1
  178. package/dist/session/hibernation.js +46 -29
  179. package/dist/session/init-phases.d.ts +1 -2
  180. package/dist/session/init-phases.d.ts.map +1 -1
  181. package/dist/session/init-phases.js +1 -2
  182. package/dist/session/init.d.ts.map +1 -1
  183. package/dist/session/init.js +7 -20
  184. package/dist/session/keys.d.ts +0 -3
  185. package/dist/session/keys.d.ts.map +1 -1
  186. package/dist/session/keys.js +0 -3
  187. package/dist/session/legacy-reset.d.ts +11 -0
  188. package/dist/session/legacy-reset.d.ts.map +1 -0
  189. package/dist/session/legacy-reset.js +16 -0
  190. package/dist/session/nimbus-session.d.ts +41 -15
  191. package/dist/session/nimbus-session.d.ts.map +1 -1
  192. package/dist/session/nimbus-session.js +64 -70
  193. package/dist/session/npm-install-port.d.ts.map +1 -1
  194. package/dist/session/npm-install-port.js +1 -0
  195. package/dist/session/programmatic.d.ts +13 -18
  196. package/dist/session/programmatic.d.ts.map +1 -1
  197. package/dist/session/programmatic.js +53 -39
  198. package/dist/session/replica-routes.d.ts +2 -3
  199. package/dist/session/replica-routes.d.ts.map +1 -1
  200. package/dist/session/replica-routes.js +3 -10
  201. package/dist/session/routes.d.ts.map +1 -1
  202. package/dist/session/routes.js +7 -10
  203. package/dist/session/rpc.d.ts +104 -20
  204. package/dist/session/rpc.d.ts.map +1 -1
  205. package/dist/session/rpc.js +184 -37
  206. package/dist/session/start-real-vite.js +2 -2
  207. package/dist/session/state-store.d.ts +1 -17
  208. package/dist/session/state-store.d.ts.map +1 -1
  209. package/dist/session/state-store.js +3 -53
  210. package/dist/session/supervisor-op.d.ts +7 -0
  211. package/dist/session/supervisor-op.d.ts.map +1 -1
  212. package/dist/session/supervisor-op.js +6 -1
  213. package/dist/session/supervisor-rpc.d.ts +104 -15
  214. package/dist/session/supervisor-rpc.d.ts.map +1 -1
  215. package/dist/session/supervisor-rpc.js +188 -71
  216. package/dist/session/vite-command.d.ts.map +1 -1
  217. package/dist/session/vite-command.js +17 -14
  218. package/dist/session/ws.d.ts.map +1 -1
  219. package/dist/session/ws.js +20 -8
  220. package/dist/shell/npm-bin-entrypoints.d.ts.map +1 -1
  221. package/dist/shell/npm-bin-entrypoints.js +30 -5
  222. package/dist/vfs/facet-resident-limits.d.ts +33 -0
  223. package/dist/vfs/facet-resident-limits.d.ts.map +1 -0
  224. package/dist/vfs/facet-resident-limits.js +33 -0
  225. package/dist/vfs/facet-resident-store.d.ts +2 -10
  226. package/dist/vfs/facet-resident-store.d.ts.map +1 -1
  227. package/dist/vfs/facet-resident-store.js +1594 -219
  228. package/dist/workspace-host.d.ts +2 -0
  229. package/dist/workspace-host.d.ts.map +1 -1
  230. package/dist/workspace-host.js +2 -0
  231. package/dist/wrangler/nimbus-wrangler.d.ts +0 -2
  232. package/dist/wrangler/nimbus-wrangler.d.ts.map +1 -1
  233. package/dist/wrangler/nimbus-wrangler.js +5 -22
  234. package/package.json +8 -7
  235. package/public/_assets/opencode/1.16.2/index-attach.js +2 -2
  236. package/public/_assets/runtime/esbuild-cli-c4fda380d52befc1.js +6892 -0
  237. package/public/_assets/runtime/git-de3e60c9f3ff006a.js +103 -0
  238. package/public/_assets/runtime/{node-shims-7b4dd7a76d95d21e.js → node-shims-06565b121555c194.js} +2089 -861
  239. package/public/_assets/runtime/resident-store-6ffb1939c53d982f.js +2264 -0
  240. package/public/_assets/runtime/vfs-write-ledger-e501e8fc793bc2c1.js +889 -0
  241. package/scripts/build-opencode-attach-entry.mjs +51 -1
  242. package/scripts/bundle-facet-workers.mjs +114 -3
  243. package/scripts/bundle-git.mjs +88 -27
  244. package/scripts/bundle-node-shims.mjs +72 -46
  245. package/scripts/bundle-runtime.mjs +18 -421
  246. package/scripts/cf-git-patch.mjs +137 -0
  247. package/scripts/patch-install-deps.mjs +49 -96
  248. package/scripts/runtime-specs.mjs +435 -0
  249. package/vendor/git-http.generated.d.ts +82 -0
  250. package/vendor/git-upstream.generated.d.ts +4378 -0
  251. package/vendor/git.LICENSE +7 -0
  252. package/vendor/git.generated.d.mts +21 -0
  253. package/vendor/git.generated.mjs +103 -0
  254. package/dist/replica/suspension.d.ts +0 -36
  255. package/dist/replica/suspension.d.ts.map +0 -1
  256. package/dist/replica/suspension.js +0 -49
  257. package/dist/runtime/static-server.d.ts +0 -3
  258. package/dist/runtime/static-server.d.ts.map +0 -1
  259. package/dist/runtime/static-server.js +0 -133
  260. package/scripts/clean-dist.mjs +0 -7
@@ -1 +1 @@
1
- {"version":3,"file":"opencode-artifact.d.ts","sourceRoot":"","sources":["../../src/runtime/opencode-artifact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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,MAAM,CAAC,CAGjB;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,WAAW,CAAC,CAEtB;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CAGjB;AAED;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,gBAAgB,EACrB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAYjC"}
@@ -20,19 +20,9 @@
20
20
  * (see OPENCODE_TREE_SITTER_WASMS and FacetManager.treeSitterModuleEntries).
21
21
  */
22
22
  import { OPENCODE_ARTIFACT_BUILD_ID, OPENCODE_ARTIFACT_DIGESTS, OPENCODE_ARTIFACT_PRESENT, OPENCODE_ARTIFACT_VERSION, } from '../opencode-artifact.generated.js';
23
- import { disposeRpcResource } from '@nimbus-sh/platform/rpc-dispose.js';
24
- import { sha256Hex } from '@nimbus-sh/core/_shared/crypto.js';
23
+ import { fetchStagedBytes } from './staged-source.js';
25
24
  /** Base asset path of the staged opencode bundle directory. */
26
25
  const OPENCODE_ASSET_BASE = `/_assets/opencode/${OPENCODE_ARTIFACT_VERSION}`;
27
- // The build id (content hash of the staged dist) is part of the L2 key so a
28
- // same-version rebuild with different bytes never serves stale content from a
29
- // warm colo cache.
30
- function l2Key(file) {
31
- return `https://nimbus-cache.invalid${OPENCODE_ASSET_BASE}/${OPENCODE_ARTIFACT_BUILD_ID}/${file}`;
32
- }
33
- function assetUrl(file) {
34
- return `https://nimbus-internal.invalid${OPENCODE_ASSET_BASE}/${file}`;
35
- }
36
26
  /**
37
27
  * The pinned digest for a staged file. Unstaged builds carry an empty map, so
38
28
  * the two conditions are reported apart: "this build has no artifact at all"
@@ -54,48 +44,22 @@ function pinnedDigest(file) {
54
44
  }
55
45
  async function fetchAsset(env, file) {
56
46
  const expected = pinnedDigest(file);
57
- const caches = globalThis.caches;
58
- let ab = null;
59
- try {
60
- if (caches?.default) {
61
- const hit = await caches.default.match(new Request(l2Key(file)));
62
- if (hit && hit.ok)
63
- ab = await hit.arrayBuffer();
64
- }
65
- }
66
- catch { /* fall through to ASSETS */ }
67
- const fromCache = ab !== null;
68
- if (!ab) {
69
- const res = await env.ASSETS.fetch(new Request(assetUrl(file)));
70
- try {
71
- if (!res.ok) {
72
- throw new Error(`opencode asset fetch failed: ${res.status} ${res.statusText} for ` +
73
- `${OPENCODE_ASSET_BASE}/${file} — deploy is missing the staged opencode artifact`);
74
- }
75
- ab = await res.arrayBuffer();
76
- }
77
- finally {
78
- disposeRpcResource(res);
79
- }
80
- }
81
- const digest = await sha256Hex(ab);
82
- if (digest !== expected) {
83
- throw new Error(`opencode asset integrity check failed for ${OPENCODE_ASSET_BASE}/${file}: expected ` +
84
- `${expected}, got ${digest} (${fromCache ? 'L2 cache' : 'ASSETS'}) — the staged ` +
85
- 'artifact is corrupt or out of sync; rerun scripts/bundle-opencode.mjs and redeploy');
86
- }
87
- if (!fromCache) {
88
- try {
89
- if (caches?.default) {
90
- const writeBack = new Response(new Uint8Array(ab), {
91
- headers: { 'Cache-Control': 'public, max-age=31536000, immutable' },
92
- });
93
- await caches.default.put(new Request(l2Key(file)), writeBack);
94
- }
95
- }
96
- catch { /* silent */ }
97
- }
98
- return ab;
47
+ const path = `${OPENCODE_ASSET_BASE}/${file}`;
48
+ return fetchStagedBytes(env, {
49
+ path,
50
+ // The build id (content hash of the staged dist) is part of the key so a
51
+ // same-version rebuild with different bytes never serves stale content
52
+ // from a warm colo cache.
53
+ l2Key: `https://nimbus-cache.invalid${OPENCODE_ASSET_BASE}/${OPENCODE_ARTIFACT_BUILD_ID}/${file}`,
54
+ sha256: expected,
55
+ poisonedCache: 'reject',
56
+ missingBinding: `Nimbus: opencode requires an env.ASSETS binding (serves ${path})`,
57
+ fetchFailed: (res) => `opencode asset fetch failed: ${res.status} ${res.statusText} for ` +
58
+ `${path} — deploy is missing the staged opencode artifact`,
59
+ integrityFailed: (digest, from) => `opencode asset integrity check failed for ${path}: expected ` +
60
+ `${expected}, got ${digest} (${from}) — the staged ` +
61
+ 'artifact is corrupt or out of sync; rerun scripts/bundle-opencode.mjs and redeploy',
62
+ });
99
63
  }
100
64
  /** Fetch the opencode CLI bundle source as text. */
101
65
  /**
@@ -35,6 +35,7 @@
35
35
  * map (see SQLITE_WASM_MODULE_NAME) and is booted before opencode opens the
36
36
  * DB at ~/.local/share/opencode/*.db.
37
37
  */
38
+ import type { NodeFacetSources } from './node-shims-artifact.js';
38
39
  /** Map-module specifier for the opencode ESM bundle. */
39
40
  export declare const OPENCODE_BUNDLE_MODULE_NAME = "opencode-bundle.js";
40
41
  /**
@@ -75,18 +76,14 @@ export interface OpencodeRunnerOptions {
75
76
  };
76
77
  cwd: string;
77
78
  stdin: string;
78
- /** The node-compat shim source (fetchNodeShimsCode — the staged asset). */
79
- shimsCode: string;
79
+ /** The node-compat layer's sources (fetchNodeFacetSources — the staged assets). */
80
+ sources: NodeFacetSources;
80
81
  /**
81
82
  * Serialized VFS snapshot bundle (the `_serializeBundleForFacet` IIFE
82
83
  * string). Provides sync VFS reads; async writes/mkdir flush live through
83
84
  * the SUPERVISOR RPC binding.
84
85
  */
85
86
  vfsBundle: string;
86
- /** Serialized VFS directory manifest (JSON) for readdir/stat coherence. */
87
- vfsManifest: string;
88
- /** Serialized VFS inode metadata (JSON) for stat and permission checks. */
89
- vfsMetadata: string;
90
87
  /** The coherence cursor the snapshot above was read at, as a JSON literal. */
91
88
  vfsCursor: string;
92
89
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"opencode-facet-runner.d.ts","sourceRoot":"","sources":["../../src/runtime/opencode-facet-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAkBH,wDAAw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8E;IAC9E,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;;;;;;;;;OAeG;IACH,IAAI,EAAE,kBAAkB,CAAC;CAC1B;AAED,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;AAuDnE,2EAA2E;AAC3E,eAAO,MAAM,wBAAwB,4BAA4B,CAAC;AAElE,2DAA2D;AAC3D,eAAO,MAAM,wBAAwB,oBAAoB,CAAC;AAE1D;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAevC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAmOjC,CAAC;AA2BF;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,qBAAqB,GAAG,MAAM,CAwuB9E"}
@@ -37,13 +37,14 @@
37
37
  */
38
38
  import { generateSqliteFacetPreamble } from './sqlite-shim.js';
39
39
  import { VFS_CURSOR_SEED_SOURCE } from '@nimbus-sh/core/_shared/facet-vfs-cursor.js';
40
- import { VFS_WRITE_LEDGER_SOURCE } from '@nimbus-sh/core/_shared/vfs-write-ledger.js';
40
+ import { ONE_SHOT_STORE_MEMORY_BYTES } from '../vfs/facet-resident-limits.js';
41
41
  import { OPENTUI_BACKEND_FACET_SRC, OPENTUI_BACKEND_GLOBAL, OPENTUI_WASM_MODULE_NAME, generateOpenTUIBackendBootCode, } from './opentui-facet-backend.js';
42
42
  import { OPENCODE_TREE_SITTER_WASMS, OPENCODE_YOGA_WASM } from '../opencode-artifact.generated.js';
43
- // The ~230 KiB node-compat shim source is staged as a static asset
44
- // (scripts/bundle-node-shims.mjs) — promoted out of the worker bundle for the
45
- // ≤6 MiB gate. The caller (FacetManager.execStagedArtifact) awaits the
46
- // memoized fetchNodeShimsCode and threads it in via opts.shimsCode.
43
+ // The node-compat layer's sources (the ~230 KiB shims and the VFS write ledger
44
+ // they write through) are staged as static assets (scripts/bundle-node-shims.mjs),
45
+ // promoted out of the worker bundle for its size gate. The caller
46
+ // (opencode-staging.ts) awaits the memoized fetchNodeFacetSources and threads
47
+ // them in via opts.sources.
47
48
  /** Map-module specifier for the opencode ESM bundle. */
48
49
  export const OPENCODE_BUNDLE_MODULE_NAME = 'opencode-bundle.js';
49
50
  /**
@@ -705,12 +706,18 @@ let stdout = "";
705
706
  let stderr = "";
706
707
  let exitCode = 0;
707
708
  let __supervisor = null;
708
- const __vfsBundle = ${opts.vfsBundle};
709
- const __vfsManifest = ${opts.vfsManifest};
710
- const __vfsMetadata = ${opts.vfsMetadata};
709
+ // The process's view of the filesystem: the same store and namespace a node
710
+ // process boots on (vfs/facet-resident-store.ts), in this facet's heap and
711
+ // bounded there. An opencode facet has no storage allowance of the session's
712
+ // ledger to grow a SQLite store under. Bound and booted by __ocBootStore
713
+ // before the opencode bundle is imported; the shims read it through
714
+ // __nimbusResidentBundle.
715
+ let __MODULE_VFS_BUNDLE = ${opts.vfsBundle};
711
716
  const __MODULE_VFS_CURSOR = ${opts.vfsCursor};
717
+ ${opts.sources.residentStore}
718
+ const __vfsBundle = __nimbusResidentBundle;
712
719
  ${VFS_CURSOR_SEED_SOURCE}
713
- ${VFS_WRITE_LEDGER_SOURCE}
720
+ ${opts.sources.ledger}
714
721
  const __vfsDirs = {};
715
722
  const __nimbusDeferProcessExitReport = true;
716
723
  // Ledger of in-flight facet I/O the teardown drain must await. The shims push
@@ -739,7 +746,7 @@ class __ProcessExit extends Error {
739
746
  constructor(code) { super("process.exit(" + code + ")"); this.code = code; }
740
747
  }
741
748
 
742
- ${opts.shimsCode}
749
+ ${opts.sources.shims}
743
750
 
744
751
  globalThis.${BUILTINS_GLOBAL} = builtins;
745
752
  // Capture workerd's real process.memoryUsage BEFORE the shim process takes over
@@ -1182,9 +1189,33 @@ async function __ocDispatchHttp(request) {
1182
1189
  return globalThis.__nimbusServeHttp(request);
1183
1190
  }
1184
1191
 
1192
+ /**
1193
+ * Bind and boot the store, and require its namespace, before any opencode code
1194
+ * runs: every synchronous stat, exists and readdir reads it. Resolves to null,
1195
+ * or to the launch's failure naming why.
1196
+ */
1197
+ async function __ocBootStore() {
1198
+ __residentBindInMemory(${ONE_SHOT_STORE_MEMORY_BYTES});
1199
+ __residentSetStorage(undefined, __supervisor);
1200
+ __nsSetCred(cred);
1201
+ __residentSetPlan([]);
1202
+ __residentSetPushRoots([cwd || "/home/user", "/tmp"]);
1203
+ const __booted = await __residentBoot(
1204
+ () => { const __bundle = __MODULE_VFS_BUNDLE; __MODULE_VFS_BUNDLE = null; return __bundle; },
1205
+ __MODULE_VFS_CURSOR,
1206
+ __supervisor,
1207
+ );
1208
+ if (__booted.cursor) {
1209
+ globalThis.__nimbusVfsCursor = { epoch: __booted.cursor.epoch, rev: __booted.cursor.rev };
1210
+ }
1211
+ return __residentRequireNamespace(__supervisor, __booted.failure);
1212
+ }
1213
+
1185
1214
  export class NimbusProcess extends __NimbusDurableObject {
1186
1215
  async startProcess() {
1187
1216
  __supervisor = (this.env && this.env.SUPERVISOR) || null;
1217
+ const __bootFailure = await __ocBootStore();
1218
+ if (__bootFailure) throw new Error(__bootFailure);
1188
1219
  // Run the resident lifecycle and hold THIS RPC open until it exits — the
1189
1220
  // same contract the long-running node path uses (its startProcess awaits
1190
1221
  // the resident lifecycle). The open call keeps the caller's stubs live for
@@ -1267,6 +1298,10 @@ async function __ocRunServe() {
1267
1298
 
1268
1299
  async function __ocOneShotFetch(request, workerEnv) {
1269
1300
  __supervisor = (workerEnv && workerEnv.SUPERVISOR) || null;
1301
+ const __bootFailure = await __ocBootStore();
1302
+ if (__bootFailure) {
1303
+ return __ocHostResponse.json({ exitCode: 1, stdout: "", stderr: __bootFailure + "\\n", vfsWrites: {} });
1304
+ }
1270
1305
  try {
1271
1306
  const __ocBundle = await import("${OPENCODE_BUNDLE_MODULE_NAME}");
1272
1307
  if (argv[2] === "${OPENCODE_TREE_SITTER_DIAG_ARG}") {
@@ -1 +1 @@
1
- {"version":3,"file":"opentui-wasm-bytes.d.ts","sourceRoot":"","sources":["../../src/runtime/opentui-wasm-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAUH,kEAAkE;AAClE,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE;QAAE,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;KAAE,CAAC;CACpD;AASD;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC,CAqD1F"}
1
+ {"version":3,"file":"opentui-wasm-bytes.d.ts","sourceRoot":"","sources":["../../src/runtime/opentui-wasm-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AASH,kEAAkE;AAClE,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE;QAAE,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;KAAE,CAAC;CACpD;AAyBD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC,CAEpF"}
@@ -16,14 +16,26 @@
16
16
  * the backend.
17
17
  */
18
18
  import { OPENTUI_WASM_BUILD_ID, OPENTUI_WASM_ENTRY, OPENTUI_WASM_SHA256, } from '../opentui-wasm-artifact.generated.js';
19
- import { disposeRpcResource } from '@nimbus-sh/platform/rpc-dispose.js';
20
- import { sha256Hex } from '@nimbus-sh/core/_shared/crypto.js';
19
+ import { fetchStagedBytes } from './staged-source.js';
21
20
  /**
22
21
  * Synthetic L2 cache key for the OpenTUI wasm asset. Build-id-pinned so a
23
22
  * same-version rebuild with different bytes lands a fresh entry instead of
24
23
  * serving stale content from a warm colo cache.
25
24
  */
26
25
  const OPENTUI_WASM_L2_KEY = `https://nimbus-cache.invalid${OPENTUI_WASM_ENTRY}?build=${OPENTUI_WASM_BUILD_ID}`;
26
+ const OPENTUI_WASM_ASSET = {
27
+ path: OPENTUI_WASM_ENTRY,
28
+ l2Key: OPENTUI_WASM_L2_KEY,
29
+ sha256: OPENTUI_WASM_SHA256,
30
+ contentType: 'application/wasm',
31
+ poisonedCache: 'reject',
32
+ missingBinding: `Nimbus: the OpenTUI backend requires an env.ASSETS binding (serves ${OPENTUI_WASM_ENTRY})`,
33
+ fetchFailed: (res) => `OpenTUI wasm asset fetch failed: ${res.status} ${res.statusText} for ` +
34
+ `${OPENTUI_WASM_ENTRY} — deploy is missing the staged opentui artifact`,
35
+ integrityFailed: (digest, from) => `OpenTUI wasm integrity check failed: expected ${OPENTUI_WASM_SHA256}, got ` +
36
+ `${digest} (${from}) — the staged artifact is ` +
37
+ `corrupt or out of sync with opentui-wasm-artifact.generated.ts`,
38
+ };
27
39
  /**
28
40
  * Fetch the staged OpenTUI wasm bytes and verify their SHA-256 against the
29
41
  * generated digest.
@@ -32,51 +44,6 @@ const OPENTUI_WASM_L2_KEY = `https://nimbus-cache.invalid${OPENTUI_WASM_ENTRY}?b
32
44
  * failures are silent — ASSETS is always the source of truth. A non-200 from
33
45
  * ASSETS, or a digest mismatch, throws.
34
46
  */
35
- export async function fetchOpenTUIWasmBytes(env) {
36
- const caches = globalThis.caches;
37
- let bytes = null;
38
- try {
39
- if (caches?.default) {
40
- const hit = await caches.default.match(new Request(OPENTUI_WASM_L2_KEY));
41
- if (hit && hit.ok)
42
- bytes = await hit.arrayBuffer();
43
- }
44
- }
45
- catch { /* fall through to ASSETS */ }
46
- let fromCache = bytes !== null;
47
- if (!bytes) {
48
- const url = `https://nimbus-internal.invalid${OPENTUI_WASM_ENTRY}`;
49
- const res = await env.ASSETS.fetch(new Request(url));
50
- try {
51
- if (!res.ok) {
52
- throw new Error(`OpenTUI wasm asset fetch failed: ${res.status} ${res.statusText} for ` +
53
- `${OPENTUI_WASM_ENTRY} — deploy is missing the staged opentui artifact`);
54
- }
55
- bytes = await res.arrayBuffer();
56
- }
57
- finally {
58
- disposeRpcResource(res);
59
- }
60
- }
61
- const digest = await sha256Hex(bytes);
62
- if (digest !== OPENTUI_WASM_SHA256) {
63
- throw new Error(`OpenTUI wasm integrity check failed: expected ${OPENTUI_WASM_SHA256}, got ` +
64
- `${digest} (${fromCache ? 'L2 cache' : 'ASSETS'}) — the staged artifact is ` +
65
- `corrupt or out of sync with opentui-wasm-artifact.generated.ts`);
66
- }
67
- if (!fromCache) {
68
- try {
69
- if (caches?.default) {
70
- const writeBack = new Response(new Uint8Array(bytes), {
71
- headers: {
72
- 'Content-Type': 'application/wasm',
73
- 'Cache-Control': 'public, max-age=31536000, immutable',
74
- },
75
- });
76
- await caches.default.put(new Request(OPENTUI_WASM_L2_KEY), writeBack);
77
- }
78
- }
79
- catch { /* silent */ }
80
- }
81
- return bytes;
47
+ export function fetchOpenTUIWasmBytes(env) {
48
+ return fetchStagedBytes(env, OPENTUI_WASM_ASSET);
82
49
  }
@@ -14,7 +14,6 @@
14
14
  import { runtimeCatalogSource, type RuntimeCatalogEnv } from './runtime-catalog.js';
15
15
  import type { CredentialedVfs } from '@nimbus-sh/core/vfs/sqlite-vfs.js';
16
16
  import type { RuntimeManager } from '@nimbus-sh/core/runtime/runtime-manager.js';
17
- import type { RuntimeAvailability } from '@nimbus-sh/core/runtime/runtime-package.js';
18
17
  import { type RuntimeWarmHook } from '@nimbus-sh/core/runtime/nimbus-command.js';
19
18
  import type { MinShellRegistry } from '@nimbus-sh/core/runtime/installed-runtimes.js';
20
19
  export { runtimeCatalogSource };
@@ -54,7 +53,6 @@ export declare function ensureRuntimesProgrammatic(deps: {
54
53
  }, specs: string[], opts?: {
55
54
  force?: boolean;
56
55
  }): Promise<RuntimeInstallSummary[]>;
57
- export declare function listAvailableRuntimes(env: RuntimeCatalogEnv): Promise<RuntimeAvailability[]>;
58
56
  /**
59
57
  * Command-not-found hints, catalog-driven: a bare name the shell could not
60
58
  * resolve is answered with the runtime that provides it, so `python3` hints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B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAAC,IAAI,EAAE;IACrD,QAAQ,EAAE,cAAc,CAAC;IACzB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,GAAG,EAAE,eAAe,CAAC;IACrB,OAAO,IAAI,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,CAAC,qBAAqB,CAAC,CA6B/E;AAED,wBAAsB,0BAA0B,CAAC,IAAI,EAAE;IACrD,QAAQ,EAAE,cAAc,CAAC;IACzB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,GAAG,EAAE,eAAe,CAAC;IACrB,OAAO,IAAI,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAMpF;AAID;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,iBAAiB,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAyChI"}
@@ -59,9 +59,6 @@ export async function ensureRuntimesProgrammatic(deps, specs, opts = {}) {
59
59
  }
60
60
  return results;
61
61
  }
62
- export async function listAvailableRuntimes(env) {
63
- return runtimeCatalogSource(env).list();
64
- }
65
62
  /**
66
63
  * Command-not-found hints, catalog-driven: a bare name the shell could not
67
64
  * resolve is answered with the runtime that provides it, so `python3` hints
@@ -1 +1 @@
1
- {"version":3,"file":"python-repl.d.ts","sourceRoot":"","sources":["../../src/runtime/python-repl.ts"],"names":[],"mappings":"AAGA,OAA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E,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAMnF,OAAO,EAAe,KAAK,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAetG,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,YAAY,CAAC;IACvB,sEAAsE;IACtE,SAAS,EAAE,yBAAyB,CAAC;IACrC,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,mFAAmF;IACnF,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,eAAe,CAAC;IAC1B;;;;;;;;;OASG;IACH,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;IACvC;;;;;;;;OAQG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAgRD,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,WAAW,GAAG,aAAa,GAAG,UAAU,CAAC,GAChF,OAAO,CAAC,IAAI,CAAC,CAIf"}
@@ -1,5 +1,5 @@
1
1
  import { IsolatePool } from '@nimbus-sh/fabric/isolate-pool.js';
2
- import { withHostFilesystem } from '@nimbus-sh/core/shell/execution-fs.js';
2
+ import { withHostView } from '@nimbus-sh/core/runtime/process-files.js';
3
3
  import { z } from 'zod/v4';
4
4
  import { ReplSession } from './repl-session.js';
5
5
  import { sessionUsesSciVariant } from '@nimbus-sh/core/runtime/python-pip.js';
@@ -162,7 +162,7 @@ class PythonReplAdapter {
162
162
  }
163
163
  }
164
164
  async ensurePool() {
165
- await withHostFilesystem(this.deps.authority, CRED_KERNEL, (vfs) => this.ensurePoolFrom(vfs));
165
+ await withHostView(this.deps.authority, CRED_KERNEL, (vfs) => this.ensurePoolFrom(vfs));
166
166
  }
167
167
  async ensurePoolFrom(vfs) {
168
168
  const sciPath = `${this.deps.installRoot}/${CPYTHON_SCI_WASM_REL}`;
@@ -53,6 +53,16 @@ export type ReplPushResult = {
53
53
  kind: 'error';
54
54
  stderr: string;
55
55
  };
56
+ /** The result of one Node/Bun facet evaluation. */
57
+ export interface ReplFacetResult {
58
+ stdout: string;
59
+ stderr: string;
60
+ incomplete?: boolean;
61
+ exit?: boolean;
62
+ exitCode?: number;
63
+ error?: string;
64
+ }
65
+ export declare function replPushResult(result: ReplFacetResult): ReplPushResult;
56
66
  export declare class ReplSession {
57
67
  private adapter;
58
68
  private detachRepl;
@@ -1 +1 @@
1
- {"version":3,"file":"repl-session.d.ts","sourceRoot":"","sources":["../../src/runtime/repl-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+CAA+C,CAAC;AAI3E;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;mCAC+B;IAC/B,MAAM,IAAI,MAAM,CAAC;IACjB;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC5C;6DACyD;IACzD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,oFAAoF;IACpF,SAAS,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,yCAAyC;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,8CAA8C;IAC9C,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,GACtB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CA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,CAAC,UAAU;CAwBnB"}
@@ -13,6 +13,13 @@
13
13
  */
14
14
  import { errorText } from '@nimbus-sh/core/_shared/error-text.js';
15
15
  import { normalizeTerminalNewlines } from '@nimbus-sh/core/_shared/terminal.js';
16
+ export function replPushResult(result) {
17
+ if (result.exit)
18
+ return { kind: 'exit', exitCode: result.exitCode || 0, stdout: result.stdout, stderr: result.stderr };
19
+ if (result.incomplete)
20
+ return { kind: 'incomplete' };
21
+ return { kind: 'output', stdout: result.stdout || '', stderr: result.stderr || '' };
22
+ }
16
23
  export class ReplSession {
17
24
  adapter;
18
25
  detachRepl = null;
@@ -1 +1 @@
1
- {"version":3,"file":"ruby-repl.d.ts","sourceRoot":"","sources":["../../src/runtime/ruby-repl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,OAAO,EAAe,KAAK,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAGtG,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,YAAY,CAAC;IACvB,qEAAqE;IACrE,SAAS,EAAE,yBAAyB,CAAC;IACrC,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;CACrB;AA8MD;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAIrE"}
1
+ {"version":3,"file":"ruby-repl.d.ts","sourceRoot":"","sources":["../../src/runtime/ruby-repl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,OAAO,EAAe,KAAK,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAItG,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,YAAY,CAAC;IACvB,qEAAqE;IACrE,SAAS,EAAE,yBAAyB,CAAC;IACrC,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;CACrB;AA8MD;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAIrE"}
@@ -27,7 +27,7 @@
27
27
  import { ReplSession } from './repl-session.js';
28
28
  import { buildRubyPreamble } from '@nimbus-sh/core/runtime/ruby-runner.js';
29
29
  import { CRED_KERNEL } from '@nimbus-sh/core/runtime/os-contracts.js';
30
- import { withHostFilesystem } from '@nimbus-sh/core/shell/execution-fs.js';
30
+ import { withHostView } from '@nimbus-sh/core/runtime/process-files.js';
31
31
  class RubyReplAdapter {
32
32
  pool = null;
33
33
  deps;
@@ -147,7 +147,7 @@ class RubyReplAdapter {
147
147
  return;
148
148
  const { installRoot, facetMgr } = this.deps;
149
149
  const wasmPath = `${installRoot}/share/ruby/ruby+stdlib.wasm`;
150
- this.wasmBytesAB = toAB(await withHostFilesystem(this.deps.authority, CRED_KERNEL, async (vfs) => {
150
+ this.wasmBytesAB = toAB(await withHostView(this.deps.authority, CRED_KERNEL, async (vfs) => {
151
151
  if (!(await vfs.exists(wasmPath))) {
152
152
  throw new Error(`ruby+stdlib.wasm missing at ${wasmPath} (run 'nimbus install ruby')`);
153
153
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ruby-resident.d.ts","sourceRoot":"","sources":["../../src/runtime/ruby-resident.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAezD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,GAAG,iBAAiB,CAgF3E;AAED,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAsKrE"}
1
+ {"version":3,"file":"ruby-resident.d.ts","sourceRoot":"","sources":["../../src/runtime/ruby-resident.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAezD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,GAAG,iBAAiB,CA+D3E;AAED,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAqLrE"}
@@ -13,7 +13,7 @@ import { z } from 'zod';
13
13
  import { buildRubyPreamble, normalizeRubyFacetResult, } from '@nimbus-sh/core/runtime/ruby-runner.js';
14
14
  import { VIRTUAL_SOCKET_KERNEL_SRC } from '@nimbus-sh/core/runtime/virtual-socket-kernel.generated.js';
15
15
  const RubySocketProcessBootResponseSchema = z.object({
16
- state: z.string().optional(),
16
+ state: z.enum(['listening', 'exited']),
17
17
  port: z.number().optional(),
18
18
  stdout: z.string().optional(),
19
19
  stderr: z.string().optional(),
@@ -35,7 +35,11 @@ export function rubyResidentStart(facetMgr) {
35
35
  // value may carry — so whichever host runs this process reads it itself.
36
36
  vfsWasmModules: { 'ruby+stdlib.wasm': args.wasmVfsPath },
37
37
  startArgs: args.startArgs,
38
+ foreground: { signal: args.signal, write: args.write },
38
39
  }).catch(() => null);
40
+ // Interrupted while it waited to bind or exit: the process is gone with it.
41
+ if (args.signal.aborted)
42
+ return { exitCode: 130, stdout: '', stderr: '' };
39
43
  if (!spawned) {
40
44
  return { exitCode: 1, stdout: '', stderr: 'ruby process boot failed\n' };
41
45
  }
@@ -69,34 +73,16 @@ export function rubyResidentStart(facetMgr) {
69
73
  port: routeablePort,
70
74
  };
71
75
  }
72
- const reservedPorts = await facetMgr.waitForRouteablePorts(spawned.pid);
73
- if (reservedPorts.length > 0) {
74
- return {
75
- exitCode: 0,
76
- stdout: `${boot.stdout || ''}\x1b[2m[started (long-running): pid=${spawned.pid} cmd="${command}" port=${reservedPorts[0]}]\x1b[0m\n`,
77
- stderr: boot.stderr || '',
78
- spawnedPid: spawned.pid,
79
- port: reservedPorts[0],
80
- };
81
- }
82
- if (boot.state === 'exited') {
83
- const result = normalizeRubyFacetResult(boot.result) || {
84
- exitCode: 1,
85
- stdout: '',
86
- stderr: 'ruby process returned an invalid exit payload\n',
87
- };
88
- facetMgr.finishProcess(spawned.pid, result.exitCode, result.stderr || 'ruby process exited');
89
- return {
90
- exitCode: result.exitCode,
91
- stdout: result.stdout,
92
- stderr: result.stderr || result.error || '',
93
- };
94
- }
76
+ const result = normalizeRubyFacetResult(boot.result) || {
77
+ exitCode: 1,
78
+ stdout: '',
79
+ stderr: 'ruby process returned an invalid exit payload\n',
80
+ };
81
+ facetMgr.finishProcess(spawned.pid, result.exitCode, result.stderr || 'ruby process exited');
95
82
  return {
96
- exitCode: 0,
97
- stdout: `${boot.stdout || ''}\x1b[2m[started (long-running): pid=${spawned.pid} cmd="${command}"]\x1b[0m\n`,
98
- stderr: boot.stderr || '',
99
- spawnedPid: spawned.pid,
83
+ exitCode: result.exitCode,
84
+ stdout: result.stdout,
85
+ stderr: result.stderr || result.error || '',
100
86
  };
101
87
  };
102
88
  }
@@ -205,6 +191,19 @@ export function buildRubySocketProcessWorker(preamble) {
205
191
  ' return true;',
206
192
  '};',
207
193
  '',
194
+ // What the process writes goes out as it is written: to the command that
195
+ // launched it while that command waits, to the process log after. One
196
+ // write at a time, in order; the runner's own markers are not output.
197
+ 'globalThis.__nimbusRubyEmitChain = globalThis.__nimbusRubyEmitChain || Promise.resolve();',
198
+ 'globalThis.__nimbusRubyEmit = function __nimbusRubyEmit(stream, text) {',
199
+ ' const supervisor = globalThis.__nimbusRubySupervisor;',
200
+ ' if (!supervisor) return;',
201
+ ' const clean = String(text).replace(/__NIMBUS_RESUMED_(true|false)_[^\\n]*\\n?/g, "").replace(/__NIMBUS_RUBY_EXIT_-?\\d+\\n?/g, "");',
202
+ ' if (!clean) return;',
203
+ ' const bytes = new TextEncoder().encode(clean);',
204
+ ' globalThis.__nimbusRubyEmitChain = globalThis.__nimbusRubyEmitChain.then(() => supervisor[stream](bytes)).catch(() => {});',
205
+ '};',
206
+ '',
208
207
  'async function __nimbusStartRubyProcess(args) {',
209
208
  ' if (!globalThis.__nimbusRubyProcessPromise) {',
210
209
  ' const stdoutStart = (globalThis.__nimbusRubyStdout || []).length;',
@@ -223,18 +222,20 @@ export function buildRubySocketProcessWorker(preamble) {
223
222
  ' });',
224
223
  ' }',
225
224
  ' const started = globalThis.__nimbusRubyProcessOutputStart || { stdoutStart: 0, stderrStart: 0 };',
226
- ' const listen = globalThis.__nimbusVirtualSockets.waitForListen(10_000).then((port) => ({ state: port ? "listening" : "pending", port }));',
225
+ // No deadline: a server reports once it binds, however long its requires take.
226
+ ' const listen = globalThis.__nimbusVirtualSockets.waitForListen().then((port) => ({ state: "listening", port }));',
227
227
  ' const exit = globalThis.__nimbusRubyProcessPromise.then((result) => ({ state: "exited", result }));',
228
228
  ' const first = await Promise.race([listen, exit]);',
229
229
  ' const registrations = globalThis.__nimbusVirtualPortRegistrationPromises || [];',
230
230
  ' if (registrations.length > 0) await Promise.allSettled(registrations.splice(0));',
231
- ' const stdout = (globalThis.__nimbusRubyStdout || []).slice(started.stdoutStart).join("");',
232
- ' const stderr = (globalThis.__nimbusRubyStderr || []).slice(started.stderrStart).join("");',
231
+ // Streamed already, so the answer carries none of it.
232
+ ' await globalThis.__nimbusRubyEmitChain;',
233
+ ' const streamed = !!globalThis.__nimbusRubySupervisor;',
234
+ ' const stdout = streamed ? "" : (globalThis.__nimbusRubyStdout || []).slice(started.stdoutStart).join("");',
235
+ ' const stderr = streamed ? "" : (globalThis.__nimbusRubyStderr || []).slice(started.stderrStart).join("");',
233
236
  ' if (first.state === "listening") return { state: "listening", port: first.port, stdout, stderr };',
234
- ' if (first.state === "exited") return { state: "exited", result: first.result, stdout, stderr };',
235
- ' const currentPort = globalThis.__nimbusVirtualSockets.firstListeningPort();',
236
- ' if (currentPort) return { state: "listening", port: currentPort, stdout, stderr };',
237
- ' return { state: "running", stdout, stderr };',
237
+ ' const result = streamed ? { ...first.result, stdout: "", stderr: "" } : first.result;',
238
+ ' return { state: "exited", result, stdout, stderr };',
238
239
  '}',
239
240
  '',
240
241
  // Only adopt a real binding: routed handleHttpRequest/fetch hops resolve
@@ -53,6 +53,7 @@ type R2BucketLike = {
53
53
  get(key: string): Promise<{
54
54
  arrayBuffer(): Promise<ArrayBuffer>;
55
55
  text(): Promise<string>;
56
+ readonly body: ReadableStream<Uint8Array>;
56
57
  } | null>;
57
58
  } | null | undefined;
58
59
  /** Minimal env shape this module consumes. */
@@ -95,15 +96,21 @@ export declare function fetchCatalog(env: RuntimeCatalogEnv): Promise<RuntimeCat
95
96
  */
96
97
  export declare function fetchManifest(env: RuntimeCatalogEnv, entry: CatalogVersionEntry): Promise<RuntimeManifest>;
97
98
  /**
98
- * Fetch the blob a manifest file entry points at, verified against the
99
- * digest that same entry carries.
99
+ * Stream the blob a manifest file entry points at, verified against the
100
+ * digest that same entry carries: from the colo cache when it has it, else
101
+ * from R2, read once either way. The stream errors at its end, rather than
102
+ * closing, with a {@link RuntimeBlobDigestMismatch} when its bytes do not
103
+ * hash to the digest; a colo-cache entry that fails is evicted and
104
+ * distrusted first, so the installer's second read of that blob comes from
105
+ * R2 whatever the cache holds by then. The installer commits
106
+ * a blob only after that clean close, so no step holds a blob whole.
100
107
  *
101
108
  * The digest is not optional and does not travel separately from the key:
102
109
  * a `ManifestFile` always has both, and it is the only thing this takes.
103
110
  * Blobs are interpreters, so an unverified read here is arbitrary code
104
111
  * execution in whichever session installs it.
105
112
  */
106
- export declare function fetchBlob(env: RuntimeCatalogEnv, file: ManifestFile): Promise<Uint8Array>;
113
+ export declare function fetchBlob(env: RuntimeCatalogEnv, file: ManifestFile): Promise<ReadableStream<Uint8Array>>;
107
114
  export declare function runtimeAbiForCatalogName(name: string): RuntimePackageAbi;
108
115
  /**
109
116
  * The R2 catalog as a core `RuntimeSource` — the worker adapter half of the
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-catalog.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAKH,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,eAAe,EACrB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,yCAAyC,CAAC;AAEjD,2CAA2C;AAC3C,KAAK,YAAY,GAAG;IAClB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;QACxB,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;QACpC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;KACzB,GAAG,IAAI,CAAC,CAAC;CACX,GAAG,IAAI,GAAG,SAAS,CAAC;AAErB,8CAA8C;AAC9C,MAAM,WAAW,iBAAiB;IAChC,oBAAoB,CAAC,EAAE,YAAY,CAAC;CACrC;AAID,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB;2EACuE;IACvE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;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;IAC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