Skip to main content

mermaid_cli/domain/
mod.rs

1//! Pure-function reducer: `fn update(State, Msg) -> (State, Vec<Cmd>)`.
2//!
3//! Heart of the MVU architecture. Everything here is synchronous,
4//! does no I/O, and is testable without tokio or a terminal. The
5//! effect runner (`crate::effect`) takes the `Cmd` values the reducer
6//! emits and performs the actual work; results come back as `Msg`
7//! events that feed into another `update` call.
8//!
9//! The split is load-bearing: stale events racing with cancellation,
10//! lost tool results, and two event loops competing for input are all
11//! impossible to express against these types.
12
13pub mod action;
14pub mod cmd;
15pub mod compaction;
16pub mod ids;
17pub mod msg;
18pub mod reducer;
19pub mod runtime;
20pub mod slash_commands;
21pub mod state;
22pub mod transition;
23
24pub use action::{ActionDetails, ActionDisplay, ActionResult};
25pub use cmd::{ChatRequest, Cmd, ToolDefinition};
26pub use compaction::{
27    CompactionArchive, CompactionPolicy, CompactionRecord, CompactionRequest, CompactionResult,
28    CompactionTrigger, PreparedCompaction, build_replacement_messages, build_summary_request,
29    build_verification_request, combine_usage, compaction_receipt, context_exceeds_hard_limit,
30    format_compact_count, normalize_summary, prepare_compaction, should_auto_compact,
31};
32pub use ids::{IdAllocator, ToolCallId, TurnId};
33pub use msg::{Key, KeyCode, KeyMods, Msg, MsgKind, Paste, SlashCmd, StartupConfig};
34pub use reducer::{build_chat_request, update};
35pub use runtime::{
36    ManagedProcess, ManagedProcessStatus, ProviderCapabilitySnapshot, RuntimeSignal, RuntimeState,
37    RuntimeTimelineEvent, RuntimeTimelineKind, ToolArtifact, ToolMetadata, ToolRunMetadata,
38    ToolStatus,
39};
40pub use slash_commands::{COMMAND_REGISTRY, SlashCommand, filter_by_prefix};
41pub use state::{
42    Attachment, Confirmation, ConfirmationTarget, ContextUsageSnapshot, ConversationSummary,
43    GenPhase, IdAllocatorBundle, McpServerEntry, McpServerStatus, McpState, McpToolSpec,
44    PendingToolCall, PromptTokenBreakdown, Session, State, StatusKind, StatusLine,
45    TokenUsageTotals, ToolOutcome, TurnState, UiMode, UiState, estimate_context_usage_for_request,
46};
47pub use transition::{
48    action_display_for, commit_assistant_message, fill_outcome, start_executing_tools,
49    start_generating, tool_result_messages, try_complete_outcomes,
50};