@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.
- package/README.md +59 -9
- package/dist/impls/async-event-queue.js +2 -0
- package/dist/impls/composio-fallback-resolver.d.ts +34 -0
- package/dist/impls/composio-fallback-resolver.js +580 -0
- package/dist/impls/composio-mcp.d.ts +22 -0
- package/dist/impls/composio-mcp.js +164 -0
- package/dist/impls/composio-proxies.d.ts +60 -0
- package/dist/impls/composio-proxies.js +311 -0
- package/dist/impls/composio-sdk.d.ts +25 -0
- package/dist/impls/composio-sdk.js +78 -0
- package/dist/impls/composio-types.d.ts +43 -0
- package/dist/impls/composio-types.js +54 -0
- package/dist/impls/elevenlabs-voice.js +2 -0
- package/dist/impls/fal-voice.js +2 -0
- package/dist/impls/fathom-meeting-recorder.js +2 -0
- package/dist/impls/fathom-meeting-recorder.mapper.js +2 -0
- package/dist/impls/fathom-meeting-recorder.utils.js +2 -0
- package/dist/impls/fathom-meeting-recorder.webhooks.js +2 -0
- package/dist/impls/fireflies-meeting-recorder.js +2 -0
- package/dist/impls/fireflies-meeting-recorder.queries.js +2 -0
- package/dist/impls/fireflies-meeting-recorder.utils.js +2 -0
- package/dist/impls/gcs-storage.js +2 -0
- package/dist/impls/gmail-inbound.js +2 -0
- package/dist/impls/gmail-outbound.js +2 -0
- package/dist/impls/google-calendar.js +2 -0
- package/dist/impls/gradium-voice.js +2 -0
- package/dist/impls/granola-meeting-recorder.js +2 -0
- package/dist/impls/granola-meeting-recorder.mcp.js +2 -0
- package/dist/impls/health/base-health-provider.js +2 -0
- package/dist/impls/health/hybrid-health-providers.js +2 -0
- package/dist/impls/health/official-health-providers.js +2 -0
- package/dist/impls/health/provider-normalizers.js +2 -0
- package/dist/impls/health/providers.js +2 -0
- package/dist/impls/health-provider-factory.js +2 -0
- package/dist/impls/index.d.ts +5 -0
- package/dist/impls/index.js +657 -0
- package/dist/impls/jira.js +2 -0
- package/dist/impls/linear.js +2 -0
- package/dist/impls/messaging-github.js +2 -0
- package/dist/impls/messaging-slack.js +2 -0
- package/dist/impls/messaging-whatsapp-meta.js +2 -0
- package/dist/impls/messaging-whatsapp-twilio.js +2 -0
- package/dist/impls/mistral-conversational.js +2 -0
- package/dist/impls/mistral-conversational.session.js +2 -0
- package/dist/impls/mistral-embedding.js +2 -0
- package/dist/impls/mistral-llm.js +2 -0
- package/dist/impls/mistral-stt.js +2 -0
- package/dist/impls/notion.js +2 -0
- package/dist/impls/posthog-reader.js +2 -0
- package/dist/impls/posthog-utils.js +2 -0
- package/dist/impls/posthog.js +2 -0
- package/dist/impls/postmark-email.js +2 -0
- package/dist/impls/powens-client.js +2 -0
- package/dist/impls/powens-openbanking.js +2 -0
- package/dist/impls/provider-factory.d.ts +24 -0
- package/dist/impls/provider-factory.js +70 -0
- package/dist/impls/qdrant-vector.js +2 -0
- package/dist/impls/stripe-payments.js +2 -0
- package/dist/impls/supabase-psql.js +2 -0
- package/dist/impls/supabase-vector.js +2 -0
- package/dist/impls/tldv-meeting-recorder.js +2 -0
- package/dist/impls/twilio-sms.js +2 -0
- package/dist/index.js +657 -0
- package/dist/node/impls/async-event-queue.js +3 -0
- package/dist/node/impls/composio-fallback-resolver.js +580 -0
- package/dist/node/impls/composio-mcp.js +164 -0
- package/dist/node/impls/composio-proxies.js +311 -0
- package/dist/node/impls/composio-sdk.js +78 -0
- package/dist/node/impls/composio-types.js +54 -0
- package/dist/node/impls/elevenlabs-voice.js +3 -0
- package/dist/node/impls/fal-voice.js +3 -0
- package/dist/node/impls/fathom-meeting-recorder.js +3 -0
- package/dist/node/impls/fathom-meeting-recorder.mapper.js +3 -0
- package/dist/node/impls/fathom-meeting-recorder.utils.js +3 -0
- package/dist/node/impls/fathom-meeting-recorder.webhooks.js +3 -0
- package/dist/node/impls/fireflies-meeting-recorder.js +3 -0
- package/dist/node/impls/fireflies-meeting-recorder.queries.js +3 -0
- package/dist/node/impls/fireflies-meeting-recorder.utils.js +3 -0
- package/dist/node/impls/gcs-storage.js +3 -0
- package/dist/node/impls/gmail-inbound.js +3 -0
- package/dist/node/impls/gmail-outbound.js +3 -0
- package/dist/node/impls/google-calendar.js +3 -0
- package/dist/node/impls/gradium-voice.js +3 -0
- package/dist/node/impls/granola-meeting-recorder.js +3 -0
- package/dist/node/impls/granola-meeting-recorder.mcp.js +3 -0
- package/dist/node/impls/health/base-health-provider.js +3 -0
- package/dist/node/impls/health/hybrid-health-providers.js +3 -0
- package/dist/node/impls/health/official-health-providers.js +3 -0
- package/dist/node/impls/health/provider-normalizers.js +3 -0
- package/dist/node/impls/health/providers.js +3 -0
- package/dist/node/impls/health-provider-factory.js +3 -0
- package/dist/node/impls/index.js +658 -0
- package/dist/node/impls/jira.js +3 -0
- package/dist/node/impls/linear.js +3 -0
- package/dist/node/impls/messaging-github.js +3 -0
- package/dist/node/impls/messaging-slack.js +3 -0
- package/dist/node/impls/messaging-whatsapp-meta.js +3 -0
- package/dist/node/impls/messaging-whatsapp-twilio.js +3 -0
- package/dist/node/impls/mistral-conversational.js +3 -0
- package/dist/node/impls/mistral-conversational.session.js +3 -0
- package/dist/node/impls/mistral-embedding.js +3 -0
- package/dist/node/impls/mistral-llm.js +3 -0
- package/dist/node/impls/mistral-stt.js +3 -0
- package/dist/node/impls/notion.js +3 -0
- package/dist/node/impls/posthog-reader.js +3 -0
- package/dist/node/impls/posthog-utils.js +3 -0
- package/dist/node/impls/posthog.js +3 -0
- package/dist/node/impls/postmark-email.js +3 -0
- package/dist/node/impls/powens-client.js +3 -0
- package/dist/node/impls/powens-openbanking.js +3 -0
- package/dist/node/impls/provider-factory.js +71 -0
- package/dist/node/impls/qdrant-vector.js +3 -0
- package/dist/node/impls/stripe-payments.js +3 -0
- package/dist/node/impls/supabase-psql.js +3 -0
- package/dist/node/impls/supabase-vector.js +3 -0
- package/dist/node/impls/tldv-meeting-recorder.js +3 -0
- package/dist/node/impls/twilio-sms.js +3 -0
- package/dist/node/index.js +658 -0
- package/dist/node/secrets/provider.js +3 -0
- package/dist/secrets/provider.js +2 -0
- package/package.json +71 -10
|
@@ -0,0 +1,164 @@
|
|
|
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
|
+
export {
|
|
163
|
+
ComposioMcpProvider
|
|
164
|
+
};
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/impls/composio-proxies.ts
|
|
5
|
+
function composioToolName(toolkit, action) {
|
|
6
|
+
return `${toolkit.toUpperCase()}_${action.toUpperCase()}`;
|
|
7
|
+
}
|
|
8
|
+
function unwrapResult(result, fallback) {
|
|
9
|
+
if (!result.success) {
|
|
10
|
+
throw new Error(`Composio tool execution failed: ${result.error}`);
|
|
11
|
+
}
|
|
12
|
+
return result.data ?? fallback;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
class ComposioMessagingProxy {
|
|
16
|
+
proxy;
|
|
17
|
+
toolkit;
|
|
18
|
+
constructor(proxy, toolkit) {
|
|
19
|
+
this.proxy = proxy;
|
|
20
|
+
this.toolkit = toolkit;
|
|
21
|
+
}
|
|
22
|
+
async sendMessage(input) {
|
|
23
|
+
const result = await this.proxy.executeTool(composioToolName(this.toolkit, "SEND_MESSAGE"), {
|
|
24
|
+
channel: input.channelId,
|
|
25
|
+
thread_ts: input.threadId,
|
|
26
|
+
text: input.text,
|
|
27
|
+
recipient: input.recipientId
|
|
28
|
+
});
|
|
29
|
+
const data = unwrapResult(result, {});
|
|
30
|
+
return {
|
|
31
|
+
id: String(data.id ?? data.ts ?? crypto.randomUUID()),
|
|
32
|
+
providerMessageId: data.ts,
|
|
33
|
+
status: "sent",
|
|
34
|
+
sentAt: new Date
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
async updateMessage(messageId, input) {
|
|
38
|
+
const result = await this.proxy.executeTool(composioToolName(this.toolkit, "UPDATE_MESSAGE"), {
|
|
39
|
+
message_id: messageId,
|
|
40
|
+
channel: input.channelId,
|
|
41
|
+
text: input.text
|
|
42
|
+
});
|
|
43
|
+
const data = unwrapResult(result, {});
|
|
44
|
+
return {
|
|
45
|
+
id: String(data.id ?? messageId),
|
|
46
|
+
status: "sent",
|
|
47
|
+
sentAt: new Date
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
class ComposioEmailProxy {
|
|
53
|
+
proxy;
|
|
54
|
+
toolkit;
|
|
55
|
+
constructor(proxy, toolkit) {
|
|
56
|
+
this.proxy = proxy;
|
|
57
|
+
this.toolkit = toolkit;
|
|
58
|
+
}
|
|
59
|
+
async sendEmail(message) {
|
|
60
|
+
const result = await this.proxy.executeTool(composioToolName(this.toolkit, "SEND_EMAIL"), {
|
|
61
|
+
to: message.to.map((a) => a.email).join(","),
|
|
62
|
+
cc: message.cc?.map((a) => a.email).join(","),
|
|
63
|
+
bcc: message.bcc?.map((a) => a.email).join(","),
|
|
64
|
+
subject: message.subject,
|
|
65
|
+
body: message.htmlBody ?? message.textBody ?? "",
|
|
66
|
+
from: message.from.email
|
|
67
|
+
});
|
|
68
|
+
const data = unwrapResult(result, {});
|
|
69
|
+
return {
|
|
70
|
+
id: String(data.id ?? data.messageId ?? crypto.randomUUID()),
|
|
71
|
+
providerMessageId: data.messageId,
|
|
72
|
+
queuedAt: new Date
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
class ComposioPaymentsProxy {
|
|
78
|
+
proxy;
|
|
79
|
+
toolkit;
|
|
80
|
+
constructor(proxy, toolkit) {
|
|
81
|
+
this.proxy = proxy;
|
|
82
|
+
this.toolkit = toolkit;
|
|
83
|
+
}
|
|
84
|
+
async createCustomer(input) {
|
|
85
|
+
const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CREATE_CUSTOMER"), { email: input.email, name: input.name, description: input.description });
|
|
86
|
+
const data = unwrapResult(result, {});
|
|
87
|
+
return {
|
|
88
|
+
id: String(data.id ?? crypto.randomUUID()),
|
|
89
|
+
email: data.email ?? input.email,
|
|
90
|
+
name: data.name ?? input.name
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
async getCustomer(customerId) {
|
|
94
|
+
const result = await this.proxy.executeTool(composioToolName(this.toolkit, "GET_CUSTOMER"), { customer_id: customerId });
|
|
95
|
+
if (!result.success)
|
|
96
|
+
return null;
|
|
97
|
+
const data = result.data;
|
|
98
|
+
if (!data)
|
|
99
|
+
return null;
|
|
100
|
+
return {
|
|
101
|
+
id: String(data.id ?? customerId),
|
|
102
|
+
email: data.email,
|
|
103
|
+
name: data.name
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
async createPaymentIntent(input) {
|
|
107
|
+
const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CREATE_PAYMENT_INTENT"), {
|
|
108
|
+
amount: input.amount.amount,
|
|
109
|
+
currency: input.amount.currency,
|
|
110
|
+
customer_id: input.customerId,
|
|
111
|
+
description: input.description
|
|
112
|
+
});
|
|
113
|
+
const data = unwrapResult(result, {});
|
|
114
|
+
return {
|
|
115
|
+
id: String(data.id ?? crypto.randomUUID()),
|
|
116
|
+
amount: input.amount,
|
|
117
|
+
status: data.status ?? "requires_payment_method",
|
|
118
|
+
customerId: input.customerId,
|
|
119
|
+
clientSecret: data.client_secret
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
async capturePayment(paymentIntentId, input) {
|
|
123
|
+
const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CAPTURE_PAYMENT"), { payment_intent_id: paymentIntentId, amount: input?.amount?.amount });
|
|
124
|
+
const data = unwrapResult(result, {});
|
|
125
|
+
return {
|
|
126
|
+
id: paymentIntentId,
|
|
127
|
+
amount: input?.amount ?? { amount: 0, currency: "usd" },
|
|
128
|
+
status: data.status ?? "succeeded"
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
async cancelPaymentIntent(paymentIntentId) {
|
|
132
|
+
const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CANCEL_PAYMENT_INTENT"), { payment_intent_id: paymentIntentId });
|
|
133
|
+
const data = unwrapResult(result, {});
|
|
134
|
+
return {
|
|
135
|
+
id: paymentIntentId,
|
|
136
|
+
amount: { amount: 0, currency: "usd" },
|
|
137
|
+
status: data.status ?? "canceled"
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
async refundPayment(input) {
|
|
141
|
+
const result = await this.proxy.executeTool(composioToolName(this.toolkit, "REFUND_PAYMENT"), {
|
|
142
|
+
payment_intent_id: input.paymentIntentId,
|
|
143
|
+
amount: input.amount?.amount,
|
|
144
|
+
reason: input.reason
|
|
145
|
+
});
|
|
146
|
+
const data = unwrapResult(result, {});
|
|
147
|
+
return {
|
|
148
|
+
id: String(data.id ?? crypto.randomUUID()),
|
|
149
|
+
paymentIntentId: input.paymentIntentId,
|
|
150
|
+
amount: input.amount ?? { amount: 0, currency: "usd" },
|
|
151
|
+
status: "succeeded"
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
async listInvoices(_query) {
|
|
155
|
+
const result = await this.proxy.executeTool(composioToolName(this.toolkit, "LIST_INVOICES"), { customer_id: _query?.customerId, limit: _query?.limit });
|
|
156
|
+
if (!result.success)
|
|
157
|
+
return [];
|
|
158
|
+
const items = result.data ?? [];
|
|
159
|
+
return items.map((i) => ({
|
|
160
|
+
id: String(i.id),
|
|
161
|
+
status: i.status ?? "open",
|
|
162
|
+
amountDue: {
|
|
163
|
+
amount: Number(i.amount_due ?? 0),
|
|
164
|
+
currency: String(i.currency ?? "usd")
|
|
165
|
+
}
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
168
|
+
async listTransactions(_query) {
|
|
169
|
+
const result = await this.proxy.executeTool(composioToolName(this.toolkit, "LIST_TRANSACTIONS"), { customer_id: _query?.customerId, limit: _query?.limit });
|
|
170
|
+
if (!result.success)
|
|
171
|
+
return [];
|
|
172
|
+
const items = result.data ?? [];
|
|
173
|
+
return items.map((i) => ({
|
|
174
|
+
id: String(i.id),
|
|
175
|
+
amount: {
|
|
176
|
+
amount: Number(i.amount ?? 0),
|
|
177
|
+
currency: String(i.currency ?? "usd")
|
|
178
|
+
},
|
|
179
|
+
type: "capture",
|
|
180
|
+
status: "succeeded",
|
|
181
|
+
createdAt: new Date
|
|
182
|
+
}));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
class ComposioProjectManagementProxy {
|
|
187
|
+
proxy;
|
|
188
|
+
toolkit;
|
|
189
|
+
constructor(proxy, toolkit) {
|
|
190
|
+
this.proxy = proxy;
|
|
191
|
+
this.toolkit = toolkit;
|
|
192
|
+
}
|
|
193
|
+
async createWorkItem(input) {
|
|
194
|
+
const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CREATE_ISSUE"), {
|
|
195
|
+
title: input.title,
|
|
196
|
+
description: input.description,
|
|
197
|
+
priority: input.priority,
|
|
198
|
+
assignee_id: input.assigneeId,
|
|
199
|
+
project_id: input.projectId,
|
|
200
|
+
labels: input.tags
|
|
201
|
+
});
|
|
202
|
+
const data = unwrapResult(result, {});
|
|
203
|
+
return {
|
|
204
|
+
id: String(data.id ?? data.key ?? crypto.randomUUID()),
|
|
205
|
+
title: input.title,
|
|
206
|
+
url: data.url,
|
|
207
|
+
status: data.status,
|
|
208
|
+
priority: input.priority,
|
|
209
|
+
tags: input.tags,
|
|
210
|
+
projectId: input.projectId
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
async createWorkItems(items) {
|
|
214
|
+
return Promise.all(items.map((item) => this.createWorkItem(item)));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
class ComposioCalendarProxy {
|
|
219
|
+
proxy;
|
|
220
|
+
toolkit;
|
|
221
|
+
constructor(proxy, toolkit) {
|
|
222
|
+
this.proxy = proxy;
|
|
223
|
+
this.toolkit = toolkit;
|
|
224
|
+
}
|
|
225
|
+
async listEvents(query) {
|
|
226
|
+
const result = await this.proxy.executeTool(composioToolName(this.toolkit, "LIST_EVENTS"), {
|
|
227
|
+
calendar_id: query.calendarId,
|
|
228
|
+
time_min: query.timeMin?.toISOString(),
|
|
229
|
+
time_max: query.timeMax?.toISOString(),
|
|
230
|
+
max_results: query.maxResults
|
|
231
|
+
});
|
|
232
|
+
if (!result.success)
|
|
233
|
+
return { events: [] };
|
|
234
|
+
const items = result.data ?? [];
|
|
235
|
+
return {
|
|
236
|
+
events: items.map((e) => ({
|
|
237
|
+
id: String(e.id),
|
|
238
|
+
calendarId: query.calendarId,
|
|
239
|
+
title: String(e.summary ?? e.title ?? ""),
|
|
240
|
+
start: new Date(String(e.start ?? Date.now())),
|
|
241
|
+
end: new Date(String(e.end ?? Date.now()))
|
|
242
|
+
}))
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
async createEvent(input) {
|
|
246
|
+
const result = await this.proxy.executeTool(composioToolName(this.toolkit, "CREATE_EVENT"), {
|
|
247
|
+
calendar_id: input.calendarId,
|
|
248
|
+
summary: input.title,
|
|
249
|
+
description: input.description,
|
|
250
|
+
location: input.location,
|
|
251
|
+
start: input.start.toISOString(),
|
|
252
|
+
end: input.end.toISOString(),
|
|
253
|
+
attendees: input.attendees?.map((a) => a.email)
|
|
254
|
+
});
|
|
255
|
+
const data = unwrapResult(result, {});
|
|
256
|
+
return {
|
|
257
|
+
id: String(data.id ?? crypto.randomUUID()),
|
|
258
|
+
calendarId: input.calendarId,
|
|
259
|
+
title: input.title,
|
|
260
|
+
start: input.start,
|
|
261
|
+
end: input.end
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
async updateEvent(calendarId, eventId, input) {
|
|
265
|
+
const result = await this.proxy.executeTool(composioToolName(this.toolkit, "UPDATE_EVENT"), {
|
|
266
|
+
calendar_id: calendarId,
|
|
267
|
+
event_id: eventId,
|
|
268
|
+
summary: input.title,
|
|
269
|
+
description: input.description,
|
|
270
|
+
start: input.start?.toISOString(),
|
|
271
|
+
end: input.end?.toISOString()
|
|
272
|
+
});
|
|
273
|
+
const data = unwrapResult(result, {});
|
|
274
|
+
return {
|
|
275
|
+
id: eventId,
|
|
276
|
+
calendarId,
|
|
277
|
+
title: String(data.summary ?? input.title ?? ""),
|
|
278
|
+
start: input.start ?? new Date,
|
|
279
|
+
end: input.end ?? new Date
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
async deleteEvent(calendarId, eventId) {
|
|
283
|
+
await this.proxy.executeTool(composioToolName(this.toolkit, "DELETE_EVENT"), { calendar_id: calendarId, event_id: eventId });
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
class ComposioGenericProxy {
|
|
288
|
+
proxy;
|
|
289
|
+
toolkit;
|
|
290
|
+
constructor(proxy, toolkit) {
|
|
291
|
+
this.proxy = proxy;
|
|
292
|
+
this.toolkit = toolkit;
|
|
293
|
+
}
|
|
294
|
+
async executeTool(action, args) {
|
|
295
|
+
return this.proxy.executeTool(composioToolName(this.toolkit, action), args);
|
|
296
|
+
}
|
|
297
|
+
async searchTools(query) {
|
|
298
|
+
return this.proxy.searchTools(query);
|
|
299
|
+
}
|
|
300
|
+
getToolkit() {
|
|
301
|
+
return this.toolkit;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
export {
|
|
305
|
+
ComposioProjectManagementProxy,
|
|
306
|
+
ComposioPaymentsProxy,
|
|
307
|
+
ComposioMessagingProxy,
|
|
308
|
+
ComposioGenericProxy,
|
|
309
|
+
ComposioEmailProxy,
|
|
310
|
+
ComposioCalendarProxy
|
|
311
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/impls/composio-sdk.ts
|
|
5
|
+
class ComposioSdkProvider {
|
|
6
|
+
config;
|
|
7
|
+
client;
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.config = config;
|
|
10
|
+
}
|
|
11
|
+
async executeTool(toolName, args) {
|
|
12
|
+
const client = await this.getClient();
|
|
13
|
+
const userId = args._userId ?? "default";
|
|
14
|
+
try {
|
|
15
|
+
const entity = await client.getEntity(userId);
|
|
16
|
+
const result = await entity.execute(toolName, args);
|
|
17
|
+
return { success: true, data: result };
|
|
18
|
+
} catch (error) {
|
|
19
|
+
return {
|
|
20
|
+
success: false,
|
|
21
|
+
error: error instanceof Error ? error.message : String(error)
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async searchTools(query) {
|
|
26
|
+
const client = await this.getClient();
|
|
27
|
+
try {
|
|
28
|
+
const tools = await client.actions.list({ query, limit: 20 });
|
|
29
|
+
return tools.map((t) => ({
|
|
30
|
+
name: t.name,
|
|
31
|
+
description: t.description ?? "",
|
|
32
|
+
toolkit: t.appName ?? "",
|
|
33
|
+
parameters: t.parameters ?? {}
|
|
34
|
+
}));
|
|
35
|
+
} catch {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async getConnectedAccounts(userId) {
|
|
40
|
+
const client = await this.getClient();
|
|
41
|
+
try {
|
|
42
|
+
const entity = await client.getEntity(userId);
|
|
43
|
+
const connections = await entity.getConnections();
|
|
44
|
+
return connections.map((c) => ({
|
|
45
|
+
id: c.id,
|
|
46
|
+
appName: c.appName,
|
|
47
|
+
status: c.status
|
|
48
|
+
}));
|
|
49
|
+
} catch {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async getMcpConfig(userId) {
|
|
54
|
+
const client = await this.getClient();
|
|
55
|
+
try {
|
|
56
|
+
const entity = await client.getEntity(userId);
|
|
57
|
+
return {
|
|
58
|
+
url: entity.getMcpUrl(),
|
|
59
|
+
headers: entity.getMcpHeaders()
|
|
60
|
+
};
|
|
61
|
+
} catch {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async getClient() {
|
|
66
|
+
if (this.client)
|
|
67
|
+
return this.client;
|
|
68
|
+
const { Composio } = await import("@composio/core");
|
|
69
|
+
this.client = new Composio({
|
|
70
|
+
apiKey: this.config.apiKey,
|
|
71
|
+
...this.config.baseUrl ? { baseUrl: this.config.baseUrl } : {}
|
|
72
|
+
});
|
|
73
|
+
return this.client;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
ComposioSdkProvider
|
|
78
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
export {
|
|
51
|
+
resolveToolkit,
|
|
52
|
+
isSessionExpired,
|
|
53
|
+
INTEGRATION_KEY_TO_TOOLKIT
|
|
54
|
+
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
+
|
|
1
4
|
// src/impls/fathom-meeting-recorder.webhooks.ts
|
|
2
5
|
import { TriggeredFor } from "fathom-typescript/sdk/models/operations";
|
|
3
6
|
function normalizeWebhookHeaders(headers) {
|