856f865cf98d
lib.rs
//! # photocraft-automation
//!
//! Agent-facing automation (architecture §12):
//!
//! * [`PhotocraftMcp`]: an MCP server (official `rmcp` SDK) exposing session,
//! document and command tools. Headless mode drives an in-process
//! [`photocraft_engine::Session`]; bridge mode forwards to a running desktop
//! app over the JSON-lines control protocol (`docs/control-protocol.md`), so
//! agents can also inspect, screenshot and click the live UI.
//! * [`Headless`]: the synchronous session + file I/O core, shared with the CLI.
//! * [`rpc`]: a headless JSON-lines server (stdio or loopback TCP) with the
//! control protocol's envelope, used by `photocraft-cli serve`.
//! * [`files`]: open/save any supported format, `.pcraft` natively.
//! * [`agent_link`] and [`live`]: plain `photocraft-cli mcp` in the open desktop app, over the
//! framework's agents switch and connection file (`craft::automation::agents`).
//!
//! L6, no UI-toolkit dependencies.
#![forbid(unsafe_code)]
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
pub mod agent_link;
pub mod app_dirs;
pub mod args;
pub mod bridge;
pub mod budgets;
pub mod files;
pub mod headless;
pub mod live;
pub mod rpc;
pub mod security;
pub mod server;
pub mod workspace;
pub use bridge::BridgeClient;
pub use headless::Headless;
pub use server::{Backend, PhotocraftMcp};
pub use workspace::AuthorizedWorkspace;
#[cfg(all(feature = "gpu", not(target_arch = "wasm32")))]
pub mod gpu;
#[cfg(all(feature = "gpu", not(target_arch = "wasm32")))]
pub use gpu::GpuRenderer;
#[derive(Debug, thiserror::Error)]
pub enum AutomationError {
#[error("{0}")]
BadRequest(String),
#[error("I/O: {0}")]
Io(String),
#[error(transparent)]
Engine(#[from] photocraft_engine::EngineError),
#[error(transparent)]
Import(#[from] photocraft_io::IoError),
#[error(transparent)]
Format(#[from] photocraft_format::FormatError),
#[error("bridge: {0}")]
Bridge(String),
#[error("app: {0}")]
App(String),
#[error("{0}")]
Other(String),
}
/// The control channel's own errors (its token files and handshake, `craft::automation::security`).
impl From<craft::automation::AutomationError> for AutomationError {
fn from(e: craft::automation::AutomationError) -> Self {
match e {
craft::automation::AutomationError::BadRequest(m) => Self::BadRequest(m),
craft::automation::AutomationError::Io(m) => Self::Io(m),
}
}
}
No file is open. Choose one in the tree, or press Ctrl+O (⌘O on a Mac) to find one by name.
Syntax highlighting could not load. The unmodified read-only text remains available above.