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.
@@ -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(`${msg.data}\r`);
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(`${msg.data}\r`);
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.16",
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
- example workflow (recommended \u2014 uses --wait to minimize round-trips):
460
- npx noninteractive workos # starts "npx workos", session = "workos"
461
- npx noninteractive send workos "" --wait # press Enter, wait for response
462
- npx noninteractive send workos "y" --wait # type "y", wait for response
463
- npx noninteractive read workos --wait # wait for new output (e.g. OAuth callback)
464
- npx noninteractive stop workos # done, stop the session
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 name = deriveSessionName(executable, args);
538
- const sock = socketPath(name);
539
- try {
540
- const res = await sendMessage(sock, { action: "read" });
541
- if (res.ok) {
542
- process.stdout.write(stripAnsi(res.output ?? ""));
543
- handleUrls(res, noOpen);
544
- if (res.exited) {
545
- console.log(`
546
- [session '${name}' already exists but exited ${res.exitCode} \u2014 stopping it]`);
547
- try {
548
- await sendMessage(sock, { action: "stop" });
549
- } catch {}
550
- } else {
551
- console.log(`
552
- [session '${name}' already running \u2014 read the output above, then use:]`);
553
- console.log(` npx noninteractive send ${name} "<text>" --wait # send and wait for response`);
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
- } catch {}
558
+ } catch {}
559
+ break;
560
+ }
561
+ const sock = socketPath(name);
560
562
  ensureSessionsDir();
561
563
  try {
562
564
  const { unlinkSync: unlinkSync2 } = await import("fs");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noninteractive",
3
- "version": "0.3.16",
3
+ "version": "0.3.18",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "noninteractive": "./bin/noninteractive.js"