Skip to main content

Module engine

Module engine 

Source
Expand description

Engine construction and top-level execution APIs.

Engine is the runtime boundary for a group of agents, tools, model providers, storage backends, hooks, and remote engines. It is responsible for:

  • validating callers and request metadata;
  • creating scoped AgentCtx and BaseCtx values;
  • dispatching local agent runs and direct tool calls;
  • exporting selected agents and tools to other engines;
  • signing challenge responses when Web3 or TEE clients are configured.

Engines are created with EngineBuilder. A built engine is private by default; configure Management to expose it to additional callers.

§Usage

  1. Start from Engine::builder.
  2. Register models, tools, agents, hooks, storage, and remote engines.
  3. Select the default agent with EngineBuilder::build.
  4. Execute agents with Engine::agent_run or direct tools with Engine::tool_call.

§Example

use anda_core::AgentInput;
use anda_engine::{
    ANONYMOUS,
    engine::{AgentInfo, EchoEngineInfo, Engine},
};
use std::sync::Arc;

let echo_info = AgentInfo {
    handle: "echo".to_string(),
    name: "Echo Agent".to_string(),
    description: "Returns engine metadata as JSON.".to_string(),
    ..Default::default()
};

let engine = Engine::builder()
    .register_agent(Arc::new(EchoEngineInfo::new(echo_info)), None)?
    .build("echo".to_string())
    .await?;

let output = engine
    .agent_run(
        ANONYMOUS,
        AgentInput::new("echo".to_string(), "hello".to_string()),
    )
    .await?;

Re-exports§

pub use crate::context::EngineCard;
pub use crate::context::RemoteEngineArgs;
pub use crate::context::RemoteEngines;

Structs§

AgentInfo
Contains descriptive and operational information about an AI agent.
EchoEngineInfo
Simple built-in agent that returns its configured AgentInfo as JSON.
Engine
Top-level runtime for a configured set of Anda agents and tools.
EngineBuilder
Builder for assembling an Engine.
EngineRef
EngineRef is a helper struct that allows for late binding of an Engine instance.