@wrongstack/tui 0.6.0 → 0.6.3

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
@@ -1,5 +1,6 @@
1
1
  import * as _wrongstack_core from '@wrongstack/core';
2
2
  import { Agent, SlashCommandRegistry, AttachmentStore, EventBus, TokenCounter, QueueStore, Director } from '@wrongstack/core';
3
+ export { buildGoalPreamble } from '@wrongstack/core';
3
4
  import { VisionAdapters } from '@wrongstack/runtime/vision';
4
5
  import React from 'react';
5
6
 
@@ -160,32 +161,4 @@ interface RunTuiOptions {
160
161
  }
161
162
  declare function runTui(opts: RunTuiOptions): Promise<number>;
162
163
 
163
- /**
164
- * `/goal <description>` preamble — the "no force can stop this" mode.
165
- *
166
- * Unlike STEERING (which redirects mid-flight), GOAL is a contract:
167
- * the user hands over a problem, the agent commits to verifiably
168
- * finishing it, and every iteration re-reads this preamble from the
169
- * conversation history. The hardening is entirely prompt-level —
170
- * the system has already removed implicit budget caps, so this
171
- * preamble's job is to remove the MODEL's tendency to hedge, ask
172
- * permission, or declare premature success.
173
- *
174
- * The four sections are intentional:
175
- * 1. AUTHORITY — explicit grant of unbounded fan-out + model
176
- * switching. Without this the model self-throttles ("I shouldn't
177
- * spawn too many…") even when budgets are unlimited.
178
- * 2. DONE — concrete bar for completion. Forces a verifiable
179
- * artifact (test passing, file written, bug re-run clean).
180
- * Without this the model returns "I believe it's fixed" and
181
- * counts that as done.
182
- * 3. NOT DONE — explicit anti-patterns. Each item is something we
183
- * saw real agents do as a "completion" that wasn't.
184
- * 4. PERSISTENCE — three-angle rule for blockers. Stops the model
185
- * from giving up on the first tool failure.
186
- *
187
- * Exported for the test that pins the structural guarantees.
188
- */
189
- declare function buildGoalPreamble(goal: string): string;
190
-
191
- export { type RunTuiOptions, buildGoalPreamble, runTui };
164
+ export { type RunTuiOptions, runTui };
package/dist/index.js CHANGED
@@ -2,7 +2,8 @@ import { render, useApp, Box, useStdout, Static, Text, useInput, useStdin } from
2
2
  import React2, { useState, useEffect, useReducer, useRef, useMemo } from 'react';
3
3
  import * as fs2 from 'fs/promises';
4
4
  import * as path2 from 'path';
5
- import { InputBuilder, DefaultSessionRewinder, formatTodosList, buildChildEnv } from '@wrongstack/core';
5
+ import { InputBuilder, DefaultSessionRewinder, formatTodosList, buildGoalPreamble, buildChildEnv } from '@wrongstack/core';
6
+ export { buildGoalPreamble } from '@wrongstack/core';
6
7
  import { routeImagesForModel } from '@wrongstack/runtime/vision';
7
8
  import { getProcessRegistry } from '@wrongstack/tools';
8
9
  import { readClipboardImage } from '@wrongstack/runtime/clipboard';
@@ -2702,75 +2703,6 @@ function buildSteeringPreamble(snapshot, newDirection) {
2702
2703
  lines.push("]");
2703
2704
  return lines.join("\n");
2704
2705
  }
2705
- function buildGoalPreamble(goal) {
2706
- return [
2707
- "[GOAL \u2014 LOCKED IN. You will work on this until it is verifiably done.",
2708
- "The user granted you full autonomy. Read these constraints once, then act.",
2709
- "",
2710
- "YOUR GOAL:",
2711
- "---",
2712
- goal,
2713
- "---",
2714
- "",
2715
- "AUTHORITY YOU HAVE:",
2716
- "- Spawn as many subagents as the work needs (delegate / spawn_subagent).",
2717
- " Parallel + recursive fan-out are both fine. There is no spawn budget.",
2718
- "- Use any provider/model per subagent \u2014 pick the right tool for each",
2719
- " piece of work. Heavy reasoning model for planning, fast model for",
2720
- " batch work, specialist model for domain code.",
2721
- "- Run unlimited tool calls and iterations. There is NO hidden budget.",
2722
- " The Agent loop auto-extends every 100 iterations forever.",
2723
- "- Retry failed tools with different inputs, alternative paths, fresh",
2724
- " subagents. Switch providers mid-run if one is rate-limited.",
2725
- "- Re-plan freely when an approach hits a dead end. You are not obliged",
2726
- " to stick with the first plan you proposed.",
2727
- "",
2728
- 'WHAT "DONE" MEANS \u2014 non-negotiable:',
2729
- "- You can name a concrete artifact (a passing test, a written file at",
2730
- " a specific path, a fixed bug verified by re-running the failing case,",
2731
- " a clean grep that previously had matches).",
2732
- "- You can tell the user HOW to verify it themselves in 10 seconds.",
2733
- '- You have NOT hedged. None of: "looks like it should work", "I',
2734
- ' believe this fixes it", "the changes appear correct".',
2735
- "",
2736
- "WHAT IS NOT DONE \u2014 never report any of these as completion:",
2737
- "- An error message you didn't recover from.",
2738
- '- An empty result, a 0-line file, a "no matches found" you accepted',
2739
- " without questioning the search.",
2740
- '- "Should I continue?" / "Want me to also...?" / "Let me know if you',
2741
- ' want X." Those are hedges. The user already told you to finish the',
2742
- " goal \u2014 just do it.",
2743
- "- Partial progress dressed up as success. Fixed 3 of 5 bugs = 60%",
2744
- " done, not done.",
2745
- "- A subagent's failed/timeout/stopped TaskResult that you didn't",
2746
- " respond to with a fresh attempt (different role, different model,",
2747
- " tighter prompt).",
2748
- "",
2749
- "PERSISTENCE PROTOCOL:",
2750
- "- If blocked, try at least 3 different angles before reporting the",
2751
- " problem to the user. Different tool inputs, different subagent",
2752
- " roles, different providers, different decomposition of the task.",
2753
- "- If a tool fails, read its error, alter the input, try again. Do",
2754
- " not just report the failure back.",
2755
- "- If a subagent returns useless output, respawn with a tighter prompt",
2756
- ' or a different role. Do not accept "I could not determine\u2026" as the',
2757
- " final answer.",
2758
- "- Use `ask_subagent` for one-shot questions when you don't need a",
2759
- " full delegated task.",
2760
- "",
2761
- "REPORTING:",
2762
- "- Stream short progress notes between major actions so the user can",
2763
- " monitor. Do not go silent for 50 tool calls then dump a wall of",
2764
- " text \u2014 but also do not narrate every tool call.",
2765
- "- Use the shared scratchpad (if available) to leave breadcrumbs",
2766
- " subagents can read.",
2767
- "- Final response must include: (a) what was accomplished, (b) how",
2768
- " to verify, (c) any caveats (residual TODOs, things the user",
2769
- " should know about).",
2770
- "",
2771
- "BEGIN.]"
2772
- ].join("\n");
2773
- }
2774
2706
  function App({
2775
2707
  agent,
2776
2708
  slashRegistry,
@@ -3594,6 +3526,34 @@ function App({
3594
3526
  offRewound();
3595
3527
  };
3596
3528
  }, [events, onClearHistory]);
3529
+ useEffect(() => {
3530
+ const offFired = events.on("compaction.fired", (e) => {
3531
+ const { level, tokens, load, maxContext: maxContext2, report, aggressive } = e;
3532
+ const pct = (load * 100).toFixed(0);
3533
+ const before = report.before;
3534
+ const after = report.after;
3535
+ const saved = before - after;
3536
+ const table = [
3537
+ `\u25B8 context compacted at ${level} (${pct}% of ${maxContext2.toLocaleString()} tok)`,
3538
+ ` tokens before ${before.toLocaleString().padStart(8)}`,
3539
+ ` tokens after ${after.toLocaleString().padStart(8)}`,
3540
+ ` saved ${saved.toLocaleString().padStart(8)} (${(saved / before * 100).toFixed(1)}%)`
3541
+ ];
3542
+ for (const line of table) {
3543
+ dispatch({ type: "addEntry", entry: { kind: "info", text: line } });
3544
+ }
3545
+ });
3546
+ const offFailed = events.on("compaction.failed", (e) => {
3547
+ const { level, load, maxContext: maxContext2, fatal } = e;
3548
+ const pct = (load * 100).toFixed(0);
3549
+ const text = fatal ? `\u2717 compaction failed at ${level} (${pct}% of ${maxContext2.toLocaleString()} tok) \u2014 FATAL` : `\u26A0 compaction failed at ${level} (${pct}% of ${maxContext2.toLocaleString()} tok) \u2014 continuing`;
3550
+ dispatch({ type: "addEntry", entry: { kind: fatal ? "error" : "warn", text } });
3551
+ });
3552
+ return () => {
3553
+ offFired();
3554
+ offFailed();
3555
+ };
3556
+ }, [events]);
3597
3557
  useEffect(() => {
3598
3558
  if (!fleetStreamController) return;
3599
3559
  fleetStreamController.enabled = state.streamFleet;
@@ -3691,6 +3651,9 @@ function App({
3691
3651
  case "iteration.started":
3692
3652
  dispatch({ type: "fleetStart", id: e.subagentId });
3693
3653
  break;
3654
+ case "session.started":
3655
+ dispatch({ type: "fleetStart", id: e.subagentId });
3656
+ break;
3694
3657
  case "provider.text_delta": {
3695
3658
  const p = e.payload;
3696
3659
  if (p?.text) {
@@ -3703,6 +3666,37 @@ function App({
3703
3666
  }
3704
3667
  break;
3705
3668
  }
3669
+ case "provider.thinking_delta": {
3670
+ const p = e.payload;
3671
+ if (p?.text) {
3672
+ streamBuf.set(e.subagentId, (streamBuf.get(e.subagentId) ?? "") + p.text);
3673
+ if (streamFlushTimer) clearTimeout(streamFlushTimer);
3674
+ streamFlushTimer = setTimeout(flushStreamBufs, FLUSH_MS * 4);
3675
+ }
3676
+ break;
3677
+ }
3678
+ case "provider.retry": {
3679
+ const p = e.payload;
3680
+ dispatch({
3681
+ type: "addEntry",
3682
+ entry: {
3683
+ kind: "warn",
3684
+ text: `subagent retry ${p?.attempt ?? "?"}${p?.delayMs ? ` (${p.delayMs}ms)` : ""}`
3685
+ }
3686
+ });
3687
+ break;
3688
+ }
3689
+ case "provider.error": {
3690
+ const p = e.payload;
3691
+ dispatch({
3692
+ type: "addEntry",
3693
+ entry: {
3694
+ kind: "error",
3695
+ text: `subagent error${p?.description ? `: ${p.description}` : ""}`
3696
+ }
3697
+ });
3698
+ break;
3699
+ }
3706
3700
  case "tool.started": {
3707
3701
  const p = e.payload;
3708
3702
  if (p?.name) {
@@ -3728,6 +3722,37 @@ function App({
3728
3722
  dispatch({ type: "fleetCost", cost: d.snapshot().total.cost });
3729
3723
  break;
3730
3724
  }
3725
+ case "session.ended":
3726
+ break;
3727
+ case "compaction.fired":
3728
+ dispatch({
3729
+ type: "addEntry",
3730
+ entry: { kind: "info", text: "subagent compaction triggered" }
3731
+ });
3732
+ break;
3733
+ case "compaction.failed":
3734
+ dispatch({
3735
+ type: "addEntry",
3736
+ entry: { kind: "warn", text: "subagent compaction failed" }
3737
+ });
3738
+ break;
3739
+ case "token.threshold":
3740
+ dispatch({
3741
+ type: "addEntry",
3742
+ entry: { kind: "info", text: "subagent token threshold reached" }
3743
+ });
3744
+ break;
3745
+ case "budget.threshold_reached": {
3746
+ const p = e.payload;
3747
+ dispatch({
3748
+ type: "fleetBudgetWarning",
3749
+ id: e.subagentId,
3750
+ kind: p?.kind ?? "unknown",
3751
+ used: p?.used ?? 0,
3752
+ limit: p?.limit ?? 0
3753
+ });
3754
+ break;
3755
+ }
3731
3756
  }
3732
3757
  });
3733
3758
  const offDone = d.on("task.completed", (payload) => {
@@ -4662,6 +4687,6 @@ async function runTui(opts) {
4662
4687
  });
4663
4688
  }
4664
4689
 
4665
- export { buildGoalPreamble, runTui };
4690
+ export { runTui };
4666
4691
  //# sourceMappingURL=index.js.map
4667
4692
  //# sourceMappingURL=index.js.map