bamboo_plugin/lib.rs
1//! Foundation for Bamboo's local plugin system.
2//!
3//! A **plugin** is a locally-installed bundle that can provide any of:
4//! skills, MCP servers, prompt presets, workflows, supervised services, and
5//! declarative ToolEvent sinks. It is
6//! installed to `~/.bamboo/plugins/<id>/` (see
7//! `bamboo_config::paths::plugin_dir`), keeping the plugin's own files
8//! together (manifest, skills, prompts, workflows, optional per-platform
9//! binaries), then REGISTERED into Bamboo's existing capability locations:
10//!
11//! | Capability | Registered into | Discovery model |
12//! |---|---|---|
13//! | MCP servers | `config.json` (`Config.mcp`) + `mcp_manager.start_server` | copied into shared config |
14//! | Skills | N/A — discovered **in place** | `~/.bamboo/plugins/*/skills` is an additional `SkillDiscoveryDir` (see `bamboo-skills`) |
15//! | Prompt presets | `prompt-presets.json` | copied into shared store |
16//! | Legacy workflows | N/A — discovered **in place** | `~/.bamboo/plugins/*/workflows/*.md` is a read-only Skill adapter source |
17//! | Services | `ServiceManager` | supervised process owned by exact plugin provenance |
18//! | Event sinks | `installed.json` + pure reconciliation plan | `bamboo-server` activates the plan through its AppState-owned `ToolEventRouter` |
19//!
20//! This crate defines the shared skeleton three things build on:
21//!
22//! 1. [`manifest::PluginManifest`] — the `plugin.json` schema, with
23//! validation and the `${plugin_dir}`/`${platform_bin}` token-substitution
24//! contract for MCP stdio commands (see the `manifest` module docs for the
25//! full contract).
26//! 2. [`registry::InstalledPlugins`] — the `~/.bamboo/plugins/installed.json`
27//! provenance registry (load/save/add/remove), recording exactly what each
28//! plugin registered so uninstall/upgrade is precise.
29//! 3. [`installer::PluginInstaller`] — the trait later agents implement to
30//! actually wire capability registration (that wiring needs `AppState`,
31//! which this `infra`-layer crate intentionally does not depend on).
32//!
33//! See the repo-root `PLUGIN_PLAN.md` (temporary, deleted before final merge)
34//! for how the remaining work is split across parallel agents, and
35//! `examples/hello-plugin/` for a minimal end-to-end reference plugin
36//! (one skill + one prompt preset, no binary, no MCP server).
37
38pub mod error;
39pub mod installer;
40pub mod manifest;
41pub mod registry;
42
43pub use bamboo_plugin_protocol::ToolEventSubscriptionId;
44pub use error::{PluginError, PluginResult};
45pub use installer::{
46 load_previous_for_disposition, on_disk_skill_dirs, preflight_install, InstallDisposition,
47 LocalPluginInstaller, PluginInstaller,
48};
49pub use manifest::{
50 platform_bin_path, EventSinkCapabilityState, EventSinkDeliveryLimits, EventSinkInactiveReason,
51 EventSinkManifestEntry, EventSinkProtocolManifest, EventSinkSubscriptionManifest,
52 GracefulShutdown, HealthCheckKind, HealthCheckSpec, McpServerManifestEntry,
53 McpTransportManifest, ObservationPermissionId, Platform, PluginArtifact, PluginManifest,
54 PluginPromptPreset, PluginProvides, ResolvedServiceEntry, ServiceInputProtocol,
55 ServiceManifestEntry, ShutdownSignal, DEFAULT_EVENT_SINK_QUEUE_CAPACITY,
56 MAX_EVENT_SINKS_PER_PLUGIN, MAX_EVENT_SINK_EVENT_BYTES, MAX_EVENT_SINK_EXTENSION_FIELDS,
57 MAX_EVENT_SINK_EXTENSION_KEY_BYTES, MAX_EVENT_SINK_EXTENSION_VALUE_BYTES,
58 MAX_EVENT_SINK_ID_BYTES, MAX_EVENT_SINK_MANIFEST_BUFFER_BYTES, MAX_EVENT_SINK_PERMISSIONS,
59 MAX_EVENT_SINK_PERMISSION_ID_BYTES, MAX_EVENT_SINK_QUEUE_CAPACITY,
60 MAX_EVENT_SINK_SERVICE_ID_BYTES, MAX_EVENT_SINK_SUBSCRIPTIONS, MAX_EVENT_SINK_TOOL_NAMES,
61 OBSERVE_CONTENT_PERMISSION, OBSERVE_DIFF_PERMISSION, OBSERVE_METADATA_PERMISSION,
62 OBSERVE_PATHS_PERMISSION, OBSERVE_TOOL_NAME_PERMISSION, PLATFORM_BIN_TOKEN,
63};
64pub use registry::{
65 classify_ownership, reconcile_event_sinks, reconcile_exclusive, reconcile_plugin_boot,
66 EventSinkPermissionGrants, EventSinkReconciliation, EventSinkRemovalOrder,
67 ExclusiveReconciliation, InstalledPlugin, InstalledPlugins, Ownership, PluginBootCandidate,
68 PluginBootIssue, PluginBootReconciliation, PluginInstallStatus, PluginSource,
69 ReconciledEventSink, RegisteredCapabilities,
70};