Types Reference

All public structs, enums, and type aliases. Enums marked #[non_exhaustive] cannot be exhaustively matched outside this crate — always include a _ arm.


Agent Builder — synwire_core::agents::agent_node


Agent<O>

Builder for configuring and constructing a runnable agent. O is the optional structured output type; use () for unstructured text.

#![allow(unused)]
fn main() {
pub struct Agent<O: Serialize + Send + Sync + 'static = ()> { /* private */ }
}

Builder methods (all #[must_use], all return Self):

MethodDescription
new(name, model)Create a builder with name and primary model set.
description(s)Human-readable description.
model(s)Override the primary model identifier.
fallback_model(s)Model used when the primary is rate-limited or unavailable.
effort(EffortLevel)Reasoning effort hint.
thinking(ThinkingConfig)Extended thinking / chain-of-thought configuration.
tool(t)Add a tool available to the agent.
allowed_tools(iter)Allowlist of tool names (only these tools may be called).
exclude_tool(name)Remove a tool by name from the effective set.
plugin(p)Attach a plugin.
middleware(mw)Append a middleware to the stack.
hooks(HookRegistry)Register lifecycle hooks.
output_mode(OutputMode)Configure structured output extraction.
output_schema(Value)JSON Schema for output validation.
max_turns(u32)Maximum turns per run.
max_budget(f64)Maximum cumulative cost in USD.
system_prompt(SystemPromptConfig)Append to or replace the base system prompt.
permission_mode(PermissionMode)Permission preset.
permission_rule(PermissionRule)Add a declarative permission rule.
sandbox(SandboxConfig)Sandbox configuration.
env(key, value)Set an environment variable available to the agent.
cwd(path)Set the working directory.
debug()Enable verbose debug logging.
debug_file(path)Write debug output to a file.
mcp_server(name)Register an MCP server by name.
before_agent(f)Callback invoked before each turn.
after_agent(f)Callback invoked after each turn (success or failure).
on_model_error(f)Callback invoked on model errors; returns ModelErrorAction.

Agent<O> implements AgentNode.


RunContext

Runtime context made available during agent execution.

#![allow(unused)]
fn main() {
pub struct RunContext {
    pub session_id: Option<String>,
    pub model: String,
    pub retry_count: u32,
    pub cumulative_cost_usd: f64,
    pub metadata: HashMap<String, Value>,
}
}
FieldDescription
session_idActive session ID, or None for stateless runs.
modelModel identifier resolved for this run.
retry_countNumber of retries for the current turn (0 = first attempt).
cumulative_cost_usdTotal cost accumulated in this session so far.
metadataArbitrary metadata attached at the call site.

ModelErrorAction

Recovery action returned by an OnModelErrorCallback. #[non_exhaustive]

VariantDescription
RetryRetry the current request unchanged.
Abort(String)Abort the run with the given message.
SwitchModel(String)Switch to the specified model and retry.

Runner — synwire_core::agents::runner


Runner<O>

Drives the agent execution loop. Stateless between runs.

#![allow(unused)]
fn main() {
pub struct Runner<O: Serialize + Send + Sync + 'static = ()> { /* private */ }
}
MethodDescription
new(agent)Create a runner wrapping the given Agent<O>.
async set_model(model)Switch to a different model for subsequent turns without resetting conversation history.
async stop_graceful()Signal a graceful stop; the runner finishes any in-flight tool call then emits TurnComplete { reason: Stopped }.
async stop_force()Signal an immediate stop; emits TurnComplete { reason: Aborted }.
async run(input, config) -> Result<Receiver<AgentEvent>, AgentError>Start a run. Events arrive on the returned mpsc::Receiver. The stream ends after a TurnComplete or Error event.

RunnerConfig

Configuration for a single runner execution.

#![allow(unused)]
fn main() {
pub struct RunnerConfig {
    pub model_override: Option<String>,
    pub session_id: Option<String>,
    pub max_retries: u32,          // default: 3
}
}
FieldDescription
model_overrideOverride the agent's model for this specific run.
session_idResume an existing session, or None for a new session.
max_retriesMaximum retries per model error before falling back or aborting.

StopKind

#![allow(unused)]
fn main() {
pub enum StopKind {
    Graceful,
    Force,
}
}
VariantDescription
GracefulDrain in-flight tool calls, then stop.
ForceCancel immediately without draining.

RunErrorAction

Action taken by the runner when an error occurs. #[non_exhaustive]

VariantDescription
RetryRetry the current request (up to max_retries).
ContinueIgnore this error and advance to the next turn.
Abort(String)Abort the run immediately.
SwitchModel(String)Switch to the given model and retry.

Directive System — synwire_core::agents::directive


Directive

Typed effect description returned by agent nodes. Directives describe side effects without executing them, enabling pure unit tests. #[non_exhaustive]

#![allow(unused)]
fn main() {
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
#[non_exhaustive]
pub enum Directive { ... }
}
VariantFieldsDescription
Emitevent: AgentEventEmit an event to the event stream.
SpawnAgentname: String, config: ValueRequest spawning a child agent.
StopChildname: StringRequest stopping a child agent.
Scheduleaction: String, delay: DurationSchedule a delayed action. Delay is serialised via humantime_serde.
RunInstructioninstruction: String, input: ValueAsk the runtime to execute an instruction and route the result back.
Cronexpression: String, action: StringSchedule a recurring action.
Stopreason: Option<String>Request agent stop.
SpawnTaskdescription: String, input: ValueSpawn a background task.
StopTasktask_id: StringCancel a background task by ID.
Custompayload: Box<dyn DirectivePayload>User-defined directive. Requires #[typetag::serde] on the payload type.

DirectiveResult<S>

Combines a state update with zero or more directives. S must implement synwire_core::State.

#![allow(unused)]
fn main() {
pub struct DirectiveResult<S: State> {
    pub state: S,
    pub directives: Vec<Directive>,
}
}

Constructors:

MethodDescription
state_only(s)No directives.
with_directive(s, d)One directive.
with_directives(s, ds)Multiple directives.
From<S>Converts state directly (equivalent to state_only).

Errors


AgentError

Top-level error for agent operations. #[non_exhaustive]

VariantDescription
Model(ModelError)LLM API error (#[from] conversion from ModelError).
Tool(String)Tool execution failure.
Strategy(String)Execution strategy error.
Middleware(String)Middleware error.
Directive(String)Directive execution error.
Backend(String)Backend operation error.
Session(String)Session management error.
Panic(String)Caught panic with message payload.
BudgetExceeded(f64)Cost exceeded the configured budget (USD).

ModelError

LLM API error with retryability metadata. #[non_exhaustive]

VariantRetryableDescription
Authentication(String)NoAPI key or credential failure.
Billing(String)NoQuota or billing error.
RateLimit(String)YesRate limit exceeded.
ServerError(String)YesProvider server error (5xx).
InvalidRequest(String)NoMalformed request.
MaxOutputTokensNoResponse exceeded the output token limit.

Methods:

MethodReturnsDescription
is_retryable()booltrue for RateLimit and ServerError variants.

StrategyError

Execution strategy error. #[non_exhaustive]

VariantFieldsDescription
InvalidTransitioncurrent_state, attempted_action, valid_actionsAction not valid from the current FSM state.
GuardRejected(String)All guard conditions rejected the transition.
NoInitialStateFsmStrategyBuilder::build called without setting an initial state.
Execution(String)General execution failure (e.g. mutex poisoned).

DirectiveError

Error from DirectiveExecutor. #[non_exhaustive]

VariantDescription
ExecutionFailed(String)Directive could not be executed.
Unsupported(String)Directive type not supported by this executor.

FilterDecision

Decision returned by DirectiveFilter::decision. #[non_exhaustive]

VariantDescription
PassDirective passes through (may be modified).
SuppressDirective is silently dropped.
RejectDirective is rejected with an error.

FilterChain

Ordered sequence of DirectiveFilter implementations.

MethodDescription
new()Create an empty chain.
add(filter)Append a filter.
apply(directive) -> Option<Directive>Apply all filters in order. Returns None if any filter suppresses.

VfsError

Backend operation error. #[non_exhaustive]

VariantDescription
NotFound(String)File or directory not found.
PermissionDenied(String)Insufficient permissions.
IsDirectory(String)Expected file, got directory.
PathTraversal { attempted, root }Path traversal attempt blocked.
ScopeViolation { path, scope }Path outside the allowed scope.
ResourceLimit(String)Resource limit exceeded.
Timeout(String)Operation timed out.
OperationDenied(String)Denied by approval gate.
Unsupported(String)Operation not supported by this backend.
Io(io::Error)I/O error (#[from] conversion).

Streaming — synwire_core::agents::streaming


AgentEvent

Streaming event produced during an agent run. #[non_exhaustive]

#![allow(unused)]
fn main() {
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
#[non_exhaustive]
pub enum AgentEvent { ... }
}
VariantKey fieldsDescription
TextDeltacontent: StringStreaming text chunk from the model.
ToolCallStartid: String, name: StringTool invocation started.
ToolCallDeltaid: String, arguments_delta: StringStreaming argument fragment.
ToolCallEndid: StringTool invocation arguments complete.
ToolResultid: String, output: ToolOutputTool execution result.
ToolProgressid: String, message: String, progress_pct: Option<f32>Progress report from a long-running tool.
StateUpdatepatch: ValueJSON patch to apply to agent state.
DirectiveEmitteddirective: ValueAgent emitted a directive (serialised).
StatusUpdatestatus: String, progress_pct: Option<f32>Human-readable status message.
UsageUpdateusage: UsageToken and cost counters for the current turn.
RateLimitInfoutilization_pct: f32, reset_at: i64, allowed: boolRate limit information.
TaskNotificationtask_id: String, kind: TaskEventKind, payload: ValueBackground task lifecycle event.
PromptSuggestionsuggestions: Vec<String>Model-suggested follow-up prompts.
TurnCompletereason: TerminationReasonTurn ended. Always the last event unless Error occurs first.
Errormessage: StringFatal error; no further events follow.

Method:

MethodReturnsDescription
is_final_response()booltrue for TurnComplete and Error.

AgentEventStream

#![allow(unused)]
fn main() {
pub type AgentEventStream =
    Pin<Box<dyn Stream<Item = Result<AgentEvent, AgentError>> + Send>>;
}

Type alias for the stream returned by AgentNode::run.


TerminationReason

Why a turn ended. #[non_exhaustive]

VariantDescription
CompleteAgent finished normally.
MaxTurnsExceededmax_turns limit reached.
BudgetExceededmax_budget limit reached.
StoppedGraceful stop requested via Runner::stop_graceful.
AbortedForce stop requested via Runner::stop_force.
ErrorTerminated due to an unrecoverable error.

TaskEventKind

Lifecycle event for background tasks. #[non_exhaustive]

VariantDescription
StartedTask began executing.
ProgressTask reported intermediate progress.
CompletedTask finished successfully.
FailedTask encountered an error.

Session — synwire_core::agents::session


Session

Full snapshot of a conversation, persisted by SessionManager.

#![allow(unused)]
fn main() {
pub struct Session {
    pub metadata: SessionMetadata,
    pub messages: Vec<Value>,
    pub state: Value,
}
}
FieldDescription
metadataIdentity and statistics.
messagesConversation history as an array of JSON message objects.
stateArbitrary agent state (plugin state, environment, etc.) serialised as JSON.

SessionMetadata

#![allow(unused)]
fn main() {
pub struct SessionMetadata {
    pub id: String,
    pub name: Option<String>,
    pub tags: Vec<String>,
    pub agent_name: String,
    pub created_at: i64,
    pub updated_at: i64,
    pub turn_count: u32,
    pub total_tokens: u64,
}
}
FieldDescription
idUnique session identifier (UUID string).
nameOptional human-readable name.
tagsUser-defined tags for filtering and search.
agent_nameName of the agent this session belongs to.
created_atUnix milliseconds at creation.
updated_atUnix milliseconds at last save.
turn_countNumber of conversation turns recorded.
total_tokensCumulative token usage.

Model and Config — synwire_core::agents


ModelInfo

#![allow(unused)]
fn main() {
pub struct ModelInfo {
    pub id: String,
    pub display_name: String,
    pub description: String,
    pub capabilities: ModelCapabilities,
    pub context_window: u32,
    pub max_output_tokens: u32,
    pub supported_effort_levels: Vec<EffortLevel>,
}
}

ModelCapabilities

#![allow(unused)]
fn main() {
pub struct ModelCapabilities {
    pub tool_calling: bool,
    pub vision: bool,
    pub streaming: bool,
    pub structured_output: bool,
    pub effort_levels: bool,
}
}

EffortLevel

Reasoning effort hint. #[non_exhaustive]

VariantDescription
LowMinimal reasoning.
MediumModerate reasoning.
HighDeep reasoning (default).
MaxMaximum reasoning.

ThinkingConfig

Extended thinking / chain-of-thought configuration. #[non_exhaustive]

VariantFieldsDescription
AdaptiveModel decides reasoning depth.
Enabledbudget_tokens: u32Fixed token budget for reasoning.
DisabledNo reasoning.

Usage

Token usage and cost for a single turn.

#![allow(unused)]
fn main() {
pub struct Usage {
    pub input_tokens: u64,
    pub output_tokens: u64,
    pub cache_read_tokens: u64,
    pub cache_creation_tokens: u64,
    pub cost_usd: f64,
    pub context_utilization_pct: f32,
}
}

context_utilization_pct is in the range 0.0–1.0.


OutputMode

How the agent extracts structured output from the model response. #[non_exhaustive]

VariantDescription
ToolVia tool call (most reliable). Default.
NativeNative JSON mode (provider must support it).
PromptPost-process raw text via prompt.
CustomUser-supplied extraction function.

SystemPromptConfig

#[non_exhaustive]

VariantFieldsDescription
Appendcontent: StringAppend to the base system prompt.
Replacecontent: StringReplace the base system prompt entirely.

PermissionMode

#[non_exhaustive]

VariantDescription
DefaultPrompt for dangerous operations. Default.
AcceptEditsAuto-approve file modifications.
PlanOnlyRead-only; no mutations allowed.
BypassAllAuto-approve everything.
DenyUnauthorizedDeny unless a matching PermissionRule allows.

PermissionBehavior

#[non_exhaustive]

VariantDescription
AllowAllow the operation.
DenyDeny the operation.
AskPrompt the user.

PermissionRule

Declarative permission rule.

#![allow(unused)]
fn main() {
pub struct PermissionRule {
    pub tool_pattern: String,
    pub behavior: PermissionBehavior,
}
}

tool_pattern is a glob matched against tool names.


SandboxConfig

#![allow(unused)]
fn main() {
pub struct SandboxConfig {
    pub enabled: bool,
    pub network: Option<NetworkConfig>,
    pub filesystem: Option<FilesystemConfig>,
    pub allowed_commands: Option<Vec<String>>,
    pub denied_commands: Vec<String>,
}
}

NetworkConfig

#![allow(unused)]
fn main() {
pub struct NetworkConfig {
    pub enabled: bool,
    pub allowed_domains: Option<Vec<String>>,
    pub denied_domains: Vec<String>,
}
}

allowed_domains = None means all domains are permitted.


FilesystemConfig

#![allow(unused)]
fn main() {
pub struct FilesystemConfig {
    pub allowed_roots: Vec<String>,
    pub denied_paths: Vec<String>,
}
}

Signals — synwire_core::agents::signal


Signal

#![allow(unused)]
fn main() {
pub struct Signal {
    pub kind: SignalKind,
    pub payload: Value,
}
}

Constructor: Signal::new(kind, payload) — both fields are public but the constructor is provided for convenience.


SignalKind

#[non_exhaustive]

VariantDescription
StopUser requested stop.
UserMessageUser message received.
ToolResultTool invocation result available.
TimerTimer or cron event.
Custom(String)Application-defined signal.

SignalRoute

Maps a signal kind (with optional predicate) to an action.

#![allow(unused)]
fn main() {
pub struct SignalRoute {
    pub kind: SignalKind,
    pub predicate: Option<fn(&Signal) -> bool>,
    pub action: Action,
    pub priority: i32,
}
}

The predicate field uses a function pointer (not a closure) so SignalRoute remains Clone + Send + Sync.

Constructors:

MethodDescription
new(kind, action, priority)Route without predicate.
with_predicate(kind, predicate, action, priority)Route with a predicate.

Action

Action resulting from signal routing. #[non_exhaustive]

VariantDescription
ContinueContinue processing normally.
GracefulStopStop after draining in-flight work.
ForceStopStop immediately.
Transition(String)Transition the FSM to the named state.
Custom(String)Application-defined action identifier.

ComposedRouter

Three-tier signal router (strategy > agent > plugin). Within a tier, the route with the highest priority value wins.

#![allow(unused)]
fn main() {
pub struct ComposedRouter { /* private */ }
}
ConstructorDescription
new(strategy_routes, agent_routes, plugin_routes)Build a composed router from three priority tiers.

Implements SignalRouter.


Hooks — synwire_core::agents::hooks


HookRegistry

Registry of lifecycle hooks with typed registration and per-hook timeout enforcement. Hooks that exceed their timeout are skipped with a warn! log and treated as HookResult::Continue.

Registration methods:

MethodHook point
on_pre_tool_use(matcher, f)Before a tool is called.
on_post_tool_use(matcher, f)After a tool succeeds.
on_post_tool_use_failure(matcher, f)After a tool fails.
on_notification(matcher, f)On notification events.
on_subagent_start(matcher, f)When a sub-agent starts.
on_subagent_stop(matcher, f)When a sub-agent stops.
on_pre_compact(matcher, f)Before conversation compaction.
on_post_compact(matcher, f)After conversation compaction.
on_session_start(matcher, f)When a session starts.
on_session_end(matcher, f)When a session ends.

Hook functions have signature Fn(ContextType) -> BoxFuture<'static, HookResult>.


HookMatcher

Selects which events a hook applies to.

#![allow(unused)]
fn main() {
pub struct HookMatcher {
    pub tool_name_pattern: Option<String>,
    pub timeout: Duration,                  // default: 30 seconds
}
}

tool_name_pattern supports * as a wildcard. None matches all events. timeout is enforced per-hook invocation.


HookResult

#[non_exhaustive]

VariantDescription
ContinueProceed with normal execution.
Abort(String)Abort the current operation.

Plugin System — synwire_core::agents::plugin


PluginStateMap

Type-keyed map for isolated plugin state. Access is via PluginStateKey implementations; plugins cannot read each other's state.

MethodDescription
new()Create an empty map.
register::<P>(state) -> Result<PluginHandle<P>, &'static str>Register state for plugin P. Fails if P is already registered (returns P::KEY as Err).
get::<P>() -> Option<&P::State>Immutable borrow.
get_mut::<P>() -> Option<&mut P::State>Mutable borrow.
insert::<P>(state)Insert or replace state unconditionally.
serialize_all() -> ValueSerialise all plugin state to a JSON object keyed by P::KEY strings.

PluginHandle<P>

Zero-sized proof token returned by PluginStateMap::register. Holding a PluginHandle<P> proves that plugin P has been registered. Implements Copy + Clone + Debug.


PluginInput

Context passed to plugin lifecycle hooks.

#![allow(unused)]
fn main() {
pub struct PluginInput {
    pub turn: u32,
    pub message: Option<String>,
}
}

Middleware — synwire_core::agents::middleware


MiddlewareInput

#![allow(unused)]
fn main() {
pub struct MiddlewareInput {
    pub messages: Vec<Value>,
    pub context: Value,
}
}

MiddlewareResult

#[non_exhaustive]

VariantDescription
Continue(MiddlewareInput)Pass (possibly modified) input to the next middleware.
Terminate(String)Halt the chain immediately.

MiddlewareStack

Ordered collection of Middleware implementations.

MethodDescription
new()Create an empty stack.
push(mw)Append a middleware.
async run(input) -> Result<MiddlewareResult, AgentError>Execute all middleware in order. Stops at the first Terminate.
system_prompt_additions() -> Vec<String>Collect additions from all middleware in order.
tools() -> Vec<Box<dyn Tool>>Collect tools from all middleware in order.

Execution Strategies — synwire_core::agents::execution_strategy


FsmStateId

Newtype wrapping String for FSM state identifiers. Implements From<&str> + From<String> + Hash + Eq.


ActionId

Newtype wrapping String for action identifiers. Implements From<&str> + From<String> + Hash + Eq.


ClosureGuard

Adapter wrapping Fn(&Value) -> bool as a GuardCondition.

#![allow(unused)]
fn main() {
pub struct ClosureGuard { /* private */ }
}
ConstructorDescription
new(name, f)Create a named closure guard.

synwire_agent — Implementations


FsmStrategy

FSM-constrained execution strategy. Actions must be valid transitions from the current state; guard conditions further restrict which transitions fire.

MethodDescription
builder() -> FsmStrategyBuilderReturn a builder.
current_state() -> Result<FsmStateId, StrategyError>Return the current FSM state.

Implements ExecutionStrategy.


FsmStrategyWithRoutes

FsmStrategy bundled with associated signal routes (produced by FsmStrategyBuilder::build).

Fields:

  • strategy: FsmStrategy — public for direct state inspection.

Implements ExecutionStrategy.


FsmStrategyBuilder

Builder for FsmStrategyWithRoutes.

MethodDescription
state(id)Declare a state (documentation only; states are inferred from transitions).
transition(from, action, to)Add an unconditional transition.
transition_with_guard(from, action, to, guard, priority)Add a guarded transition. Higher priority is evaluated first.
initial(state)Set the initial FSM state.
route(SignalRoute)Add a signal route contributed by this strategy.
build() -> Result<FsmStrategyWithRoutes, StrategyError>Build. Fails with StrategyError::NoInitialState if no initial state was declared.

FsmTransition

#![allow(unused)]
fn main() {
pub struct FsmTransition {
    pub target: FsmStateId,
    pub guard: Option<Box<dyn GuardCondition>>,
    pub priority: i32,
}
}

DirectStrategy

Executes actions immediately without state constraints. Input is passed through unchanged.

#![allow(unused)]
fn main() {
pub struct DirectStrategy;  // Clone + Default
}

DirectStrategy::new() is equivalent to DirectStrategy::default(). Implements ExecutionStrategy.


InMemorySessionManager

Ephemeral SessionManager backed by a tokio::sync::RwLock<HashMap>. All data is lost when the process exits. See synwire-checkpoint for persistence.

ConstructorDescription
new()Create an empty manager.

InMemoryStore

In-memory BaseStore backed by RwLock<BTreeMap<String, Vec<u8>>>.

ConstructorDescription
new()Create an empty store.

StoreProvider

Wraps a BaseStore and exposes it as Vfs. Keys are paths of the form /<namespace>/<key>. Supports only READ, WRITE, RM.

ConstructorDescription
new(namespace, store)Create a backend scoped to namespace.

CompositeProvider

Routes Vfs operations to the backend whose prefix is the longest segment-boundary match. /store matches /store/foo but not /storefront.

#![allow(unused)]
fn main() {
pub struct CompositeProvider { /* private */ }
}
ConstructorDescription
new(mounts: Vec<Mount>)Sorts mounts by descending prefix length automatically.

For grep: delegates to the first mount that advertises VfsCapabilities::GREP. For glob: aggregates results from all mounts that advertise VfsCapabilities::GLOB.


Mount

#![allow(unused)]
fn main() {
pub struct Mount {
    pub prefix: String,
    pub backend: Box<dyn Vfs>,
}
}

ThresholdGate

ApprovalCallback that auto-approves operations at or below a RiskLevel threshold and delegates higher-risk operations to an inner callback. Caches AllowAlways decisions for subsequent calls to the same operation.

ConstructorDescription
new(threshold, inner)Create a threshold gate.

McpLifecycleManager

Manages multiple named MCP server connections: connects on start, reconnects on disconnect, and supports runtime enable/disable.

MethodDescription
new()Create an empty manager.
async register(name, transport, reconnect_delay)Register a transport under name.
async start_all()Connect all enabled servers.
async stop_all()Disconnect all servers.
async enable(name)Enable and connect a named server.
async disable(name)Disable and disconnect a named server.
async all_status() -> Vec<McpServerStatus>Current status of all managed servers.
async list_tools(server_name)List tools from a named server.
async call_tool(server_name, tool_name, arguments)Call a tool; reconnects if the server is disconnected.
spawn_health_monitor(self: Arc<Self>, interval)Spawn a background task that polls and reconnects dropped servers.

Stdio / Http / InProcess MCP Transports

All three implement McpTransport.

TypeConfig variantDescription
StdioMcpTransportMcpServerConfig::StdioSpawns a subprocess; communicates over stdin/stdout with newline-delimited JSON-RPC.
HttpMcpTransportMcpServerConfig::HttpCommunicates over HTTP; supports optional bearer token authentication.
InProcessMcpTransportMcpServerConfig::InProcessIn-process server backed by registered tool definitions.

SummarisationMiddleware

Detects when conversation history exceeds configured thresholds and marks the context for summarisation. The actual LLM summarisation call is injected by provider crates.

ConstructorDescription
new(thresholds)Create with custom thresholds.
default()max_messages = 50, max_tokens = 80_000, max_context_utilisation = 0.8.

SummarisationThresholds

#![allow(unused)]
fn main() {
pub struct SummarisationThresholds {
    pub max_messages: Option<usize>,
    pub max_tokens: Option<usize>,
    pub max_context_utilisation: Option<f32>,
}
}

Any threshold set to None is not checked. max_context_utilisation is in the range 0.0–1.0.


Backend Types — synwire_core::vfs::types


VfsCapabilities

Bitflags struct. Individual flags:

FlagOperation
LSList directory
READRead files
WRITEWrite files
EDITEdit files
GREPSearch content
GLOBFind files
UPLOADUpload files
DOWNLOADDownload files
PWDGet working directory
CDChange working directory
RMRemove files
CPCopy files
MVMove files
EXECExecute commands

DirEntry

#![allow(unused)]
fn main() {
pub struct DirEntry {
    pub name: String,
    pub path: String,
    pub is_dir: bool,
    pub size: Option<u64>,
    pub modified: Option<DateTime<Utc>>,
}
}

FileContent

#![allow(unused)]
fn main() {
pub struct FileContent {
    pub content: Vec<u8>,
    pub mime_type: Option<String>,
}
}

WriteResult

#![allow(unused)]
fn main() {
pub struct WriteResult {
    pub path: String,
    pub bytes_written: u64,
}
}

EditResult

#![allow(unused)]
fn main() {
pub struct EditResult {
    pub path: String,
    pub edits_applied: usize,
    pub content_after: Option<String>,
}
}

edits_applied is 0 when the old string was not found; 1 when the first occurrence was replaced.


GrepMatch

#![allow(unused)]
fn main() {
pub struct GrepMatch {
    pub file: String,
    pub line_number: usize,   // 1-indexed; 0 when line_numbers is false
    pub column: usize,        // 0-indexed byte offset of match start
    pub line_content: String,
    pub before: Vec<String>,
    pub after: Vec<String>,
}
}

In GrepOutputMode::Count mode, line_number holds the match count and line_content holds its string representation.


GlobEntry

#![allow(unused)]
fn main() {
pub struct GlobEntry {
    pub path: String,
    pub is_dir: bool,
    pub size: Option<u64>,
}
}

TransferResult

#![allow(unused)]
fn main() {
pub struct TransferResult {
    pub path: String,
    pub bytes_transferred: u64,
}
}

Used by upload, download, cp, and mv_file.


FileInfo

#![allow(unused)]
fn main() {
pub struct FileInfo {
    pub path: String,
    pub size: u64,
    pub is_dir: bool,
    pub is_symlink: bool,
    pub modified: Option<DateTime<Utc>>,
    pub permissions: Option<u32>,    // Unix mode bits
}
}

ExecuteResponse

#![allow(unused)]
fn main() {
pub struct ExecuteResponse {
    pub exit_code: i32,
    pub stdout: String,
    pub stderr: String,
}
}

ProcessInfo

#![allow(unused)]
fn main() {
pub struct ProcessInfo {
    pub pid: u32,
    pub command: String,
    pub cpu_pct: Option<f32>,
    pub mem_bytes: Option<u64>,
    pub parent_pid: Option<u32>,
    pub state: String,
}
}

JobInfo

Background job information.

#![allow(unused)]
fn main() {
pub struct JobInfo {
    pub id: String,
    pub pid: Option<u32>,
    pub command: String,
    pub status: String,
}
}

ArchiveEntry

#![allow(unused)]
fn main() {
pub struct ArchiveEntry {
    pub path: String,
    pub is_dir: bool,
    pub size: u64,             // uncompressed size
}
}

ArchiveInfo

#![allow(unused)]
fn main() {
pub struct ArchiveInfo {
    pub entries: Vec<ArchiveEntry>,
    pub format: String,
    pub compressed_size: u64,
}
}

PipelineStage

One stage in a multi-command pipeline.

#![allow(unused)]
fn main() {
pub struct PipelineStage {
    pub command: String,
    pub args: Vec<String>,
    pub stderr_to_stdout: bool,
    pub timeout_secs: Option<u64>,
}
}

Used by SandboxVfs::execute_pipeline.


GrepOptions — synwire_core::vfs::grep_options


GrepOptions

Ripgrep-style search configuration. All fields have zero-value defaults.

#![allow(unused)]
fn main() {
pub struct GrepOptions {
    pub path: Option<String>,
    pub after_context: u32,
    pub before_context: u32,
    pub context: Option<u32>,     // symmetric; overrides before/after if set
    pub case_insensitive: bool,
    pub glob: Option<String>,
    pub file_type: Option<String>,
    pub max_matches: Option<usize>,
    pub output_mode: GrepOutputMode,
    pub multiline: bool,
    pub line_numbers: bool,
    pub invert: bool,
    pub fixed_string: bool,
}
}

path = None searches from the current working directory. file_type accepts ripgrep-style type names: rust, python, js, typescript, json, yaml, toml, markdown, go, sh.


GrepOutputMode

#[non_exhaustive]

VariantDescription
ContentReturn matching lines with context. Default.
FilesWithMatchesReturn only file paths that contain a match.
CountReturn match counts per file (via GrepMatch::line_number).

Approval — synwire_core::vfs::approval


ApprovalRequest

#![allow(unused)]
fn main() {
pub struct ApprovalRequest {
    pub operation: String,
    pub description: String,
    pub risk: RiskLevel,
    pub timeout_secs: Option<u64>,
    pub context: Value,
}
}

ApprovalDecision

#[non_exhaustive]

VariantDescription
AllowPermit this invocation.
DenyDeny this invocation.
AllowAlwaysPermit this and all future invocations of the same operation.
AbortAbort the entire agent run.
AllowModified { modified_context }Permit with substituted context.

RiskLevel

Ordered (PartialOrd) risk classification. #[non_exhaustive]

VariantDescription
NoneNo meaningful risk (read-only).
LowReversible writes.
MediumFile deletions, overwrites.
HighSystem changes, process spawning.
CriticalIrreversible or destructive.

AutoApprove / AutoDeny Callbacks

TypeBehaviour
AutoApproveCallbackAlways returns ApprovalDecision::Allow.
AutoDenyCallbackAlways returns ApprovalDecision::Deny.

Both implement ApprovalCallback + Clone + Default + Debug.


MemoryProvider

Ephemeral in-memory implementation of Vfs. All data lives for the lifetime of the backend instance. Suitable for agent scratchpads and test fixtures.

Supports: LS, READ, WRITE, EDIT, GREP, GLOB, PWD, CD, RM, CP, MV.

ConstructorDescription
new()Create an empty backend with / as the working directory.

MCP Types — synwire_core::mcp


McpServerConfig

Connection configuration for an MCP server. #[non_exhaustive]

VariantKey fieldsDescription
Stdiocommand, args, envLaunch a subprocess and communicate over stdin/stdout.
Httpurl, auth_token, timeout_secsConnect to an HTTP MCP server.
Sseurl, auth_token, timeout_secsConnect via Server-Sent Events transport.
InProcessnameIn-process server backed by registered tool definitions.

Method: transport_kind() -> &'static str — returns "stdio", "http", "sse", or "in-process".


McpServerStatus

#![allow(unused)]
fn main() {
pub struct McpServerStatus {
    pub name: String,
    pub state: McpConnectionState,
    pub calls_succeeded: u64,
    pub calls_failed: u64,
    pub enabled: bool,
}
}

McpToolDescriptor

#![allow(unused)]
fn main() {
pub struct McpToolDescriptor {
    pub name: String,
    pub description: String,
    pub input_schema: Value,   // JSON Schema
}
}

McpConnectionState

#[non_exhaustive]

VariantDescription
DisconnectedNot yet connected. Default.
ConnectingConnection attempt in progress.
ConnectedReady to accept tool calls.
ReconnectingReconnection in progress after a drop.
ShutdownServer has been shut down.

ElicitationRequest

#![allow(unused)]
fn main() {
pub struct ElicitationRequest {
    pub request_id: String,
    pub message: String,
    pub response_schema: Value,   // JSON Schema for the expected response
    pub required: bool,
}
}

ElicitationResult

#[non_exhaustive]

VariantFieldsDescription
Providedrequest_id: String, value: ValueUser provided a valid response.
Cancelledrequest_id: StringUser cancelled without providing a response.

CancelAllElicitations

Default OnElicitation implementation. Cancels every request without prompting. Implements Default + Debug.