@nimbus-sh/worker 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -43
- package/dist/_shared/preview-host.d.ts +33 -2
- package/dist/_shared/preview-host.d.ts.map +1 -1
- package/dist/_shared/preview-host.js +73 -8
- package/dist/_shared/session-router.d.ts +43 -0
- package/dist/_shared/session-router.d.ts.map +1 -1
- package/dist/_shared/session-router.js +59 -12
- package/dist/facets/durable-images.d.ts +59 -0
- package/dist/facets/durable-images.d.ts.map +1 -0
- package/dist/facets/durable-images.js +94 -0
- package/dist/facets/durable-slots.d.ts +45 -0
- package/dist/facets/durable-slots.d.ts.map +1 -0
- package/dist/facets/durable-slots.js +95 -0
- package/dist/facets/esbuild-transform.d.ts +10 -0
- package/dist/facets/esbuild-transform.d.ts.map +1 -0
- package/dist/facets/esbuild-transform.js +36 -0
- package/dist/facets/manager.d.ts +244 -6
- package/dist/facets/manager.d.ts.map +1 -1
- package/dist/facets/manager.js +901 -117
- package/dist/facets/resident-identity.d.ts +23 -0
- package/dist/facets/resident-identity.d.ts.map +1 -0
- package/dist/facets/resident-identity.js +31 -0
- package/dist/git/commands.d.ts +22 -1
- package/dist/git/commands.d.ts.map +1 -1
- package/dist/git/commands.js +429 -425
- package/dist/git-bundle.generated.d.ts +2 -2
- package/dist/git-bundle.generated.d.ts.map +1 -1
- package/dist/git-bundle.generated.js +3 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/node-shims-artifact.generated.js +3 -3
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +97 -3
- package/dist/router/public-directory-do.d.ts +17 -0
- package/dist/router/public-directory-do.d.ts.map +1 -0
- package/dist/router/public-directory-do.js +16 -0
- package/dist/router/public-directory.d.ts +79 -0
- package/dist/router/public-directory.d.ts.map +1 -0
- package/dist/router/public-directory.js +122 -0
- package/dist/router/remote-api.d.ts +27 -1
- package/dist/router/remote-api.d.ts.map +1 -1
- package/dist/router/remote-api.js +48 -2
- package/dist/runtime/cpython-resident.d.ts.map +1 -1
- package/dist/runtime/cpython-resident.js +3 -1
- package/dist/runtime/node-shims.d.ts +4 -1
- package/dist/runtime/node-shims.d.ts.map +1 -1
- package/dist/runtime/node-shims.js +324 -6
- package/dist/runtime/package-manager.d.ts +44 -1
- package/dist/runtime/package-manager.d.ts.map +1 -1
- package/dist/runtime/package-manager.js +168 -3
- package/dist/runtime/ruby-resident.d.ts.map +1 -1
- package/dist/runtime/ruby-resident.js +2 -0
- package/dist/session/agent.d.ts +11 -0
- package/dist/session/agent.d.ts.map +1 -1
- package/dist/session/agent.js +28 -1
- package/dist/session/helpers.js +1 -1
- package/dist/session/init-phases.d.ts +17 -23
- package/dist/session/init-phases.d.ts.map +1 -1
- package/dist/session/init-phases.js +17 -41
- package/dist/session/init.d.ts.map +1 -1
- package/dist/session/init.js +28 -15
- package/dist/session/keys.d.ts +12 -0
- package/dist/session/keys.d.ts.map +1 -1
- package/dist/session/keys.js +12 -0
- package/dist/session/nimbus-session.d.ts +63 -5
- package/dist/session/nimbus-session.d.ts.map +1 -1
- package/dist/session/nimbus-session.js +131 -17
- package/dist/session/port-capability.d.ts +141 -8
- package/dist/session/port-capability.d.ts.map +1 -1
- package/dist/session/port-capability.js +265 -8
- package/dist/session/programmatic.d.ts +145 -3
- package/dist/session/programmatic.d.ts.map +1 -1
- package/dist/session/programmatic.js +434 -12
- package/dist/session/routes.d.ts +26 -0
- package/dist/session/routes.d.ts.map +1 -1
- package/dist/session/routes.js +117 -25
- package/dist/session/rpc.d.ts +24 -1
- package/dist/session/rpc.d.ts.map +1 -1
- package/dist/session/rpc.js +65 -98
- package/dist/session/shell-socket.d.ts +76 -0
- package/dist/session/shell-socket.d.ts.map +1 -0
- package/dist/session/shell-socket.js +172 -0
- package/dist/session/start-real-vite.js +1 -1
- package/dist/session/supervisor-op.d.ts +42 -0
- package/dist/session/supervisor-op.d.ts.map +1 -0
- package/dist/session/supervisor-op.js +96 -0
- package/dist/session/supervisor-rpc.d.ts +6 -10
- package/dist/session/supervisor-rpc.d.ts.map +1 -1
- package/dist/session/supervisor-rpc.js +91 -71
- package/dist/session/ws.d.ts.map +1 -1
- package/dist/session/ws.js +19 -4
- package/package.json +4 -4
- package/public/_assets/runtime/{node-shims-fea906843f6d594e.js → node-shims-9e1380d9ee430fcc.js} +320 -5
- package/public/s/index.html +101 -5
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
* - events: full EventEmitter
|
|
10
10
|
* - stream: real Readable/Writable/Transform/Duplex with backpressure
|
|
11
11
|
* - crypto: createHash (FNV-1a sync, SubtleCrypto async), randomBytes/UUID
|
|
12
|
-
* - zlib:
|
|
12
|
+
* - zlib: forward to workerd's native node:zlib when the facet real-import
|
|
13
|
+
* block materialised (full sync/brotli/stream surface; results are the
|
|
14
|
+
* host realm's own Buffers, recognized by the widened isBuffer);
|
|
15
|
+
* CompressionStream fallback with honest sync refusal
|
|
13
16
|
* - dns: real DNS resolution via Cloudflare DNS-over-HTTPS
|
|
14
17
|
* - http: virtual server with port registry for supervisor routing
|
|
15
18
|
* - https: fetch()-backed request/get
|
|
@@ -386,7 +389,19 @@ const __BufferMod = (() => {
|
|
|
386
389
|
|
|
387
390
|
function alloc(n, fill) { const a = new Uint8Array(n); if (fill !== undefined) a.fill(typeof fill === "number" ? fill : 0); return _wrap(a); }
|
|
388
391
|
function allocUnsafe(n) { return _wrap(new Uint8Array(Number(n) || 0)); }
|
|
389
|
-
|
|
392
|
+
// Marker check plus native-brand recognition: forwarded node:* builtins
|
|
393
|
+
// (zlib streams and results, crypto) hand back the host realm's own Buffer
|
|
394
|
+
// instances, which carry no __isBuffer marker. Their constructor brand is
|
|
395
|
+
// the closest cross-realm equivalent of Node's instanceof check, so
|
|
396
|
+
// Buffer.isBuffer stays truthful across the shim/native boundary instead
|
|
397
|
+
// of rejecting genuine host Buffers. Always returns a boolean (the old
|
|
398
|
+
// single-expression form leaked an undefined when the marker was absent).
|
|
399
|
+
function isBuffer(o) {
|
|
400
|
+
if (!(o instanceof Uint8Array)) return false;
|
|
401
|
+
if (o.__isBuffer) return true;
|
|
402
|
+
const ctor = o.constructor;
|
|
403
|
+
return typeof ctor === "function" && ctor.name === "Buffer";
|
|
404
|
+
}
|
|
390
405
|
function concat(bufs, len) {
|
|
391
406
|
const total = len ?? bufs.reduce((s, b) => s + b.length, 0);
|
|
392
407
|
const r = new Uint8Array(total); let off = 0;
|
|
@@ -5593,6 +5608,21 @@ const __processMod = {
|
|
|
5593
5608
|
},
|
|
5594
5609
|
platform: "linux", arch: "x64",
|
|
5595
5610
|
version: ${NODE_VERSION_LITERAL}, versions: ${NODE_VERSIONS_LITERAL},
|
|
5611
|
+
features: Object.freeze({
|
|
5612
|
+
inspector: false,
|
|
5613
|
+
debug: false,
|
|
5614
|
+
uv: false,
|
|
5615
|
+
ipv6: true,
|
|
5616
|
+
tls_alpn: true,
|
|
5617
|
+
tls_sni: true,
|
|
5618
|
+
tls_ocsp: false,
|
|
5619
|
+
tls: true,
|
|
5620
|
+
openssl_is_boringssl: true,
|
|
5621
|
+
}),
|
|
5622
|
+
getBuiltinModule: (specifier) => {
|
|
5623
|
+
const key = String(specifier).replace(/^node:/, "");
|
|
5624
|
+
return Object.prototype.hasOwnProperty.call(builtins, key) ? builtins[key] : undefined;
|
|
5625
|
+
},
|
|
5596
5626
|
execPath: "/usr/local/bin/node",
|
|
5597
5627
|
execArgv: [],
|
|
5598
5628
|
pid: 1, ppid: 0, title: "node",
|
|
@@ -6152,10 +6182,295 @@ const __nimbusFacetProvidedPackages = new Set(${FACET_PROVIDED_PACKAGES_LITERAL}
|
|
|
6152
6182
|
// timers.setInterval(...)), which clack's spinner — used by
|
|
6153
6183
|
// create-cloudflare — triggers.
|
|
6154
6184
|
builtins.timers = { setTimeout: globalThis.setTimeout.bind(globalThis), setInterval: globalThis.setInterval.bind(globalThis), clearTimeout: globalThis.clearTimeout.bind(globalThis), clearInterval: globalThis.clearInterval.bind(globalThis), setImmediate: (fn,...a) => globalThis.setTimeout(fn,0,...a), clearImmediate: globalThis.clearTimeout.bind(globalThis) };
|
|
6185
|
+
// ── zlib ───────────────────────────────────────────────────────────
|
|
6186
|
+
//
|
|
6187
|
+
// Two runtimes, one surface:
|
|
6188
|
+
// 1. Facet templates prepend the static import block
|
|
6189
|
+
// (_shared/real-node-imports.ts), which carries workerd's native
|
|
6190
|
+
// node:zlib — complete at the production compat date: every *Sync
|
|
6191
|
+
// variant, brotli/zstd, crc32, constants, and real streaming create*
|
|
6192
|
+
// factories. Forward verbatim: results are the host realm's own Buffer
|
|
6193
|
+
// instances, and __BufferMod.isBuffer recognizes that brand (see the
|
|
6194
|
+
// Buffer shim), so Buffer checks stay truthful without copying every
|
|
6195
|
+
// result or intercepting stream chunks.
|
|
6196
|
+
// 2. Scopes without the import block keep the CompressionStream fallback.
|
|
6197
|
+
// It is async-only by nature; the sync names refuse with an honest,
|
|
6198
|
+
// actionable error instead of pretending.
|
|
6155
6199
|
builtins.zlib = (() => {
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6200
|
+
const __real = (typeof __real_zlib !== "undefined") ? (__real_zlib.default ?? __real_zlib) : null;
|
|
6201
|
+
if (__real && typeof __real.gzipSync === "function") {
|
|
6202
|
+
const mod = {};
|
|
6203
|
+
// Constants, lookup tables, crc32, and the stream factories/classes pass
|
|
6204
|
+
// through bound to the native module (capitalized names are classes —
|
|
6205
|
+
// binding would strip their prototype and break \`new\`).
|
|
6206
|
+
for (const k of Object.keys(__real)) {
|
|
6207
|
+
const v = __real[k];
|
|
6208
|
+
mod[k] = (typeof v === "function" && /^[a-z]/.test(k)) ? v.bind(__real) : v;
|
|
6209
|
+
}
|
|
6210
|
+
if (__real.promises) mod.promises = __real.promises;
|
|
6211
|
+
mod.default = mod;
|
|
6212
|
+
return mod;
|
|
6213
|
+
}
|
|
6214
|
+
function _c(i,a) { return new Response(new Blob([i]).stream().pipeThrough(new CompressionStream(a))).arrayBuffer().then(ab=>__BufferMod.from(new Uint8Array(ab))); }
|
|
6215
|
+
// Decompression is driven by hand rather than piped: feeding and draining
|
|
6216
|
+
// run together, because a write only completes while somebody reads.
|
|
6217
|
+
async function _d(i,a) {
|
|
6218
|
+
const codec = _openCodec("decompress", a);
|
|
6219
|
+
const chunks = [];
|
|
6220
|
+
let failure = null;
|
|
6221
|
+
const record = (reason) => { if (!failure) failure = { reason }; };
|
|
6222
|
+
const drain = (async () => {
|
|
6223
|
+
for (;;) {
|
|
6224
|
+
const next = await codec.reader.read();
|
|
6225
|
+
if (next.done) return;
|
|
6226
|
+
chunks.push(next.value);
|
|
6227
|
+
}
|
|
6228
|
+
})().catch(record);
|
|
6229
|
+
const feed = (async () => {
|
|
6230
|
+
await codec.writer.write(i);
|
|
6231
|
+
await codec.writer.close();
|
|
6232
|
+
})().catch(record);
|
|
6233
|
+
await Promise.all([drain, feed]);
|
|
6234
|
+
if (failure) throw _decompressFailure(failure.reason);
|
|
6235
|
+
return __BufferMod.from(_concat(chunks));
|
|
6236
|
+
}
|
|
6237
|
+
function _syncRefusal(name, asyncName) {
|
|
6238
|
+
const e = new Error("zlib." + name + ": synchronous compression is not available on this runtime (no native node:zlib in scope). Use the async zlib." + asyncName + "(data, callback) form.");
|
|
6239
|
+
e.code = "ERR_ZLIB_SYNC_UNAVAILABLE";
|
|
6240
|
+
throw e;
|
|
6241
|
+
}
|
|
6242
|
+
// Node accepts strings, ArrayBuffers, and any ArrayBufferView; one funnel
|
|
6243
|
+
// yields a byte-addressed Uint8Array over the caller's own region —
|
|
6244
|
+
// byteOffset/byteLength preserved, element values never reinterpreted.
|
|
6245
|
+
function _u8(d) {
|
|
6246
|
+
if (typeof d === "string") return new TextEncoder().encode(d);
|
|
6247
|
+
if (d instanceof Uint8Array) return d;
|
|
6248
|
+
if (ArrayBuffer.isView(d)) return new Uint8Array(d.buffer, d.byteOffset, d.byteLength);
|
|
6249
|
+
return new Uint8Array(d);
|
|
6250
|
+
}
|
|
6251
|
+
// Node splits decompression failures two ways, and the engine's own
|
|
6252
|
+
// failure is the only thing that can tell them apart: an input that ran
|
|
6253
|
+
// out is Z_BUF_ERROR / errno -5, everything else — bad header, bad block,
|
|
6254
|
+
// and a checksum or length trailer that only fails once the member is
|
|
6255
|
+
// complete — is Z_DATA_ERROR / errno -3. Which side of a write or close
|
|
6256
|
+
// the failure lands on says nothing about that, so it is not consulted.
|
|
6257
|
+
function _zdata(e) {
|
|
6258
|
+
const err = new Error(e instanceof Error && e.message ? e.message : String(e));
|
|
6259
|
+
err.code = "Z_DATA_ERROR";
|
|
6260
|
+
err.errno = -3;
|
|
6261
|
+
err.cause = e;
|
|
6262
|
+
return err;
|
|
6263
|
+
}
|
|
6264
|
+
function _zbuf(e) {
|
|
6265
|
+
const err = new Error("unexpected end of file");
|
|
6266
|
+
err.code = "Z_BUF_ERROR";
|
|
6267
|
+
err.errno = -5;
|
|
6268
|
+
if (e != null) err.cause = e;
|
|
6269
|
+
return err;
|
|
6270
|
+
}
|
|
6271
|
+
function _isUnexpectedEnd(e) {
|
|
6272
|
+
const m = e instanceof Error && typeof e.message === "string" ? e.message : String(e);
|
|
6273
|
+
return /unexpected end|end of (?:file|input|stream)|premature|truncated|\\bEOF\\b/i.test(m);
|
|
6274
|
+
}
|
|
6275
|
+
function _decompressFailure(e) { return _isUnexpectedEnd(e) ? _zbuf(e) : _zdata(e); }
|
|
6276
|
+
function _destroyedWrite() {
|
|
6277
|
+
const e = new Error("Cannot call write after a stream was destroyed");
|
|
6278
|
+
e.code = "ERR_STREAM_DESTROYED";
|
|
6279
|
+
return e;
|
|
6280
|
+
}
|
|
6281
|
+
// Node throws synchronously rather than deferring a callback that is not
|
|
6282
|
+
// there; this surface has no promise form to fall back on.
|
|
6283
|
+
function _invalidCallback(v) {
|
|
6284
|
+
const got = v === undefined ? "undefined"
|
|
6285
|
+
: v === null ? "null"
|
|
6286
|
+
: typeof v === "object" ? "an instance of " + ((v.constructor && v.constructor.name) || "Object")
|
|
6287
|
+
: "type " + typeof v + " (" + String(v) + ")";
|
|
6288
|
+
const e = new TypeError('The "callback" argument must be of type function. Received ' + got);
|
|
6289
|
+
e.code = "ERR_INVALID_ARG_TYPE";
|
|
6290
|
+
return e;
|
|
6291
|
+
}
|
|
6292
|
+
// Node's Unzip contract sniffs the wrapper itself: gzip magic or zlib.
|
|
6293
|
+
function _isGzip(u8) { return u8.length >= 2 && u8[0] === 0x1f && u8[1] === 0x8b; }
|
|
6294
|
+
function _concat(chunks) {
|
|
6295
|
+
let n = 0;
|
|
6296
|
+
for (const c of chunks) n += c.length;
|
|
6297
|
+
const out = new Uint8Array(n);
|
|
6298
|
+
let o = 0;
|
|
6299
|
+
for (const c of chunks) { out.set(c, o); o += c.length; }
|
|
6300
|
+
return out;
|
|
6301
|
+
}
|
|
6302
|
+
function _process(mode, fmt, input) {
|
|
6303
|
+
const algo = mode === "compress" ? fmt : (fmt || (_isGzip(input) ? "gzip" : "deflate"));
|
|
6304
|
+
return mode === "compress" ? _c(input, algo) : _d(input, algo);
|
|
6305
|
+
}
|
|
6306
|
+
function _async(mode, fmt) {
|
|
6307
|
+
return (d, o, cb) => {
|
|
6308
|
+
const callback = typeof o === "function" ? o : cb;
|
|
6309
|
+
if (typeof callback !== "function") throw _invalidCallback(callback);
|
|
6310
|
+
// Two arms, not .then().catch(): a callback that throws on success must
|
|
6311
|
+
// not be handed its own exception as a second, failed invocation.
|
|
6312
|
+
_process(mode, fmt, _u8(d)).then(
|
|
6313
|
+
(r) => callback(null, r),
|
|
6314
|
+
(e) => callback(e instanceof Error ? e : new Error(String(e))),
|
|
6315
|
+
);
|
|
6316
|
+
};
|
|
6317
|
+
}
|
|
6318
|
+
// Live codec per Transform lifetime: every write feeds one real
|
|
6319
|
+
// CompressionStream/DecompressionStream writer (its queue serializes
|
|
6320
|
+
// ordering; the write promise settles before the callback), a reader pump
|
|
6321
|
+
// relays output as it is produced instead of accumulating the payload,
|
|
6322
|
+
// and flush closes the writer then awaits full drain before completing.
|
|
6323
|
+
// Chunks are copied so later caller mutations cannot reach the codec, and
|
|
6324
|
+
// createUnzip holds copies only until two bytes decide the wrapper.
|
|
6325
|
+
function _openCodec(openMode, openAlgo) {
|
|
6326
|
+
const cs = openMode === "compress" ? new CompressionStream(openAlgo) : new DecompressionStream(openAlgo);
|
|
6327
|
+
return { writer: cs.writable.getWriter(), reader: cs.readable.getReader() };
|
|
6328
|
+
}
|
|
6329
|
+
// The legacy Readable has no resume notification, so room below the
|
|
6330
|
+
// high-water mark is observed by yielding to the task queue until the
|
|
6331
|
+
// consumer drains or the stream is destroyed.
|
|
6332
|
+
async function _drainRoom(stream) {
|
|
6333
|
+
while (
|
|
6334
|
+
stream._readableState &&
|
|
6335
|
+
!stream._readableState.destroyed &&
|
|
6336
|
+
stream.readableLength >= stream._readableState.highWaterMark
|
|
6337
|
+
) {
|
|
6338
|
+
await new Promise((tick) => setTimeout(tick, 0));
|
|
6339
|
+
}
|
|
6340
|
+
// True when the wait ended because the stream went away, not because
|
|
6341
|
+
// the consumer made room.
|
|
6342
|
+
return !!(stream._readableState && stream._readableState.destroyed);
|
|
6343
|
+
}
|
|
6344
|
+
function _streamFactory(factoryMode, fmt) {
|
|
6345
|
+
return () => {
|
|
6346
|
+
let writer = null;
|
|
6347
|
+
let reader = null;
|
|
6348
|
+
let drained = Promise.resolve();
|
|
6349
|
+
let pumpFailure = null;
|
|
6350
|
+
let algo = fmt;
|
|
6351
|
+
let held = [];
|
|
6352
|
+
let heldLen = 0;
|
|
6353
|
+
let destroyed = false;
|
|
6354
|
+
const t = new __streamMod.Transform({
|
|
6355
|
+
transform: async (chunk, _enc, cb) => {
|
|
6356
|
+
try {
|
|
6357
|
+
if (destroyed) return cb(_destroyedWrite());
|
|
6358
|
+
const bytes = _u8(chunk).slice();
|
|
6359
|
+
let feed = bytes;
|
|
6360
|
+
if (!writer) {
|
|
6361
|
+
if (fmt === null && heldLen + bytes.length < 2) {
|
|
6362
|
+
held.push(bytes);
|
|
6363
|
+
heldLen += bytes.length;
|
|
6364
|
+
return cb();
|
|
6365
|
+
}
|
|
6366
|
+
if (heldLen > 0) feed = _concat([...held, bytes]);
|
|
6367
|
+
held = [];
|
|
6368
|
+
heldLen = 0;
|
|
6369
|
+
if (fmt === null) algo = _isGzip(feed) ? "gzip" : "deflate";
|
|
6370
|
+
start();
|
|
6371
|
+
}
|
|
6372
|
+
await writer.write(feed);
|
|
6373
|
+
cb();
|
|
6374
|
+
} catch (e) {
|
|
6375
|
+
cb(destroyed ? _destroyedWrite() : factoryMode === "decompress" ? _decompressFailure(e) : e);
|
|
6376
|
+
}
|
|
6377
|
+
},
|
|
6378
|
+
flush: async (cb) => {
|
|
6379
|
+
try {
|
|
6380
|
+
if (destroyed) return cb(_destroyedWrite());
|
|
6381
|
+
if (!writer) {
|
|
6382
|
+
if (factoryMode !== "compress") {
|
|
6383
|
+
// Nothing was ever fed: the input ended before a member
|
|
6384
|
+
// began, which is Node's unexpected-end buffer error rather
|
|
6385
|
+
// than corrupt data. No codec is invented to hide it.
|
|
6386
|
+
return cb(_zbuf(null));
|
|
6387
|
+
}
|
|
6388
|
+
start();
|
|
6389
|
+
}
|
|
6390
|
+
await writer.close();
|
|
6391
|
+
await drained;
|
|
6392
|
+
cb(pumpFailure);
|
|
6393
|
+
} catch (e) {
|
|
6394
|
+
if (pumpFailure) return cb(pumpFailure);
|
|
6395
|
+
if (destroyed) return cb(_destroyedWrite());
|
|
6396
|
+
cb(factoryMode === "decompress" ? _decompressFailure(e) : e);
|
|
6397
|
+
}
|
|
6398
|
+
},
|
|
6399
|
+
});
|
|
6400
|
+
// Every destroy exit fires 'close' on the custom Transform — even when
|
|
6401
|
+
// the pump sits parked inside reader.read() on truncated input that can
|
|
6402
|
+
// never decode. Waking there is immediate: cancel settles the parked
|
|
6403
|
+
// read, abort fails queued writes, and writes arriving after destroy
|
|
6404
|
+
// report ERR_STREAM_DESTROYED instead of silent acceptance.
|
|
6405
|
+
t.on("close", () => {
|
|
6406
|
+
destroyed = true;
|
|
6407
|
+
_releaseCodec();
|
|
6408
|
+
});
|
|
6409
|
+
// One cleanup path for every destroy exit: cancel the readable side,
|
|
6410
|
+
// abort the writable side, and stop the pump.
|
|
6411
|
+
function _releaseCodec() {
|
|
6412
|
+
if (reader) reader.cancel().catch(() => {});
|
|
6413
|
+
if (writer) writer.abort().catch(() => {});
|
|
6414
|
+
}
|
|
6415
|
+
function start() {
|
|
6416
|
+
const opened = _openCodec(factoryMode, algo);
|
|
6417
|
+
writer = opened.writer;
|
|
6418
|
+
reader = opened.reader;
|
|
6419
|
+
drained = (async () => {
|
|
6420
|
+
try {
|
|
6421
|
+
for (;;) {
|
|
6422
|
+
// A destroy can land while a read is in flight; check on both
|
|
6423
|
+
// sides so nothing buffers after the stream went away.
|
|
6424
|
+
if (destroyed) return _releaseCodec();
|
|
6425
|
+
const next = await reader.read();
|
|
6426
|
+
if (destroyed) return _releaseCodec();
|
|
6427
|
+
if (next.done) {
|
|
6428
|
+
return;
|
|
6429
|
+
}
|
|
6430
|
+
// Backpressure: once push reports pressure, park the pump and
|
|
6431
|
+
// do not read again until the consumer drains below the
|
|
6432
|
+
// high-water mark. The pending writer.write promise then holds
|
|
6433
|
+
// the transform callback, so producer writes stop resolving
|
|
6434
|
+
// instead of accumulating. A destroy while parked releases the
|
|
6435
|
+
// codec through the close hook above.
|
|
6436
|
+
if (!t.push(__BufferMod.from(next.value))) {
|
|
6437
|
+
if (await _drainRoom(t)) return _releaseCodec();
|
|
6438
|
+
}
|
|
6439
|
+
}
|
|
6440
|
+
} catch (e) {
|
|
6441
|
+
pumpFailure = factoryMode === "decompress"
|
|
6442
|
+
? _decompressFailure(e)
|
|
6443
|
+
: (e instanceof Error ? e : new Error(String(e)));
|
|
6444
|
+
}
|
|
6445
|
+
})();
|
|
6446
|
+
}
|
|
6447
|
+
return t;
|
|
6448
|
+
};
|
|
6449
|
+
}
|
|
6450
|
+
return {
|
|
6451
|
+
gzip: _async("compress", "gzip"),
|
|
6452
|
+
gunzip: _async("decompress", "gzip"),
|
|
6453
|
+
deflate: _async("compress", "deflate"),
|
|
6454
|
+
inflate: _async("decompress", "deflate"),
|
|
6455
|
+
deflateRaw: _async("compress", "deflate-raw"),
|
|
6456
|
+
inflateRaw: _async("decompress", "deflate-raw"),
|
|
6457
|
+
unzip: _async("decompress", null),
|
|
6458
|
+
gzipSync: (d, o) => _syncRefusal("gzipSync", "gzip"),
|
|
6459
|
+
gunzipSync: (d, o) => _syncRefusal("gunzipSync", "gunzip"),
|
|
6460
|
+
deflateSync: (d, o) => _syncRefusal("deflateSync", "deflate"),
|
|
6461
|
+
inflateSync: (d, o) => _syncRefusal("inflateSync", "inflate"),
|
|
6462
|
+
deflateRawSync: (d, o) => _syncRefusal("deflateRawSync", "deflateRaw"),
|
|
6463
|
+
inflateRawSync: (d, o) => _syncRefusal("inflateRawSync", "inflateRaw"),
|
|
6464
|
+
unzipSync: (d, o) => _syncRefusal("unzipSync", "unzip"),
|
|
6465
|
+
createGzip: _streamFactory("compress", "gzip"),
|
|
6466
|
+
createGunzip: _streamFactory("decompress", "gzip"),
|
|
6467
|
+
createDeflate: _streamFactory("compress", "deflate"),
|
|
6468
|
+
createInflate: _streamFactory("decompress", "deflate"),
|
|
6469
|
+
createDeflateRaw: _streamFactory("compress", "deflate-raw"),
|
|
6470
|
+
createInflateRaw: _streamFactory("decompress", "deflate-raw"),
|
|
6471
|
+
createUnzip: _streamFactory("decompress", null),
|
|
6472
|
+
constants: { Z_NO_FLUSH: 0, Z_PARTIAL_FLUSH: 1, Z_SYNC_FLUSH: 2, Z_FULL_FLUSH: 3, Z_FINISH: 4, Z_BEST_COMPRESSION: 9, Z_DEFAULT_COMPRESSION: -1 },
|
|
6473
|
+
};
|
|
6159
6474
|
})();
|
|
6160
6475
|
builtins.readline = (() => {
|
|
6161
6476
|
function emitKeypressEvents(stream) {
|
|
@@ -6880,9 +7195,11 @@ function __resolveImportsField(name, fromDir) {
|
|
|
6880
7195
|
function __mkCompiledFn(code) {
|
|
6881
7196
|
const reFn = /(?:^|\\n|;)\\s*(?:const|let|var)\\s+__filename\\s*=/m;
|
|
6882
7197
|
const reDn = /(?:^|\\n|;)\\s*(?:const|let|var)\\s+__dirname\\s*=/m;
|
|
7198
|
+
const reRequire = /(?:^|\\n|;)\\s*(?:const|let|var)\\s+require\\s*=/m;
|
|
6883
7199
|
const fnName = reFn.test(code) ? "__filename__nimbus_unused" : "__filename";
|
|
6884
7200
|
const dnName = reDn.test(code) ? "__dirname__nimbus_unused" : "__dirname";
|
|
6885
|
-
|
|
7201
|
+
const requireName = reRequire.test(code) ? "require__nimbus_unused" : "require";
|
|
7202
|
+
return new Function("exports", requireName, "module", fnName, dnName, code);
|
|
6886
7203
|
}
|
|
6887
7204
|
|
|
6888
7205
|
function __exportsTarget(mod) {
|
|
@@ -6961,6 +7278,7 @@ function __loadModule(resolvedPath) {
|
|
|
6961
7278
|
};
|
|
6962
7279
|
scopedRequire.cache = __moduleCache;
|
|
6963
7280
|
scopedRequire.main = __require.main;
|
|
7281
|
+
mod.require = scopedRequire;
|
|
6964
7282
|
|
|
6965
7283
|
// X.5-M3: thread currently-loading module path through globalThis so the
|
|
6966
7284
|
// URL shim null-base fallback (in node-shims url module) can compose
|
|
@@ -93,9 +93,50 @@ export declare function ensureRuntimesProgrammatic(deps: {
|
|
|
93
93
|
}, specs: string[], opts?: {
|
|
94
94
|
force?: boolean;
|
|
95
95
|
}): Promise<RuntimeInstallSummary[]>;
|
|
96
|
+
/**
|
|
97
|
+
* The session's application verbs, as the shell reaches them — the SAME
|
|
98
|
+
* session methods the SDK and the Agent call (session/programmatic.ts), so
|
|
99
|
+
* there is one policy for what an exposure, a rotation or a removal is.
|
|
100
|
+
*/
|
|
101
|
+
export interface NimbusAppVerbs {
|
|
102
|
+
expose(target: number | string, options: {
|
|
103
|
+
visibility?: 'scoped' | 'public';
|
|
104
|
+
name?: string;
|
|
105
|
+
}): Promise<{
|
|
106
|
+
owner: string;
|
|
107
|
+
name: string | null;
|
|
108
|
+
port: number;
|
|
109
|
+
capability: string | null;
|
|
110
|
+
visibility: 'scoped' | 'public';
|
|
111
|
+
url: string | null;
|
|
112
|
+
}>;
|
|
113
|
+
list(): Promise<Array<{
|
|
114
|
+
owner: string;
|
|
115
|
+
name: string | null;
|
|
116
|
+
port: number | null;
|
|
117
|
+
pid: number | null;
|
|
118
|
+
status: string;
|
|
119
|
+
visibility: string;
|
|
120
|
+
restart: string;
|
|
121
|
+
diagnostic: string | null;
|
|
122
|
+
url: string | null;
|
|
123
|
+
}>>;
|
|
124
|
+
rotateLink(target: number | string): Promise<{
|
|
125
|
+
name: string | null;
|
|
126
|
+
port: number;
|
|
127
|
+
url: string | null;
|
|
128
|
+
capability: string | null;
|
|
129
|
+
}>;
|
|
130
|
+
remove(target: number | string): Promise<{
|
|
131
|
+
owner: string;
|
|
132
|
+
removed: boolean;
|
|
133
|
+
port: number | null;
|
|
134
|
+
}>;
|
|
135
|
+
}
|
|
96
136
|
/**
|
|
97
137
|
* Build the shell-command handler that implements `nimbus install …`,
|
|
98
|
-
* `nimbus uninstall
|
|
138
|
+
* `nimbus uninstall …`, `nimbus expose …`, `nimbus app …` and
|
|
139
|
+
* `nimbus start …`. Registered under the name `nimbus`.
|
|
99
140
|
*/
|
|
100
141
|
export declare function makeNimbusVerbHandler(deps: {
|
|
101
142
|
env: RuntimeCatalogEnv;
|
|
@@ -105,5 +146,7 @@ export declare function makeNimbusVerbHandler(deps: {
|
|
|
105
146
|
* caller (init.ts) from the shell env. */
|
|
106
147
|
getHome(): string;
|
|
107
148
|
warmRuntime?: RuntimeWarmHook;
|
|
149
|
+
/** The application verbs; absent on a host with no session (tests). */
|
|
150
|
+
apps?: NimbusAppVerbs;
|
|
108
151
|
}): (ctx: any) => Promise<number>;
|
|
109
152
|
//# sourceMappingURL=package-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager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AU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IACnI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;CACpG;AASD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAC1C,GAAG,EAAE,iBAAiB,CAAC;IACvB,GAAG,EAAE,SAAS,CAAC;IACf,QAAQ,EAAE,gBAAgB,CAAC;IAC3B;+CAC2C;IAC3C,OAAO,IAAI,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,uEAAuE;IACvE,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,CAkChC"}
|
|
@@ -200,12 +200,19 @@ export async function ensureRuntimesProgrammatic(deps, specs, opts = {}) {
|
|
|
200
200
|
}
|
|
201
201
|
return results;
|
|
202
202
|
}
|
|
203
|
+
const NIMBUS_USAGE = [
|
|
204
|
+
'usage: nimbus install <name>[@<version>] | nimbus install --list | nimbus install --available | nimbus uninstall <name>',
|
|
205
|
+
' nimbus expose <port|pid> [--public] [--name <name>]',
|
|
206
|
+
' nimbus app list | url <name|port> | rotate <name|port> | remove <name|port>',
|
|
207
|
+
' nimbus start [--restart never|on-failure] <command> [args...]',
|
|
208
|
+
].join('\n');
|
|
203
209
|
/**
|
|
204
210
|
* Build the shell-command handler that implements `nimbus install …`,
|
|
205
|
-
* `nimbus uninstall
|
|
211
|
+
* `nimbus uninstall …`, `nimbus expose …`, `nimbus app …` and
|
|
212
|
+
* `nimbus start …`. Registered under the name `nimbus`.
|
|
206
213
|
*/
|
|
207
214
|
export function makeNimbusVerbHandler(deps) {
|
|
208
|
-
const { env, registry, getHome, warmRuntime } = deps;
|
|
215
|
+
const { env, registry, getHome, warmRuntime, apps } = deps;
|
|
209
216
|
const vfs = deps.vfs.as(CRED_KERNEL);
|
|
210
217
|
return async function nimbus(ctx) {
|
|
211
218
|
const argv = ctx.args || [];
|
|
@@ -217,12 +224,170 @@ export function makeNimbusVerbHandler(deps) {
|
|
|
217
224
|
if (verb === 'uninstall') {
|
|
218
225
|
return runUninstall(rest, ctx, { vfs, registry, getHome });
|
|
219
226
|
}
|
|
227
|
+
if (verb === 'expose' || verb === 'app' || verb === 'start') {
|
|
228
|
+
if (verb === 'start')
|
|
229
|
+
return runStart(rest, ctx, registry);
|
|
230
|
+
if (!apps) {
|
|
231
|
+
ctx.stderr.write(`nimbus ${verb}: this host has no session to address applications on\n`);
|
|
232
|
+
return 1;
|
|
233
|
+
}
|
|
234
|
+
try {
|
|
235
|
+
return verb === 'expose' ? await runExpose(rest, ctx, apps) : await runApp(rest, ctx, apps);
|
|
236
|
+
}
|
|
237
|
+
catch (e) {
|
|
238
|
+
ctx.stderr.write(`nimbus ${verb}: ${e instanceof Error ? e.message : String(e)}\n`);
|
|
239
|
+
return 1;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
220
242
|
// Unknown verb.
|
|
221
243
|
ctx.stderr.write(`nimbus: unknown subcommand '${verb || '(none)'}'\n`);
|
|
222
|
-
ctx.stderr.write(
|
|
244
|
+
ctx.stderr.write(`${NIMBUS_USAGE}\n`);
|
|
223
245
|
return 2;
|
|
224
246
|
};
|
|
225
247
|
}
|
|
248
|
+
// ── expose / app / start ─────────────────────────────────────────────
|
|
249
|
+
/** `<port|pid|name>` as the verbs take it: digits are a port or pid, anything else a name. */
|
|
250
|
+
function appTargetArg(raw) {
|
|
251
|
+
return /^\d+$/.test(raw) ? Number(raw) : raw;
|
|
252
|
+
}
|
|
253
|
+
async function runExpose(args, ctx, apps) {
|
|
254
|
+
let target;
|
|
255
|
+
let name;
|
|
256
|
+
let visibility;
|
|
257
|
+
for (let i = 0; i < args.length; i++) {
|
|
258
|
+
const arg = args[i];
|
|
259
|
+
if (arg === '--public')
|
|
260
|
+
visibility = 'public';
|
|
261
|
+
else if (arg === '--scoped')
|
|
262
|
+
visibility = 'scoped';
|
|
263
|
+
else if (arg === '--name') {
|
|
264
|
+
name = args[++i];
|
|
265
|
+
}
|
|
266
|
+
else if (arg.startsWith('--name='))
|
|
267
|
+
name = arg.slice('--name='.length);
|
|
268
|
+
else if (arg.startsWith('--')) {
|
|
269
|
+
ctx.stderr.write(`nimbus expose: unknown flag ${arg}\n`);
|
|
270
|
+
return 2;
|
|
271
|
+
}
|
|
272
|
+
else if (target === undefined)
|
|
273
|
+
target = arg;
|
|
274
|
+
else {
|
|
275
|
+
ctx.stderr.write('nimbus expose: one target only\n');
|
|
276
|
+
return 2;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (target === undefined) {
|
|
280
|
+
ctx.stderr.write('usage: nimbus expose <port|pid> [--public] [--name <name>]\n');
|
|
281
|
+
return 2;
|
|
282
|
+
}
|
|
283
|
+
const exposed = await apps.expose(appTargetArg(target), {
|
|
284
|
+
...(visibility !== undefined ? { visibility } : {}),
|
|
285
|
+
...(name !== undefined ? { name } : {}),
|
|
286
|
+
});
|
|
287
|
+
ctx.stdout.write(`${exposed.url ?? `(no URL: port ${exposed.port}, capability ${exposed.capability ?? 'none'})`}\n`);
|
|
288
|
+
ctx.stdout.write(` ${exposed.visibility} · ${exposed.name ?? exposed.owner} · port ${exposed.port}\n`);
|
|
289
|
+
return 0;
|
|
290
|
+
}
|
|
291
|
+
async function runApp(args, ctx, apps) {
|
|
292
|
+
const [sub, target] = args;
|
|
293
|
+
if (sub === 'list' || sub === 'ls') {
|
|
294
|
+
const rows = await apps.list();
|
|
295
|
+
if (rows.length === 0) {
|
|
296
|
+
ctx.stdout.write('(no applications)\n');
|
|
297
|
+
return 0;
|
|
298
|
+
}
|
|
299
|
+
for (const app of rows) {
|
|
300
|
+
const label = app.name ?? app.owner;
|
|
301
|
+
const where = app.port === null ? '-' : String(app.port);
|
|
302
|
+
const pid = app.pid === null ? '-' : String(app.pid);
|
|
303
|
+
const status = app.diagnostic ? `${app.status} (${app.diagnostic})` : app.status;
|
|
304
|
+
ctx.stdout.write(`${label}\t${where}\t${pid}\t${status}\t${app.visibility}\t${app.restart}\t${app.url ?? '-'}\n`);
|
|
305
|
+
}
|
|
306
|
+
return 0;
|
|
307
|
+
}
|
|
308
|
+
if (target === undefined || (sub !== 'url' && sub !== 'rotate' && sub !== 'remove')) {
|
|
309
|
+
ctx.stderr.write('usage: nimbus app list | url <name|port> | rotate <name|port> | remove <name|port>\n');
|
|
310
|
+
return 2;
|
|
311
|
+
}
|
|
312
|
+
const t = appTargetArg(target);
|
|
313
|
+
if (sub === 'url') {
|
|
314
|
+
const app = (await apps.list()).find((row) => row.name === t || row.owner === t || row.port === t || row.pid === t);
|
|
315
|
+
if (!app) {
|
|
316
|
+
ctx.stderr.write(`nimbus app url: no application matches ${target}\n`);
|
|
317
|
+
return 1;
|
|
318
|
+
}
|
|
319
|
+
ctx.stdout.write(`${app.url ?? `(no URL: port ${app.port ?? '-'})`}\n`);
|
|
320
|
+
return 0;
|
|
321
|
+
}
|
|
322
|
+
if (sub === 'rotate') {
|
|
323
|
+
const rotated = await apps.rotateLink(t);
|
|
324
|
+
ctx.stdout.write(`${rotated.url ?? `(no URL: port ${rotated.port}, capability ${rotated.capability ?? 'none'})`}\n`);
|
|
325
|
+
return 0;
|
|
326
|
+
}
|
|
327
|
+
const removed = await apps.remove(t);
|
|
328
|
+
ctx.stdout.write(removed.removed
|
|
329
|
+
? `removed ${removed.owner}${removed.port !== null ? ` (port ${removed.port} released)` : ''}\n`
|
|
330
|
+
: `nothing to remove for ${removed.owner}\n`);
|
|
331
|
+
return removed.removed ? 0 : 1;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* `nimbus start [--restart <policy>] <command> [args...]` — run a
|
|
335
|
+
* registered command with the restart policy in its environment, which is
|
|
336
|
+
* where the resident it starts reads the policy from (`NIMBUS_RESTART`),
|
|
337
|
+
* exactly as the SDK's `startProcess({ restart })` carries it.
|
|
338
|
+
*/
|
|
339
|
+
async function runStart(args, ctx, registry) {
|
|
340
|
+
let restart = 'never';
|
|
341
|
+
let i = 0;
|
|
342
|
+
for (; i < args.length; i++) {
|
|
343
|
+
const arg = args[i];
|
|
344
|
+
if (arg === '--restart') {
|
|
345
|
+
const policy = args[++i];
|
|
346
|
+
if (policy !== 'never' && policy !== 'on-failure') {
|
|
347
|
+
ctx.stderr.write(`nimbus start: --restart must be never or on-failure, got ${policy ?? '(none)'}\n`);
|
|
348
|
+
return 2;
|
|
349
|
+
}
|
|
350
|
+
restart = policy;
|
|
351
|
+
}
|
|
352
|
+
else if (arg.startsWith('--restart=')) {
|
|
353
|
+
const policy = arg.slice('--restart='.length);
|
|
354
|
+
if (policy !== 'never' && policy !== 'on-failure') {
|
|
355
|
+
ctx.stderr.write(`nimbus start: --restart must be never or on-failure, got ${policy}\n`);
|
|
356
|
+
return 2;
|
|
357
|
+
}
|
|
358
|
+
restart = policy;
|
|
359
|
+
}
|
|
360
|
+
else if (arg === '--') {
|
|
361
|
+
i += 1;
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
else if (arg.startsWith('--')) {
|
|
365
|
+
ctx.stderr.write(`nimbus start: unknown flag ${arg}\n`);
|
|
366
|
+
return 2;
|
|
367
|
+
}
|
|
368
|
+
else
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
const [command, ...commandArgs] = args.slice(i);
|
|
372
|
+
if (!command) {
|
|
373
|
+
ctx.stderr.write('usage: nimbus start [--restart never|on-failure] <command> [args...]\n');
|
|
374
|
+
return 2;
|
|
375
|
+
}
|
|
376
|
+
const handler = registry.resolve ? await registry.resolve(command) : null;
|
|
377
|
+
if (!handler) {
|
|
378
|
+
ctx.stderr.write(`nimbus start: ${command}: command not found\n`);
|
|
379
|
+
return 127;
|
|
380
|
+
}
|
|
381
|
+
// The shell hands `nimbus` its full CommandContext; ShellCtx is only the
|
|
382
|
+
// slice this module reads, so the spread carries everything the command
|
|
383
|
+
// needs (signal, vfs, stdin, ...) through untouched.
|
|
384
|
+
const full = ctx;
|
|
385
|
+
return handler({
|
|
386
|
+
...full,
|
|
387
|
+
args: commandArgs,
|
|
388
|
+
env: { ...full.env, NIMBUS_RESTART: restart },
|
|
389
|
+
});
|
|
390
|
+
}
|
|
226
391
|
// ── install ──────────────────────────────────────────────────────────
|
|
227
392
|
async function runInstall(args, ctx, deps) {
|
|
228
393
|
// Flag parsing.
|
|
@@ -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,
|
|
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,CAiLrE"}
|
|
@@ -28,6 +28,8 @@ export function rubyResidentStart(facetMgr) {
|
|
|
28
28
|
const command = args.command;
|
|
29
29
|
const workerCode = buildRubySocketProcessWorker(buildRubyPreamble());
|
|
30
30
|
const spawned = await facetMgr.spawnWorker(workerCode, command, args.cwd, {
|
|
31
|
+
resident: { argv: args.argv, runtime: 'ruby' },
|
|
32
|
+
restart: args.startArgs.userEnv.NIMBUS_RESTART === 'on-failure' ? 'on-failure' : 'never',
|
|
31
33
|
compatibilityFlags: ['nodejs_compat'],
|
|
32
34
|
// By path, not by value: the image is 34.3 MiB — more than a single RPC
|
|
33
35
|
// value may carry — so whichever host runs this process reads it itself.
|