@contractspec/integration.providers-impls 3.8.9 → 3.8.11

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