Skip to main content

Crate mofa_sdk

Crate mofa_sdk 

Source
Expand description

MoFA API - Standard SDK for MoFA framework

This crate provides a standardized API for the MoFA (Model-based Framework for Agents) framework.

§Architecture Layers

The SDK is organized into clear layers following microkernel architecture principles:

┌─────────────────────────────────────────┐
│            User Code                    │
└─────────────────┬───────────────────────┘
                  ↓
┌─────────────────────────────────────────┐
│     SDK (Standard API Surface)          │
│  - kernel: Core abstractions            │
│  - runtime: Lifecycle management        │
│  - foundation: Business functionality   │
└─────────────────┬───────────────────────┘

§Features

  • dora - Enable dora-rs runtime support for distributed dataflow

For FFI bindings (Python, Kotlin, Swift, Java), use the mofa-ffi crate.

§Quick Start

mofa-sdk = "0.1"
use mofa_sdk::kernel::{AgentInput, MoFAAgent};
use mofa_sdk::runtime::run_agents;

struct MyAgent;

#[async_trait::async_trait]
impl MoFAAgent for MyAgent {
    // implementation...
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let outputs = run_agents(MyAgent, vec![AgentInput::text("Hello")]).await?;
    println!("{}", outputs[0].to_text());
    Ok(())
}

Modules§

agent
Agent building blocks and concrete implementations (foundation layer)
collaboration
自适应协作协议模块
config
Global configuration facade (kernel + runtime + foundation)
coordination
Coordination strategies and schedulers (foundation layer)
foundation
Business functionality and concrete implementations
kernel
Core agent abstractions and extensions
llm
LLM (Large Language Model) integration module
messaging
Generic message bus framework for decoupled agent architectures
persistence
plugins
prelude
Commonly used types for quick start
prompt
Prompt templates, registries, and composition utilities
react
ReAct (Reasoning + Acting) 框架
rhai
runtime
Agent lifecycle and execution management
secretary
秘书Agent模式 - 基于事件循环的智能助手
skills
Agent Skills 管理 API
workflow
Workflow orchestration module with LangGraph-inspired StateGraph API

Functions§

anthropic_from_env
从环境变量创建 Anthropic 提供器
gemini_from_env
从环境变量创建 Google Gemini 提供器