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.
- Plugin
Error - 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.runrequest. - RunResult
- Successful node result.
- Tool
Call - A
tool.callrequest. - Tool
Result - 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.