Skip to main content

MultiToolPlugin

Trait MultiToolPlugin 

Source
pub trait MultiToolPlugin: Send + Sync {
    // Required methods
    fn plugin_info(&self) -> PluginInfo;
    fn create_tools(&self) -> Vec<Box<dyn Tool>>;
}
Expand description

A plugin that provides multiple tools from a single shared library.

This is the primary interface between a plugin and the Cortex runtime. Implement this trait and use export_plugin! to generate the FFI entry point.

§Requirements

  • The implementing type must also implement Default (required by export_plugin! for construction via FFI).
  • The type must be Send + Sync because the runtime may access it from multiple threads.

§Example

use cortex_sdk::prelude::*;

#[derive(Default)]
struct MyPlugin;

impl MultiToolPlugin for MyPlugin {
    fn plugin_info(&self) -> PluginInfo {
        PluginInfo {
            name: "my-plugin".into(),
            version: "0.1.0".into(),
            description: "Example plugin".into(),
        }
    }

    fn create_tools(&self) -> Vec<Box<dyn Tool>> {
        vec![]
    }
}

cortex_sdk::export_plugin!(MyPlugin);

Required Methods§

Source

fn plugin_info(&self) -> PluginInfo

Return plugin metadata.

Source

fn create_tools(&self) -> Vec<Box<dyn Tool>>

Create all tools this plugin provides.

Called once at daemon startup. Returned tools live for the daemon’s lifetime. Each tool is registered by name into the global tool registry.

Implementors§