graphrt_plugin/lib.rs
1//! # graphrt-plugin
2//!
3//! Plug-and-play extensions for graphrt. A plugin is a directory with a
4//! `graphrt-plugin.json` (or `.yaml`) manifest that adds node kinds and tools,
5//! implemented by:
6//!
7//! - **process**: an executable in any language speaking newline-delimited
8//! JSON-RPC 2.0 over stdio (started lazily, restarted after crashes);
9//! - **http**: a remote service receiving JSON-RPC over `POST`;
10//! - **wasm** (or any custom runtime): a [`PluginLoader`] registered on the host.
11//!
12//! ```no_run
13//! # async fn demo() -> Result<(), graphrt_plugin::PluginError> {
14//! use graphrt_core::{Registry, tool::ToolRegistry};
15//! use graphrt_plugin::{PluginHost, default_plugin_paths};
16//!
17//! let mut host = PluginHost::new();
18//! host.load_dirs(&default_plugin_paths())?;
19//! let mut registry = Registry::with_builtins();
20//! let mut tools = ToolRegistry::new();
21//! host.register(&mut registry, &mut tools)?;
22//! # Ok(()) }
23//! ```
24//!
25//! The protocol and manifest format are specified in `docs/plugins.md`.
26
27mod conn;
28mod discover;
29mod error;
30mod host;
31#[cfg(feature = "http")]
32mod http;
33mod manifest;
34mod node;
35#[cfg(feature = "process")]
36mod process;
37mod protocol;
38mod render;
39mod transport;
40
41pub use conn::{Connection, NotifySink};
42pub use discover::{
43 PLUGIN_PATH_ENV, default_install_dir, default_plugin_paths, discover, install_from_dir, sha256_file,
44 verify_checksums,
45};
46#[cfg(feature = "git")]
47pub use discover::{install_from_git, install_from_git_subdir};
48pub use error::{CallError, PluginError};
49pub use host::{LoadedPlugin, PluginHost, PluginInfo, PluginLoader};
50#[cfg(feature = "http")]
51pub use http::HttpTransport;
52pub use manifest::{
53 HttpRuntime, Limits, LoadedManifest, MANIFEST_FILES, PROTOCOL_VERSION, Permissions, PluginManifest, ProcessRuntime,
54 Runtime, WasmRuntime, is_valid_name, manifest_in,
55};
56#[cfg(feature = "process")]
57pub use process::{DEFAULT_PASS_ENV, MAX_CONSECUTIVE_TIMEOUTS, ProcessTransport};
58pub use protocol::Notification;
59pub use render::{collect_selectors, render_config};
60pub use transport::{IoTransport, Transport};