Skip to main content

idlewarden_plugin_api/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2//! The IdleWarden plugin contract.
3//!
4//! This crate is the **only** stable surface a plugin depends on, and it is
5//! licensed Apache-2.0 (the rest of IdleWarden is MPL-2.0) so that anyone can
6//! build plugins under any license they like. See `docs/adr/0010-*.md`.
7//!
8//! The contract is **data**, not Rust symbols: a plugin is described by a
9//! [`PluginManifest`] and speaks in [`Observation`]s and [`Intent`]s. The Core
10//! never loads third-party native code into its own process (ADR-0001), so the
11//! types here are all serialisable.
12
13pub mod action;
14pub mod capability;
15pub mod manifest;
16pub mod observation;
17pub mod value;
18
19pub use action::{ActionOutcome, InputCommand, Intent, Key, MouseButton, Point};
20pub use capability::{Capability, TrustLevel};
21pub use manifest::{
22    ApiVersion, GameMatcher, PluginId, PluginManifest, SignalDecl, SignalId, API_VERSION,
23};
24pub use observation::{Confidence, Observation, Signal};
25pub use value::Value;
26
27/// Errors that cross the plugin boundary.
28#[derive(Debug, thiserror::Error)]
29pub enum PluginError {
30    #[error("plugin targets API version {found}, host supports {supported}")]
31    IncompatibleApi { found: String, supported: String },
32    #[error("manifest is invalid: {0}")]
33    InvalidManifest(String),
34    #[error("capability `{0}` was not granted to this plugin")]
35    CapabilityDenied(String),
36    #[error("observation failed: {0}")]
37    Observe(String),
38    #[error("action failed: {0}")]
39    Act(String),
40}