MoFA SDK
MoFA (Modular Framework for Agents) SDK - A standard development toolkit for building AI agents with Rust.
Architecture
mofa-sdk (标准 API 层 - SDK)
↓
├── mofa-kernel (微内核核心)
├── mofa-runtime (运行时)
├── mofa-foundation (业务逻辑)
└── mofa-plugins (插件系统)
Public Modules
kernel: core abstractions frommofa-kernelruntime: lifecycle and execution runtimeagent: foundation agent building blocksllm: LLM integration and helpersplugins: plugin system and adaptersworkflow: workflow engine and DSLpersistence: persistence stores and pluginsmessaging: message bus and contractssecretary: secretary agent patterncollaboration: multi-agent collaboration protocolscoordination: scheduling and coordination utilitiesprompt: prompt templates and compositionconfig: global config facade (kernel/runtime/foundation)skills: progressive disclosure skills systemprelude: common imports for quick start
Installation
Add this to your Cargo.toml:
[]
= "0.1"
Optional Features
# With dora-rs runtime support (distributed dataflow)
= { = "0.1", = ["dora"] }
# With persistence support (database backends)
= { = "0.1", = ["persistence-sqlite"] }
= { = "0.1", = ["persistence-postgres"] }
# With monitoring support
= { = "0.1", = ["monitoring"] }
# For cross-language bindings (Python, Kotlin, Swift, Java, Go)
# Use mofa-ffi instead - see below
Quick Start
Basic Agent
use ;
use run_agents;
use async_trait;
async
Batch Execution
use AgentInput;
use run_agents;
async
LLM Agent (Recommended)
Use the built-in LLMAgent for quick LLM interactions:
use LLMAgentBuilder;
async
Load Agent from Configuration File
use agent_from_config;
async
With Dora Runtime
use ;
async
Cross-Language Bindings
For Python, Kotlin, Swift, Java, and Go bindings, use the mofa-ffi crate:
[]
= { = "0.1", = ["uniffi"] }
See mofa-ffi/README.md for detailed usage instructions.
Features
| Feature | Description |
|---|---|
dora |
Enable dora-rs runtime for distributed dataflow |
persistence-postgres |
PostgreSQL persistence backend |
persistence-mysql |
MySQL persistence backend |
persistence-sqlite |
SQLite persistence backend |
monitoring |
Enable monitoring and observability |
kokoro |
Enable Kokoro TTS support |
Configuration File Format (agent.yml)
agent:
id: "my-agent-001"
name: "My LLM Agent"
description: "A helpful assistant"
llm:
provider: openai # openai, ollama, azure, compatible
model: gpt-4o
api_key: ${OPENAI_API_KEY} # Environment variable reference
temperature: 0.7
max_tokens: 4096
system_prompt: |
You are a helpful AI assistant.
Documentation
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.