noninteractive 0.3.10 → 0.3.12

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/README.md CHANGED
@@ -61,7 +61,7 @@ npx noninteractive stop workos
61
61
 
62
62
  ## The `--wait` flag
63
63
 
64
- Both `send` and `read` support `--wait` (`-w`), which blocks until new output appears instead of returning immediately. This eliminates polling loops and reduces tool calls by ~7-10x.
64
+ Both `send` and `read` support `--wait` (`-w`), which blocks until new output appears instead of returning immediately. This eliminates polling loops and reduces tool calls by ~7-10x. Output is returned as clean text with ANSI escape codes stripped by default, so agents get readable content without terminal formatting noise.
65
65
 
66
66
  ```bash
67
67
  # Old way (polling): send + read + read + read...
@@ -243,7 +243,7 @@ var init_daemon = __esm(() => {
243
243
  var require_package = __commonJS((exports, module) => {
244
244
  module.exports = {
245
245
  name: "noninteractive",
246
- version: "0.3.10",
246
+ version: "0.3.12",
247
247
  type: "module",
248
248
  bin: {
249
249
  noninteractive: "./bin/noninteractive.js"
@@ -362,6 +362,8 @@ more examples:
362
362
  npx noninteractive vercel # session "vercel"
363
363
  npx noninteractive supabase init # session "supabase"
364
364
  npx noninteractive start vercel login # explicit start for non-npx commands`;
365
+ var stripAnsi = (s) => s.replace(/\x1b\[[\x20-\x3f]*[\x40-\x7e]|\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b[()][A-Z0-9]|\x1b[\x20-\x2f]*[\x30-\x7e]|\x07/g, "").replace(/\r\n?/g, `
366
+ `);
365
367
  function getSelfCommand() {
366
368
  const script = process.argv[1];
367
369
  if (!script)
@@ -386,7 +388,8 @@ function deriveSessionName(cmd, args) {
386
388
  while (i < parts.length && parts[i].startsWith("-"))
387
389
  i++;
388
390
  const name = parts[i] || cmd;
389
- return name.replace(/^@[^/]+\//, "").replace(/[^a-zA-Z0-9_-]/g, "");
391
+ const stripped = name.replace(/(?<=.)@[^/].*$/, "");
392
+ return (stripped || name).replace(/^@[^/]+\//, "").replace(/[^a-zA-Z0-9_-]/g, "");
390
393
  }
391
394
  async function start(cmdArgs) {
392
395
  const executable = cmdArgs[0];
@@ -396,7 +399,7 @@ async function start(cmdArgs) {
396
399
  try {
397
400
  const res = await sendMessage(sock, { action: "read" });
398
401
  if (res.ok) {
399
- process.stdout.write(res.output ?? "");
402
+ process.stdout.write(stripAnsi(res.output ?? ""));
400
403
  if (res.exited) {
401
404
  console.log(`
402
405
  [session '${name}' already exists but exited ${res.exitCode} \u2014 stopping it]`);
@@ -438,14 +441,13 @@ make sure the command exists. examples:`);
438
441
  console.error(` npx noninteractive start vercel login # run a command directly`);
439
442
  process.exit(1);
440
443
  }
441
- const stripAnsi = (s) => s.replace(/\x1b\[[0-9;]*[a-zA-Z]|\x1b\][^\x07]*\x07/g, "");
442
444
  for (let i = 0;i < 50; i++) {
443
445
  await new Promise((r) => setTimeout(r, 200));
444
446
  try {
445
447
  const res = await sendMessage(sock, { action: "read" });
446
448
  const clean = stripAnsi(res.output ?? "").trim();
447
449
  if (clean.length > 10) {
448
- process.stdout.write(res.output);
450
+ process.stdout.write(stripAnsi(res.output));
449
451
  if (res.exited) {
450
452
  console.log(`
451
453
  [session '${name}' exited ${res.exitCode} \u2014 the command failed]`);
@@ -462,7 +464,7 @@ make sure the command exists. examples:`);
462
464
  return;
463
465
  }
464
466
  if (res.exited) {
465
- process.stdout.write(res.output ?? "");
467
+ process.stdout.write(stripAnsi(res.output ?? ""));
466
468
  console.log(`
467
469
  [session '${name}' exited ${res.exitCode} \u2014 the command failed]`);
468
470
  console.log(`hint: the first argument to "start" is the command to run, NOT a session name.`);
@@ -487,7 +489,7 @@ async function read(name, wait, timeout) {
487
489
  const clientTimeout = wait ? timeout + 5000 : 5000;
488
490
  const res = await sendMessage(sock, msg, clientTimeout);
489
491
  if (res.output !== undefined)
490
- process.stdout.write(res.output);
492
+ process.stdout.write(stripAnsi(res.output));
491
493
  if (res.exited)
492
494
  console.log(`
493
495
  [exited ${res.exitCode}]`);
@@ -497,7 +499,7 @@ async function send(name, text, wait, timeout) {
497
499
  if (wait) {
498
500
  const res = await sendMessage(sock, { action: "sendread", data: text, timeout }, timeout + 5000);
499
501
  if (res.output !== undefined)
500
- process.stdout.write(res.output);
502
+ process.stdout.write(stripAnsi(res.output));
501
503
  if (res.exited)
502
504
  console.log(`
503
505
  [exited ${res.exitCode}]`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noninteractive",
3
- "version": "0.3.10",
3
+ "version": "0.3.12",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "noninteractive": "./bin/noninteractive.js"