Skip to main content

Crate graphrt_plugin_sdk

Crate graphrt_plugin_sdk 

Source
Expand description

§graphrt-plugin-sdk

Write graphrt plugins in Rust. A plugin is a small executable that serves node kinds (and optionally tools) over the graphrt plugin protocol (newline-delimited JSON-RPC 2.0 on stdin/stdout).

use graphrt_plugin_sdk::{Plugin, RunResult};

#[tokio::main(flavor = "current_thread")]
async fn main() -> std::io::Result<()> {
    Plugin::new("acme")
        .node("acme.len", |ctx, req| async move {
            let text = req.config["text"].as_str().unwrap_or_default().to_owned();
            ctx.chunk("log", "counting...");
            Ok(RunResult::new().output("length", text.chars().count()))
        })
        .serve_stdio()
        .await
}

Pair the executable with a graphrt-plugin.json manifest (see the graphrt plugin documentation). Never print to stdout yourself: it carries the protocol. Use RunCtx::log or stderr instead.

Structs§

Plugin
A plugin: a set of node kinds and tools.
PluginError
An error reported to the host.
Resume
Resume data for a node that paused.
RunCtx
Per-request context: streaming, progress, logs and cancellation.
RunRequest
A node.run request.
RunResult
Successful node result.
ToolCall
A tool.call request.
ToolResult
A tool result.

Enums§

Outcome
What a node handler returns.

Constants§

MAX_MESSAGE_BYTES
Largest accepted incoming message.
PROTOCOL_VERSION
Protocol version implemented by this SDK.