Skip to main content

State

Struct State 

Source
pub struct State {
Show 14 fields pub seq: Seq, pub sessions: BTreeMap<SessionId, Session>, pub archived_sessions: BTreeMap<SessionId, Session>, pub tasks: BTreeMap<TaskId, Task>, pub messages: Vec<BusMessage>, pub artifacts: Vec<Artifact>, pub reviews: Vec<ReviewComment>, pub pending_permissions: BTreeMap<String, PermissionRequest>, pub pending_questions: BTreeMap<String, UserQuestion>, pub transcripts: HashMap<SessionId, VecDeque<String>>, pub log_ok: bool, pub quotas: BTreeMap<String, Quota>, pub queues: BTreeMap<SessionId, Vec<String>>, pub inbox_cursors: BTreeMap<SessionId, String>,
}

Fields§

§seq: Seq§sessions: BTreeMap<SessionId, Session>§archived_sessions: BTreeMap<SessionId, Session>

Historical sessions removed from active list with native_id (for resuming original conversation).

§tasks: BTreeMap<TaskId, Task>§messages: Vec<BusMessage>§artifacts: Vec<Artifact>§reviews: Vec<ReviewComment>§pending_permissions: BTreeMap<String, PermissionRequest>

Pending approval requests.

§pending_questions: BTreeMap<String, UserQuestion>

Pending interactive user questions.

§transcripts: HashMap<SessionId, VecDeque<String>>

Session ID -> output text lines.

§log_ok: bool

Event log write health status (defaults to normal).

§quotas: BTreeMap<String, Quota>

Latest quota reported by each agent (agent ID -> quota).

§queues: BTreeMap<SessionId, Vec<String>>

Queued raw prompt text list per session (session ID -> items).

§inbox_cursors: BTreeMap<SessionId, String>

Last bus message id already delivered to each session (session ID -> message ID).

Implementations§

Source§

impl State

Source

pub fn new() -> Self

Source

pub fn archive_session(&mut self, session: &str)

Moves terminated session from active list; archives to archived_sessions if possessing native_id for future resumption.

Source

pub fn archived_to_prune( &self, now_ms: u64, max_count: usize, max_days: u64, ) -> Vec<SessionId>

Archived session ids that exceed the retention limits: older than max_days (counted from when they ended) or beyond the newest max_count entries.

Source

pub fn apply(&mut self, rec: &Record)

Applies an event to state. rec.seq updates self.seq.

Source

pub fn session_depth(&self, sid: &str) -> usize

Calculates depth of sid (human-created sessions are level 0, child agents increment sequentially).

Source

pub fn tree_root(&self, sid: &str) -> SessionId

Traverses upward along parent to find the root session ID of the tree.

Source

pub fn tree_sessions(&self, sid: &str) -> Vec<SessionId>

Returns all session IDs in the same tree as sid (root and all descendants).

Source

pub fn tree_cost_usd(&self, sid: &str) -> f64

Calculates total USD cost for the same tree as sid (root and all descendants).

Source

pub fn live_children_count(&self, parent_id: &str) -> usize

Counts live direct child sessions currently running under parent_id.

Source

pub fn sessions_sorted(&self) -> Vec<&Session>

Helper for TUI to retrieve sessions sorted by creation time.

Source

pub fn live_sessions(&self) -> impl Iterator<Item = &Session>

Source

pub fn total_cost(&self) -> Cost

Calculates cumulative cost and token usage across all sessions.

Source

pub fn unfinished_deps(&self, task: &Task) -> Vec<&Task>

Incomplete prerequisite tasks (present in depends_on with status other than done). Missing IDs do not count: they will never complete, and counting them would deadlock the task.

Source

pub fn resolve_session_id(&self, id_or_label: &str) -> Option<SessionId>

Resolves session ID by id or label (prefers exact ID match, then live session with matching label).

Source

pub fn resolve_resumable_session( &self, id_or_label: &str, ) -> Option<(Session, bool)>

Finds target session for :resume by id, label, or native_id; returns (Session, is_archived).

Source

pub fn successor_of(&self, id: &str) -> SessionId

Follows handed_off_to chain to final successor; stops at current node on cycles or exceeding 16 levels.

Source

pub fn inbox_for( &self, session_id: &str, after_msg_id: Option<&str>, ) -> Vec<BusMessage>

Retrieves messages received by a session after after_msg_id.

Source

pub fn export_markdown( &self, root_id: &str, include_tree: bool, diff: Option<&str>, ) -> Result<String, String>

Exports a session (and optionally entire child session tree) into a Markdown report suitable for PR / Issue description.

Includes metadata, child session hierarchy, associated tasks, transcript, and optional git diff; entire output is masked with redact_secrets to prevent leaking keys to external services.

Trait Implementations§

Source§

impl Clone for State

Source§

fn clone(&self) -> Self

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 State

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for State

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for State

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for State

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Forget for State

§

impl Freeze for State

§

impl Move for State

§

impl RefUnwindSafe for State

§

impl Send for State
where NodeRef<Owned, String, Session, LeafOrInternal>: Send, BoxRaw<(String, Session)>: Send, NodeRef<Owned, String, Task, LeafOrInternal>: Send, BoxRaw<(String, Task)>: Send, RawVecInner: Send, NodeRef<Owned, String, PermissionRequest, LeafOrInternal>: Send, BoxRaw<(String, PermissionRequest)>: Send, NodeRef<Owned, String, UserQuestion, LeafOrInternal>: Send, BoxRaw<(String, UserQuestion)>: Send, RawTable<(String, VecDeque<String>)>: Send, NodeRef<Owned, String, Quota, LeafOrInternal>: Send, BoxRaw<(String, Quota)>: Send, NodeRef<Owned, String, Vec<String>, LeafOrInternal>: Send, BoxRaw<(String, Vec<String>)>: Send, NodeRef<Owned, String, String, LeafOrInternal>: Send, BoxRaw<(String, String)>: Send,

§

impl Sync for State
where NodeRef<Owned, String, Session, LeafOrInternal>: Sync, BoxRaw<(String, Session)>: Sync, NodeRef<Owned, String, Task, LeafOrInternal>: Sync, BoxRaw<(String, Task)>: Sync, RawVecInner: Sync, NodeRef<Owned, String, PermissionRequest, LeafOrInternal>: Sync, BoxRaw<(String, PermissionRequest)>: Sync, NodeRef<Owned, String, UserQuestion, LeafOrInternal>: Sync, BoxRaw<(String, UserQuestion)>: Sync, RawTable<(String, VecDeque<String>)>: Sync, NodeRef<Owned, String, Quota, LeafOrInternal>: Sync, BoxRaw<(String, Quota)>: Sync, NodeRef<Owned, String, Vec<String>, LeafOrInternal>: Sync, BoxRaw<(String, Vec<String>)>: Sync, NodeRef<Owned, String, String, LeafOrInternal>: Sync, BoxRaw<(String, String)>: Sync,

§

impl Unpin for State
where *const LeafNode<String, Session> is !null: Unpin, Box<(String, Session)>: Unpin, *const LeafNode<String, Task> is !null: Unpin, Box<(String, Task)>: Unpin, *const u8 is !null: Unpin, *const LeafNode<String, PermissionRequest> is !null: Unpin, Box<(String, PermissionRequest)>: Unpin, *const LeafNode<String, UserQuestion> is !null: Unpin, Box<(String, UserQuestion)>: Unpin, *const LeafNode<String, Quota> is !null: Unpin, Box<(String, Quota)>: Unpin, *const LeafNode<String, Vec<String>> is !null: Unpin, Box<(String, Vec<String>)>: Unpin, *const LeafNode<String, String> is !null: Unpin, Box<(String, String)>: Unpin,

§

impl UnsafeUnpin for State

§

impl UnwindSafe for State

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.