synwire-agent
The agent runtime for Synwire. Concrete implementations of all synwire-core agent traits: Runner, execution strategies, backends, middleware, MCP transports, and session management.
What this crate provides
Runner— drives the agent turn loop:AgentNode+ExecutionStrategy+ middleware + backend + sessionDirectStrategy— unconstrained execution; model decides everythingFsmStrategy/FsmStrategyBuilder— finite state machine with guards, priorities, and named transitions- 10
BackendProtocolimplementations —StateBackend,FilesystemBackend,GitBackend,HttpBackend,LocalShellBackend,ProcessBackend,ArchiveBackend,StoreBackend,PipelineExecutor,CompositeBackend - 9
Middlewaretypes —ToolInjection,SystemPrompt,RateLimit,AuditLog,Summarisation,ConversationHistory,Caching,Timeout,CircuitBreaker - MCP transports —
StdioMcpTransport,HttpMcpTransport,InProcessMcpTransport,McpLifecycleManager InMemorySessionManager— in-process session storage- Approval gates —
ThresholdGate,RiskLevel,ApprovalDecision - Signals —
Signal,SignalKind,Action,SignalRoute,ComposedRouter - Permissions —
PermissionMode,PermissionRule,PermissionBehavior
Quick start
[]
= "0.1"
= "0.1"
= { = "1", = ["full"] }
Run an agent with the direct strategy:
use Runner;
use DirectStrategy;
use StateBackend;
// Assume `my_agent` implements `AgentNode`
// let runner = Runner::builder()
// .agent(my_agent)
// .strategy(DirectStrategy::new())
// .backend(StateBackend::new())
// .build()?;
//
// let mut events = runner.run("Hello, agent!".to_string(), Default::default()).await?;
// while let Some(event) = events.next().await {
// println!("{:?}", event?);
// }
FSM strategy with two states and a guard:
use ;
// let strategy = FsmStrategyBuilder::new()
// .add_state("idle")
// .add_state("working")
// .set_initial_state("idle")
// .add_transition("idle", "working", ClosureGuard::new(|directive| {
// matches!(directive, Directive::RunInstruction { .. })
// }))
// .add_transition("working", "idle", ClosureGuard::always())
// .build()?;
Middleware stack:
use ;
// let runner = Runner::builder()
// .middleware(SystemPromptMiddleware::new("You are a helpful assistant."))
// .middleware(AuditLogMiddleware::new(std::io::stderr()))
// .build()?;
Backend selection
| Backend | Scope | Use when |
|---|---|---|
StateBackend |
Ephemeral in-memory | Sandboxed agents, tests |
FilesystemBackend |
Scoped to root path | Reading/writing files safely |
GitBackend |
Within a git repo | Version-controlled operations |
HttpBackend |
External HTTP | Calling APIs |
LocalShellBackend |
Sandboxed working dir | Shell commands with scope control |
ProcessBackend |
Any | Spawning background jobs |
ArchiveBackend |
Scoped root | tar/zip read and write |
StoreBackend |
Namespaced K-V | Persistent agent state |
CompositeBackend |
Mount table | Different backends by path prefix |