@wrongstack/tui 1.1.4 → 1.1.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.
@@ -1,19 +1,13 @@
1
1
  import type { Agent } from '@wrongstack/core/agent';
2
- import type { AutonomousCoordinator, CoordinatorEvent, Director } from '@wrongstack/core/coordination';
3
2
  import type { EventBus } from '@wrongstack/core/kernel';
4
3
  import type { SlashCommandRegistry } from '@wrongstack/core/registry';
5
- import type { StatuslineDensities, StatuslineLines, StatuslineOrder } from '@wrongstack/core/statusline';
6
4
  import type { QueueStore } from '@wrongstack/core/storage';
7
- import type { AttachmentStore, AutonomyStage, ConfigStore, ContextSnapshot, FleetChatVerbosity, Message, SessionLoadProgress, SkillLoader, ThemePresetId, TokenCounter, TokenSavingTier } from '@wrongstack/core/types';
5
+ import type { AttachmentStore, AutonomyStage, SkillLoader, TokenCounter, TokenSavingTier } from '@wrongstack/core/types';
8
6
  import type { VisionAdapters } from '@wrongstack/runtime/vision';
9
7
  import type { SddLifecycleResult, SddRunControl } from '@wrongstack/sdd';
10
- import type { AgentTranscriptReader } from './components/agents-monitor.js';
11
- import type { McpPickerItem } from './components/mcp-picker.js';
12
- import type { PluginPickerItem } from './components/plugin-picker.js';
13
- import type { StatuslineItem } from './components/statusline-picker.js';
14
- import type { ToolPickerItem } from './components/tools-picker.js';
8
+ import type { RunTuiSurfaceOptions } from './run-tui-surface-options.js';
15
9
  import type { ResourceMenuId, ResourceMenuSnapshot } from './ui-contracts.js';
16
- export interface RunTuiOptions {
10
+ export interface RunTuiOptions extends RunTuiSurfaceOptions {
17
11
  agent: Agent;
18
12
  slashRegistry: SlashCommandRegistry;
19
13
  /** Shared loader used by the interactive `/skill` browser. */
@@ -215,457 +209,5 @@ export interface RunTuiOptions {
215
209
  } | {
216
210
  type: 'toolStreamClear';
217
211
  }>) => void) | undefined;
218
- /**
219
- * Live director instance. When set, the TUI renders a fleet panel
220
- * showing every spawned subagent, its current task, streaming output,
221
- * and runtime cost — updated live from the FleetBus. Pass null or omit
222
- * when multi-agent / director mode is disabled.
223
- */
224
- director?: Director | null | undefined;
225
- /**
226
- * Read the CURRENT director. Unlike the static `director` option (captured
227
- * at boot, null in non---director sessions), this sees a director the fleet
228
- * host built lazily on the first delegate/spawn — the TUI's fleet-teardown
229
- * paths (Ctrl+C, Esc, /steer) resolve through it.
230
- */
231
- getDirector?: (() => Director | null) | undefined;
232
- /**
233
- * Optional roster reference for resolving subagent role ids to
234
- * human-readable names. Same value passed to director.tools().
235
- */
236
- fleetRoster?: Record<string, {
237
- name: string;
238
- }> | undefined;
239
- /**
240
- * Shared controller for the `/fleet stream on|off` toggle. The slash
241
- * command runs in the CLI process and needs to flip TUI reducer state;
242
- * the App installs a dispatch-backed `setEnabled` here on mount so
243
- * both sides stay synchronized.
244
- */
245
- /**
246
- * Shared controller for the `/fleet stream on|off` toggle. The slash
247
- * command runs in the CLI process and needs to flip TUI reducer state;
248
- * the App installs a dispatch-backed `setEnabled` here on mount so
249
- * both sides stay synchronized.
250
- */
251
- fleetStreamController?: {
252
- mode: FleetChatVerbosity;
253
- setMode: (mode: FleetChatVerbosity) => void;
254
- } | undefined;
255
- /**
256
- * Read-only per-subagent transcript access for the F3 agents monitor
257
- * (AgentMonitorService satisfies this structurally).
258
- */
259
- agentTranscripts?: AgentTranscriptReader | undefined;
260
- /**
261
- * Controller for the `/interrupt` slash command. The App installs the real
262
- * `abortLeader` on mount so the command can abort the in-flight leader run.
263
- */
264
- interruptController?: {
265
- abortLeader: () => boolean;
266
- isRunning?: (() => boolean) | undefined;
267
- confirmClear?: ((info: {
268
- leaderActive: boolean;
269
- subagentCount: number;
270
- }) => Promise<boolean>) | undefined;
271
- confirmSlash?: ((question: string, defaultYes: boolean) => Promise<boolean | null>) | undefined;
272
- resetSession?: (() => void) | undefined;
273
- waitForIdle?: (() => Promise<void>) | undefined;
274
- } | undefined;
275
- /**
276
- * Controller for the `/enhance on|off` prompt-refinement toggle. The App
277
- * installs a dispatch-backed `setEnabled` here on mount so the slash command
278
- * (run in the CLI process) flips the TUI's reducer flag. Mirrors
279
- * `fleetStreamController`.
280
- */
281
- enhanceController?: {
282
- enabled: boolean;
283
- setEnabled: (enabled: boolean) => void;
284
- } | undefined;
285
- /** Capability-gated low-effort reasoning hint for the prompt refiner. */
286
- getEnhancerReasoning?: ((providerId?: string, modelId?: string) => import('@wrongstack/core/types').ReasoningRequest | undefined | Promise<import('@wrongstack/core/types').ReasoningRequest | undefined>) | undefined;
287
- /**
288
- * Effort levels the ACTIVE model documents (models.dev reasoningConfig),
289
- * for the model-aware /settings reasoning-effort cycle. Undefined =
290
- * vocabulary undocumented; the picker cycles the full canonical set.
291
- */
292
- getActiveModelReasoningEffortLevels?: (() => string[] | undefined) | undefined;
293
- /** Build an ephemeral Provider for retrying a failed refinement on another model (no session switch). */
294
- buildEnhancerProvider?: ((providerId: string, modelId: string) => Promise<import('@wrongstack/core/types').Provider | undefined>) | undefined;
295
- /** Resolve the one-key "retry with another model" fallback ref on a refine failure. */
296
- getEnhanceFallbackRef?: (() => string | undefined) | undefined;
297
- /** Resolve the dedicated refiner target for the initial refinement attempt. */
298
- getConfiguredRefinerRef?: (() => string | undefined) | undefined;
299
- /**
300
- * Controller for status bar hidden items. App installs a dispatch-backed
301
- * setter on mount so the /statusline slash command can update the TUI's
302
- * visible bar without a round-trip. The initial value is loaded from
303
- * the config file before App mounts.
304
- */
305
- statuslineHiddenItems: StatuslineItem[];
306
- setStatuslineHiddenItems: (items: StatuslineItem[]) => void;
307
- /**
308
- * Atomically updates in-memory state AND persists to
309
- * Active profile/statusline.json. Used by the statusline picker to
310
- * make each toggle immediately durable.
311
- */
312
- saveStatuslineHiddenItems: (items: StatuslineItem[]) => Promise<void>;
313
- /**
314
- * Per-chip statusline line assignment (statusline.json schema v2).
315
- * Optional: hosts that don't load it keep the core contract defaults.
316
- */
317
- statuslineLines?: StatuslineLines | undefined;
318
- setStatuslineLines?: ((lines: StatuslineLines) => void) | undefined;
319
- saveStatuslineLines?: ((lines: StatuslineLines) => Promise<void>) | undefined;
320
- /** Per-chip density pin (statusline.json schema v3). */
321
- statuslineDensities?: StatuslineDensities | undefined;
322
- setStatuslineDensities?: ((densities: StatuslineDensities) => void) | undefined;
323
- saveStatuslineDensities?: ((densities: StatuslineDensities) => Promise<void>) | undefined;
324
- /** Custom left-to-right chip order (statusline.json schema v4). */
325
- statuslineOrder?: StatuslineOrder | undefined;
326
- setStatuslineOrder?: ((order: StatuslineOrder) => void) | undefined;
327
- saveStatuslineOrder?: ((order: StatuslineOrder) => Promise<void>) | undefined;
328
- /**
329
- * Controller for the agents monitor overlay. App installs a dispatch-backed
330
- * setter on mount so the `/agents on|off` slash command can toggle the
331
- * overlay without a round-trip.
332
- */
333
- agentsMonitorController?: {
334
- visible: boolean;
335
- setVisible: (visible: boolean) => void;
336
- } | undefined;
337
- /**
338
- * Mutable ref for opening TUI panels from slash commands. The slash commands
339
- * call `onPanelOpen.current(action)` to open panels. The App sets
340
- * `onPanelOpen.current` to its actual dispatch function on mount.
341
- */
342
- onPanelOpen?: {
343
- current: ((action: string) => boolean) | null;
344
- } | undefined;
345
- /**
346
- * If set, the App boots straight into goal mode — the text is wrapped
347
- * in the GOAL preamble and submitted as the first turn. Lets users
348
- * launch directly from the shell:
349
- * wstack --tui --director --goal "audit packages/core for races"
350
- * The chat shows a one-line "🎯 Goal locked: …" hint; the actual
351
- * preamble is hidden from the visible history (same as `/goal`).
352
- */
353
- initialGoal?: string | undefined;
354
- /**
355
- * If set, submitted as the first turn verbatim (no preamble). Mainly
356
- * for scripted shell aliases — `wstack --tui --ask "summarize foo.md"`
357
- * — that want one turn pre-populated without the goal-mode framing.
358
- * Ignored when `initialGoal` is also set.
359
- */
360
- initialAsk?: string | undefined;
361
- /**
362
- * Directory containing session JSONL files. Required for rewind
363
- * functionality. When provided the TUI can list checkpoints and
364
- * trigger a rewind via `/rewind` or Ctrl+R.
365
- */
366
- sessionsDir?: string | undefined;
367
- /** Live active session id for cross-surface client registration. */
368
- getSessionId?: (() => string | undefined) | undefined;
369
- /**
370
- * SDD session context getter. When an SDD session is active, returns
371
- * the AI prompt context to inject into user messages.
372
- */
373
- getSDDContext?: (() => Promise<string | null>) | undefined;
374
- /**
375
- * Process AI output for SDD auto-detection (spec, tasks, plan).
376
- * Returns displayable status messages.
377
- */
378
- onSDDOutput?: ((output: string) => Promise<string[]>) | undefined;
379
- /**
380
- * Subscribe to Goal phase/graph events from the PhaseOrchestrator.
381
- * Returns an unsubscribe function. The TUI uses this to drive the
382
- * PhaseMonitor and PhasePanel live views via dispatch actions.
383
- */
384
- subscribeGoal?: ((handler: (event: string, payload: unknown) => void) => () => void) | undefined;
385
- /**
386
- * Read the persisted autonomy settings (defaultMode, autoProceedDelayMs).
387
- * Used by the SettingsPicker in the TUI on mount and after Ctrl+S toggle.
388
- */
389
- getSettings?: (() => import('./app-state.js').Settings) | undefined;
390
- /**
391
- * The leader's own effort override (`leader_effort_set`), while it is in
392
- * force. Display-only: kept apart from `getSettings` so the settings picker
393
- * never reads — and on save persists — the leader's choice as the user's.
394
- */
395
- getLeaderEffort?: (() => string | undefined) | undefined;
396
- /**
397
- * Persist settings changes. Returns null on success, or an
398
- * error string on failure (so the TUI can display it as a hint).
399
- */
400
- saveSettings?: ((s: import('./app-state.js').Settings) => string | null | Promise<string | null>) | undefined;
401
- /** Persist the active theme preset to disk so the next boot starts with it. */
402
- saveThemePreset?: ((preset: ThemePresetId) => Promise<void>) | undefined;
403
- /**
404
- * Live ConfigStore — passed through to the TUI so the `/theme` slash
405
- * command can read the current `themePreset`, apply it via
406
- * `setActiveTheme()`, and persist the user's pick back to disk.
407
- * Subscribes via `ConfigStore.watch` so any external write (CLI REPL,
408
- * WebUI, profile migration) is reflected immediately.
409
- */
410
- configStore?: ConfigStore | undefined;
411
- /** Load toggleable plugin rows for the interactive plugin picker. */
412
- getPluginItems?: (() => PluginPickerItem[]) | undefined;
413
- /** Toggle one plugin from the interactive picker and return refreshed rows. */
414
- onPluginToggle?: ((name: string) => Promise<{
415
- items: PluginPickerItem[];
416
- message?: string | undefined;
417
- error?: string | undefined;
418
- }>) | undefined;
419
- /** Load MCP server rows for the interactive MCP picker. */
420
- getMcpServers?: (() => McpPickerItem[]) | undefined;
421
- onMcpManage?: ((action: 'add' | 'edit' | 'remove', input: Pick<McpPickerItem, 'name' | 'transport' | 'command' | 'url' | 'args'>) => Promise<{
422
- items: McpPickerItem[];
423
- message?: string | undefined;
424
- error?: string | undefined;
425
- }>) | undefined;
426
- /** Toggle one MCP server (enable/disable) from the interactive picker. */
427
- onMcpToggle?: ((name: string) => Promise<{
428
- items: McpPickerItem[];
429
- message?: string | undefined;
430
- error?: string | undefined;
431
- }>) | undefined;
432
- /** Restart one MCP server from the interactive picker. */
433
- onMcpRestart?: ((name: string) => Promise<{
434
- items: McpPickerItem[];
435
- message?: string | undefined;
436
- error?: string | undefined;
437
- }>) | undefined;
438
- /** Load tool rows for the interactive tool picker. */
439
- getToolsItems?: (() => ToolPickerItem[]) | undefined;
440
- /** Toggle one tool (enable/disable) from the interactive tool picker. */
441
- onToolToggle?: ((name: string) => Promise<{
442
- items: ToolPickerItem[];
443
- message?: string | undefined;
444
- error?: string | undefined;
445
- }>) | undefined;
446
- /** Get current brain risk level and decision log for the Brain panel. */
447
- getBrainData?: (() => {
448
- riskLevel: 'off' | 'low' | 'medium' | 'high' | 'all';
449
- log: Array<{
450
- kind: string;
451
- question: string;
452
- outcome: string;
453
- age: string;
454
- }>;
455
- }) | undefined;
456
- /** Set brain risk ceiling from the Brain panel. */
457
- onBrainRiskLevel?: ((level: 'off' | 'low' | 'medium' | 'high' | 'all') => string | undefined) | undefined;
458
- /** Full Brain settings editor bridge (live apply + persist to global config). */
459
- brainPanelHost?: import('./brain-panel-model.js').BrainPanelHost | undefined;
460
- /** Session-scoped model-lane bridge for the interactive `/subagent-models` panel. */
461
- subagentModelsHost?: import('./subagent-models-panel-model.js').SubagentModelsPanelHost | undefined;
462
- /** Get current Shadow Agent state. */
463
- getShadowData?: (() => {
464
- activeId: string | null;
465
- running: boolean;
466
- model: string;
467
- intervalMs: number;
468
- }) | undefined;
469
- /** Start Shadow Agent. Returns message or error. */
470
- onShadowStart?: (() => Promise<string | undefined>) | undefined;
471
- /** Stop Shadow Agent. Returns message or error. */
472
- onShadowStop?: (() => Promise<string | undefined>) | undefined;
473
- /**
474
- * Host for the interactive `/auth` panel (provider/key management, OAuth
475
- * sign-in, local-server add). The CLI builds this from its vault +
476
- * models registry; when absent, `/auth` falls back to plain text.
477
- */
478
- authHost?: import('./auth-panel-model.js').AuthPanelHost | undefined;
479
- /**
480
- * Predict likely next steps after a completed turn. The CLI wires this from
481
- * the session provider and the `/next` toggle; it returns [] when prediction
482
- * is disabled or autonomy isn't 'off'. Display-only — never executed.
483
- */
484
- predictNext?: ((input: {
485
- userRequest: string;
486
- assistantSummary: string;
487
- }) => Promise<string[]>) | undefined;
488
- /**
489
- * Called after each agent turn with the assistant's final output text.
490
- * The host parses "💡 Next steps" suggestions from the text and stores
491
- * them in the shared suggestion store so `/next 1`, `/next 1 2 3` work.
492
- */
493
- onSuggestionsParsed?: ((finalText: string) => void) | undefined;
494
- /**
495
- * Retrieve current suggestions from the shared suggestion store.
496
- * Used by the TUI to display and auto-submit next steps in 'auto' mode.
497
- */
498
- getSuggestions?: (() => string[]) | undefined;
499
- /**
500
- * Retrieve current auto suggestions (items with auto="true" attribute).
501
- * Used by YOLO+auto mode for automatic next-step submission.
502
- */
503
- getAutoSuggestions?: (() => string[]) | undefined;
504
- /**
505
- * Autonomy next prompt template for YOLO+auto mode. Contains {{suggestion}} placeholder.
506
- */
507
- autonomyNextPrompt?: string | undefined;
508
- /**
509
- * Write parsed next steps into the shared suggestion store.
510
- * Called by the Entry component after parsing each assistant message
511
- * so /next 1 and the auto-submit countdown can access them.
512
- */
513
- setSuggestions?: ((steps: string[]) => void) | undefined;
514
- /**
515
- * Messages restored from a previous session. When provided (non-empty),
516
- * the TUI renders the prior conversation as history entries so a resumed
517
- * session shows its full chat context, not just the LLM's internal state.
518
- */
519
- restoredMessages?: Message[] | undefined;
520
- /**
521
- * Tool execution records from a previous session, keyed by tool_use id.
522
- * Used to render tool entries (name, duration, ok/error) in the TUI on
523
- * resume. Events are `tool_call_end` records from the session JSONL.
524
- */
525
- restoredToolCalls?: Array<{
526
- name: string;
527
- id: string;
528
- durationMs: number;
529
- ok: boolean;
530
- outputBytes?: number | undefined;
531
- outputTokens?: number | undefined;
532
- outputLines?: number | undefined;
533
- }> | undefined;
534
- /**
535
- * Raw prior-session JSONL events. When provided, the boot `--resume` history
536
- * is rebuilt with the canonical renderer (tool I/O + interleaved audit
537
- * markers) instead of meta-only tool chips. Omitted → legacy fallback.
538
- */
539
- restoredEvents?: import('@wrongstack/core/types').SessionEvent[] | undefined;
540
- /**
541
- * List recent session summaries for the /resume picker. The CLI reads
542
- * from the session store and returns ResumeSessionEntry-shaped data.
543
- */
544
- listSessions?: ((limit?: number) => Promise<import('./app-state.js').ResumeSessionEntry[]>) | undefined;
545
- /**
546
- * Branch a session at a checkpoint (the conversation before that prompt)
547
- * into a new session, leaving the original as it is. Returns the new id;
548
- * the TUI then resumes it. The working tree is shared, not copied.
549
- */
550
- forkSession?: ((sessionId: string, checkpointPromptIndex: number) => Promise<{
551
- id: string;
552
- }>) | undefined;
553
- /**
554
- * Resume a session by id: load JSONL events, replay history entries,
555
- * rebuild agent context, and return hydrated entries for the TUI to
556
- * display. Returns null when resume fails.
557
- */
558
- onResumeSession?: ((sessionId: string, onLoadProgress?: (progress: SessionLoadProgress) => void,
559
- /**
560
- * Live stage names as each step of the resume begins (`resolve_id`,
561
- * `open_journal`, `swap_writer`, …). Drives the rolling rows of the
562
- * resume loading block, so the screen reports what is actually
563
- * happening instead of a spinner over an unexplained multi-second wait.
564
- */
565
- onStage?: (stage: string) => void) => Promise<{
566
- entries: import('./components/history/types.js').HistoryEntry[];
567
- nextId: number;
568
- sessionId: string;
569
- /**
570
- * Optional context-window snapshot computed from the resumed
571
- * session's tokenCounter after accounting the persisted usage.
572
- * When present, the reducer writes `tokens` to `state.leader.ctxTokens`
573
- * and bumps `state.contextChipVersion` so the chip refreshes
574
- * immediately. When absent, the chip stays at its previous value
575
- * until the next ctx.pct event lands.
576
- */
577
- contextSnapshot?: ContextSnapshot | undefined;
578
- /** `false` = transcript replayed read-only; the session was not claimed. */
579
- attached?: boolean | undefined;
580
- /** Non-fatal problems to surface next to the replayed transcript. */
581
- warnings?: string[] | undefined;
582
- /**
583
- * `<nextsteps>` parsed from the resumed session's final assistant turn.
584
- *
585
- * OFFERED, never executed: the resume lists them and stops. Empty when
586
- * the session did not end on a next-steps block, when it has open todos
587
- * (the board keeps precedence), or when the transcript is read-only.
588
- */
589
- nextSteps?: string[] | undefined;
590
- } | null>) | undefined;
591
- getProjectPickerItems?: (() => Promise<import('./components/project-picker.js').ProjectPickerItem[]>) | undefined;
592
- onProjectSelect?: ((key: string, kind: 'project' | 'action') => void | string | null | Promise<void | string | null>) | undefined;
593
- /**
594
- * Request the TUI to exit with a specific code. Used by the project picker
595
- * to trigger a clean exit before spawning a new wstack process in a different
596
- * project directory. The host CLI catches this exit code and performs the
597
- * actual project switch.
598
- */
599
- requestExit?: (code: number) => void;
600
- getLiveSessions?: (() => Promise<import('./components/sessions-panel.js').LiveSessionEntry[]>) | undefined;
601
- onSwitchToSession?: ((sessionId: string, projectRoot: string, projectName: string) => void) | undefined;
602
- /**
603
- * When true, the agents monitor (F3) is open by default at TUI startup.
604
- * Used by the `wrongstack quick` command to show agents panel immediately.
605
- */
606
- initialAgentsMonitorOpen?: boolean | undefined;
607
- /**
608
- * Access the project-level AutonomousCoordinator instance. When set, the TUI
609
- * renders a coordination panel showing live goals, pending tasks, consensus
610
- * decisions, and shared knowledge from all active sessions. The coordinator
611
- * runs independently of the session — it coordinates multiple sessions.
612
- */
613
- getAutonomousCoordinator?: () => AutonomousCoordinator | null | undefined;
614
- /**
615
- * Subscribe to live events from the AutonomousCoordinator:
616
- * - `goal:added` — new coordination goal received
617
- * - `goal:completed` — goal finished successfully
618
- * - `goal:failed` — goal failed after max attempts
619
- * - `task:ready` — task's dependencies are satisfied, ready to execute
620
- * - `task:completed` — task finished
621
- * - `knowledge:added` — new shared fact published
622
- * - `consensus:reached` — multi-session agreement reached
623
- * Returns an unsubscribe function.
624
- */
625
- subscribeCoordinatorEvents?: (fn: (event: CoordinatorEvent) => void) => () => void;
626
- /**
627
- * Start the AutonomousCoordinator loop. Fire-and-forget — run() loops
628
- * asynchronously. Pass a goal string to begin decomposition and task
629
- * auction immediately.
630
- */
631
- onCoordinatorStart?: ((goal?: string) => void) | undefined;
632
- /** Stop the AutonomousCoordinator loop. */
633
- onCoordinatorStop?: (() => void) | undefined;
634
- /** List pending coordinator tasks claimable by this terminal. */
635
- onCoordinatorTasks?: (() => Promise<Array<{
636
- id: string;
637
- title: string;
638
- priority: string;
639
- tags: string[];
640
- }> | null>) | undefined;
641
- /** Claim a coordinator task. Returns description on success. */
642
- onCoordinatorClaim?: ((taskId: string) => Promise<string | null | {
643
- description: string;
644
- }>) | undefined;
645
- /** Mark a claimed task as completed. */
646
- onCoordinatorComplete?: ((taskId: string, result?: string) => Promise<string | null>) | undefined;
647
- /** Mark a claimed task as failed. */
648
- onCoordinatorFail?: ((taskId: string, error: string) => Promise<string | null>) | undefined;
649
- /** Get coordinator stats for status display. */
650
- onCoordinatorStatus?: (() => Promise<{
651
- goals: {
652
- total: number;
653
- done: number;
654
- pending: number;
655
- failed: number;
656
- };
657
- dag: {
658
- running: number;
659
- ready: number;
660
- done: number;
661
- failed: number;
662
- };
663
- auction: {
664
- pending: number;
665
- inProgress: number;
666
- };
667
- } | null>) | undefined;
668
- /** Access the persistent memory store for listing and inspecting memories. */
669
- memoryStore?: import('@wrongstack/core/types').MemoryPort | undefined;
670
212
  }
671
213
  //# sourceMappingURL=run-tui-options.d.ts.map