Skip to main content

ag_agent/
lib.rs

1//! Agent backend transports and provider-neutral contracts.
2//!
3//! This crate owns the agent execution boundary used by Agentty: provider
4//! model metadata, turn prompt payloads, CLI/app-server transports, and
5//! channel contracts. [`OneShotClient`] presents isolated structured prompts
6//! as one injectable operation, while [`TurnContinuation`] keeps transport
7//! recovery state out of [`TurnRequest`]. The crate intentionally avoids
8//! depending on the `agentty` application crate so provider-specific
9//! dependencies compile in a leaf workspace member.
10
11mod agent;
12mod app_server;
13pub(crate) mod app_server_transport;
14mod channel;
15mod model;
16
17pub use agent::{
18    AgentAvailabilityProbe, AgentBackend, AgentBackendError, AgentTransport, BuildCommandRequest,
19    OneShotClient, OneShotError, OneShotRequest, OneShotSubmission, RealAgentAvailabilityProbe,
20    RealOneShotClient, StaticAgentAvailabilityProbe, cleanup_session_worktree_artifacts,
21    create_app_server_client, create_backend, diff_fence, executable_name,
22    normalize_instruction_conversation_id, transport_mode,
23};
24#[cfg(any(test, feature = "test-utils"))]
25pub use agent::{MockAgentBackend, MockOneShotClient};
26#[cfg(any(test, feature = "test-utils"))]
27pub use app_server::MockAppServerClient;
28pub use app_server::{
29    AppServerClient, AppServerError, AppServerFuture, AppServerStreamEvent, AppServerTurnRequest,
30    AppServerTurnResponse,
31};
32pub use channel::{
33    AgentChannel, AgentError, AgentFuture, AgentRequestKind, LiveTranscript, SessionRef,
34    StartSessionRequest, TurnContinuation, TurnEvent, TurnRequest, TurnResult,
35    create_agent_channel,
36};
37#[cfg(any(test, feature = "test-utils"))]
38pub use channel::{MockAgentChannel, create_cli_agent_channel_with_backend};
39pub use model::agent::{
40    AgentCliInfo, AgentCliVersion, AgentKind, AgentModel, AgentSelection, AgentSelectionMetadata,
41    ReasoningLevel, parse_persisted_session_agent_model, resolve_agent_kind_for_model,
42    resolve_agent_selection_for_model, resolve_model_for_available_agent_kinds,
43    resolve_prompt_model_agent_kind, selectable_models_for_agent_kinds,
44};
45pub use model::permission::PermissionMode;
46pub use model::session::SessionStats;