noninteractive 0.3.16 → 0.3.18
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 +34 -32
- 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.18",
|
|
351
351
|
type: "module",
|
|
352
352
|
bin: {
|
|
353
353
|
noninteractive: "./bin/noninteractive.js"
|
|
@@ -443,7 +443,7 @@ 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] send keystrokes (--wait waits for new output)
|
|
446
|
+
send <session> <text> [--wait] send raw keystrokes (--wait waits for new output)
|
|
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
|
|
@@ -456,12 +456,15 @@ flags:
|
|
|
456
456
|
|
|
457
457
|
the session name is auto-derived from the tool (e.g. "workos" \u2192 session "workos").
|
|
458
458
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
npx noninteractive
|
|
463
|
-
npx noninteractive
|
|
464
|
-
npx noninteractive
|
|
459
|
+
text is sent exactly as-is \u2014 no auto-appended enter. use $'\\r' for Enter, $'\\x1b[B' for arrow keys.
|
|
460
|
+
|
|
461
|
+
example workflow:
|
|
462
|
+
npx noninteractive workos # starts "npx workos", session = "workos"
|
|
463
|
+
npx noninteractive send workos $'\\r' --wait # press Enter, wait for response
|
|
464
|
+
npx noninteractive send workos $'y\\r' --wait # type "y" + Enter, wait for response
|
|
465
|
+
npx noninteractive send workos $'\\x1b[B\\r' --wait # arrow down + Enter
|
|
466
|
+
npx noninteractive read workos --wait # wait for new output (e.g. OAuth callback)
|
|
467
|
+
npx noninteractive stop workos # done, stop the session
|
|
465
468
|
|
|
466
469
|
more examples:
|
|
467
470
|
npx noninteractive vercel # session "vercel"
|
|
@@ -534,29 +537,28 @@ function deriveSessionName(cmd, args) {
|
|
|
534
537
|
async function start(cmdArgs, noOpen = false) {
|
|
535
538
|
const executable = cmdArgs[0];
|
|
536
539
|
const args = cmdArgs.slice(1);
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
if (res.
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
console.log(` npx noninteractive read ${name} --wait # wait for new output`);
|
|
555
|
-
console.log(` npx noninteractive stop ${name} # stop the session`);
|
|
556
|
-
return;
|
|
540
|
+
const baseName = deriveSessionName(executable, args);
|
|
541
|
+
let name = baseName;
|
|
542
|
+
let suffix = 1;
|
|
543
|
+
while (true) {
|
|
544
|
+
const sock2 = socketPath(name);
|
|
545
|
+
try {
|
|
546
|
+
const res = await sendMessage(sock2, { action: "read" });
|
|
547
|
+
if (res.ok) {
|
|
548
|
+
if (res.exited) {
|
|
549
|
+
try {
|
|
550
|
+
await sendMessage(sock2, { action: "stop" });
|
|
551
|
+
} catch {}
|
|
552
|
+
break;
|
|
553
|
+
}
|
|
554
|
+
suffix++;
|
|
555
|
+
name = `${baseName}-${suffix}`;
|
|
556
|
+
continue;
|
|
557
557
|
}
|
|
558
|
-
}
|
|
559
|
-
|
|
558
|
+
} catch {}
|
|
559
|
+
break;
|
|
560
|
+
}
|
|
561
|
+
const sock = socketPath(name);
|
|
560
562
|
ensureSessionsDir();
|
|
561
563
|
try {
|
|
562
564
|
const { unlinkSync: unlinkSync2 } = await import("fs");
|