@contractspec/integration.providers-impls 3.0.0 → 3.2.0

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 (121) hide show
  1. package/README.md +59 -9
  2. package/dist/impls/async-event-queue.js +2 -0
  3. package/dist/impls/composio-fallback-resolver.d.ts +34 -0
  4. package/dist/impls/composio-fallback-resolver.js +580 -0
  5. package/dist/impls/composio-mcp.d.ts +22 -0
  6. package/dist/impls/composio-mcp.js +164 -0
  7. package/dist/impls/composio-proxies.d.ts +60 -0
  8. package/dist/impls/composio-proxies.js +311 -0
  9. package/dist/impls/composio-sdk.d.ts +25 -0
  10. package/dist/impls/composio-sdk.js +78 -0
  11. package/dist/impls/composio-types.d.ts +43 -0
  12. package/dist/impls/composio-types.js +54 -0
  13. package/dist/impls/elevenlabs-voice.js +2 -0
  14. package/dist/impls/fal-voice.js +2 -0
  15. package/dist/impls/fathom-meeting-recorder.js +2 -0
  16. package/dist/impls/fathom-meeting-recorder.mapper.js +2 -0
  17. package/dist/impls/fathom-meeting-recorder.utils.js +2 -0
  18. package/dist/impls/fathom-meeting-recorder.webhooks.js +2 -0
  19. package/dist/impls/fireflies-meeting-recorder.js +2 -0
  20. package/dist/impls/fireflies-meeting-recorder.queries.js +2 -0
  21. package/dist/impls/fireflies-meeting-recorder.utils.js +2 -0
  22. package/dist/impls/gcs-storage.js +2 -0
  23. package/dist/impls/gmail-inbound.js +2 -0
  24. package/dist/impls/gmail-outbound.js +2 -0
  25. package/dist/impls/google-calendar.js +2 -0
  26. package/dist/impls/gradium-voice.js +2 -0
  27. package/dist/impls/granola-meeting-recorder.js +2 -0
  28. package/dist/impls/granola-meeting-recorder.mcp.js +2 -0
  29. package/dist/impls/health/base-health-provider.js +2 -0
  30. package/dist/impls/health/hybrid-health-providers.js +2 -0
  31. package/dist/impls/health/official-health-providers.js +2 -0
  32. package/dist/impls/health/provider-normalizers.js +2 -0
  33. package/dist/impls/health/providers.js +2 -0
  34. package/dist/impls/health-provider-factory.js +2 -0
  35. package/dist/impls/index.d.ts +5 -0
  36. package/dist/impls/index.js +657 -0
  37. package/dist/impls/jira.js +2 -0
  38. package/dist/impls/linear.js +2 -0
  39. package/dist/impls/messaging-github.js +2 -0
  40. package/dist/impls/messaging-slack.js +2 -0
  41. package/dist/impls/messaging-whatsapp-meta.js +2 -0
  42. package/dist/impls/messaging-whatsapp-twilio.js +2 -0
  43. package/dist/impls/mistral-conversational.js +2 -0
  44. package/dist/impls/mistral-conversational.session.js +2 -0
  45. package/dist/impls/mistral-embedding.js +2 -0
  46. package/dist/impls/mistral-llm.js +2 -0
  47. package/dist/impls/mistral-stt.js +2 -0
  48. package/dist/impls/notion.js +2 -0
  49. package/dist/impls/posthog-reader.js +2 -0
  50. package/dist/impls/posthog-utils.js +2 -0
  51. package/dist/impls/posthog.js +2 -0
  52. package/dist/impls/postmark-email.js +2 -0
  53. package/dist/impls/powens-client.js +2 -0
  54. package/dist/impls/powens-openbanking.js +2 -0
  55. package/dist/impls/provider-factory.d.ts +24 -0
  56. package/dist/impls/provider-factory.js +70 -0
  57. package/dist/impls/qdrant-vector.js +2 -0
  58. package/dist/impls/stripe-payments.js +2 -0
  59. package/dist/impls/supabase-psql.js +2 -0
  60. package/dist/impls/supabase-vector.js +2 -0
  61. package/dist/impls/tldv-meeting-recorder.js +2 -0
  62. package/dist/impls/twilio-sms.js +2 -0
  63. package/dist/index.js +657 -0
  64. package/dist/node/impls/async-event-queue.js +3 -0
  65. package/dist/node/impls/composio-fallback-resolver.js +580 -0
  66. package/dist/node/impls/composio-mcp.js +164 -0
  67. package/dist/node/impls/composio-proxies.js +311 -0
  68. package/dist/node/impls/composio-sdk.js +78 -0
  69. package/dist/node/impls/composio-types.js +54 -0
  70. package/dist/node/impls/elevenlabs-voice.js +3 -0
  71. package/dist/node/impls/fal-voice.js +3 -0
  72. package/dist/node/impls/fathom-meeting-recorder.js +3 -0
  73. package/dist/node/impls/fathom-meeting-recorder.mapper.js +3 -0
  74. package/dist/node/impls/fathom-meeting-recorder.utils.js +3 -0
  75. package/dist/node/impls/fathom-meeting-recorder.webhooks.js +3 -0
  76. package/dist/node/impls/fireflies-meeting-recorder.js +3 -0
  77. package/dist/node/impls/fireflies-meeting-recorder.queries.js +3 -0
  78. package/dist/node/impls/fireflies-meeting-recorder.utils.js +3 -0
  79. package/dist/node/impls/gcs-storage.js +3 -0
  80. package/dist/node/impls/gmail-inbound.js +3 -0
  81. package/dist/node/impls/gmail-outbound.js +3 -0
  82. package/dist/node/impls/google-calendar.js +3 -0
  83. package/dist/node/impls/gradium-voice.js +3 -0
  84. package/dist/node/impls/granola-meeting-recorder.js +3 -0
  85. package/dist/node/impls/granola-meeting-recorder.mcp.js +3 -0
  86. package/dist/node/impls/health/base-health-provider.js +3 -0
  87. package/dist/node/impls/health/hybrid-health-providers.js +3 -0
  88. package/dist/node/impls/health/official-health-providers.js +3 -0
  89. package/dist/node/impls/health/provider-normalizers.js +3 -0
  90. package/dist/node/impls/health/providers.js +3 -0
  91. package/dist/node/impls/health-provider-factory.js +3 -0
  92. package/dist/node/impls/index.js +658 -0
  93. package/dist/node/impls/jira.js +3 -0
  94. package/dist/node/impls/linear.js +3 -0
  95. package/dist/node/impls/messaging-github.js +3 -0
  96. package/dist/node/impls/messaging-slack.js +3 -0
  97. package/dist/node/impls/messaging-whatsapp-meta.js +3 -0
  98. package/dist/node/impls/messaging-whatsapp-twilio.js +3 -0
  99. package/dist/node/impls/mistral-conversational.js +3 -0
  100. package/dist/node/impls/mistral-conversational.session.js +3 -0
  101. package/dist/node/impls/mistral-embedding.js +3 -0
  102. package/dist/node/impls/mistral-llm.js +3 -0
  103. package/dist/node/impls/mistral-stt.js +3 -0
  104. package/dist/node/impls/notion.js +3 -0
  105. package/dist/node/impls/posthog-reader.js +3 -0
  106. package/dist/node/impls/posthog-utils.js +3 -0
  107. package/dist/node/impls/posthog.js +3 -0
  108. package/dist/node/impls/postmark-email.js +3 -0
  109. package/dist/node/impls/powens-client.js +3 -0
  110. package/dist/node/impls/powens-openbanking.js +3 -0
  111. package/dist/node/impls/provider-factory.js +71 -0
  112. package/dist/node/impls/qdrant-vector.js +3 -0
  113. package/dist/node/impls/stripe-payments.js +3 -0
  114. package/dist/node/impls/supabase-psql.js +3 -0
  115. package/dist/node/impls/supabase-vector.js +3 -0
  116. package/dist/node/impls/tldv-meeting-recorder.js +3 -0
  117. package/dist/node/impls/twilio-sms.js +3 -0
  118. package/dist/node/index.js +658 -0
  119. package/dist/node/secrets/provider.js +3 -0
  120. package/dist/secrets/provider.js +2 -0
  121. package/package.json +71 -10
@@ -0,0 +1,580 @@
1
+ // @bun
2
+ var __require = import.meta.require;
3
+
4
+ // src/impls/composio-types.ts
5
+ var INTEGRATION_KEY_TO_TOOLKIT = {
6
+ payments: "stripe",
7
+ email: "gmail",
8
+ calendar: "googlecalendar",
9
+ sms: "twilio",
10
+ "messaging.slack": "slack",
11
+ "messaging.github": "github",
12
+ "messaging.discord": "discord",
13
+ "messaging.teams": "microsoft_teams",
14
+ "analytics.posthog": "posthog",
15
+ "project-management.linear": "linear",
16
+ "project-management.jira": "jira",
17
+ "project-management.notion": "notion",
18
+ "project-management.asana": "asana",
19
+ "project-management.trello": "trello",
20
+ "project-management.monday": "monday",
21
+ "storage.s3": "aws",
22
+ "storage.gcs": "google_cloud",
23
+ "storage.gdrive": "googledrive",
24
+ "storage.dropbox": "dropbox",
25
+ "storage.onedrive": "onedrive",
26
+ "crm.salesforce": "salesforce",
27
+ "crm.hubspot": "hubspot",
28
+ "crm.pipedrive": "pipedrive",
29
+ "database.supabase": "supabase",
30
+ "vectordb.supabase": "supabase",
31
+ "ai-llm": "openai"
32
+ };
33
+ var SESSION_TTL_MS = 30 * 60 * 1000;
34
+ function isSessionExpired(session) {
35
+ return Date.now() - session.createdAt > SESSION_TTL_MS;
36
+ }
37
+ function resolveToolkit(integrationKey) {
38
+ if (INTEGRATION_KEY_TO_TOOLKIT[integrationKey]) {
39
+ return INTEGRATION_KEY_TO_TOOLKIT[integrationKey];
40
+ }
41
+ for (const [prefix, toolkit] of Object.entries(INTEGRATION_KEY_TO_TOOLKIT)) {
42
+ if (integrationKey.startsWith(prefix)) {
43
+ return toolkit;
44
+ }
45
+ }
46
+ const parts = integrationKey.split(".");
47
+ const last = parts[parts.length - 1];
48
+ return parts.length > 1 && last ? last : integrationKey;
49
+ }
50
+
51
+ // src/impls/composio-mcp.ts
52
+ class ComposioMcpProvider {
53
+ sessions = new Map;
54
+ config;
55
+ composioInstance;
56
+ constructor(config) {
57
+ this.config = config;
58
+ }
59
+ async executeTool(toolName, args) {
60
+ const userId = args._userId ?? "default";
61
+ const session = await this.getOrCreateSession(userId);
62
+ try {
63
+ const response = await fetch(session.mcpUrl, {
64
+ method: "POST",
65
+ headers: {
66
+ "Content-Type": "application/json",
67
+ ...session.mcpHeaders
68
+ },
69
+ body: JSON.stringify({
70
+ jsonrpc: "2.0",
71
+ id: crypto.randomUUID(),
72
+ method: "tools/call",
73
+ params: { name: toolName, arguments: args }
74
+ })
75
+ });
76
+ if (!response.ok) {
77
+ return {
78
+ success: false,
79
+ error: `Composio MCP call failed: ${response.status} ${response.statusText}`
80
+ };
81
+ }
82
+ const result = await response.json();
83
+ if (result.error) {
84
+ return {
85
+ success: false,
86
+ error: result.error.message ?? "Unknown MCP error"
87
+ };
88
+ }
89
+ return { success: true, data: result.result };
90
+ } catch (error) {
91
+ return {
92
+ success: false,
93
+ error: error instanceof Error ? error.message : String(error)
94
+ };
95
+ }
96
+ }
97
+ async searchTools(query) {
98
+ const session = await this.getOrCreateSession("default");
99
+ try {
100
+ const response = await fetch(session.mcpUrl, {
101
+ method: "POST",
102
+ headers: {
103
+ "Content-Type": "application/json",
104
+ ...session.mcpHeaders
105
+ },
106
+ body: JSON.stringify({
107
+ jsonrpc: "2.0",
108
+ id: crypto.randomUUID(),
109
+ method: "tools/list",
110
+ params: {}
111
+ })
112
+ });
113
+ if (!response.ok)
114
+ return [];
115
+ const result = await response.json();
116
+ const tools = result.result?.tools ?? [];
117
+ return tools.filter((t) => t.name.toLowerCase().includes(query.toLowerCase()) || (t.description ?? "").toLowerCase().includes(query.toLowerCase())).map((t) => ({
118
+ name: t.name,
119
+ description: t.description ?? "",
120
+ toolkit: resolveToolkit(t.name.split("_")[0]?.toLowerCase() ?? ""),
121
+ parameters: t.inputSchema ?? {}
122
+ }));
123
+ } catch {
124
+ return [];
125
+ }
126
+ }
127
+ getMcpConfig(userId) {
128
+ const session = this.sessions.get(userId);
129
+ if (!session || isSessionExpired(session))
130
+ return;
131
+ return { url: session.mcpUrl, headers: session.mcpHeaders };
132
+ }
133
+ async getOrCreateSession(userId) {
134
+ const existing = this.sessions.get(userId);
135
+ if (existing && !isSessionExpired(existing)) {
136
+ return existing;
137
+ }
138
+ const client = await this.getClient();
139
+ const entity = await client.getEntity(userId);
140
+ const mcpUrl = entity.getMcpUrl();
141
+ const mcpHeaders = entity.getMcpHeaders();
142
+ const session = {
143
+ userId,
144
+ mcpUrl,
145
+ mcpHeaders,
146
+ createdAt: Date.now()
147
+ };
148
+ this.sessions.set(userId, session);
149
+ return session;
150
+ }
151
+ async getClient() {
152
+ if (this.composioInstance)
153
+ return this.composioInstance;
154
+ const { Composio } = await import("@composio/core");
155
+ this.composioInstance = new Composio({
156
+ apiKey: this.config.apiKey,
157
+ ...this.config.baseUrl ? { baseUrl: this.config.baseUrl } : {}
158
+ });
159
+ return this.composioInstance;
160
+ }
161
+ }
162
+
163
+ // src/impls/composio-sdk.ts
164
+ class ComposioSdkProvider {
165
+ config;
166
+ client;
167
+ constructor(config) {
168
+ this.config = config;
169
+ }
170
+ async executeTool(toolName, args) {
171
+ const client = await this.getClient();
172
+ const userId = args._userId ?? "default";
173
+ try {
174
+ const entity = await client.getEntity(userId);
175
+ const result = await entity.execute(toolName, args);
176
+ return { success: true, data: result };
177
+ } catch (error) {
178
+ return {
179
+ success: false,
180
+ error: error instanceof Error ? error.message : String(error)
181
+ };
182
+ }
183
+ }
184
+ async searchTools(query) {
185
+ const client = await this.getClient();
186
+ try {
187
+ const tools = await client.actions.list({ query, limit: 20 });
188
+ return tools.map((t) => ({
189
+ name: t.name,
190
+ description: t.description ?? "",
191
+ toolkit: t.appName ?? "",
192
+ parameters: t.parameters ?? {}
193
+ }));
194
+ } catch {
195
+ return [];
196
+ }
197
+ }
198
+ async getConnectedAccounts(userId) {
199
+ const client = await this.getClient();
200
+ try {
201
+ const entity = await client.getEntity(userId);
202
+ const connections = await entity.getConnections();
203
+ return connections.map((c) => ({
204
+ id: c.id,
205
+ appName: c.appName,
206
+ status: c.status
207
+ }));
208
+ } catch {
209
+ return [];
210
+ }
211
+ }
212
+ async getMcpConfig(userId) {
213
+ const client = await this.getClient();
214
+ try {
215
+ const entity = await client.getEntity(userId);
216
+ return {
217
+ url: entity.getMcpUrl(),
218
+ headers: entity.getMcpHeaders()
219
+ };
220
+ } catch {
221
+ return;
222
+ }
223
+ }
224
+ async getClient() {
225
+ if (this.client)
226
+ return this.client;
227
+ const { Composio } = await import("@composio/core");
228
+ this.client = new Composio({
229
+ apiKey: this.config.apiKey,
230
+ ...this.config.baseUrl ? { baseUrl: this.config.baseUrl } : {}
231
+ });
232
+ return this.client;
233
+ }
234
+ }
235
+
236
+ // src/impls/composio-proxies.ts
237
+ function composioToolName(toolkit, action) {
238
+ return `${toolkit.toUpperCase()}_${action.toUpperCase()}`;
239
+ }
240
+ function unwrapResult(result, fallback) {
241
+ if (!result.success) {
242
+ throw new Error(`Composio tool execution failed: ${result.error}`);
243
+ }
244
+ return result.data ?? fallback;
245
+ }
246
+
247
+ class ComposioMessagingProxy {
248
+ proxy;
249
+ toolkit;
250
+ constructor(proxy, toolkit) {
251
+ this.proxy = proxy;
252
+ this.toolkit = toolkit;
253
+ }
254
+ async sendMessage(input) {
255
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "SEND_MESSAGE"), {
256
+ channel: input.channelId,
257
+ thread_ts: input.threadId,
258
+ text: input.text,
259
+ recipient: input.recipientId
260
+ });
261
+ const data = unwrapResult(result, {});
262
+ return {
263
+ id: String(data.id ?? data.ts ?? crypto.randomUUID()),
264
+ providerMessageId: data.ts,
265
+ status: "sent",
266
+ sentAt: new Date
267
+ };
268
+ }
269
+ async updateMessage(messageId, input) {
270
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "UPDATE_MESSAGE"), {
271
+ message_id: messageId,
272
+ channel: input.channelId,
273
+ text: input.text
274
+ });
275
+ const data = unwrapResult(result, {});
276
+ return {
277
+ id: String(data.id ?? messageId),
278
+ status: "sent",
279
+ sentAt: new Date
280
+ };
281
+ }
282
+ }
283
+
284
+ class ComposioEmailProxy {
285
+ proxy;
286
+ toolkit;
287
+ constructor(proxy, toolkit) {
288
+ this.proxy = proxy;
289
+ this.toolkit = toolkit;
290
+ }
291
+ async sendEmail(message) {
292
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "SEND_EMAIL"), {
293
+ to: message.to.map((a) => a.email).join(","),
294
+ cc: message.cc?.map((a) => a.email).join(","),
295
+ bcc: message.bcc?.map((a) => a.email).join(","),
296
+ subject: message.subject,
297
+ body: message.htmlBody ?? message.textBody ?? "",
298
+ from: message.from.email
299
+ });
300
+ const data = unwrapResult(result, {});
301
+ return {
302
+ id: String(data.id ?? data.messageId ?? crypto.randomUUID()),
303
+ providerMessageId: data.messageId,
304
+ queuedAt: new Date
305
+ };
306
+ }
307
+ }
308
+
309
+ class ComposioPaymentsProxy {
310
+ proxy;
311
+ toolkit;
312
+ constructor(proxy, toolkit) {
313
+ this.proxy = proxy;
314
+ this.toolkit = toolkit;
315
+ }
316
+ async createCustomer(input) {
317
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CREATE_CUSTOMER"), { email: input.email, name: input.name, description: input.description });
318
+ const data = unwrapResult(result, {});
319
+ return {
320
+ id: String(data.id ?? crypto.randomUUID()),
321
+ email: data.email ?? input.email,
322
+ name: data.name ?? input.name
323
+ };
324
+ }
325
+ async getCustomer(customerId) {
326
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "GET_CUSTOMER"), { customer_id: customerId });
327
+ if (!result.success)
328
+ return null;
329
+ const data = result.data;
330
+ if (!data)
331
+ return null;
332
+ return {
333
+ id: String(data.id ?? customerId),
334
+ email: data.email,
335
+ name: data.name
336
+ };
337
+ }
338
+ async createPaymentIntent(input) {
339
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CREATE_PAYMENT_INTENT"), {
340
+ amount: input.amount.amount,
341
+ currency: input.amount.currency,
342
+ customer_id: input.customerId,
343
+ description: input.description
344
+ });
345
+ const data = unwrapResult(result, {});
346
+ return {
347
+ id: String(data.id ?? crypto.randomUUID()),
348
+ amount: input.amount,
349
+ status: data.status ?? "requires_payment_method",
350
+ customerId: input.customerId,
351
+ clientSecret: data.client_secret
352
+ };
353
+ }
354
+ async capturePayment(paymentIntentId, input) {
355
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CAPTURE_PAYMENT"), { payment_intent_id: paymentIntentId, amount: input?.amount?.amount });
356
+ const data = unwrapResult(result, {});
357
+ return {
358
+ id: paymentIntentId,
359
+ amount: input?.amount ?? { amount: 0, currency: "usd" },
360
+ status: data.status ?? "succeeded"
361
+ };
362
+ }
363
+ async cancelPaymentIntent(paymentIntentId) {
364
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CANCEL_PAYMENT_INTENT"), { payment_intent_id: paymentIntentId });
365
+ const data = unwrapResult(result, {});
366
+ return {
367
+ id: paymentIntentId,
368
+ amount: { amount: 0, currency: "usd" },
369
+ status: data.status ?? "canceled"
370
+ };
371
+ }
372
+ async refundPayment(input) {
373
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "REFUND_PAYMENT"), {
374
+ payment_intent_id: input.paymentIntentId,
375
+ amount: input.amount?.amount,
376
+ reason: input.reason
377
+ });
378
+ const data = unwrapResult(result, {});
379
+ return {
380
+ id: String(data.id ?? crypto.randomUUID()),
381
+ paymentIntentId: input.paymentIntentId,
382
+ amount: input.amount ?? { amount: 0, currency: "usd" },
383
+ status: "succeeded"
384
+ };
385
+ }
386
+ async listInvoices(_query) {
387
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "LIST_INVOICES"), { customer_id: _query?.customerId, limit: _query?.limit });
388
+ if (!result.success)
389
+ return [];
390
+ const items = result.data ?? [];
391
+ return items.map((i) => ({
392
+ id: String(i.id),
393
+ status: i.status ?? "open",
394
+ amountDue: {
395
+ amount: Number(i.amount_due ?? 0),
396
+ currency: String(i.currency ?? "usd")
397
+ }
398
+ }));
399
+ }
400
+ async listTransactions(_query) {
401
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "LIST_TRANSACTIONS"), { customer_id: _query?.customerId, limit: _query?.limit });
402
+ if (!result.success)
403
+ return [];
404
+ const items = result.data ?? [];
405
+ return items.map((i) => ({
406
+ id: String(i.id),
407
+ amount: {
408
+ amount: Number(i.amount ?? 0),
409
+ currency: String(i.currency ?? "usd")
410
+ },
411
+ type: "capture",
412
+ status: "succeeded",
413
+ createdAt: new Date
414
+ }));
415
+ }
416
+ }
417
+
418
+ class ComposioProjectManagementProxy {
419
+ proxy;
420
+ toolkit;
421
+ constructor(proxy, toolkit) {
422
+ this.proxy = proxy;
423
+ this.toolkit = toolkit;
424
+ }
425
+ async createWorkItem(input) {
426
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CREATE_ISSUE"), {
427
+ title: input.title,
428
+ description: input.description,
429
+ priority: input.priority,
430
+ assignee_id: input.assigneeId,
431
+ project_id: input.projectId,
432
+ labels: input.tags
433
+ });
434
+ const data = unwrapResult(result, {});
435
+ return {
436
+ id: String(data.id ?? data.key ?? crypto.randomUUID()),
437
+ title: input.title,
438
+ url: data.url,
439
+ status: data.status,
440
+ priority: input.priority,
441
+ tags: input.tags,
442
+ projectId: input.projectId
443
+ };
444
+ }
445
+ async createWorkItems(items) {
446
+ return Promise.all(items.map((item) => this.createWorkItem(item)));
447
+ }
448
+ }
449
+
450
+ class ComposioCalendarProxy {
451
+ proxy;
452
+ toolkit;
453
+ constructor(proxy, toolkit) {
454
+ this.proxy = proxy;
455
+ this.toolkit = toolkit;
456
+ }
457
+ async listEvents(query) {
458
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "LIST_EVENTS"), {
459
+ calendar_id: query.calendarId,
460
+ time_min: query.timeMin?.toISOString(),
461
+ time_max: query.timeMax?.toISOString(),
462
+ max_results: query.maxResults
463
+ });
464
+ if (!result.success)
465
+ return { events: [] };
466
+ const items = result.data ?? [];
467
+ return {
468
+ events: items.map((e) => ({
469
+ id: String(e.id),
470
+ calendarId: query.calendarId,
471
+ title: String(e.summary ?? e.title ?? ""),
472
+ start: new Date(String(e.start ?? Date.now())),
473
+ end: new Date(String(e.end ?? Date.now()))
474
+ }))
475
+ };
476
+ }
477
+ async createEvent(input) {
478
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CREATE_EVENT"), {
479
+ calendar_id: input.calendarId,
480
+ summary: input.title,
481
+ description: input.description,
482
+ location: input.location,
483
+ start: input.start.toISOString(),
484
+ end: input.end.toISOString(),
485
+ attendees: input.attendees?.map((a) => a.email)
486
+ });
487
+ const data = unwrapResult(result, {});
488
+ return {
489
+ id: String(data.id ?? crypto.randomUUID()),
490
+ calendarId: input.calendarId,
491
+ title: input.title,
492
+ start: input.start,
493
+ end: input.end
494
+ };
495
+ }
496
+ async updateEvent(calendarId, eventId, input) {
497
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "UPDATE_EVENT"), {
498
+ calendar_id: calendarId,
499
+ event_id: eventId,
500
+ summary: input.title,
501
+ description: input.description,
502
+ start: input.start?.toISOString(),
503
+ end: input.end?.toISOString()
504
+ });
505
+ const data = unwrapResult(result, {});
506
+ return {
507
+ id: eventId,
508
+ calendarId,
509
+ title: String(data.summary ?? input.title ?? ""),
510
+ start: input.start ?? new Date,
511
+ end: input.end ?? new Date
512
+ };
513
+ }
514
+ async deleteEvent(calendarId, eventId) {
515
+ await this.proxy.executeTool(composioToolName(this.toolkit, "DELETE_EVENT"), { calendar_id: calendarId, event_id: eventId });
516
+ }
517
+ }
518
+
519
+ class ComposioGenericProxy {
520
+ proxy;
521
+ toolkit;
522
+ constructor(proxy, toolkit) {
523
+ this.proxy = proxy;
524
+ this.toolkit = toolkit;
525
+ }
526
+ async executeTool(action, args) {
527
+ return this.proxy.executeTool(composioToolName(this.toolkit, action), args);
528
+ }
529
+ async searchTools(query) {
530
+ return this.proxy.searchTools(query);
531
+ }
532
+ getToolkit() {
533
+ return this.toolkit;
534
+ }
535
+ }
536
+
537
+ // src/impls/composio-fallback-resolver.ts
538
+ class ComposioFallbackResolver {
539
+ mcpProvider;
540
+ sdkProvider;
541
+ preferredTransport;
542
+ constructor(config) {
543
+ this.mcpProvider = new ComposioMcpProvider(config);
544
+ this.sdkProvider = new ComposioSdkProvider(config);
545
+ this.preferredTransport = config.preferredTransport;
546
+ }
547
+ canHandle(_integrationKey) {
548
+ return true;
549
+ }
550
+ createMessagingProxy(context) {
551
+ const toolkit = resolveToolkit(context.spec.meta.key);
552
+ return new ComposioMessagingProxy(this.getProxy(), toolkit);
553
+ }
554
+ createEmailProxy(context) {
555
+ const toolkit = resolveToolkit(context.spec.meta.key);
556
+ return new ComposioEmailProxy(this.getProxy(), toolkit);
557
+ }
558
+ createPaymentsProxy(context) {
559
+ const toolkit = resolveToolkit(context.spec.meta.key);
560
+ return new ComposioPaymentsProxy(this.getProxy(), toolkit);
561
+ }
562
+ createProjectManagementProxy(context) {
563
+ const toolkit = resolveToolkit(context.spec.meta.key);
564
+ return new ComposioProjectManagementProxy(this.getProxy(), toolkit);
565
+ }
566
+ createCalendarProxy(context) {
567
+ const toolkit = resolveToolkit(context.spec.meta.key);
568
+ return new ComposioCalendarProxy(this.getProxy(), toolkit);
569
+ }
570
+ createGenericProxy(context) {
571
+ const toolkit = resolveToolkit(context.spec.meta.key);
572
+ return new ComposioGenericProxy(this.getProxy(), toolkit);
573
+ }
574
+ getProxy() {
575
+ return this.preferredTransport === "sdk" ? this.sdkProvider : this.mcpProvider;
576
+ }
577
+ }
578
+ export {
579
+ ComposioFallbackResolver
580
+ };
@@ -0,0 +1,22 @@
1
+ import type { ComposioConfig, ComposioToolProxy, ComposioToolResult, ComposioToolDescriptor } from './composio-types';
2
+ /**
3
+ * Composio MCP transport provider.
4
+ *
5
+ * Creates Composio sessions and exposes tools via the MCP protocol,
6
+ * leveraging the existing MCP client infrastructure in lib.ai-agent.
7
+ * Sessions are cached per userId with a 30-minute TTL.
8
+ */
9
+ export declare class ComposioMcpProvider implements ComposioToolProxy {
10
+ private readonly sessions;
11
+ private readonly config;
12
+ private composioInstance;
13
+ constructor(config: ComposioConfig);
14
+ executeTool(toolName: string, args: Record<string, unknown>): Promise<ComposioToolResult>;
15
+ searchTools(query: string): Promise<ComposioToolDescriptor[]>;
16
+ getMcpConfig(userId: string): {
17
+ url: string;
18
+ headers: Record<string, string>;
19
+ } | undefined;
20
+ private getOrCreateSession;
21
+ private getClient;
22
+ }