theway-core 0.1.21

theway core — stateful agent runtime + harness (Agent loop, skills, prompt templates, sessions, compaction) on top of theway-llm-provider.
Documentation
//! High-frequency event plane types for the job registry (graph mode).

use strum::IntoStaticStr;

/// Capacity of the built-in broadcast channel for [`SubagentJobEvent`]s.
/// Same sizing rationale as `LOOP_EVENT_BROADCAST_CAPACITY`: enough for
/// bursty output without backpressure on the subagent runner.
pub const SUBAGENT_JOB_EVENT_BROADCAST_CAPACITY: usize = 256;

/// High-frequency event plane (graph mode): broadcast by the registry as jobs
/// start, produce output, update metrics, and complete. Transport-agnostic — the
/// transport layer converts these into the wire `StreamEvent` (see
/// `crates/theway-transport/proto/events.proto`).
#[derive(Clone, Debug)]
pub enum SubagentJobEvent {
    Started {
        id: String,
        agent: String,
        source: String,
        run_id: Option<String>,
        node_id: Option<String>,
        session_id: Option<String>,
    },
    Output {
        id: String,
        chunk: String,
        session_id: Option<String>,
    },
    Metrics {
        id: String,
        tps: Option<f64>,
        cps: Option<f64>,
        chars: u64,
        tokens_in: u64,
        tokens_out: u64,
        tools_called: u64,
        turn: u32,
        session_id: Option<String>,
    },
    Completed {
        id: String,
        status: SubagentJobStatus,
        error: Option<String>,
        chars: u64,
        tokens_in: u64,
        tokens_out: u64,
        tools_called: u64,
        session_id: Option<String>,
    },
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, IntoStaticStr)]
#[strum(serialize_all = "lowercase")]
pub enum SubagentJobStatus {
    Running,
    Succeeded,
    Failed,
    Cancelled,
    /// The current turn was interrupted (`SubagentControlHandle::interrupt`) and no
    /// steering was queued, so the run ended at the turn boundary.
    Interrupted,
}

impl SubagentJobStatus {
    pub fn as_str(&self) -> &'static str {
        (*self).into()
    }
}

#[cfg(test)]
tests_bridge_macro::tests_bridge!("multiagent/job_events");