@nimbus-sh/worker 0.1.5 → 0.1.6
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 +37 -0
- package/dist/_shared/crypto.d.ts +15 -0
- package/dist/_shared/crypto.d.ts.map +1 -0
- package/dist/_shared/crypto.js +122 -0
- package/dist/facets/manager.d.ts +24 -0
- package/dist/facets/manager.d.ts.map +1 -1
- package/dist/facets/manager.js +279 -70
- package/dist/facets/process.d.ts +11 -2
- package/dist/facets/process.d.ts.map +1 -1
- package/dist/facets/process.js +187 -21
- package/dist/facets/vite-dev-server.d.ts +2 -0
- package/dist/facets/vite-dev-server.d.ts.map +1 -1
- package/dist/facets/vite-dev-server.js +39 -12
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/loaders/child-process/spawn-facet.d.ts +1 -3
- package/dist/loaders/child-process/spawn-facet.d.ts.map +1 -1
- package/dist/loaders/child-process/spawn-facet.js +1 -12
- package/dist/loaders/child-process/spawn-pool.d.ts +1 -1
- package/dist/loaders/child-process/spawn-pool.d.ts.map +1 -1
- package/dist/loaders/child-process/spawn-pool.js +1 -6
- package/dist/npm/installer.d.ts.map +1 -1
- package/dist/npm/installer.js +47 -27
- package/dist/npm/pre-bundle-facet.d.ts.map +1 -1
- package/dist/npm/pre-bundle-facet.js +2 -1
- package/dist/npm/resolve-one-facet.d.ts.map +1 -1
- package/dist/npm/resolve-one-facet.js +41 -13
- package/dist/npm/resolver.d.ts.map +1 -1
- package/dist/npm/resolver.js +70 -35
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +45 -21
- package/dist/router/remote-api.d.ts.map +1 -1
- package/dist/router/remote-api.js +29 -8
- package/dist/runtime/barrel-synthesizer.d.ts +7 -0
- package/dist/runtime/barrel-synthesizer.d.ts.map +1 -1
- package/dist/runtime/barrel-synthesizer.js +11 -0
- package/dist/runtime/clang-runner.d.ts.map +1 -1
- package/dist/runtime/clang-runner.js +1 -8
- package/dist/runtime/esbuild-service.d.ts +12 -5
- package/dist/runtime/esbuild-service.d.ts.map +1 -1
- package/dist/runtime/esbuild-service.js +28 -14
- package/dist/runtime/node-runner.d.ts +2 -0
- package/dist/runtime/node-runner.d.ts.map +1 -1
- package/dist/runtime/node-shims.d.ts +4 -2
- package/dist/runtime/node-shims.d.ts.map +1 -1
- package/dist/runtime/node-shims.js +404 -55
- package/dist/runtime/os-contracts.d.ts +128 -0
- package/dist/runtime/os-contracts.d.ts.map +1 -0
- package/dist/runtime/os-contracts.js +1 -0
- package/dist/runtime/package-manager.d.ts.map +1 -1
- package/dist/runtime/package-manager.js +32 -7
- package/dist/runtime/port-registry.d.ts +5 -0
- package/dist/runtime/port-registry.d.ts.map +1 -1
- package/dist/runtime/port-registry.js +22 -1
- package/dist/runtime/pyodide-runtime-assets.d.ts +19 -0
- package/dist/runtime/pyodide-runtime-assets.d.ts.map +1 -0
- package/dist/runtime/pyodide-runtime-assets.js +44 -0
- package/dist/runtime/python-repl.d.ts +3 -1
- package/dist/runtime/python-repl.d.ts.map +1 -1
- package/dist/runtime/python-repl.js +11 -29
- package/dist/runtime/python-runner.d.ts +8 -9
- package/dist/runtime/python-runner.d.ts.map +1 -1
- package/dist/runtime/python-runner.js +897 -61
- package/dist/runtime/python-socket-shim.d.ts +11 -0
- package/dist/runtime/python-socket-shim.d.ts.map +1 -0
- package/dist/runtime/python-socket-shim.js +526 -0
- package/dist/runtime/require-resolver.d.ts.map +1 -1
- package/dist/runtime/require-resolver.js +2 -11
- package/dist/runtime/ruby-gems.d.ts +25 -0
- package/dist/runtime/ruby-gems.d.ts.map +1 -0
- package/dist/runtime/ruby-gems.js +582 -0
- package/dist/runtime/ruby-runner.d.ts +2 -4
- package/dist/runtime/ruby-runner.d.ts.map +1 -1
- package/dist/runtime/ruby-runner.js +335 -34
- package/dist/runtime/runtime-catalog.d.ts +16 -4
- package/dist/runtime/runtime-catalog.d.ts.map +1 -1
- package/dist/runtime/runtime-catalog.js +21 -10
- package/dist/runtime/runtime-registry.d.ts +3 -0
- package/dist/runtime/runtime-registry.d.ts.map +1 -1
- package/dist/runtime/runtime-registry.js +4 -0
- package/dist/runtime/sqlite-runtime-fs-bridge.d.ts +43 -0
- package/dist/runtime/sqlite-runtime-fs-bridge.d.ts.map +1 -0
- package/dist/runtime/sqlite-runtime-fs-bridge.js +224 -0
- package/dist/runtime/static-server.d.ts +3 -0
- package/dist/runtime/static-server.d.ts.map +1 -0
- package/dist/runtime/static-server.js +121 -0
- package/dist/runtime/vfs-snapshot.d.ts +57 -0
- package/dist/runtime/vfs-snapshot.d.ts.map +1 -0
- package/dist/runtime/vfs-snapshot.js +141 -0
- package/dist/runtime/virtual-socket-kernel.d.ts +16 -0
- package/dist/runtime/virtual-socket-kernel.d.ts.map +1 -0
- package/dist/runtime/virtual-socket-kernel.js +360 -0
- package/dist/runtime/wasi-instance.d.ts +6 -3
- package/dist/runtime/wasi-instance.d.ts.map +1 -1
- package/dist/runtime/wasm-runner.d.ts +1 -25
- package/dist/runtime/wasm-runner.d.ts.map +1 -1
- package/dist/runtime/wasm-runner.js +1 -160
- package/dist/session/agent.d.ts +43 -0
- package/dist/session/agent.d.ts.map +1 -0
- package/dist/session/agent.js +1252 -0
- package/dist/session/init.d.ts.map +1 -1
- package/dist/session/init.js +15 -16
- package/dist/session/nimbus-session.d.ts +13 -2
- package/dist/session/nimbus-session.d.ts.map +1 -1
- package/dist/session/nimbus-session.js +55 -7
- package/dist/session/programmatic.d.ts +10 -0
- package/dist/session/programmatic.d.ts.map +1 -1
- package/dist/session/programmatic.js +121 -0
- package/dist/session/routes.d.ts.map +1 -1
- package/dist/session/routes.js +19 -1
- package/dist/session/rpc.d.ts +11 -0
- package/dist/session/rpc.d.ts.map +1 -1
- package/dist/session/rpc.js +56 -43
- package/dist/session/supervisor-rpc.d.ts +15 -0
- package/dist/session/supervisor-rpc.d.ts.map +1 -1
- package/dist/session/supervisor-rpc.js +32 -0
- package/dist/session/ws.d.ts +4 -3
- package/dist/session/ws.d.ts.map +1 -1
- package/dist/session/ws.js +11 -1
- package/dist/shell/unix-commands.js +12 -16
- package/dist/vfs/path.d.ts +8 -4
- package/dist/vfs/path.d.ts.map +1 -1
- package/dist/vfs/path.js +16 -4
- package/dist/vfs/sqlite-vfs.d.ts +2 -0
- package/dist/vfs/sqlite-vfs.d.ts.map +1 -1
- package/dist/vfs/sqlite-vfs.js +11 -0
- package/dist/vfs/symlink-registry.d.ts +7 -1
- package/dist/vfs/symlink-registry.d.ts.map +1 -1
- package/dist/vfs/symlink-registry.js +16 -11
- package/package.json +4 -1
- package/public/index.html +240 -0
- package/public/s/index.html +1172 -146
- package/runtime-contracts/pyodide-workerd-adapter.json +18 -0
- package/scripts/bundle-runtime.mjs +99 -24
package/dist/facets/process.js
CHANGED
|
@@ -42,6 +42,7 @@ export const CHILD_PROCESS_MAX_DEPTH = 8;
|
|
|
42
42
|
* signal (real Node would return false from .write).
|
|
43
43
|
*/
|
|
44
44
|
const STDIN_QUEUE_MAX_BYTES = 256 * 1024; // 256 KiB
|
|
45
|
+
const STDIN_ATTACH_WAIT_MS = 500;
|
|
45
46
|
/**
|
|
46
47
|
* How long the parent's cpReadOutput long-poll waits for new chunks
|
|
47
48
|
* before returning empty. 250ms is the plan §3 target.
|
|
@@ -52,6 +53,80 @@ const READ_OUTPUT_DEFAULT_WAIT_MS = 250;
|
|
|
52
53
|
* polls by the caller.
|
|
53
54
|
*/
|
|
54
55
|
const WAIT_MAX_MS = 30_000;
|
|
56
|
+
function basenameOfCommand(command) {
|
|
57
|
+
const text = String(command || '').trim();
|
|
58
|
+
if (!text)
|
|
59
|
+
return '';
|
|
60
|
+
const slash = text.lastIndexOf('/');
|
|
61
|
+
return slash >= 0 ? text.slice(slash + 1) : text;
|
|
62
|
+
}
|
|
63
|
+
function isShellCommand(command) {
|
|
64
|
+
const base = basenameOfCommand(command);
|
|
65
|
+
return base === 'sh' || base === 'bash';
|
|
66
|
+
}
|
|
67
|
+
function normalizeVirtualCommand(command) {
|
|
68
|
+
const text = String(command || '').trim();
|
|
69
|
+
if (!text.startsWith('/'))
|
|
70
|
+
return text;
|
|
71
|
+
const base = basenameOfCommand(text);
|
|
72
|
+
const dir = text.slice(0, Math.max(0, text.length - base.length));
|
|
73
|
+
if (dir === '/bin/' || dir === '/usr/bin/' || dir === '/usr/local/bin/') {
|
|
74
|
+
return base;
|
|
75
|
+
}
|
|
76
|
+
return text;
|
|
77
|
+
}
|
|
78
|
+
function parseShellCommandArgs(args) {
|
|
79
|
+
const argv = Array.isArray(args) ? args.map(String) : [];
|
|
80
|
+
for (let i = 0; i < argv.length; i++) {
|
|
81
|
+
const arg = argv[i];
|
|
82
|
+
if (arg === '--')
|
|
83
|
+
continue;
|
|
84
|
+
if (arg === '-c') {
|
|
85
|
+
const commandLine = argv[i + 1];
|
|
86
|
+
return typeof commandLine === 'string'
|
|
87
|
+
? { commandLine, args: argv.slice(i + 2) }
|
|
88
|
+
: null;
|
|
89
|
+
}
|
|
90
|
+
if (arg.startsWith('-') && arg.length > 2) {
|
|
91
|
+
for (let j = 1; j < arg.length; j++) {
|
|
92
|
+
if (arg[j] === 'c') {
|
|
93
|
+
const commandLine = argv[i + 1];
|
|
94
|
+
return typeof commandLine === 'string'
|
|
95
|
+
? { commandLine, args: argv.slice(i + 2) }
|
|
96
|
+
: null;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (!arg.startsWith('-'))
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
function quoteShellToken(value) {
|
|
107
|
+
const text = String(value);
|
|
108
|
+
if (text.length === 0)
|
|
109
|
+
return "''";
|
|
110
|
+
let simple = true;
|
|
111
|
+
for (let i = 0; i < text.length; i++) {
|
|
112
|
+
const code = text.charCodeAt(i);
|
|
113
|
+
const ch = text[i];
|
|
114
|
+
const ok = (code >= 48 && code <= 57) ||
|
|
115
|
+
(code >= 65 && code <= 90) ||
|
|
116
|
+
(code >= 97 && code <= 122) ||
|
|
117
|
+
ch === '_' || ch === '-' || ch === '.' || ch === '/' || ch === ':' || ch === '=';
|
|
118
|
+
if (!ok) {
|
|
119
|
+
simple = false;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (simple)
|
|
124
|
+
return text;
|
|
125
|
+
return "'" + text.split("'").join("'\\''") + "'";
|
|
126
|
+
}
|
|
127
|
+
function shellLineFromSpawn(command, args) {
|
|
128
|
+
return [command, ...(Array.isArray(args) ? args : [])].map((part) => quoteShellToken(String(part))).join(' ');
|
|
129
|
+
}
|
|
55
130
|
export class FacetProcessManager {
|
|
56
131
|
children = new Map();
|
|
57
132
|
nextPid = 10_000; // child PIDs start above ProcessTable's range
|
|
@@ -107,18 +182,26 @@ export class FacetProcessManager {
|
|
|
107
182
|
this.deps.processTable.spawn(`${req.command} ${req.args.join(' ')}`.trim(), req.args, req.cwd);
|
|
108
183
|
}
|
|
109
184
|
catch { /* ignore */ }
|
|
185
|
+
const shellPlan = this._shellPlanFor(req);
|
|
186
|
+
const normalizedCommand = shellPlan ? 'sh' : normalizeVirtualCommand(req.command);
|
|
187
|
+
const dispatchReq = shellPlan
|
|
188
|
+
? { ...req, command: 'sh', args: ['-c', shellPlan.commandLine, ...shellPlan.args] }
|
|
189
|
+
: { ...req, command: normalizedCommand };
|
|
110
190
|
// Resolve command kind. Resolution failure → exit 127 (command not
|
|
111
191
|
// found), no facet at all. Same shell semantics.
|
|
112
|
-
const reg = this.deps.commandRegistry.resolve(
|
|
192
|
+
const reg = shellPlan ? { kind: 'shell-direct' } : this.deps.commandRegistry.resolve(normalizedCommand);
|
|
113
193
|
const kind = reg ? reg.kind : 'unknown';
|
|
114
|
-
// Dispatch
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
194
|
+
// Dispatch after the cpSpawn RPC has had a chance to return to the
|
|
195
|
+
// parent facet. That lets immediate child.stdin.write(); child.stdin.end()
|
|
196
|
+
// calls land in the stdin queue before a preseeded child runtime starts.
|
|
197
|
+
setTimeout(() => {
|
|
198
|
+
void this._dispatch(child, kind, dispatchReq).catch((e) => {
|
|
199
|
+
// Last-resort: if both runners somehow throw, exit 1 with the error
|
|
200
|
+
// on stderr.
|
|
201
|
+
this._appendOutput(child, 2, `Error: ${e?.message || String(e)}\n`);
|
|
202
|
+
this._stampExit(child, 1, null);
|
|
203
|
+
});
|
|
204
|
+
}, 0);
|
|
122
205
|
return { childPid: pid };
|
|
123
206
|
}
|
|
124
207
|
/** Dispatch by kind. */
|
|
@@ -140,17 +223,19 @@ export class FacetProcessManager {
|
|
|
140
223
|
// pure-builtin / facet-direct correctness; only the dispatch
|
|
141
224
|
// envelope moves to a fresh isolate).
|
|
142
225
|
if (this.deps.spawnPool) {
|
|
143
|
-
|
|
144
|
-
//
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
226
|
+
const liveStdin = kind === 'facet-direct' || kind === 'shell-direct';
|
|
227
|
+
// Pure builtins consume stdin from the request payload. Facet-direct
|
|
228
|
+
// commands receive live stdin through NIMBUS_CP_CHILD_PID and
|
|
229
|
+
// supervisor cpReadStdin, which matches Node child_process pipes.
|
|
230
|
+
const stdin = liveStdin ? '' : await this._drainStdinForBuiltin(child);
|
|
148
231
|
// Single-ownership: build a fresh request payload (not a reference
|
|
149
232
|
// to the caller's req) at the boundary.
|
|
150
233
|
const reqCopy = {
|
|
151
234
|
command: String(req.command),
|
|
152
235
|
args: Array.isArray(req.args) ? [...req.args] : [],
|
|
153
|
-
env:
|
|
236
|
+
env: liveStdin
|
|
237
|
+
? { ...child.env, NIMBUS_CP_CHILD_PID: String(child.pid) }
|
|
238
|
+
: { ...child.env },
|
|
154
239
|
cwd: String(req.cwd),
|
|
155
240
|
stdio: req.stdio,
|
|
156
241
|
detached: !!req.detached,
|
|
@@ -170,6 +255,10 @@ export class FacetProcessManager {
|
|
|
170
255
|
return;
|
|
171
256
|
}
|
|
172
257
|
// ── Legacy in-supervisor dispatch (unit-test path) ─────────────
|
|
258
|
+
if (kind === 'shell-direct') {
|
|
259
|
+
await this._dispatchShell(child, req, hooks);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
173
262
|
if (kind === 'pure-builtin') {
|
|
174
263
|
// Drain stdin synchronously — pure builtins are sync-style; they
|
|
175
264
|
// expect a complete stdin string. The parent must call stdinEnd()
|
|
@@ -193,9 +282,9 @@ export class FacetProcessManager {
|
|
|
193
282
|
const payload = JSON.stringify({
|
|
194
283
|
command: req.command,
|
|
195
284
|
args: req.args,
|
|
196
|
-
env: child.env,
|
|
285
|
+
env: { ...child.env, NIMBUS_CP_CHILD_PID: String(child.pid) },
|
|
197
286
|
cwd: req.cwd,
|
|
198
|
-
stdin: '',
|
|
287
|
+
stdin: '',
|
|
199
288
|
});
|
|
200
289
|
// Register the facet-slot so kill() can find the abort handle.
|
|
201
290
|
child.facetSlot = { abort: undefined, killed: false };
|
|
@@ -234,6 +323,20 @@ export class FacetProcessManager {
|
|
|
234
323
|
const childEnv = {
|
|
235
324
|
...(req.env || {}),
|
|
236
325
|
};
|
|
326
|
+
if (kind === 'shell-direct') {
|
|
327
|
+
try {
|
|
328
|
+
const plan = this._shellPlanFor(req);
|
|
329
|
+
if (!plan) {
|
|
330
|
+
return { exitCode: 127, stdout: '', stderr: `${req.command}: unsupported shell invocation\n` };
|
|
331
|
+
}
|
|
332
|
+
const code = await this._runShellLine(plan.commandLine, childEnv, String(req.cwd || '/home/user'), '', hooks);
|
|
333
|
+
return { exitCode: typeof code === 'number' ? code : 0, stdout: stdoutBuf, stderr: stderrBuf };
|
|
334
|
+
}
|
|
335
|
+
catch (e) {
|
|
336
|
+
stderrBuf += `shell error: ${e?.message || String(e)}\n`;
|
|
337
|
+
return { exitCode: 1, stdout: stdoutBuf, stderr: stderrBuf };
|
|
338
|
+
}
|
|
339
|
+
}
|
|
237
340
|
if (kind === 'pure-builtin') {
|
|
238
341
|
try {
|
|
239
342
|
const code = await this.deps.commandRegistry.runPureBuiltin(req.command, req.args, childEnv, String(req.cwd || '/home/user'), typeof req.stdin === 'string' ? req.stdin : '', hooks);
|
|
@@ -250,7 +353,7 @@ export class FacetProcessManager {
|
|
|
250
353
|
args: req.args,
|
|
251
354
|
env: childEnv,
|
|
252
355
|
cwd: String(req.cwd || '/home/user'),
|
|
253
|
-
stdin:
|
|
356
|
+
stdin: '',
|
|
254
357
|
});
|
|
255
358
|
try {
|
|
256
359
|
const code = await this.deps.facetMgr.execStream(payload,
|
|
@@ -270,13 +373,76 @@ export class FacetProcessManager {
|
|
|
270
373
|
* on full stdin so we have to commit upfront — the parent should have
|
|
271
374
|
* called stdinEnd() before the wait ticks expire.
|
|
272
375
|
*/
|
|
376
|
+
async _waitForStdinEvent(child, waitMs) {
|
|
377
|
+
if (child.stdinClosed)
|
|
378
|
+
return;
|
|
379
|
+
await new Promise((resolve) => {
|
|
380
|
+
const timer = setTimeout(() => {
|
|
381
|
+
const idx = child.stdinWaiters.indexOf(wrapped);
|
|
382
|
+
if (idx >= 0)
|
|
383
|
+
child.stdinWaiters.splice(idx, 1);
|
|
384
|
+
resolve();
|
|
385
|
+
}, Math.max(0, waitMs));
|
|
386
|
+
const wrapped = () => {
|
|
387
|
+
clearTimeout(timer);
|
|
388
|
+
resolve();
|
|
389
|
+
};
|
|
390
|
+
child.stdinWaiters.push(wrapped);
|
|
391
|
+
});
|
|
392
|
+
}
|
|
273
393
|
async _drainStdinForBuiltin(child) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
394
|
+
if (!child.stdinClosed && child.stdinChunks.length === 0) {
|
|
395
|
+
await this._waitForStdinEvent(child, STDIN_ATTACH_WAIT_MS);
|
|
396
|
+
}
|
|
397
|
+
if (!child.stdinClosed && child.stdinChunks.length > 0) {
|
|
398
|
+
await this._waitForStdinEvent(child, STDIN_ATTACH_WAIT_MS);
|
|
277
399
|
}
|
|
278
400
|
return child.stdinChunks.join('');
|
|
279
401
|
}
|
|
402
|
+
_shellPlanFor(req) {
|
|
403
|
+
const args = Array.isArray(req.args) ? req.args.map(String) : [];
|
|
404
|
+
if (req.shell) {
|
|
405
|
+
if (isShellCommand(req.command))
|
|
406
|
+
return parseShellCommandArgs(args);
|
|
407
|
+
return { commandLine: shellLineFromSpawn(String(req.command), args), args: [] };
|
|
408
|
+
}
|
|
409
|
+
if (!isShellCommand(req.command))
|
|
410
|
+
return null;
|
|
411
|
+
return parseShellCommandArgs(args);
|
|
412
|
+
}
|
|
413
|
+
async _dispatchShell(child, req, hooks) {
|
|
414
|
+
const plan = this._shellPlanFor(req);
|
|
415
|
+
if (!plan) {
|
|
416
|
+
this._appendOutput(child, 2, `${req.command}: unsupported shell invocation\n`);
|
|
417
|
+
this._stampExit(child, 127, null);
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
try {
|
|
421
|
+
const stdin = await this._drainStdinForShell(child);
|
|
422
|
+
const code = await this._runShellLine(plan.commandLine, child.env, req.cwd, stdin, hooks);
|
|
423
|
+
this._stampExit(child, typeof code === 'number' ? code : 0, null);
|
|
424
|
+
}
|
|
425
|
+
catch (e) {
|
|
426
|
+
this._appendOutput(child, 2, `shell error: ${e?.message || String(e)}\n`);
|
|
427
|
+
this._stampExit(child, 1, null);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
async _drainStdinForShell(child) {
|
|
431
|
+
if (!child.stdinClosed && child.stdinChunks.length === 0) {
|
|
432
|
+
await this._waitForStdinEvent(child, STDIN_ATTACH_WAIT_MS);
|
|
433
|
+
}
|
|
434
|
+
if (!child.stdinClosed && child.stdinChunks.length > 0) {
|
|
435
|
+
await this._waitForStdinEvent(child, STDIN_ATTACH_WAIT_MS);
|
|
436
|
+
}
|
|
437
|
+
return child.stdinChunks.join('');
|
|
438
|
+
}
|
|
439
|
+
async _runShellLine(commandLine, env, cwd, stdin, hooks) {
|
|
440
|
+
if (!this.deps.shellExecutor) {
|
|
441
|
+
hooks.onStderr('sh: shell executor unavailable\n');
|
|
442
|
+
return 127;
|
|
443
|
+
}
|
|
444
|
+
return this.deps.shellExecutor.execute(commandLine, env, cwd || '/home/user', stdin, hooks);
|
|
445
|
+
}
|
|
280
446
|
// ── stdin queue ─────────────────────────────────────────────────────────
|
|
281
447
|
stdinWrite(childPid, data) {
|
|
282
448
|
const child = this.children.get(childPid);
|
|
@@ -213,6 +213,8 @@ export declare class ViteDevServer {
|
|
|
213
213
|
handleRequest(request: Request, pathname: string): Promise<Response>;
|
|
214
214
|
private _handleRequestInner;
|
|
215
215
|
private serveIndexHtml;
|
|
216
|
+
private getBarrelModuleCacheInfo;
|
|
217
|
+
private cachedModuleMatchesBarrelInput;
|
|
216
218
|
private serveModule;
|
|
217
219
|
/**
|
|
218
220
|
* Cold path of serveModule: package resolution → on-demand facet
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-dev-server.d.ts","sourceRoot":"","sources":["../../src/facets/vite-dev-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"vite-dev-server.d.ts","sourceRoot":"","sources":["../../src/facets/vite-dev-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAqBpE,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,SAAS,CAAC;IACf,OAAO,EAAE,cAAc,CAAC;IACxB,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IAC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CAAC,cAAc;IAyBtB;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,oBAAoB;IAkE5B;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,eAAe;YAoDT,SAAS;YAiKT,gBAAgB;IAiF9B,IAAI,KAAK;;;;;;;MASR;CACF"}
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
import { getSharedRuntimeExternals, BUNDLER_VERSION } from '../runtime/esbuild-service.js';
|
|
25
25
|
import { NpmCache } from '../npm/cache.js';
|
|
26
26
|
import { countPackageFiles, BARREL_PKG_FILE_THRESHOLD, packageNameFromSpecifier } from '../runtime/barrel-detect.js';
|
|
27
|
-
import { scanNamedImports, buildSyntheticEntry, buildScopedSliceForSynthetic, syntheticEntryPath, } from '../runtime/barrel-synthesizer.js';
|
|
27
|
+
import { scanNamedImports, namedImportSignature, buildSyntheticEntry, buildScopedSliceForSynthetic, syntheticEntryPath, } from '../runtime/barrel-synthesizer.js';
|
|
28
28
|
import { resolvePackageEntry, resolveExports } from '../_shared/exports-resolver.js';
|
|
29
29
|
import { injectRouterBasename, shouldProcessForRouter } from '../runtime/router-basename.js';
|
|
30
30
|
import { TAILWIND_PLAY_BUNDLE, TAILWIND_PLAY_VERSION, } from '../tailwind-play.generated.js';
|
|
@@ -1678,16 +1678,41 @@ export class ViteDevServer {
|
|
|
1678
1678
|
});
|
|
1679
1679
|
}
|
|
1680
1680
|
// ── Module serving (/@modules/<pkg>) ──────────────────────────────────
|
|
1681
|
+
getBarrelModuleCacheInfo(specifier) {
|
|
1682
|
+
const pkgName = packageNameFromSpecifier(specifier);
|
|
1683
|
+
if (specifier !== pkgName)
|
|
1684
|
+
return null;
|
|
1685
|
+
const pkgDir = this.root + '/node_modules/' + pkgName;
|
|
1686
|
+
const fileCount = countPackageFiles(this.vfs, pkgDir);
|
|
1687
|
+
if (fileCount <= BARREL_PKG_FILE_THRESHOLD)
|
|
1688
|
+
return null;
|
|
1689
|
+
const names = scanNamedImports(this.vfs, this.root).get(pkgName) ?? null;
|
|
1690
|
+
return {
|
|
1691
|
+
pkgName,
|
|
1692
|
+
fileCount,
|
|
1693
|
+
names,
|
|
1694
|
+
inputHash: namedImportSignature(pkgName, names),
|
|
1695
|
+
};
|
|
1696
|
+
}
|
|
1697
|
+
cachedModuleMatchesBarrelInput(inputHash, barrelInfo) {
|
|
1698
|
+
if (!barrelInfo)
|
|
1699
|
+
return true;
|
|
1700
|
+
return !!barrelInfo.inputHash && inputHash === barrelInfo.inputHash;
|
|
1701
|
+
}
|
|
1681
1702
|
async serveModule(specifier, headers) {
|
|
1682
1703
|
const JS_CT = 'application/javascript; charset=utf-8';
|
|
1683
1704
|
const cacheKey = `@modules/${specifier}`;
|
|
1705
|
+
const barrelInfo = this.getBarrelModuleCacheInfo(specifier);
|
|
1684
1706
|
// 1. In-memory cache (hot path — already bundled)
|
|
1685
1707
|
const memCached = this.moduleCache.get(cacheKey);
|
|
1686
|
-
if (memCached) {
|
|
1708
|
+
if (memCached && this.cachedModuleMatchesBarrelInput(memCached.inputHash, barrelInfo)) {
|
|
1687
1709
|
return new Response(memCached.code, {
|
|
1688
1710
|
headers: { ...headers, 'Content-Type': JS_CT },
|
|
1689
1711
|
});
|
|
1690
1712
|
}
|
|
1713
|
+
else if (memCached) {
|
|
1714
|
+
this.moduleCache.delete(cacheKey);
|
|
1715
|
+
}
|
|
1691
1716
|
// 2. SQLite pre-bundle cache (warm path — from npm install pre-bundling)
|
|
1692
1717
|
// Pre-bundled modules may contain leaked bare imports if they were built
|
|
1693
1718
|
// with `external` peer deps (see npm-installer.prebundleUsedModules).
|
|
@@ -1699,14 +1724,16 @@ export class ViteDevServer {
|
|
|
1699
1724
|
// Only use cached bundles built with the current bundler version.
|
|
1700
1725
|
// Stale bundles (from older bundler versions) are treated as missing
|
|
1701
1726
|
// and re-bundled on the cold path.
|
|
1702
|
-
if (esmBundle &&
|
|
1727
|
+
if (esmBundle &&
|
|
1728
|
+
esmBundle.bundleHash === BUNDLER_VERSION &&
|
|
1729
|
+
this.cachedModuleMatchesBarrelInput(esmBundle.inputHash, barrelInfo)) {
|
|
1703
1730
|
let code = esmBundle.esmCode;
|
|
1704
1731
|
// Rewrite __require("external") calls to ESM imports so externalized
|
|
1705
1732
|
// packages (react, scheduler) actually work in the browser.
|
|
1706
1733
|
code = rewriteExternalRequires(code, this.basePath);
|
|
1707
1734
|
code = rewriteAllImports(code, this.aliases, this.basePath);
|
|
1708
1735
|
code = synthesizeCjsNamedExports(code);
|
|
1709
|
-
this.moduleCache.set(cacheKey, { code, timestamp: Date.now() });
|
|
1736
|
+
this.moduleCache.set(cacheKey, { code, timestamp: Date.now(), inputHash: esmBundle.inputHash });
|
|
1710
1737
|
return new Response(code, {
|
|
1711
1738
|
headers: { ...headers, 'Content-Type': JS_CT },
|
|
1712
1739
|
});
|
|
@@ -1728,7 +1755,7 @@ export class ViteDevServer {
|
|
|
1728
1755
|
this.onDemandQueue = new Promise((res) => { releaseSlot = res; });
|
|
1729
1756
|
try {
|
|
1730
1757
|
await prev;
|
|
1731
|
-
return await this.serveModuleCold(specifier, headers);
|
|
1758
|
+
return await this.serveModuleCold(specifier, headers, barrelInfo);
|
|
1732
1759
|
}
|
|
1733
1760
|
finally {
|
|
1734
1761
|
releaseSlot();
|
|
@@ -1750,7 +1777,7 @@ export class ViteDevServer {
|
|
|
1750
1777
|
* + semaphore wrapper in serveModule() reads cleanly. Always runs
|
|
1751
1778
|
* inside the on-demand semaphore — see serveModule's wrapper.
|
|
1752
1779
|
*/
|
|
1753
|
-
async serveModuleCold(specifier, headers) {
|
|
1780
|
+
async serveModuleCold(specifier, headers, knownBarrelInfo = null) {
|
|
1754
1781
|
const JS_CT = 'application/javascript; charset=utf-8';
|
|
1755
1782
|
const cacheKey = `@modules/${specifier}`;
|
|
1756
1783
|
// 3. On-demand bundle (cold path — resolve from node_modules, bundle via esbuild)
|
|
@@ -1776,8 +1803,9 @@ export class ViteDevServer {
|
|
|
1776
1803
|
if (resolved) {
|
|
1777
1804
|
const pkgName = packageNameFromSpecifier(specifier);
|
|
1778
1805
|
const pkgDir = this.root + '/node_modules/' + pkgName;
|
|
1779
|
-
const
|
|
1780
|
-
const
|
|
1806
|
+
const barrelInfo = knownBarrelInfo ?? this.getBarrelModuleCacheInfo(specifier);
|
|
1807
|
+
const fileCount = barrelInfo?.fileCount ?? countPackageFiles(this.vfs, pkgDir);
|
|
1808
|
+
const isBarrel = !!barrelInfo && specifier === pkgName;
|
|
1781
1809
|
let bundled = null;
|
|
1782
1810
|
const externals = getSharedRuntimeExternals(specifier);
|
|
1783
1811
|
const onDemandPool = await this.ensureOnDemandPool().catch(() => null);
|
|
@@ -1790,8 +1818,7 @@ export class ViteDevServer {
|
|
|
1790
1818
|
let synthetic = false;
|
|
1791
1819
|
let syntheticReferencedFiles = null;
|
|
1792
1820
|
if (isBarrel) {
|
|
1793
|
-
const
|
|
1794
|
-
const names = namedImports.get(pkgName);
|
|
1821
|
+
const names = barrelInfo.names;
|
|
1795
1822
|
if (!names || names.size === 0) {
|
|
1796
1823
|
// No statically-resolvable imports. We refuse to CDN-fallback
|
|
1797
1824
|
// (100% edge contract) AND we refuse to bundle the whole
|
|
@@ -1979,12 +2006,12 @@ export class ViteDevServer {
|
|
|
1979
2006
|
bundleHash: BUNDLER_VERSION,
|
|
1980
2007
|
esmCode: code,
|
|
1981
2008
|
builtAt: Date.now(),
|
|
1982
|
-
inputHash: '',
|
|
2009
|
+
inputHash: barrelInfo?.inputHash ?? '',
|
|
1983
2010
|
});
|
|
1984
2011
|
}
|
|
1985
2012
|
catch { /* non-fatal */ }
|
|
1986
2013
|
}
|
|
1987
|
-
this.moduleCache.set(cacheKey, { code, timestamp: Date.now() });
|
|
2014
|
+
this.moduleCache.set(cacheKey, { code, timestamp: Date.now(), inputHash: barrelInfo?.inputHash ?? '' });
|
|
1988
2015
|
return new Response(code, {
|
|
1989
2016
|
headers: { ...headers, 'Content-Type': JS_CT },
|
|
1990
2017
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ import { CirrusHmrRPC } from './facets/real-vite-hmr.js';
|
|
|
27
27
|
export { createNimbusHandler } from './router/index.js';
|
|
28
28
|
export type { NimbusHandler, NimbusHooks, NimbusHookContext, CustomRoutes, CreateNimbusHandlerOptions, AuthMode, NimbusAuthConfig, NimbusRemoteApiConfig, NimbusRuntimePolicy, NimbusSandboxProfile, NimbusSdkConfig, NimbusSdkRouterConfig, } from './router/index.js';
|
|
29
29
|
export { issueNimbusToken, verifyNimbusToken, NimbusAuthError, } from './auth/index.js';
|
|
30
|
+
export { generateSessionId, isValidSessionId, } from './_shared/session-id.js';
|
|
31
|
+
export { base64Utf8, base64Url, base64UrlDecode, decodeJsonBase64Url, encodeJsonBase64Url, pkceChallenge, randomBase64Url, sealJson, sha256Base64Url, unsealJson, } from './_shared/crypto.js';
|
|
30
32
|
export type { NimbusAuthEnv, NimbusTokenClaims, VerifiedNimbusToken, } from './auth/index.js';
|
|
31
33
|
export { NimbusSession, SupervisorRPC, NimbusAssetsRPC, NimbusLoaderRPC, NimbusLoadedWorker, NimbusLoadedEntrypoint, NimbusDurableObjectNamespace, NimbusDOStub, CirrusHmrRPC, };
|
|
32
34
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,4BAA4B,EAC5B,YAAY,EACb,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAUzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,YAAY,EACV,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,0BAA0B,EAC1B,QAAQ,EACR,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAmBzB,OAAO,EACL,aAAa,EACb,aAAa,EACb,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,4BAA4B,EAC5B,YAAY,EACZ,YAAY,GACb,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,GAAG,CAEnC;;AAOD,wBAAqC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,4BAA4B,EAC5B,YAAY,EACb,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAUzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,YAAY,EACV,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,0BAA0B,EAC1B,QAAQ,EACR,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,UAAU,EACV,SAAS,EACT,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,QAAQ,EACR,eAAe,EACf,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAmBzB,OAAO,EACL,aAAa,EACb,aAAa,EACb,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,4BAA4B,EAC5B,YAAY,EACZ,YAAY,GACb,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,GAAG,CAEnC;;AAOD,wBAAqC"}
|
package/dist/index.js
CHANGED
|
@@ -37,6 +37,8 @@ export { createNimbusHandler } from './router/index.js';
|
|
|
37
37
|
// to mint tokens from custom routes. `@nimbus-sh/sdk/token` re-exports
|
|
38
38
|
// from the dedicated auth subpath for application callers.
|
|
39
39
|
export { issueNimbusToken, verifyNimbusToken, NimbusAuthError, } from './auth/index.js';
|
|
40
|
+
export { generateSessionId, isValidSessionId, } from './_shared/session-id.js';
|
|
41
|
+
export { base64Utf8, base64Url, base64UrlDecode, decodeJsonBase64Url, encodeJsonBase64Url, pkceChallenge, randomBase64Url, sealJson, sha256Base64Url, unsealJson, } from './_shared/crypto.js';
|
|
40
42
|
// W6.5: install the default registry-event sink at module top so events
|
|
41
43
|
// emitted from any code path (supervisor BFS, facet drain, applyW6Registry)
|
|
42
44
|
// land in `wrangler tail` as one JSON line per event. When F-observability
|
|
@@ -18,14 +18,12 @@ export interface SpawnInIsolateSpec {
|
|
|
18
18
|
stdin?: string;
|
|
19
19
|
};
|
|
20
20
|
/** Pre-resolved kind from FacetProcessManager._dispatch. */
|
|
21
|
-
kind: 'pure-builtin' | 'facet-direct' | 'unknown';
|
|
21
|
+
kind: 'pure-builtin' | 'facet-direct' | 'shell-direct' | 'unknown';
|
|
22
22
|
/** Stable id the parent captured for the spawn (for hooks-routing). */
|
|
23
23
|
parentChildId: number | string;
|
|
24
24
|
}
|
|
25
25
|
export interface SpawnInIsolateResult {
|
|
26
26
|
exitCode: number;
|
|
27
|
-
/** Per-isolate token line used by diagnostics that verify isolate routing. */
|
|
28
|
-
marker: string;
|
|
29
27
|
stdout: string;
|
|
30
28
|
stderr: string;
|
|
31
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn-facet.d.ts","sourceRoot":"","sources":["../../../src/loaders/child-process/spawn-facet.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,kBAAkB;IACjC,wDAAwD;IACxD,GAAG,EAAE;QACH,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC5B,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;QACzB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,4DAA4D;IAC5D,IAAI,EAAE,cAAc,GAAG,cAAc,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"spawn-facet.d.ts","sourceRoot":"","sources":["../../../src/loaders/child-process/spawn-facet.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,kBAAkB;IACjC,wDAAwD;IACxD,GAAG,EAAE;QACH,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC5B,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;QACzB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,4DAA4D;IAC5D,IAAI,EAAE,cAAc,GAAG,cAAc,GAAG,cAAc,GAAG,SAAS,CAAC;IACnE,uEAAuE;IACvE,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,kBAAkB,EACxB,KAAK;IACH,UAAU,EAAE;QACV,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;YAChD,QAAQ,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAC;SAClD,CAAC,CAAC;KACJ,CAAC;CACH,KACA,OAAO,CAAC,oBAAoB,CAwC9B,CAAC"}
|
|
@@ -10,20 +10,12 @@
|
|
|
10
10
|
* the task as `fn(item, env)`.
|
|
11
11
|
*/
|
|
12
12
|
export const runSpawnInIsolate = async function runSpawnInIsolate(spec, env) {
|
|
13
|
-
// Mint or reuse the per-isolate token.
|
|
14
|
-
const g = globalThis;
|
|
15
|
-
if (typeof g.__nimbus_g3_token__ !== 'string') {
|
|
16
|
-
g.__nimbus_g3_token__ = Math.random().toString(36).slice(2, 10) +
|
|
17
|
-
Math.random().toString(36).slice(2, 6);
|
|
18
|
-
}
|
|
19
|
-
const marker = '[g3-spawn-isolate] tok=' + g.__nimbus_g3_token__ + '\n';
|
|
20
13
|
if (!spec || !spec.req) {
|
|
21
|
-
return { exitCode: 1,
|
|
14
|
+
return { exitCode: 1, stdout: '', stderr: 'spawn-facet: missing spec.req\n' };
|
|
22
15
|
}
|
|
23
16
|
if (spec.kind === 'unknown') {
|
|
24
17
|
return {
|
|
25
18
|
exitCode: 127,
|
|
26
|
-
marker,
|
|
27
19
|
stdout: '',
|
|
28
20
|
stderr: spec.req.command + ': command not found\n',
|
|
29
21
|
};
|
|
@@ -36,7 +28,6 @@ export const runSpawnInIsolate = async function runSpawnInIsolate(spec, env) {
|
|
|
36
28
|
if (!env || !env.SUPERVISOR || typeof env.SUPERVISOR.cpDispatchInline !== 'function') {
|
|
37
29
|
return {
|
|
38
30
|
exitCode: 1,
|
|
39
|
-
marker,
|
|
40
31
|
stdout: '',
|
|
41
32
|
stderr: 'spawn-facet: env.SUPERVISOR.cpDispatchInline missing\n',
|
|
42
33
|
};
|
|
@@ -45,7 +36,6 @@ export const runSpawnInIsolate = async function runSpawnInIsolate(spec, env) {
|
|
|
45
36
|
const r = await env.SUPERVISOR.cpDispatchInline(spec.req, spec.kind);
|
|
46
37
|
return {
|
|
47
38
|
exitCode: typeof r.exitCode === 'number' ? r.exitCode : 1,
|
|
48
|
-
marker,
|
|
49
39
|
stdout: typeof r.stdout === 'string' ? r.stdout : '',
|
|
50
40
|
stderr: typeof r.stderr === 'string' ? r.stderr : '',
|
|
51
41
|
};
|
|
@@ -53,7 +43,6 @@ export const runSpawnInIsolate = async function runSpawnInIsolate(spec, env) {
|
|
|
53
43
|
catch (e) {
|
|
54
44
|
return {
|
|
55
45
|
exitCode: 1,
|
|
56
|
-
marker,
|
|
57
46
|
stdout: '',
|
|
58
47
|
stderr: 'spawn-facet error: ' + (e && e.message ? e.message : String(e)) + '\n',
|
|
59
48
|
};
|
|
@@ -66,6 +66,6 @@ export declare class ChildProcessSpawnPool {
|
|
|
66
66
|
*
|
|
67
67
|
* Returns the exit code.
|
|
68
68
|
*/
|
|
69
|
-
runOne(req: SpawnPoolReq, kind: 'pure-builtin' | 'facet-direct' | 'unknown', hooks: SpawnPoolHooks, childId: number | string): Promise<number>;
|
|
69
|
+
runOne(req: SpawnPoolReq, kind: 'pure-builtin' | 'facet-direct' | 'shell-direct' | 'unknown', hooks: SpawnPoolHooks, childId: number | string): Promise<number>;
|
|
70
70
|
}
|
|
71
71
|
//# sourceMappingURL=spawn-pool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn-pool.d.ts","sourceRoot":"","sources":["../../../src/loaders/child-process/spawn-pool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAM;IAC1B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAqB;IACzC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAmB;IACxC;;;;;OAKG;IACH,OAAO,CAAC,KAAK,CAAuC;gBAExC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,kBAAkB;IAW7C;;;;;;;;OAQG;IACG,MAAM,CACV,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,cAAc,GAAG,cAAc,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"spawn-pool.d.ts","sourceRoot":"","sources":["../../../src/loaders/child-process/spawn-pool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAM;IAC1B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAqB;IACzC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAmB;IACxC;;;;;OAKG;IACH,OAAO,CAAC,KAAK,CAAuC;gBAExC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,kBAAkB;IAW7C;;;;;;;;OAQG;IACG,MAAM,CACV,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,cAAc,GAAG,cAAc,GAAG,cAAc,GAAG,SAAS,EAClE,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,MAAM,GAAG,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC;CAqDnB"}
|
|
@@ -94,7 +94,7 @@ export class ChildProcessSpawnPool {
|
|
|
94
94
|
}
|
|
95
95
|
catch (e) {
|
|
96
96
|
const msg = (e && e.message) ? String(e.message) : String(e);
|
|
97
|
-
return { exitCode: 1,
|
|
97
|
+
return { exitCode: 1, stdout: '', stderr: 'spawn-pool: ' + msg + '\n' };
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
// Update the chain BEFORE awaiting so the next caller serializes
|
|
@@ -108,11 +108,6 @@ export class ChildProcessSpawnPool {
|
|
|
108
108
|
return 1;
|
|
109
109
|
}
|
|
110
110
|
const r = results[0];
|
|
111
|
-
// Emit the per-isolate marker FIRST so the probe sees it ahead of
|
|
112
|
-
// any user-command stderr. The probe's regex `[g3-spawn-isolate]
|
|
113
|
-
// tok=…` matches this exact line.
|
|
114
|
-
if (r.marker)
|
|
115
|
-
hooks.onStderr(r.marker);
|
|
116
111
|
if (r.stdout)
|
|
117
112
|
hooks.onStdout(r.stdout);
|
|
118
113
|
if (r.stderr)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../src/npm/installer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EAAE,QAAQ,EAAsB,MAAM,YAAY,CAAC;AAC1D,OAAO,EAEiC,KAAK,OAAO,EACnD,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../src/npm/installer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EAAE,QAAQ,EAAsB,MAAM,YAAY,CAAC;AAC1D,OAAO,EAEiC,KAAK,OAAO,EACnD,MAAM,eAAe,CAAC;AAoEvB,YAAY,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEh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