Expand description
§graphrt-plugin
Plug-and-play extensions for graphrt. A plugin is a directory with a
graphrt-plugin.json (or .yaml) manifest that adds node kinds and tools,
implemented by:
- process: an executable in any language speaking newline-delimited JSON-RPC 2.0 over stdio (started lazily, restarted after crashes);
- http: a remote service receiving JSON-RPC over
POST; - wasm (or any custom runtime): a
PluginLoaderregistered on the host.
use graphrt_core::{Registry, tool::ToolRegistry};
use graphrt_plugin::{PluginHost, default_plugin_paths};
let mut host = PluginHost::new();
host.load_dirs(&default_plugin_paths())?;
let mut registry = Registry::with_builtins();
let mut tools = ToolRegistry::new();
host.register(&mut registry, &mut tools)?;The protocol and manifest format are specified in docs/plugins.md.
Structs§
- Connection
- A live connection to a plugin.
- Http
Runtime runtime: httpsettings.- Http
Transport - A plugin served over HTTP.
- IoTransport
- A transport over an already-connected byte stream, e.g. an in-process plugin or a socket. The connection is initialized on first use.
- Limits
- Resource limits for plugin requests.
- Loaded
Manifest - A manifest together with the directory it was loaded from.
- Loaded
Plugin - What a
PluginLoaderproduces for one plugin. - Notification
- Notification forwarded from a plugin while a request is in flight.
- Permissions
- What the plugin may access.
- Plugin
Host - Loads plugins and registers them into a
RegistryandToolRegistry. - Plugin
Info - Summary of a loaded plugin (for
plugin liststyle output). - Plugin
Manifest - A parsed and validated plugin manifest.
- Process
Runtime runtime: processsettings.- Process
Transport - Supervises one plugin process.
- Wasm
Runtime runtime: wasmsettings.
Enums§
- Call
Error - Failure of one protocol call.
- Plugin
Error - Error loading, installing or registering plugins.
- Runtime
- How the plugin is executed.
Constants§
- DEFAULT_
PASS_ ENV - Host variables always passed to plugin processes.
- MANIFEST_
FILES - Manifest file names, in lookup order.
- MAX_
CONSECUTIVE_ TIMEOUTS - Consecutive request timeouts after which a plugin process is considered wedged and is killed; the next request starts a fresh process.
- PLUGIN_
PATH_ ENV - Environment variable listing extra plugin directories.
- PROTOCOL_
VERSION - Protocol version spoken by this host.
Traits§
- Plugin
Loader - Executes plugins of a custom runtime (e.g.
wasm). - Transport
- A channel to one plugin.
Functions§
- collect_
selectors - Every selector referenced by
config. - default_
install_ dir ~/.graphrt/plugins, if a home directory is known.- default_
plugin_ paths - Default plugin search paths:
$GRAPHRT_PLUGIN_PATHentries, then~/.graphrt/plugins. - discover
- Find plugin manifests under
paths. A path that is itself a plugin directory is returned directly; otherwise its direct subdirectories are scanned. Missing paths are skipped. Results are sorted for determinism. - install_
from_ dir - Copy the plugin in
srcinto<dest_root>/<name>(replacing an existing copy) and return the installed manifest. - install_
from_ git - Clone a git repository (optionally at
rev, a branch or tag) and install the plugin at its root. Requires thegitexecutable. - install_
from_ git_ subdir - Clone a git repository (optionally at
rev, a branch or tag) and install the plugin in its subdirectorysubdir(for examplewhatsapp-apiin a monorepo with one plugin per directory). Requires thegitexecutable. - is_
valid_ name - Valid plugin names:
[a-z0-9_-]{1,64}. - manifest_
in - The manifest file inside
dir, if any. - render_
config - Render
configagainstpool. Secrets are masked unlessexpose_secrets. - sha256_
file - Lowercase hex SHA-256 of a file, read in chunks (no whole-file buffer).
- verify_
checksums - Verify every
checksumsentry of a manifest.
Type Aliases§
- Notify
Sink - Receives notifications for one in-flight request.