chasm_cli/integrations/
mod.rs1#![allow(dead_code, unused_imports)]
20pub 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#[derive(Debug, Clone, Serialize, Deserialize)]
39pub struct Capability {
40 pub id: String,
42 pub name: String,
44 pub description: String,
46 pub permissions: Vec<String>,
48 pub parameters: Vec<Parameter>,
50 pub requires_confirmation: bool,
52}
53
54#[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#[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#[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#[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#[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#[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}