pub struct Agent;Expand description
Agent factory - wraps a private ForgeSdkBridge behind a channel API.
Implementations§
Source§impl Agent
impl Agent
Sourcepub fn testing_stub() -> (AgentHandle, UnboundedReceiver<AgentCommand>)
pub fn testing_stub() -> (AgentHandle, UnboundedReceiver<AgentCommand>)
Construct a test stub: AgentHandle backed by a fresh
ForgeSdkBridge that’s never actually driven (no new_session
call). Returns the handle plus a Receiver<AgentCommand> that
drains every command the test exercises.
Safe to call outside a Tokio runtime - no tasks are spawned.
The bridge’s events stream is dropped on the floor; tests that
don’t drive sessions never see events anyway. The bridge is
bound to a synthetic /tmp/forge-testing-stub config_dir;
since no session is driven, no I/O hits this path.
Sourcepub fn spawn(
config_dir: PathBuf,
display_name: Option<String>,
extra_mcp_servers: Vec<(String, McpServer)>,
env: HashMap<String, String>,
) -> AgentHandle
pub fn spawn( config_dir: PathBuf, display_name: Option<String>, extra_mcp_servers: Vec<(String, McpServer)>, env: HashMap<String, String>, ) -> AgentHandle
Spawn a new agent runtime bound to config_dir with an
optional forge-account display_name. Both are stored on the
bridge as typed fields. config_dir is consulted by every
in-process accessor (oauth, settings, catalog scans) and
exported to the spawned claude subprocess as
CLAUDE_CONFIG_DIR. display_name, when set, is read back
through the handle’s display_name() so a view
renders which forge-account the bridge is bound to. env
carries the session’s resolved forge.toml env - [env], then
[accounts.env], then the spawning project’s [[orgs.projects]]
env - stamped onto the spawned subprocess
alongside CLAUDE_CONFIG_DIR. Returns a
handle holding the command sender + events receiver + direct-
accessor passthroughs.