robot-resources 1.12.2 → 1.12.3
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/lib/non-oc-wizard.js +60 -11
- package/package.json +1 -1
package/lib/non-oc-wizard.js
CHANGED
|
@@ -266,19 +266,40 @@ export async function runNonOcWizard({ nonInteractive = false, target = null } =
|
|
|
266
266
|
|
|
267
267
|
const defaultPath = detectDefaultPath() ?? 'js';
|
|
268
268
|
|
|
269
|
+
// Phase 3.6: race the prompt against a timeout. Some agent runners report
|
|
270
|
+
// stdin.isTTY=true (so `nonInteractive` ends up false), then never deliver
|
|
271
|
+
// a keystroke — `select()` blocks forever and the wizard exits silently
|
|
272
|
+
// without firing wizard_path_chosen. The May-2 23:31 RU cluster all hit
|
|
273
|
+
// this: 5 wizard_started events, zero wizard_path_chosen.
|
|
274
|
+
//
|
|
275
|
+
// After SELECT_TIMEOUT_MS, we treat the session as practically
|
|
276
|
+
// non-interactive and fall through to the same auto-detect path the
|
|
277
|
+
// nonInteractive branch above uses (Phase 3.5).
|
|
278
|
+
const SELECT_TIMEOUT_MS = Number(process.env.RR_WIZARD_SELECT_TIMEOUT_MS) || 30_000;
|
|
279
|
+
const TIMED_OUT = Symbol('select_timeout');
|
|
280
|
+
|
|
269
281
|
let chosen;
|
|
282
|
+
let timer;
|
|
270
283
|
try {
|
|
271
|
-
chosen = await
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
284
|
+
chosen = await Promise.race([
|
|
285
|
+
select({
|
|
286
|
+
message: 'What are you building?',
|
|
287
|
+
default: defaultPath,
|
|
288
|
+
choices: [
|
|
289
|
+
{ name: PATH_LABELS.js, value: 'js' },
|
|
290
|
+
{ name: PATH_LABELS.python, value: 'python' },
|
|
291
|
+
{ name: PATH_LABELS.mcp, value: 'mcp' },
|
|
292
|
+
{ name: PATH_LABELS.docs, value: 'docs' },
|
|
293
|
+
{ name: PATH_LABELS['install-oc'], value: 'install-oc' },
|
|
294
|
+
],
|
|
295
|
+
}),
|
|
296
|
+
new Promise((resolve) => {
|
|
297
|
+
timer = setTimeout(() => resolve(TIMED_OUT), SELECT_TIMEOUT_MS);
|
|
298
|
+
// Don't keep the event loop alive purely for this timer — once the
|
|
299
|
+
// user picks, the process should be free to exit.
|
|
300
|
+
if (typeof timer.unref === 'function') timer.unref();
|
|
301
|
+
}),
|
|
302
|
+
]);
|
|
282
303
|
} catch (err) {
|
|
283
304
|
// User hit Ctrl-C or terminal closed — exit cleanly, but mark the funnel
|
|
284
305
|
// so we can distinguish "agent shown the prompt and bailed" from
|
|
@@ -288,6 +309,34 @@ export async function runNonOcWizard({ nonInteractive = false, target = null } =
|
|
|
288
309
|
return;
|
|
289
310
|
}
|
|
290
311
|
throw err;
|
|
312
|
+
} finally {
|
|
313
|
+
if (timer) clearTimeout(timer);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if (chosen === TIMED_OUT) {
|
|
317
|
+
// No keystroke after SELECT_TIMEOUT_MS — practically non-interactive.
|
|
318
|
+
// Mirror the Phase 3.5 auto-detect logic.
|
|
319
|
+
blank();
|
|
320
|
+
info(`No input received after ${Math.round(SELECT_TIMEOUT_MS / 1000)}s — treating session as non-interactive.`);
|
|
321
|
+
const runtime = detectAgentRuntime();
|
|
322
|
+
let autoTarget = null;
|
|
323
|
+
if (runtime.kind === 'node' || runtime.kind === 'both') autoTarget = 'js';
|
|
324
|
+
else if (runtime.kind === 'python') autoTarget = 'python';
|
|
325
|
+
|
|
326
|
+
if (autoTarget) {
|
|
327
|
+
info(`Detected a ${autoTarget === 'js' ? 'Node' : 'Python'} project — installing the matching shim automatically.`);
|
|
328
|
+
blank();
|
|
329
|
+
await runPath(autoTarget);
|
|
330
|
+
await emitPathChosen(autoTarget);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Truly empty cwd — nothing to install. Surface the timeout so the
|
|
335
|
+
// funnel can be queried separately from genuine aborts.
|
|
336
|
+
blank();
|
|
337
|
+
info('No project shape detected — nothing to install. Re-run with --for=<target>.');
|
|
338
|
+
await emitPathChosen('interactive_timeout');
|
|
339
|
+
return;
|
|
291
340
|
}
|
|
292
341
|
|
|
293
342
|
await runPath(chosen);
|