@elevasis/core 0.15.0 → 0.16.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/dist/index.d.ts +1718 -19
- package/dist/index.js +369 -25
- package/dist/organization-model/index.d.ts +1718 -19
- package/dist/organization-model/index.js +369 -25
- package/dist/test-utils/index.d.ts +1108 -371
- package/dist/test-utils/index.js +357 -17
- package/package.json +5 -1
- package/src/__tests__/publish.test.ts +14 -13
- package/src/__tests__/template-core-compatibility.test.ts +4 -4
- package/src/_gen/__tests__/__snapshots__/contracts.md.snap +1109 -882
- package/src/auth/multi-tenancy/index.ts +3 -0
- package/src/auth/multi-tenancy/theme-presets.ts +45 -0
- package/src/auth/multi-tenancy/types.ts +57 -83
- package/src/auth/multi-tenancy/users/api-schemas.ts +165 -194
- package/src/business/acquisition/activity-events.ts +13 -4
- package/src/business/acquisition/api-schemas.test.ts +315 -4
- package/src/business/acquisition/api-schemas.ts +122 -8
- package/src/business/acquisition/build-templates.ts +44 -0
- package/src/business/acquisition/crm-next-action.test.ts +262 -0
- package/src/business/acquisition/crm-next-action.ts +220 -0
- package/src/business/acquisition/crm-priority.test.ts +216 -0
- package/src/business/acquisition/crm-priority.ts +349 -0
- package/src/business/acquisition/crm-state-actions.test.ts +151 -160
- package/src/business/acquisition/deal-ownership.test.ts +351 -0
- package/src/business/acquisition/deal-ownership.ts +120 -0
- package/src/business/acquisition/derive-actions.test.ts +101 -37
- package/src/business/acquisition/derive-actions.ts +102 -87
- package/src/business/acquisition/index.ts +10 -0
- package/src/business/acquisition/types.ts +400 -366
- package/src/business/crm/api-schemas.ts +40 -0
- package/src/business/crm/index.ts +1 -0
- package/src/business/deals/api-schemas.ts +79 -0
- package/src/business/deals/index.ts +1 -0
- package/src/business/projects/types.ts +124 -88
- package/src/execution/core/runner-types.ts +61 -80
- package/src/execution/engine/index.ts +4 -3
- package/src/execution/engine/tools/integration/server/adapters/gmail/gmail-tools.ts +105 -104
- package/src/execution/engine/tools/integration/server/adapters/instantly/instantly-tools.ts +1474 -1473
- package/src/execution/engine/tools/integration/server/adapters/millionverifier/millionverifier-tools.ts +103 -102
- package/src/execution/engine/tools/integration/server/adapters/signature-api/signature-api-tools.ts +182 -179
- package/src/execution/engine/tools/integration/server/adapters/stripe/stripe-tools.ts +310 -309
- package/src/execution/engine/tools/integration/tool.ts +255 -253
- package/src/execution/engine/tools/lead-service-types.ts +939 -924
- package/src/execution/engine/tools/messages.ts +43 -0
- package/src/execution/engine/tools/platform/acquisition/list-tools.ts +6 -5
- package/src/execution/engine/tools/platform/acquisition/types.ts +5 -2
- package/src/execution/engine/tools/platform/email/types.ts +97 -96
- package/src/execution/engine/tools/registry.ts +4 -3
- package/src/execution/engine/tools/tool-maps.ts +3 -1
- package/src/execution/engine/tools/types.ts +234 -233
- package/src/execution/engine/workflow/types.ts +195 -193
- package/src/execution/external/api-schemas.ts +40 -0
- package/src/execution/external/index.ts +1 -0
- package/src/knowledge/README.md +32 -0
- package/src/knowledge/__tests__/queries.test.ts +504 -0
- package/src/knowledge/format.ts +99 -0
- package/src/knowledge/index.ts +5 -0
- package/src/knowledge/queries.ts +256 -0
- package/src/organization-model/__tests__/defaults.test.ts +172 -172
- package/src/organization-model/__tests__/foundation.test.ts +7 -7
- package/src/organization-model/__tests__/icons.test.ts +27 -0
- package/src/organization-model/__tests__/knowledge.test.ts +214 -0
- package/src/organization-model/contracts.ts +17 -15
- package/src/organization-model/defaults.ts +74 -19
- package/src/organization-model/domains/knowledge.ts +53 -0
- package/src/organization-model/domains/navigation.ts +416 -399
- package/src/organization-model/domains/prospecting.ts +204 -1
- package/src/organization-model/domains/sales.test.ts +29 -0
- package/src/organization-model/domains/sales.ts +102 -0
- package/src/organization-model/domains/shared.ts +6 -5
- package/src/organization-model/foundation.ts +10 -6
- package/src/organization-model/graph/build.ts +209 -182
- package/src/organization-model/graph/schema.ts +37 -34
- package/src/organization-model/graph/types.ts +47 -31
- package/src/organization-model/icons.ts +81 -0
- package/src/organization-model/index.ts +8 -3
- package/src/organization-model/organization-model.mdx +1 -1
- package/src/organization-model/published.ts +103 -86
- package/src/organization-model/schema.ts +90 -85
- package/src/organization-model/types.ts +42 -35
- package/src/platform/constants/versions.ts +1 -1
- package/src/platform/index.ts +23 -27
- package/src/platform/registry/index.ts +0 -4
- package/src/platform/registry/resource-registry.ts +0 -77
- package/src/platform/registry/serialized-types.ts +148 -219
- package/src/platform/registry/stats-types.ts +60 -60
- package/src/reference/_generated/contracts.md +829 -595
- package/src/supabase/database.types.ts +2978 -2958
|
@@ -1,253 +1,255 @@
|
|
|
1
|
-
import type { z } from 'zod'
|
|
2
|
-
import type { Tool, ToolExecutionOptions } from '../types'
|
|
3
|
-
import { ToolingError } from '../types'
|
|
4
|
-
import { getToolServices } from '../registry'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Supported integration types
|
|
8
|
-
*
|
|
9
|
-
* These represent the available integration adapters that can be used with tools.
|
|
10
|
-
* Each integration type corresponds to an adapter implementation.
|
|
11
|
-
*
|
|
12
|
-
* Note: Concrete adapter implementations are deferred until needed.
|
|
13
|
-
* This type provides compile-time safety and auto-completion for tool definitions.
|
|
14
|
-
*/
|
|
15
|
-
export type IntegrationType =
|
|
16
|
-
| 'gmail' // Google Gmail API
|
|
17
|
-
| 'google-sheets' // Google Sheets API
|
|
18
|
-
| 'slack' // Slack API
|
|
19
|
-
| 'github' // GitHub API
|
|
20
|
-
| 'linear' // Linear API
|
|
21
|
-
| 'attio' // Attio CRM API
|
|
22
|
-
| 'airtable' // Airtable API
|
|
23
|
-
| 'salesforce' // Salesforce API
|
|
24
|
-
| 'hubspot' // HubSpot API
|
|
25
|
-
| 'stripe' // Stripe API
|
|
26
|
-
| 'twilio' // Twilio API
|
|
27
|
-
| 'sendgrid' // SendGrid API
|
|
28
|
-
| 'mailgun' // Mailgun API
|
|
29
|
-
| 'zapier' // Zapier Webhooks
|
|
30
|
-
| 'webhook' // Generic webhook
|
|
31
|
-
| 'apify' // Apify actor automation
|
|
32
|
-
| 'instantly' // Instantly.ai email automation
|
|
33
|
-
| 'resend' // Resend transactional email API
|
|
34
|
-
| 'signature-api' // SignatureAPI eSignature service
|
|
35
|
-
| 'dropbox' // Dropbox file storage API
|
|
36
|
-
| 'anymailfinder' // Anymailfinder email finder API
|
|
37
|
-
| 'tomba' // Tomba email discovery API
|
|
38
|
-
| 'millionverifier' // MillionVerifier email verification API
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Type-safe method names for each integration
|
|
42
|
-
* Provides compile-time validation and IDE auto-completion
|
|
43
|
-
*/
|
|
44
|
-
export type GmailMethod = 'sendEmail' | 'searchEmails' | 'readEmail' | 'createDraft' | 'addLabel'
|
|
45
|
-
export type SlackMethod = 'postMessage' | 'listChannels' | 'createChannel' | 'uploadFile' | 'addReaction'
|
|
46
|
-
export type GithubMethod = 'createIssue' | 'createPR' | 'addComment' | 'listIssues'
|
|
47
|
-
export type LinearMethod = 'createIssue' | 'updateIssue' | 'listIssues'
|
|
48
|
-
export type AttioMethod =
|
|
49
|
-
| 'createRecord'
|
|
50
|
-
| 'updateRecord'
|
|
51
|
-
| 'listRecords'
|
|
52
|
-
| 'getRecord'
|
|
53
|
-
| 'deleteRecord'
|
|
54
|
-
| 'createTask'
|
|
55
|
-
| 'createNote'
|
|
56
|
-
| 'listNotes'
|
|
57
|
-
| 'deleteNote'
|
|
58
|
-
| 'listObjects'
|
|
59
|
-
| 'listAttributes'
|
|
60
|
-
| 'createAttribute'
|
|
61
|
-
| 'updateAttribute'
|
|
62
|
-
export type AirtableMethod = 'listRecords' | 'createRecord' | 'updateRecord' | 'deleteRecord'
|
|
63
|
-
export type SalesforceMethod = 'query' | 'create' | 'update' | 'delete'
|
|
64
|
-
export type HubspotMethod = 'createContact' | 'updateContact' | 'listContacts'
|
|
65
|
-
export type StripeMethod =
|
|
66
|
-
| 'createPaymentLink'
|
|
67
|
-
| 'getPaymentLink'
|
|
68
|
-
| 'updatePaymentLink'
|
|
69
|
-
| 'listPaymentLinks'
|
|
70
|
-
| 'createCheckoutSession'
|
|
71
|
-
| 'createAutoPaymentLink'
|
|
72
|
-
export type TwilioMethod = 'sendSMS' | 'sendWhatsApp' | 'makeCall'
|
|
73
|
-
export type SendgridMethod = 'sendEmail' | 'addToList'
|
|
74
|
-
export type MailgunMethod = 'sendEmail' | 'validateEmail'
|
|
75
|
-
export type ZapierMethod = 'trigger'
|
|
76
|
-
export type WebhookMethod = 'call'
|
|
77
|
-
export type GoogleSheetsMethod =
|
|
78
|
-
| 'readSheet'
|
|
79
|
-
| 'writeSheet'
|
|
80
|
-
| 'appendRows'
|
|
81
|
-
| 'clearRange'
|
|
82
|
-
| 'getSpreadsheetMetadata'
|
|
83
|
-
| 'batchUpdate'
|
|
84
|
-
| 'getHeaders'
|
|
85
|
-
| 'getLastRow'
|
|
86
|
-
| 'getRowByValue'
|
|
87
|
-
| 'updateRowByValue'
|
|
88
|
-
| 'upsertRow'
|
|
89
|
-
| 'filterRows'
|
|
90
|
-
| 'deleteRowByValue'
|
|
91
|
-
export type ApifyMethod = 'runActor' | 'getDatasetItems' | 'startActor'
|
|
92
|
-
export type InstantlyMethod =
|
|
93
|
-
| 'sendReply'
|
|
94
|
-
| 'updateInterestStatus'
|
|
95
|
-
| 'removeFromSubsequence'
|
|
96
|
-
| 'deleteLead'
|
|
97
|
-
| 'moveLead'
|
|
98
|
-
| 'getEmails'
|
|
99
|
-
| 'addToCampaign'
|
|
100
|
-
| 'listCampaigns'
|
|
101
|
-
| 'getCampaign'
|
|
102
|
-
| 'updateCampaign'
|
|
103
|
-
| 'pauseCampaign'
|
|
104
|
-
| 'activateCampaign'
|
|
105
|
-
| 'getCampaignAnalytics'
|
|
106
|
-
| 'getStepAnalytics'
|
|
107
|
-
| 'bulkAddLeads'
|
|
108
|
-
| 'getAccountHealth'
|
|
109
|
-
| 'createInboxTest'
|
|
110
|
-
| 'createCampaign'
|
|
111
|
-
| 'getDailyCampaignAnalytics'
|
|
112
|
-
| 'listLeads'
|
|
113
|
-
| 'bulkDeleteLeads'
|
|
114
|
-
| 'deleteCampaign'
|
|
115
|
-
export type ResendMethod = 'sendEmail' | 'getEmail'
|
|
116
|
-
export type SignatureApiMethod = 'createEnvelope' | 'voidEnvelope' | 'downloadDocument' | 'getEnvelope'
|
|
117
|
-
export type DropboxMethod = 'uploadFile' | 'createFolder'
|
|
118
|
-
export type AnymailfinderMethod = 'findCompanyEmail' | 'findPersonEmail' | 'findDecisionMakerEmail' | 'verifyEmail'
|
|
119
|
-
export type TombaMethod = 'emailFinder' | 'domainSearch' | 'emailVerifier'
|
|
120
|
-
export type MillionVerifierMethod = 'verifyEmail' | 'checkCredits'
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Map integration types to their method types
|
|
124
|
-
*/
|
|
125
|
-
export type IntegrationMethodMap = {
|
|
126
|
-
gmail: GmailMethod
|
|
127
|
-
'google-sheets': GoogleSheetsMethod
|
|
128
|
-
slack: SlackMethod
|
|
129
|
-
github: GithubMethod
|
|
130
|
-
linear: LinearMethod
|
|
131
|
-
attio: AttioMethod
|
|
132
|
-
airtable: AirtableMethod
|
|
133
|
-
salesforce: SalesforceMethod
|
|
134
|
-
hubspot: HubspotMethod
|
|
135
|
-
stripe: StripeMethod
|
|
136
|
-
twilio: TwilioMethod
|
|
137
|
-
sendgrid: SendgridMethod
|
|
138
|
-
mailgun: MailgunMethod
|
|
139
|
-
zapier: ZapierMethod
|
|
140
|
-
webhook: WebhookMethod
|
|
141
|
-
apify: ApifyMethod
|
|
142
|
-
instantly: InstantlyMethod
|
|
143
|
-
resend: ResendMethod
|
|
144
|
-
'signature-api': SignatureApiMethod
|
|
145
|
-
dropbox: DropboxMethod
|
|
146
|
-
anymailfinder: AnymailfinderMethod
|
|
147
|
-
tomba: TombaMethod
|
|
148
|
-
millionverifier: MillionVerifierMethod
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Configuration for creating an integration tool.
|
|
153
|
-
* Integration tools call external APIs (Gmail, Slack, etc.) using organization credentials.
|
|
154
|
-
*
|
|
155
|
-
* @template T - Integration type (e.g., 'gmail', 'slack')
|
|
156
|
-
*/
|
|
157
|
-
export interface IntegrationToolConfig<T extends IntegrationType = IntegrationType> {
|
|
158
|
-
/** Unique name for the tool (e.g., 'gmail_sendEmail', 'slack_postMessage') */
|
|
159
|
-
name: string
|
|
160
|
-
/** Description of what the tool does (shown to LLM) */
|
|
161
|
-
description: string
|
|
162
|
-
/** Zod schema for validating input */
|
|
163
|
-
inputSchema: z.ZodSchema
|
|
164
|
-
/** Zod schema for validating output */
|
|
165
|
-
outputSchema: z.ZodSchema
|
|
166
|
-
/** Integration adapter type (e.g., 'gmail', 'slack') */
|
|
167
|
-
integration: T
|
|
168
|
-
/** Method to call on the integration adapter (type-safe based on integration) */
|
|
169
|
-
method: T extends keyof IntegrationMethodMap ? IntegrationMethodMap[T] : string
|
|
170
|
-
/** Credential name to use from credentials table (e.g., 'support-gmail', 'sales-gmail') */
|
|
171
|
-
credentialName: string
|
|
172
|
-
/** Optional callback executed after successful tool execution (e.g., cache updates) - receives full options including iterationContext for memory management */
|
|
173
|
-
onSuccess?: (result: unknown, options: ToolExecutionOptions) => void | Promise<void>
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Create an integration tool that calls external APIs using organization credentials
|
|
178
|
-
*
|
|
179
|
-
* Integration tools enable agents to interact with external services (Gmail, Slack, etc.)
|
|
180
|
-
* using encrypted credentials stored in the credentials table. Each tool
|
|
181
|
-
* specifies which credential name to use, allowing multiple credentials per integration type.
|
|
182
|
-
*
|
|
183
|
-
* @param config - Configuration for the integration tool
|
|
184
|
-
* @returns Tool that calls the integration adapter with credentials
|
|
185
|
-
*
|
|
186
|
-
* @example
|
|
187
|
-
* // Create tool for sending email via support Gmail account
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
config.
|
|
242
|
-
options.
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
1
|
+
import type { z } from 'zod'
|
|
2
|
+
import type { Tool, ToolExecutionOptions } from '../types'
|
|
3
|
+
import { ToolingError } from '../types'
|
|
4
|
+
import { getToolServices } from '../registry'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Supported integration types
|
|
8
|
+
*
|
|
9
|
+
* These represent the available integration adapters that can be used with tools.
|
|
10
|
+
* Each integration type corresponds to an adapter implementation.
|
|
11
|
+
*
|
|
12
|
+
* Note: Concrete adapter implementations are deferred until needed.
|
|
13
|
+
* This type provides compile-time safety and auto-completion for tool definitions.
|
|
14
|
+
*/
|
|
15
|
+
export type IntegrationType =
|
|
16
|
+
| 'gmail' // Google Gmail API
|
|
17
|
+
| 'google-sheets' // Google Sheets API
|
|
18
|
+
| 'slack' // Slack API
|
|
19
|
+
| 'github' // GitHub API
|
|
20
|
+
| 'linear' // Linear API
|
|
21
|
+
| 'attio' // Attio CRM API
|
|
22
|
+
| 'airtable' // Airtable API
|
|
23
|
+
| 'salesforce' // Salesforce API
|
|
24
|
+
| 'hubspot' // HubSpot API
|
|
25
|
+
| 'stripe' // Stripe API
|
|
26
|
+
| 'twilio' // Twilio API
|
|
27
|
+
| 'sendgrid' // SendGrid API
|
|
28
|
+
| 'mailgun' // Mailgun API
|
|
29
|
+
| 'zapier' // Zapier Webhooks
|
|
30
|
+
| 'webhook' // Generic webhook
|
|
31
|
+
| 'apify' // Apify actor automation
|
|
32
|
+
| 'instantly' // Instantly.ai email automation
|
|
33
|
+
| 'resend' // Resend transactional email API
|
|
34
|
+
| 'signature-api' // SignatureAPI eSignature service
|
|
35
|
+
| 'dropbox' // Dropbox file storage API
|
|
36
|
+
| 'anymailfinder' // Anymailfinder email finder API
|
|
37
|
+
| 'tomba' // Tomba email discovery API
|
|
38
|
+
| 'millionverifier' // MillionVerifier email verification API
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Type-safe method names for each integration
|
|
42
|
+
* Provides compile-time validation and IDE auto-completion
|
|
43
|
+
*/
|
|
44
|
+
export type GmailMethod = 'sendEmail' | 'searchEmails' | 'readEmail' | 'createDraft' | 'addLabel'
|
|
45
|
+
export type SlackMethod = 'postMessage' | 'listChannels' | 'createChannel' | 'uploadFile' | 'addReaction'
|
|
46
|
+
export type GithubMethod = 'createIssue' | 'createPR' | 'addComment' | 'listIssues'
|
|
47
|
+
export type LinearMethod = 'createIssue' | 'updateIssue' | 'listIssues'
|
|
48
|
+
export type AttioMethod =
|
|
49
|
+
| 'createRecord'
|
|
50
|
+
| 'updateRecord'
|
|
51
|
+
| 'listRecords'
|
|
52
|
+
| 'getRecord'
|
|
53
|
+
| 'deleteRecord'
|
|
54
|
+
| 'createTask'
|
|
55
|
+
| 'createNote'
|
|
56
|
+
| 'listNotes'
|
|
57
|
+
| 'deleteNote'
|
|
58
|
+
| 'listObjects'
|
|
59
|
+
| 'listAttributes'
|
|
60
|
+
| 'createAttribute'
|
|
61
|
+
| 'updateAttribute'
|
|
62
|
+
export type AirtableMethod = 'listRecords' | 'createRecord' | 'updateRecord' | 'deleteRecord'
|
|
63
|
+
export type SalesforceMethod = 'query' | 'create' | 'update' | 'delete'
|
|
64
|
+
export type HubspotMethod = 'createContact' | 'updateContact' | 'listContacts'
|
|
65
|
+
export type StripeMethod =
|
|
66
|
+
| 'createPaymentLink'
|
|
67
|
+
| 'getPaymentLink'
|
|
68
|
+
| 'updatePaymentLink'
|
|
69
|
+
| 'listPaymentLinks'
|
|
70
|
+
| 'createCheckoutSession'
|
|
71
|
+
| 'createAutoPaymentLink'
|
|
72
|
+
export type TwilioMethod = 'sendSMS' | 'sendWhatsApp' | 'makeCall'
|
|
73
|
+
export type SendgridMethod = 'sendEmail' | 'addToList'
|
|
74
|
+
export type MailgunMethod = 'sendEmail' | 'validateEmail'
|
|
75
|
+
export type ZapierMethod = 'trigger'
|
|
76
|
+
export type WebhookMethod = 'call'
|
|
77
|
+
export type GoogleSheetsMethod =
|
|
78
|
+
| 'readSheet'
|
|
79
|
+
| 'writeSheet'
|
|
80
|
+
| 'appendRows'
|
|
81
|
+
| 'clearRange'
|
|
82
|
+
| 'getSpreadsheetMetadata'
|
|
83
|
+
| 'batchUpdate'
|
|
84
|
+
| 'getHeaders'
|
|
85
|
+
| 'getLastRow'
|
|
86
|
+
| 'getRowByValue'
|
|
87
|
+
| 'updateRowByValue'
|
|
88
|
+
| 'upsertRow'
|
|
89
|
+
| 'filterRows'
|
|
90
|
+
| 'deleteRowByValue'
|
|
91
|
+
export type ApifyMethod = 'runActor' | 'getDatasetItems' | 'startActor'
|
|
92
|
+
export type InstantlyMethod =
|
|
93
|
+
| 'sendReply'
|
|
94
|
+
| 'updateInterestStatus'
|
|
95
|
+
| 'removeFromSubsequence'
|
|
96
|
+
| 'deleteLead'
|
|
97
|
+
| 'moveLead'
|
|
98
|
+
| 'getEmails'
|
|
99
|
+
| 'addToCampaign'
|
|
100
|
+
| 'listCampaigns'
|
|
101
|
+
| 'getCampaign'
|
|
102
|
+
| 'updateCampaign'
|
|
103
|
+
| 'pauseCampaign'
|
|
104
|
+
| 'activateCampaign'
|
|
105
|
+
| 'getCampaignAnalytics'
|
|
106
|
+
| 'getStepAnalytics'
|
|
107
|
+
| 'bulkAddLeads'
|
|
108
|
+
| 'getAccountHealth'
|
|
109
|
+
| 'createInboxTest'
|
|
110
|
+
| 'createCampaign'
|
|
111
|
+
| 'getDailyCampaignAnalytics'
|
|
112
|
+
| 'listLeads'
|
|
113
|
+
| 'bulkDeleteLeads'
|
|
114
|
+
| 'deleteCampaign'
|
|
115
|
+
export type ResendMethod = 'sendEmail' | 'getEmail'
|
|
116
|
+
export type SignatureApiMethod = 'createEnvelope' | 'voidEnvelope' | 'downloadDocument' | 'getEnvelope'
|
|
117
|
+
export type DropboxMethod = 'uploadFile' | 'createFolder'
|
|
118
|
+
export type AnymailfinderMethod = 'findCompanyEmail' | 'findPersonEmail' | 'findDecisionMakerEmail' | 'verifyEmail'
|
|
119
|
+
export type TombaMethod = 'emailFinder' | 'domainSearch' | 'emailVerifier'
|
|
120
|
+
export type MillionVerifierMethod = 'verifyEmail' | 'checkCredits'
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Map integration types to their method types
|
|
124
|
+
*/
|
|
125
|
+
export type IntegrationMethodMap = {
|
|
126
|
+
gmail: GmailMethod
|
|
127
|
+
'google-sheets': GoogleSheetsMethod
|
|
128
|
+
slack: SlackMethod
|
|
129
|
+
github: GithubMethod
|
|
130
|
+
linear: LinearMethod
|
|
131
|
+
attio: AttioMethod
|
|
132
|
+
airtable: AirtableMethod
|
|
133
|
+
salesforce: SalesforceMethod
|
|
134
|
+
hubspot: HubspotMethod
|
|
135
|
+
stripe: StripeMethod
|
|
136
|
+
twilio: TwilioMethod
|
|
137
|
+
sendgrid: SendgridMethod
|
|
138
|
+
mailgun: MailgunMethod
|
|
139
|
+
zapier: ZapierMethod
|
|
140
|
+
webhook: WebhookMethod
|
|
141
|
+
apify: ApifyMethod
|
|
142
|
+
instantly: InstantlyMethod
|
|
143
|
+
resend: ResendMethod
|
|
144
|
+
'signature-api': SignatureApiMethod
|
|
145
|
+
dropbox: DropboxMethod
|
|
146
|
+
anymailfinder: AnymailfinderMethod
|
|
147
|
+
tomba: TombaMethod
|
|
148
|
+
millionverifier: MillionVerifierMethod
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Configuration for creating an integration tool.
|
|
153
|
+
* Integration tools call external APIs (Gmail, Slack, etc.) using organization credentials.
|
|
154
|
+
*
|
|
155
|
+
* @template T - Integration type (e.g., 'gmail', 'slack')
|
|
156
|
+
*/
|
|
157
|
+
export interface IntegrationToolConfig<T extends IntegrationType = IntegrationType> {
|
|
158
|
+
/** Unique name for the tool (e.g., 'gmail_sendEmail', 'slack_postMessage') */
|
|
159
|
+
name: string
|
|
160
|
+
/** Description of what the tool does (shown to LLM) */
|
|
161
|
+
description: string
|
|
162
|
+
/** Zod schema for validating input */
|
|
163
|
+
inputSchema: z.ZodSchema
|
|
164
|
+
/** Zod schema for validating output */
|
|
165
|
+
outputSchema: z.ZodSchema
|
|
166
|
+
/** Integration adapter type (e.g., 'gmail', 'slack') */
|
|
167
|
+
integration: T
|
|
168
|
+
/** Method to call on the integration adapter (type-safe based on integration) */
|
|
169
|
+
method: T extends keyof IntegrationMethodMap ? IntegrationMethodMap[T] : string
|
|
170
|
+
/** Credential name to use from credentials table (e.g., 'support-gmail', 'sales-gmail') */
|
|
171
|
+
credentialName: string
|
|
172
|
+
/** Optional callback executed after successful tool execution (e.g., cache updates) - receives full options including iterationContext for memory management */
|
|
173
|
+
onSuccess?: (result: unknown, options: ToolExecutionOptions) => void | Promise<void>
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Create an integration tool that calls external APIs using organization credentials
|
|
178
|
+
*
|
|
179
|
+
* Integration tools enable agents to interact with external services (Gmail, Slack, etc.)
|
|
180
|
+
* using encrypted credentials stored in the credentials table. Each tool
|
|
181
|
+
* specifies which credential name to use, allowing multiple credentials per integration type.
|
|
182
|
+
*
|
|
183
|
+
* @param config - Configuration for the integration tool
|
|
184
|
+
* @returns Tool that calls the integration adapter with credentials
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* // Create tool for sending email via support Gmail account
|
|
188
|
+
* import { EmailSchema } from '@repo/core'
|
|
189
|
+
* const sendSupportEmail = createIntegrationTool({
|
|
190
|
+
* name: 'send_support_email',
|
|
191
|
+
* description: 'Send email from support@company.com',
|
|
192
|
+
* inputSchema: z.object({
|
|
193
|
+
* to: EmailSchema,
|
|
194
|
+
* subject: z.string(),
|
|
195
|
+
* body: z.string()
|
|
196
|
+
* }),
|
|
197
|
+
* outputSchema: z.object({ messageId: z.string() }),
|
|
198
|
+
* integration: 'gmail',
|
|
199
|
+
* method: 'sendEmail',
|
|
200
|
+
* credentialName: 'support-gmail'
|
|
201
|
+
* })
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* // Create tool for sending email via sales Gmail account
|
|
205
|
+
* import { EmailSchema } from '@repo/core'
|
|
206
|
+
* const sendSalesEmail = createIntegrationTool({
|
|
207
|
+
* name: 'send_sales_email',
|
|
208
|
+
* description: 'Send email from sales@company.com',
|
|
209
|
+
* inputSchema: z.object({
|
|
210
|
+
* to: EmailSchema,
|
|
211
|
+
* subject: z.string(),
|
|
212
|
+
* body: z.string()
|
|
213
|
+
* }),
|
|
214
|
+
* outputSchema: z.object({ messageId: z.string() }),
|
|
215
|
+
* integration: 'gmail',
|
|
216
|
+
* method: 'sendEmail',
|
|
217
|
+
* credentialName: 'sales-gmail' // Different credential, same integration
|
|
218
|
+
* })
|
|
219
|
+
*/
|
|
220
|
+
export function createIntegrationTool(config: IntegrationToolConfig): Tool {
|
|
221
|
+
return {
|
|
222
|
+
name: config.name,
|
|
223
|
+
description: config.description,
|
|
224
|
+
inputSchema: config.inputSchema,
|
|
225
|
+
outputSchema: config.outputSchema,
|
|
226
|
+
|
|
227
|
+
async execute(options: ToolExecutionOptions): Promise<unknown> {
|
|
228
|
+
// Get integration service from global registry
|
|
229
|
+
const { integrationService } = getToolServices()
|
|
230
|
+
if (!integrationService) {
|
|
231
|
+
throw new ToolingError(
|
|
232
|
+
'service_unavailable',
|
|
233
|
+
'IntegrationService not initialized. Ensure toolServicesRegistry.initialize() was called in apps/api/src/main.ts',
|
|
234
|
+
{ integration: config.integration, method: config.method }
|
|
235
|
+
)
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Call integration service
|
|
239
|
+
const result = await integrationService.call(
|
|
240
|
+
config.integration,
|
|
241
|
+
config.method,
|
|
242
|
+
options.input,
|
|
243
|
+
config.credentialName,
|
|
244
|
+
options.executionContext
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
// Execute onSuccess hook if provided (e.g., for cache updates)
|
|
248
|
+
if (config.onSuccess) {
|
|
249
|
+
await config.onSuccess(result, options)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return result
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|