@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
@@ -1,4 +1,6 @@
1
1
  // @bun
2
+ var __require = import.meta.require;
3
+
2
4
  // src/impls/async-event-queue.ts
3
5
  class AsyncEventQueue {
4
6
  values = [];
@@ -43,6 +45,581 @@ class AsyncEventQueue {
43
45
  }
44
46
  }
45
47
 
48
+ // src/impls/composio-types.ts
49
+ var INTEGRATION_KEY_TO_TOOLKIT = {
50
+ payments: "stripe",
51
+ email: "gmail",
52
+ calendar: "googlecalendar",
53
+ sms: "twilio",
54
+ "messaging.slack": "slack",
55
+ "messaging.github": "github",
56
+ "messaging.discord": "discord",
57
+ "messaging.teams": "microsoft_teams",
58
+ "analytics.posthog": "posthog",
59
+ "project-management.linear": "linear",
60
+ "project-management.jira": "jira",
61
+ "project-management.notion": "notion",
62
+ "project-management.asana": "asana",
63
+ "project-management.trello": "trello",
64
+ "project-management.monday": "monday",
65
+ "storage.s3": "aws",
66
+ "storage.gcs": "google_cloud",
67
+ "storage.gdrive": "googledrive",
68
+ "storage.dropbox": "dropbox",
69
+ "storage.onedrive": "onedrive",
70
+ "crm.salesforce": "salesforce",
71
+ "crm.hubspot": "hubspot",
72
+ "crm.pipedrive": "pipedrive",
73
+ "database.supabase": "supabase",
74
+ "vectordb.supabase": "supabase",
75
+ "ai-llm": "openai"
76
+ };
77
+ var SESSION_TTL_MS = 30 * 60 * 1000;
78
+ function isSessionExpired(session) {
79
+ return Date.now() - session.createdAt > SESSION_TTL_MS;
80
+ }
81
+ function resolveToolkit(integrationKey) {
82
+ if (INTEGRATION_KEY_TO_TOOLKIT[integrationKey]) {
83
+ return INTEGRATION_KEY_TO_TOOLKIT[integrationKey];
84
+ }
85
+ for (const [prefix, toolkit] of Object.entries(INTEGRATION_KEY_TO_TOOLKIT)) {
86
+ if (integrationKey.startsWith(prefix)) {
87
+ return toolkit;
88
+ }
89
+ }
90
+ const parts = integrationKey.split(".");
91
+ const last = parts[parts.length - 1];
92
+ return parts.length > 1 && last ? last : integrationKey;
93
+ }
94
+
95
+ // src/impls/composio-mcp.ts
96
+ class ComposioMcpProvider {
97
+ sessions = new Map;
98
+ config;
99
+ composioInstance;
100
+ constructor(config) {
101
+ this.config = config;
102
+ }
103
+ async executeTool(toolName, args) {
104
+ const userId = args._userId ?? "default";
105
+ const session = await this.getOrCreateSession(userId);
106
+ try {
107
+ const response = await fetch(session.mcpUrl, {
108
+ method: "POST",
109
+ headers: {
110
+ "Content-Type": "application/json",
111
+ ...session.mcpHeaders
112
+ },
113
+ body: JSON.stringify({
114
+ jsonrpc: "2.0",
115
+ id: crypto.randomUUID(),
116
+ method: "tools/call",
117
+ params: { name: toolName, arguments: args }
118
+ })
119
+ });
120
+ if (!response.ok) {
121
+ return {
122
+ success: false,
123
+ error: `Composio MCP call failed: ${response.status} ${response.statusText}`
124
+ };
125
+ }
126
+ const result = await response.json();
127
+ if (result.error) {
128
+ return {
129
+ success: false,
130
+ error: result.error.message ?? "Unknown MCP error"
131
+ };
132
+ }
133
+ return { success: true, data: result.result };
134
+ } catch (error) {
135
+ return {
136
+ success: false,
137
+ error: error instanceof Error ? error.message : String(error)
138
+ };
139
+ }
140
+ }
141
+ async searchTools(query) {
142
+ const session = await this.getOrCreateSession("default");
143
+ try {
144
+ const response = await fetch(session.mcpUrl, {
145
+ method: "POST",
146
+ headers: {
147
+ "Content-Type": "application/json",
148
+ ...session.mcpHeaders
149
+ },
150
+ body: JSON.stringify({
151
+ jsonrpc: "2.0",
152
+ id: crypto.randomUUID(),
153
+ method: "tools/list",
154
+ params: {}
155
+ })
156
+ });
157
+ if (!response.ok)
158
+ return [];
159
+ const result = await response.json();
160
+ const tools = result.result?.tools ?? [];
161
+ return tools.filter((t) => t.name.toLowerCase().includes(query.toLowerCase()) || (t.description ?? "").toLowerCase().includes(query.toLowerCase())).map((t) => ({
162
+ name: t.name,
163
+ description: t.description ?? "",
164
+ toolkit: resolveToolkit(t.name.split("_")[0]?.toLowerCase() ?? ""),
165
+ parameters: t.inputSchema ?? {}
166
+ }));
167
+ } catch {
168
+ return [];
169
+ }
170
+ }
171
+ getMcpConfig(userId) {
172
+ const session = this.sessions.get(userId);
173
+ if (!session || isSessionExpired(session))
174
+ return;
175
+ return { url: session.mcpUrl, headers: session.mcpHeaders };
176
+ }
177
+ async getOrCreateSession(userId) {
178
+ const existing = this.sessions.get(userId);
179
+ if (existing && !isSessionExpired(existing)) {
180
+ return existing;
181
+ }
182
+ const client = await this.getClient();
183
+ const entity = await client.getEntity(userId);
184
+ const mcpUrl = entity.getMcpUrl();
185
+ const mcpHeaders = entity.getMcpHeaders();
186
+ const session = {
187
+ userId,
188
+ mcpUrl,
189
+ mcpHeaders,
190
+ createdAt: Date.now()
191
+ };
192
+ this.sessions.set(userId, session);
193
+ return session;
194
+ }
195
+ async getClient() {
196
+ if (this.composioInstance)
197
+ return this.composioInstance;
198
+ const { Composio } = await import("@composio/core");
199
+ this.composioInstance = new Composio({
200
+ apiKey: this.config.apiKey,
201
+ ...this.config.baseUrl ? { baseUrl: this.config.baseUrl } : {}
202
+ });
203
+ return this.composioInstance;
204
+ }
205
+ }
206
+
207
+ // src/impls/composio-sdk.ts
208
+ class ComposioSdkProvider {
209
+ config;
210
+ client;
211
+ constructor(config) {
212
+ this.config = config;
213
+ }
214
+ async executeTool(toolName, args) {
215
+ const client = await this.getClient();
216
+ const userId = args._userId ?? "default";
217
+ try {
218
+ const entity = await client.getEntity(userId);
219
+ const result = await entity.execute(toolName, args);
220
+ return { success: true, data: result };
221
+ } catch (error) {
222
+ return {
223
+ success: false,
224
+ error: error instanceof Error ? error.message : String(error)
225
+ };
226
+ }
227
+ }
228
+ async searchTools(query) {
229
+ const client = await this.getClient();
230
+ try {
231
+ const tools = await client.actions.list({ query, limit: 20 });
232
+ return tools.map((t) => ({
233
+ name: t.name,
234
+ description: t.description ?? "",
235
+ toolkit: t.appName ?? "",
236
+ parameters: t.parameters ?? {}
237
+ }));
238
+ } catch {
239
+ return [];
240
+ }
241
+ }
242
+ async getConnectedAccounts(userId) {
243
+ const client = await this.getClient();
244
+ try {
245
+ const entity = await client.getEntity(userId);
246
+ const connections = await entity.getConnections();
247
+ return connections.map((c) => ({
248
+ id: c.id,
249
+ appName: c.appName,
250
+ status: c.status
251
+ }));
252
+ } catch {
253
+ return [];
254
+ }
255
+ }
256
+ async getMcpConfig(userId) {
257
+ const client = await this.getClient();
258
+ try {
259
+ const entity = await client.getEntity(userId);
260
+ return {
261
+ url: entity.getMcpUrl(),
262
+ headers: entity.getMcpHeaders()
263
+ };
264
+ } catch {
265
+ return;
266
+ }
267
+ }
268
+ async getClient() {
269
+ if (this.client)
270
+ return this.client;
271
+ const { Composio } = await import("@composio/core");
272
+ this.client = new Composio({
273
+ apiKey: this.config.apiKey,
274
+ ...this.config.baseUrl ? { baseUrl: this.config.baseUrl } : {}
275
+ });
276
+ return this.client;
277
+ }
278
+ }
279
+
280
+ // src/impls/composio-proxies.ts
281
+ function composioToolName(toolkit, action) {
282
+ return `${toolkit.toUpperCase()}_${action.toUpperCase()}`;
283
+ }
284
+ function unwrapResult(result, fallback) {
285
+ if (!result.success) {
286
+ throw new Error(`Composio tool execution failed: ${result.error}`);
287
+ }
288
+ return result.data ?? fallback;
289
+ }
290
+
291
+ class ComposioMessagingProxy {
292
+ proxy;
293
+ toolkit;
294
+ constructor(proxy, toolkit) {
295
+ this.proxy = proxy;
296
+ this.toolkit = toolkit;
297
+ }
298
+ async sendMessage(input) {
299
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "SEND_MESSAGE"), {
300
+ channel: input.channelId,
301
+ thread_ts: input.threadId,
302
+ text: input.text,
303
+ recipient: input.recipientId
304
+ });
305
+ const data = unwrapResult(result, {});
306
+ return {
307
+ id: String(data.id ?? data.ts ?? crypto.randomUUID()),
308
+ providerMessageId: data.ts,
309
+ status: "sent",
310
+ sentAt: new Date
311
+ };
312
+ }
313
+ async updateMessage(messageId, input) {
314
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "UPDATE_MESSAGE"), {
315
+ message_id: messageId,
316
+ channel: input.channelId,
317
+ text: input.text
318
+ });
319
+ const data = unwrapResult(result, {});
320
+ return {
321
+ id: String(data.id ?? messageId),
322
+ status: "sent",
323
+ sentAt: new Date
324
+ };
325
+ }
326
+ }
327
+
328
+ class ComposioEmailProxy {
329
+ proxy;
330
+ toolkit;
331
+ constructor(proxy, toolkit) {
332
+ this.proxy = proxy;
333
+ this.toolkit = toolkit;
334
+ }
335
+ async sendEmail(message) {
336
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "SEND_EMAIL"), {
337
+ to: message.to.map((a) => a.email).join(","),
338
+ cc: message.cc?.map((a) => a.email).join(","),
339
+ bcc: message.bcc?.map((a) => a.email).join(","),
340
+ subject: message.subject,
341
+ body: message.htmlBody ?? message.textBody ?? "",
342
+ from: message.from.email
343
+ });
344
+ const data = unwrapResult(result, {});
345
+ return {
346
+ id: String(data.id ?? data.messageId ?? crypto.randomUUID()),
347
+ providerMessageId: data.messageId,
348
+ queuedAt: new Date
349
+ };
350
+ }
351
+ }
352
+
353
+ class ComposioPaymentsProxy {
354
+ proxy;
355
+ toolkit;
356
+ constructor(proxy, toolkit) {
357
+ this.proxy = proxy;
358
+ this.toolkit = toolkit;
359
+ }
360
+ async createCustomer(input) {
361
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CREATE_CUSTOMER"), { email: input.email, name: input.name, description: input.description });
362
+ const data = unwrapResult(result, {});
363
+ return {
364
+ id: String(data.id ?? crypto.randomUUID()),
365
+ email: data.email ?? input.email,
366
+ name: data.name ?? input.name
367
+ };
368
+ }
369
+ async getCustomer(customerId) {
370
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "GET_CUSTOMER"), { customer_id: customerId });
371
+ if (!result.success)
372
+ return null;
373
+ const data = result.data;
374
+ if (!data)
375
+ return null;
376
+ return {
377
+ id: String(data.id ?? customerId),
378
+ email: data.email,
379
+ name: data.name
380
+ };
381
+ }
382
+ async createPaymentIntent(input) {
383
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CREATE_PAYMENT_INTENT"), {
384
+ amount: input.amount.amount,
385
+ currency: input.amount.currency,
386
+ customer_id: input.customerId,
387
+ description: input.description
388
+ });
389
+ const data = unwrapResult(result, {});
390
+ return {
391
+ id: String(data.id ?? crypto.randomUUID()),
392
+ amount: input.amount,
393
+ status: data.status ?? "requires_payment_method",
394
+ customerId: input.customerId,
395
+ clientSecret: data.client_secret
396
+ };
397
+ }
398
+ async capturePayment(paymentIntentId, input) {
399
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CAPTURE_PAYMENT"), { payment_intent_id: paymentIntentId, amount: input?.amount?.amount });
400
+ const data = unwrapResult(result, {});
401
+ return {
402
+ id: paymentIntentId,
403
+ amount: input?.amount ?? { amount: 0, currency: "usd" },
404
+ status: data.status ?? "succeeded"
405
+ };
406
+ }
407
+ async cancelPaymentIntent(paymentIntentId) {
408
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CANCEL_PAYMENT_INTENT"), { payment_intent_id: paymentIntentId });
409
+ const data = unwrapResult(result, {});
410
+ return {
411
+ id: paymentIntentId,
412
+ amount: { amount: 0, currency: "usd" },
413
+ status: data.status ?? "canceled"
414
+ };
415
+ }
416
+ async refundPayment(input) {
417
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "REFUND_PAYMENT"), {
418
+ payment_intent_id: input.paymentIntentId,
419
+ amount: input.amount?.amount,
420
+ reason: input.reason
421
+ });
422
+ const data = unwrapResult(result, {});
423
+ return {
424
+ id: String(data.id ?? crypto.randomUUID()),
425
+ paymentIntentId: input.paymentIntentId,
426
+ amount: input.amount ?? { amount: 0, currency: "usd" },
427
+ status: "succeeded"
428
+ };
429
+ }
430
+ async listInvoices(_query) {
431
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "LIST_INVOICES"), { customer_id: _query?.customerId, limit: _query?.limit });
432
+ if (!result.success)
433
+ return [];
434
+ const items = result.data ?? [];
435
+ return items.map((i) => ({
436
+ id: String(i.id),
437
+ status: i.status ?? "open",
438
+ amountDue: {
439
+ amount: Number(i.amount_due ?? 0),
440
+ currency: String(i.currency ?? "usd")
441
+ }
442
+ }));
443
+ }
444
+ async listTransactions(_query) {
445
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "LIST_TRANSACTIONS"), { customer_id: _query?.customerId, limit: _query?.limit });
446
+ if (!result.success)
447
+ return [];
448
+ const items = result.data ?? [];
449
+ return items.map((i) => ({
450
+ id: String(i.id),
451
+ amount: {
452
+ amount: Number(i.amount ?? 0),
453
+ currency: String(i.currency ?? "usd")
454
+ },
455
+ type: "capture",
456
+ status: "succeeded",
457
+ createdAt: new Date
458
+ }));
459
+ }
460
+ }
461
+
462
+ class ComposioProjectManagementProxy {
463
+ proxy;
464
+ toolkit;
465
+ constructor(proxy, toolkit) {
466
+ this.proxy = proxy;
467
+ this.toolkit = toolkit;
468
+ }
469
+ async createWorkItem(input) {
470
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CREATE_ISSUE"), {
471
+ title: input.title,
472
+ description: input.description,
473
+ priority: input.priority,
474
+ assignee_id: input.assigneeId,
475
+ project_id: input.projectId,
476
+ labels: input.tags
477
+ });
478
+ const data = unwrapResult(result, {});
479
+ return {
480
+ id: String(data.id ?? data.key ?? crypto.randomUUID()),
481
+ title: input.title,
482
+ url: data.url,
483
+ status: data.status,
484
+ priority: input.priority,
485
+ tags: input.tags,
486
+ projectId: input.projectId
487
+ };
488
+ }
489
+ async createWorkItems(items) {
490
+ return Promise.all(items.map((item) => this.createWorkItem(item)));
491
+ }
492
+ }
493
+
494
+ class ComposioCalendarProxy {
495
+ proxy;
496
+ toolkit;
497
+ constructor(proxy, toolkit) {
498
+ this.proxy = proxy;
499
+ this.toolkit = toolkit;
500
+ }
501
+ async listEvents(query) {
502
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "LIST_EVENTS"), {
503
+ calendar_id: query.calendarId,
504
+ time_min: query.timeMin?.toISOString(),
505
+ time_max: query.timeMax?.toISOString(),
506
+ max_results: query.maxResults
507
+ });
508
+ if (!result.success)
509
+ return { events: [] };
510
+ const items = result.data ?? [];
511
+ return {
512
+ events: items.map((e) => ({
513
+ id: String(e.id),
514
+ calendarId: query.calendarId,
515
+ title: String(e.summary ?? e.title ?? ""),
516
+ start: new Date(String(e.start ?? Date.now())),
517
+ end: new Date(String(e.end ?? Date.now()))
518
+ }))
519
+ };
520
+ }
521
+ async createEvent(input) {
522
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CREATE_EVENT"), {
523
+ calendar_id: input.calendarId,
524
+ summary: input.title,
525
+ description: input.description,
526
+ location: input.location,
527
+ start: input.start.toISOString(),
528
+ end: input.end.toISOString(),
529
+ attendees: input.attendees?.map((a) => a.email)
530
+ });
531
+ const data = unwrapResult(result, {});
532
+ return {
533
+ id: String(data.id ?? crypto.randomUUID()),
534
+ calendarId: input.calendarId,
535
+ title: input.title,
536
+ start: input.start,
537
+ end: input.end
538
+ };
539
+ }
540
+ async updateEvent(calendarId, eventId, input) {
541
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "UPDATE_EVENT"), {
542
+ calendar_id: calendarId,
543
+ event_id: eventId,
544
+ summary: input.title,
545
+ description: input.description,
546
+ start: input.start?.toISOString(),
547
+ end: input.end?.toISOString()
548
+ });
549
+ const data = unwrapResult(result, {});
550
+ return {
551
+ id: eventId,
552
+ calendarId,
553
+ title: String(data.summary ?? input.title ?? ""),
554
+ start: input.start ?? new Date,
555
+ end: input.end ?? new Date
556
+ };
557
+ }
558
+ async deleteEvent(calendarId, eventId) {
559
+ await this.proxy.executeTool(composioToolName(this.toolkit, "DELETE_EVENT"), { calendar_id: calendarId, event_id: eventId });
560
+ }
561
+ }
562
+
563
+ class ComposioGenericProxy {
564
+ proxy;
565
+ toolkit;
566
+ constructor(proxy, toolkit) {
567
+ this.proxy = proxy;
568
+ this.toolkit = toolkit;
569
+ }
570
+ async executeTool(action, args) {
571
+ return this.proxy.executeTool(composioToolName(this.toolkit, action), args);
572
+ }
573
+ async searchTools(query) {
574
+ return this.proxy.searchTools(query);
575
+ }
576
+ getToolkit() {
577
+ return this.toolkit;
578
+ }
579
+ }
580
+
581
+ // src/impls/composio-fallback-resolver.ts
582
+ class ComposioFallbackResolver {
583
+ mcpProvider;
584
+ sdkProvider;
585
+ preferredTransport;
586
+ constructor(config) {
587
+ this.mcpProvider = new ComposioMcpProvider(config);
588
+ this.sdkProvider = new ComposioSdkProvider(config);
589
+ this.preferredTransport = config.preferredTransport;
590
+ }
591
+ canHandle(_integrationKey) {
592
+ return true;
593
+ }
594
+ createMessagingProxy(context) {
595
+ const toolkit = resolveToolkit(context.spec.meta.key);
596
+ return new ComposioMessagingProxy(this.getProxy(), toolkit);
597
+ }
598
+ createEmailProxy(context) {
599
+ const toolkit = resolveToolkit(context.spec.meta.key);
600
+ return new ComposioEmailProxy(this.getProxy(), toolkit);
601
+ }
602
+ createPaymentsProxy(context) {
603
+ const toolkit = resolveToolkit(context.spec.meta.key);
604
+ return new ComposioPaymentsProxy(this.getProxy(), toolkit);
605
+ }
606
+ createProjectManagementProxy(context) {
607
+ const toolkit = resolveToolkit(context.spec.meta.key);
608
+ return new ComposioProjectManagementProxy(this.getProxy(), toolkit);
609
+ }
610
+ createCalendarProxy(context) {
611
+ const toolkit = resolveToolkit(context.spec.meta.key);
612
+ return new ComposioCalendarProxy(this.getProxy(), toolkit);
613
+ }
614
+ createGenericProxy(context) {
615
+ const toolkit = resolveToolkit(context.spec.meta.key);
616
+ return new ComposioGenericProxy(this.getProxy(), toolkit);
617
+ }
618
+ getProxy() {
619
+ return this.preferredTransport === "sdk" ? this.sdkProvider : this.mcpProvider;
620
+ }
621
+ }
622
+
46
623
  // src/impls/elevenlabs-voice.ts
47
624
  import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";
48
625
  var FORMAT_MAP = {
@@ -6408,9 +6985,29 @@ async function safeReadError4(response) {
6408
6985
 
6409
6986
  // src/impls/provider-factory.ts
6410
6987
  import { Buffer as Buffer6 } from "buffer";
6988
+ import { resolveIntegrationRequestContext } from "@contractspec/lib.contracts-integrations/integrations/runtime";
6989
+ import { buildAuthHeaders } from "@contractspec/lib.contracts-integrations/integrations/auth-helpers";
6990
+ import { findAuthConfig } from "@contractspec/lib.contracts-integrations/integrations/auth";
6411
6991
  var SECRET_CACHE = new Map;
6412
6992
 
6413
6993
  class IntegrationProviderFactory {
6994
+ composioFallback;
6995
+ constructor(options) {
6996
+ this.composioFallback = options?.composioFallback;
6997
+ }
6998
+ async resolveProviderContext(context) {
6999
+ const secrets = await this.loadSecrets(context);
7000
+ const { transport, authMethod, apiVersion } = resolveIntegrationRequestContext(context.spec, context.connection);
7001
+ let authHeaders = {};
7002
+ if (authMethod && context.spec.supportedAuthMethods) {
7003
+ const authConfig = findAuthConfig(context.spec.supportedAuthMethods, authMethod);
7004
+ if (authConfig) {
7005
+ const stringSecrets = Object.fromEntries(Object.entries(secrets).filter(([, v]) => typeof v === "string").map(([k, v]) => [k, v]));
7006
+ authHeaders = buildAuthHeaders(authConfig, stringSecrets);
7007
+ }
7008
+ }
7009
+ return { transport, authMethod, apiVersion, authHeaders, secrets };
7010
+ }
6414
7011
  async createPaymentsProvider(context) {
6415
7012
  const secrets = await this.loadSecrets(context);
6416
7013
  switch (context.spec.meta.key) {
@@ -6419,6 +7016,9 @@ class IntegrationProviderFactory {
6419
7016
  apiKey: requireSecret(secrets, "apiKey", "Stripe API key is required")
6420
7017
  });
6421
7018
  default:
7019
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7020
+ return this.composioFallback.createPaymentsProxy(context);
7021
+ }
6422
7022
  throw new Error(`Unsupported payments integration: ${context.spec.meta.key}`);
6423
7023
  }
6424
7024
  }
@@ -6432,6 +7032,9 @@ class IntegrationProviderFactory {
6432
7032
  messageStream: context.config.messageStream
6433
7033
  });
6434
7034
  default:
7035
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7036
+ return this.composioFallback.createEmailProxy(context);
7037
+ }
6435
7038
  throw new Error(`Unsupported email integration: ${context.spec.meta.key}`);
6436
7039
  }
6437
7040
  }
@@ -6445,6 +7048,9 @@ class IntegrationProviderFactory {
6445
7048
  fromNumber: context.config.fromNumber
6446
7049
  });
6447
7050
  default:
7051
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7052
+ return this.composioFallback.createMessagingProxy(context);
7053
+ }
6448
7054
  throw new Error(`Unsupported SMS integration: ${context.spec.meta.key}`);
6449
7055
  }
6450
7056
  }
@@ -6478,6 +7084,9 @@ class IntegrationProviderFactory {
6478
7084
  fromNumber: config?.fromNumber
6479
7085
  });
6480
7086
  default:
7087
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7088
+ return this.composioFallback.createMessagingProxy(context);
7089
+ }
6481
7090
  throw new Error(`Unsupported messaging integration: ${context.spec.meta.key}`);
6482
7091
  }
6483
7092
  }
@@ -6501,6 +7110,9 @@ class IntegrationProviderFactory {
6501
7110
  sslMode: config?.sslMode
6502
7111
  });
6503
7112
  default:
7113
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7114
+ return this.composioFallback.createGenericProxy(context);
7115
+ }
6504
7116
  throw new Error(`Unsupported vector store integration: ${context.spec.meta.key}`);
6505
7117
  }
6506
7118
  }
@@ -6517,6 +7129,9 @@ class IntegrationProviderFactory {
6517
7129
  personalApiKey: requireSecret(secrets, "personalApiKey", "PostHog personalApiKey is required")
6518
7130
  });
6519
7131
  default:
7132
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7133
+ return this.composioFallback.createGenericProxy(context);
7134
+ }
6520
7135
  throw new Error(`Unsupported analytics integration: ${context.spec.meta.key}`);
6521
7136
  }
6522
7137
  }
@@ -6531,6 +7146,9 @@ class IntegrationProviderFactory {
6531
7146
  sslMode: config?.sslMode
6532
7147
  });
6533
7148
  default:
7149
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7150
+ return this.composioFallback.createGenericProxy(context);
7151
+ }
6534
7152
  throw new Error(`Unsupported database integration: ${context.spec.meta.key}`);
6535
7153
  }
6536
7154
  }
@@ -6544,6 +7162,9 @@ class IntegrationProviderFactory {
6544
7162
  clientOptions: secrets.type === "service_account" ? { credentials: secrets } : undefined
6545
7163
  });
6546
7164
  default:
7165
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7166
+ return this.composioFallback.createGenericProxy(context);
7167
+ }
6547
7168
  throw new Error(`Unsupported storage integration: ${context.spec.meta.key}`);
6548
7169
  }
6549
7170
  }
@@ -6576,6 +7197,9 @@ class IntegrationProviderFactory {
6576
7197
  pollIntervalMs: config?.pollIntervalMs
6577
7198
  });
6578
7199
  default:
7200
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7201
+ return this.composioFallback.createGenericProxy(context);
7202
+ }
6579
7203
  throw new Error(`Unsupported voice integration: ${context.spec.meta.key}`);
6580
7204
  }
6581
7205
  }
@@ -6591,6 +7215,9 @@ class IntegrationProviderFactory {
6591
7215
  serverURL: config?.serverURL
6592
7216
  });
6593
7217
  default:
7218
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7219
+ return this.composioFallback.createGenericProxy(context);
7220
+ }
6594
7221
  throw new Error(`Unsupported STT integration: ${context.spec.meta.key}`);
6595
7222
  }
6596
7223
  }
@@ -6611,6 +7238,9 @@ class IntegrationProviderFactory {
6611
7238
  }
6612
7239
  });
6613
7240
  default:
7241
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7242
+ return this.composioFallback.createGenericProxy(context);
7243
+ }
6614
7244
  throw new Error(`Unsupported conversational integration: ${context.spec.meta.key}`);
6615
7245
  }
6616
7246
  }
@@ -6651,6 +7281,9 @@ class IntegrationProviderFactory {
6651
7281
  descriptionProperty: config?.descriptionProperty
6652
7282
  });
6653
7283
  default:
7284
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7285
+ return this.composioFallback.createProjectManagementProxy(context);
7286
+ }
6654
7287
  throw new Error(`Unsupported project management integration: ${context.spec.meta.key}`);
6655
7288
  }
6656
7289
  }
@@ -6699,6 +7332,9 @@ class IntegrationProviderFactory {
6699
7332
  webhookSecret: secrets.webhookSecret
6700
7333
  });
6701
7334
  default:
7335
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7336
+ return this.composioFallback.createGenericProxy(context);
7337
+ }
6702
7338
  throw new Error(`Unsupported meeting recorder integration: ${context.spec.meta.key}`);
6703
7339
  }
6704
7340
  }
@@ -6711,6 +7347,9 @@ class IntegrationProviderFactory {
6711
7347
  defaultModel: context.config.model
6712
7348
  });
6713
7349
  default:
7350
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7351
+ return this.composioFallback.createGenericProxy(context);
7352
+ }
6714
7353
  throw new Error(`Unsupported LLM integration: ${context.spec.meta.key}`);
6715
7354
  }
6716
7355
  }
@@ -6723,6 +7362,9 @@ class IntegrationProviderFactory {
6723
7362
  defaultModel: context.config.embeddingModel
6724
7363
  });
6725
7364
  default:
7365
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7366
+ return this.composioFallback.createGenericProxy(context);
7367
+ }
6726
7368
  throw new Error(`Unsupported embeddings integration: ${context.spec.meta.key}`);
6727
7369
  }
6728
7370
  }
@@ -6744,6 +7386,9 @@ class IntegrationProviderFactory {
6744
7386
  });
6745
7387
  }
6746
7388
  default:
7389
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7390
+ return this.composioFallback.createGenericProxy(context);
7391
+ }
6747
7392
  throw new Error(`Unsupported open banking integration: ${context.spec.meta.key}`);
6748
7393
  }
6749
7394
  }
@@ -6796,6 +7441,8 @@ function requireConfig(context, key, message) {
6796
7441
  return value;
6797
7442
  }
6798
7443
  export {
7444
+ resolveToolkit,
7445
+ isSessionExpired,
6799
7446
  createHealthProviderFromContext,
6800
7447
  WhoopHealthProvider,
6801
7448
  UnofficialHealthAutomationProvider,
@@ -6827,6 +7474,7 @@ export {
6827
7474
  LinearProjectManagementProvider,
6828
7475
  JiraProjectManagementProvider,
6829
7476
  IntegrationProviderFactory,
7477
+ INTEGRATION_KEY_TO_TOOLKIT,
6830
7478
  GranolaMeetingRecorderProvider,
6831
7479
  GradiumVoiceProvider,
6832
7480
  GoogleCloudStorageProvider,
@@ -6841,5 +7489,14 @@ export {
6841
7489
  FalVoiceProvider,
6842
7490
  ElevenLabsVoiceProvider,
6843
7491
  EightSleepHealthProvider,
7492
+ ComposioSdkProvider,
7493
+ ComposioProjectManagementProxy,
7494
+ ComposioPaymentsProxy,
7495
+ ComposioMessagingProxy,
7496
+ ComposioMcpProvider,
7497
+ ComposioGenericProxy,
7498
+ ComposioFallbackResolver,
7499
+ ComposioEmailProxy,
7500
+ ComposioCalendarProxy,
6844
7501
  AppleHealthBridgeProvider
6845
7502
  };