| Crates.io | actflow-agent-sdk |
| lib.rs | actflow-agent-sdk |
| version | 0.1.2 |
| created_at | 2025-12-04 07:24:39.055194+00 |
| updated_at | 2025-12-09 03:22:45.249803+00 |
| description | A Rust SDK for building agents for Actflow. |
| homepage | |
| repository | https://github.com/yunis-du/actflow-agent-sdk |
| max_upload_size | |
| id | 1966093 |
| size | 42,986 |
A Rust SDK for building agents for the Actflow workflow engine.
Add to your Cargo.toml:
[dependencies]
actflow-agent-sdk = "0.1.1"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
serde_json = "1"
use actflow_agent_sdk::{Agent, AgentServer, AgentOutput, Inputs, LogSender};
struct MyAgent;
impl Agent for MyAgent {
async fn run(
&self,
pid: String,
nid: String,
inputs: Inputs,
log: LogSender,
) -> AgentOutput {
log.send("Starting agent...").await;
// Your agent logic here
AgentOutput::success(serde_json::json!({"result": "done"}))
}
}
#[tokio::main]
async fn main() {
AgentServer::new(MyAgent)
.serve("0.0.0.0:50051")
.await
.unwrap();
}
pub trait Agent: Send + Sync + 'static {
fn run(&self, pid: String, nid: String, inputs: Inputs, log: LogSender)
-> impl Future<Output = AgentOutput> + Send;
fn shutdown(&self) -> impl Future<Output = ()> + Send { async {} }
}
| Method | Description |
|---|---|
AgentOutput::success(outputs) |
Create a successful output |
AgentOutput::failed(err) |
Create a failed output |
AgentOutput::exception(msg) |
Create an exception output |
| Status | Description |
|---|---|
Pending |
Agent is pending |
Succeeded |
Agent completed successfully |
Failed |
Agent failed with error |
Exception |
Agent encountered exception |
Stopped |
Agent was stopped |
Paused |
Agent is paused |
impl LogSender {
pub async fn send(&self, msg: impl Into<String>); // Async send
pub fn try_send(&self, msg: impl Into<String>); // Non-blocking send
}
cargo run --example simple_agent
cargo run --example calculator_agent
cargo run --example stateful_agent
MIT