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
| Module | Description |
|---|---|
autoreply | Auto-reply rule and trigger types |
channel | ChannelId, ChannelKind, channel metadata |
config | AppConfig, provider/channel/gateway configuration structs |
cron | CronTask, CronSchedule, task status types |
error | Shared error enums (StorageError, ProviderError, ChannelError) |
media | MediaType, MediaPayload, attachment metadata |
message | Message, Role, MessageId, token usage |
plugin | PluginManifest, PluginCapability, sandbox types |
protocol | Wire protocol types for WebSocket and RPC |
security | AclRule, Identity, Permission, security policy types |
session | Session, 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.