@wrongstack/tui 0.6.3 → 0.6.5

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.d.ts CHANGED
@@ -31,13 +31,19 @@ interface RunTuiOptions {
31
31
  /** Query live YOLO state from the permission policy. */
32
32
  getYolo?: () => boolean;
33
33
  /** Query the live autonomy mode. */
34
- getAutonomy?: () => 'off' | 'suggest' | 'auto' | 'eternal';
34
+ getAutonomy?: () => 'off' | 'suggest' | 'auto' | 'eternal' | 'eternal-parallel';
35
35
  /**
36
36
  * Access the eternal-autonomy engine. When autonomy mode flips to
37
37
  * 'eternal' the TUI drives `runOneIteration()` from the post-slash hook
38
38
  * so the engine and TUI never race for the shared Context.
39
39
  */
40
40
  getEternalEngine?: () => _wrongstack_core.EternalAutonomyEngine | null;
41
+ /**
42
+ * Access the parallel-eternal engine. When autonomy mode flips to
43
+ * 'eternal-parallel' the TUI drives `runOneIteration()` from the post-slash
44
+ * hook so the engine and TUI never race for the shared Context.
45
+ */
46
+ getParallelEngine?: () => _wrongstack_core.ParallelEternalEngine | null;
41
47
  /**
42
48
  * Subscribe to live per-iteration events from the eternal engine.
43
49
  * Returns an unsubscribe function. TUI uses this to render each
package/dist/index.js CHANGED
@@ -2718,6 +2718,7 @@ function App({
2718
2718
  getYolo,
2719
2719
  getAutonomy,
2720
2720
  getEternalEngine,
2721
+ getParallelEngine,
2721
2722
  subscribeEternalIteration,
2722
2723
  getSDDContext,
2723
2724
  onSDDOutput,
@@ -3471,6 +3472,7 @@ function App({
3471
3472
  const offBudgetWarning = events.on("subagent.budget_warning", (e) => {
3472
3473
  const lbl = labelFor(e.subagentId);
3473
3474
  dispatch({ type: "fleetBudgetWarning", id: e.subagentId, kind: e.kind, used: e.used, limit: e.limit });
3475
+ const timeoutSuffix = e.kind === "timeout" ? " (subagent continues running)" : " \u2014 extending";
3474
3476
  dispatch({
3475
3477
  type: "addEntry",
3476
3478
  entry: {
@@ -3478,12 +3480,27 @@ function App({
3478
3480
  agentLabel: lbl.label,
3479
3481
  agentColor: lbl.color,
3480
3482
  icon: "\u26A1",
3481
- text: `hitting ${e.kind} limit (${e.used}/${e.limit}) \u2014 extending`
3483
+ text: `hitting ${e.kind} limit (${e.used}/${e.limit})${timeoutSuffix}`
3484
+ }
3485
+ });
3486
+ });
3487
+ const offIterationSummary = events.on("subagent.iteration_summary", (e) => {
3488
+ const lbl = labelFor(e.subagentId);
3489
+ const costStr = e.costUsd > 0 ? ` \xB7 ${e.costUsd.toFixed(3)}` : "";
3490
+ const toolStr = e.currentTool ? ` \xB7 doing ${e.currentTool}` : "";
3491
+ const partial = e.partialText ? ` \xB7 "${e.partialText.slice(0, 60)}${e.partialText.length > 60 ? "\u2026" : ""}"` : "";
3492
+ dispatch({
3493
+ type: "addEntry",
3494
+ entry: {
3495
+ kind: "subagent",
3496
+ agentLabel: lbl.label,
3497
+ agentColor: lbl.color,
3498
+ icon: "\u{1F4AC}",
3499
+ text: `L${e.iteration} \xB7 ${e.toolCalls} tools${costStr}${toolStr}${partial}`
3482
3500
  }
3483
3501
  });
3484
3502
  });
3485
3503
  const offTool = events.on("subagent.tool_executed", (e) => {
3486
- if (director) return;
3487
3504
  dispatch({
3488
3505
  type: "fleetTool",
3489
3506
  id: e.subagentId,
@@ -3499,6 +3516,7 @@ function App({
3499
3516
  offStarted();
3500
3517
  offCompleted();
3501
3518
  offBudgetWarning();
3519
+ offIterationSummary();
3502
3520
  offTool();
3503
3521
  };
3504
3522
  }, [events, director]);
@@ -4111,6 +4129,18 @@ function App({
4111
4129
  setDraft(next2, lastWordStart);
4112
4130
  return;
4113
4131
  }
4132
+ if (key.delete || key.ctrl && input === "d") {
4133
+ if (cursor >= buffer.length) return;
4134
+ const next2 = buffer.slice(0, cursor) + buffer.slice(cursor + 1);
4135
+ setDraft(next2, cursor);
4136
+ return;
4137
+ }
4138
+ if (key.ctrl && input === "k") {
4139
+ if (cursor >= buffer.length) return;
4140
+ const next2 = buffer.slice(0, cursor);
4141
+ setDraft(next2, cursor);
4142
+ return;
4143
+ }
4114
4144
  if (key.meta && input === "v") {
4115
4145
  await pasteClipboardImage();
4116
4146
  return;
@@ -4260,11 +4290,48 @@ function App({
4260
4290
  }
4261
4291
  } finally {
4262
4292
  eternalLoopRunningRef.current = false;
4293
+ if (getAutonomy) {
4294
+ const finalMode = getAutonomy();
4295
+ if (finalMode !== autonomyLive) setAutonomyLive(finalMode);
4296
+ }
4263
4297
  }
4264
4298
  };
4265
4299
  const eternalLoopRunningRef = useRef(false);
4266
4300
  const runEternalLoopRef = useRef(runEternalLoop);
4267
4301
  runEternalLoopRef.current = runEternalLoop;
4302
+ const runParallelLoop = async () => {
4303
+ const engine = getParallelEngine?.();
4304
+ if (!engine) return;
4305
+ if (parallelLoopRunningRef.current) return;
4306
+ parallelLoopRunningRef.current = true;
4307
+ try {
4308
+ while (true) {
4309
+ const liveMode = getAutonomy?.() ?? "off";
4310
+ if (liveMode !== "eternal-parallel") break;
4311
+ if (engine.currentState === "stopped") break;
4312
+ dispatch({ type: "status", status: "running" });
4313
+ try {
4314
+ await engine.runOneIteration();
4315
+ } catch (err) {
4316
+ dispatch({
4317
+ type: "addEntry",
4318
+ entry: { kind: "error", text: `[parallel] ${err instanceof Error ? err.message : String(err)}` }
4319
+ });
4320
+ }
4321
+ dispatch({ type: "status", status: "idle" });
4322
+ await new Promise((r) => setTimeout(r, 200));
4323
+ }
4324
+ } finally {
4325
+ parallelLoopRunningRef.current = false;
4326
+ if (getAutonomy) {
4327
+ const finalMode = getAutonomy();
4328
+ if (finalMode !== autonomyLive) setAutonomyLive(finalMode);
4329
+ }
4330
+ }
4331
+ };
4332
+ const parallelLoopRunningRef = useRef(false);
4333
+ const runParallelLoopRef = useRef(runParallelLoop);
4334
+ runParallelLoopRef.current = runParallelLoop;
4268
4335
  useEffect(() => {
4269
4336
  if (!subscribeEternalIteration) return;
4270
4337
  const unsub = subscribeEternalIteration((entry) => {
@@ -4313,6 +4380,9 @@ function App({
4313
4380
  if (currentAutonomy === "eternal" && getEternalEngine) {
4314
4381
  void runEternalLoopRef.current();
4315
4382
  }
4383
+ if (currentAutonomy === "eternal-parallel" && getParallelEngine) {
4384
+ void runParallelLoopRef.current();
4385
+ }
4316
4386
  }
4317
4387
  if (res?.exit) {
4318
4388
  exit();
@@ -4635,6 +4705,7 @@ async function runTui(opts) {
4635
4705
  getYolo: opts.getYolo,
4636
4706
  getAutonomy: opts.getAutonomy,
4637
4707
  getEternalEngine: opts.getEternalEngine,
4708
+ getParallelEngine: opts.getParallelEngine,
4638
4709
  subscribeEternalIteration: opts.subscribeEternalIteration,
4639
4710
  appVersion: opts.appVersion,
4640
4711
  provider: opts.provider,