Skip to main content

Module agent

Module agent 

Source
Expand description

Channel-based Agent handle - the public consumer surface.

Agent::spawn constructs a ForgeSdkBridge under the hood and spawns one background task: the command dispatcher, which drains mpsc::UnboundedReceiver<AgentCommand> and calls the matching inherent method on the bridge. The bridge’s AgentEvent receiver is handed back to consumers via take_events().

Direct-return accessors (config_dir, settings_documents, etc.) live on AgentHandle as method passthroughs to the bridge.

Re-exportsΒ§

use std::collections::HashMap; πŸ”’
use std::path::Path; πŸ”’
use std::path::PathBuf; πŸ”’
use std::sync::Arc; πŸ”’
use forge_primitives::AgentCommand; πŸ”’
use forge_primitives::PermissionMode; πŸ”’
use parking_lot::Mutex; πŸ”’
use tokio::sync::mpsc; πŸ”’
use tracing::Instrument; πŸ”’
use crate::forge_sdk_bridge::ForgeSdkBridge; πŸ”’

StructsΒ§

Agent
Agent factory - wraps a private ForgeSdkBridge behind a channel API.
AgentHandle
Handle returned by Agent::spawn. Owns the channels + a thin passthrough to the bridge’s direct-return accessors.

EnumsΒ§

AgentError
Errors surfaced from AgentHandle’s fire-and-forget command methods. The underlying claude subprocess work flows back asynchronously via the events stream - these are dispatch-time failures only.

FunctionsΒ§

decode_launch_settings πŸ”’
Decode launch settings off the dispatcher channel. Symmetric to the encode-side ?-propagation in AgentHandle::new_session.
dispatch πŸ”’
Dispatch one AgentCommand to the matching ForgeSdkBridge method. Internal - kept on anyhow because the bridge surface itself returns anyhow::Result and the dispatcher task only logs the error before continuing. The public AgentHandle surface above uses the typed AgentError.
dispatch_commands πŸ”’