@nimbus-sh/worker 0.5.0 → 0.7.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 (164) hide show
  1. package/README.md +2 -2
  2. package/dist/_shared/preview-host.d.ts +26 -8
  3. package/dist/_shared/preview-host.d.ts.map +1 -1
  4. package/dist/_shared/preview-host.js +51 -11
  5. package/dist/cirrus-npm-cjs.generated.d.ts +1 -1
  6. package/dist/cirrus-npm-cjs.generated.js +1 -1
  7. package/dist/facets/cirrus-real.d.ts.map +1 -1
  8. package/dist/facets/cirrus-real.js +6 -5
  9. package/dist/facets/compose.d.ts +148 -0
  10. package/dist/facets/compose.d.ts.map +1 -0
  11. package/dist/facets/compose.js +146 -0
  12. package/dist/facets/durable-images.d.ts +18 -5
  13. package/dist/facets/durable-images.d.ts.map +1 -1
  14. package/dist/facets/durable-images.js +36 -7
  15. package/dist/facets/durable-slots.d.ts +1 -1
  16. package/dist/facets/durable-slots.d.ts.map +1 -1
  17. package/dist/facets/durable-slots.js +2 -1
  18. package/dist/facets/esbuild-bundle-pool.d.ts +49 -0
  19. package/dist/facets/esbuild-bundle-pool.d.ts.map +1 -0
  20. package/dist/facets/esbuild-bundle-pool.js +122 -0
  21. package/dist/facets/exec-telemetry.d.ts +8 -0
  22. package/dist/facets/exec-telemetry.d.ts.map +1 -1
  23. package/dist/facets/manager.d.ts +337 -123
  24. package/dist/facets/manager.d.ts.map +1 -1
  25. package/dist/facets/manager.js +1100 -449
  26. package/dist/facets/process.d.ts +20 -16
  27. package/dist/facets/process.d.ts.map +1 -1
  28. package/dist/facets/process.js +59 -28
  29. package/dist/facets/real-vite-fs-shim.js +2 -2
  30. package/dist/facets/resident-identity.d.ts +23 -0
  31. package/dist/facets/resident-identity.d.ts.map +1 -0
  32. package/dist/facets/resident-identity.js +31 -0
  33. package/dist/facets/vite-dev-server.d.ts +25 -47
  34. package/dist/facets/vite-dev-server.d.ts.map +1 -1
  35. package/dist/facets/vite-dev-server.js +185 -219
  36. package/dist/facets/wasm-image-digest.d.ts +25 -0
  37. package/dist/facets/wasm-image-digest.d.ts.map +1 -0
  38. package/dist/facets/wasm-image-digest.js +25 -0
  39. package/dist/facets/wasm-swap-registry.d.ts +51 -92
  40. package/dist/facets/wasm-swap-registry.d.ts.map +1 -1
  41. package/dist/facets/wasm-swap-registry.js +68 -227
  42. package/dist/git/commands.d.ts +0 -1
  43. package/dist/git/commands.d.ts.map +1 -1
  44. package/dist/git/commands.js +0 -3
  45. package/dist/git/network-facet.d.ts.map +1 -1
  46. package/dist/git/network-facet.js +6 -5
  47. package/dist/loaders/child-process/spawn-pool.d.ts +3 -2
  48. package/dist/loaders/child-process/spawn-pool.d.ts.map +1 -1
  49. package/dist/loaders/child-process/spawn-pool.js +3 -2
  50. package/dist/loaders/generated-workers.d.ts +2 -2
  51. package/dist/loaders/generated-workers.d.ts.map +1 -1
  52. package/dist/loaders/generated-workers.js +3 -3
  53. package/dist/loaders/npm-resolve-preamble.d.ts +3 -6
  54. package/dist/loaders/npm-resolve-preamble.d.ts.map +1 -1
  55. package/dist/loaders/npm-resolve-preamble.js +34 -108
  56. package/dist/node-shims-artifact.generated.js +3 -3
  57. package/dist/npm/install-batch-facet.d.ts +3 -2
  58. package/dist/npm/install-batch-facet.d.ts.map +1 -1
  59. package/dist/npm/install-batch-facet.js +45 -15
  60. package/dist/npm/installer.d.ts +22 -17
  61. package/dist/npm/installer.d.ts.map +1 -1
  62. package/dist/npm/installer.js +209 -193
  63. package/dist/npm/pre-bundle-facet.d.ts +1 -1
  64. package/dist/npm/pre-bundle-facet.d.ts.map +1 -1
  65. package/dist/npm/pre-bundle-facet.js +1 -1
  66. package/dist/npm/resolve-facet.d.ts +6 -0
  67. package/dist/npm/resolve-facet.d.ts.map +1 -1
  68. package/dist/npm/resolve-one-facet.d.ts +21 -20
  69. package/dist/npm/resolve-one-facet.d.ts.map +1 -1
  70. package/dist/npm/resolve-one-facet.js +85 -84
  71. package/dist/npm/semver.d.ts +59 -0
  72. package/dist/npm/semver.d.ts.map +1 -0
  73. package/dist/npm/semver.js +226 -0
  74. package/dist/router/index.d.ts.map +1 -1
  75. package/dist/router/index.js +47 -10
  76. package/dist/router/public-directory.d.ts +5 -1
  77. package/dist/router/public-directory.d.ts.map +1 -1
  78. package/dist/router/public-directory.js +9 -2
  79. package/dist/router/remote-api.d.ts +18 -0
  80. package/dist/router/remote-api.d.ts.map +1 -1
  81. package/dist/router/remote-api.js +64 -5
  82. package/dist/runtime/cpython-resident.d.ts.map +1 -1
  83. package/dist/runtime/cpython-resident.js +3 -1
  84. package/dist/runtime/html-entrypoint.d.ts +7 -0
  85. package/dist/runtime/html-entrypoint.d.ts.map +1 -1
  86. package/dist/runtime/html-entrypoint.js +18 -2
  87. package/dist/runtime/node-runner.d.ts +3 -0
  88. package/dist/runtime/node-runner.d.ts.map +1 -1
  89. package/dist/runtime/node-runner.js +7 -0
  90. package/dist/runtime/node-shims.d.ts.map +1 -1
  91. package/dist/runtime/node-shims.js +305 -29
  92. package/dist/runtime/opencode-facet-runner.js +2 -2
  93. package/dist/runtime/package-manager.d.ts +44 -1
  94. package/dist/runtime/package-manager.d.ts.map +1 -1
  95. package/dist/runtime/package-manager.js +168 -3
  96. package/dist/runtime/ruby-resident.d.ts.map +1 -1
  97. package/dist/runtime/ruby-resident.js +2 -0
  98. package/dist/session/agent.d.ts.map +1 -1
  99. package/dist/session/agent.js +28 -1
  100. package/dist/session/helpers.d.ts +38 -0
  101. package/dist/session/helpers.d.ts.map +1 -1
  102. package/dist/session/helpers.js +76 -0
  103. package/dist/session/init-phases.d.ts +1 -1
  104. package/dist/session/init-phases.d.ts.map +1 -1
  105. package/dist/session/init-phases.js +2 -12
  106. package/dist/session/init.d.ts +15 -1
  107. package/dist/session/init.d.ts.map +1 -1
  108. package/dist/session/init.js +91 -603
  109. package/dist/session/keys.d.ts +4 -0
  110. package/dist/session/keys.d.ts.map +1 -1
  111. package/dist/session/keys.js +4 -0
  112. package/dist/session/nimbus-session.d.ts +90 -23
  113. package/dist/session/nimbus-session.d.ts.map +1 -1
  114. package/dist/session/nimbus-session.js +200 -110
  115. package/dist/session/npm-install-port.d.ts +16 -0
  116. package/dist/session/npm-install-port.d.ts.map +1 -0
  117. package/dist/session/npm-install-port.js +37 -0
  118. package/dist/session/port-capability.d.ts +90 -0
  119. package/dist/session/port-capability.d.ts.map +1 -1
  120. package/dist/session/port-capability.js +219 -9
  121. package/dist/session/programmatic.d.ts +125 -5
  122. package/dist/session/programmatic.d.ts.map +1 -1
  123. package/dist/session/programmatic.js +439 -89
  124. package/dist/session/routes.d.ts +39 -17
  125. package/dist/session/routes.d.ts.map +1 -1
  126. package/dist/session/routes.js +67 -131
  127. package/dist/session/rpc.d.ts +39 -16
  128. package/dist/session/rpc.d.ts.map +1 -1
  129. package/dist/session/rpc.js +137 -130
  130. package/dist/session/serving-port.d.ts +27 -0
  131. package/dist/session/serving-port.d.ts.map +1 -0
  132. package/dist/session/serving-port.js +27 -0
  133. package/dist/session/start-real-vite.d.ts +12 -0
  134. package/dist/session/start-real-vite.d.ts.map +1 -1
  135. package/dist/session/start-real-vite.js +4 -4
  136. package/dist/session/supervisor-op.d.ts +41 -4
  137. package/dist/session/supervisor-op.d.ts.map +1 -1
  138. package/dist/session/supervisor-op.js +101 -73
  139. package/dist/session/supervisor-rpc.d.ts +7 -7
  140. package/dist/session/supervisor-rpc.d.ts.map +1 -1
  141. package/dist/session/supervisor-rpc.js +6 -3
  142. package/dist/session/vite-command.d.ts +18 -0
  143. package/dist/session/vite-command.d.ts.map +1 -0
  144. package/dist/session/vite-command.js +609 -0
  145. package/dist/session/ws.d.ts +61 -0
  146. package/dist/session/ws.d.ts.map +1 -1
  147. package/dist/session/ws.js +122 -12
  148. package/dist/shell/npm-bin-entrypoints.d.ts +0 -35
  149. package/dist/shell/npm-bin-entrypoints.d.ts.map +1 -1
  150. package/dist/shell/npm-bin-entrypoints.js +12 -85
  151. package/package.json +24 -4
  152. package/public/_assets/runtime/{node-shims-9e1380d9ee430fcc.js → node-shims-8f8c64edd2a1f0f5.js} +305 -29
  153. package/public/index.html +1 -1
  154. package/scripts/bundle-facet-workers.mjs +1 -1
  155. package/scripts/bundle-npm-cjs.mjs +2 -2
  156. package/dist/facets/on-demand-bundle-gate.d.ts +0 -65
  157. package/dist/facets/on-demand-bundle-gate.d.ts.map +0 -1
  158. package/dist/facets/on-demand-bundle-gate.js +0 -125
  159. package/dist/npm/install-args.d.ts +0 -21
  160. package/dist/npm/install-args.d.ts.map +0 -1
  161. package/dist/npm/install-args.js +0 -70
  162. package/dist/npm/npm-log.d.ts +0 -31
  163. package/dist/npm/npm-log.d.ts.map +0 -1
  164. package/dist/npm/npm-log.js +0 -51
@@ -22,7 +22,7 @@ import { CirrusReal } from '../facets/cirrus-real.js';
22
22
  import { makeLongRunningPortStub } from '@nimbus-sh/core/runtime/long-running-handle.js';
23
23
  import { acquireHeavyAlloc } from '@nimbus-sh/platform/heavy-alloc-coord.js';
24
24
  import { VITE_CONFIG_KEY } from './keys.js';
25
- import { clearPortCapability } from './port-capability.js';
25
+ import { registerServingPort } from './serving-port.js';
26
26
  /**
27
27
  * Boot a cirrus-real dev server on `self`, register its port, and persist the
28
28
  * config restore needs. `self` is the session host (RoutesHost/InitHost = any).
@@ -103,7 +103,7 @@ export async function startRealVite(self, opts) {
103
103
  });
104
104
  self.cirrusReal = cirrusReal;
105
105
  // Reserve a PID so `ps`/logs show it like any other facet.
106
- const entry = self.processes.spawn('vite (real, ' + opts.root + ')', [], opts.root, { longRunning: true });
106
+ const entry = self.processes.spawn('vite (real, ' + opts.root + ')', opts.identity?.argv ?? [], opts.identity?.cwd ?? opts.root, { longRunning: true });
107
107
  // start() is async — it ASSETS-fetches the Vite/plugin-react bundles on
108
108
  // first invocation (cached per-isolate after).
109
109
  await cirrusReal.start(self.ctx, entry.pid);
@@ -111,8 +111,7 @@ export async function startRealVite(self, opts) {
111
111
  // only difference is which handler.handleRequest the stub forwards into.
112
112
  const cirrusStub = makeLongRunningPortStub(cirrusReal);
113
113
  self.portRegistry.bindFacetStub(entry.pid, cirrusStub);
114
- await clearPortCapability(self, opts.port);
115
- self.portRegistry.register(opts.port, entry.pid);
114
+ await registerServingPort(self, entry.pid, opts.port);
116
115
  self._viteShimPid = entry.pid;
117
116
  self._viteShimPort = opts.port;
118
117
  // Persist so the session recovers after hibernation — same key the shim
@@ -125,6 +124,7 @@ export async function startRealVite(self, opts) {
125
124
  port: opts.port,
126
125
  basePath: opts.basePath,
127
126
  configDir: opts.configDir,
127
+ identity: { cwd: entry.cwd, argv: entry.argv },
128
128
  });
129
129
  }
130
130
  catch { /* persistence is best-effort; the server still serves now */ }
@@ -1,5 +1,42 @@
1
- import type { SupervisorOpEnvelope } from '@nimbus-sh/core/workspace/supervisor-op.js';
2
- import type { NimbusSession } from './nimbus-session.js';
3
- /** Preserve hosted accounting and lifecycle work behind the shared host seam. */
4
- export declare function sessionSupervisorOp(host: NimbusSession, envelope: SupervisorOpEnvelope): Promise<unknown>;
1
+ /**
2
+ * The session's supervisor-op handler — one `createSupervisorOpHandler`
3
+ * built over this session's own SQLite filesystem, process table and `_rpc*`
4
+ * surface, so the same code serves process facets, the facet loopback stubs
5
+ * and the SDK's direct `_rpc*` calls.
6
+ *
7
+ * - The native filesystem ops in core's `ops` table run in-process against
8
+ * the shared bridge store — the same cache `supervisorBridge` hands the
9
+ * handle-based and append RPC bodies.
10
+ * - `readFile`, `readFileBytes`, `fsReadRange`, `fsReadRangeUncached` and
11
+ * `writeBatchStream` are overridden here, not replaced: they are the ops
12
+ * that carry this DO's heap accounting (read-allocation leases, the
13
+ * write-stream's decode-drain timestamp).
14
+ * - Every other named op dispatches through `SUPERVISOR_OP_ROUTES` to the
15
+ * session's `_rpc*` methods — `host` IS the session — exactly as the
16
+ * canonical route table maps them.
17
+ */
18
+ import { type SupervisorOpBridgeStore, type SupervisorOpEnvelope } from '@nimbus-sh/core/workspace/supervisor-op.js';
19
+ import type { SqliteRuntimeFsBridge } from '@nimbus-sh/core/runtime/sqlite-runtime-fs-bridge.js';
20
+ import type { SqliteVFS } from '@nimbus-sh/core/vfs/sqlite-vfs.js';
21
+ import type { SessionProcessSupervisor } from '@nimbus-sh/core/runtime/session-process-supervisor.js';
22
+ /**
23
+ * The supervisor surface a session exposes to the handler: the `_rpc*`
24
+ * methods SUPERVISOR_OP_ROUTES can name plus the filesystem and process
25
+ * accessors the overrides read. Deliberately not an index-signature record —
26
+ * a class can't carry one, and the handler only ever reads named routes.
27
+ */
28
+ export interface SessionSupervisorHost {
29
+ ensureSqliteFs(): void;
30
+ readonly sqliteFs: SqliteVFS | null;
31
+ readonly processes: SessionProcessSupervisor;
32
+ _rpcStdout(pid: number, data: Uint8Array): Promise<void>;
33
+ _rpcStderr(pid: number, data: Uint8Array): Promise<void>;
34
+ }
35
+ export interface SessionSupervisorOps {
36
+ readonly dispatch: (envelope: SupervisorOpEnvelope) => Promise<unknown>;
37
+ readonly bridge: (pid?: number) => SqliteRuntimeFsBridge;
38
+ /** Drop a pid's bridge — a process exit ends its credential's validity. */
39
+ readonly forget: (pid: number) => void;
40
+ }
41
+ export declare function buildSessionSupervisorOps(host: SessionSupervisorHost, store?: SupervisorOpBridgeStore): SessionSupervisorOps;
5
42
  //# sourceMappingURL=supervisor-op.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"supervisor-op.d.ts","sourceRoot":"","sources":["../../src/session/supervisor-op.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAuEzD,iFAAiF;AACjF,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,aAAa,EACnB,QAAQ,EAAE,oBAAoB,GAC7B,OAAO,CAAC,OAAO,CAAC,CASlB"}
1
+ {"version":3,"file":"supervisor-op.d.ts","sourceRoot":"","sources":["../../src/session/supervisor-op.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAI1B,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AACjG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uDAAuD,CAAC;AAQtG;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,cAAc,IAAI,IAAI,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,wBAAwB,CAAC;IAC7C,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D;AACD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACxE,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,qBAAqB,CAAC;IACzD,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAQD,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,qBAAqB,EAC3B,KAAK,CAAC,EAAE,uBAAuB,GAC9B,oBAAoB,CA8EtB"}
@@ -1,74 +1,102 @@
1
- // Only named supervisor operations are callable; no RPC name comes from input.
2
- const routes = {
3
- readFile: { method: '_rpcReadFile', args: [0, 'pid'] },
4
- readFileBytes: { method: '_rpcReadFileBytes', args: [0, 'pid'] },
5
- writeFile: { method: '_rpcWriteFile', args: [0, 1, 'pid'] },
6
- stat: { method: '_rpcStat', args: [0, 'pid'] },
7
- lstat: { method: '_rpcLstat', args: [0, 'pid'] },
8
- hasLegacySymlinkUnder: { method: '_rpcHasLegacySymlinkUnder', args: [0, 'pid'] },
9
- utimes: { method: '_rpcUtimes', args: [0, 1, 2, 'pid'] },
10
- chmod: { method: '_rpcChmod', args: [0, 1, 'pid'] },
11
- access: { method: '_rpcAccess', args: [0, 1, 'pid'] },
12
- chown: { method: '_rpcChown', args: [0, 1, 2, 'pid', 3] },
13
- setUmask: { method: '_rpcSetUmask', args: [0, 'pid'] },
14
- readdir: { method: '_rpcReaddir', args: [0, 'pid'] },
15
- exists: { method: '_rpcExists', args: [0, 'pid'] },
16
- mkdir: { method: '_rpcMkdir', args: [0, 'pid'] },
17
- rmdir: { method: '_rpcRmdir', args: [0, 'pid'] },
18
- rename: { method: '_rpcRename', args: [0, 1, 'pid'] },
19
- unlink: { method: '_rpcUnlink', args: [0, 'pid'] },
20
- readlink: { method: '_rpcReadlink', args: [0, 'pid'] },
21
- symlink: { method: '_rpcSymlink', args: [0, 1, 'pid'] },
22
- fsAcquire: { method: '_rpcFsAcquire', args: [0, 1, 'pid'] },
23
- fsRevision: { method: '_rpcFsRevision', args: [0, 'pid'] },
24
- fsList: { method: '_rpcFsList', args: [0, 1, 'pid'] },
25
- wsOpen: { method: '_rpcWsOpen', args: [0, 1, 'pid'] },
26
- wsPoll: { method: '_rpcWsPoll', args: [0, 1, 'pid'] },
27
- wsSend: { method: '_rpcWsSend', args: [0, 1, 2, 'pid'] },
28
- wsClose: { method: '_rpcWsClose', args: [0, 1, 2, 'pid'] },
29
- fsOpen: { method: '_rpcFsOpen', args: [0, 1, 'pid'] },
30
- fsRead: { method: '_rpcFsRead', args: [0, 1, 2, 'pid'] },
31
- fsWrite: { method: '_rpcFsWrite', args: [0, 1, 2, 'pid'] },
32
- fsClose: { method: '_rpcFsClose', args: [0, 'pid'] },
33
- fsReadRange: { method: '_rpcFsReadRange', args: [0, 1, 2, 'pid'] },
34
- fsReadRangeUncached: { method: '_rpcFsReadRangeUncached', args: [0, 1, 2, 'pid'] },
35
- fsReadBatch: { method: '_rpcFsReadBatch', args: [0, 'pid'] },
36
- fsWriteRange: { method: '_rpcFsWriteRange', args: [0, 1, 2, 'pid'] },
37
- fsAppend: { method: '_rpcFsAppend', args: [0, 'writerId', 1, 2, 3, 'pid'] },
38
- fsAppendAck: { method: '_rpcFsAppendAck', args: [0, 1, 2, 'pid'] },
39
- fsTruncate: { method: '_rpcFsTruncate', args: [0, 1, 'pid'] },
40
- writeBatch: { method: '_rpcWriteBatch', args: [0, 'pid'] },
41
- writeBatchStream: { method: '_rpcWriteBatchStream', args: ['stream', 'mutationOwner', 'pid'] },
42
- putRegistryEntries: { method: '_rpcPutRegistryEntries', args: [0] },
43
- stdout: { method: '_rpcStdout', args: ['pid', 0] },
44
- stderr: { method: '_rpcStderr', args: ['pid', 0] },
45
- reportExit: { method: '_rpcReportExit', args: ['pid', 0, 1] },
46
- prefetch: { method: '_rpcPrefetch', args: [0, 1] },
47
- registerPort: { method: '_rpcRegisterPort', args: ['pid', 0] },
48
- ensureDurableApp: { method: '_rpcEnsureDurableApp', args: [0] },
49
- removeDurableApp: { method: '_rpcRemoveDurableApp', args: [0] },
50
- unregisterPort: { method: '_rpcUnregisterPort', args: [0] },
51
- routeLoopback: { method: '_rpcRouteLoopback', args: [0, 1] },
52
- transform: { method: '_rpcTransform', args: [0, 1] },
53
- cpSpawn: { method: '_rpcCpSpawn', args: [0] },
54
- cpStdinWrite: { method: '_rpcCpStdinWrite', args: [0, 1] },
55
- cpStdinEnd: { method: '_rpcCpStdinEnd', args: [0] },
56
- cpReadStdin: { method: '_rpcCpReadStdin', args: [0, 1] },
57
- cpReadOutput: { method: '_rpcCpReadOutput', args: [0, 1, 2, 3] },
58
- cpDrainOutput: { method: '_rpcCpDrainOutput', args: [0] },
59
- cpKill: { method: '_rpcCpKill', args: [0, 1] },
60
- cpWait: { method: '_rpcCpWait', args: [0, 1] },
61
- cpDispatchInline: { method: '_rpcCpDispatchInline', args: [0, 1] },
62
- };
63
- /** Preserve hosted accounting and lifecycle work behind the shared host seam. */
64
- export async function sessionSupervisorOp(host, envelope) {
65
- if (!envelope || typeof envelope.op !== 'string' || !Object.hasOwn(routes, envelope.op)) {
66
- throw new Error(`supervisor op: '${envelope?.op}' is not served by this host`);
67
- }
68
- const route = routes[envelope.op];
69
- const args = route.args.map((slot) => typeof slot === 'number' ? envelope.args?.[slot] : envelope[slot]);
70
- const method = host[route.method];
71
- if (typeof method !== 'function')
72
- throw new Error(`supervisor op: missing host method ${route.method}`);
73
- return Reflect.apply(method, host, args);
1
+ /**
2
+ * The session's supervisor-op handler — one `createSupervisorOpHandler`
3
+ * built over this session's own SQLite filesystem, process table and `_rpc*`
4
+ * surface, so the same code serves process facets, the facet loopback stubs
5
+ * and the SDK's direct `_rpc*` calls.
6
+ *
7
+ * - The native filesystem ops in core's `ops` table run in-process against
8
+ * the shared bridge store — the same cache `supervisorBridge` hands the
9
+ * handle-based and append RPC bodies.
10
+ * - `readFile`, `readFileBytes`, `fsReadRange`, `fsReadRangeUncached` and
11
+ * `writeBatchStream` are overridden here, not replaced: they are the ops
12
+ * that carry this DO's heap accounting (read-allocation leases, the
13
+ * write-stream's decode-drain timestamp).
14
+ * - Every other named op dispatches through `SUPERVISOR_OP_ROUTES` to the
15
+ * session's `_rpc*` methods — `host` IS the session — exactly as the
16
+ * canonical route table maps them.
17
+ */
18
+ import { createSupervisorOpHandler, createSupervisorBridgeStore, } from '@nimbus-sh/core/workspace/supervisor-op.js';
19
+ import { FsReadRangeArgsSchema, rangeReadBytes, withReadAllocation, } from './rpc.js';
20
+ import { dec } from '@nimbus-sh/core/_shared/bytes.js';
21
+ /** The stdout/stderr ops carry bytes; anything else is a caller bug, named. */
22
+ function outputBytesArg(value) {
23
+ if (value instanceof Uint8Array)
24
+ return value;
25
+ throw new Error(`supervisor op stdout/stderr: expected bytes, got ${typeof value}`);
26
+ }
27
+ export function buildSessionSupervisorOps(host, store) {
28
+ host.ensureSqliteFs();
29
+ store ??= createSupervisorBridgeStore({ vfs: host.sqliteFs, processes: host.processes });
30
+ const extend = {
31
+ // The native ops whose session bodies carry accounting the bridge
32
+ // alone doesn't know: a read lease sized to what the file can return.
33
+ readFile: async (envelope, tools) => {
34
+ const path = envelope.args?.[0];
35
+ const fs = tools.bridge(envelope.pid, envelope.cred);
36
+ const stat = await fs.stat(path);
37
+ if (!stat)
38
+ return null;
39
+ return withReadAllocation(stat.size, async () => {
40
+ const bytes = await fs.readFile(path);
41
+ return bytes ? dec.decode(bytes) : null;
42
+ });
43
+ },
44
+ readFileBytes: async (envelope, tools) => {
45
+ const path = envelope.args?.[0];
46
+ const fs = tools.bridge(envelope.pid, envelope.cred);
47
+ const stat = await fs.stat(path);
48
+ if (!stat)
49
+ return null;
50
+ return withReadAllocation(stat.size, () => fs.readFile(path));
51
+ },
52
+ fsReadRange: async (envelope, tools) => {
53
+ const args = FsReadRangeArgsSchema.parse({
54
+ path: envelope.args?.[0],
55
+ offset: envelope.args?.[1],
56
+ length: envelope.args?.[2],
57
+ });
58
+ const fs = tools.bridge(envelope.pid, envelope.cred);
59
+ return withReadAllocation(await rangeReadBytes(fs, args.path, args.offset, args.length), () => fs.readRange(args.path, args.offset, args.length));
60
+ },
61
+ fsReadRangeUncached: async (envelope, tools) => {
62
+ const args = FsReadRangeArgsSchema.parse({
63
+ path: envelope.args?.[0],
64
+ offset: envelope.args?.[1],
65
+ length: envelope.args?.[2],
66
+ });
67
+ const fs = tools.bridge(envelope.pid, envelope.cred);
68
+ return withReadAllocation(await rangeReadBytes(fs, args.path, args.offset, args.length), () => fs.readRange(args.path, args.offset, args.length, { cached: false }));
69
+ },
70
+ // The write stream's decode-drain timestamp starts when the envelope
71
+ // arrives, not when the DO first reads it — the same contract
72
+ // _rpcWriteBatchStream has always had.
73
+ writeBatchStream: (envelope, tools) => {
74
+ if (!envelope.stream)
75
+ throw new Error('supervisor op writeBatchStream: no stream');
76
+ // Same contract _rpcWriteBatchStream had: a supplied pid must be a
77
+ // real process pid; only an absent pid is a host call.
78
+ const pid = envelope.pid;
79
+ if (pid !== undefined && (!Number.isInteger(pid) || pid <= 0)) {
80
+ throw new Error('filesystem RPC requires a valid process pid');
81
+ }
82
+ return tools.vfs.as(tools.cred(pid, envelope.cred)).writeStream(envelope.stream, {
83
+ decodeDrainStartedAt: performance.now(),
84
+ mutationOwner: envelope.mutationOwner,
85
+ });
86
+ },
87
+ // stdout/stderr are session methods, not bridge ops: mirroring,
88
+ // log-append and prior-generation filtering all live in _rpcStdout.
89
+ stdout: (envelope) => host._rpcStdout(envelope.pid ?? 0, outputBytesArg(envelope.args?.[0])),
90
+ stderr: (envelope) => host._rpcStderr(envelope.pid ?? 0, outputBytesArg(envelope.args?.[0])),
91
+ };
92
+ const dispatch = createSupervisorOpHandler({
93
+ vfs: host.sqliteFs,
94
+ processes: host.processes,
95
+ // The session IS the host — its _rpc* methods are the route table's
96
+ // targets. The index signature exists on the declared surface only.
97
+ host: host,
98
+ bridge: store,
99
+ extend,
100
+ });
101
+ return { dispatch, bridge: store.bridge, forget: store.forget };
74
102
  }
@@ -274,8 +274,8 @@ export declare class SupervisorRPC extends WorkerEntrypoint {
274
274
  }): Promise<PackumentReadThrough & {
275
275
  events: SupervisorCacheStatEvent[];
276
276
  }>;
277
- stdout(data: string): Promise<void>;
278
- stderr(data: string): Promise<void>;
277
+ stdout(data: Uint8Array): Promise<void>;
278
+ stderr(data: Uint8Array): Promise<void>;
279
279
  /**
280
280
  * Report process exit to the supervisor. Called from the facet's own
281
281
  * `finally` block after I/O has drained. The supervisor uses this to
@@ -309,12 +309,12 @@ export declare class SupervisorRPC extends WorkerEntrypoint {
309
309
  cpSpawn(req: any): Promise<{
310
310
  childPid: number;
311
311
  }>;
312
- cpStdinWrite(childPid: number, data: string): Promise<{
312
+ cpStdinWrite(childPid: number, data: Uint8Array): Promise<{
313
313
  ok: boolean;
314
314
  }>;
315
315
  cpStdinEnd(childPid: number): Promise<void>;
316
316
  cpReadStdin(childPid: number, waitMs: number): Promise<{
317
- data: string;
317
+ data: Uint8Array;
318
318
  ended: boolean;
319
319
  resize?: {
320
320
  columns: number;
@@ -325,14 +325,14 @@ export declare class SupervisorRPC extends WorkerEntrypoint {
325
325
  cpReadOutput(childPid: number, fd: 1 | 2, sinceSeq: number, waitMs: number): Promise<{
326
326
  chunks: {
327
327
  seq: number;
328
- data: string;
328
+ data: Uint8Array;
329
329
  }[];
330
330
  closed: boolean;
331
331
  maxSeq: number;
332
332
  }>;
333
333
  cpDrainOutput(childPid: number): Promise<{
334
- stdout: string;
335
- stderr: string;
334
+ stdout: Uint8Array;
335
+ stderr: Uint8Array;
336
336
  stdoutClosed: boolean;
337
337
  stderrClosed: boolean;
338
338
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"supervisor-rpc.d.ts","sourceRoot":"","sources":["../../src/session/supervisor-rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAStD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAUrE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAEnF;;;;;;;GAOG;AACH,MAAM,MAAM,wBAAwB,GAChC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAA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320
320
  return this._call(this._op('fsAppend', [path, moduleId, operationId, bytes], { pid: this._pid(), writerId: this._writerId() }));
321
321
  }
322
322
  async fsAppendAck(moduleId, operationId) {
323
- return this._call(this._fsOp('fsAppendAck', [this._writerId(), moduleId, operationId]));
323
+ return this._call(this._op('fsAppendAck', [moduleId, operationId], { pid: this._pid(), writerId: this._writerId() }));
324
324
  }
325
325
  async fsTruncate(path, size) {
326
326
  return this._call(this._fsOp('fsTruncate', [path, size]));
@@ -497,6 +497,10 @@ export class SupervisorRPC extends WorkerEntrypoint {
497
497
  return { ...result, events: _drainCacheEvents(r2) };
498
498
  }
499
499
  // ── Process I/O ───────────────────────────────────────────────────────
500
+ //
501
+ // A process's stdio is bytes end to end: stdout/stderr up, cpStdinWrite
502
+ // down, cpReadStdin/cpReadOutput/cpDrainOutput in a child's direction. A
503
+ // text producer encodes at its own edge; a text consumer decodes at its.
500
504
  async stdout(data) {
501
505
  return this._call(this._op('stdout', [data], { pid: this._reportingPid() }));
502
506
  }
@@ -513,8 +517,7 @@ export class SupervisorRPC extends WorkerEntrypoint {
513
517
  * via __pendingIO first).
514
518
  */
515
519
  async reportExit(code, tail) {
516
- const pid = this.ctx.props?.pid || 0;
517
- return this._call(this._op('reportExit', [code, tail || ''], { pid }));
520
+ return this._call(this._op('reportExit', [code, tail || ''], { pid: this._reportingPid() }));
518
521
  }
519
522
  // ── Prefetch ──────────────────────────────────────────────────────────
520
523
  async prefetch(cwd, entryCode) {
@@ -0,0 +1,18 @@
1
+ /**
2
+ * session/vite-command.ts — the `vite` builtin command.
3
+ *
4
+ * Extracted from init.ts so the handler can be driven through the
5
+ * command registry in unit tests — the module's only session coupling
6
+ * is `self`, the same InitHost view initSession passes to every other
7
+ * registration.
8
+ *
9
+ * Subcommands: `vite` (dev server), `vite build`, `vite preview`,
10
+ * `vite stop`. Build honours build.outDir with Vite parity: output
11
+ * writes to the resolved path, only an outDir strictly inside the
12
+ * project root is emptied first, and the bundle is validated before
13
+ * old output is cleared.
14
+ */
15
+ type ViteHost = any;
16
+ export declare function createViteCommand(self: ViteHost): (ctx: any) => Promise<number>;
17
+ export {};
18
+ //# sourceMappingURL=vite-command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-command.d.ts","sourceRoot":"","sources":["../../src/session/vite-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAyBH,KAAK,QAAQ,GAAG,GAAG,CAAC;AAEpB,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,IAChC,KAAK,GAAG,KAAG,OAAO,CAAC,MAAM,CAAC,CAmlBzC"}