chasm_cli/integrations/
registry.rs

1// Copyright (c) 2024-2026 Nervosys LLC
2// SPDX-License-Identifier: Apache-2.0
3//! Integration Registry
4//!
5//! Central registry for all available integrations.
6
7#![allow(dead_code)]
8
9use super::{AuthMethod, Capability, IntegrationResult};
10use serde::{Deserialize, Serialize};
11use std::collections::HashMap;
12
13/// Integration category
14#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
15#[serde(rename_all = "snake_case")]
16pub enum IntegrationCategory {
17    // Productivity
18    Calendar,
19    Email,
20    Notes,
21    Tasks,
22    Documents,
23
24    // Communication
25    Chat,
26    VideoConference,
27    Social,
28    Messaging,
29
30    // Development
31    Git,
32    Ide,
33    Terminal,
34    Ci,
35    Containers,
36    Cloud,
37
38    // Browser & Web
39    Browser,
40    Automation,
41    Scraping,
42
43    // Smart Home & IoT
44    SmartHome,
45    Iot,
46    Voice,
47
48    // Media & Entertainment
49    Music,
50    Video,
51    Podcasts,
52    Reading,
53
54    // Finance
55    Banking,
56    Crypto,
57    Trading,
58    Payments,
59
60    // Health & Fitness
61    Health,
62    Fitness,
63    Sleep,
64    Nutrition,
65
66    // Travel & Transport
67    Maps,
68    RideShare,
69    Travel,
70
71    // Shopping & Commerce
72    Shopping,
73    Grocery,
74    Food,
75
76    // Utilities
77    Weather,
78    Storage,
79    Backup,
80    Security,
81
82    // System
83    System,
84    Clipboard,
85    Notifications,
86}
87
88/// Integration status
89#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
90#[serde(rename_all = "snake_case")]
91pub enum IntegrationStatus {
92    Available,
93    Connected,
94    Disconnected,
95    NeedsAuth,
96    Error,
97    Disabled,
98}
99
100/// Integration definition
101#[derive(Debug, Clone, Serialize, Deserialize)]
102pub struct Integration {
103    /// Unique identifier
104    pub id: String,
105    /// Display name
106    pub name: String,
107    /// Description
108    pub description: String,
109    /// Category
110    pub category: IntegrationCategory,
111    /// Icon (emoji or icon name)
112    pub icon: String,
113    /// Brand color
114    pub color: String,
115    /// Website URL
116    pub website: Option<String>,
117    /// Status
118    pub status: IntegrationStatus,
119    /// Available capabilities
120    pub capabilities: Vec<Capability>,
121    /// Required authentication method
122    pub auth_method: Option<AuthMethod>,
123    /// Whether this integration is a native/built-in
124    pub is_native: bool,
125    /// Platform availability
126    pub platforms: Vec<String>,
127    /// Setup instructions
128    pub setup_instructions: Option<String>,
129}
130
131/// Integration registry
132pub struct IntegrationRegistry {
133    integrations: HashMap<String, Integration>,
134}
135
136impl IntegrationRegistry {
137    pub fn new() -> Self {
138        let mut registry = Self {
139            integrations: HashMap::new(),
140        };
141        registry.register_all();
142        registry
143    }
144
145    fn register_all(&mut self) {
146        // =====================================================================
147        // Productivity - Calendar
148        // =====================================================================
149        self.register(Integration {
150            id: "google_calendar".to_string(),
151            name: "Google Calendar".to_string(),
152            description: "Manage events, meetings, and schedules".to_string(),
153            category: IntegrationCategory::Calendar,
154            icon: "".to_string(),
155            color: "#4285f4".to_string(),
156            website: Some("https://calendar.google.com".to_string()),
157            status: IntegrationStatus::Available,
158            capabilities: vec![
159                capability("list_events", "List Events", "Get upcoming calendar events"),
160                capability("create_event", "Create Event", "Create a new calendar event"),
161                capability("update_event", "Update Event", "Modify an existing event"),
162                capability("delete_event", "Delete Event", "Remove a calendar event"),
163                capability("find_free_time", "Find Free Time", "Find available time slots"),
164            ],
165            auth_method: Some(AuthMethod::OAuth2(super::OAuthConfig {
166                client_id: String::new(),
167                client_secret: None,
168                auth_url: "https://accounts.google.com/o/oauth2/auth".to_string(),
169                token_url: "https://oauth2.googleapis.com/token".to_string(),
170                scopes: vec!["https://www.googleapis.com/auth/calendar".to_string()],
171                redirect_uri: "http://localhost:8080/oauth/callback".to_string(),
172            })),
173            is_native: false,
174            platforms: vec!["all".to_string()],
175            setup_instructions: Some("1. Create OAuth credentials in Google Cloud Console\n2. Add credentials to CSM settings".to_string()),
176        });
177
178        self.register(Integration {
179            id: "outlook_calendar".to_string(),
180            name: "Outlook Calendar".to_string(),
181            description: "Microsoft 365 calendar integration".to_string(),
182            category: IntegrationCategory::Calendar,
183            icon: "".to_string(),
184            color: "#0078d4".to_string(),
185            website: Some("https://outlook.office.com/calendar".to_string()),
186            status: IntegrationStatus::Available,
187            capabilities: vec![
188                capability("list_events", "List Events", "Get upcoming calendar events"),
189                capability(
190                    "create_event",
191                    "Create Event",
192                    "Create a new calendar event",
193                ),
194                capability(
195                    "schedule_meeting",
196                    "Schedule Meeting",
197                    "Schedule a Teams meeting",
198                ),
199            ],
200            auth_method: None,
201            is_native: false,
202            platforms: vec!["all".to_string()],
203            setup_instructions: None,
204        });
205
206        self.register(Integration {
207            id: "apple_calendar".to_string(),
208            name: "Apple Calendar".to_string(),
209            description: "macOS/iOS native calendar".to_string(),
210            category: IntegrationCategory::Calendar,
211            icon: "".to_string(),
212            color: "#ff3b30".to_string(),
213            website: None,
214            status: IntegrationStatus::Available,
215            capabilities: vec![
216                capability("list_events", "List Events", "Get upcoming calendar events"),
217                capability(
218                    "create_event",
219                    "Create Event",
220                    "Create a new calendar event",
221                ),
222            ],
223            auth_method: None,
224            is_native: true,
225            platforms: vec!["macos".to_string(), "ios".to_string()],
226            setup_instructions: None,
227        });
228
229        // =====================================================================
230        // Productivity - Email
231        // =====================================================================
232        self.register(Integration {
233            id: "gmail".to_string(),
234            name: "Gmail".to_string(),
235            description: "Read, send, and organize emails".to_string(),
236            category: IntegrationCategory::Email,
237            icon: "".to_string(),
238            color: "#ea4335".to_string(),
239            website: Some("https://mail.google.com".to_string()),
240            status: IntegrationStatus::Available,
241            capabilities: vec![
242                capability("list_emails", "List Emails", "Get emails from inbox"),
243                capability("send_email", "Send Email", "Send a new email"),
244                capability("reply_email", "Reply to Email", "Reply to an email thread"),
245                capability("label_email", "Label Email", "Apply labels to emails"),
246                capability("search_emails", "Search Emails", "Search through emails"),
247            ],
248            auth_method: None,
249            is_native: false,
250            platforms: vec!["all".to_string()],
251            setup_instructions: None,
252        });
253
254        self.register(Integration {
255            id: "outlook_mail".to_string(),
256            name: "Outlook Mail".to_string(),
257            description: "Microsoft 365 email".to_string(),
258            category: IntegrationCategory::Email,
259            icon: "".to_string(),
260            color: "#0078d4".to_string(),
261            website: Some("https://outlook.office.com".to_string()),
262            status: IntegrationStatus::Available,
263            capabilities: vec![
264                capability("list_emails", "List Emails", "Get emails from inbox"),
265                capability("send_email", "Send Email", "Send a new email"),
266            ],
267            auth_method: None,
268            is_native: false,
269            platforms: vec!["all".to_string()],
270            setup_instructions: None,
271        });
272
273        // =====================================================================
274        // Productivity - Notes
275        // =====================================================================
276        self.register(Integration {
277            id: "notion".to_string(),
278            name: "Notion".to_string(),
279            description: "All-in-one workspace for notes, docs, and wikis".to_string(),
280            category: IntegrationCategory::Notes,
281            icon: "".to_string(),
282            color: "#000000".to_string(),
283            website: Some("https://notion.so".to_string()),
284            status: IntegrationStatus::Available,
285            capabilities: vec![
286                capability("create_page", "Create Page", "Create a new Notion page"),
287                capability("update_page", "Update Page", "Update page content"),
288                capability("search", "Search", "Search Notion workspace"),
289                capability(
290                    "create_database",
291                    "Create Database",
292                    "Create a new database",
293                ),
294                capability("query_database", "Query Database", "Query database entries"),
295            ],
296            auth_method: None,
297            is_native: false,
298            platforms: vec!["all".to_string()],
299            setup_instructions: None,
300        });
301
302        self.register(Integration {
303            id: "obsidian".to_string(),
304            name: "Obsidian".to_string(),
305            description: "Local-first knowledge base with markdown".to_string(),
306            category: IntegrationCategory::Notes,
307            icon: "".to_string(),
308            color: "#7c3aed".to_string(),
309            website: Some("https://obsidian.md".to_string()),
310            status: IntegrationStatus::Available,
311            capabilities: vec![
312                capability("create_note", "Create Note", "Create a new markdown note"),
313                capability("update_note", "Update Note", "Update note content"),
314                capability("search", "Search", "Search vault"),
315                capability("list_notes", "List Notes", "List notes in folder"),
316                capability("get_backlinks", "Get Backlinks", "Get note backlinks"),
317            ],
318            auth_method: None,
319            is_native: true,
320            platforms: vec!["all".to_string()],
321            setup_instructions: Some("Set vault path in CSM settings".to_string()),
322        });
323
324        self.register(Integration {
325            id: "apple_notes".to_string(),
326            name: "Apple Notes".to_string(),
327            description: "Native Apple notes app".to_string(),
328            category: IntegrationCategory::Notes,
329            icon: "".to_string(),
330            color: "#ffcc00".to_string(),
331            website: None,
332            status: IntegrationStatus::Available,
333            capabilities: vec![
334                capability("create_note", "Create Note", "Create a new note"),
335                capability("list_notes", "List Notes", "List all notes"),
336            ],
337            auth_method: None,
338            is_native: true,
339            platforms: vec!["macos".to_string(), "ios".to_string()],
340            setup_instructions: None,
341        });
342
343        // =====================================================================
344        // Productivity - Tasks
345        // =====================================================================
346        self.register(Integration {
347            id: "todoist".to_string(),
348            name: "Todoist".to_string(),
349            description: "Task management and to-do lists".to_string(),
350            category: IntegrationCategory::Tasks,
351            icon: "".to_string(),
352            color: "#e44332".to_string(),
353            website: Some("https://todoist.com".to_string()),
354            status: IntegrationStatus::Available,
355            capabilities: vec![
356                capability("list_tasks", "List Tasks", "Get tasks from projects"),
357                capability("create_task", "Create Task", "Create a new task"),
358                capability("complete_task", "Complete Task", "Mark task as complete"),
359                capability("list_projects", "List Projects", "Get all projects"),
360            ],
361            auth_method: None,
362            is_native: false,
363            platforms: vec!["all".to_string()],
364            setup_instructions: None,
365        });
366
367        self.register(Integration {
368            id: "things".to_string(),
369            name: "Things 3".to_string(),
370            description: "Beautiful task manager for Apple devices".to_string(),
371            category: IntegrationCategory::Tasks,
372            icon: "".to_string(),
373            color: "#4a90d9".to_string(),
374            website: Some("https://culturedcode.com/things".to_string()),
375            status: IntegrationStatus::Available,
376            capabilities: vec![
377                capability("create_task", "Create Task", "Create a new to-do"),
378                capability("list_today", "Today", "Get today's tasks"),
379            ],
380            auth_method: None,
381            is_native: true,
382            platforms: vec!["macos".to_string(), "ios".to_string()],
383            setup_instructions: None,
384        });
385
386        self.register(Integration {
387            id: "apple_reminders".to_string(),
388            name: "Apple Reminders".to_string(),
389            description: "Native Apple reminders".to_string(),
390            category: IntegrationCategory::Tasks,
391            icon: "".to_string(),
392            color: "#ff9500".to_string(),
393            website: None,
394            status: IntegrationStatus::Available,
395            capabilities: vec![
396                capability(
397                    "create_reminder",
398                    "Create Reminder",
399                    "Create a new reminder",
400                ),
401                capability("list_reminders", "List Reminders", "Get all reminders"),
402            ],
403            auth_method: None,
404            is_native: true,
405            platforms: vec!["macos".to_string(), "ios".to_string()],
406            setup_instructions: None,
407        });
408
409        self.register(Integration {
410            id: "linear".to_string(),
411            name: "Linear".to_string(),
412            description: "Issue tracking for modern software teams".to_string(),
413            category: IntegrationCategory::Tasks,
414            icon: "".to_string(),
415            color: "#5e6ad2".to_string(),
416            website: Some("https://linear.app".to_string()),
417            status: IntegrationStatus::Available,
418            capabilities: vec![
419                capability("create_issue", "Create Issue", "Create a new issue"),
420                capability("list_issues", "List Issues", "Get issues"),
421                capability("update_issue", "Update Issue", "Update issue status"),
422            ],
423            auth_method: None,
424            is_native: false,
425            platforms: vec!["all".to_string()],
426            setup_instructions: None,
427        });
428
429        // =====================================================================
430        // Communication - Chat
431        // =====================================================================
432        self.register(Integration {
433            id: "slack".to_string(),
434            name: "Slack".to_string(),
435            description: "Team communication and collaboration".to_string(),
436            category: IntegrationCategory::Chat,
437            icon: "".to_string(),
438            color: "#4a154b".to_string(),
439            website: Some("https://slack.com".to_string()),
440            status: IntegrationStatus::Available,
441            capabilities: vec![
442                capability(
443                    "send_message",
444                    "Send Message",
445                    "Send a message to a channel",
446                ),
447                capability("list_channels", "List Channels", "Get all channels"),
448                capability("set_status", "Set Status", "Update your status"),
449                capability("search", "Search", "Search messages"),
450                capability("upload_file", "Upload File", "Share a file"),
451            ],
452            auth_method: None,
453            is_native: false,
454            platforms: vec!["all".to_string()],
455            setup_instructions: None,
456        });
457
458        self.register(Integration {
459            id: "discord".to_string(),
460            name: "Discord".to_string(),
461            description: "Voice, video, and text communication".to_string(),
462            category: IntegrationCategory::Chat,
463            icon: "".to_string(),
464            color: "#5865f2".to_string(),
465            website: Some("https://discord.com".to_string()),
466            status: IntegrationStatus::Available,
467            capabilities: vec![
468                capability(
469                    "send_message",
470                    "Send Message",
471                    "Send a message to a channel",
472                ),
473                capability("list_servers", "List Servers", "Get all servers"),
474            ],
475            auth_method: None,
476            is_native: false,
477            platforms: vec!["all".to_string()],
478            setup_instructions: None,
479        });
480
481        self.register(Integration {
482            id: "teams".to_string(),
483            name: "Microsoft Teams".to_string(),
484            description: "Microsoft 365 collaboration".to_string(),
485            category: IntegrationCategory::Chat,
486            icon: "".to_string(),
487            color: "#6264a7".to_string(),
488            website: Some("https://teams.microsoft.com".to_string()),
489            status: IntegrationStatus::Available,
490            capabilities: vec![
491                capability(
492                    "send_message",
493                    "Send Message",
494                    "Send a message to a channel",
495                ),
496                capability(
497                    "schedule_meeting",
498                    "Schedule Meeting",
499                    "Schedule a Teams meeting",
500                ),
501            ],
502            auth_method: None,
503            is_native: false,
504            platforms: vec!["all".to_string()],
505            setup_instructions: None,
506        });
507
508        // =====================================================================
509        // Communication - Messaging
510        // =====================================================================
511        self.register(Integration {
512            id: "telegram".to_string(),
513            name: "Telegram".to_string(),
514            description: "Secure messaging".to_string(),
515            category: IntegrationCategory::Messaging,
516            icon: "".to_string(),
517            color: "#0088cc".to_string(),
518            website: Some("https://telegram.org".to_string()),
519            status: IntegrationStatus::Available,
520            capabilities: vec![
521                capability("send_message", "Send Message", "Send a message"),
522                capability("send_photo", "Send Photo", "Send an image"),
523            ],
524            auth_method: None,
525            is_native: false,
526            platforms: vec!["all".to_string()],
527            setup_instructions: None,
528        });
529
530        self.register(Integration {
531            id: "whatsapp".to_string(),
532            name: "WhatsApp".to_string(),
533            description: "Messaging and calls".to_string(),
534            category: IntegrationCategory::Messaging,
535            icon: "".to_string(),
536            color: "#25d366".to_string(),
537            website: Some("https://whatsapp.com".to_string()),
538            status: IntegrationStatus::Available,
539            capabilities: vec![capability("send_message", "Send Message", "Send a message")],
540            auth_method: None,
541            is_native: false,
542            platforms: vec!["all".to_string()],
543            setup_instructions: None,
544        });
545
546        self.register(Integration {
547            id: "imessage".to_string(),
548            name: "iMessage".to_string(),
549            description: "Apple Messages".to_string(),
550            category: IntegrationCategory::Messaging,
551            icon: "".to_string(),
552            color: "#34c759".to_string(),
553            website: None,
554            status: IntegrationStatus::Available,
555            capabilities: vec![capability(
556                "send_message",
557                "Send Message",
558                "Send an iMessage",
559            )],
560            auth_method: None,
561            is_native: true,
562            platforms: vec!["macos".to_string(), "ios".to_string()],
563            setup_instructions: None,
564        });
565
566        // =====================================================================
567        // Development - Git
568        // =====================================================================
569        self.register(Integration {
570            id: "github".to_string(),
571            name: "GitHub".to_string(),
572            description: "Code hosting and collaboration".to_string(),
573            category: IntegrationCategory::Git,
574            icon: "".to_string(),
575            color: "#24292e".to_string(),
576            website: Some("https://github.com".to_string()),
577            status: IntegrationStatus::Available,
578            capabilities: vec![
579                capability("list_repos", "List Repos", "Get repositories"),
580                capability("create_issue", "Create Issue", "Create a new issue"),
581                capability("create_pr", "Create PR", "Create a pull request"),
582                capability("list_prs", "List PRs", "Get pull requests"),
583                capability("merge_pr", "Merge PR", "Merge a pull request"),
584                capability("create_branch", "Create Branch", "Create a new branch"),
585            ],
586            auth_method: None,
587            is_native: false,
588            platforms: vec!["all".to_string()],
589            setup_instructions: None,
590        });
591
592        self.register(Integration {
593            id: "gitlab".to_string(),
594            name: "GitLab".to_string(),
595            description: "DevOps platform".to_string(),
596            category: IntegrationCategory::Git,
597            icon: "".to_string(),
598            color: "#fc6d26".to_string(),
599            website: Some("https://gitlab.com".to_string()),
600            status: IntegrationStatus::Available,
601            capabilities: vec![
602                capability("list_projects", "List Projects", "Get projects"),
603                capability("create_issue", "Create Issue", "Create a new issue"),
604                capability("create_mr", "Create MR", "Create a merge request"),
605            ],
606            auth_method: None,
607            is_native: false,
608            platforms: vec!["all".to_string()],
609            setup_instructions: None,
610        });
611
612        // =====================================================================
613        // Browser & Automation
614        // =====================================================================
615        self.register(Integration {
616            id: "chrome".to_string(),
617            name: "Chrome".to_string(),
618            description: "Browser control and automation".to_string(),
619            category: IntegrationCategory::Browser,
620            icon: "".to_string(),
621            color: "#4285f4".to_string(),
622            website: Some("https://chrome.google.com".to_string()),
623            status: IntegrationStatus::Available,
624            capabilities: vec![
625                capability("open_url", "Open URL", "Open a URL in Chrome"),
626                capability("list_tabs", "List Tabs", "Get open tabs"),
627                capability("close_tab", "Close Tab", "Close a tab"),
628                capability("get_bookmarks", "Get Bookmarks", "Get bookmarks"),
629                capability("get_history", "Get History", "Get browsing history"),
630            ],
631            auth_method: None,
632            is_native: true,
633            platforms: vec!["all".to_string()],
634            setup_instructions: None,
635        });
636
637        self.register(Integration {
638            id: "arc".to_string(),
639            name: "Arc Browser".to_string(),
640            description: "Modern browser with spaces".to_string(),
641            category: IntegrationCategory::Browser,
642            icon: "".to_string(),
643            color: "#5c5ce6".to_string(),
644            website: Some("https://arc.net".to_string()),
645            status: IntegrationStatus::Available,
646            capabilities: vec![
647                capability("open_url", "Open URL", "Open a URL in Arc"),
648                capability("list_tabs", "List Tabs", "Get open tabs"),
649                capability("list_spaces", "List Spaces", "Get Arc spaces"),
650            ],
651            auth_method: None,
652            is_native: true,
653            platforms: vec!["macos".to_string()],
654            setup_instructions: None,
655        });
656
657        self.register(Integration {
658            id: "playwright".to_string(),
659            name: "Playwright".to_string(),
660            description: "Browser automation framework".to_string(),
661            category: IntegrationCategory::Automation,
662            icon: "".to_string(),
663            color: "#2ead33".to_string(),
664            website: Some("https://playwright.dev".to_string()),
665            status: IntegrationStatus::Available,
666            capabilities: vec![
667                capability("run_script", "Run Script", "Run automation script"),
668                capability("screenshot", "Screenshot", "Take screenshot"),
669                capability("scrape", "Scrape", "Extract page data"),
670            ],
671            auth_method: None,
672            is_native: true,
673            platforms: vec!["all".to_string()],
674            setup_instructions: None,
675        });
676
677        // =====================================================================
678        // Smart Home
679        // =====================================================================
680        self.register(Integration {
681            id: "home_assistant".to_string(),
682            name: "Home Assistant".to_string(),
683            description: "Open source home automation".to_string(),
684            category: IntegrationCategory::SmartHome,
685            icon: "".to_string(),
686            color: "#41bdf5".to_string(),
687            website: Some("https://home-assistant.io".to_string()),
688            status: IntegrationStatus::Available,
689            capabilities: vec![
690                capability("list_devices", "List Devices", "Get all devices"),
691                capability("control_device", "Control Device", "Control a device"),
692                capability("get_state", "Get State", "Get device state"),
693                capability("call_service", "Call Service", "Call a service"),
694                capability("run_automation", "Run Automation", "Trigger an automation"),
695            ],
696            auth_method: None,
697            is_native: false,
698            platforms: vec!["all".to_string()],
699            setup_instructions: Some("1. Get long-lived access token from Home Assistant\n2. Add URL and token to CSM settings".to_string()),
700        });
701
702        self.register(Integration {
703            id: "homekit".to_string(),
704            name: "Apple HomeKit".to_string(),
705            description: "Apple smart home control".to_string(),
706            category: IntegrationCategory::SmartHome,
707            icon: "".to_string(),
708            color: "#ff9500".to_string(),
709            website: None,
710            status: IntegrationStatus::Available,
711            capabilities: vec![
712                capability(
713                    "list_accessories",
714                    "List Accessories",
715                    "Get all accessories",
716                ),
717                capability(
718                    "control_accessory",
719                    "Control Accessory",
720                    "Control an accessory",
721                ),
722                capability("run_scene", "Run Scene", "Activate a scene"),
723            ],
724            auth_method: None,
725            is_native: true,
726            platforms: vec!["macos".to_string(), "ios".to_string()],
727            setup_instructions: None,
728        });
729
730        self.register(Integration {
731            id: "hue".to_string(),
732            name: "Philips Hue".to_string(),
733            description: "Smart lighting control".to_string(),
734            category: IntegrationCategory::SmartHome,
735            icon: "".to_string(),
736            color: "#0065d3".to_string(),
737            website: Some("https://meethue.com".to_string()),
738            status: IntegrationStatus::Available,
739            capabilities: vec![
740                capability("list_lights", "List Lights", "Get all lights"),
741                capability("control_light", "Control Light", "Control a light"),
742                capability("set_scene", "Set Scene", "Activate a scene"),
743            ],
744            auth_method: None,
745            is_native: false,
746            platforms: vec!["all".to_string()],
747            setup_instructions: None,
748        });
749
750        // =====================================================================
751        // Media
752        // =====================================================================
753        self.register(Integration {
754            id: "spotify".to_string(),
755            name: "Spotify".to_string(),
756            description: "Music streaming".to_string(),
757            category: IntegrationCategory::Music,
758            icon: "".to_string(),
759            color: "#1db954".to_string(),
760            website: Some("https://spotify.com".to_string()),
761            status: IntegrationStatus::Available,
762            capabilities: vec![
763                capability("play", "Play", "Play music"),
764                capability("pause", "Pause", "Pause playback"),
765                capability("next", "Next", "Skip to next track"),
766                capability("search", "Search", "Search for music"),
767                capability("get_now_playing", "Now Playing", "Get current track"),
768            ],
769            auth_method: None,
770            is_native: false,
771            platforms: vec!["all".to_string()],
772            setup_instructions: None,
773        });
774
775        self.register(Integration {
776            id: "youtube".to_string(),
777            name: "YouTube".to_string(),
778            description: "Video streaming".to_string(),
779            category: IntegrationCategory::Video,
780            icon: "".to_string(),
781            color: "#ff0000".to_string(),
782            website: Some("https://youtube.com".to_string()),
783            status: IntegrationStatus::Available,
784            capabilities: vec![
785                capability("search", "Search", "Search for videos"),
786                capability("get_video", "Get Video", "Get video info"),
787                capability("list_playlists", "List Playlists", "Get playlists"),
788            ],
789            auth_method: None,
790            is_native: false,
791            platforms: vec!["all".to_string()],
792            setup_instructions: None,
793        });
794
795        // =====================================================================
796        // System
797        // =====================================================================
798        self.register(Integration {
799            id: "shell".to_string(),
800            name: "Shell".to_string(),
801            description: "Run terminal commands".to_string(),
802            category: IntegrationCategory::System,
803            icon: "".to_string(),
804            color: "#1e1e1e".to_string(),
805            website: None,
806            status: IntegrationStatus::Connected,
807            capabilities: vec![
808                capability("run_command", "Run Command", "Execute a shell command"),
809                capability("run_script", "Run Script", "Execute a script file"),
810            ],
811            auth_method: None,
812            is_native: true,
813            platforms: vec!["all".to_string()],
814            setup_instructions: None,
815        });
816
817        self.register(Integration {
818            id: "clipboard".to_string(),
819            name: "Clipboard".to_string(),
820            description: "System clipboard access".to_string(),
821            category: IntegrationCategory::Clipboard,
822            icon: "".to_string(),
823            color: "#6b7280".to_string(),
824            website: None,
825            status: IntegrationStatus::Connected,
826            capabilities: vec![
827                capability("get", "Get Clipboard", "Get clipboard contents"),
828                capability("set", "Set Clipboard", "Set clipboard contents"),
829                capability("history", "Clipboard History", "Get clipboard history"),
830            ],
831            auth_method: None,
832            is_native: true,
833            platforms: vec!["all".to_string()],
834            setup_instructions: None,
835        });
836
837        self.register(Integration {
838            id: "notifications".to_string(),
839            name: "Notifications".to_string(),
840            description: "System notifications".to_string(),
841            category: IntegrationCategory::Notifications,
842            icon: "".to_string(),
843            color: "#f97316".to_string(),
844            website: None,
845            status: IntegrationStatus::Connected,
846            capabilities: vec![capability(
847                "send",
848                "Send Notification",
849                "Send a system notification",
850            )],
851            auth_method: None,
852            is_native: true,
853            platforms: vec!["all".to_string()],
854            setup_instructions: None,
855        });
856
857        // =====================================================================
858        // Finance
859        // =====================================================================
860        self.register(Integration {
861            id: "plaid".to_string(),
862            name: "Plaid".to_string(),
863            description: "Bank account integration".to_string(),
864            category: IntegrationCategory::Banking,
865            icon: "".to_string(),
866            color: "#00d632".to_string(),
867            website: Some("https://plaid.com".to_string()),
868            status: IntegrationStatus::Available,
869            capabilities: vec![
870                capability("get_accounts", "Get Accounts", "List connected accounts"),
871                capability(
872                    "get_transactions",
873                    "Get Transactions",
874                    "Get recent transactions",
875                ),
876                capability("get_balance", "Get Balance", "Get account balance"),
877            ],
878            auth_method: None,
879            is_native: false,
880            platforms: vec!["all".to_string()],
881            setup_instructions: None,
882        });
883
884        // =====================================================================
885        // Travel
886        // =====================================================================
887        self.register(Integration {
888            id: "google_maps".to_string(),
889            name: "Google Maps".to_string(),
890            description: "Maps and directions".to_string(),
891            category: IntegrationCategory::Maps,
892            icon: "".to_string(),
893            color: "#4285f4".to_string(),
894            website: Some("https://maps.google.com".to_string()),
895            status: IntegrationStatus::Available,
896            capabilities: vec![
897                capability(
898                    "directions",
899                    "Get Directions",
900                    "Get directions between locations",
901                ),
902                capability("search_places", "Search Places", "Search for places"),
903                capability("get_eta", "Get ETA", "Get estimated travel time"),
904            ],
905            auth_method: None,
906            is_native: false,
907            platforms: vec!["all".to_string()],
908            setup_instructions: None,
909        });
910
911        // =====================================================================
912        // Weather
913        // =====================================================================
914        self.register(Integration {
915            id: "weather".to_string(),
916            name: "Weather".to_string(),
917            description: "Weather forecasts".to_string(),
918            category: IntegrationCategory::Weather,
919            icon: "".to_string(),
920            color: "#00b4d8".to_string(),
921            website: None,
922            status: IntegrationStatus::Available,
923            capabilities: vec![
924                capability("current", "Current Weather", "Get current weather"),
925                capability("forecast", "Forecast", "Get weather forecast"),
926            ],
927            auth_method: None,
928            is_native: true,
929            platforms: vec!["all".to_string()],
930            setup_instructions: None,
931        });
932    }
933
934    pub fn register(&mut self, integration: Integration) {
935        self.integrations
936            .insert(integration.id.clone(), integration);
937    }
938
939    pub fn get(&self, id: &str) -> Option<&Integration> {
940        self.integrations.get(id)
941    }
942
943    pub fn list(&self) -> Vec<&Integration> {
944        self.integrations.values().collect()
945    }
946
947    pub fn list_by_category(&self, category: IntegrationCategory) -> Vec<&Integration> {
948        self.integrations
949            .values()
950            .filter(|i| i.category == category)
951            .collect()
952    }
953
954    pub fn search(&self, query: &str) -> Vec<&Integration> {
955        let query = query.to_lowercase();
956        self.integrations
957            .values()
958            .filter(|i| {
959                i.name.to_lowercase().contains(&query)
960                    || i.description.to_lowercase().contains(&query)
961                    || i.id.contains(&query)
962            })
963            .collect()
964    }
965
966    pub fn count(&self) -> usize {
967        self.integrations.len()
968    }
969
970    pub fn categories(&self) -> Vec<(IntegrationCategory, usize)> {
971        let mut counts: HashMap<IntegrationCategory, usize> = HashMap::new();
972        for integration in self.integrations.values() {
973            *counts.entry(integration.category).or_insert(0) += 1;
974        }
975        let mut result: Vec<_> = counts.into_iter().collect();
976        result.sort_by_key(|(_, count)| std::cmp::Reverse(*count));
977        result
978    }
979}
980
981impl Default for IntegrationRegistry {
982    fn default() -> Self {
983        Self::new()
984    }
985}
986
987fn capability(id: &str, name: &str, description: &str) -> Capability {
988    Capability {
989        id: id.to_string(),
990        name: name.to_string(),
991        description: description.to_string(),
992        permissions: vec![],
993        parameters: vec![],
994        requires_confirmation: false,
995    }
996}