apteva 0.4.57 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +216 -54
  2. package/cli.js +35 -0
  3. package/install.js +92 -0
  4. package/package.json +15 -76
  5. package/LICENSE +0 -63
  6. package/bin/apteva.js +0 -196
  7. package/dist/ActivityPage.kxzzb4yc.js +0 -3
  8. package/dist/ApiDocsPage.zq998hbm.js +0 -4
  9. package/dist/App.55rea8mn.js +0 -61
  10. package/dist/App.5ywb23z4.js +0 -53
  11. package/dist/App.6thds120.js +0 -4
  12. package/dist/App.9tctxzqm.js +0 -8
  13. package/dist/App.a8r8ttaz.js +0 -4
  14. package/dist/App.agsv5bje.js +0 -4
  15. package/dist/App.cepapqmx.js +0 -4
  16. package/dist/App.dp041gb3.js +0 -221
  17. package/dist/App.fds72zb5.js +0 -4
  18. package/dist/App.fg9qj2dq.js +0 -4
  19. package/dist/App.ndfejbm9.js +0 -4
  20. package/dist/App.nxmfmq1h.js +0 -13
  21. package/dist/App.qdfyt8ba.js +0 -4
  22. package/dist/App.x2d0ygt6.js +0 -4
  23. package/dist/App.yt9p4nr3.js +0 -20
  24. package/dist/App.zn4mw16t.js +0 -1
  25. package/dist/ConnectionsPage.8r96ryw7.js +0 -3
  26. package/dist/McpPage.3cwh0gnd.js +0 -3
  27. package/dist/SettingsPage.ykgdh5ev.js +0 -3
  28. package/dist/SkillsPage.4np1s65b.js +0 -3
  29. package/dist/TasksPage.4g08t7p6.js +0 -3
  30. package/dist/TelemetryPage.72w9pwcp.js +0 -3
  31. package/dist/TestsPage.z4fk3r7r.js +0 -3
  32. package/dist/ThreadsPage.63tcajeh.js +0 -3
  33. package/dist/apteva-kit.css +0 -1
  34. package/dist/icon.png +0 -0
  35. package/dist/index.html +0 -16
  36. package/dist/styles.css +0 -1
  37. package/scripts/postinstall.mjs +0 -102
  38. package/src/auth/index.ts +0 -394
  39. package/src/auth/middleware.ts +0 -213
  40. package/src/binary.ts +0 -536
  41. package/src/channels/index.ts +0 -40
  42. package/src/channels/telegram.ts +0 -311
  43. package/src/crypto.ts +0 -301
  44. package/src/db-tests.ts +0 -174
  45. package/src/db.ts +0 -3133
  46. package/src/integrations/agentdojo.ts +0 -559
  47. package/src/integrations/composio.ts +0 -437
  48. package/src/integrations/index.ts +0 -87
  49. package/src/integrations/skillsmp.ts +0 -318
  50. package/src/mcp-client.ts +0 -605
  51. package/src/mcp-handler.ts +0 -394
  52. package/src/mcp-platform.ts +0 -2403
  53. package/src/openapi.ts +0 -2410
  54. package/src/providers.ts +0 -597
  55. package/src/routes/api/agent-utils.ts +0 -890
  56. package/src/routes/api/agents.ts +0 -916
  57. package/src/routes/api/api-keys.ts +0 -95
  58. package/src/routes/api/channels.ts +0 -182
  59. package/src/routes/api/helpers.ts +0 -12
  60. package/src/routes/api/integrations.ts +0 -639
  61. package/src/routes/api/mcp.ts +0 -574
  62. package/src/routes/api/meta-agent.ts +0 -195
  63. package/src/routes/api/projects.ts +0 -112
  64. package/src/routes/api/providers.ts +0 -424
  65. package/src/routes/api/skills.ts +0 -537
  66. package/src/routes/api/system.ts +0 -333
  67. package/src/routes/api/telemetry.ts +0 -203
  68. package/src/routes/api/tests.ts +0 -148
  69. package/src/routes/api/triggers.ts +0 -518
  70. package/src/routes/api/users.ts +0 -148
  71. package/src/routes/api/webhooks.ts +0 -171
  72. package/src/routes/api.ts +0 -53
  73. package/src/routes/auth.ts +0 -251
  74. package/src/routes/share.ts +0 -86
  75. package/src/routes/static.ts +0 -131
  76. package/src/server.ts +0 -642
  77. package/src/test-runner.ts +0 -598
  78. package/src/triggers/agentdojo.ts +0 -253
  79. package/src/triggers/composio.ts +0 -264
  80. package/src/triggers/index.ts +0 -71
  81. package/src/tui/AgentList.tsx +0 -145
  82. package/src/tui/App.tsx +0 -102
  83. package/src/tui/Login.tsx +0 -104
  84. package/src/tui/api.ts +0 -72
  85. package/src/tui/index.tsx +0 -7
  86. package/src/web/App.tsx +0 -455
  87. package/src/web/components/activity/ActivityPage.tsx +0 -314
  88. package/src/web/components/activity/index.ts +0 -1
  89. package/src/web/components/agents/AgentCard.tsx +0 -189
  90. package/src/web/components/agents/AgentPanel.tsx +0 -2244
  91. package/src/web/components/agents/AgentsView.tsx +0 -180
  92. package/src/web/components/agents/CreateAgentModal.tsx +0 -475
  93. package/src/web/components/agents/index.ts +0 -4
  94. package/src/web/components/api/ApiDocsPage.tsx +0 -842
  95. package/src/web/components/auth/CreateAccountStep.tsx +0 -176
  96. package/src/web/components/auth/LoginPage.tsx +0 -91
  97. package/src/web/components/auth/index.ts +0 -2
  98. package/src/web/components/common/Icons.tsx +0 -250
  99. package/src/web/components/common/LoadingSpinner.tsx +0 -44
  100. package/src/web/components/common/Modal.tsx +0 -199
  101. package/src/web/components/common/Select.tsx +0 -97
  102. package/src/web/components/common/index.ts +0 -20
  103. package/src/web/components/connections/ConnectionsPage.tsx +0 -54
  104. package/src/web/components/connections/IntegrationsTab.tsx +0 -170
  105. package/src/web/components/connections/OverviewTab.tsx +0 -137
  106. package/src/web/components/connections/TriggersTab.tsx +0 -1346
  107. package/src/web/components/dashboard/Dashboard.tsx +0 -572
  108. package/src/web/components/dashboard/index.ts +0 -1
  109. package/src/web/components/index.ts +0 -21
  110. package/src/web/components/layout/ErrorBanner.tsx +0 -18
  111. package/src/web/components/layout/Header.tsx +0 -332
  112. package/src/web/components/layout/Sidebar.tsx +0 -231
  113. package/src/web/components/layout/index.ts +0 -3
  114. package/src/web/components/mcp/IntegrationsPanel.tsx +0 -857
  115. package/src/web/components/mcp/McpPage.tsx +0 -2515
  116. package/src/web/components/mcp/index.ts +0 -1
  117. package/src/web/components/meta-agent/MetaAgent.tsx +0 -245
  118. package/src/web/components/onboarding/OnboardingWizard.tsx +0 -404
  119. package/src/web/components/onboarding/index.ts +0 -1
  120. package/src/web/components/settings/SettingsPage.tsx +0 -2776
  121. package/src/web/components/settings/index.ts +0 -1
  122. package/src/web/components/skills/SkillsPage.tsx +0 -1200
  123. package/src/web/components/tasks/TasksPage.tsx +0 -1116
  124. package/src/web/components/tasks/index.ts +0 -1
  125. package/src/web/components/telemetry/TelemetryPage.tsx +0 -1129
  126. package/src/web/components/tests/TestsPage.tsx +0 -594
  127. package/src/web/components/threads/ThreadsPage.tsx +0 -315
  128. package/src/web/context/AuthContext.tsx +0 -242
  129. package/src/web/context/ProjectContext.tsx +0 -214
  130. package/src/web/context/TelemetryContext.tsx +0 -299
  131. package/src/web/context/ThemeContext.tsx +0 -90
  132. package/src/web/context/UIModeContext.tsx +0 -49
  133. package/src/web/context/index.ts +0 -12
  134. package/src/web/hooks/index.ts +0 -3
  135. package/src/web/hooks/useAgents.ts +0 -115
  136. package/src/web/hooks/useOnboarding.ts +0 -20
  137. package/src/web/hooks/useProviders.ts +0 -75
  138. package/src/web/icon.png +0 -0
  139. package/src/web/index.html +0 -16
  140. package/src/web/styles.css +0 -118
  141. package/src/web/themes.ts +0 -162
  142. package/src/web/types.ts +0 -298
@@ -1,437 +0,0 @@
1
- // Composio Integration Provider
2
- // https://docs.composio.dev/api-reference
3
-
4
- import type {
5
- IntegrationProvider,
6
- IntegrationApp,
7
- ConnectedAccount,
8
- ConnectionRequest,
9
- ConnectionCredentials,
10
- } from "./index";
11
-
12
- const COMPOSIO_API_BASE = "https://backend.composio.dev";
13
-
14
- export const ComposioProvider: IntegrationProvider = {
15
- id: "composio",
16
- name: "Composio",
17
-
18
- async listApps(apiKey: string): Promise<IntegrationApp[]> {
19
- const res = await fetch(`${COMPOSIO_API_BASE}/api/v3/toolkits`, {
20
- headers: {
21
- "x-api-key": apiKey,
22
- "Content-Type": "application/json",
23
- },
24
- });
25
-
26
- if (!res.ok) {
27
- console.error("Composio listApps error:", res.status, await res.text());
28
- return [];
29
- }
30
-
31
- const data = await res.json();
32
- const items = data.items || data.toolkits || data || [];
33
-
34
- return items.map((item: any) => ({
35
- id: item.slug || item.key || item.name,
36
- name: item.name || item.slug,
37
- slug: item.slug || item.key || item.name?.toLowerCase(),
38
- description: item.meta?.description || item.description || null,
39
- logo: item.meta?.logo || item.logo || null,
40
- categories: (item.meta?.categories || item.categories || []).map((c: any) =>
41
- typeof c === "string" ? c : c.name || c.id
42
- ),
43
- authSchemes: item.auth_schemes || item.authSchemes || ["OAUTH2"],
44
- }));
45
- },
46
-
47
- async listConnectedAccounts(apiKey: string, userId: string): Promise<ConnectedAccount[]> {
48
- console.log(`Fetching connected accounts for user: ${userId}`);
49
- const res = await fetch(
50
- `${COMPOSIO_API_BASE}/api/v3/connected_accounts?user_id=${encodeURIComponent(userId)}&limit=100`,
51
- {
52
- headers: {
53
- "x-api-key": apiKey,
54
- "Content-Type": "application/json",
55
- },
56
- }
57
- );
58
-
59
- if (!res.ok) {
60
- console.error("Composio listConnectedAccounts error:", res.status, await res.text());
61
- return [];
62
- }
63
-
64
- const data = await res.json();
65
- const items = data.items || data.connections || data || [];
66
- console.log(`Found ${items.length} connected accounts`);
67
- if (items.length > 0) {
68
- console.log(`Sample account:`, JSON.stringify(items[0], null, 2));
69
- }
70
-
71
- return items.map((item: any) => ({
72
- id: item.id,
73
- appId: item.toolkit?.slug || item.toolkit_slug || item.appId || item.app_id,
74
- appName: item.toolkit?.name || item.toolkit_name || item.appName || item.toolkit?.slug,
75
- status: mapStatus(item.status),
76
- createdAt: item.created_at || item.createdAt || new Date().toISOString(),
77
- metadata: {
78
- entityId: item.entity_id || item.user_id,
79
- integrationId: item.auth_config?.id,
80
- },
81
- }));
82
- },
83
-
84
- async initiateConnection(
85
- apiKey: string,
86
- userId: string,
87
- appSlug: string,
88
- redirectUrl: string,
89
- credentials?: ConnectionCredentials
90
- ): Promise<ConnectionRequest> {
91
- const isApiKeyAuth = credentials?.authScheme === "API_KEY" && credentials?.apiKey;
92
-
93
- console.log(`Initiating ${isApiKeyAuth ? "API_KEY" : "OAuth"} connection for ${appSlug}`);
94
-
95
- // Step 1: Get toolkit info to find the API key field name
96
- let apiKeyFieldName = "api_key"; // default
97
- try {
98
- const toolkitRes = await fetch(`${COMPOSIO_API_BASE}/api/v3/toolkits/${appSlug}`, {
99
- headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
100
- });
101
- if (toolkitRes.ok) {
102
- const toolkitData = await toolkitRes.json();
103
- // Find the API_KEY auth config details
104
- const apiKeyConfig = toolkitData.auth_config_details?.find(
105
- (c: any) => c.mode === "API_KEY"
106
- );
107
- if (apiKeyConfig?.fields?.connected_account_initiation?.required?.[0]?.name) {
108
- apiKeyFieldName = apiKeyConfig.fields.connected_account_initiation.required[0].name;
109
- }
110
- console.log(`Toolkit ${appSlug} API key field: ${apiKeyFieldName}`);
111
- }
112
- } catch (e) {
113
- console.error(`Failed to get toolkit info:`, e);
114
- }
115
-
116
- // Step 2: Get existing auth configs for this toolkit
117
- const configsRes = await fetch(`${COMPOSIO_API_BASE}/api/v3/auth_configs?toolkit=${appSlug}`, {
118
- headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
119
- });
120
-
121
- let authConfigId: string | null = null;
122
-
123
- if (configsRes.ok) {
124
- const configsData = await configsRes.json();
125
- const allConfigs = configsData.items || [];
126
-
127
- // Filter to configs for this toolkit
128
- const configs = allConfigs.filter((c: any) => {
129
- const toolkit = c.toolkit?.slug || c.toolkit_slug || "";
130
- return toolkit.toLowerCase() === appSlug.toLowerCase();
131
- });
132
-
133
- console.log(`Found ${configs.length} auth configs for ${appSlug}`);
134
-
135
- if (isApiKeyAuth) {
136
- const apiKeyConfig = configs.find((c: any) => c.auth_scheme === "API_KEY");
137
- if (apiKeyConfig) {
138
- authConfigId = apiKeyConfig.id;
139
- console.log(`Using existing API_KEY config: ${authConfigId}`);
140
- }
141
- } else {
142
- const oauthConfig = configs.find((c: any) =>
143
- c.auth_scheme === "OAUTH2" || c.is_composio_managed
144
- );
145
- if (oauthConfig) {
146
- authConfigId = oauthConfig.id;
147
- console.log(`Using existing OAuth config: ${authConfigId}`);
148
- }
149
- }
150
- }
151
-
152
- // Step 3: Create auth config if not found
153
- if (!authConfigId) {
154
- console.log(`Creating new auth config for ${appSlug}...`);
155
-
156
- const createBody = isApiKeyAuth
157
- ? {
158
- toolkit: { slug: appSlug },
159
- auth_config: {
160
- type: "use_custom_auth",
161
- authScheme: "API_KEY",
162
- },
163
- }
164
- : {
165
- toolkit: { slug: appSlug },
166
- auth_config: {
167
- type: "use_composio_managed_auth",
168
- },
169
- };
170
-
171
- const createRes = await fetch(`${COMPOSIO_API_BASE}/api/v3/auth_configs`, {
172
- method: "POST",
173
- headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
174
- body: JSON.stringify(createBody),
175
- });
176
-
177
- if (createRes.ok) {
178
- const createData = await createRes.json();
179
- authConfigId = createData.auth_config?.id;
180
- console.log(`Created auth config: ${authConfigId}`);
181
- } else {
182
- const errText = await createRes.text();
183
- console.error(`Failed to create auth config:`, errText);
184
- throw new Error(`Failed to create auth config: ${errText}`);
185
- }
186
- }
187
-
188
- if (!authConfigId) {
189
- throw new Error(`Could not find or create auth configuration for ${appSlug}.`);
190
- }
191
-
192
- // Step 4: Create connected account
193
- const connectionBody: any = {
194
- auth_config: { id: authConfigId },
195
- connection: {
196
- user_id: userId,
197
- },
198
- };
199
-
200
- if (isApiKeyAuth && credentials?.apiKey) {
201
- connectionBody.connection.state = {
202
- authScheme: "API_KEY",
203
- val: {
204
- [apiKeyFieldName]: credentials.apiKey,
205
- },
206
- };
207
- } else {
208
- connectionBody.connection.callback_url = redirectUrl;
209
- }
210
-
211
- console.log(`Creating connected account...`);
212
-
213
- const res = await fetch(`${COMPOSIO_API_BASE}/api/v3/connected_accounts`, {
214
- method: "POST",
215
- headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
216
- body: JSON.stringify(connectionBody),
217
- });
218
-
219
- if (!res.ok) {
220
- const text = await res.text();
221
- console.error("Composio connection error:", res.status, text);
222
- throw new Error(`Failed to create connection: ${text}`);
223
- }
224
-
225
- const data = await res.json();
226
- const status = (data.status || "").toLowerCase();
227
-
228
- console.log(`Connection created: ${data.id}, status: ${status}`);
229
-
230
- return {
231
- redirectUrl: isApiKeyAuth ? null : (data.redirect_url || data.redirectUrl),
232
- connectionId: data.id,
233
- status: (status === "active" || status === "connected") ? "active" : "pending",
234
- };
235
- },
236
-
237
- async getConnectionStatus(apiKey: string, connectionId: string): Promise<ConnectedAccount | null> {
238
- const res = await fetch(`${COMPOSIO_API_BASE}/api/v3/connected_accounts/${connectionId}`, {
239
- headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
240
- });
241
-
242
- if (!res.ok) {
243
- if (res.status === 404) return null;
244
- console.error("Composio getConnectionStatus error:", res.status, await res.text());
245
- return null;
246
- }
247
-
248
- const item = await res.json();
249
-
250
- return {
251
- id: item.id,
252
- appId: item.toolkit_slug || item.appId,
253
- appName: item.toolkit_name || item.appName || item.toolkit_slug,
254
- status: mapStatus(item.status),
255
- createdAt: item.created_at || item.createdAt,
256
- metadata: {
257
- entityId: item.entity_id,
258
- integrationId: item.integration_id,
259
- },
260
- };
261
- },
262
-
263
- async disconnect(apiKey: string, connectionId: string): Promise<boolean> {
264
- const res = await fetch(`${COMPOSIO_API_BASE}/api/v3/connected_accounts/${connectionId}`, {
265
- method: "DELETE",
266
- headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
267
- });
268
-
269
- return res.ok;
270
- },
271
- };
272
-
273
- // MCP Server types
274
- export interface McpServer {
275
- id: string;
276
- name: string;
277
- authConfigIds: string[];
278
- mcpUrl: string;
279
- toolkits: string[];
280
- toolkitIcons: Record<string, string>;
281
- allowedTools: string[];
282
- createdAt: string;
283
- }
284
-
285
- export async function listMcpServers(apiKey: string): Promise<McpServer[]> {
286
- const res = await fetch(`${COMPOSIO_API_BASE}/api/v3/mcp/servers`, {
287
- headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
288
- });
289
-
290
- if (!res.ok) {
291
- console.error("Failed to list MCP servers:", await res.text());
292
- return [];
293
- }
294
-
295
- const data = await res.json();
296
- const items = data.items || [];
297
-
298
- return items.map((item: any) => ({
299
- id: item.id,
300
- name: item.name,
301
- authConfigIds: item.auth_config_ids || [],
302
- mcpUrl: item.mcp_url,
303
- toolkits: item.toolkits || [],
304
- toolkitIcons: item.toolkit_icons || {},
305
- allowedTools: item.allowed_tools || [],
306
- createdAt: item.created_at,
307
- }));
308
- }
309
-
310
- export async function createMcpServer(
311
- apiKey: string,
312
- name: string,
313
- authConfigIds: string[],
314
- allowedTools?: string[]
315
- ): Promise<McpServer | null> {
316
- // Use auth_config_ids - Composio includes all tools by default when allowed_tools is not provided
317
- const body: any = {
318
- name,
319
- auth_config_ids: authConfigIds,
320
- };
321
-
322
- // Only set allowed_tools if explicitly provided to restrict tools
323
- // If not provided, Composio enables all tools by default
324
- if (allowedTools?.length) {
325
- body.allowed_tools = allowedTools;
326
- }
327
-
328
- const res = await fetch(`${COMPOSIO_API_BASE}/api/v3/mcp/servers`, {
329
- method: "POST",
330
- headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
331
- body: JSON.stringify(body),
332
- });
333
-
334
- if (!res.ok) {
335
- const errText = await res.text();
336
- console.error("Failed to create MCP server:", errText);
337
- throw new Error(`Failed to create MCP server: ${errText}`);
338
- }
339
-
340
- const item = await res.json();
341
- return {
342
- id: item.id,
343
- name: item.name,
344
- authConfigIds: item.auth_config_ids || [],
345
- mcpUrl: item.mcp_url,
346
- toolkits: item.toolkits || [],
347
- toolkitIcons: item.toolkit_icons || {},
348
- allowedTools: item.allowed_tools || [],
349
- createdAt: item.created_at,
350
- };
351
- }
352
-
353
- export async function deleteMcpServer(apiKey: string, serverId: string): Promise<boolean> {
354
- const res = await fetch(`${COMPOSIO_API_BASE}/api/v3/mcp/servers/${serverId}`, {
355
- method: "DELETE",
356
- headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
357
- });
358
- return res.ok;
359
- }
360
-
361
- // Create a server instance for a user
362
- export async function createMcpServerInstance(
363
- apiKey: string,
364
- serverId: string,
365
- userId: string
366
- ): Promise<{ id: string; instanceId: string } | null> {
367
- const res = await fetch(`${COMPOSIO_API_BASE}/api/v3/mcp/servers/${serverId}/instances`, {
368
- method: "POST",
369
- headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
370
- body: JSON.stringify({ user_id: userId }),
371
- });
372
-
373
- if (!res.ok) {
374
- const errText = await res.text();
375
- console.error("Failed to create MCP server instance:", errText);
376
- return null;
377
- }
378
-
379
- const data = await res.json();
380
- return {
381
- id: data.id,
382
- instanceId: data.instance_id,
383
- };
384
- }
385
-
386
- // Get user_id from connected accounts for a specific auth config
387
- export async function getUserIdForAuthConfig(
388
- apiKey: string,
389
- authConfigId: string
390
- ): Promise<string | null> {
391
- const res = await fetch(`${COMPOSIO_API_BASE}/api/v3/connected_accounts?limit=100`, {
392
- headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
393
- });
394
-
395
- if (!res.ok) return null;
396
-
397
- const data = await res.json();
398
- const items = data.items || [];
399
-
400
- // Find an active connected account for this auth config
401
- const account = items.find((item: any) =>
402
- item.auth_config?.id === authConfigId && item.status === "ACTIVE"
403
- );
404
-
405
- return account?.user_id || null;
406
- }
407
-
408
- // Get auth config ID for a connected account's toolkit
409
- export async function getAuthConfigForToolkit(
410
- apiKey: string,
411
- toolkitSlug: string,
412
- authScheme: "API_KEY" | "OAUTH2" = "API_KEY"
413
- ): Promise<string | null> {
414
- const res = await fetch(`${COMPOSIO_API_BASE}/api/v3/auth_configs?toolkit=${toolkitSlug}`, {
415
- headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
416
- });
417
-
418
- if (!res.ok) return null;
419
-
420
- const data = await res.json();
421
- const configs = (data.items || []).filter((c: any) => {
422
- const toolkit = c.toolkit?.slug || "";
423
- return toolkit.toLowerCase() === toolkitSlug.toLowerCase();
424
- });
425
-
426
- const config = configs.find((c: any) => c.auth_scheme === authScheme);
427
- return config?.id || null;
428
- }
429
-
430
- function mapStatus(status: string): ConnectedAccount["status"] {
431
- const s = (status || "").toLowerCase();
432
- if (s === "active" || s === "connected") return "active";
433
- if (s === "pending" || s === "initiated") return "pending";
434
- if (s === "failed" || s === "error") return "failed";
435
- if (s === "expired") return "expired";
436
- return "pending";
437
- }
@@ -1,87 +0,0 @@
1
- // Generic Integration Provider Interface
2
- // Allows multiple providers (Composio, Smithery, etc.) to offer OAuth app connections
3
-
4
- export interface IntegrationApp {
5
- id: string;
6
- name: string;
7
- slug: string;
8
- description: string | null;
9
- logo: string | null;
10
- categories: string[];
11
- authSchemes: string[]; // e.g., ["OAUTH2", "API_KEY"]
12
- providerSlug?: string; // The underlying provider name (one provider can serve multiple toolkits)
13
- credentialFields?: { // Fields required for API_KEY auth (from provider auth_config)
14
- name: string;
15
- description?: string;
16
- required?: boolean;
17
- }[];
18
- }
19
-
20
- export interface ConnectedAccount {
21
- id: string;
22
- appId: string;
23
- appName: string;
24
- status: "active" | "pending" | "failed" | "expired";
25
- createdAt: string;
26
- metadata?: Record<string, unknown>;
27
- }
28
-
29
- export interface ConnectionRequest {
30
- redirectUrl: string | null; // null for API_KEY auth (no redirect needed)
31
- connectionId?: string;
32
- status?: "active" | "pending"; // API_KEY connections are immediately active
33
- }
34
-
35
- export interface ConnectionCredentials {
36
- authScheme: "OAUTH2" | "API_KEY" | "BEARER_TOKEN" | "BASIC";
37
- apiKey?: string;
38
- bearerToken?: string;
39
- username?: string;
40
- password?: string;
41
- fields?: Record<string, string>; // Arbitrary credential fields (e.g. { appToken: "...", userKey: "..." })
42
- }
43
-
44
- export interface IntegrationProvider {
45
- id: string;
46
- name: string;
47
-
48
- // List available apps/toolkits
49
- listApps(apiKey: string): Promise<IntegrationApp[]>;
50
-
51
- // List user's connected accounts
52
- listConnectedAccounts(apiKey: string, userId: string): Promise<ConnectedAccount[]>;
53
-
54
- // Initiate connection (OAuth or API Key)
55
- initiateConnection(
56
- apiKey: string,
57
- userId: string,
58
- appSlug: string,
59
- redirectUrl: string,
60
- credentials?: ConnectionCredentials
61
- ): Promise<ConnectionRequest>;
62
-
63
- // Check connection status
64
- getConnectionStatus(apiKey: string, connectionId: string): Promise<ConnectedAccount | null>;
65
-
66
- // Disconnect/revoke
67
- disconnect(apiKey: string, connectionId: string): Promise<boolean>;
68
- }
69
-
70
- // Provider registry
71
- const providers: Map<string, IntegrationProvider> = new Map();
72
-
73
- export function registerProvider(provider: IntegrationProvider) {
74
- providers.set(provider.id, provider);
75
- }
76
-
77
- export function getProvider(id: string): IntegrationProvider | undefined {
78
- return providers.get(id);
79
- }
80
-
81
- export function getAllProviders(): IntegrationProvider[] {
82
- return Array.from(providers.values());
83
- }
84
-
85
- export function getProviderIds(): string[] {
86
- return Array.from(providers.keys());
87
- }