noninteractive 0.3.18 → 0.3.20

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.
@@ -168,13 +168,22 @@ function runDaemon(sessionName, executable, args) {
168
168
  const detectedUrls = new Set;
169
169
  const reportedUrls = new Set;
170
170
  const waiters = [];
171
+ let notifyDebounce = null;
172
+ const NOTIFY_SETTLE_MS = 50;
171
173
  function notifyWaiters() {
172
- let w = waiters.shift();
173
- while (w) {
174
- clearTimeout(w.timer);
175
- w.resolve(outputBuffer);
176
- w = waiters.shift();
177
- }
174
+ if (waiters.length === 0)
175
+ return;
176
+ if (notifyDebounce)
177
+ clearTimeout(notifyDebounce);
178
+ notifyDebounce = setTimeout(() => {
179
+ notifyDebounce = null;
180
+ let w = waiters.shift();
181
+ while (w) {
182
+ clearTimeout(w.timer);
183
+ w.resolve(outputBuffer);
184
+ w = waiters.shift();
185
+ }
186
+ }, NOTIFY_SETTLE_MS);
178
187
  }
179
188
  const binDir = sessionBinDir2(sessionName);
180
189
  const ptyBridge = getPtyBridge();
@@ -227,7 +236,15 @@ function runDaemon(sessionName, executable, args) {
227
236
  exitCode = code;
228
237
  outputBuffer += `
229
238
  [exited ${code}]`;
230
- notifyWaiters();
239
+ if (notifyDebounce)
240
+ clearTimeout(notifyDebounce);
241
+ notifyDebounce = null;
242
+ let w = waiters.shift();
243
+ while (w) {
244
+ clearTimeout(w.timer);
245
+ w.resolve(outputBuffer);
246
+ w = waiters.shift();
247
+ }
231
248
  setTimeout(() => {
232
249
  server.close();
233
250
  try {
@@ -347,7 +364,7 @@ var init_daemon = __esm(() => {
347
364
  var require_package = __commonJS((exports, module) => {
348
365
  module.exports = {
349
366
  name: "noninteractive",
350
- version: "0.3.18",
367
+ version: "0.3.20",
351
368
  type: "module",
352
369
  bin: {
353
370
  noninteractive: "./bin/noninteractive.js"
@@ -443,15 +460,16 @@ usage: npx noninteractive <tool> [args...]
443
460
 
444
461
  commands:
445
462
  <tool> [args...] start a session (runs npx <tool> in a PTY)
446
- send <session> <text> [--wait] send raw keystrokes (--wait waits for new output)
463
+ send <session> <text> [--no-wait] send keystrokes and return output (--no-wait to fire-and-forget)
447
464
  read <session> [--wait] [--timeout N] read terminal output (--wait blocks until new output)
448
465
  stop <session> stop a session
449
466
  list show active sessions
450
467
  start <cmd> [args...] explicit start (for non-npx commands)
451
468
 
452
469
  flags:
453
- --wait, -w block until new output appears (for send and read)
454
- --timeout <ms> max wait time in ms (default: 30000, used with --wait)
470
+ --no-wait fire-and-forget mode for send (don't wait for output)
471
+ --wait, -w block until new output appears (for read)
472
+ --timeout <ms> max wait time in ms (default: 30000)
455
473
  --no-open don't auto-open URLs in browser (still shown in output)
456
474
 
457
475
  the session name is auto-derived from the tool (e.g. "workos" \u2192 session "workos").
@@ -460,9 +478,9 @@ text is sent exactly as-is \u2014 no auto-appended enter. use $'\\r' for Enter,
460
478
 
461
479
  example workflow:
462
480
  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
481
+ npx noninteractive send workos $'\\r' # press Enter, returns output
482
+ npx noninteractive send workos $'y\\r' # type "y" + Enter, returns output
483
+ npx noninteractive send workos $'\\x1b[B\\r' # arrow down + Enter, returns output
466
484
  npx noninteractive read workos --wait # wait for new output (e.g. OAuth callback)
467
485
  npx noninteractive stop workos # done, stop the session
468
486
 
@@ -601,7 +619,7 @@ make sure the command exists. examples:`);
601
619
  } else {
602
620
  console.log(`
603
621
  [session '${name}' started \u2014 read the output above, then use:]`);
604
- console.log(` npx noninteractive send ${name} "<text>" --wait # send and wait for response`);
622
+ console.log(` npx noninteractive send ${name} "<text>" # send and get response`);
605
623
  console.log(` npx noninteractive read ${name} --wait # wait for new output`);
606
624
  console.log(` npx noninteractive stop ${name} # stop the session`);
607
625
  }
@@ -619,7 +637,7 @@ make sure the command exists. examples:`);
619
637
  } catch {}
620
638
  }
621
639
  console.log(`[session '${name}' started but no output yet \u2014 use:]`);
622
- console.log(` npx noninteractive send ${name} "<text>" --wait # send and wait for response`);
640
+ console.log(` npx noninteractive send ${name} "<text>" # send and get response`);
623
641
  console.log(` npx noninteractive read ${name} --wait # wait for new output`);
624
642
  console.log(` npx noninteractive stop ${name} # stop the session`);
625
643
  }
@@ -640,6 +658,8 @@ async function read(name, wait, timeout, noOpen = false) {
640
658
  [exited ${res.exitCode}]`);
641
659
  }
642
660
  async function send(name, text, wait, timeout, noOpen = false) {
661
+ if (text === "")
662
+ text = "\r";
643
663
  const sock = socketPath(name);
644
664
  if (wait) {
645
665
  const res = await sendMessage(sock, { action: "sendread", data: text, timeout }, timeout + 5000);
@@ -721,12 +741,13 @@ example: npx noninteractive read vercel --wait`);
721
741
  const name = positional[0];
722
742
  const text = positional[1];
723
743
  if (!name || text === undefined) {
724
- console.error(`usage: noninteractive send <session> <text> [--wait] [--timeout <ms>]
744
+ console.error(`usage: noninteractive send <session> <text> [--no-wait] [--timeout <ms>]
725
745
 
726
- example: npx noninteractive send workos "" --wait`);
746
+ example: npx noninteractive send workos ""`);
727
747
  process.exit(1);
728
748
  }
729
- const wait = cmd === "sendread" || sendArgs.includes("-w") || sendArgs.includes("--wait");
749
+ const noWait = sendArgs.includes("--no-wait") || sendArgs.includes("--silent");
750
+ const wait = !noWait || cmd === "sendread" || sendArgs.includes("-w") || sendArgs.includes("--wait");
730
751
  const timeoutIdx = sendArgs.indexOf("--timeout");
731
752
  const timeout = timeoutIdx !== -1 ? Number(sendArgs[timeoutIdx + 1]) : 30000;
732
753
  return send(name, text, wait, timeout, noOpen);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noninteractive",
3
- "version": "0.3.18",
3
+ "version": "0.3.20",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "noninteractive": "./bin/noninteractive.js"