noninteractive 0.3.17 → 0.3.19
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/bin/noninteractive.js +24 -17
- package/package.json +1 -1
package/bin/noninteractive.js
CHANGED
|
@@ -297,7 +297,7 @@ function runDaemon(sessionName, executable, args) {
|
|
|
297
297
|
socket.end(JSON.stringify({ ok: false, error: "process exited" }));
|
|
298
298
|
break;
|
|
299
299
|
}
|
|
300
|
-
stdin?.write(
|
|
300
|
+
stdin?.write(msg.data);
|
|
301
301
|
socket.end(JSON.stringify({ ok: true }));
|
|
302
302
|
break;
|
|
303
303
|
case "sendread": {
|
|
@@ -307,7 +307,7 @@ function runDaemon(sessionName, executable, args) {
|
|
|
307
307
|
}
|
|
308
308
|
const beforeLength = outputBuffer.length;
|
|
309
309
|
const timeout = msg.timeout ?? 30000;
|
|
310
|
-
stdin?.write(
|
|
310
|
+
stdin?.write(msg.data);
|
|
311
311
|
waitForNewOutput(socket, beforeLength, timeout);
|
|
312
312
|
break;
|
|
313
313
|
}
|
|
@@ -347,7 +347,7 @@ var init_daemon = __esm(() => {
|
|
|
347
347
|
var require_package = __commonJS((exports, module) => {
|
|
348
348
|
module.exports = {
|
|
349
349
|
name: "noninteractive",
|
|
350
|
-
version: "0.3.
|
|
350
|
+
version: "0.3.19",
|
|
351
351
|
type: "module",
|
|
352
352
|
bin: {
|
|
353
353
|
noninteractive: "./bin/noninteractive.js"
|
|
@@ -443,25 +443,29 @@ usage: npx noninteractive <tool> [args...]
|
|
|
443
443
|
|
|
444
444
|
commands:
|
|
445
445
|
<tool> [args...] start a session (runs npx <tool> in a PTY)
|
|
446
|
-
send <session> <text> [--wait]
|
|
446
|
+
send <session> <text> [--no-wait] send keystrokes and return output (--no-wait to fire-and-forget)
|
|
447
447
|
read <session> [--wait] [--timeout N] read terminal output (--wait blocks until new output)
|
|
448
448
|
stop <session> stop a session
|
|
449
449
|
list show active sessions
|
|
450
450
|
start <cmd> [args...] explicit start (for non-npx commands)
|
|
451
451
|
|
|
452
452
|
flags:
|
|
453
|
-
--wait
|
|
454
|
-
--
|
|
453
|
+
--no-wait fire-and-forget mode for send (don't wait for output)
|
|
454
|
+
--wait, -w block until new output appears (for read)
|
|
455
|
+
--timeout <ms> max wait time in ms (default: 30000)
|
|
455
456
|
--no-open don't auto-open URLs in browser (still shown in output)
|
|
456
457
|
|
|
457
458
|
the session name is auto-derived from the tool (e.g. "workos" \u2192 session "workos").
|
|
458
459
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
npx noninteractive
|
|
463
|
-
npx noninteractive
|
|
464
|
-
npx noninteractive
|
|
460
|
+
text is sent exactly as-is \u2014 no auto-appended enter. use $'\\r' for Enter, $'\\x1b[B' for arrow keys.
|
|
461
|
+
|
|
462
|
+
example workflow:
|
|
463
|
+
npx noninteractive workos # starts "npx workos", session = "workos"
|
|
464
|
+
npx noninteractive send workos $'\\r' # press Enter, returns output
|
|
465
|
+
npx noninteractive send workos $'y\\r' # type "y" + Enter, returns output
|
|
466
|
+
npx noninteractive send workos $'\\x1b[B\\r' # arrow down + Enter, returns output
|
|
467
|
+
npx noninteractive read workos --wait # wait for new output (e.g. OAuth callback)
|
|
468
|
+
npx noninteractive stop workos # done, stop the session
|
|
465
469
|
|
|
466
470
|
more examples:
|
|
467
471
|
npx noninteractive vercel # session "vercel"
|
|
@@ -598,7 +602,7 @@ make sure the command exists. examples:`);
|
|
|
598
602
|
} else {
|
|
599
603
|
console.log(`
|
|
600
604
|
[session '${name}' started \u2014 read the output above, then use:]`);
|
|
601
|
-
console.log(` npx noninteractive send ${name} "<text>"
|
|
605
|
+
console.log(` npx noninteractive send ${name} "<text>" # send and get response`);
|
|
602
606
|
console.log(` npx noninteractive read ${name} --wait # wait for new output`);
|
|
603
607
|
console.log(` npx noninteractive stop ${name} # stop the session`);
|
|
604
608
|
}
|
|
@@ -616,7 +620,7 @@ make sure the command exists. examples:`);
|
|
|
616
620
|
} catch {}
|
|
617
621
|
}
|
|
618
622
|
console.log(`[session '${name}' started but no output yet \u2014 use:]`);
|
|
619
|
-
console.log(` npx noninteractive send ${name} "<text>"
|
|
623
|
+
console.log(` npx noninteractive send ${name} "<text>" # send and get response`);
|
|
620
624
|
console.log(` npx noninteractive read ${name} --wait # wait for new output`);
|
|
621
625
|
console.log(` npx noninteractive stop ${name} # stop the session`);
|
|
622
626
|
}
|
|
@@ -637,6 +641,8 @@ async function read(name, wait, timeout, noOpen = false) {
|
|
|
637
641
|
[exited ${res.exitCode}]`);
|
|
638
642
|
}
|
|
639
643
|
async function send(name, text, wait, timeout, noOpen = false) {
|
|
644
|
+
if (text === "")
|
|
645
|
+
text = "\r";
|
|
640
646
|
const sock = socketPath(name);
|
|
641
647
|
if (wait) {
|
|
642
648
|
const res = await sendMessage(sock, { action: "sendread", data: text, timeout }, timeout + 5000);
|
|
@@ -718,12 +724,13 @@ example: npx noninteractive read vercel --wait`);
|
|
|
718
724
|
const name = positional[0];
|
|
719
725
|
const text = positional[1];
|
|
720
726
|
if (!name || text === undefined) {
|
|
721
|
-
console.error(`usage: noninteractive send <session> <text> [--wait] [--timeout <ms>]
|
|
727
|
+
console.error(`usage: noninteractive send <session> <text> [--no-wait] [--timeout <ms>]
|
|
722
728
|
|
|
723
|
-
example: npx noninteractive send workos ""
|
|
729
|
+
example: npx noninteractive send workos ""`);
|
|
724
730
|
process.exit(1);
|
|
725
731
|
}
|
|
726
|
-
const
|
|
732
|
+
const noWait = sendArgs.includes("--no-wait") || sendArgs.includes("--silent");
|
|
733
|
+
const wait = !noWait || cmd === "sendread" || sendArgs.includes("-w") || sendArgs.includes("--wait");
|
|
727
734
|
const timeoutIdx = sendArgs.indexOf("--timeout");
|
|
728
735
|
const timeout = timeoutIdx !== -1 ? Number(sendArgs[timeoutIdx + 1]) : 30000;
|
|
729
736
|
return send(name, text, wait, timeout, noOpen);
|