Skip to main content

Agent

Struct Agent 

Source
pub struct Agent { /* private fields */ }

Implementations§

Source§

impl Agent

Source

pub fn spawn( provider: Arc<dyn Provider>, dir: &Path, args: &[String], resume_session: Option<&str>, prompt: Option<&str>, env_vars: &[(&str, &str)], ) -> Result<Self>

Spawn a new agent process attached to a PTY. env_vars are set on the child process (e.g. TAM_AGENT_ID, TAM_SOCKET).

Source

pub fn check_exited(&mut self) -> Option<i32>

Check if the child process has exited. Returns Some(exit_code) if so. Agents that exit are cleaned up by the daemon — exit is an event, not a state.

Source

pub fn kill(&mut self) -> Result<()>

Send SIGTERM, wait briefly, then SIGKILL if needed.

Source

pub fn kill_and_drop(self)

Kill the agent and drop it. Intended for use in background tasks where ownership is transferred (e.g. spawn_blocking).

Source

pub fn set_state(&mut self, state: AgentState)

Set the stored state directly (used by hook-based providers).

Source

pub fn handle_hook_event(&mut self, event: &str) -> Option<AgentState>

Map a hook event to a state via the provider, and update stored state. Returns the new state if the event was recognized, None otherwise.

Source

pub fn check_state_change(&mut self) -> Option<(AgentState, AgentState)>

Check for a state transition. Returns Some((old, new)) if state changed. Updates reported_state so the same transition isn’t reported twice.

Source

pub fn current_state(&self) -> AgentState

Compute current state: ask the provider first (output heuristic), fall back to the stored state (set by hooks or default).

Source

pub fn info(&self, id: &str) -> AgentInfo

Build an AgentInfo snapshot for reporting to clients.

Source

pub fn context_refresh_job(&self, id: &str) -> ContextRefreshJob

Collect lightweight metadata for two-phase context refresh. This is cheap (no IO) and can be called under the lock.

Source

pub fn set_context_percent(&mut self, pct: Option<u8>) -> bool

Set context percent. Returns true if the value changed.

Source

pub fn context_percent(&self) -> Option<u8>

Source

pub fn viewers(&self) -> Arc<AtomicUsize>

Get the viewer count handle for increment/decrement by attach sessions.

Source

pub fn subscribe(&self) -> Receiver<Vec<u8>>

Subscribe to live PTY output. Returns a broadcast receiver.

Source

pub fn scrollback_contents(&self) -> Vec<u8>

Get a copy of the current scrollback buffer contents.

Source

pub fn pty_master(&self) -> Arc<OwnedFd>

Get a clone of the PTY master fd (kept alive by Arc).

Source

pub fn resize(&self, cols: u16, rows: u16)

Resize the agent’s PTY and notify the agent process.

Auto Trait Implementations§

§

impl Freeze for Agent

§

impl !RefUnwindSafe for Agent

§

impl Send for Agent

§

impl Sync for Agent

§

impl Unpin for Agent

§

impl UnsafeUnpin for Agent

§

impl !UnwindSafe for Agent

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> 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, 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