Skip to content

Personal AI, On Personal Devices

Python

feat: add connector TypeScript types and API client

krypticmouse53233f94ae87
diff --git a/frontend/src/lib/connectors-api.ts b/frontend/src/lib/connectors-api.ts
new file mode 100644
index 00000000..078772c5
--- /dev/null
+++ b/frontend/src/lib/connectors-api.ts
@@ -0,0 +1,42 @@
+import { getBase } from './api';
+import type { ConnectorInfo, SyncStatus, ConnectRequest } from '../types/connectors';
+
+// ---------------------------------------------------------------------------
+// Connectors API
+// ---------------------------------------------------------------------------
+
+export async function listConnectors(): Promise<ConnectorInfo[]> {
+ const res = await fetch(`${getBase()}/v1/connectors`);
+ if (!res.ok) throw new Error(`Failed to list connectors: ${res.status}`);
+ const data = await res.json();
+ return data.connectors || [];
+}
+
+export async function getConnector(id: string): Promise<ConnectorInfo> {
+ const res = await fetch(`${getBase()}/v1/connectors/${encodeURIComponent(id)}`);
+ if (!res.ok) throw new Error(`Failed to get connector ${id}: ${res.status}`);
+ return res.json();
+}
+
+export async function connectSource(id: string, req: ConnectRequest): Promise<ConnectorInfo> {
+ const res = await fetch(`${getBase()}/v1/connectors/${encodeURIComponent(id)}/connect`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify(req),
+ });
+ if (!res.ok) throw new Error(`Failed to connect ${id}: ${res.status}`);
+ return res.json();
+}
+
+export async function disconnectSource(id: string): Promise<void> {
+ const res = await fetch(`${getBase()}/v1/connectors/${encodeURIComponent(id)}/disconnect`, {
+ method: 'POST',
+ });
+ if (!res.ok) throw new Error(`Failed to disconnect ${id}: ${res.status}`);
+}
+
+export async function getSyncStatus(id: string): Promise<SyncStatus> {
+ const res = await fetch(`${getBase()}/v1/connectors/${encodeURIComponent(id)}/sync`);
+ if (!res.ok) throw new Error(`Failed to get sync status for ${id}: ${res.status}`);
+ return res.json();
+}
diff --git a/frontend/src/types/connectors.ts b/frontend/src/types/connectors.ts
new file mode 100644
index 00000000..cb5306b2
--- /dev/null
+++ b/frontend/src/types/connectors.ts
@@ -0,0 +1,49 @@
+export interface ConnectorInfo {
+ connector_id: string;
+ display_name: string;
+ auth_type: "oauth" | "local" | "bridge" | "filesystem";
+ connected: boolean;
+ auth_url?: string;
+ mcp_tools?: string[];
+}
+
+export interface SyncStatus {
+ state: "idle" | "syncing" | "paused" | "error";
+ items_synced: number;
+ items_total: number;
+ last_sync: string | null;
+ error: string | null;
+}
+
+export interface ConnectRequest {
+ path?: string;
+ token?: string;
+ code?: string;
+ email?: string;
+ password?: string;
+}
+
+export type WizardStep = "pick" | "connect" | "ingest" | "ready";
+
+export interface SourceCard {
+ connector_id: string;
+ display_name: string;
+ auth_type: string;
+ category: "communication" | "documents" | "pim";
+ icon: string;
+ color: string;
+ description: string;
+}
+
+export const SOURCE_CATALOG: SourceCard[] = [
+ { connector_id: "gmail", display_name: "Gmail", auth_type: "oauth", category: "communication", icon: "Mail", color: "text-red-400", description: "Email messages and threads" },
+ { connector_id: "gmail_imap", display_name: "Gmail (IMAP)", auth_type: "oauth", category: "communication", icon: "Mail", color: "text-red-400", description: "Email via app password" },
+ { connector_id: "slack", display_name: "Slack", auth_type: "oauth", category: "communication", icon: "Hash", color: "text-purple-400", description: "Channel messages and threads" },
+ { connector_id: "imessage", display_name: "iMessage", auth_type: "local", category: "communication", icon: "MessageSquare", color: "text-green-400", description: "macOS Messages history" },
+ { connector_id: "gdrive", display_name: "Google Drive", auth_type: "oauth", category: "documents", icon: "FolderOpen", color: "text-blue-400", description: "Docs, Sheets, and files" },
+ { connector_id: "notion", display_name: "Notion", auth_type: "oauth", category: "documents", icon: "FileText", color: "text-gray-300", description: "Pages and databases" },
+ { connector_id: "obsidian", display_name: "Obsidian", auth_type: "filesystem", category: "documents", icon: "Diamond", color: "text-violet-400", description: "Markdown vault" },
+ { connector_id: "granola", display_name: "Granola", auth_type: "oauth", category: "documents", icon: "Mic", color: "text-amber-400", description: "AI meeting notes" },
+ { connector_id: "gcalendar", display_name: "Calendar", auth_type: "oauth", category: "pim", icon: "Calendar", color: "text-blue-400", description: "Events and meetings" },
+ { connector_id: "gcontacts", display_name: "Contacts", auth_type: "oauth", category: "pim", icon: "Users", color: "text-blue-400", description: "People and contact info" },
+];