@wrongstack/cli 0.3.4 → 0.3.7

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/dist/index.js CHANGED
@@ -826,12 +826,12 @@ var ReadlineInputReader = class {
826
826
  this.pending = true;
827
827
  try {
828
828
  const rl = this.ensure();
829
- if (rl._flushed) {
829
+ if (rl.closed || rl._flushed) {
830
830
  rl.close();
831
831
  this.rl = void 0;
832
832
  }
833
833
  const fresh = this.ensure();
834
- return new Promise((resolve3, reject) => {
834
+ return new Promise((resolve3) => {
835
835
  fresh.question(prompt ?? "> ", (line) => {
836
836
  if (line.trim()) {
837
837
  this.history.push(line);
@@ -839,7 +839,11 @@ var ReadlineInputReader = class {
839
839
  }
840
840
  resolve3(line);
841
841
  });
842
- fresh.once("close", () => reject(new Error("EOF")));
842
+ fresh.once("close", () => resolve3(""));
843
+ }).then((result) => {
844
+ this.rl?.close();
845
+ this.rl = void 0;
846
+ return result;
843
847
  });
844
848
  } finally {
845
849
  this.pending = false;
@@ -855,6 +859,12 @@ var ReadlineInputReader = class {
855
859
  stdin.resume();
856
860
  const onData = (buf) => {
857
861
  const key = buf.toString();
862
+ if (key === "") {
863
+ cleanup();
864
+ process.stdout.write("\n");
865
+ resolve3("");
866
+ return;
867
+ }
858
868
  const opt = options.find(
859
869
  (o) => o.key.toLowerCase() === key.toLowerCase() || o.value === key
860
870
  );
@@ -865,12 +875,18 @@ var ReadlineInputReader = class {
865
875
  resolve3(opt.value);
866
876
  }
867
877
  };
878
+ const onClose = () => {
879
+ cleanup();
880
+ resolve3("");
881
+ };
868
882
  const cleanup = () => {
869
883
  stdin.off("data", onData);
884
+ stdin.off("close", onClose);
870
885
  if (stdin.isTTY) stdin.setRawMode(wasRaw);
871
886
  if (wasPaused) stdin.pause();
872
887
  };
873
888
  stdin.on("data", onData);
889
+ stdin.on("close", onClose);
874
890
  });
875
891
  }
876
892
  /**
@@ -4380,10 +4396,14 @@ async function readPossiblyMultiline(opts) {
4380
4396
  const first = await opts.reader.readLine(firstPrompt);
4381
4397
  if (first.trim() === '"""') {
4382
4398
  const parts = [];
4383
- for (; ; ) {
4384
- const next = await opts.reader.readLine(contPrompt);
4385
- if (next.trim() === '"""') break;
4386
- parts.push(next);
4399
+ try {
4400
+ for (; ; ) {
4401
+ const next = await opts.reader.readLine(contPrompt);
4402
+ if (next.trim() === '"""') break;
4403
+ parts.push(next);
4404
+ }
4405
+ } catch {
4406
+ return parts.join("\n");
4387
4407
  }
4388
4408
  return parts.join("\n");
4389
4409
  }
@@ -4537,6 +4557,7 @@ async function execute(deps) {
4537
4557
  );
4538
4558
  }
4539
4559
  } else if (flags.tui && !flags["no-tui"]) {
4560
+ agent.disableInteractiveConfirmation();
4540
4561
  const { runTui } = await import('@wrongstack/tui');
4541
4562
  renderer.setSilent(true);
4542
4563
  const banneredFamily = savedProviderCfg?.family ?? resolvedProvider?.family;
@@ -4596,19 +4617,22 @@ async function execute(deps) {
4596
4617
  modelsRegistry,
4597
4618
  globalConfigPath: wpaths.globalConfig
4598
4619
  });
4599
- code = await runRepl({
4600
- agent,
4601
- renderer,
4602
- reader,
4603
- slashRegistry,
4604
- tokenCounter,
4605
- visionAdapters,
4606
- supportsVision,
4607
- attachments,
4608
- effectiveMaxContext,
4609
- projectName: path14.basename(projectRoot) || void 0
4610
- });
4611
- await webuiPromise;
4620
+ try {
4621
+ code = await runRepl({
4622
+ agent,
4623
+ renderer,
4624
+ reader,
4625
+ slashRegistry,
4626
+ tokenCounter,
4627
+ visionAdapters,
4628
+ supportsVision,
4629
+ attachments,
4630
+ effectiveMaxContext,
4631
+ projectName: path14.basename(projectRoot) || void 0
4632
+ });
4633
+ } finally {
4634
+ await webuiPromise.catch(() => void 0);
4635
+ }
4612
4636
  } else {
4613
4637
  code = await runRepl({
4614
4638
  agent,
@@ -4624,7 +4648,10 @@ async function execute(deps) {
4624
4648
  });
4625
4649
  }
4626
4650
  } finally {
4627
- stats.render(renderer);
4651
+ try {
4652
+ stats.render(renderer);
4653
+ } catch (err) {
4654
+ }
4628
4655
  await Promise.resolve(detachTodosCheckpoint?.()).catch(() => void 0);
4629
4656
  await mcpRegistry.stopAll();
4630
4657
  await session.append({
@@ -5081,8 +5108,9 @@ var MultiAgentHost = class {
5081
5108
  };
5082
5109
  function makePromptDelegate(reader) {
5083
5110
  return async (tool, input, suggestedPattern) => {
5111
+ process.stdout.write("\x07");
5084
5112
  process.stdout.write(`
5085
- ${theme2.primary("\u258D")} ${theme2.bold(tool.name)}
5113
+ ${theme2.warn("\u26A0 APPROVAL REQUIRED")} ${theme2.primary("\u2502")} ${theme2.bold(tool.name)}
5086
5114
  `);
5087
5115
  process.stdout.write(`${color.dim(stringifyInput(input))}
5088
5116
  `);