noninteractive 0.3.16 → 0.3.17

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.
@@ -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.17",
351
351
  type: "module",
352
352
  bin: {
353
353
  noninteractive: "./bin/noninteractive.js"
@@ -534,29 +534,28 @@ function deriveSessionName(cmd, args) {
534
534
  async function start(cmdArgs, noOpen = false) {
535
535
  const executable = cmdArgs[0];
536
536
  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;
537
+ const baseName = deriveSessionName(executable, args);
538
+ let name = baseName;
539
+ let suffix = 1;
540
+ while (true) {
541
+ const sock2 = socketPath(name);
542
+ try {
543
+ const res = await sendMessage(sock2, { action: "read" });
544
+ if (res.ok) {
545
+ if (res.exited) {
546
+ try {
547
+ await sendMessage(sock2, { action: "stop" });
548
+ } catch {}
549
+ break;
550
+ }
551
+ suffix++;
552
+ name = `${baseName}-${suffix}`;
553
+ continue;
557
554
  }
558
- }
559
- } catch {}
555
+ } catch {}
556
+ break;
557
+ }
558
+ const sock = socketPath(name);
560
559
  ensureSessionsDir();
561
560
  try {
562
561
  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.17",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "noninteractive": "./bin/noninteractive.js"