Skip to main content

clawdesk-types

Foundational type definitions shared across the entire ClawDesk workspace. This crate sits at the bottom of the dependency graph — every other crate depends on it. It defines the canonical representations for messages, sessions, channels, errors, and configuration without imposing any runtime behavior.

Dependencies

Internal: None (leaf crate)

External: serde, chrono, uuid, thiserror

Modules

ModuleDescription
autoreplyAuto-reply rule and trigger types
channelChannelId, ChannelKind, channel metadata
configAppConfig, provider/channel/gateway configuration structs
cronCronTask, CronSchedule, task status types
errorShared error enums (StorageError, ProviderError, ChannelError)
mediaMediaType, MediaPayload, attachment metadata
messageMessage, Role, MessageId, token usage
pluginPluginManifest, PluginCapability, sandbox types
protocolWire protocol types for WebSocket and RPC
securityAclRule, Identity, Permission, security policy types
sessionSession, SessionId, session metadata

Key Types

/// Unique session identifier
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
pub struct SessionId(String);

/// A chat message in a conversation
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Message {
pub id: MessageId,
pub role: Role,
pub content: String,
pub timestamp: chrono::DateTime<chrono::Utc>,
pub model: Option<String>,
pub tokens: Option<TokenUsage>,
pub metadata: HashMap<String, serde_json::Value>,
}

/// Speaker role
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
pub enum Role {
System,
User,
Assistant,
Tool,
}

/// Channel identifier
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
pub struct ChannelId(String);

/// Application configuration root
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AppConfig {
pub gateway: GatewayConfig,
pub providers: ProvidersConfig,
pub channels: ChannelsConfig,
pub storage: StorageConfig,
pub security: SecurityConfig,
pub fallback: FallbackConfig,
}

Example Usage

use clawdesk_types::{Message, Role, SessionId, ChannelId};

let session_id = SessionId::new();
let channel = ChannelId::from("telegram");

let msg = Message {
id: MessageId::new(),
role: Role::User,
content: "Hello, ClawDesk!".into(),
timestamp: chrono::Utc::now(),
model: None,
tokens: None,
metadata: Default::default(),
};
info

All types in this crate derive Serialize and Deserialize for JSON/TOML serialization, and Clone + Debug for ergonomic use across async boundaries.