chasm_cli/integrations/
mod.rs

1// Copyright (c) 2024-2026 Nervosys LLC
2// SPDX-License-Identifier: Apache-2.0
3//! Life Integrations Module
4//!
5//! Comprehensive hooks for AI agents to interact with daily life applications.
6//! Makes ChatSystemManager the home for AI power users.
7//!
8//! ## Categories
9//!
10//! - **Productivity**: Calendar, Email, Notes, Tasks, Documents
11//! - **Communication**: Slack, Discord, Teams, Telegram, SMS
12//! - **Browser**: Chrome, Arc, Firefox, web automation
13//! - **Development**: GitHub, GitLab, Terminal, Docker
14//! - **Smart Home**: Home Assistant, HomeKit, IoT
15//! - **Finance**: Banking, Crypto, Trading
16//! - **Health**: Apple Health, Fitness trackers
17//! - **Media**: Spotify, YouTube, Podcasts
18
19#![allow(dead_code, unused_imports)]
20//! - **Travel**: Maps, Uber, Flights
21//! - **Shopping**: Amazon, Groceries
22
23pub mod browser;
24pub mod communication;
25pub mod hooks;
26pub mod productivity;
27pub mod registry;
28pub mod smart_home;
29pub mod system;
30
31pub use hooks::{Hook, HookAction, HookConfig, HookResult, HookTrigger};
32pub use registry::{Integration, IntegrationCategory, IntegrationRegistry, IntegrationStatus};
33
34use serde::{Deserialize, Serialize};
35use std::collections::HashMap;
36
37/// Integration capability that an app provides
38#[derive(Debug, Clone, Serialize, Deserialize)]
39pub struct Capability {
40    /// Capability identifier
41    pub id: String,
42    /// Human-readable name
43    pub name: String,
44    /// Description of what this capability does
45    pub description: String,
46    /// Required permissions
47    pub permissions: Vec<String>,
48    /// Input parameters
49    pub parameters: Vec<Parameter>,
50    /// Whether this capability requires user confirmation
51    pub requires_confirmation: bool,
52}
53
54/// Parameter for a capability
55#[derive(Debug, Clone, Serialize, Deserialize)]
56pub struct Parameter {
57    pub name: String,
58    pub description: String,
59    pub param_type: ParameterType,
60    pub required: bool,
61    pub default: Option<serde_json::Value>,
62}
63
64/// Parameter types
65#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(rename_all = "snake_case")]
67pub enum ParameterType {
68    String,
69    Number,
70    Boolean,
71    Date,
72    DateTime,
73    Duration,
74    Email,
75    Url,
76    FilePath,
77    Json,
78    Array(Box<ParameterType>),
79    Object(HashMap<String, ParameterType>),
80}
81
82/// Result of executing an integration action
83#[derive(Debug, Clone, Serialize, Deserialize)]
84pub struct IntegrationResult {
85    pub success: bool,
86    pub data: Option<serde_json::Value>,
87    pub error: Option<String>,
88    pub metadata: HashMap<String, serde_json::Value>,
89}
90
91impl IntegrationResult {
92    pub fn ok(data: serde_json::Value) -> Self {
93        Self {
94            success: true,
95            data: Some(data),
96            error: None,
97            metadata: HashMap::new(),
98        }
99    }
100
101    pub fn err(error: impl Into<String>) -> Self {
102        Self {
103            success: false,
104            data: None,
105            error: Some(error.into()),
106            metadata: HashMap::new(),
107        }
108    }
109}
110
111/// OAuth configuration for integrations requiring authentication
112#[derive(Debug, Clone, Serialize, Deserialize)]
113pub struct OAuthConfig {
114    pub client_id: String,
115    pub client_secret: Option<String>,
116    pub auth_url: String,
117    pub token_url: String,
118    pub scopes: Vec<String>,
119    pub redirect_uri: String,
120}
121
122/// API key configuration
123#[derive(Debug, Clone, Serialize, Deserialize)]
124pub struct ApiKeyConfig {
125    pub key: String,
126    pub header_name: Option<String>,
127    pub prefix: Option<String>,
128}
129
130/// Authentication method for integrations
131#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(tag = "type", rename_all = "snake_case")]
133pub enum AuthMethod {
134    None,
135    ApiKey(ApiKeyConfig),
136    OAuth2(OAuthConfig),
137    Bearer { token: String },
138    Basic { username: String, password: String },
139    Custom { headers: HashMap<String, String> },
140}