@contractspec/integration.providers-impls 3.0.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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,3 +1,6 @@
1
+ import { createRequire } from "node:module";
2
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
+
1
4
  // src/analytics.ts
2
5
  export * from "@contractspec/lib.contracts-integrations";
3
6
 
@@ -60,6 +63,581 @@ class AsyncEventQueue {
60
63
  }
61
64
  }
62
65
 
66
+ // src/impls/composio-types.ts
67
+ var INTEGRATION_KEY_TO_TOOLKIT = {
68
+ payments: "stripe",
69
+ email: "gmail",
70
+ calendar: "googlecalendar",
71
+ sms: "twilio",
72
+ "messaging.slack": "slack",
73
+ "messaging.github": "github",
74
+ "messaging.discord": "discord",
75
+ "messaging.teams": "microsoft_teams",
76
+ "analytics.posthog": "posthog",
77
+ "project-management.linear": "linear",
78
+ "project-management.jira": "jira",
79
+ "project-management.notion": "notion",
80
+ "project-management.asana": "asana",
81
+ "project-management.trello": "trello",
82
+ "project-management.monday": "monday",
83
+ "storage.s3": "aws",
84
+ "storage.gcs": "google_cloud",
85
+ "storage.gdrive": "googledrive",
86
+ "storage.dropbox": "dropbox",
87
+ "storage.onedrive": "onedrive",
88
+ "crm.salesforce": "salesforce",
89
+ "crm.hubspot": "hubspot",
90
+ "crm.pipedrive": "pipedrive",
91
+ "database.supabase": "supabase",
92
+ "vectordb.supabase": "supabase",
93
+ "ai-llm": "openai"
94
+ };
95
+ var SESSION_TTL_MS = 30 * 60 * 1000;
96
+ function isSessionExpired(session) {
97
+ return Date.now() - session.createdAt > SESSION_TTL_MS;
98
+ }
99
+ function resolveToolkit(integrationKey) {
100
+ if (INTEGRATION_KEY_TO_TOOLKIT[integrationKey]) {
101
+ return INTEGRATION_KEY_TO_TOOLKIT[integrationKey];
102
+ }
103
+ for (const [prefix, toolkit] of Object.entries(INTEGRATION_KEY_TO_TOOLKIT)) {
104
+ if (integrationKey.startsWith(prefix)) {
105
+ return toolkit;
106
+ }
107
+ }
108
+ const parts = integrationKey.split(".");
109
+ const last = parts[parts.length - 1];
110
+ return parts.length > 1 && last ? last : integrationKey;
111
+ }
112
+
113
+ // src/impls/composio-mcp.ts
114
+ class ComposioMcpProvider {
115
+ sessions = new Map;
116
+ config;
117
+ composioInstance;
118
+ constructor(config) {
119
+ this.config = config;
120
+ }
121
+ async executeTool(toolName, args) {
122
+ const userId = args._userId ?? "default";
123
+ const session = await this.getOrCreateSession(userId);
124
+ try {
125
+ const response = await fetch(session.mcpUrl, {
126
+ method: "POST",
127
+ headers: {
128
+ "Content-Type": "application/json",
129
+ ...session.mcpHeaders
130
+ },
131
+ body: JSON.stringify({
132
+ jsonrpc: "2.0",
133
+ id: crypto.randomUUID(),
134
+ method: "tools/call",
135
+ params: { name: toolName, arguments: args }
136
+ })
137
+ });
138
+ if (!response.ok) {
139
+ return {
140
+ success: false,
141
+ error: `Composio MCP call failed: ${response.status} ${response.statusText}`
142
+ };
143
+ }
144
+ const result = await response.json();
145
+ if (result.error) {
146
+ return {
147
+ success: false,
148
+ error: result.error.message ?? "Unknown MCP error"
149
+ };
150
+ }
151
+ return { success: true, data: result.result };
152
+ } catch (error) {
153
+ return {
154
+ success: false,
155
+ error: error instanceof Error ? error.message : String(error)
156
+ };
157
+ }
158
+ }
159
+ async searchTools(query) {
160
+ const session = await this.getOrCreateSession("default");
161
+ try {
162
+ const response = await fetch(session.mcpUrl, {
163
+ method: "POST",
164
+ headers: {
165
+ "Content-Type": "application/json",
166
+ ...session.mcpHeaders
167
+ },
168
+ body: JSON.stringify({
169
+ jsonrpc: "2.0",
170
+ id: crypto.randomUUID(),
171
+ method: "tools/list",
172
+ params: {}
173
+ })
174
+ });
175
+ if (!response.ok)
176
+ return [];
177
+ const result = await response.json();
178
+ const tools = result.result?.tools ?? [];
179
+ return tools.filter((t) => t.name.toLowerCase().includes(query.toLowerCase()) || (t.description ?? "").toLowerCase().includes(query.toLowerCase())).map((t) => ({
180
+ name: t.name,
181
+ description: t.description ?? "",
182
+ toolkit: resolveToolkit(t.name.split("_")[0]?.toLowerCase() ?? ""),
183
+ parameters: t.inputSchema ?? {}
184
+ }));
185
+ } catch {
186
+ return [];
187
+ }
188
+ }
189
+ getMcpConfig(userId) {
190
+ const session = this.sessions.get(userId);
191
+ if (!session || isSessionExpired(session))
192
+ return;
193
+ return { url: session.mcpUrl, headers: session.mcpHeaders };
194
+ }
195
+ async getOrCreateSession(userId) {
196
+ const existing = this.sessions.get(userId);
197
+ if (existing && !isSessionExpired(existing)) {
198
+ return existing;
199
+ }
200
+ const client = await this.getClient();
201
+ const entity = await client.getEntity(userId);
202
+ const mcpUrl = entity.getMcpUrl();
203
+ const mcpHeaders = entity.getMcpHeaders();
204
+ const session = {
205
+ userId,
206
+ mcpUrl,
207
+ mcpHeaders,
208
+ createdAt: Date.now()
209
+ };
210
+ this.sessions.set(userId, session);
211
+ return session;
212
+ }
213
+ async getClient() {
214
+ if (this.composioInstance)
215
+ return this.composioInstance;
216
+ const { Composio } = await import("@composio/core");
217
+ this.composioInstance = new Composio({
218
+ apiKey: this.config.apiKey,
219
+ ...this.config.baseUrl ? { baseUrl: this.config.baseUrl } : {}
220
+ });
221
+ return this.composioInstance;
222
+ }
223
+ }
224
+
225
+ // src/impls/composio-sdk.ts
226
+ class ComposioSdkProvider {
227
+ config;
228
+ client;
229
+ constructor(config) {
230
+ this.config = config;
231
+ }
232
+ async executeTool(toolName, args) {
233
+ const client = await this.getClient();
234
+ const userId = args._userId ?? "default";
235
+ try {
236
+ const entity = await client.getEntity(userId);
237
+ const result = await entity.execute(toolName, args);
238
+ return { success: true, data: result };
239
+ } catch (error) {
240
+ return {
241
+ success: false,
242
+ error: error instanceof Error ? error.message : String(error)
243
+ };
244
+ }
245
+ }
246
+ async searchTools(query) {
247
+ const client = await this.getClient();
248
+ try {
249
+ const tools = await client.actions.list({ query, limit: 20 });
250
+ return tools.map((t) => ({
251
+ name: t.name,
252
+ description: t.description ?? "",
253
+ toolkit: t.appName ?? "",
254
+ parameters: t.parameters ?? {}
255
+ }));
256
+ } catch {
257
+ return [];
258
+ }
259
+ }
260
+ async getConnectedAccounts(userId) {
261
+ const client = await this.getClient();
262
+ try {
263
+ const entity = await client.getEntity(userId);
264
+ const connections = await entity.getConnections();
265
+ return connections.map((c) => ({
266
+ id: c.id,
267
+ appName: c.appName,
268
+ status: c.status
269
+ }));
270
+ } catch {
271
+ return [];
272
+ }
273
+ }
274
+ async getMcpConfig(userId) {
275
+ const client = await this.getClient();
276
+ try {
277
+ const entity = await client.getEntity(userId);
278
+ return {
279
+ url: entity.getMcpUrl(),
280
+ headers: entity.getMcpHeaders()
281
+ };
282
+ } catch {
283
+ return;
284
+ }
285
+ }
286
+ async getClient() {
287
+ if (this.client)
288
+ return this.client;
289
+ const { Composio } = await import("@composio/core");
290
+ this.client = new Composio({
291
+ apiKey: this.config.apiKey,
292
+ ...this.config.baseUrl ? { baseUrl: this.config.baseUrl } : {}
293
+ });
294
+ return this.client;
295
+ }
296
+ }
297
+
298
+ // src/impls/composio-proxies.ts
299
+ function composioToolName(toolkit, action) {
300
+ return `${toolkit.toUpperCase()}_${action.toUpperCase()}`;
301
+ }
302
+ function unwrapResult(result, fallback) {
303
+ if (!result.success) {
304
+ throw new Error(`Composio tool execution failed: ${result.error}`);
305
+ }
306
+ return result.data ?? fallback;
307
+ }
308
+
309
+ class ComposioMessagingProxy {
310
+ proxy;
311
+ toolkit;
312
+ constructor(proxy, toolkit) {
313
+ this.proxy = proxy;
314
+ this.toolkit = toolkit;
315
+ }
316
+ async sendMessage(input) {
317
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "SEND_MESSAGE"), {
318
+ channel: input.channelId,
319
+ thread_ts: input.threadId,
320
+ text: input.text,
321
+ recipient: input.recipientId
322
+ });
323
+ const data = unwrapResult(result, {});
324
+ return {
325
+ id: String(data.id ?? data.ts ?? crypto.randomUUID()),
326
+ providerMessageId: data.ts,
327
+ status: "sent",
328
+ sentAt: new Date
329
+ };
330
+ }
331
+ async updateMessage(messageId, input) {
332
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "UPDATE_MESSAGE"), {
333
+ message_id: messageId,
334
+ channel: input.channelId,
335
+ text: input.text
336
+ });
337
+ const data = unwrapResult(result, {});
338
+ return {
339
+ id: String(data.id ?? messageId),
340
+ status: "sent",
341
+ sentAt: new Date
342
+ };
343
+ }
344
+ }
345
+
346
+ class ComposioEmailProxy {
347
+ proxy;
348
+ toolkit;
349
+ constructor(proxy, toolkit) {
350
+ this.proxy = proxy;
351
+ this.toolkit = toolkit;
352
+ }
353
+ async sendEmail(message) {
354
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "SEND_EMAIL"), {
355
+ to: message.to.map((a) => a.email).join(","),
356
+ cc: message.cc?.map((a) => a.email).join(","),
357
+ bcc: message.bcc?.map((a) => a.email).join(","),
358
+ subject: message.subject,
359
+ body: message.htmlBody ?? message.textBody ?? "",
360
+ from: message.from.email
361
+ });
362
+ const data = unwrapResult(result, {});
363
+ return {
364
+ id: String(data.id ?? data.messageId ?? crypto.randomUUID()),
365
+ providerMessageId: data.messageId,
366
+ queuedAt: new Date
367
+ };
368
+ }
369
+ }
370
+
371
+ class ComposioPaymentsProxy {
372
+ proxy;
373
+ toolkit;
374
+ constructor(proxy, toolkit) {
375
+ this.proxy = proxy;
376
+ this.toolkit = toolkit;
377
+ }
378
+ async createCustomer(input) {
379
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CREATE_CUSTOMER"), { email: input.email, name: input.name, description: input.description });
380
+ const data = unwrapResult(result, {});
381
+ return {
382
+ id: String(data.id ?? crypto.randomUUID()),
383
+ email: data.email ?? input.email,
384
+ name: data.name ?? input.name
385
+ };
386
+ }
387
+ async getCustomer(customerId) {
388
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "GET_CUSTOMER"), { customer_id: customerId });
389
+ if (!result.success)
390
+ return null;
391
+ const data = result.data;
392
+ if (!data)
393
+ return null;
394
+ return {
395
+ id: String(data.id ?? customerId),
396
+ email: data.email,
397
+ name: data.name
398
+ };
399
+ }
400
+ async createPaymentIntent(input) {
401
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CREATE_PAYMENT_INTENT"), {
402
+ amount: input.amount.amount,
403
+ currency: input.amount.currency,
404
+ customer_id: input.customerId,
405
+ description: input.description
406
+ });
407
+ const data = unwrapResult(result, {});
408
+ return {
409
+ id: String(data.id ?? crypto.randomUUID()),
410
+ amount: input.amount,
411
+ status: data.status ?? "requires_payment_method",
412
+ customerId: input.customerId,
413
+ clientSecret: data.client_secret
414
+ };
415
+ }
416
+ async capturePayment(paymentIntentId, input) {
417
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CAPTURE_PAYMENT"), { payment_intent_id: paymentIntentId, amount: input?.amount?.amount });
418
+ const data = unwrapResult(result, {});
419
+ return {
420
+ id: paymentIntentId,
421
+ amount: input?.amount ?? { amount: 0, currency: "usd" },
422
+ status: data.status ?? "succeeded"
423
+ };
424
+ }
425
+ async cancelPaymentIntent(paymentIntentId) {
426
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CANCEL_PAYMENT_INTENT"), { payment_intent_id: paymentIntentId });
427
+ const data = unwrapResult(result, {});
428
+ return {
429
+ id: paymentIntentId,
430
+ amount: { amount: 0, currency: "usd" },
431
+ status: data.status ?? "canceled"
432
+ };
433
+ }
434
+ async refundPayment(input) {
435
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "REFUND_PAYMENT"), {
436
+ payment_intent_id: input.paymentIntentId,
437
+ amount: input.amount?.amount,
438
+ reason: input.reason
439
+ });
440
+ const data = unwrapResult(result, {});
441
+ return {
442
+ id: String(data.id ?? crypto.randomUUID()),
443
+ paymentIntentId: input.paymentIntentId,
444
+ amount: input.amount ?? { amount: 0, currency: "usd" },
445
+ status: "succeeded"
446
+ };
447
+ }
448
+ async listInvoices(_query) {
449
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "LIST_INVOICES"), { customer_id: _query?.customerId, limit: _query?.limit });
450
+ if (!result.success)
451
+ return [];
452
+ const items = result.data ?? [];
453
+ return items.map((i) => ({
454
+ id: String(i.id),
455
+ status: i.status ?? "open",
456
+ amountDue: {
457
+ amount: Number(i.amount_due ?? 0),
458
+ currency: String(i.currency ?? "usd")
459
+ }
460
+ }));
461
+ }
462
+ async listTransactions(_query) {
463
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "LIST_TRANSACTIONS"), { customer_id: _query?.customerId, limit: _query?.limit });
464
+ if (!result.success)
465
+ return [];
466
+ const items = result.data ?? [];
467
+ return items.map((i) => ({
468
+ id: String(i.id),
469
+ amount: {
470
+ amount: Number(i.amount ?? 0),
471
+ currency: String(i.currency ?? "usd")
472
+ },
473
+ type: "capture",
474
+ status: "succeeded",
475
+ createdAt: new Date
476
+ }));
477
+ }
478
+ }
479
+
480
+ class ComposioProjectManagementProxy {
481
+ proxy;
482
+ toolkit;
483
+ constructor(proxy, toolkit) {
484
+ this.proxy = proxy;
485
+ this.toolkit = toolkit;
486
+ }
487
+ async createWorkItem(input) {
488
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CREATE_ISSUE"), {
489
+ title: input.title,
490
+ description: input.description,
491
+ priority: input.priority,
492
+ assignee_id: input.assigneeId,
493
+ project_id: input.projectId,
494
+ labels: input.tags
495
+ });
496
+ const data = unwrapResult(result, {});
497
+ return {
498
+ id: String(data.id ?? data.key ?? crypto.randomUUID()),
499
+ title: input.title,
500
+ url: data.url,
501
+ status: data.status,
502
+ priority: input.priority,
503
+ tags: input.tags,
504
+ projectId: input.projectId
505
+ };
506
+ }
507
+ async createWorkItems(items) {
508
+ return Promise.all(items.map((item) => this.createWorkItem(item)));
509
+ }
510
+ }
511
+
512
+ class ComposioCalendarProxy {
513
+ proxy;
514
+ toolkit;
515
+ constructor(proxy, toolkit) {
516
+ this.proxy = proxy;
517
+ this.toolkit = toolkit;
518
+ }
519
+ async listEvents(query) {
520
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "LIST_EVENTS"), {
521
+ calendar_id: query.calendarId,
522
+ time_min: query.timeMin?.toISOString(),
523
+ time_max: query.timeMax?.toISOString(),
524
+ max_results: query.maxResults
525
+ });
526
+ if (!result.success)
527
+ return { events: [] };
528
+ const items = result.data ?? [];
529
+ return {
530
+ events: items.map((e) => ({
531
+ id: String(e.id),
532
+ calendarId: query.calendarId,
533
+ title: String(e.summary ?? e.title ?? ""),
534
+ start: new Date(String(e.start ?? Date.now())),
535
+ end: new Date(String(e.end ?? Date.now()))
536
+ }))
537
+ };
538
+ }
539
+ async createEvent(input) {
540
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CREATE_EVENT"), {
541
+ calendar_id: input.calendarId,
542
+ summary: input.title,
543
+ description: input.description,
544
+ location: input.location,
545
+ start: input.start.toISOString(),
546
+ end: input.end.toISOString(),
547
+ attendees: input.attendees?.map((a) => a.email)
548
+ });
549
+ const data = unwrapResult(result, {});
550
+ return {
551
+ id: String(data.id ?? crypto.randomUUID()),
552
+ calendarId: input.calendarId,
553
+ title: input.title,
554
+ start: input.start,
555
+ end: input.end
556
+ };
557
+ }
558
+ async updateEvent(calendarId, eventId, input) {
559
+ const result = await this.proxy.executeTool(composioToolName(this.toolkit, "UPDATE_EVENT"), {
560
+ calendar_id: calendarId,
561
+ event_id: eventId,
562
+ summary: input.title,
563
+ description: input.description,
564
+ start: input.start?.toISOString(),
565
+ end: input.end?.toISOString()
566
+ });
567
+ const data = unwrapResult(result, {});
568
+ return {
569
+ id: eventId,
570
+ calendarId,
571
+ title: String(data.summary ?? input.title ?? ""),
572
+ start: input.start ?? new Date,
573
+ end: input.end ?? new Date
574
+ };
575
+ }
576
+ async deleteEvent(calendarId, eventId) {
577
+ await this.proxy.executeTool(composioToolName(this.toolkit, "DELETE_EVENT"), { calendar_id: calendarId, event_id: eventId });
578
+ }
579
+ }
580
+
581
+ class ComposioGenericProxy {
582
+ proxy;
583
+ toolkit;
584
+ constructor(proxy, toolkit) {
585
+ this.proxy = proxy;
586
+ this.toolkit = toolkit;
587
+ }
588
+ async executeTool(action, args) {
589
+ return this.proxy.executeTool(composioToolName(this.toolkit, action), args);
590
+ }
591
+ async searchTools(query) {
592
+ return this.proxy.searchTools(query);
593
+ }
594
+ getToolkit() {
595
+ return this.toolkit;
596
+ }
597
+ }
598
+
599
+ // src/impls/composio-fallback-resolver.ts
600
+ class ComposioFallbackResolver {
601
+ mcpProvider;
602
+ sdkProvider;
603
+ preferredTransport;
604
+ constructor(config) {
605
+ this.mcpProvider = new ComposioMcpProvider(config);
606
+ this.sdkProvider = new ComposioSdkProvider(config);
607
+ this.preferredTransport = config.preferredTransport;
608
+ }
609
+ canHandle(_integrationKey) {
610
+ return true;
611
+ }
612
+ createMessagingProxy(context) {
613
+ const toolkit = resolveToolkit(context.spec.meta.key);
614
+ return new ComposioMessagingProxy(this.getProxy(), toolkit);
615
+ }
616
+ createEmailProxy(context) {
617
+ const toolkit = resolveToolkit(context.spec.meta.key);
618
+ return new ComposioEmailProxy(this.getProxy(), toolkit);
619
+ }
620
+ createPaymentsProxy(context) {
621
+ const toolkit = resolveToolkit(context.spec.meta.key);
622
+ return new ComposioPaymentsProxy(this.getProxy(), toolkit);
623
+ }
624
+ createProjectManagementProxy(context) {
625
+ const toolkit = resolveToolkit(context.spec.meta.key);
626
+ return new ComposioProjectManagementProxy(this.getProxy(), toolkit);
627
+ }
628
+ createCalendarProxy(context) {
629
+ const toolkit = resolveToolkit(context.spec.meta.key);
630
+ return new ComposioCalendarProxy(this.getProxy(), toolkit);
631
+ }
632
+ createGenericProxy(context) {
633
+ const toolkit = resolveToolkit(context.spec.meta.key);
634
+ return new ComposioGenericProxy(this.getProxy(), toolkit);
635
+ }
636
+ getProxy() {
637
+ return this.preferredTransport === "sdk" ? this.sdkProvider : this.mcpProvider;
638
+ }
639
+ }
640
+
63
641
  // src/impls/elevenlabs-voice.ts
64
642
  import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";
65
643
  var FORMAT_MAP = {
@@ -6425,9 +7003,29 @@ async function safeReadError4(response) {
6425
7003
 
6426
7004
  // src/impls/provider-factory.ts
6427
7005
  import { Buffer as Buffer6 } from "node:buffer";
7006
+ import { resolveIntegrationRequestContext } from "@contractspec/lib.contracts-integrations/integrations/runtime";
7007
+ import { buildAuthHeaders } from "@contractspec/lib.contracts-integrations/integrations/auth-helpers";
7008
+ import { findAuthConfig } from "@contractspec/lib.contracts-integrations/integrations/auth";
6428
7009
  var SECRET_CACHE = new Map;
6429
7010
 
6430
7011
  class IntegrationProviderFactory {
7012
+ composioFallback;
7013
+ constructor(options) {
7014
+ this.composioFallback = options?.composioFallback;
7015
+ }
7016
+ async resolveProviderContext(context) {
7017
+ const secrets = await this.loadSecrets(context);
7018
+ const { transport, authMethod, apiVersion } = resolveIntegrationRequestContext(context.spec, context.connection);
7019
+ let authHeaders = {};
7020
+ if (authMethod && context.spec.supportedAuthMethods) {
7021
+ const authConfig = findAuthConfig(context.spec.supportedAuthMethods, authMethod);
7022
+ if (authConfig) {
7023
+ const stringSecrets = Object.fromEntries(Object.entries(secrets).filter(([, v]) => typeof v === "string").map(([k, v]) => [k, v]));
7024
+ authHeaders = buildAuthHeaders(authConfig, stringSecrets);
7025
+ }
7026
+ }
7027
+ return { transport, authMethod, apiVersion, authHeaders, secrets };
7028
+ }
6431
7029
  async createPaymentsProvider(context) {
6432
7030
  const secrets = await this.loadSecrets(context);
6433
7031
  switch (context.spec.meta.key) {
@@ -6436,6 +7034,9 @@ class IntegrationProviderFactory {
6436
7034
  apiKey: requireSecret(secrets, "apiKey", "Stripe API key is required")
6437
7035
  });
6438
7036
  default:
7037
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7038
+ return this.composioFallback.createPaymentsProxy(context);
7039
+ }
6439
7040
  throw new Error(`Unsupported payments integration: ${context.spec.meta.key}`);
6440
7041
  }
6441
7042
  }
@@ -6449,6 +7050,9 @@ class IntegrationProviderFactory {
6449
7050
  messageStream: context.config.messageStream
6450
7051
  });
6451
7052
  default:
7053
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7054
+ return this.composioFallback.createEmailProxy(context);
7055
+ }
6452
7056
  throw new Error(`Unsupported email integration: ${context.spec.meta.key}`);
6453
7057
  }
6454
7058
  }
@@ -6462,6 +7066,9 @@ class IntegrationProviderFactory {
6462
7066
  fromNumber: context.config.fromNumber
6463
7067
  });
6464
7068
  default:
7069
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7070
+ return this.composioFallback.createMessagingProxy(context);
7071
+ }
6465
7072
  throw new Error(`Unsupported SMS integration: ${context.spec.meta.key}`);
6466
7073
  }
6467
7074
  }
@@ -6495,6 +7102,9 @@ class IntegrationProviderFactory {
6495
7102
  fromNumber: config?.fromNumber
6496
7103
  });
6497
7104
  default:
7105
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7106
+ return this.composioFallback.createMessagingProxy(context);
7107
+ }
6498
7108
  throw new Error(`Unsupported messaging integration: ${context.spec.meta.key}`);
6499
7109
  }
6500
7110
  }
@@ -6518,6 +7128,9 @@ class IntegrationProviderFactory {
6518
7128
  sslMode: config?.sslMode
6519
7129
  });
6520
7130
  default:
7131
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7132
+ return this.composioFallback.createGenericProxy(context);
7133
+ }
6521
7134
  throw new Error(`Unsupported vector store integration: ${context.spec.meta.key}`);
6522
7135
  }
6523
7136
  }
@@ -6534,6 +7147,9 @@ class IntegrationProviderFactory {
6534
7147
  personalApiKey: requireSecret(secrets, "personalApiKey", "PostHog personalApiKey is required")
6535
7148
  });
6536
7149
  default:
7150
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7151
+ return this.composioFallback.createGenericProxy(context);
7152
+ }
6537
7153
  throw new Error(`Unsupported analytics integration: ${context.spec.meta.key}`);
6538
7154
  }
6539
7155
  }
@@ -6548,6 +7164,9 @@ class IntegrationProviderFactory {
6548
7164
  sslMode: config?.sslMode
6549
7165
  });
6550
7166
  default:
7167
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7168
+ return this.composioFallback.createGenericProxy(context);
7169
+ }
6551
7170
  throw new Error(`Unsupported database integration: ${context.spec.meta.key}`);
6552
7171
  }
6553
7172
  }
@@ -6561,6 +7180,9 @@ class IntegrationProviderFactory {
6561
7180
  clientOptions: secrets.type === "service_account" ? { credentials: secrets } : undefined
6562
7181
  });
6563
7182
  default:
7183
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7184
+ return this.composioFallback.createGenericProxy(context);
7185
+ }
6564
7186
  throw new Error(`Unsupported storage integration: ${context.spec.meta.key}`);
6565
7187
  }
6566
7188
  }
@@ -6593,6 +7215,9 @@ class IntegrationProviderFactory {
6593
7215
  pollIntervalMs: config?.pollIntervalMs
6594
7216
  });
6595
7217
  default:
7218
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7219
+ return this.composioFallback.createGenericProxy(context);
7220
+ }
6596
7221
  throw new Error(`Unsupported voice integration: ${context.spec.meta.key}`);
6597
7222
  }
6598
7223
  }
@@ -6608,6 +7233,9 @@ class IntegrationProviderFactory {
6608
7233
  serverURL: config?.serverURL
6609
7234
  });
6610
7235
  default:
7236
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7237
+ return this.composioFallback.createGenericProxy(context);
7238
+ }
6611
7239
  throw new Error(`Unsupported STT integration: ${context.spec.meta.key}`);
6612
7240
  }
6613
7241
  }
@@ -6628,6 +7256,9 @@ class IntegrationProviderFactory {
6628
7256
  }
6629
7257
  });
6630
7258
  default:
7259
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7260
+ return this.composioFallback.createGenericProxy(context);
7261
+ }
6631
7262
  throw new Error(`Unsupported conversational integration: ${context.spec.meta.key}`);
6632
7263
  }
6633
7264
  }
@@ -6668,6 +7299,9 @@ class IntegrationProviderFactory {
6668
7299
  descriptionProperty: config?.descriptionProperty
6669
7300
  });
6670
7301
  default:
7302
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7303
+ return this.composioFallback.createProjectManagementProxy(context);
7304
+ }
6671
7305
  throw new Error(`Unsupported project management integration: ${context.spec.meta.key}`);
6672
7306
  }
6673
7307
  }
@@ -6716,6 +7350,9 @@ class IntegrationProviderFactory {
6716
7350
  webhookSecret: secrets.webhookSecret
6717
7351
  });
6718
7352
  default:
7353
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7354
+ return this.composioFallback.createGenericProxy(context);
7355
+ }
6719
7356
  throw new Error(`Unsupported meeting recorder integration: ${context.spec.meta.key}`);
6720
7357
  }
6721
7358
  }
@@ -6728,6 +7365,9 @@ class IntegrationProviderFactory {
6728
7365
  defaultModel: context.config.model
6729
7366
  });
6730
7367
  default:
7368
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7369
+ return this.composioFallback.createGenericProxy(context);
7370
+ }
6731
7371
  throw new Error(`Unsupported LLM integration: ${context.spec.meta.key}`);
6732
7372
  }
6733
7373
  }
@@ -6740,6 +7380,9 @@ class IntegrationProviderFactory {
6740
7380
  defaultModel: context.config.embeddingModel
6741
7381
  });
6742
7382
  default:
7383
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7384
+ return this.composioFallback.createGenericProxy(context);
7385
+ }
6743
7386
  throw new Error(`Unsupported embeddings integration: ${context.spec.meta.key}`);
6744
7387
  }
6745
7388
  }
@@ -6761,6 +7404,9 @@ class IntegrationProviderFactory {
6761
7404
  });
6762
7405
  }
6763
7406
  default:
7407
+ if (this.composioFallback?.canHandle(context.spec.meta.key)) {
7408
+ return this.composioFallback.createGenericProxy(context);
7409
+ }
6764
7410
  throw new Error(`Unsupported open banking integration: ${context.spec.meta.key}`);
6765
7411
  }
6766
7412
  }
@@ -6842,6 +7488,8 @@ export * from "@contractspec/lib.contracts-integrations";
6842
7488
  // src/meeting-recorder.ts
6843
7489
  export * from "@contractspec/lib.contracts-integrations";
6844
7490
  export {
7491
+ resolveToolkit,
7492
+ isSessionExpired,
6845
7493
  createHealthProviderFromContext,
6846
7494
  WhoopHealthProvider,
6847
7495
  UnofficialHealthAutomationProvider,
@@ -6873,6 +7521,7 @@ export {
6873
7521
  LinearProjectManagementProvider,
6874
7522
  JiraProjectManagementProvider,
6875
7523
  IntegrationProviderFactory,
7524
+ INTEGRATION_KEY_TO_TOOLKIT,
6876
7525
  GranolaMeetingRecorderProvider,
6877
7526
  GradiumVoiceProvider,
6878
7527
  GoogleCloudStorageProvider,
@@ -6887,5 +7536,14 @@ export {
6887
7536
  FalVoiceProvider,
6888
7537
  ElevenLabsVoiceProvider,
6889
7538
  EightSleepHealthProvider,
7539
+ ComposioSdkProvider,
7540
+ ComposioProjectManagementProxy,
7541
+ ComposioPaymentsProxy,
7542
+ ComposioMessagingProxy,
7543
+ ComposioMcpProvider,
7544
+ ComposioGenericProxy,
7545
+ ComposioFallbackResolver,
7546
+ ComposioEmailProxy,
7547
+ ComposioCalendarProxy,
6890
7548
  AppleHealthBridgeProvider
6891
7549
  };