@nimbus-sh/worker 0.2.0 → 0.2.1

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 (63) hide show
  1. package/dist/facets/manager.d.ts +47 -2
  2. package/dist/facets/manager.d.ts.map +1 -1
  3. package/dist/facets/manager.js +139 -15
  4. package/dist/runtime/bash-repl.d.ts +1 -1
  5. package/dist/runtime/bash-repl.d.ts.map +1 -1
  6. package/dist/runtime/bash-repl.js +3 -2
  7. package/dist/runtime/clang-runner.d.ts +1 -1
  8. package/dist/runtime/clang-runner.d.ts.map +1 -1
  9. package/dist/runtime/cpython-resident.d.ts +27 -0
  10. package/dist/runtime/cpython-resident.d.ts.map +1 -0
  11. package/dist/runtime/cpython-resident.js +133 -0
  12. package/dist/runtime/facet-loader-host.d.ts +15 -1
  13. package/dist/runtime/facet-loader-host.d.ts.map +1 -1
  14. package/dist/runtime/facet-loader-host.js +41 -0
  15. package/dist/runtime/package-manager.d.ts +3 -58
  16. package/dist/runtime/package-manager.d.ts.map +1 -1
  17. package/dist/runtime/package-manager.js +6 -143
  18. package/dist/runtime/python-repl.d.ts +1 -1
  19. package/dist/runtime/python-repl.d.ts.map +1 -1
  20. package/dist/runtime/python-repl.js +2 -2
  21. package/dist/runtime/ruby-runner.d.ts +1 -1
  22. package/dist/runtime/ruby-runner.d.ts.map +1 -1
  23. package/dist/runtime/ruby-runner.js +1 -1
  24. package/dist/runtime/runtime-catalog.d.ts +4 -80
  25. package/dist/runtime/runtime-catalog.d.ts.map +1 -1
  26. package/dist/runtime/runtime-catalog.js +4 -67
  27. package/dist/session/init.d.ts.map +1 -1
  28. package/dist/session/init.js +29 -41
  29. package/dist/session/keys.d.ts +13 -0
  30. package/dist/session/keys.d.ts.map +1 -1
  31. package/dist/session/keys.js +13 -0
  32. package/dist/session/nimbus-session.d.ts +19 -1
  33. package/dist/session/nimbus-session.d.ts.map +1 -1
  34. package/dist/session/nimbus-session.js +36 -1
  35. package/dist/session/programmatic.d.ts +2 -2
  36. package/dist/session/programmatic.d.ts.map +1 -1
  37. package/dist/session/programmatic.js +2 -1
  38. package/dist/session/supervisor-rpc.d.ts +6 -13
  39. package/dist/session/supervisor-rpc.d.ts.map +1 -1
  40. package/dist/session/supervisor-rpc.js +7 -17
  41. package/package.json +2 -2
  42. package/scripts/bundle-facet-workers.mjs +5 -5
  43. package/dist/runtime/bash-runner.d.ts +0 -63
  44. package/dist/runtime/bash-runner.d.ts.map +0 -1
  45. package/dist/runtime/bash-runner.generated.d.ts +0 -14
  46. package/dist/runtime/bash-runner.generated.d.ts.map +0 -1
  47. package/dist/runtime/bash-runner.generated.js +0 -13
  48. package/dist/runtime/bash-runner.js +0 -291
  49. package/dist/runtime/cpython-runner.d.ts +0 -71
  50. package/dist/runtime/cpython-runner.d.ts.map +0 -1
  51. package/dist/runtime/cpython-runner.js +0 -535
  52. package/dist/runtime/python-pip.d.ts +0 -38
  53. package/dist/runtime/python-pip.d.ts.map +0 -1
  54. package/dist/runtime/python-pip.js +0 -1063
  55. package/dist/runtime/runtime-registry.d.ts +0 -162
  56. package/dist/runtime/runtime-registry.d.ts.map +0 -1
  57. package/dist/runtime/runtime-registry.js +0 -364
  58. package/dist/runtime/virtual-socket-kernel.generated.d.ts +0 -14
  59. package/dist/runtime/virtual-socket-kernel.generated.d.ts.map +0 -1
  60. package/dist/runtime/virtual-socket-kernel.generated.js +0 -13
  61. package/dist/runtime/wasm-runner.d.ts +0 -70
  62. package/dist/runtime/wasm-runner.d.ts.map +0 -1
  63. package/dist/runtime/wasm-runner.js +0 -664
@@ -573,6 +573,16 @@ export interface FacetManagerHooks {
573
573
  * a fresh CPU budget, and a launch needs each for a different reason.
574
574
  */
575
575
  requestLaunchTurn?: () => void;
576
+ /**
577
+ * Put a line in front of the user, whether or not a terminal is attached.
578
+ *
579
+ * Distinct from writing to a process's output: what this reports happened to
580
+ * the SESSION, and the socket that would have shown it is typically the one
581
+ * the event destroyed. The session satisfies it with the live terminal when
582
+ * there is one and the persisted scrollback when there is not, so the line
583
+ * survives until someone reconnects to read it.
584
+ */
585
+ notify?: (line: string) => void;
576
586
  }
577
587
  export interface LongRunningWorkerSpawnOptions {
578
588
  port?: number;
@@ -634,10 +644,14 @@ export declare class FacetManager {
634
644
  *
635
645
  * In-memory on purpose: a launch is only meaningful while the process table
636
646
  * entry it is building for exists, and both are lost together if the isolate
637
- * resets. Persisting the queue would resurrect launches for pids that no
638
- * longer exist.
647
+ * resets. What survives a reset is the journal, which names the launch's
648
+ * INPUTS rather than its position — a resumed queue would be resurrecting
649
+ * half-built work for pids that no longer exist, where re-driving a launch
650
+ * from its inputs is the same idempotent work again.
639
651
  */
640
652
  private launchWaiters;
653
+ /** Whether this instance has already read the journal a reset leaves behind. */
654
+ private launchesRecovered;
641
655
  private timedOutProcessIds;
642
656
  private _pairedServeFacet;
643
657
  /**
@@ -979,6 +993,31 @@ export declare class FacetManager {
979
993
  * the runtime may tear the context down mid-chunk.
980
994
  */
981
995
  pumpResidentLaunches(): Promise<void>;
996
+ /**
997
+ * Re-drive the launches a previous instance was building when it was reset.
998
+ *
999
+ * The platform resets a session Durable Object over what one turn has
1000
+ * outstanding in storage ("Internal error in Durable Object storage caused
1001
+ * object to be reset"), and a launch is the largest writer this session has.
1002
+ * Everything the launch held was in memory, so the process it was building
1003
+ * and the terminal watching it both went with the instance, and until now
1004
+ * the user was told nothing at all.
1005
+ *
1006
+ * Sited on the pump because the pump is what an alarm calls, and a launch
1007
+ * that was suspended has an alarm armed for it — a reset during a chunk
1008
+ * fails that alarm, and the platform re-delivers it to the instance that
1009
+ * replaces this one. So the first turn after a reset is already this one.
1010
+ *
1011
+ * Runs once per instance: the journal only changes when a launch of THIS
1012
+ * instance starts or settles, and those are rows this instance wrote.
1013
+ */
1014
+ private _recoverInterruptedLaunches;
1015
+ /**
1016
+ * Record a launch as in flight, so an instance that replaces this one knows
1017
+ * it never finished. Best-effort: a launch that cannot be journalled still
1018
+ * runs, and a reset then costs exactly what it cost before the journal.
1019
+ */
1020
+ private _journalLaunch;
982
1021
  /** Whether any launch is suspended waiting for a turn. */
983
1022
  get hasPendingLaunchTurns(): boolean;
984
1023
  /** Allocate a free loopback port for a resident server facet (from 4096 up). */
@@ -1024,6 +1063,12 @@ export declare class FacetManager {
1024
1063
  spawnNode(code: string, opts?: ResidentSpawnOptions): Promise<{
1025
1064
  pid: number;
1026
1065
  }>;
1066
+ /**
1067
+ * `attempt` distinguishes the launch the user asked for from the one re-drive
1068
+ * an instance reset earns it, and is carried in the journal rather than in
1069
+ * the caller's options because no caller has an opinion about it.
1070
+ */
1071
+ private _spawnResident;
1027
1072
  /**
1028
1073
  * Build and boot a resident process across as many turns as it takes.
1029
1074
  *
@@ -1 +1 @@
1
- {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/facets/manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,uDAAuD,CAAC;AAUjG,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAE7F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAM7E,OAAO,EAAE,WAAW,EAAiD,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAI5E,OAAO,EAOL,KAAK,kBAAkB,EAIxB,MAAM,8BAA8B,CAAC;AAMtC,OAAO,EAEL,KAAK,qBAAqB,EAE3B,MAAM,qCAAqC,CAAC;AAG7C,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,2CAA2C,CAAC;AAenD,6CAA6C;AAC7C,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,C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AAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;IA2D1C,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAM7C,qBAAqB,CACnB,GAAG,EAAE,MAAM,EACX,SAAS,SAAmC,GAC3C,OAAO,CAAC,MAAM,EAAE,CAAC;IAIpB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAW,GAAG,IAAI;IAYrE,qCAAqC;IACrC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAc1B,IAAI,KAAK;;;;;;MAAmC;CAC7C"}
@@ -37,7 +37,8 @@ import { createLoadedWorkerEntrypoint, getNimbusCtxExports, } from '../loaders/w
37
37
  import { SQLITE_WASM_MODULE_NAME, } from '../runtime/opencode-facet-runner.js';
38
38
  import { parsePortFromArgv, resolveLongRunningPort } from '@nimbus-sh/core/runtime/long-running-handle.js';
39
39
  import { DEFAULT_FACET_BUNDLE_PROFILE, } from '@nimbus-sh/core/runtime/bundle-profile.js';
40
- import { BUNDLE_BUILD_DEADLINE_MS, CF_COMPAT_DATE, FACET_TIMEOUT_MS, VFS_BUNDLE_MAX_FILES, VFS_BUNDLE_MAX_BYTES, CWD_SNAPSHOT_MAX_FILE_BYTES, BUNDLE_MAX_ENCODED_BYTES, MAX_RPC_SAFE_PAYLOAD_BYTES, PREFETCH_CACHE_MAX_BYTES, } from '@nimbus-sh/core/constants.js';
40
+ import { BUNDLE_BUILD_DEADLINE_MS, CF_COMPAT_DATE, CHUNK_SIZE, FACET_TIMEOUT_MS, VFS_BUNDLE_MAX_FILES, VFS_BUNDLE_MAX_BYTES, CWD_SNAPSHOT_MAX_FILE_BYTES, BUNDLE_MAX_ENCODED_BYTES, MAX_RPC_SAFE_PAYLOAD_BYTES, MAX_TX_BLOB_BYTES, PREFETCH_CACHE_MAX_BYTES, } from '@nimbus-sh/core/constants.js';
41
+ import { RESIDENT_LAUNCH_KEY_PREFIX } from '../session/keys.js';
41
42
  import { CRED_KERNEL } from '@nimbus-sh/core/runtime/os-contracts.js';
42
43
  import { acquireSupervisorAllocation } from '@nimbus-sh/core/observability/heavy-alloc-coord.js';
43
44
  import { prefetchBundleStart, prefetchBundleEnd, setPrefetchCacheBytes, } from '@nimbus-sh/core/observability/diag-counters.js';
@@ -3146,6 +3147,19 @@ async function _buildPrefetchBundle(vfs, scriptPath, cwd, entryCode, esbuild, bu
3146
3147
  };
3147
3148
  }
3148
3149
  const ROUTEABLE_PORT_ATTACH_TIMEOUT_MS = 1_000;
3150
+ /**
3151
+ * Bytes of an image written in one storage transaction.
3152
+ *
3153
+ * The bound is the VFS's own, not a knob: a `writeRange` whose chunks fit
3154
+ * inside one transaction is committed in place, and one that does not falls
3155
+ * back to copy-on-write — which rewrites every chunk of the file, per slice,
3156
+ * making a sliced write quadratic in its size. A whole number of chunks is
3157
+ * the other half of that: a slice that ends mid-chunk makes the next one read
3158
+ * the partial chunk back to complete it.
3159
+ */
3160
+ const FACET_IMAGE_WRITE_SLICE_BYTES = Math.floor(MAX_TX_BLOB_BYTES / CHUNK_SIZE) * CHUNK_SIZE;
3161
+ /** A launch is re-driven once. A reset that recurs is not the transient one. */
3162
+ const RESIDENT_LAUNCH_MAX_ATTEMPT = 1;
3149
3163
  export class FacetManager {
3150
3164
  ctx;
3151
3165
  env;
@@ -3176,10 +3190,14 @@ export class FacetManager {
3176
3190
  *
3177
3191
  * In-memory on purpose: a launch is only meaningful while the process table
3178
3192
  * entry it is building for exists, and both are lost together if the isolate
3179
- * resets. Persisting the queue would resurrect launches for pids that no
3180
- * longer exist.
3193
+ * resets. What survives a reset is the journal, which names the launch's
3194
+ * INPUTS rather than its position — a resumed queue would be resurrecting
3195
+ * half-built work for pids that no longer exist, where re-driving a launch
3196
+ * from its inputs is the same idempotent work again.
3181
3197
  */
3182
3198
  launchWaiters = [];
3199
+ /** Whether this instance has already read the journal a reset leaves behind. */
3200
+ launchesRecovered = false;
3183
3201
  timedOutProcessIds = new Set();
3184
3202
  // attach-pid → serve-pid: the resident serve facet a bare-`opencode` dual
3185
3203
  // spawn created as an OS-child of the attach TUI. When the attach process
@@ -4180,8 +4198,7 @@ export class FacetManager {
4180
4198
  const path = facetImagePath(await facetImageDigest(source));
4181
4199
  images[moduleName] = path;
4182
4200
  sources.set(path, source);
4183
- if (pacer)
4184
- await pacer.spend(source.length);
4201
+ await pacer.spend(source.length);
4185
4202
  }
4186
4203
  // Register the WHOLE root set here, in one synchronous step, before any
4187
4204
  // byte of it exists on disk. That ordering is the entire protocol between
@@ -4196,15 +4213,32 @@ export class FacetManager {
4196
4213
  for (const [path, source] of sources) {
4197
4214
  const stored = path.replace(/^\/+/, '');
4198
4215
  const bytes = new TextEncoder().encode(source);
4199
- // A whole-file write is atomic against the DO's single thread, so an
4200
- // image already present at the right size cannot be a torn one, and
4201
- // rewriting it would only cost the disk. Size is enough of a check here
4216
+ // An image at its full size is a COMPLETE one: a write only ever grows
4217
+ // the file from offset zero, so a write cut short by a reset leaves a
4218
+ // strictly shorter file and fails this test. Size is enough of a check
4202
4219
  // because the reader verifies the digest before the loader sees it.
4203
- if (!(fs.exists(stored) && fs.lstat(stored).size === bytes.byteLength)) {
4204
- fs.writeFile(stored, bytes, { mode: 0o644 });
4205
- }
4206
- if (pacer)
4220
+ if (fs.exists(stored) && fs.lstat(stored).size === bytes.byteLength) {
4207
4221
  await pacer.spend(bytes.byteLength);
4222
+ continue;
4223
+ }
4224
+ // Sliced because the platform resets the object over what ONE TURN has
4225
+ // outstanding, not over what it eventually writes — pi's 22.9 MB map
4226
+ // went in as a single write and took the session down with it ~25% of
4227
+ // the time. Spending between slices is what puts the rest of the image
4228
+ // on later turns; the slice bound is what keeps any one of them small.
4229
+ let offset = 0;
4230
+ do {
4231
+ const slice = bytes.subarray(offset, offset + FACET_IMAGE_WRITE_SLICE_BYTES);
4232
+ // The first slice REPLACES the file, so an interrupted write's remains
4233
+ // are truncated to a known length rather than left as a tail past this
4234
+ // content — and the mode is chosen here, at creation, as POSIX has it.
4235
+ if (offset === 0)
4236
+ fs.writeFile(stored, slice, { mode: 0o644 });
4237
+ else
4238
+ fs.writeRange(stored, offset, slice);
4239
+ offset += slice.byteLength;
4240
+ await pacer.spend(slice.byteLength);
4241
+ } while (offset < bytes.byteLength);
4208
4242
  }
4209
4243
  this._sweepFacetImages(fs);
4210
4244
  return images;
@@ -4318,6 +4352,7 @@ export class FacetManager {
4318
4352
  * the runtime may tear the context down mid-chunk.
4319
4353
  */
4320
4354
  async pumpResidentLaunches() {
4355
+ await this._recoverInterruptedLaunches();
4321
4356
  const waiting = this.launchWaiters;
4322
4357
  if (waiting.length === 0)
4323
4358
  return;
@@ -4326,6 +4361,70 @@ export class FacetManager {
4326
4361
  waiter.resume();
4327
4362
  await Promise.all(waiting.map((waiter) => waiter.chunkEnded));
4328
4363
  }
4364
+ /**
4365
+ * Re-drive the launches a previous instance was building when it was reset.
4366
+ *
4367
+ * The platform resets a session Durable Object over what one turn has
4368
+ * outstanding in storage ("Internal error in Durable Object storage caused
4369
+ * object to be reset"), and a launch is the largest writer this session has.
4370
+ * Everything the launch held was in memory, so the process it was building
4371
+ * and the terminal watching it both went with the instance, and until now
4372
+ * the user was told nothing at all.
4373
+ *
4374
+ * Sited on the pump because the pump is what an alarm calls, and a launch
4375
+ * that was suspended has an alarm armed for it — a reset during a chunk
4376
+ * fails that alarm, and the platform re-delivers it to the instance that
4377
+ * replaces this one. So the first turn after a reset is already this one.
4378
+ *
4379
+ * Runs once per instance: the journal only changes when a launch of THIS
4380
+ * instance starts or settles, and those are rows this instance wrote.
4381
+ */
4382
+ async _recoverInterruptedLaunches() {
4383
+ if (this.launchesRecovered)
4384
+ return;
4385
+ this.launchesRecovered = true;
4386
+ const journal = await this.ctx.storage.list({
4387
+ prefix: RESIDENT_LAUNCH_KEY_PREFIX,
4388
+ });
4389
+ for (const [key, record] of journal) {
4390
+ // A pid at or below this instance's base was allocated by a PREVIOUS one
4391
+ // (process-table.ts, PID_GEN_STRIDE), so its launch never finished; above
4392
+ // the base is this instance's own, still running. Same predicate as
4393
+ // `session/rpc.ts` uses to attribute a prior generation's pid.
4394
+ if (!(record.pid > 0 && record.pid <= this.processes.pidBase))
4395
+ continue;
4396
+ await this.ctx.storage.delete(key);
4397
+ if (record.attempt >= RESIDENT_LAUNCH_MAX_ATTEMPT) {
4398
+ this.hooks.notify?.('\x1b[2m[nimbus: the session restarted again while '
4399
+ + `"${record.command}" was starting — leaving it stopped]\x1b[0m\r\n`);
4400
+ continue;
4401
+ }
4402
+ this.hooks.notify?.('\x1b[2m[nimbus: the session restarted while '
4403
+ + `"${record.command}" was starting — restarting it]\x1b[0m\r\n`);
4404
+ // Not awaited: this call is running inside the alarm that granted the
4405
+ // turn, and the launch it starts asks for turns of its own through that
4406
+ // same alarm — awaiting it here would be waiting on an alarm that cannot
4407
+ // be scheduled until this one returns.
4408
+ this.ctx.waitUntil(this._spawnResident(record.code, record.opts, record.attempt + 1)
4409
+ .catch((e) => {
4410
+ this.hooks.notify?.(`\x1b[2m[nimbus: "${record.command}" could not be restarted: `
4411
+ + `${errorMessage(e)}]\x1b[0m\r\n`);
4412
+ }));
4413
+ }
4414
+ }
4415
+ /**
4416
+ * Record a launch as in flight, so an instance that replaces this one knows
4417
+ * it never finished. Best-effort: a launch that cannot be journalled still
4418
+ * runs, and a reset then costs exactly what it cost before the journal.
4419
+ */
4420
+ async _journalLaunch(record) {
4421
+ try {
4422
+ await this.ctx.storage.put(`${RESIDENT_LAUNCH_KEY_PREFIX}${record.pid}`, record);
4423
+ }
4424
+ catch (e) {
4425
+ console.warn('[nimbus] resident launch journal write failed:', errorMessage(e));
4426
+ }
4427
+ }
4329
4428
  /** Whether any launch is suspended waiting for a turn. */
4330
4429
  get hasPendingLaunchTurns() {
4331
4430
  return this.launchWaiters.length > 0;
@@ -4501,7 +4600,15 @@ export class FacetManager {
4501
4600
  * is the largest thing Nimbus generates, so it travels by VFS path rather
4502
4601
  * than inside the boot spec and is read only when the facet loads.
4503
4602
  */
4504
- async spawnNode(code, opts = {}) {
4603
+ spawnNode(code, opts = {}) {
4604
+ return this._spawnResident(code, opts, 0);
4605
+ }
4606
+ /**
4607
+ * `attempt` distinguishes the launch the user asked for from the one re-drive
4608
+ * an instance reset earns it, and is carried in the journal rather than in
4609
+ * the caller's options because no caller has an opinion about it.
4610
+ */
4611
+ async _spawnResident(code, opts, attempt) {
4505
4612
  this.processes.reap();
4506
4613
  const command = opts.command || (opts.filename ? `node ${opts.filename}` : 'node <script>');
4507
4614
  const cwd = opts.cwd || '/home/user';
@@ -4525,7 +4632,7 @@ export class FacetManager {
4525
4632
  }
4526
4633
  catch { }
4527
4634
  }
4528
- const launch = this._runResidentLaunch(entry, code, command, opts);
4635
+ const launch = this._runResidentLaunch(entry, code, command, opts, attempt);
4529
4636
  if (!opts.attachedTty) {
4530
4637
  // A server's caller is told a port is bound, so it has to wait for the
4531
4638
  // boot that binds it. The wait costs this turn nothing: every chunk of
@@ -4555,14 +4662,31 @@ export class FacetManager {
4555
4662
  * terminal WebSocket needs to survive a launch, and what no amount of making
4556
4663
  * the launch faster would have given it.
4557
4664
  */
4558
- async _runResidentLaunch(entry, code, command, opts) {
4665
+ async _runResidentLaunch(entry, code, command, opts, attempt) {
4559
4666
  const cwd = opts.cwd || '/home/user';
4560
4667
  const pacer = new LaunchPacer(this.launchScheduler, launchChunkMaxBytes(this.env), () => this._assertLaunchStillOwned(entry.pid));
4668
+ // Journalled before the first byte of work and removed when the launch
4669
+ // settles either way, so a row that outlives its instance means one thing:
4670
+ // the launch was still running when the object was reset. A re-drive owns
4671
+ // its own process, so the caller's pid goes with the instance that had it.
4672
+ await this._journalLaunch({
4673
+ pid: entry.pid,
4674
+ command,
4675
+ code,
4676
+ opts: { ...opts, skipSpawn: undefined, callerPid: undefined },
4677
+ attempt,
4678
+ });
4561
4679
  try {
4562
4680
  await this._residentLaunchBody(entry, code, command, cwd, opts, pacer);
4563
4681
  }
4564
4682
  finally {
4565
4683
  pacer.settle();
4684
+ try {
4685
+ await this.ctx.storage.delete(`${RESIDENT_LAUNCH_KEY_PREFIX}${entry.pid}`);
4686
+ }
4687
+ catch (e) {
4688
+ console.warn('[nimbus] resident launch journal delete failed:', errorMessage(e));
4689
+ }
4566
4690
  }
4567
4691
  }
4568
4692
  async _residentLaunchBody(entry, code, command, cwd, opts, pacer) {
@@ -3,7 +3,7 @@ import type { WebSocketTerminal } from '../facets/ws-terminal.js';
3
3
  import type { SqliteVFS } from '@nimbus-sh/core/vfs/sqlite-vfs.js';
4
4
  import type { Shell } from '@nimbus-sh/core/substrate/lifo/shell/Shell.js';
5
5
  import type { VfsCred } from '@nimbus-sh/core/runtime/os-contracts.js';
6
- import type { RuntimeManifest } from './runtime-catalog.js';
6
+ import type { RuntimeManifest } from '@nimbus-sh/core/runtime/runtime-manifest.js';
7
7
  export interface BashReplDeps {
8
8
  facetMgr: FacetManager;
9
9
  vfs: SqliteVFS;
@@ -1 +1 @@
1
- {"version":3,"file":"bash-repl.d.ts","sourceRoot":"","sources":["../../src/runtime/bash-repl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+CAA+C,CAAC;AAE3E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAS5D,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,YAAY,CAAC;IACvB,GAAG,EAAE,SAAS,CAAC;IACf,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ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  import { formatShellPrompt } from '@nimbus-sh/core/substrate/lifo/shell/Shell.js';
2
- import { createBashFacetSession } from './bash-runner.js';
2
+ import { createBashFacetSession } from '@nimbus-sh/core/runtime/bash-runner.js';
3
+ import { facetHostForManager } from './facet-loader-host.js';
3
4
  import { ReplSession, } from './repl-session.js';
4
5
  class BashReplAdapter {
5
6
  deps;
@@ -49,7 +50,7 @@ class BashReplAdapter {
49
50
  if (this.session)
50
51
  return null;
51
52
  this.session = await createBashFacetSession({
52
- facetMgr: this.deps.facetMgr,
53
+ facets: facetHostForManager(this.deps.facetMgr),
53
54
  vfs: this.deps.vfs.as(this.deps.cred),
54
55
  manifest: this.deps.manifest,
55
56
  installRoot: this.deps.installRoot,
@@ -25,7 +25,7 @@
25
25
  * Dispatch stays direct: no sleeps, no caller-side retries, and no
26
26
  * catch-and-continue around loader failures.
27
27
  */
28
- import type { RuntimeManifest } from './runtime-catalog.js';
28
+ import type { RuntimeManifest } from '@nimbus-sh/core/runtime/runtime-manifest.js';
29
29
  import type { SqliteVFS } from '@nimbus-sh/core/vfs/sqlite-vfs.js';
30
30
  import type { FacetManager } from '../facets/manager.js';
31
31
  /** Build the runner factory. Closes over facetMgr + vfs. */
@@ -1 +1 @@
1
- {"version":3,"file":"clang-runner.d.ts","sourceRoot":"","sources":["../../src/runtime/clang-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AASzD,4DAA4D;AAC5D,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,QAAQ,EAAE,YAAY,CAAC;IACvB,GAAG,EAAE,SAAS,CAAC;CAChB,GAAG,CAAC,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,KAC7F,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,CAkThC;AAyjBD,eAAO,MAAM,qBAAqB,QAAiE,CAAC"}
1
+ {"version":3,"file":"clang-runner.d.ts","sourceRoot":"","sources":["../../src/runtime/clang-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AASzD,4DAA4D;AAC5D,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,QAAQ,EAAE,YAAY,CAAC;IACvB,GAAG,EAAE,SAAS,CAAC;CAChB,GAAG,CAAC,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,KAC7F,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,CAkThC;AAyjBD,eAAO,MAAM,qBAAqB,QAAiE,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * cpython-resident.ts — a Python program that keeps serving, as a Durable
3
+ * Object facet.
4
+ *
5
+ * The half of the CPython runtime that names workerd. Everything about running
6
+ * the interpreter is in `@nimbus-sh/core`; this is the substrate a program that
7
+ * outlives its invocation needs — an actor that stays alive between requests,
8
+ * with inbound HTTP routed into the socket the program bound. A host without
9
+ * one supplies no {@link CPythonResidentStart} and such a program is refused
10
+ * rather than quietly run as a one-shot that dies with the call.
11
+ */
12
+ import { type CPythonResidentStart } from '@nimbus-sh/core/runtime/cpython-runner.js';
13
+ import type { FacetManager } from '../facets/manager.js';
14
+ /**
15
+ * The worker source for a resident Python process. Same shape as
16
+ * buildRubySocketProcessWorker: the socket kernel and the interpreter live in a
17
+ * DurableObject, startProcess runs the program until it stops, and inbound
18
+ * requests arrive on handleHttpRequest and are dispatched into the server the
19
+ * program registered before exiting.
20
+ */
21
+ export declare function buildCPythonSocketProcessWorker(preamble: string): string;
22
+ /**
23
+ * Start a program that binds a port as its own process, so it outlives the
24
+ * invocation that started it. Mirrors spawnRubySocketProcess.
25
+ */
26
+ export declare function cpythonResidentStart(facetMgr: FacetManager): CPythonResidentStart;
27
+ //# sourceMappingURL=cpython-resident.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cpython-resident.d.ts","sourceRoot":"","sources":["../../src/runtime/cpython-resident.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAwDxE;AAeD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,YAAY,GAAG,oBAAoB,CA8CjF"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * cpython-resident.ts — a Python program that keeps serving, as a Durable
3
+ * Object facet.
4
+ *
5
+ * The half of the CPython runtime that names workerd. Everything about running
6
+ * the interpreter is in `@nimbus-sh/core`; this is the substrate a program that
7
+ * outlives its invocation needs — an actor that stays alive between requests,
8
+ * with inbound HTTP routed into the socket the program bound. A host without
9
+ * one supplies no {@link CPythonResidentStart} and such a program is refused
10
+ * rather than quietly run as a one-shot that dies with the call.
11
+ */
12
+ import { z } from 'zod/v4';
13
+ import { buildCPythonPreamble, } from '@nimbus-sh/core/runtime/cpython-runner.js';
14
+ /**
15
+ * The worker source for a resident Python process. Same shape as
16
+ * buildRubySocketProcessWorker: the socket kernel and the interpreter live in a
17
+ * DurableObject, startProcess runs the program until it stops, and inbound
18
+ * requests arrive on handleHttpRequest and are dispatched into the server the
19
+ * program registered before exiting.
20
+ */
21
+ export function buildCPythonSocketProcessWorker(preamble) {
22
+ return [
23
+ 'import { DurableObject } from "cloudflare:workers";',
24
+ // The module arrives by path (vfsWasmModules) and has to be published where
25
+ // the preamble looks for it. Without this the facet boots and the first
26
+ // thing it says is "python.wasm was not supplied to this facet".
27
+ "import __NIMBUS_WASM_python from './python.wasm';",
28
+ 'globalThis.__NIMBUS_WASM = globalThis.__NIMBUS_WASM || {};',
29
+ "globalThis.__NIMBUS_WASM['python.wasm'] = __NIMBUS_WASM_python;",
30
+ '',
31
+ preamble,
32
+ '',
33
+ // Only adopt a real binding: routed fetch hops resolve the entrypoint
34
+ // without a supervisor, and overwriting with undefined would drop the live
35
+ // stub the process needs for its whole lifetime.
36
+ 'function __nimbusAdoptPySupervisor(env) {',
37
+ ' const supervisor = env && env.SUPERVISOR;',
38
+ ' if (supervisor) globalThis.__nimbusPySupervisor = supervisor;',
39
+ ' __wasiAdoptSupervisor(supervisor);',
40
+ '}',
41
+ // A resident process answers between requests, and that is the only moment
42
+ // "durable while running" can be made true: by the time the caller holds a
43
+ // response, everything the request wrote has reached the VFS.
44
+ 'async function __nimbusParkPy(value) {',
45
+ ' await __wasiDrainPersist();',
46
+ ' await __wasiRevalidateFS();',
47
+ ' return value;',
48
+ '}',
49
+ 'async function __nimbusStartPyProcess(args) {',
50
+ ' const result = await globalThis.__cpythonStartProcess(args || {});',
51
+ ' const ports = await globalThis.__cpythonListeningPorts();',
52
+ ' const registrations = globalThis.__nimbusVirtualPortRegistrationPromises || [];',
53
+ ' if (registrations.length > 0) await Promise.allSettled(registrations.splice(0));',
54
+ ' if (ports.length > 0) {',
55
+ ' return { state: "listening", port: ports[0], stdout: result.stdout, stderr: result.stderr };',
56
+ ' }',
57
+ ' return { state: "exited", result, stdout: result.stdout, stderr: result.stderr };',
58
+ '}',
59
+ 'export class NimbusProcess extends DurableObject {',
60
+ ' async startProcess(args) {',
61
+ ' __nimbusAdoptPySupervisor(this.env);',
62
+ ' return __nimbusParkPy(await __nimbusStartPyProcess(args || {}));',
63
+ ' }',
64
+ ' async fetch(request) {',
65
+ ' __nimbusAdoptPySupervisor(this.env);',
66
+ ' return this.handleHttpRequest(request);',
67
+ ' }',
68
+ ' async handleHttpRequest(request) {',
69
+ ' __nimbusAdoptPySupervisor(this.env);',
70
+ ' const hinted = Number(request.headers.get("X-Nimbus-Port") || 0);',
71
+ ' const port = hinted || Array.from(globalThis.__nimbusVirtualSockets.listeners.keys())[0];',
72
+ ' if (!port) return new Response("Nimbus Python process has no listening virtual socket", { status: 502 });',
73
+ ' return __nimbusParkPy(await globalThis.__nimbusVirtualSockets.handleHttpRequest(port, request));',
74
+ ' }',
75
+ '}',
76
+ ].join('\n');
77
+ }
78
+ const CPythonBootSchema = z.object({
79
+ state: z.string().optional(),
80
+ port: z.number().optional(),
81
+ stdout: z.string().optional(),
82
+ stderr: z.string().optional(),
83
+ result: z.object({ exitCode: z.number().optional() }).passthrough().optional(),
84
+ }).passthrough();
85
+ /**
86
+ * Start a program that binds a port as its own process, so it outlives the
87
+ * invocation that started it. Mirrors spawnRubySocketProcess.
88
+ */
89
+ export function cpythonResidentStart(facetMgr) {
90
+ return async function startResidentCPython(args) {
91
+ const command = args.command;
92
+ const workerCode = buildCPythonSocketProcessWorker(buildCPythonPreamble());
93
+ const spawned = await facetMgr.spawnWorker(workerCode, command, args.cwd, {
94
+ compatibilityFlags: ['nodejs_compat'],
95
+ // By path, not by value: the interpreter is 10.6 MiB, more than a single
96
+ // RPC value may carry, so whichever host runs this process reads it itself.
97
+ vfsWasmModules: { 'python.wasm': args.wasmVfsPath },
98
+ startArgs: args.startArgs,
99
+ }).catch(() => null);
100
+ if (!spawned)
101
+ return { exitCode: 1, stdout: '', stderr: 'python process boot failed\n' };
102
+ const boot = CPythonBootSchema.safeParse(spawned.boot);
103
+ if (!boot.success) {
104
+ facetMgr.finishProcess(spawned.pid, 1, 'python process boot failed');
105
+ return { exitCode: 1, stdout: '', stderr: 'python process boot failed\n' };
106
+ }
107
+ const data = boot.data;
108
+ if (data.state === 'listening' && typeof data.port === 'number' && data.port > 0) {
109
+ facetMgr.registerPort(spawned.pid, data.port);
110
+ const routeable = await facetMgr.waitForRouteablePorts(spawned.pid);
111
+ const port = routeable.includes(data.port) ? data.port : routeable[0];
112
+ if (!port) {
113
+ facetMgr.kill(spawned.pid);
114
+ return {
115
+ exitCode: 1,
116
+ stdout: data.stdout || '',
117
+ stderr: `${data.stderr || ''}python: virtual socket port ${data.port} failed to attach a route handler\n`,
118
+ };
119
+ }
120
+ return {
121
+ exitCode: 0,
122
+ stdout: `${data.stdout || ''}\x1b[2m[started (long-running): pid=${spawned.pid} cmd="${command}" port=${port}]\x1b[0m\n`,
123
+ stderr: data.stderr || '',
124
+ spawnedPid: spawned.pid,
125
+ port,
126
+ };
127
+ }
128
+ const result = data.result;
129
+ const exitCode = typeof result?.exitCode === 'number' ? result.exitCode : 0;
130
+ facetMgr.finishProcess(spawned.pid, exitCode, data.stderr || 'python process exited');
131
+ return { exitCode, stdout: data.stdout || '', stderr: data.stderr || '' };
132
+ };
133
+ }
@@ -1,3 +1,16 @@
1
+ /**
2
+ * The workerd {@link FacetHost}: a facet is a dynamic worker.
3
+ *
4
+ * The whole adapter is the option rename below, because `NimbusLoaderPool`
5
+ * already IS the port's shape — `submit` and `dispose`, with the same meanings.
6
+ * The one thing it spells differently is the supervisor capability, which it
7
+ * takes as a pid plus a separate flag saying whether to bind one at all; the
8
+ * port collapses the pair, since a facet with the binding and no pid can read
9
+ * the session and never write to it.
10
+ */
11
+ import type { FacetHost } from '@nimbus-sh/core/runtime/facet-host.js';
12
+ import type { FacetManager } from '../facets/manager.js';
13
+ export declare function loaderFacetHost(env: unknown, ctx: DurableObjectState): FacetHost;
1
14
  /**
2
15
  * The two objects a NimbusLoaderPool needs from a FacetManager.
3
16
  *
@@ -7,9 +20,10 @@
7
20
  * checked here once, and a FacetManager built on something other than a
8
21
  * DurableObjectState fails with a sentence instead of at the first RPC.
9
22
  */
10
- import type { FacetManager } from '../facets/manager.js';
11
23
  export declare function getFacetManagerLoaderHost(facetMgr: FacetManager): {
12
24
  env: unknown;
13
25
  ctx: DurableObjectState;
14
26
  };
27
+ /** The facet host a runtime reached through a FacetManager runs on. */
28
+ export declare function facetHostForManager(facetMgr: FacetManager): FacetHost;
15
29
  //# sourceMappingURL=facet-loader-host.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"facet-loader-host.d.ts","sourceRoot":"","sources":["../../src/runtime/facet-loader-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,YAAY,GACrB;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,kBAAkB,CAAA;CAAE,CAO3C"}
1
+ {"version":3,"file":"facet-loader-host.d.ts","sourceRoot":"","sources":["../../src/runtime/facet-loader-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAIV,SAAS,EAEV,MAAM,uCAAuC,CAAC;AAG/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,kBAAkB,GAAG,SAAS,CA4BhF;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,YAAY,GACrB;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,kBAAkB,CAAA;CAAE,CAO3C;AAED,uEAAuE;AACvE,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAGrE"}