agent_works/plugin/mod.rs
1//! Plugin package machinery (P2) — manifest / registry integrity / install lifecycle / loading.
2//!
3//! From the user's point of view, in one sentence: "install a plugin". After the
4//! install, a few more tools show up in the tool table; the user doesn't need to know
5//! which one is wasm and which one is python. For the mechanism's main text, see
6//! `phimint/notes/tool-socket-design.md`, sections "Shape of a plugin package /
7//! Plugin install":
8//!
9//! - **Three forms, one key scheme**: tools in the wasm / script / mcp forms share
10//! the unified identity `plugin.{plugin}.{tool}` ([crate::tool_provider]);
11//! - **Human review before install**: [`manifest::ReviewDigest`] lays out the full
12//! manifest (tools / execution summary / capabilities with concrete paths/hosts),
13//! and only after human confirmation does [`install::commit_install`] write to
14//! disk; a plugin requested for install on an agent's behalf is never allowed
15//! through by default (guaranteed at the product layer);
16//! - **Install integrity is pinned outside the plugin directory**:
17//! [`registry::PluginRegistry`] (`<plugins_root>/registry.json`) stores the manifest
18//! hash + the hash of every .wasm + pinned resolved capabilities/absolute paths.
19//! **No authoritative copy** is kept inside the plugin directory — anchor and
20//! anchored object in the same cave = self-deception. Re-verified on every load;
21//! tampering = all of that plugin's tools are disabled + "run `plugin add` again to
22//! re-review";
23//! - **Capability tightening reads the pinned values in the registry**, never the
24//! plugin's own manifest;
25//! - **Corruption does not skip the whole package**: if plugin.json lists a tool but
26//! the .wasm is missing/corrupt → that tool is disabled + an error is reported,
27//! while the other tools work as usual;
28//! - **Uninstall cleans three places**: the tool table (the provider no longer lists
29//! it) / the ledger (`plugin.{name}.*`) / the registry entry.
30//!
31//! Transport notes (explicitly documented, phased discipline): git URLs depend on
32//! the git executable (must be on PATH on Windows; gix could be embedded later);
33//! archive extraction performs a zip-slip path check (a member path that escapes the
34//! target directory is rejected).
35
36pub mod install;
37pub mod loader;
38pub mod manifest;
39pub mod registry;
40#[cfg(feature = "wasm")]
41pub mod wasm;
42
43pub use install::{
44 ArchiveFormat, InstallError, InstallPlan, InstalledPlugin, PluginSource, RemovalReport,
45 StagingLayout, commit_install, plan_install, remove_plugin,
46};
47pub use loader::{
48 DisabledTool, LoadedPlugin, McpKeyAssignment, PluginLoader, PluginMcpServer,
49 assign_mcp_tool_keys,
50};
51pub use manifest::{
52 CapabilitySpec, FsReadSpec, ManifestError, McpServerSpec, McpToolSpec, NetHttpSpec,
53 PluginManifest, PluginToolSpec, ResolvedCapability, ReviewDigest, ReviewTool, ScriptToolSpec,
54 WasmToolSpec, resolve_capabilities,
55};
56pub use registry::{
57 PackageStatus, PluginPin, PluginRegistry, RegistryError, ToolPin, ToolStatus, VerifyIssue,
58 VerifyReport,
59};