Skip to main content

claude_pool_server/
lib.rs

1//! Library interface for claude-pool-server.
2//!
3//! Exposes [`State`] and the tool/resource builders so that integration tests
4//! (and downstream embedders) can construct a router without going through the
5//! binary entry point.
6
7pub mod prompts;
8pub mod resources;
9pub mod tools;
10
11pub mod auth;
12
13use std::path::PathBuf;
14use std::sync::Arc;
15
16use claude_pool::{Pool, PoolStore, SkillRegistry, WorkflowRegistry};
17use serde::Serialize;
18use tokio::sync::RwLock;
19
20/// Server version and metadata information.
21#[derive(Debug, Clone, Serialize)]
22pub struct ServerInfo {
23    /// Server version from Cargo.toml.
24    pub version: String,
25    /// Git commit hash (short form).
26    pub commit: String,
27    /// Default model for slots.
28    pub model: Option<String>,
29    /// Permission mode for slots.
30    pub permission_mode: String,
31    /// Total number of slots.
32    pub slots: usize,
33}
34
35impl ServerInfo {
36    /// Create a new ServerInfo instance.
37    pub fn new(model: Option<String>, permission_mode: String, slots: usize) -> Self {
38        Self {
39            version: env!("CARGO_PKG_VERSION").to_string(),
40            commit: env!("GIT_HASH").to_string(),
41            model,
42            permission_mode,
43            slots,
44        }
45    }
46}
47
48/// Shared state accessible by all tool/resource handlers.
49pub struct State<S: PoolStore> {
50    /// The pool instance.
51    pub pool: Pool<S>,
52    /// Thread-safe skill registry (mutated by skill management tools).
53    pub skills: Arc<RwLock<SkillRegistry>>,
54    /// Workflow registry.
55    pub workflows: WorkflowRegistry,
56    /// Directory for persisting project-local skills.
57    pub skills_dir: PathBuf,
58    /// Server metadata.
59    pub server_info: ServerInfo,
60}