@elevasis/core 0.26.0 → 0.28.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 (49) hide show
  1. package/dist/index.d.ts +162 -105
  2. package/dist/index.js +280 -174
  3. package/dist/knowledge/index.d.ts +43 -43
  4. package/dist/organization-model/index.d.ts +162 -105
  5. package/dist/organization-model/index.js +280 -174
  6. package/dist/test-utils/index.d.ts +20 -20
  7. package/dist/test-utils/index.js +184 -126
  8. package/package.json +3 -3
  9. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +976 -1063
  10. package/src/business/acquisition/api-schemas.test.ts +1962 -1841
  11. package/src/business/acquisition/api-schemas.ts +1461 -1464
  12. package/src/business/acquisition/crm-next-action.test.ts +45 -25
  13. package/src/business/acquisition/crm-next-action.ts +227 -220
  14. package/src/business/acquisition/crm-priority.test.ts +41 -8
  15. package/src/business/acquisition/crm-priority.ts +365 -349
  16. package/src/business/acquisition/crm-state-actions.test.ts +208 -153
  17. package/src/business/acquisition/derive-actions.test.ts +90 -13
  18. package/src/business/acquisition/derive-actions.ts +8 -139
  19. package/src/business/acquisition/ontology-validation.ts +72 -158
  20. package/src/business/pdf/sections/investment.ts +1 -1
  21. package/src/business/pdf/sections/summary-investment.ts +1 -1
  22. package/src/execution/engine/tools/tool-maps.ts +872 -831
  23. package/src/organization-model/__tests__/cross-ref.test.ts +167 -0
  24. package/src/organization-model/__tests__/define-domain-record.test.ts +289 -0
  25. package/src/organization-model/__tests__/om-spine-doc-contract.test.ts +56 -0
  26. package/src/organization-model/__tests__/published-zero-leak.test.ts +60 -1
  27. package/src/organization-model/__tests__/resolve.test.ts +1 -1
  28. package/src/organization-model/__tests__/schema-refinements.test.ts +72 -0
  29. package/src/organization-model/cross-ref.ts +175 -0
  30. package/src/organization-model/domains/actions.ts +13 -0
  31. package/src/organization-model/domains/branding.ts +6 -6
  32. package/src/organization-model/domains/customers.ts +95 -78
  33. package/src/organization-model/domains/entities.ts +157 -144
  34. package/src/organization-model/domains/goals.ts +100 -83
  35. package/src/organization-model/domains/knowledge.ts +106 -93
  36. package/src/organization-model/domains/offerings.ts +88 -71
  37. package/src/organization-model/domains/policies.ts +115 -102
  38. package/src/organization-model/domains/roles.ts +109 -96
  39. package/src/organization-model/domains/sales.test.ts +104 -218
  40. package/src/organization-model/domains/sales.ts +212 -375
  41. package/src/organization-model/domains/statuses.ts +351 -339
  42. package/src/organization-model/domains/systems.ts +176 -164
  43. package/src/organization-model/helpers.ts +331 -306
  44. package/src/organization-model/index.ts +43 -0
  45. package/src/organization-model/published.ts +27 -2
  46. package/src/organization-model/schema-refinements.ts +667 -0
  47. package/src/organization-model/schema.ts +8 -715
  48. package/src/platform/constants/versions.ts +1 -1
  49. package/src/reference/_generated/contracts.md +1000 -1087
@@ -1,831 +1,872 @@
1
- /**
2
- * Tool Method Maps
3
- *
4
- * Single source of truth for tool -> method -> params -> result type mappings.
5
- * Used by SDK adapters (compile-time typed wrappers) and optionally by the
6
- * server-side dispatcher for type checking.
7
- *
8
- * Browser-safe: no Node.js imports, pure type definitions.
9
- */
10
-
11
- import type {
12
- CreateRecordParams,
13
- CreateRecordResult,
14
- UpdateRecordParams,
15
- UpdateRecordResult,
16
- QueryRecordsParams,
17
- QueryRecordsResult,
18
- GetRecordParams,
19
- GetRecordResult,
20
- DeleteRecordParams,
21
- DeleteRecordResult,
22
- ListObjectsResult,
23
- ListAttributesParams,
24
- ListAttributesResult,
25
- CreateAttributeParams,
26
- CreateAttributeResult,
27
- UpdateAttributeParams,
28
- UpdateAttributeResult,
29
- CreateNoteParams,
30
- CreateNoteResult,
31
- ListNotesParams,
32
- ListNotesResult,
33
- DeleteNoteParams,
34
- DeleteNoteResult
35
- } from './integration/types/attio'
36
-
37
- import type {
38
- RunActorParams,
39
- RunActorResult,
40
- GetDatasetItemsParams,
41
- GetDatasetItemsResult,
42
- StartActorParams,
43
- StartActorResult
44
- } from './integration/types/apify'
45
-
46
- import type {
47
- UploadFileParams,
48
- UploadFileResult,
49
- CreateFolderParams,
50
- CreateFolderResult
51
- } from './integration/types/dropbox'
52
-
53
- import type { GmailSendEmailParams, GmailSendEmailResult } from './integration/types/gmail'
54
-
55
- import type {
56
- ReadSheetParams,
57
- ReadSheetResult,
58
- WriteSheetParams,
59
- WriteSheetResult,
60
- AppendRowsParams,
61
- AppendRowsResult,
62
- ClearRangeParams,
63
- ClearRangeResult,
64
- GetSpreadsheetMetadataParams,
65
- GetSpreadsheetMetadataResult,
66
- BatchUpdateParams,
67
- BatchUpdateResult,
68
- GetHeadersParams,
69
- GetHeadersResult,
70
- GetLastRowParams,
71
- GetLastRowResult,
72
- GetRowByValueParams,
73
- GetRowByValueResult,
74
- UpdateRowByValueParams,
75
- UpdateRowByValueResult,
76
- UpsertRowParams,
77
- UpsertRowResult,
78
- FilterRowsParams,
79
- FilterRowsResult,
80
- DeleteRowByValueParams,
81
- DeleteRowByValueResult
82
- } from './integration/types/google-sheets'
83
-
84
- import type {
85
- SendReplyParams,
86
- SendReplyResult,
87
- RemoveFromSubsequenceParams,
88
- RemoveFromSubsequenceResult,
89
- GetEmailsParams,
90
- GetEmailsResult,
91
- UpdateInterestStatusParams,
92
- UpdateInterestStatusResult,
93
- AddToCampaignParams,
94
- AddToCampaignResult,
95
- ListCampaignsParams,
96
- ListCampaignsResult,
97
- GetCampaignParams,
98
- GetCampaignResult,
99
- UpdateCampaignParams,
100
- UpdateCampaignResult,
101
- PauseCampaignParams,
102
- PauseCampaignResult,
103
- ActivateCampaignParams,
104
- ActivateCampaignResult,
105
- GetCampaignAnalyticsParams,
106
- GetCampaignAnalyticsResult,
107
- GetStepAnalyticsParams,
108
- GetStepAnalyticsResult,
109
- BulkAddLeadsParams,
110
- BulkAddLeadsResult,
111
- GetAccountHealthParams,
112
- GetAccountHealthResult,
113
- CreateInboxTestParams,
114
- CreateInboxTestResult,
115
- CreateCampaignParams,
116
- CreateCampaignResult,
117
- GetDailyCampaignAnalyticsParams,
118
- GetDailyCampaignAnalyticsResult,
119
- ListLeadsParams,
120
- ListLeadsResult,
121
- BulkDeleteLeadsParams,
122
- BulkDeleteLeadsResult,
123
- DeleteCampaignParams,
124
- DeleteCampaignResult,
125
- PatchLeadParams,
126
- PatchLeadResult
127
- } from './integration/types/instantly'
128
-
129
- import type {
130
- MillionVerifierVerifyEmailParams,
131
- MillionVerifierVerifyEmailResult,
132
- MillionVerifierCheckCreditsParams,
133
- MillionVerifierCheckCreditsResult
134
- } from './integration/types/millionverifier'
135
-
136
- import type {
137
- FindCompanyEmailParams,
138
- FindCompanyEmailResult,
139
- FindPersonEmailParams,
140
- FindPersonEmailResult,
141
- FindDecisionMakerEmailParams,
142
- FindDecisionMakerEmailResult,
143
- VerifyEmailParams,
144
- VerifyEmailResult
145
- } from './integration/types/anymailfinder'
146
-
147
- import type {
148
- EmailFinderParams,
149
- EmailFinderResult,
150
- DomainSearchParams,
151
- DomainSearchResult,
152
- EmailVerifierParams,
153
- EmailVerifierResult
154
- } from './integration/types/tomba'
155
-
156
- import type {
157
- ResendSendEmailParams,
158
- ResendSendEmailResult,
159
- ResendGetEmailParams,
160
- ResendGetEmailResult
161
- } from './integration/types/resend'
162
-
163
- import type {
164
- CreateEnvelopeParams,
165
- CreateEnvelopeResult,
166
- VoidEnvelopeParams,
167
- VoidEnvelopeResult,
168
- DownloadDocumentParams,
169
- DownloadDocumentResult,
170
- GetEnvelopeParams,
171
- GetEnvelopeResult
172
- } from './integration/types/signature-api'
173
-
174
- import type {
175
- CreatePaymentLinkParams,
176
- CreatePaymentLinkResult,
177
- GetPaymentLinkParams,
178
- GetPaymentLinkResult,
179
- UpdatePaymentLinkParams,
180
- UpdatePaymentLinkResult,
181
- ListPaymentLinksParams,
182
- ListPaymentLinksResult,
183
- CreateAutoPaymentLinkParams,
184
- CreateAutoPaymentLinkResult,
185
- CreateCheckoutSessionParams,
186
- CreateCheckoutSessionResult
187
- } from './integration/types/stripe'
188
-
189
- import type {
190
- StorageUploadInput,
191
- StorageUploadOutput,
192
- StorageDownloadInput,
193
- StorageDownloadOutput,
194
- StorageSignedUrlInput,
195
- StorageSignedUrlOutput,
196
- StorageDeleteInput,
197
- StorageDeleteOutput,
198
- StorageListInput,
199
- StorageListOutput
200
- } from './platform/storage/types'
201
-
202
- import type { CreateScheduleInput, TaskSchedule } from '../../scheduler/types'
203
-
204
- import type { CreateNotificationParams } from '../../../operations/notifications/types'
205
-
206
- import type {
207
- AcqList,
208
- AcqCompany,
209
- AcqContact,
210
- PaginatedResult,
211
- CreateListParams,
212
- UpdateListParams,
213
- CreateCompanyParams,
214
- UpdateCompanyParams,
215
- UpsertCompanyParams,
216
- CompanyFilters,
217
- CreateContactParams,
218
- UpdateContactParams,
219
- UpsertContactParams,
220
- ContactFilters,
221
- UpsertDealParams,
222
- AcqDeal,
223
- AcqDealNote,
224
- AcqDealTask,
225
- CreateDealNoteParams,
226
- ListDealNotesParams,
227
- CreateDealTaskParams,
228
- ListDealTasksParams,
229
- ListDealTasksDueParams,
230
- CompleteDealTaskParams,
231
- RecordDealActivityParams,
232
- AddContactsToListParams,
233
- AddContactsToListResult,
234
- AddCompaniesToListParams,
235
- AddCompaniesToListResult,
236
- BulkImportParams,
237
- BulkImportResult,
238
- BulkImportCompaniesParams,
239
- BulkImportCompaniesResult,
240
- UpdateDiscoveryDataParams,
241
- UpdateProposalDataParams,
242
- MarkProposalSentParams,
243
- MarkProposalReviewedParams,
244
- UpdateCloseLostReasonParams,
245
- UpdateFeesParams,
246
- CacheInstantlyThreadIdsParams,
247
- TransitionItemParams,
248
- SetContactNurtureParams,
249
- CancelSchedulesAndHitlByEmailParams,
250
- CancelHitlByDealIdParams,
251
- ClearDealFieldsParams,
252
- DeleteDealParams,
253
- DealFilters,
254
- DealPipelineAnalytics,
255
- ScrapingConfig,
256
- IcpRubric,
257
- PipelineConfig,
258
- RecordListExecutionParams,
259
- UpdateCompanyStageParams,
260
- UpdateContactStageParams,
261
- ListPendingCompanyIdsParams,
262
- ListPendingContactIdsParams,
263
- UpsertSocialPostParams,
264
- UpsertSocialPostsResult,
265
- GetDealByIdParams,
266
- GetContactByIdParams,
267
- GetCompanyByIdParams
268
- } from './lead-service-types'
269
-
270
- import type { DealListItem, DealDetail } from '../../../business/acquisition'
271
- import { CrmSchemas } from '../../../business/sales/api-schemas'
272
- import type { RecentActivityEntry } from '../../../business/sales/api-schemas'
273
- import { DealSchemas } from '../../../business/acquisition'
274
- import { ProjectSchemas } from '../../../projects/api-schemas'
275
- import type {
276
- ProjectRow,
277
- MilestoneRow,
278
- TaskRow,
279
- NoteRow,
280
- ProjectWithCounts,
281
- ProjectDetail
282
- } from '../../../business/projects'
283
- import type { z } from 'zod'
284
-
285
- // ---------------------------------------------------------------------------
286
- // Generic constraint types
287
- // ---------------------------------------------------------------------------
288
-
289
- /** A single method entry: what params go in, what result comes out */
290
- export interface MethodEntry {
291
- params: unknown
292
- result: unknown
293
- }
294
-
295
- /** A tool's complete method map: method name -> MethodEntry */
296
- export type ToolMethodMap = Record<string, MethodEntry>
297
-
298
- // ---------------------------------------------------------------------------
299
- // Attio (integration adapter, 12 methods)
300
- // ---------------------------------------------------------------------------
301
-
302
- export type AttioToolMap = {
303
- createRecord: { params: CreateRecordParams; result: CreateRecordResult }
304
- updateRecord: { params: UpdateRecordParams; result: UpdateRecordResult }
305
- listRecords: { params: QueryRecordsParams; result: QueryRecordsResult }
306
- getRecord: { params: GetRecordParams; result: GetRecordResult }
307
- deleteRecord: { params: DeleteRecordParams; result: DeleteRecordResult }
308
- listObjects: { params: Record<string, never>; result: ListObjectsResult }
309
- listAttributes: { params: ListAttributesParams; result: ListAttributesResult }
310
- createAttribute: { params: CreateAttributeParams; result: CreateAttributeResult }
311
- updateAttribute: { params: UpdateAttributeParams; result: UpdateAttributeResult }
312
- createNote: { params: CreateNoteParams; result: CreateNoteResult }
313
- listNotes: { params: ListNotesParams; result: ListNotesResult }
314
- deleteNote: { params: DeleteNoteParams; result: DeleteNoteResult }
315
- }
316
-
317
- // ---------------------------------------------------------------------------
318
- // Scheduler (platform tool, 9 methods)
319
- // ---------------------------------------------------------------------------
320
-
321
- export type SchedulerToolMap = {
322
- createSchedule: { params: CreateScheduleInput; result: TaskSchedule }
323
- updateAnchor: { params: { scheduleId: string; anchorAt: string }; result: TaskSchedule }
324
- deleteSchedule: { params: { scheduleId: string }; result: void }
325
- findByIdempotencyKey: { params: { idempotencyKey: string }; result: TaskSchedule | null }
326
- deleteScheduleByIdempotencyKey: { params: { idempotencyKey: string }; result: void }
327
- listSchedules: { params: { status?: string; limit?: number; offset?: number }; result: TaskSchedule[] }
328
- getSchedule: { params: { scheduleId: string }; result: TaskSchedule }
329
- cancelSchedule: { params: { scheduleId: string }; result: void }
330
- cancelSchedulesByMetadata: { params: { metadata: Record<string, unknown> }; result: { cancelledCount: number } }
331
- cancelScheduleByIdempotencyKey: { params: { idempotencyKey: string }; result: { cancelled: boolean } }
332
- }
333
-
334
- // ---------------------------------------------------------------------------
335
- // Storage (platform tool, 5 methods)
336
- // ---------------------------------------------------------------------------
337
-
338
- export type StorageToolMap = {
339
- upload: { params: StorageUploadInput; result: StorageUploadOutput }
340
- download: { params: StorageDownloadInput; result: StorageDownloadOutput }
341
- createSignedUrl: { params: StorageSignedUrlInput; result: StorageSignedUrlOutput }
342
- delete: { params: StorageDeleteInput; result: StorageDeleteOutput }
343
- list: { params: StorageListInput; result: StorageListOutput }
344
- }
345
-
346
- // ---------------------------------------------------------------------------
347
- // Notification (platform tool, 1 method)
348
- // ---------------------------------------------------------------------------
349
-
350
- /**
351
- * SDK-side notification input.
352
- * Omits userId and organizationId which are injected server-side from execution context.
353
- */
354
- export type NotificationSDKInput = Omit<CreateNotificationParams, 'userId' | 'organizationId'>
355
-
356
- export type NotificationToolMap = {
357
- create: { params: NotificationSDKInput; result: void }
358
- }
359
-
360
- // ---------------------------------------------------------------------------
361
- // Projects (platform tool, 18 methods)
362
- // ---------------------------------------------------------------------------
363
-
364
- type ProjectsListParams = z.infer<typeof ProjectSchemas.GetProjectsQuery>
365
- type ProjectCreateParams = z.infer<typeof ProjectSchemas.CreateProjectRequest>
366
- type ProjectUpdateParams = z.infer<typeof ProjectSchemas.UpdateProjectRequest>
367
- type MilestoneCreateParams = z.infer<typeof ProjectSchemas.ProjectIdPathParams> &
368
- z.infer<typeof ProjectSchemas.CreateMilestoneRequest>
369
- type MilestoneUpdateParams = z.infer<typeof ProjectSchemas.UpdateMilestoneRequest>
370
- type TaskListParams = z.infer<typeof ProjectSchemas.ProjectIdPathParams> & z.infer<typeof ProjectSchemas.GetTasksQuery>
371
- type TaskCreateParams = z.infer<typeof ProjectSchemas.CreateTaskRequest>
372
- type TaskUpdateParams = z.infer<typeof ProjectSchemas.UpdateTaskRequest>
373
- type TaskResumeContextParams = z.infer<typeof ProjectSchemas.TaskIdParams> &
374
- z.infer<typeof ProjectSchemas.MergeResumeContextRequest>
375
- type NoteListParams = z.infer<typeof ProjectSchemas.ProjectIdPathParams>
376
- type NoteCreateParams = z.infer<typeof ProjectSchemas.CreateNoteRequest>
377
- type NoteUpdateParams = z.infer<typeof ProjectSchemas.UpdateNoteRequest>
378
- type TaskResumeContextResult = Pick<TaskRow, 'id' | 'resume_context' | 'updated_at'>
379
-
380
- export type ProjectsToolMap = {
381
- listProjects: { params: ProjectsListParams; result: ProjectWithCounts[] }
382
- getProject: { params: z.infer<typeof ProjectSchemas.ProjectIdParams>; result: ProjectDetail }
383
- createProject: { params: ProjectCreateParams; result: ProjectRow }
384
- updateProject: { params: z.infer<typeof ProjectSchemas.ProjectIdParams> & ProjectUpdateParams; result: ProjectRow }
385
- deleteProject: { params: z.infer<typeof ProjectSchemas.ProjectIdParams>; result: void }
386
- listMilestones: { params: z.infer<typeof ProjectSchemas.ProjectIdPathParams>; result: MilestoneRow[] }
387
- createMilestone: { params: MilestoneCreateParams; result: MilestoneRow }
388
- updateMilestone: {
389
- params: z.infer<typeof ProjectSchemas.MilestoneIdParams> & MilestoneUpdateParams
390
- result: MilestoneRow
391
- }
392
- deleteMilestone: { params: z.infer<typeof ProjectSchemas.MilestoneIdParams>; result: void }
393
- listTasks: { params: TaskListParams; result: TaskRow[] }
394
- getTask: { params: z.infer<typeof ProjectSchemas.TaskIdParams>; result: TaskRow }
395
- createTask: { params: TaskCreateParams; result: TaskRow }
396
- updateTask: { params: z.infer<typeof ProjectSchemas.TaskIdParams> & TaskUpdateParams; result: TaskRow }
397
- deleteTask: { params: z.infer<typeof ProjectSchemas.TaskIdParams>; result: void }
398
- mergeTaskResumeContext: { params: TaskResumeContextParams; result: TaskResumeContextResult }
399
- listNotes: { params: NoteListParams; result: NoteRow[] }
400
- createNote: { params: NoteCreateParams; result: NoteRow }
401
- updateNote: { params: z.infer<typeof ProjectSchemas.NoteIdParams> & NoteUpdateParams; result: NoteRow }
402
- deleteNote: { params: z.infer<typeof ProjectSchemas.NoteIdParams>; result: void }
403
- }
404
-
405
- // ---------------------------------------------------------------------------
406
- // CRM (platform tool, 13 methods)
407
- // ---------------------------------------------------------------------------
408
-
409
- type CrmRecentActivityParams = Partial<z.infer<typeof CrmSchemas.GetRecentActivityQuery>>
410
- type CrmListDealsParams = Partial<z.infer<typeof DealSchemas.ListDealsQuery>>
411
- type CrmGetDealParams = z.infer<typeof DealSchemas.DealIdParams>
412
- type CrmGetDealByEmailParams = { email: string }
413
- type CrmTaskDueParams = Partial<z.infer<typeof DealSchemas.ListDealTasksDueQuery>>
414
- type CrmDealTaskParams = Omit<CreateDealTaskParams, 'organizationId'>
415
- type CrmDealNoteParams = Omit<CreateDealNoteParams, 'organizationId'>
416
- type CrmRecordActivityParams = Omit<RecordDealActivityParams, 'organizationId'>
417
- type CrmDeleteDealParams = Omit<DeleteDealParams, 'organizationId'>
418
-
419
- export type CrmToolMap = {
420
- getRecentActivity: { params: CrmRecentActivityParams; result: RecentActivityEntry[] }
421
- listDeals: { params: CrmListDealsParams; result: DealListItem[] }
422
- getDeal: { params: CrmGetDealParams; result: DealDetail | null }
423
- getDealByEmail: { params: CrmGetDealByEmailParams; result: DealDetail | null }
424
- createDealNote: { params: CrmDealNoteParams; result: AcqDealNote }
425
- listDealNotes: { params: Omit<ListDealNotesParams, 'organizationId'>; result: AcqDealNote[] }
426
- createDealTask: { params: CrmDealTaskParams; result: AcqDealTask }
427
- listDealTasks: { params: Omit<ListDealTasksParams, 'organizationId'>; result: AcqDealTask[] }
428
- listDealTasksDue: { params: CrmTaskDueParams; result: AcqDealTask[] }
429
- completeDealTask: { params: Omit<CompleteDealTaskParams, 'organizationId'>; result: AcqDealTask }
430
- recordActivity: { params: CrmRecordActivityParams; result: void }
431
- deleteDeal: { params: CrmDeleteDealParams; result: void }
432
- }
433
-
434
- // ---------------------------------------------------------------------------
435
- // Stripe (integration adapter, 6 methods)
436
- // ---------------------------------------------------------------------------
437
-
438
- export type StripeToolMap = {
439
- createPaymentLink: { params: CreatePaymentLinkParams; result: CreatePaymentLinkResult }
440
- getPaymentLink: { params: GetPaymentLinkParams; result: GetPaymentLinkResult }
441
- updatePaymentLink: { params: UpdatePaymentLinkParams; result: UpdatePaymentLinkResult }
442
- listPaymentLinks: { params: ListPaymentLinksParams; result: ListPaymentLinksResult }
443
- createAutoPaymentLink: { params: CreateAutoPaymentLinkParams; result: CreateAutoPaymentLinkResult }
444
- createCheckoutSession: { params: CreateCheckoutSessionParams; result: CreateCheckoutSessionResult }
445
- }
446
-
447
- // ---------------------------------------------------------------------------
448
- // Google Sheets (integration adapter, 13 methods)
449
- // ---------------------------------------------------------------------------
450
-
451
- export type GoogleSheetsToolMap = {
452
- readSheet: { params: ReadSheetParams; result: ReadSheetResult }
453
- writeSheet: { params: WriteSheetParams; result: WriteSheetResult }
454
- appendRows: { params: AppendRowsParams; result: AppendRowsResult }
455
- clearRange: { params: ClearRangeParams; result: ClearRangeResult }
456
- getSpreadsheetMetadata: { params: GetSpreadsheetMetadataParams; result: GetSpreadsheetMetadataResult }
457
- batchUpdate: { params: BatchUpdateParams; result: BatchUpdateResult }
458
- getHeaders: { params: GetHeadersParams; result: GetHeadersResult }
459
- getLastRow: { params: GetLastRowParams; result: GetLastRowResult }
460
- getRowByValue: { params: GetRowByValueParams; result: GetRowByValueResult }
461
- updateRowByValue: { params: UpdateRowByValueParams; result: UpdateRowByValueResult }
462
- upsertRow: { params: UpsertRowParams; result: UpsertRowResult }
463
- filterRows: { params: FilterRowsParams; result: FilterRowsResult }
464
- deleteRowByValue: { params: DeleteRowByValueParams; result: DeleteRowByValueResult }
465
- }
466
-
467
- // ---------------------------------------------------------------------------
468
- // Resend (integration adapter, 2 methods)
469
- // ---------------------------------------------------------------------------
470
-
471
- export type ResendToolMap = {
472
- sendEmail: { params: ResendSendEmailParams; result: ResendSendEmailResult }
473
- getEmail: { params: ResendGetEmailParams; result: ResendGetEmailResult }
474
- }
475
-
476
- // ---------------------------------------------------------------------------
477
- // Apify (integration adapter, 2 methods)
478
- // ---------------------------------------------------------------------------
479
-
480
- export type ApifyToolMap = {
481
- runActor: { params: RunActorParams; result: RunActorResult }
482
- getDatasetItems: { params: GetDatasetItemsParams; result: GetDatasetItemsResult }
483
- startActor: { params: StartActorParams; result: StartActorResult }
484
- }
485
-
486
- // ---------------------------------------------------------------------------
487
- // Gmail (integration adapter, 1 method)
488
- // ---------------------------------------------------------------------------
489
-
490
- export type GmailToolMap = {
491
- sendEmail: { params: GmailSendEmailParams; result: GmailSendEmailResult }
492
- }
493
-
494
- // ---------------------------------------------------------------------------
495
- // Dropbox (integration adapter, 2 methods)
496
- // ---------------------------------------------------------------------------
497
-
498
- export type DropboxToolMap = {
499
- uploadFile: { params: UploadFileParams; result: UploadFileResult }
500
- createFolder: { params: CreateFolderParams; result: CreateFolderResult }
501
- }
502
-
503
- // ---------------------------------------------------------------------------
504
- // SignatureAPI (integration adapter, 4 methods)
505
- // ---------------------------------------------------------------------------
506
-
507
- export type SignatureApiToolMap = {
508
- createEnvelope: { params: CreateEnvelopeParams; result: CreateEnvelopeResult }
509
- voidEnvelope: { params: VoidEnvelopeParams; result: VoidEnvelopeResult }
510
- downloadDocument: { params: DownloadDocumentParams; result: DownloadDocumentResult }
511
- getEnvelope: { params: GetEnvelopeParams; result: GetEnvelopeResult }
512
- }
513
-
514
- // ---------------------------------------------------------------------------
515
- // Instantly (integration adapter, 21 methods)
516
- // ---------------------------------------------------------------------------
517
-
518
- export type InstantlyToolMap = {
519
- sendReply: { params: SendReplyParams; result: SendReplyResult }
520
- removeFromSubsequence: { params: RemoveFromSubsequenceParams; result: RemoveFromSubsequenceResult }
521
- getEmails: { params: GetEmailsParams; result: GetEmailsResult }
522
- updateInterestStatus: { params: UpdateInterestStatusParams; result: UpdateInterestStatusResult }
523
- addToCampaign: { params: AddToCampaignParams; result: AddToCampaignResult }
524
- listCampaigns: { params: ListCampaignsParams; result: ListCampaignsResult }
525
- getCampaign: { params: GetCampaignParams; result: GetCampaignResult }
526
- updateCampaign: { params: UpdateCampaignParams; result: UpdateCampaignResult }
527
- pauseCampaign: { params: PauseCampaignParams; result: PauseCampaignResult }
528
- activateCampaign: { params: ActivateCampaignParams; result: ActivateCampaignResult }
529
- getCampaignAnalytics: { params: GetCampaignAnalyticsParams; result: GetCampaignAnalyticsResult }
530
- getStepAnalytics: { params: GetStepAnalyticsParams; result: GetStepAnalyticsResult }
531
- bulkAddLeads: { params: BulkAddLeadsParams; result: BulkAddLeadsResult }
532
- getAccountHealth: { params: GetAccountHealthParams; result: GetAccountHealthResult }
533
- createInboxTest: { params: CreateInboxTestParams; result: CreateInboxTestResult }
534
- createCampaign: { params: CreateCampaignParams; result: CreateCampaignResult }
535
- getDailyCampaignAnalytics: { params: GetDailyCampaignAnalyticsParams; result: GetDailyCampaignAnalyticsResult }
536
- listLeads: { params: ListLeadsParams; result: ListLeadsResult }
537
- bulkDeleteLeads: { params: BulkDeleteLeadsParams; result: BulkDeleteLeadsResult }
538
- deleteCampaign: { params: DeleteCampaignParams; result: DeleteCampaignResult }
539
- patchLead: { params: PatchLeadParams; result: PatchLeadResult }
540
- }
541
-
542
- // ---------------------------------------------------------------------------
543
- // Anymailfinder (integration adapter, 4 methods)
544
- // ---------------------------------------------------------------------------
545
-
546
- export type AnymailfinderToolMap = {
547
- findCompanyEmail: { params: FindCompanyEmailParams; result: FindCompanyEmailResult }
548
- findPersonEmail: { params: FindPersonEmailParams; result: FindPersonEmailResult }
549
- findDecisionMakerEmail: { params: FindDecisionMakerEmailParams; result: FindDecisionMakerEmailResult }
550
- verifyEmail: { params: VerifyEmailParams; result: VerifyEmailResult }
551
- }
552
-
553
- // ---------------------------------------------------------------------------
554
- // Tomba (integration adapter, 3 methods)
555
- // ---------------------------------------------------------------------------
556
-
557
- export type TombaToolMap = {
558
- emailFinder: { params: EmailFinderParams; result: EmailFinderResult }
559
- domainSearch: { params: DomainSearchParams; result: DomainSearchResult }
560
- emailVerifier: { params: EmailVerifierParams; result: EmailVerifierResult }
561
- }
562
-
563
- // ---------------------------------------------------------------------------
564
- // MillionVerifier (integration adapter, 2 methods)
565
- // ---------------------------------------------------------------------------
566
-
567
- export type MillionVerifierToolMap = {
568
- verifyEmail: { params: MillionVerifierVerifyEmailParams; result: MillionVerifierVerifyEmailResult }
569
- checkCredits: { params: MillionVerifierCheckCreditsParams; result: MillionVerifierCheckCreditsResult }
570
- }
571
-
572
- // ---------------------------------------------------------------------------
573
- // Lead (platform tool, 56 methods)
574
- // ---------------------------------------------------------------------------
575
-
576
- export type LeadToolMap = {
577
- // List operations
578
- listLists: { params: Record<string, never>; result: AcqList[] }
579
- createList: { params: Omit<CreateListParams, 'organizationId'>; result: AcqList }
580
- updateList: { params: { id: string } & UpdateListParams; result: AcqList }
581
- deleteList: { params: { id: string }; result: void }
582
- addContactsToList: { params: Omit<AddContactsToListParams, 'organizationId'>; result: AddContactsToListResult }
583
- addCompaniesToList: { params: Omit<AddCompaniesToListParams, 'organizationId'>; result: AddCompaniesToListResult }
584
- updateCompanyStage: {
585
- params: Omit<UpdateCompanyStageParams, 'organizationId'>
586
- result: void
587
- }
588
- updateContactStage: {
589
- params: Omit<UpdateContactStageParams, 'organizationId'>
590
- result: void
591
- }
592
- // Company operations
593
- createCompany: { params: Omit<CreateCompanyParams, 'organizationId'>; result: AcqCompany }
594
- upsertCompany: { params: Omit<UpsertCompanyParams, 'organizationId'>; result: AcqCompany }
595
- updateCompany: { params: { id: string } & UpdateCompanyParams; result: AcqCompany }
596
- getCompany: { params: { id: string }; result: AcqCompany | null }
597
- listCompanies: { params: CompanyFilters; result: AcqCompany[] }
598
- deleteCompany: { params: { id: string }; result: void }
599
- // Contact operations
600
- createContact: { params: Omit<CreateContactParams, 'organizationId'>; result: AcqContact }
601
- upsertContact: { params: Omit<UpsertContactParams, 'organizationId'>; result: AcqContact }
602
- updateContact: { params: { id: string } & UpdateContactParams; result: AcqContact }
603
- getContact: { params: { id: string }; result: AcqContact | null }
604
- getContactByEmail: { params: { email: string }; result: AcqContact | null }
605
- listContacts: {
606
- params: ContactFilters & { limit?: number; offset?: number }
607
- result: PaginatedResult<AcqContact>
608
- }
609
- deleteContact: { params: { id: string }; result: void }
610
- bulkImportContacts: { params: Omit<BulkImportParams, 'organizationId'>; result: BulkImportResult }
611
- bulkImportCompanies: {
612
- params: Omit<BulkImportCompaniesParams, 'organizationId'>
613
- result: BulkImportCompaniesResult
614
- }
615
- deactivateContactsByCompany: {
616
- params: { companyId: string }
617
- result: { deactivated: number }
618
- }
619
- // Deal operations
620
- upsertDeal: { params: Omit<UpsertDealParams, 'organizationId'>; result: AcqDeal }
621
- getDealByEmail: { params: { email: string }; result: AcqDeal | null }
622
- getDealByEnvelopeId: { params: { envelopeId: string }; result: AcqDeal | null }
623
- updateDealEnvelopeId: { params: { dealId: string; envelopeId: string }; result: AcqDeal | null }
624
- getDealById: { params: Omit<GetDealByIdParams, 'organizationId'>; result: AcqDeal | null }
625
- getContactById: { params: Omit<GetContactByIdParams, 'organizationId'>; result: AcqContact | null }
626
- getCompanyById: { params: Omit<GetCompanyByIdParams, 'organizationId'>; result: AcqCompany | null }
627
- // Deal-sync operations
628
- updateDiscoveryData: { params: Omit<UpdateDiscoveryDataParams, 'organizationId'>; result: void }
629
- updateProposalData: { params: Omit<UpdateProposalDataParams, 'organizationId'>; result: void }
630
- markProposalSent: { params: Omit<MarkProposalSentParams, 'organizationId'>; result: void }
631
- markProposalReviewed: { params: Omit<MarkProposalReviewedParams, 'organizationId'>; result: void }
632
- updateCloseLostReason: { params: Omit<UpdateCloseLostReasonParams, 'organizationId'>; result: void }
633
- updateFees: { params: Omit<UpdateFeesParams, 'organizationId'>; result: void }
634
- cacheInstantlyThreadIds: { params: Omit<CacheInstantlyThreadIdsParams, 'organizationId'>; result: void }
635
- transitionItem: { params: Omit<TransitionItemParams, 'organizationId'>; result: void }
636
- setContactNurture: { params: Omit<SetContactNurtureParams, 'organizationId'>; result: void }
637
- cancelSchedulesAndHitlByEmail: {
638
- params: Omit<CancelSchedulesAndHitlByEmailParams, 'organizationId'>
639
- result: { schedulesCancelled: number; hitlDeleted: number }
640
- }
641
- cancelHitlByDealId: { params: Omit<CancelHitlByDealIdParams, 'organizationId'>; result: { hitlDeleted: number } }
642
- clearDealFields: { params: Omit<ClearDealFieldsParams, 'organizationId'>; result: void }
643
- deleteDeal: { params: Omit<DeleteDealParams, 'organizationId'>; result: void }
644
- recordDealActivity: {
645
- params: Omit<RecordDealActivityParams, 'organizationId'>
646
- result: void
647
- }
648
- // Deal note operations
649
- createDealNote: {
650
- params: Omit<CreateDealNoteParams, 'organizationId'>
651
- result: AcqDealNote
652
- }
653
- listDealNotes: {
654
- params: Omit<ListDealNotesParams, 'organizationId'>
655
- result: AcqDealNote[]
656
- }
657
- // Deal task operations
658
- createDealTask: {
659
- params: Omit<CreateDealTaskParams, 'organizationId'>
660
- result: AcqDealTask
661
- }
662
- listDealTasks: {
663
- params: Omit<ListDealTasksParams, 'organizationId'>
664
- result: AcqDealTask[]
665
- }
666
- listDealTasksDue: {
667
- params: Omit<ListDealTasksDueParams, 'organizationId'>
668
- result: AcqDealTask[]
669
- }
670
- completeDealTask: {
671
- params: Omit<CompleteDealTaskParams, 'organizationId'>
672
- result: AcqDealTask
673
- }
674
- // Deal query & analytics operations
675
- listDeals: { params: DealFilters; result: AcqDeal[] }
676
- getDealPipelineAnalytics: { params: { recentLimit?: number }; result: DealPipelineAnalytics }
677
- // Enrichment data operations
678
- mergeEnrichmentData: {
679
- params: { id: string; table: 'acq_companies' | 'acq_contacts'; data: Record<string, unknown> }
680
- result: void
681
- }
682
- // Social monitoring operations
683
- upsertSocialPosts: {
684
- params: { posts: Omit<UpsertSocialPostParams, 'organizationId'>[] }
685
- result: UpsertSocialPostsResult
686
- }
687
- setDealStateKey: {
688
- params: {
689
- dealId: string
690
- stateKey: string
691
- }
692
- result: { ok: true }
693
- }
694
- // CRM workflow helpers
695
- transitionDeal: {
696
- params: {
697
- dealId: string
698
- toStage: string
699
- toState?: string
700
- }
701
- result: { deal: AcqDeal }
702
- }
703
- loadDeal: {
704
- params: { dealId: string }
705
- result: DealDetail | null
706
- }
707
- }
708
-
709
- // ---------------------------------------------------------------------------
710
- // List (platform tool, 4 methods)
711
- // ---------------------------------------------------------------------------
712
-
713
- export type ListToolMap = {
714
- getConfig: {
715
- params: { listId: string }
716
- result: { scrapingConfig: ScrapingConfig; icp: IcpRubric; pipelineConfig: PipelineConfig }
717
- }
718
- recordExecution: {
719
- params: Omit<RecordListExecutionParams, 'organizationId'>
720
- result: void
721
- }
722
- updateCompanyStage: {
723
- params: Omit<UpdateCompanyStageParams, 'organizationId'>
724
- result: void
725
- }
726
- updateContactStage: {
727
- params: Omit<UpdateContactStageParams, 'organizationId'>
728
- result: void
729
- }
730
- listPendingCompanyIds: {
731
- params: Omit<ListPendingCompanyIdsParams, 'organizationId'>
732
- result: string[]
733
- }
734
- listPendingContactIds: {
735
- params: Omit<ListPendingContactIdsParams, 'organizationId'>
736
- result: string[]
737
- }
738
- }
739
-
740
- // ---------------------------------------------------------------------------
741
- // PDF (platform tool, 2 methods)
742
- // ---------------------------------------------------------------------------
743
-
744
- export type PdfToolMap = {
745
- render: {
746
- params: {
747
- document: Record<string, unknown>
748
- theme?: Record<string, unknown>
749
- storage: { bucket: string; path: string }
750
- }
751
- result: { success: boolean; pdfUrl: string; size: number }
752
- }
753
- renderToBuffer: {
754
- params: {
755
- document: Record<string, unknown>
756
- theme?: Record<string, unknown>
757
- }
758
- result: { buffer: string }
759
- }
760
- }
761
-
762
- // ---------------------------------------------------------------------------
763
- // Approval (platform tool, 2 methods)
764
- // ---------------------------------------------------------------------------
765
-
766
- export type ApprovalToolMap = {
767
- create: {
768
- params: {
769
- actions: Array<{
770
- id: string
771
- label: string
772
- type: 'primary' | 'secondary' | 'danger' | 'outline'
773
- icon?: string
774
- color?: string
775
- target?: { resourceType: 'agent' | 'workflow'; resourceId: string; sessionId?: string }
776
- form?: Record<string, unknown>
777
- requiresConfirmation?: boolean
778
- confirmationMessage?: string
779
- description?: string
780
- }>
781
- context: Record<string, unknown>
782
- description?: string
783
- priority?: number
784
- humanCheckpoint?: string
785
- metadata?: Record<string, unknown>
786
- expiresAt?: string
787
- idempotencyKey?: string
788
- }
789
- result: { id: string }
790
- }
791
- deleteByMetadata: {
792
- params: { metadata: Record<string, unknown>; status?: string }
793
- result: { deleted: number }
794
- }
795
- }
796
-
797
- // ---------------------------------------------------------------------------
798
- // Execution (platform tool, 1 method)
799
- // ---------------------------------------------------------------------------
800
-
801
- export type ExecutionToolMap = {
802
- trigger: {
803
- params: { resourceId: string; input?: unknown }
804
- result: { success: boolean; executionId: string; output: unknown; error?: string }
805
- }
806
- triggerAsync: {
807
- params: { resourceId: string; input?: unknown }
808
- result: { executionId: string }
809
- }
810
- }
811
-
812
- // ---------------------------------------------------------------------------
813
- // Email (platform tool, 1 method)
814
- // ---------------------------------------------------------------------------
815
-
816
- export type EmailToolMap = {
817
- send: {
818
- params: {
819
- subject: string
820
- html?: string
821
- text?: string
822
- replyTo?: string
823
- tags?: Array<{ name: string; value: string }>
824
- } & (
825
- | { userIds: string[]; targetRole?: never; targetAll?: never }
826
- | { targetRole: string; userIds?: never; targetAll?: never }
827
- | { targetAll: true; userIds?: never; targetRole?: never }
828
- )
829
- result: { sent: number; failed: number; errors?: Array<{ userId: string; email: string; error: string }> }
830
- }
831
- }
1
+ /**
2
+ * Tool Method Maps
3
+ *
4
+ * Single source of truth for tool -> method -> params -> result type mappings.
5
+ * Used by SDK adapters (compile-time typed wrappers) and optionally by the
6
+ * server-side dispatcher for type checking.
7
+ *
8
+ * Browser-safe: no Node.js imports, pure type definitions.
9
+ */
10
+
11
+ import type {
12
+ CreateRecordParams,
13
+ CreateRecordResult,
14
+ UpdateRecordParams,
15
+ UpdateRecordResult,
16
+ QueryRecordsParams,
17
+ QueryRecordsResult,
18
+ GetRecordParams,
19
+ GetRecordResult,
20
+ DeleteRecordParams,
21
+ DeleteRecordResult,
22
+ ListObjectsResult,
23
+ ListAttributesParams,
24
+ ListAttributesResult,
25
+ CreateAttributeParams,
26
+ CreateAttributeResult,
27
+ UpdateAttributeParams,
28
+ UpdateAttributeResult,
29
+ CreateNoteParams,
30
+ CreateNoteResult,
31
+ ListNotesParams,
32
+ ListNotesResult,
33
+ DeleteNoteParams,
34
+ DeleteNoteResult
35
+ } from './integration/types/attio'
36
+
37
+ import type {
38
+ RunActorParams,
39
+ RunActorResult,
40
+ GetDatasetItemsParams,
41
+ GetDatasetItemsResult,
42
+ StartActorParams,
43
+ StartActorResult
44
+ } from './integration/types/apify'
45
+
46
+ import type {
47
+ UploadFileParams,
48
+ UploadFileResult,
49
+ CreateFolderParams,
50
+ CreateFolderResult
51
+ } from './integration/types/dropbox'
52
+
53
+ import type { GmailSendEmailParams, GmailSendEmailResult } from './integration/types/gmail'
54
+
55
+ import type {
56
+ ReadSheetParams,
57
+ ReadSheetResult,
58
+ WriteSheetParams,
59
+ WriteSheetResult,
60
+ AppendRowsParams,
61
+ AppendRowsResult,
62
+ ClearRangeParams,
63
+ ClearRangeResult,
64
+ GetSpreadsheetMetadataParams,
65
+ GetSpreadsheetMetadataResult,
66
+ BatchUpdateParams,
67
+ BatchUpdateResult,
68
+ GetHeadersParams,
69
+ GetHeadersResult,
70
+ GetLastRowParams,
71
+ GetLastRowResult,
72
+ GetRowByValueParams,
73
+ GetRowByValueResult,
74
+ UpdateRowByValueParams,
75
+ UpdateRowByValueResult,
76
+ UpsertRowParams,
77
+ UpsertRowResult,
78
+ FilterRowsParams,
79
+ FilterRowsResult,
80
+ DeleteRowByValueParams,
81
+ DeleteRowByValueResult
82
+ } from './integration/types/google-sheets'
83
+
84
+ import type {
85
+ SendReplyParams,
86
+ SendReplyResult,
87
+ RemoveFromSubsequenceParams,
88
+ RemoveFromSubsequenceResult,
89
+ GetEmailsParams,
90
+ GetEmailsResult,
91
+ UpdateInterestStatusParams,
92
+ UpdateInterestStatusResult,
93
+ AddToCampaignParams,
94
+ AddToCampaignResult,
95
+ ListCampaignsParams,
96
+ ListCampaignsResult,
97
+ GetCampaignParams,
98
+ GetCampaignResult,
99
+ UpdateCampaignParams,
100
+ UpdateCampaignResult,
101
+ PauseCampaignParams,
102
+ PauseCampaignResult,
103
+ ActivateCampaignParams,
104
+ ActivateCampaignResult,
105
+ GetCampaignAnalyticsParams,
106
+ GetCampaignAnalyticsResult,
107
+ GetStepAnalyticsParams,
108
+ GetStepAnalyticsResult,
109
+ BulkAddLeadsParams,
110
+ BulkAddLeadsResult,
111
+ GetAccountHealthParams,
112
+ GetAccountHealthResult,
113
+ CreateInboxTestParams,
114
+ CreateInboxTestResult,
115
+ CreateCampaignParams,
116
+ CreateCampaignResult,
117
+ GetDailyCampaignAnalyticsParams,
118
+ GetDailyCampaignAnalyticsResult,
119
+ ListLeadsParams,
120
+ ListLeadsResult,
121
+ BulkDeleteLeadsParams,
122
+ BulkDeleteLeadsResult,
123
+ DeleteCampaignParams,
124
+ DeleteCampaignResult,
125
+ PatchLeadParams,
126
+ PatchLeadResult
127
+ } from './integration/types/instantly'
128
+
129
+ import type {
130
+ MillionVerifierVerifyEmailParams,
131
+ MillionVerifierVerifyEmailResult,
132
+ MillionVerifierCheckCreditsParams,
133
+ MillionVerifierCheckCreditsResult
134
+ } from './integration/types/millionverifier'
135
+
136
+ import type {
137
+ FindCompanyEmailParams,
138
+ FindCompanyEmailResult,
139
+ FindPersonEmailParams,
140
+ FindPersonEmailResult,
141
+ FindDecisionMakerEmailParams,
142
+ FindDecisionMakerEmailResult,
143
+ VerifyEmailParams,
144
+ VerifyEmailResult
145
+ } from './integration/types/anymailfinder'
146
+
147
+ import type {
148
+ EmailFinderParams,
149
+ EmailFinderResult,
150
+ DomainSearchParams,
151
+ DomainSearchResult,
152
+ EmailVerifierParams,
153
+ EmailVerifierResult
154
+ } from './integration/types/tomba'
155
+
156
+ import type {
157
+ ResendSendEmailParams,
158
+ ResendSendEmailResult,
159
+ ResendGetEmailParams,
160
+ ResendGetEmailResult
161
+ } from './integration/types/resend'
162
+
163
+ import type {
164
+ CreateEnvelopeParams,
165
+ CreateEnvelopeResult,
166
+ VoidEnvelopeParams,
167
+ VoidEnvelopeResult,
168
+ DownloadDocumentParams,
169
+ DownloadDocumentResult,
170
+ GetEnvelopeParams,
171
+ GetEnvelopeResult
172
+ } from './integration/types/signature-api'
173
+
174
+ import type {
175
+ CreatePaymentLinkParams,
176
+ CreatePaymentLinkResult,
177
+ GetPaymentLinkParams,
178
+ GetPaymentLinkResult,
179
+ UpdatePaymentLinkParams,
180
+ UpdatePaymentLinkResult,
181
+ ListPaymentLinksParams,
182
+ ListPaymentLinksResult,
183
+ CreateAutoPaymentLinkParams,
184
+ CreateAutoPaymentLinkResult,
185
+ CreateCheckoutSessionParams,
186
+ CreateCheckoutSessionResult
187
+ } from './integration/types/stripe'
188
+
189
+ import type {
190
+ StorageUploadInput,
191
+ StorageUploadOutput,
192
+ StorageDownloadInput,
193
+ StorageDownloadOutput,
194
+ StorageSignedUrlInput,
195
+ StorageSignedUrlOutput,
196
+ StorageDeleteInput,
197
+ StorageDeleteOutput,
198
+ StorageListInput,
199
+ StorageListOutput
200
+ } from './platform/storage/types'
201
+
202
+ import type { CreateScheduleInput, TaskSchedule } from '../../scheduler/types'
203
+
204
+ import type { CreateNotificationParams } from '../../../operations/notifications/types'
205
+
206
+ import type {
207
+ AcqList,
208
+ AcqCompany,
209
+ AcqContact,
210
+ PaginatedResult,
211
+ CreateListParams,
212
+ UpdateListParams,
213
+ CreateCompanyParams,
214
+ UpdateCompanyParams,
215
+ UpsertCompanyParams,
216
+ CompanyFilters,
217
+ CreateContactParams,
218
+ UpdateContactParams,
219
+ UpsertContactParams,
220
+ ContactFilters,
221
+ UpsertDealParams,
222
+ AcqDeal,
223
+ AcqDealNote,
224
+ AcqDealTask,
225
+ CreateDealNoteParams,
226
+ ListDealNotesParams,
227
+ CreateDealTaskParams,
228
+ ListDealTasksParams,
229
+ ListDealTasksDueParams,
230
+ CompleteDealTaskParams,
231
+ RecordDealActivityParams,
232
+ AddContactsToListParams,
233
+ AddContactsToListResult,
234
+ AddCompaniesToListParams,
235
+ AddCompaniesToListResult,
236
+ BulkImportParams,
237
+ BulkImportResult,
238
+ BulkImportCompaniesParams,
239
+ BulkImportCompaniesResult,
240
+ UpdateDiscoveryDataParams,
241
+ UpdateProposalDataParams,
242
+ MarkProposalSentParams,
243
+ MarkProposalReviewedParams,
244
+ UpdateCloseLostReasonParams,
245
+ UpdateFeesParams,
246
+ CacheInstantlyThreadIdsParams,
247
+ TransitionItemParams,
248
+ SetContactNurtureParams,
249
+ CancelSchedulesAndHitlByEmailParams,
250
+ CancelHitlByDealIdParams,
251
+ ClearDealFieldsParams,
252
+ DeleteDealParams,
253
+ DealFilters,
254
+ DealPipelineAnalytics,
255
+ ScrapingConfig,
256
+ IcpRubric,
257
+ PipelineConfig,
258
+ RecordListExecutionParams,
259
+ UpdateCompanyStageParams,
260
+ UpdateContactStageParams,
261
+ ListPendingCompanyIdsParams,
262
+ ListPendingContactIdsParams,
263
+ UpsertSocialPostParams,
264
+ UpsertSocialPostsResult,
265
+ GetDealByIdParams,
266
+ GetContactByIdParams,
267
+ GetCompanyByIdParams
268
+ } from './lead-service-types'
269
+
270
+ import type { DealListItem, DealDetail } from '../../../business/acquisition'
271
+ import { CrmSchemas } from '../../../business/sales/api-schemas'
272
+ import type { RecentActivityEntry } from '../../../business/sales/api-schemas'
273
+ import { DealSchemas } from '../../../business/acquisition'
274
+ import { ProjectSchemas } from '../../../projects/api-schemas'
275
+ import type {
276
+ ProjectRow,
277
+ MilestoneRow,
278
+ TaskRow,
279
+ NoteRow,
280
+ ProjectWithCounts,
281
+ ProjectDetail
282
+ } from '../../../business/projects'
283
+ import type { z } from 'zod'
284
+
285
+ // ---------------------------------------------------------------------------
286
+ // Generic constraint types
287
+ // ---------------------------------------------------------------------------
288
+
289
+ /** A single method entry: what params go in, what result comes out */
290
+ export interface MethodEntry {
291
+ params: unknown
292
+ result: unknown
293
+ }
294
+
295
+ /** A tool's complete method map: method name -> MethodEntry */
296
+ export type ToolMethodMap = Record<string, MethodEntry>
297
+
298
+ // ---------------------------------------------------------------------------
299
+ // Attio (integration adapter, 12 methods)
300
+ // ---------------------------------------------------------------------------
301
+
302
+ export type AttioToolMap = {
303
+ createRecord: { params: CreateRecordParams; result: CreateRecordResult }
304
+ updateRecord: { params: UpdateRecordParams; result: UpdateRecordResult }
305
+ listRecords: { params: QueryRecordsParams; result: QueryRecordsResult }
306
+ getRecord: { params: GetRecordParams; result: GetRecordResult }
307
+ deleteRecord: { params: DeleteRecordParams; result: DeleteRecordResult }
308
+ listObjects: { params: Record<string, never>; result: ListObjectsResult }
309
+ listAttributes: { params: ListAttributesParams; result: ListAttributesResult }
310
+ createAttribute: { params: CreateAttributeParams; result: CreateAttributeResult }
311
+ updateAttribute: { params: UpdateAttributeParams; result: UpdateAttributeResult }
312
+ createNote: { params: CreateNoteParams; result: CreateNoteResult }
313
+ listNotes: { params: ListNotesParams; result: ListNotesResult }
314
+ deleteNote: { params: DeleteNoteParams; result: DeleteNoteResult }
315
+ }
316
+
317
+ // ---------------------------------------------------------------------------
318
+ // Scheduler (platform tool, 9 methods)
319
+ // ---------------------------------------------------------------------------
320
+
321
+ export type SchedulerToolMap = {
322
+ createSchedule: { params: CreateScheduleInput; result: TaskSchedule }
323
+ updateAnchor: { params: { scheduleId: string; anchorAt: string }; result: TaskSchedule }
324
+ deleteSchedule: { params: { scheduleId: string }; result: void }
325
+ findByIdempotencyKey: { params: { idempotencyKey: string }; result: TaskSchedule | null }
326
+ deleteScheduleByIdempotencyKey: { params: { idempotencyKey: string }; result: void }
327
+ listSchedules: { params: { status?: string; limit?: number; offset?: number }; result: TaskSchedule[] }
328
+ getSchedule: { params: { scheduleId: string }; result: TaskSchedule }
329
+ cancelSchedule: { params: { scheduleId: string }; result: void }
330
+ cancelSchedulesByMetadata: { params: { metadata: Record<string, unknown> }; result: { cancelledCount: number } }
331
+ cancelScheduleByIdempotencyKey: { params: { idempotencyKey: string }; result: { cancelled: boolean } }
332
+ }
333
+
334
+ // ---------------------------------------------------------------------------
335
+ // Storage (platform tool, 5 methods)
336
+ // ---------------------------------------------------------------------------
337
+
338
+ export type StorageToolMap = {
339
+ upload: { params: StorageUploadInput; result: StorageUploadOutput }
340
+ download: { params: StorageDownloadInput; result: StorageDownloadOutput }
341
+ createSignedUrl: { params: StorageSignedUrlInput; result: StorageSignedUrlOutput }
342
+ delete: { params: StorageDeleteInput; result: StorageDeleteOutput }
343
+ list: { params: StorageListInput; result: StorageListOutput }
344
+ }
345
+
346
+ // ---------------------------------------------------------------------------
347
+ // Notification (platform tool, 1 method)
348
+ // ---------------------------------------------------------------------------
349
+
350
+ /**
351
+ * SDK-side notification input.
352
+ * Omits userId and organizationId which are injected server-side from execution context.
353
+ */
354
+ export type NotificationSDKInput = Omit<CreateNotificationParams, 'userId' | 'organizationId'>
355
+
356
+ export type NotificationToolMap = {
357
+ create: { params: NotificationSDKInput; result: void }
358
+ }
359
+
360
+ // ---------------------------------------------------------------------------
361
+ // Projects (platform tool, 18 methods)
362
+ // ---------------------------------------------------------------------------
363
+
364
+ type ProjectsListParams = z.infer<typeof ProjectSchemas.GetProjectsQuery>
365
+ type ProjectCreateParams = z.infer<typeof ProjectSchemas.CreateProjectRequest>
366
+ type ProjectUpdateParams = z.infer<typeof ProjectSchemas.UpdateProjectRequest>
367
+ type MilestoneCreateParams = z.infer<typeof ProjectSchemas.ProjectIdPathParams> &
368
+ z.infer<typeof ProjectSchemas.CreateMilestoneRequest>
369
+ type MilestoneUpdateParams = z.infer<typeof ProjectSchemas.UpdateMilestoneRequest>
370
+ type TaskListParams = z.infer<typeof ProjectSchemas.ProjectIdPathParams> & z.infer<typeof ProjectSchemas.GetTasksQuery>
371
+ type TaskCreateParams = z.infer<typeof ProjectSchemas.CreateTaskRequest>
372
+ type TaskUpdateParams = z.infer<typeof ProjectSchemas.UpdateTaskRequest>
373
+ type TaskResumeContextParams = z.infer<typeof ProjectSchemas.TaskIdParams> &
374
+ z.infer<typeof ProjectSchemas.MergeResumeContextRequest>
375
+ type NoteListParams = z.infer<typeof ProjectSchemas.ProjectIdPathParams>
376
+ type NoteCreateParams = z.infer<typeof ProjectSchemas.CreateNoteRequest>
377
+ type NoteUpdateParams = z.infer<typeof ProjectSchemas.UpdateNoteRequest>
378
+ type TaskResumeContextResult = Pick<TaskRow, 'id' | 'resume_context' | 'updated_at'>
379
+
380
+ export type ProjectsToolMap = {
381
+ listProjects: { params: ProjectsListParams; result: ProjectWithCounts[] }
382
+ getProject: { params: z.infer<typeof ProjectSchemas.ProjectIdParams>; result: ProjectDetail }
383
+ createProject: { params: ProjectCreateParams; result: ProjectRow }
384
+ updateProject: { params: z.infer<typeof ProjectSchemas.ProjectIdParams> & ProjectUpdateParams; result: ProjectRow }
385
+ deleteProject: { params: z.infer<typeof ProjectSchemas.ProjectIdParams>; result: void }
386
+ listMilestones: { params: z.infer<typeof ProjectSchemas.ProjectIdPathParams>; result: MilestoneRow[] }
387
+ createMilestone: { params: MilestoneCreateParams; result: MilestoneRow }
388
+ updateMilestone: {
389
+ params: z.infer<typeof ProjectSchemas.MilestoneIdParams> & MilestoneUpdateParams
390
+ result: MilestoneRow
391
+ }
392
+ deleteMilestone: { params: z.infer<typeof ProjectSchemas.MilestoneIdParams>; result: void }
393
+ listTasks: { params: TaskListParams; result: TaskRow[] }
394
+ getTask: { params: z.infer<typeof ProjectSchemas.TaskIdParams>; result: TaskRow }
395
+ createTask: { params: TaskCreateParams; result: TaskRow }
396
+ updateTask: { params: z.infer<typeof ProjectSchemas.TaskIdParams> & TaskUpdateParams; result: TaskRow }
397
+ deleteTask: { params: z.infer<typeof ProjectSchemas.TaskIdParams>; result: void }
398
+ mergeTaskResumeContext: { params: TaskResumeContextParams; result: TaskResumeContextResult }
399
+ listNotes: { params: NoteListParams; result: NoteRow[] }
400
+ createNote: { params: NoteCreateParams; result: NoteRow }
401
+ updateNote: { params: z.infer<typeof ProjectSchemas.NoteIdParams> & NoteUpdateParams; result: NoteRow }
402
+ deleteNote: { params: z.infer<typeof ProjectSchemas.NoteIdParams>; result: void }
403
+ }
404
+
405
+ // ---------------------------------------------------------------------------
406
+ // CRM (platform tool, 13 methods)
407
+ // ---------------------------------------------------------------------------
408
+
409
+ type CrmRecentActivityParams = Partial<z.infer<typeof CrmSchemas.GetRecentActivityQuery>>
410
+ type CrmListDealsParams = Partial<z.infer<typeof DealSchemas.ListDealsQuery>>
411
+ type CrmGetDealParams = z.infer<typeof DealSchemas.DealIdParams>
412
+ type CrmGetDealByEmailParams = { email: string }
413
+ type CrmTaskDueParams = Partial<z.infer<typeof DealSchemas.ListDealTasksDueQuery>>
414
+ type CrmDealTaskParams = Omit<CreateDealTaskParams, 'organizationId'>
415
+ type CrmDealNoteParams = Omit<CreateDealNoteParams, 'organizationId'>
416
+ type CrmRecordActivityParams = Omit<RecordDealActivityParams, 'organizationId'>
417
+ type CrmDeleteDealParams = Omit<DeleteDealParams, 'organizationId'>
418
+
419
+ export type CrmToolMap = {
420
+ getRecentActivity: { params: CrmRecentActivityParams; result: RecentActivityEntry[] }
421
+ listDeals: { params: CrmListDealsParams; result: DealListItem[] }
422
+ getDeal: { params: CrmGetDealParams; result: DealDetail | null }
423
+ getDealByEmail: { params: CrmGetDealByEmailParams; result: DealDetail | null }
424
+ createDealNote: { params: CrmDealNoteParams; result: AcqDealNote }
425
+ listDealNotes: { params: Omit<ListDealNotesParams, 'organizationId'>; result: AcqDealNote[] }
426
+ createDealTask: { params: CrmDealTaskParams; result: AcqDealTask }
427
+ listDealTasks: { params: Omit<ListDealTasksParams, 'organizationId'>; result: AcqDealTask[] }
428
+ listDealTasksDue: { params: CrmTaskDueParams; result: AcqDealTask[] }
429
+ completeDealTask: { params: Omit<CompleteDealTaskParams, 'organizationId'>; result: AcqDealTask }
430
+ recordActivity: { params: CrmRecordActivityParams; result: void }
431
+ deleteDeal: { params: CrmDeleteDealParams; result: void }
432
+ }
433
+
434
+ // ---------------------------------------------------------------------------
435
+ // Stripe (integration adapter, 6 methods)
436
+ // ---------------------------------------------------------------------------
437
+
438
+ export type StripeToolMap = {
439
+ createPaymentLink: { params: CreatePaymentLinkParams; result: CreatePaymentLinkResult }
440
+ getPaymentLink: { params: GetPaymentLinkParams; result: GetPaymentLinkResult }
441
+ updatePaymentLink: { params: UpdatePaymentLinkParams; result: UpdatePaymentLinkResult }
442
+ listPaymentLinks: { params: ListPaymentLinksParams; result: ListPaymentLinksResult }
443
+ createAutoPaymentLink: { params: CreateAutoPaymentLinkParams; result: CreateAutoPaymentLinkResult }
444
+ createCheckoutSession: { params: CreateCheckoutSessionParams; result: CreateCheckoutSessionResult }
445
+ }
446
+
447
+ // ---------------------------------------------------------------------------
448
+ // Google Sheets (integration adapter, 13 methods)
449
+ // ---------------------------------------------------------------------------
450
+
451
+ export type GoogleSheetsToolMap = {
452
+ readSheet: { params: ReadSheetParams; result: ReadSheetResult }
453
+ writeSheet: { params: WriteSheetParams; result: WriteSheetResult }
454
+ appendRows: { params: AppendRowsParams; result: AppendRowsResult }
455
+ clearRange: { params: ClearRangeParams; result: ClearRangeResult }
456
+ getSpreadsheetMetadata: { params: GetSpreadsheetMetadataParams; result: GetSpreadsheetMetadataResult }
457
+ batchUpdate: { params: BatchUpdateParams; result: BatchUpdateResult }
458
+ getHeaders: { params: GetHeadersParams; result: GetHeadersResult }
459
+ getLastRow: { params: GetLastRowParams; result: GetLastRowResult }
460
+ getRowByValue: { params: GetRowByValueParams; result: GetRowByValueResult }
461
+ updateRowByValue: { params: UpdateRowByValueParams; result: UpdateRowByValueResult }
462
+ upsertRow: { params: UpsertRowParams; result: UpsertRowResult }
463
+ filterRows: { params: FilterRowsParams; result: FilterRowsResult }
464
+ deleteRowByValue: { params: DeleteRowByValueParams; result: DeleteRowByValueResult }
465
+ }
466
+
467
+ // ---------------------------------------------------------------------------
468
+ // Resend (integration adapter, 2 methods)
469
+ // ---------------------------------------------------------------------------
470
+
471
+ export type ResendToolMap = {
472
+ sendEmail: { params: ResendSendEmailParams; result: ResendSendEmailResult }
473
+ getEmail: { params: ResendGetEmailParams; result: ResendGetEmailResult }
474
+ }
475
+
476
+ // ---------------------------------------------------------------------------
477
+ // Apify (integration adapter, 2 methods)
478
+ // ---------------------------------------------------------------------------
479
+
480
+ export type ApifyToolMap = {
481
+ runActor: { params: RunActorParams; result: RunActorResult }
482
+ getDatasetItems: { params: GetDatasetItemsParams; result: GetDatasetItemsResult }
483
+ startActor: { params: StartActorParams; result: StartActorResult }
484
+ }
485
+
486
+ // ---------------------------------------------------------------------------
487
+ // Gmail (integration adapter, 1 method)
488
+ // ---------------------------------------------------------------------------
489
+
490
+ export type GmailToolMap = {
491
+ sendEmail: { params: GmailSendEmailParams; result: GmailSendEmailResult }
492
+ }
493
+
494
+ // ---------------------------------------------------------------------------
495
+ // Dropbox (integration adapter, 2 methods)
496
+ // ---------------------------------------------------------------------------
497
+
498
+ export type DropboxToolMap = {
499
+ uploadFile: { params: UploadFileParams; result: UploadFileResult }
500
+ createFolder: { params: CreateFolderParams; result: CreateFolderResult }
501
+ }
502
+
503
+ // ---------------------------------------------------------------------------
504
+ // SignatureAPI (integration adapter, 4 methods)
505
+ // ---------------------------------------------------------------------------
506
+
507
+ export type SignatureApiToolMap = {
508
+ createEnvelope: { params: CreateEnvelopeParams; result: CreateEnvelopeResult }
509
+ voidEnvelope: { params: VoidEnvelopeParams; result: VoidEnvelopeResult }
510
+ downloadDocument: { params: DownloadDocumentParams; result: DownloadDocumentResult }
511
+ getEnvelope: { params: GetEnvelopeParams; result: GetEnvelopeResult }
512
+ }
513
+
514
+ // ---------------------------------------------------------------------------
515
+ // Instantly (integration adapter, 21 methods)
516
+ // ---------------------------------------------------------------------------
517
+
518
+ export type InstantlyToolMap = {
519
+ sendReply: { params: SendReplyParams; result: SendReplyResult }
520
+ removeFromSubsequence: { params: RemoveFromSubsequenceParams; result: RemoveFromSubsequenceResult }
521
+ getEmails: { params: GetEmailsParams; result: GetEmailsResult }
522
+ updateInterestStatus: { params: UpdateInterestStatusParams; result: UpdateInterestStatusResult }
523
+ addToCampaign: { params: AddToCampaignParams; result: AddToCampaignResult }
524
+ listCampaigns: { params: ListCampaignsParams; result: ListCampaignsResult }
525
+ getCampaign: { params: GetCampaignParams; result: GetCampaignResult }
526
+ updateCampaign: { params: UpdateCampaignParams; result: UpdateCampaignResult }
527
+ pauseCampaign: { params: PauseCampaignParams; result: PauseCampaignResult }
528
+ activateCampaign: { params: ActivateCampaignParams; result: ActivateCampaignResult }
529
+ getCampaignAnalytics: { params: GetCampaignAnalyticsParams; result: GetCampaignAnalyticsResult }
530
+ getStepAnalytics: { params: GetStepAnalyticsParams; result: GetStepAnalyticsResult }
531
+ bulkAddLeads: { params: BulkAddLeadsParams; result: BulkAddLeadsResult }
532
+ getAccountHealth: { params: GetAccountHealthParams; result: GetAccountHealthResult }
533
+ createInboxTest: { params: CreateInboxTestParams; result: CreateInboxTestResult }
534
+ createCampaign: { params: CreateCampaignParams; result: CreateCampaignResult }
535
+ getDailyCampaignAnalytics: { params: GetDailyCampaignAnalyticsParams; result: GetDailyCampaignAnalyticsResult }
536
+ listLeads: { params: ListLeadsParams; result: ListLeadsResult }
537
+ bulkDeleteLeads: { params: BulkDeleteLeadsParams; result: BulkDeleteLeadsResult }
538
+ deleteCampaign: { params: DeleteCampaignParams; result: DeleteCampaignResult }
539
+ patchLead: { params: PatchLeadParams; result: PatchLeadResult }
540
+ }
541
+
542
+ // ---------------------------------------------------------------------------
543
+ // Anymailfinder (integration adapter, 4 methods)
544
+ // ---------------------------------------------------------------------------
545
+
546
+ export type AnymailfinderToolMap = {
547
+ findCompanyEmail: { params: FindCompanyEmailParams; result: FindCompanyEmailResult }
548
+ findPersonEmail: { params: FindPersonEmailParams; result: FindPersonEmailResult }
549
+ findDecisionMakerEmail: { params: FindDecisionMakerEmailParams; result: FindDecisionMakerEmailResult }
550
+ verifyEmail: { params: VerifyEmailParams; result: VerifyEmailResult }
551
+ }
552
+
553
+ // ---------------------------------------------------------------------------
554
+ // Tomba (integration adapter, 3 methods)
555
+ // ---------------------------------------------------------------------------
556
+
557
+ export type TombaToolMap = {
558
+ emailFinder: { params: EmailFinderParams; result: EmailFinderResult }
559
+ domainSearch: { params: DomainSearchParams; result: DomainSearchResult }
560
+ emailVerifier: { params: EmailVerifierParams; result: EmailVerifierResult }
561
+ }
562
+
563
+ // ---------------------------------------------------------------------------
564
+ // MillionVerifier (integration adapter, 2 methods)
565
+ // ---------------------------------------------------------------------------
566
+
567
+ export type MillionVerifierToolMap = {
568
+ verifyEmail: { params: MillionVerifierVerifyEmailParams; result: MillionVerifierVerifyEmailResult }
569
+ checkCredits: { params: MillionVerifierCheckCreditsParams; result: MillionVerifierCheckCreditsResult }
570
+ }
571
+
572
+ // ---------------------------------------------------------------------------
573
+ // Lead (platform tool, 56 methods)
574
+ // ---------------------------------------------------------------------------
575
+
576
+ export type LeadToolMap = {
577
+ // List operations
578
+ listLists: { params: Record<string, never>; result: AcqList[] }
579
+ createList: { params: Omit<CreateListParams, 'organizationId'>; result: AcqList }
580
+ updateList: { params: { id: string } & UpdateListParams; result: AcqList }
581
+ deleteList: { params: { id: string }; result: void }
582
+ addContactsToList: { params: Omit<AddContactsToListParams, 'organizationId'>; result: AddContactsToListResult }
583
+ addCompaniesToList: { params: Omit<AddCompaniesToListParams, 'organizationId'>; result: AddCompaniesToListResult }
584
+ updateCompanyStage: {
585
+ params: Omit<UpdateCompanyStageParams, 'organizationId'>
586
+ result: void
587
+ }
588
+ updateContactStage: {
589
+ params: Omit<UpdateContactStageParams, 'organizationId'>
590
+ result: void
591
+ }
592
+ // Company operations
593
+ createCompany: { params: Omit<CreateCompanyParams, 'organizationId'>; result: AcqCompany }
594
+ upsertCompany: { params: Omit<UpsertCompanyParams, 'organizationId'>; result: AcqCompany }
595
+ updateCompany: { params: { id: string } & UpdateCompanyParams; result: AcqCompany }
596
+ getCompany: { params: { id: string }; result: AcqCompany | null }
597
+ listCompanies: { params: CompanyFilters; result: AcqCompany[] }
598
+ deleteCompany: { params: { id: string }; result: void }
599
+ // Contact operations
600
+ createContact: { params: Omit<CreateContactParams, 'organizationId'>; result: AcqContact }
601
+ upsertContact: { params: Omit<UpsertContactParams, 'organizationId'>; result: AcqContact }
602
+ updateContact: { params: { id: string } & UpdateContactParams; result: AcqContact }
603
+ getContact: { params: { id: string }; result: AcqContact | null }
604
+ getContactByEmail: { params: { email: string }; result: AcqContact | null }
605
+ listContacts: {
606
+ params: ContactFilters & { limit?: number; offset?: number }
607
+ result: PaginatedResult<AcqContact>
608
+ }
609
+ deleteContact: { params: { id: string }; result: void }
610
+ bulkImportContacts: { params: Omit<BulkImportParams, 'organizationId'>; result: BulkImportResult }
611
+ bulkImportCompanies: {
612
+ params: Omit<BulkImportCompaniesParams, 'organizationId'>
613
+ result: BulkImportCompaniesResult
614
+ }
615
+ deactivateContactsByCompany: {
616
+ params: { companyId: string }
617
+ result: { deactivated: number }
618
+ }
619
+ // Deal operations
620
+ upsertDeal: { params: Omit<UpsertDealParams, 'organizationId'>; result: AcqDeal }
621
+ getDealByEmail: { params: { email: string }; result: AcqDeal | null }
622
+ getDealByEnvelopeId: { params: { envelopeId: string }; result: AcqDeal | null }
623
+ updateDealEnvelopeId: { params: { dealId: string; envelopeId: string }; result: AcqDeal | null }
624
+ getDealById: { params: Omit<GetDealByIdParams, 'organizationId'>; result: AcqDeal | null }
625
+ getContactById: { params: Omit<GetContactByIdParams, 'organizationId'>; result: AcqContact | null }
626
+ getCompanyById: { params: Omit<GetCompanyByIdParams, 'organizationId'>; result: AcqCompany | null }
627
+ // Deal-sync operations
628
+ updateDiscoveryData: { params: Omit<UpdateDiscoveryDataParams, 'organizationId'>; result: void }
629
+ updateProposalData: { params: Omit<UpdateProposalDataParams, 'organizationId'>; result: void }
630
+ markProposalSent: { params: Omit<MarkProposalSentParams, 'organizationId'>; result: void }
631
+ markProposalReviewed: { params: Omit<MarkProposalReviewedParams, 'organizationId'>; result: void }
632
+ updateCloseLostReason: { params: Omit<UpdateCloseLostReasonParams, 'organizationId'>; result: void }
633
+ updateFees: { params: Omit<UpdateFeesParams, 'organizationId'>; result: void }
634
+ cacheInstantlyThreadIds: { params: Omit<CacheInstantlyThreadIdsParams, 'organizationId'>; result: void }
635
+ transitionItem: { params: Omit<TransitionItemParams, 'organizationId'>; result: void }
636
+ setContactNurture: { params: Omit<SetContactNurtureParams, 'organizationId'>; result: void }
637
+ cancelSchedulesAndHitlByEmail: {
638
+ params: Omit<CancelSchedulesAndHitlByEmailParams, 'organizationId'>
639
+ result: { schedulesCancelled: number; hitlDeleted: number }
640
+ }
641
+ cancelHitlByDealId: { params: Omit<CancelHitlByDealIdParams, 'organizationId'>; result: { hitlDeleted: number } }
642
+ clearDealFields: { params: Omit<ClearDealFieldsParams, 'organizationId'>; result: void }
643
+ deleteDeal: { params: Omit<DeleteDealParams, 'organizationId'>; result: void }
644
+ recordDealActivity: {
645
+ params: Omit<RecordDealActivityParams, 'organizationId'>
646
+ result: void
647
+ }
648
+ // Deal note operations
649
+ createDealNote: {
650
+ params: Omit<CreateDealNoteParams, 'organizationId'>
651
+ result: AcqDealNote
652
+ }
653
+ listDealNotes: {
654
+ params: Omit<ListDealNotesParams, 'organizationId'>
655
+ result: AcqDealNote[]
656
+ }
657
+ // Deal task operations
658
+ createDealTask: {
659
+ params: Omit<CreateDealTaskParams, 'organizationId'>
660
+ result: AcqDealTask
661
+ }
662
+ listDealTasks: {
663
+ params: Omit<ListDealTasksParams, 'organizationId'>
664
+ result: AcqDealTask[]
665
+ }
666
+ listDealTasksDue: {
667
+ params: Omit<ListDealTasksDueParams, 'organizationId'>
668
+ result: AcqDealTask[]
669
+ }
670
+ completeDealTask: {
671
+ params: Omit<CompleteDealTaskParams, 'organizationId'>
672
+ result: AcqDealTask
673
+ }
674
+ // Deal query & analytics operations
675
+ listDeals: { params: DealFilters; result: AcqDeal[] }
676
+ getDealPipelineAnalytics: { params: { recentLimit?: number }; result: DealPipelineAnalytics }
677
+ // Enrichment data operations
678
+ mergeEnrichmentData: {
679
+ params: { id: string; table: 'acq_companies' | 'acq_contacts'; data: Record<string, unknown> }
680
+ result: void
681
+ }
682
+ // Social monitoring operations
683
+ upsertSocialPosts: {
684
+ params: { posts: Omit<UpsertSocialPostParams, 'organizationId'>[] }
685
+ result: UpsertSocialPostsResult
686
+ }
687
+ setDealStateKey: {
688
+ params: {
689
+ dealId: string
690
+ stateKey: string
691
+ }
692
+ result: { ok: true }
693
+ }
694
+ // CRM workflow helpers
695
+ transitionDeal: {
696
+ params: {
697
+ dealId: string
698
+ toStage: string
699
+ toState?: string
700
+ }
701
+ result: { deal: AcqDeal }
702
+ }
703
+ loadDeal: {
704
+ params: { dealId: string }
705
+ result: DealDetail | null
706
+ }
707
+ }
708
+
709
+ // ---------------------------------------------------------------------------
710
+ // List (platform tool, 4 methods)
711
+ // ---------------------------------------------------------------------------
712
+
713
+ export type ListToolMap = {
714
+ getConfig: {
715
+ params: { listId: string }
716
+ result: { scrapingConfig: ScrapingConfig; icp: IcpRubric; pipelineConfig: PipelineConfig }
717
+ }
718
+ recordExecution: {
719
+ params: Omit<RecordListExecutionParams, 'organizationId'>
720
+ result: void
721
+ }
722
+ updateCompanyStage: {
723
+ params: Omit<UpdateCompanyStageParams, 'organizationId'>
724
+ result: void
725
+ }
726
+ updateContactStage: {
727
+ params: Omit<UpdateContactStageParams, 'organizationId'>
728
+ result: void
729
+ }
730
+ listPendingCompanyIds: {
731
+ params: Omit<ListPendingCompanyIdsParams, 'organizationId'>
732
+ result: string[]
733
+ }
734
+ listPendingContactIds: {
735
+ params: Omit<ListPendingContactIdsParams, 'organizationId'>
736
+ result: string[]
737
+ }
738
+ }
739
+
740
+ // ---------------------------------------------------------------------------
741
+ // PDF (platform tool, 2 methods)
742
+ // ---------------------------------------------------------------------------
743
+
744
+ export type PdfToolMap = {
745
+ render: {
746
+ params: {
747
+ document: Record<string, unknown>
748
+ theme?: Record<string, unknown>
749
+ storage: { bucket: string; path: string }
750
+ }
751
+ result: { success: boolean; pdfUrl: string; size: number }
752
+ }
753
+ renderToBuffer: {
754
+ params: {
755
+ document: Record<string, unknown>
756
+ theme?: Record<string, unknown>
757
+ }
758
+ result: { buffer: string }
759
+ }
760
+ }
761
+
762
+ // ---------------------------------------------------------------------------
763
+ // Approval (platform tool, 2 methods)
764
+ // ---------------------------------------------------------------------------
765
+
766
+ export type ApprovalToolMap = {
767
+ create: {
768
+ params: {
769
+ actions: Array<{
770
+ id: string
771
+ label: string
772
+ type: 'primary' | 'secondary' | 'danger' | 'outline'
773
+ icon?: string
774
+ color?: string
775
+ target?: { resourceType: 'agent' | 'workflow'; resourceId: string; sessionId?: string }
776
+ form?: Record<string, unknown>
777
+ requiresConfirmation?: boolean
778
+ confirmationMessage?: string
779
+ description?: string
780
+ }>
781
+ context: Record<string, unknown>
782
+ description?: string
783
+ priority?: number
784
+ humanCheckpoint?: string
785
+ metadata?: Record<string, unknown>
786
+ expiresAt?: string
787
+ idempotencyKey?: string
788
+ }
789
+ result: { id: string }
790
+ }
791
+ deleteByMetadata: {
792
+ params: { metadata: Record<string, unknown>; status?: string }
793
+ result: { deleted: number }
794
+ }
795
+ }
796
+
797
+ // ---------------------------------------------------------------------------
798
+ // Execution (platform tool, 1 method)
799
+ // ---------------------------------------------------------------------------
800
+
801
+ export type ExecutionToolMap = {
802
+ trigger: {
803
+ params: { resourceId: string; input?: unknown }
804
+ result: { success: boolean; executionId: string; output: unknown; error?: string }
805
+ }
806
+ triggerAsync: {
807
+ params: { resourceId: string; input?: unknown }
808
+ result: { executionId: string }
809
+ }
810
+ }
811
+
812
+ // ---------------------------------------------------------------------------
813
+ // Email (platform tool, 1 method)
814
+ // ---------------------------------------------------------------------------
815
+
816
+ export type EmailToolMap = {
817
+ send: {
818
+ params: {
819
+ subject: string
820
+ html?: string
821
+ text?: string
822
+ replyTo?: string
823
+ tags?: Array<{ name: string; value: string }>
824
+ } & (
825
+ | { userIds: string[]; targetRole?: never; targetAll?: never }
826
+ | { targetRole: string; userIds?: never; targetAll?: never }
827
+ | { targetAll: true; userIds?: never; targetRole?: never }
828
+ )
829
+ result: { sent: number; failed: number; errors?: Array<{ userId: string; email: string; error: string }> }
830
+ }
831
+ }
832
+
833
+ // ---------------------------------------------------------------------------
834
+ // Aggregate platform adapter contract
835
+ // ---------------------------------------------------------------------------
836
+
837
+ /**
838
+ * Platform tools that have SDK adapter method maps and are dispatched by the
839
+ * API parent process without worker-owned credentials.
840
+ */
841
+ export type PlatformToolMapByName = {
842
+ email: EmailToolMap
843
+ storage: StorageToolMap
844
+ pdf: PdfToolMap
845
+ notification: NotificationToolMap
846
+ approval: ApprovalToolMap
847
+ scheduler: SchedulerToolMap
848
+ acqDb: LeadToolMap
849
+ crm: CrmToolMap
850
+ projects: ProjectsToolMap
851
+ list: ListToolMap
852
+ execution: ExecutionToolMap
853
+ }
854
+
855
+ export type PlatformToolName = keyof PlatformToolMapByName
856
+
857
+ export type PlatformToolMethod<TTool extends PlatformToolName> = Extract<keyof PlatformToolMapByName[TTool], string>
858
+
859
+ type PlatformToolEntry<
860
+ TTool extends PlatformToolName,
861
+ TMethod extends PlatformToolMethod<TTool>
862
+ > = PlatformToolMapByName[TTool][TMethod] extends MethodEntry ? PlatformToolMapByName[TTool][TMethod] : never
863
+
864
+ export type PlatformToolParams<
865
+ TTool extends PlatformToolName,
866
+ TMethod extends PlatformToolMethod<TTool>
867
+ > = PlatformToolEntry<TTool, TMethod>['params']
868
+
869
+ export type PlatformToolResult<
870
+ TTool extends PlatformToolName,
871
+ TMethod extends PlatformToolMethod<TTool>
872
+ > = PlatformToolEntry<TTool, TMethod>['result']