Skip to main content

Cmd

Enum Cmd 

Source
pub enum Cmd {
Show 44 variants CallModel { turn: TurnId, request: ChatRequest, }, CompactConversation { turn: TurnId, request: CompactionRequest, }, ExecuteTool { turn: TurnId, call_id: ToolCallId, source: ToolCall, model_id: String, safety_mode: SafetyMode, intent: Option<String>, }, CancelScope(TurnId), BackgroundScope(TurnId), ResolveApproval { call_id: ToolCallId, decision: ApprovalChoice, }, SaveConversation(ConversationHistory), SaveCompactionArchive { archive: CompactionArchive, record: CompactionRecord, conversation: ConversationHistory, }, SaveProcess(ManagedProcess), PersistLastModel(String), PersistReasoningFor { model_id: String, level: ReasoningLevel, }, PersistOllamaNumCtxFor { model_id: String, num_ctx: Option<u32>, }, PersistOllamaOffload(bool), ListMemory, RememberMemory { text: String, }, ForgetMemory { id: String, }, ConsolidateMemory { model_id: String, }, LoadConversation(String), ListConversations, ListRuntimeTasks { limit: usize, }, LoadRuntimeTask { id: String, }, ListRuntimeProcesses { limit: usize, }, ShowRuntimeProcessLogs { id: String, }, StopRuntimeProcess { id: String, }, RestartRuntimeProcess { id: String, }, OpenRuntimeTarget { target: String, }, ShowRuntimePorts, ListRuntimeApprovals, DecideRuntimeApproval { id: String, decision: String, }, ListRuntimeCheckpoints { limit: usize, }, ListRuntimePlugins, UpdateRuntimeTaskStatus { id: String, status: TaskStatus, final_report: Option<String>, }, CreateRuntimeCheckpoint { paths: Vec<PathBuf>, }, RestoreRuntimeCheckpoint { id: String, }, ShowRuntimeModelInfo { model: String, }, InitMcpServers(HashMap<String, McpServerConfig>), StopMcpServer { name: String, }, PullOllamaModel { model: String, }, OpenInSystem(PathBuf), WriteImageToTemp { path: PathBuf, bytes: Vec<u8>, format: String, }, ReadClipboard, CopyToClipboard(String), Exit, SetTerminalTitle(String),
}
Expand description

A single side-effect request. Most variants are one-shot; CallModel and ExecuteTool spawn long-running tasks inside a per-turn TurnScope.

Variants§

§

CallModel

Dispatch the next chat request. Effect runner maps this onto ModelProvider::chat for the session’s active provider.

Fields

§turn: TurnId
§request: ChatRequest
§

CompactConversation

Generate a compact context checkpoint without continuing into a normal assistant turn.

Fields

§turn: TurnId
§

ExecuteTool

Run one tool in parallel with any other tools in the same turn. The runner wires ExecContext::token to the turn’s scope so Cmd::CancelScope aborts them all at once.

model_id is the active session’s model id at the moment this tool call was emitted. The runner passes it into ExecContext so tools like SubagentTool can spawn children against the same provider the parent is using.

Fields

§turn: TurnId
§call_id: ToolCallId
§source: ToolCall
§model_id: String
§safety_mode: SafetyMode

Effective live safety mode (from state.session.safety_mode) at the moment this call was emitted. The runner builds the policy gate / Auto classifier from this rather than the static config.

§intent: Option<String>

The user’s stated intent for the turn (latest user message), passed to the Auto-mode classifier as alignment context.

§

CancelScope(TurnId)

Cancel every task in the given turn’s TurnScope. After the scope’s JoinSet drains (bounded by a ~2s timeout), the runner emits a single Msg::TurnCancelled(turn) — that, not Msg::StreamDone, is the terminal event that lets the reducer transition Cancelling → Idle. A same-id Msg::StreamDone that races the drain does NOT end the turn: handle_stream_done only acts on a Generating turn and restores the prior state (Cancelling) otherwise, so TurnCancelled stays the one terminal signal for a cancel.

§

BackgroundScope(TurnId)

Ctrl+B: signal the turn’s scope to BACKGROUND (not cancel) its running work. The scope’s background token fires; detachable tools (execute_ command) move their child to a background process and return. The scope is left intact (unlike CancelScope).

§

ResolveApproval

Resolve an inline approval prompt: deliver the user’s decision to the parked tool task via the ApprovalBroker. NOT turn-scoped — it’s a fire-and-forget to the broker (the tool task it unblocks is the turn-scoped work).

Fields

§call_id: ToolCallId
§

SaveConversation(ConversationHistory)

Save the current conversation to disk. No-op if unchanged since last save (effect-side idempotence).

§

SaveCompactionArchive

Persist the raw messages removed by a compaction, then the compacted (message-stripped) conversation. Both are written by ONE effect task, archive first — only overwriting the conversation if the archive persisted — so a failed/lagging archive can never lose messages while the stripped conversation is saved over the old one.

§

SaveProcess(ManagedProcess)

Persist a daemon-visible background process record.

§

PersistLastModel(String)

Persist the active model ID as last_used_model.

§

PersistReasoningFor

Persist reasoning level tied to a specific model ID.

Fields

§model_id: String
§

PersistOllamaNumCtxFor

Persist (or clear, when num_ctx is None) a per-model Ollama num_ctx override set via /context <n>/max/auto.

Fields

§model_id: String
§num_ctx: Option<u32>
§

PersistOllamaOffload(bool)

Persist the Ollama RAM-offload toggle (/context offload on|off).

§

ListMemory

List saved memories; emits Msg::RuntimeText with the rendered list.

§

RememberMemory

Save free-text to private memory; emits Msg::MemoryChanged + status.

Fields

§text: String
§

ForgetMemory

Delete a memory by name/id; emits Msg::MemoryChanged + status.

Fields

§

ConsolidateMemory

Model-assisted prune of duplicate/obsolete memories, reversible via a checkpoint. Emits Msg::RuntimeText (the report) + Msg::MemoryChanged.

Fields

§model_id: String
§

LoadConversation(String)

Load a specific conversation by ID and emit Msg::ConversationLoaded. Reducer consumes that event to replace the current session.

§

ListConversations

Scan the conversations directory for the /load picker. Emits Msg::ConversationsListed with one ConversationSummary per saved session (newest first). The reducer transitions to UiMode::ConversationList and the render shows the picker.

§

ListRuntimeTasks

List durable daemon/runtime tasks.

Fields

§limit: usize
§

LoadRuntimeTask

Load one durable daemon/runtime task and its timeline.

Fields

§

ListRuntimeProcesses

List durable daemon/runtime background processes.

Fields

§limit: usize
§

ShowRuntimeProcessLogs

Print one durable process log into the conversation.

Fields

§

StopRuntimeProcess

Stop a durable process by pid.

Fields

§

RestartRuntimeProcess

Restart a durable process using its recorded command/cwd.

Fields

§

OpenRuntimeTarget

Open a URL, path, or process target.

Fields

§target: String
§

ShowRuntimePorts

Show listening ports.

§

ListRuntimeApprovals

List pending approval records.

§

DecideRuntimeApproval

Mark one approval as approved or denied.

Fields

§decision: String
§

ListRuntimeCheckpoints

List restore checkpoints.

Fields

§limit: usize
§

ListRuntimePlugins

List installed plugins.

§

UpdateRuntimeTaskStatus

Update one durable task’s status.

Fields

§status: TaskStatus
§final_report: Option<String>
§

CreateRuntimeCheckpoint

Create a shadow checkpoint for explicit paths.

Fields

§paths: Vec<PathBuf>
§

RestoreRuntimeCheckpoint

Restore files from a shadow checkpoint.

Fields

§

ShowRuntimeModelInfo

Show provider/model capability information.

Fields

§model: String
§

InitMcpServers(HashMap<String, McpServerConfig>)

Start every configured MCP server; each one emits Msg::McpServerReady or Msg::McpServerErrored as it comes up.

§

StopMcpServer

Stop a running server (e.g. config was removed, or app quit).

Fields

§name: String
§

PullOllamaModel

ollama pull <model> with progress → Msg::ModelPullFinished.

Fields

§model: String
§

OpenInSystem(PathBuf)

xdg-open / open / start on a file path. Used by the image-paste preview and the “open in editor” affordance.

§

WriteImageToTemp

Persist a pasted image to a temp file so the TUI can open it via OpenInSystem. Emits no follow-up Msg on success; failure is a log-and-drop.

Fields

§path: PathBuf
§bytes: Vec<u8>
§format: String
§

ReadClipboard

Read the system clipboard on a blocking task. The per-platform dispatch (xclip / wl-paste / pngpaste / PowerShell) can block for hundreds of ms on macOS via osascript, so it never runs on the reducer thread. Emits Msg::Paste(Paste::Image|Text) on success; Msg::TransientStatus when the clipboard is empty or the read fails.

§

CopyToClipboard(String)

Write text to the system clipboard on a blocking task (mirrors ReadClipboard’s per-platform dispatch). Used by in-app drag-select copy. Emits a Msg::TransientStatus (“Copied N chars” / failure).

§

Exit

Exit the main loop. No reply message — the loop observes state.should_exit after the reducer returns and breaks out.

§

SetTerminalTitle(String)

Write the OSC 2 terminal-title sequence. Reducer diffs against ui.last_title_dispatched so this only fires on actual title changes, not every frame.

Implementations§

Source§

impl Cmd

Source

pub fn tag(&self) -> &'static str

Human-readable tag, for tracing + replay logs. Stable across refactors (tests assert against it).

Source

pub fn is_turn_scoped(&self) -> bool

True iff this command needs to run inside a TurnScope so it can be cancelled by Cmd::CancelScope. The effect runner uses this to decide between “spawn into JoinSet” and “spawn detached”.

Source

pub fn scope_turn(&self) -> Option<TurnId>

The TurnId of the scope this command would spawn fresh work into. Only the scope-spawning variants return Some (the same set as is_turn_scoped); the scope-control variants (CancelScope / BackgroundScope) act on an existing scope rather than populating one with new work, so they return None.

The effect runner uses this to refuse spawning fresh work for a turn it has already cancelled (tombstoned) — a stray post-cancel CallModel/ExecuteTool/CompactConversation would otherwise resurrect an un-cancelled scope via scope_mut’s or_insert_with (F38). CancelScope must keep working on a tombstoned turn, which is exactly why it is excluded here.

Source

pub fn summary(&self) -> String

For traces + the --record file — some Cmd payloads are huge (think ChatRequest::messages). This returns a compact identifier that doesn’t dump the full payload.

Trait Implementations§

Source§

impl Clone for Cmd

Source§

fn clone(&self) -> Cmd

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Cmd

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Cmd

§

impl RefUnwindSafe for Cmd

§

impl Send for Cmd

§

impl Sync for Cmd

§

impl Unpin for Cmd

§

impl UnsafeUnpin for Cmd

§

impl UnwindSafe for Cmd

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more