outbound-sdk 0.0.0-stage → 0.1.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 (271) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +121 -2
  3. package/dist/alerts/index.d.ts +2 -0
  4. package/dist/alerts/index.js +136 -0
  5. package/dist/alerts/plugin.d.ts +58 -0
  6. package/dist/audit/index.d.ts +33 -0
  7. package/dist/audit/index.js +60 -0
  8. package/dist/benchmarks/index.d.ts +29 -0
  9. package/dist/benchmarks/index.js +70 -0
  10. package/dist/budget/index.d.ts +21 -0
  11. package/dist/budget/index.js +50 -0
  12. package/dist/cache/index.d.ts +31 -0
  13. package/dist/cache/index.js +11 -0
  14. package/dist/cards/content.d.ts +43 -0
  15. package/dist/cards/copy-cards.d.ts +2 -0
  16. package/dist/cards/format.d.ts +39 -0
  17. package/dist/cards/index.d.ts +9 -0
  18. package/dist/cards/index.js +2070 -0
  19. package/dist/cards/notify-cards.d.ts +14 -0
  20. package/dist/cards/ops-cards.d.ts +2 -0
  21. package/dist/cards/parts.d.ts +22 -0
  22. package/dist/cards/people-cards.d.ts +2 -0
  23. package/dist/cards/render.d.ts +28 -0
  24. package/dist/cards/sender-cards.d.ts +2 -0
  25. package/dist/cards/slack-rich.d.ts +19 -0
  26. package/dist/cards/slack-text.d.ts +10 -0
  27. package/dist/cards/slack.d.ts +21 -0
  28. package/dist/cards/spec.d.ts +86 -0
  29. package/dist/cards/tool-cards.d.ts +4 -0
  30. package/dist/chunks/chunk-4O2HRTTI.js +75 -0
  31. package/dist/chunks/chunk-7BCYLIDG.js +483 -0
  32. package/dist/chunks/chunk-B7V6EOAC.js +2273 -0
  33. package/dist/chunks/chunk-CMQ5ZHLZ.js +25 -0
  34. package/dist/chunks/chunk-F7MKFVIG.js +43 -0
  35. package/dist/chunks/chunk-FZF6CLPX.js +232 -0
  36. package/dist/chunks/chunk-GPEJG34O.js +53 -0
  37. package/dist/chunks/chunk-HEC7XFFH.js +65 -0
  38. package/dist/chunks/chunk-IBC52BX3.js +24 -0
  39. package/dist/chunks/chunk-LNCOGBMI.js +144 -0
  40. package/dist/chunks/chunk-LOXBLQ3I.js +180 -0
  41. package/dist/chunks/chunk-NAWZ73QS.js +22 -0
  42. package/dist/chunks/chunk-OCV66TS2.js +705 -0
  43. package/dist/chunks/chunk-Q465X22Y.js +548 -0
  44. package/dist/chunks/chunk-QTB747K4.js +100 -0
  45. package/dist/chunks/chunk-QZNNCXXD.js +92 -0
  46. package/dist/chunks/chunk-R6AM4GJR.js +105 -0
  47. package/dist/chunks/chunk-TIJKJJDW.js +6 -0
  48. package/dist/chunks/chunk-VURTOVGI.js +61 -0
  49. package/dist/chunks/chunk-WAM6N4OF.js +269 -0
  50. package/dist/chunks/chunk-WW746NJF.js +94 -0
  51. package/dist/chunks/chunk-XC6CZP73.js +80 -0
  52. package/dist/chunks/chunk-ZGHQYZEH.js +45 -0
  53. package/dist/cli/bin.d.ts +2 -0
  54. package/dist/cli/bin.js +34 -0
  55. package/dist/cli/commands.d.ts +16 -0
  56. package/dist/cli/index.d.ts +13 -0
  57. package/dist/cli/index.js +25 -0
  58. package/dist/cli/mcp.d.ts +14 -0
  59. package/dist/clients/index.d.ts +2 -0
  60. package/dist/clients/index.js +107 -0
  61. package/dist/clients/plugin.d.ts +42 -0
  62. package/dist/combine/account.d.ts +4 -0
  63. package/dist/combine/adapter.d.ts +9 -0
  64. package/dist/combine/index.d.ts +2 -0
  65. package/dist/combine/index.js +345 -0
  66. package/dist/combine/route.d.ts +17 -0
  67. package/dist/exporter/index.d.ts +29 -0
  68. package/dist/exporter/index.js +77 -0
  69. package/dist/failover/index.d.ts +11 -0
  70. package/dist/failover/index.js +45 -0
  71. package/dist/fixtures/index.d.ts +27 -0
  72. package/dist/fixtures/index.js +241 -0
  73. package/dist/fixtures/scrub.d.ts +5 -0
  74. package/dist/heyreach/account.d.ts +11 -0
  75. package/dist/heyreach/adapter.d.ts +5 -0
  76. package/dist/heyreach/capabilities.d.ts +68 -0
  77. package/dist/heyreach/client.d.ts +20 -0
  78. package/dist/heyreach/inbox.d.ts +7 -0
  79. package/dist/heyreach/index.d.ts +18 -0
  80. package/dist/heyreach/index.js +1708 -0
  81. package/dist/heyreach/lookup.d.ts +15 -0
  82. package/dist/heyreach/map-account.d.ts +25 -0
  83. package/dist/heyreach/map-sequence.d.ts +5 -0
  84. package/dist/heyreach/map-stats.d.ts +10 -0
  85. package/dist/heyreach/map.d.ts +35 -0
  86. package/dist/heyreach/native-organization.d.ts +128 -0
  87. package/dist/heyreach/native-voice.d.ts +106 -0
  88. package/dist/heyreach/native.d.ts +496 -0
  89. package/dist/heyreach/paging.d.ts +7 -0
  90. package/dist/heyreach/webhooks.d.ts +2 -0
  91. package/dist/identity/index.d.ts +3 -0
  92. package/dist/identity/index.js +148 -0
  93. package/dist/identity/keys.d.ts +9 -0
  94. package/dist/identity/plugin.d.ts +34 -0
  95. package/dist/index.d.ts +36 -0
  96. package/dist/index.js +119 -0
  97. package/dist/insights/copy/copy-audit.d.ts +55 -0
  98. package/dist/insights/copy/copy-checks.d.ts +44 -0
  99. package/dist/insights/copy/copy-reuse.d.ts +59 -0
  100. package/dist/insights/copy/index.d.ts +67 -0
  101. package/dist/insights/copy/reply-timing.d.ts +63 -0
  102. package/dist/insights/copy/shared.d.ts +53 -0
  103. package/dist/insights/copy/step-funnel.d.ts +66 -0
  104. package/dist/insights/copy/variant-test.d.ts +64 -0
  105. package/dist/insights/define.d.ts +98 -0
  106. package/dist/insights/index.d.ts +10 -0
  107. package/dist/insights/index.js +4873 -0
  108. package/dist/insights/ops/anomalies.d.ts +80 -0
  109. package/dist/insights/ops/campaign-diagnosis.d.ts +39 -0
  110. package/dist/insights/ops/campaign-ranking.d.ts +56 -0
  111. package/dist/insights/ops/channel-mix.d.ts +44 -0
  112. package/dist/insights/ops/client-report.d.ts +76 -0
  113. package/dist/insights/ops/diagnosis-checks.d.ts +48 -0
  114. package/dist/insights/ops/index.d.ts +135 -0
  115. package/dist/insights/ops/period-comparison.d.ts +86 -0
  116. package/dist/insights/ops/pipeline-forecast.d.ts +44 -0
  117. package/dist/insights/ops/shared.d.ts +149 -0
  118. package/dist/insights/ops/tag-rollup.d.ts +32 -0
  119. package/dist/insights/people/account-summary.d.ts +68 -0
  120. package/dist/insights/people/dropped-replies.d.ts +51 -0
  121. package/dist/insights/people/find.d.ts +18 -0
  122. package/dist/insights/people/hot-leads.d.ts +67 -0
  123. package/dist/insights/people/index.d.ts +88 -0
  124. package/dist/insights/people/lead-collisions.d.ts +43 -0
  125. package/dist/insights/people/person-summary.d.ts +46 -0
  126. package/dist/insights/people/personalization-gaps.d.ts +60 -0
  127. package/dist/insights/people/read.d.ts +40 -0
  128. package/dist/insights/people/suppression-check.d.ts +53 -0
  129. package/dist/insights/plugin.d.ts +40 -0
  130. package/dist/insights/registry.d.ts +335 -0
  131. package/dist/insights/senders/bounce-watch.d.ts +70 -0
  132. package/dist/insights/senders/domain-health.d.ts +69 -0
  133. package/dist/insights/senders/index.d.ts +74 -0
  134. package/dist/insights/senders/read.d.ts +37 -0
  135. package/dist/insights/senders/sender-capacity.d.ts +67 -0
  136. package/dist/insights/senders/sender-load.d.ts +52 -0
  137. package/dist/insights/senders/settings-audit.d.ts +48 -0
  138. package/dist/insights/senders/warmup-readiness.d.ts +39 -0
  139. package/dist/insights/stats.d.ts +45 -0
  140. package/dist/insights/tools.d.ts +16 -0
  141. package/dist/insights/types.d.ts +4 -0
  142. package/dist/instantly/adapter-account.d.ts +5 -0
  143. package/dist/instantly/adapter-mail.d.ts +3 -0
  144. package/dist/instantly/adapter.d.ts +7 -0
  145. package/dist/instantly/capabilities.d.ts +83 -0
  146. package/dist/instantly/client.d.ts +29 -0
  147. package/dist/instantly/index.d.ts +20 -0
  148. package/dist/instantly/index.js +2372 -0
  149. package/dist/instantly/map-account.d.ts +23 -0
  150. package/dist/instantly/map-lead.d.ts +18 -0
  151. package/dist/instantly/map-stats.d.ts +22 -0
  152. package/dist/instantly/map.d.ts +24 -0
  153. package/dist/instantly/native-agents-sales.d.ts +161 -0
  154. package/dist/instantly/native-agents.d.ts +156 -0
  155. package/dist/instantly/native-campaigns.d.ts +101 -0
  156. package/dist/instantly/native-leads.d.ts +93 -0
  157. package/dist/instantly/native-params.d.ts +24 -0
  158. package/dist/instantly/native-search.d.ts +82 -0
  159. package/dist/instantly/native-senders.d.ts +182 -0
  160. package/dist/instantly/native-supersearch.d.ts +149 -0
  161. package/dist/instantly/native-workspace.d.ts +170 -0
  162. package/dist/instantly/native.d.ts +1081 -0
  163. package/dist/instantly/pages.d.ts +29 -0
  164. package/dist/instantly/stats.d.ts +5 -0
  165. package/dist/instantly/webhooks.d.ts +2 -0
  166. package/dist/internal/adapter.d.ts +189 -0
  167. package/dist/internal/capabilities.d.ts +86 -0
  168. package/dist/internal/cursor.d.ts +10 -0
  169. package/dist/internal/engine/budget.d.ts +44 -0
  170. package/dist/internal/engine/engine.d.ts +45 -0
  171. package/dist/internal/engine/rate-store.d.ts +25 -0
  172. package/dist/internal/engine/request.d.ts +27 -0
  173. package/dist/internal/engine/retry.d.ts +21 -0
  174. package/dist/internal/engine/runtime.d.ts +13 -0
  175. package/dist/internal/entities-account.d.ts +135 -0
  176. package/dist/internal/entities.d.ts +389 -0
  177. package/dist/internal/env.d.ts +4 -0
  178. package/dist/internal/errors.d.ts +57 -0
  179. package/dist/internal/hooks.d.ts +55 -0
  180. package/dist/internal/json.d.ts +40 -0
  181. package/dist/internal/limits.d.ts +34 -0
  182. package/dist/internal/metrics.d.ts +52 -0
  183. package/dist/internal/native.d.ts +66 -0
  184. package/dist/internal/outbound/api.d.ts +267 -0
  185. package/dist/internal/outbound/collections.d.ts +31 -0
  186. package/dist/internal/outbound/core.d.ts +36 -0
  187. package/dist/internal/outbound/create.d.ts +16 -0
  188. package/dist/internal/outbound/handles.d.ts +7 -0
  189. package/dist/internal/outbound/native.d.ts +4 -0
  190. package/dist/internal/outbound/operation-shared.d.ts +28 -0
  191. package/dist/internal/outbound/operations-account.d.ts +29 -0
  192. package/dist/internal/outbound/operations.d.ts +42 -0
  193. package/dist/internal/outbound/outbound.d.ts +64 -0
  194. package/dist/internal/outbound/plugins.d.ts +40 -0
  195. package/dist/internal/outbound/raw.d.ts +9 -0
  196. package/dist/internal/outbound/specs-account.d.ts +16 -0
  197. package/dist/internal/outbound/specs.d.ts +14 -0
  198. package/dist/internal/outbound/stats.d.ts +7 -0
  199. package/dist/internal/outbound/validate.d.ts +5 -0
  200. package/dist/internal/outbound/walker.d.ts +22 -0
  201. package/dist/internal/record.d.ts +19 -0
  202. package/dist/internal/redact.d.ts +18 -0
  203. package/dist/internal/ref.d.ts +16 -0
  204. package/dist/internal/sha256.d.ts +4 -0
  205. package/dist/internal/text.d.ts +11 -0
  206. package/dist/internal/url.d.ts +9 -0
  207. package/dist/loader/index.d.ts +12 -0
  208. package/dist/loader/index.js +12 -0
  209. package/dist/memory/account-reads.d.ts +5 -0
  210. package/dist/memory/account.d.ts +67 -0
  211. package/dist/memory/adapter.d.ts +16 -0
  212. package/dist/memory/data.d.ts +122 -0
  213. package/dist/memory/demo.d.ts +7 -0
  214. package/dist/memory/index.d.ts +5 -0
  215. package/dist/memory/index.js +792 -0
  216. package/dist/memory/stats.d.ts +6 -0
  217. package/dist/memory/store.d.ts +18 -0
  218. package/dist/providers/index.d.ts +22 -0
  219. package/dist/providers/index.js +10 -0
  220. package/dist/reconcile/index.d.ts +2 -0
  221. package/dist/reconcile/index.js +72 -0
  222. package/dist/reconcile/plugin.d.ts +55 -0
  223. package/dist/redact/index.d.ts +2 -0
  224. package/dist/redact/index.js +192 -0
  225. package/dist/redact/plugin.d.ts +22 -0
  226. package/dist/redis/index.d.ts +41 -0
  227. package/dist/redis/index.js +114 -0
  228. package/dist/smartlead/account.d.ts +5 -0
  229. package/dist/smartlead/adapter.d.ts +5 -0
  230. package/dist/smartlead/capabilities.d.ts +85 -0
  231. package/dist/smartlead/client.d.ts +23 -0
  232. package/dist/smartlead/hmac.d.ts +9 -0
  233. package/dist/smartlead/index.d.ts +17 -0
  234. package/dist/smartlead/index.js +2170 -0
  235. package/dist/smartlead/leads.d.ts +6 -0
  236. package/dist/smartlead/lookup.d.ts +8 -0
  237. package/dist/smartlead/mail.d.ts +5 -0
  238. package/dist/smartlead/map-account.d.ts +22 -0
  239. package/dist/smartlead/map-messages.d.ts +31 -0
  240. package/dist/smartlead/map-stats.d.ts +37 -0
  241. package/dist/smartlead/map.d.ts +52 -0
  242. package/dist/smartlead/native-analytics.d.ts +242 -0
  243. package/dist/smartlead/native-campaigns.d.ts +211 -0
  244. package/dist/smartlead/native-inbox.d.ts +141 -0
  245. package/dist/smartlead/native-params.d.ts +33 -0
  246. package/dist/smartlead/native-services.d.ts +204 -0
  247. package/dist/smartlead/native.d.ts +785 -0
  248. package/dist/smartlead/shared.d.ts +28 -0
  249. package/dist/smartlead/stats.d.ts +5 -0
  250. package/dist/smartlead/webhooks.d.ts +2 -0
  251. package/dist/sync/index.d.ts +2 -0
  252. package/dist/sync/index.js +158 -0
  253. package/dist/sync/plugin.d.ts +58 -0
  254. package/dist/tools/account-tools.d.ts +21 -0
  255. package/dist/tools/ai-sdk.d.ts +8 -0
  256. package/dist/tools/ai-sdk.js +26 -0
  257. package/dist/tools/campaign-tools.d.ts +59 -0
  258. package/dist/tools/claude-agent.d.ts +18 -0
  259. package/dist/tools/claude-agent.js +40 -0
  260. package/dist/tools/index.d.ts +28 -0
  261. package/dist/tools/index.js +20 -0
  262. package/dist/tools/people-tools.d.ts +19 -0
  263. package/dist/tools/registry.d.ts +34 -0
  264. package/dist/tools/shared.d.ts +75 -0
  265. package/dist/tracing/index.d.ts +25 -0
  266. package/dist/tracing/index.js +69 -0
  267. package/dist/webhooks/index.d.ts +3 -0
  268. package/dist/webhooks/index.js +226 -0
  269. package/dist/webhooks/parse.d.ts +41 -0
  270. package/dist/webhooks/secret.d.ts +4 -0
  271. package/package.json +181 -4
@@ -0,0 +1,792 @@
1
+ import {
2
+ emptyCounts,
3
+ sumCounts
4
+ } from "../chunks/chunk-WW746NJF.js";
5
+ import {
6
+ profileSlug
7
+ } from "../chunks/chunk-NAWZ73QS.js";
8
+ import {
9
+ stableId
10
+ } from "../chunks/chunk-LNCOGBMI.js";
11
+ import {
12
+ recordBase,
13
+ refTo,
14
+ refsTo
15
+ } from "../chunks/chunk-IBC52BX3.js";
16
+ import {
17
+ SCHEMA_VERSION
18
+ } from "../chunks/chunk-WAM6N4OF.js";
19
+ import {
20
+ assertWorkspaceId,
21
+ makeRef
22
+ } from "../chunks/chunk-ZGHQYZEH.js";
23
+ import {
24
+ OutboundError,
25
+ makeErrorMapper
26
+ } from "../chunks/chunk-LOXBLQ3I.js";
27
+ import {
28
+ isNumber
29
+ } from "../chunks/chunk-QZNNCXXD.js";
30
+
31
+ // src/memory/account.ts
32
+ var base = (identity, sourceId) => recordBase(identity, sourceId, null);
33
+ var toSettings = (identity, campaignId, seed) => ({
34
+ ...base(identity, campaignId),
35
+ campaignRef: makeRef(identity.provider, identity.workspaceId, campaignId),
36
+ dailyLimit: seed.dailyLimit ?? null,
37
+ dailyNewLeads: seed.dailyNewLeads ?? null,
38
+ endDate: seed.endDate ?? null,
39
+ gapMinutes: seed.gapMinutes ?? null,
40
+ plainText: seed.plainText ?? null,
41
+ schedule: (seed.schedule ?? []).map((window) => ({
42
+ days: [...window.days ?? []],
43
+ from: window.from ?? null,
44
+ name: window.name ?? null,
45
+ timezone: window.timezone ?? null,
46
+ to: window.to ?? null
47
+ })),
48
+ startDate: seed.startDate ?? null,
49
+ stopOnAutoReply: seed.stopOnAutoReply ?? null,
50
+ stopOnReply: seed.stopOnReply ?? null,
51
+ tracking: {
52
+ clicks: seed.trackClicks ?? null,
53
+ opens: seed.trackOpens ?? null
54
+ }
55
+ });
56
+ var toHealth = (identity, sender, seed) => ({
57
+ ...base(identity, sender.id),
58
+ blacklisted: seed.blacklisted ?? null,
59
+ checkedAt: seed.checkedAt ?? null,
60
+ connected: seed.connected ?? null,
61
+ dns: {
62
+ dkim: seed.dkim ?? null,
63
+ dmarc: seed.dmarc ?? null,
64
+ mx: seed.mx ?? null,
65
+ spf: seed.spf ?? null
66
+ },
67
+ domain: sender.address?.split("@")[1]?.trim().toLowerCase() ?? null,
68
+ issues: [...seed.issues ?? []],
69
+ senderRef: makeRef(identity.provider, identity.workspaceId, sender.id),
70
+ warmup: seed.warmup === void 0 ? null : {
71
+ inbox: seed.warmup.inbox ?? null,
72
+ received: seed.warmup.received ?? null,
73
+ score: seed.warmup.score ?? null,
74
+ sent: seed.warmup.sent ?? null,
75
+ spam: seed.warmup.spam ?? null
76
+ }
77
+ });
78
+ var toList = (identity, seed, size) => ({
79
+ ...base(identity, seed.id),
80
+ createdAt: seed.createdAt ?? null,
81
+ kind: seed.kind ?? "leads",
82
+ name: seed.name ?? seed.id,
83
+ size
84
+ });
85
+ var toBlockEntry = (identity, seed) => ({
86
+ ...base(identity, seed.id),
87
+ createdAt: seed.createdAt ?? null,
88
+ kind: seed.kind ?? (seed.value.includes("@") ? "email" : "domain"),
89
+ value: seed.value.trim().toLowerCase()
90
+ });
91
+ var toTag = (identity, seed) => ({
92
+ ...base(identity, seed.id),
93
+ description: seed.description ?? null,
94
+ name: seed.name ?? seed.id
95
+ });
96
+ var toWebhook = (identity, seed) => ({
97
+ ...base(identity, seed.id),
98
+ active: seed.active ?? true,
99
+ campaignRefs: refsTo(identity, [seed.campaignId]),
100
+ createdAt: seed.createdAt ?? null,
101
+ events: [...seed.events ?? []],
102
+ name: seed.name ?? null,
103
+ url: seed.url
104
+ });
105
+
106
+ // src/memory/data.ts
107
+ var base2 = (identity, sourceId) => recordBase(identity, sourceId, null);
108
+ var refOrNull = refTo;
109
+ var toCampaign = (identity, seed) => ({
110
+ ...base2(identity, seed.id),
111
+ channel: seed.channel ?? "email",
112
+ createdAt: seed.createdAt ?? null,
113
+ name: seed.name ?? seed.id,
114
+ status: seed.status ?? "active",
115
+ tags: [...seed.tags ?? []]
116
+ });
117
+ var toSteps = (steps, channel) => steps.map((step, index) => ({
118
+ action: step.action ?? (channel === "linkedin" ? "message" : "email"),
119
+ branch: step.branch ?? null,
120
+ delayDays: step.delayDays ?? null,
121
+ index,
122
+ parentIndex: step.parentIndex ?? (index === 0 ? null : index - 1),
123
+ variants: step.variants.map((variant, variantIndex) => ({
124
+ body: variant.body ?? null,
125
+ contentHash: stableId(variant.subject, variant.body),
126
+ subject: variant.subject ?? null,
127
+ variantKey: variant.key ?? String.fromCodePoint(65 + variantIndex)
128
+ }))
129
+ }));
130
+ var toSequence = (identity, seed) => ({
131
+ ...base2(identity, seed.id),
132
+ campaignRef: makeRef(identity.provider, identity.workspaceId, seed.id),
133
+ kind: "main",
134
+ name: null,
135
+ steps: toSteps(seed.steps ?? [], seed.channel)
136
+ });
137
+ var toSubsequence = (identity, campaign, seed) => ({
138
+ ...base2(identity, seed.id),
139
+ campaignRef: makeRef(identity.provider, identity.workspaceId, campaign.id),
140
+ kind: "subsequence",
141
+ name: seed.name ?? seed.id,
142
+ steps: toSteps(seed.steps, campaign.channel)
143
+ });
144
+ var toSender = (identity, seed) => ({
145
+ ...base2(identity, seed.id),
146
+ address: seed.address?.trim().toLowerCase() ?? null,
147
+ dailyLimit: seed.dailyLimit ?? null,
148
+ kind: seed.linkedinUrl === void 0 ? "mailbox" : "linkedin",
149
+ linkedinUrl: seed.linkedinUrl ?? null,
150
+ name: seed.name ?? null,
151
+ status: seed.status ?? "active",
152
+ warmup: seed.warmup === void 0 ? null : { enabled: seed.warmup.enabled, score: seed.warmup.score ?? null }
153
+ });
154
+ var toEngagement = (seed) => ({
155
+ clicks: seed.clicks ?? null,
156
+ lastContactedAt: seed.lastContactedAt ?? null,
157
+ lastOpenedAt: seed.lastOpenedAt ?? null,
158
+ lastRepliedAt: seed.lastRepliedAt ?? null,
159
+ opens: seed.opens ?? null,
160
+ repliedStepIndex: seed.repliedStepIndex ?? null,
161
+ replies: seed.replies ?? null,
162
+ stepIndex: seed.stepIndex ?? null
163
+ });
164
+ var toLead = (identity, seed) => ({
165
+ ...base2(identity, seed.id),
166
+ campaignRef: refOrNull(identity, seed.campaignId),
167
+ company: seed.company ?? null,
168
+ createdAt: seed.createdAt ?? null,
169
+ custom: { ...seed.custom },
170
+ email: seed.email?.trim().toLowerCase() ?? null,
171
+ engagement: seed.engagement === void 0 ? null : toEngagement(seed.engagement),
172
+ firstName: seed.firstName ?? null,
173
+ interest: seed.interest ?? null,
174
+ tags: [...seed.tags ?? []],
175
+ lastName: seed.lastName ?? null,
176
+ linkedinUrl: seed.linkedinUrl ?? null,
177
+ status: seed.status ?? "active",
178
+ title: seed.title ?? null
179
+ });
180
+ var messageFields = (identity, seed, channel, includeBody) => ({
181
+ ...base2(identity, seed.id),
182
+ bodyHtml: null,
183
+ bodyText: includeBody ? seed.body ?? null : null,
184
+ campaignRef: refOrNull(identity, seed.campaignId),
185
+ channel,
186
+ leadRef: refOrNull(identity, seed.leadId),
187
+ senderRef: refOrNull(identity, seed.senderId),
188
+ sentAt: seed.sentAt,
189
+ stepIndex: seed.stepIndex ?? null,
190
+ subject: seed.subject ?? null,
191
+ threadId: seed.threadId ?? null,
192
+ variantKey: seed.variantKey ?? null
193
+ });
194
+ var toMessage = (identity, seed, channel, includeBody) => ({
195
+ ...messageFields(identity, seed, channel, includeBody),
196
+ direction: seed.direction
197
+ });
198
+ var toReply = (identity, seed, channel, includeBody) => ({
199
+ ...messageFields(identity, seed, channel, includeBody),
200
+ category: seed.category ?? "unknown",
201
+ categorySource: seed.category === void 0 ? null : "vendor",
202
+ direction: "in",
203
+ isAuto: seed.isAuto ?? null
204
+ });
205
+ var toMetricRow = (identity, counts) => ({
206
+ ...counts,
207
+ contentHash: null,
208
+ date: identity.date,
209
+ evidence: "exact",
210
+ provider: identity.provider,
211
+ schemaVersion: SCHEMA_VERSION,
212
+ scope: identity.scope,
213
+ scopeRef: makeRef(identity.provider, identity.workspaceId, identity.scopeId),
214
+ stepIndex: identity.stepIndex,
215
+ timezone: identity.date === null ? null : "UTC",
216
+ variantKey: identity.variantKey,
217
+ workspaceId: identity.workspaceId
218
+ });
219
+
220
+ // src/memory/store.ts
221
+ var paginate = (items, query, pageSize) => {
222
+ const offset = isNumber(query.next) ? query.next : 0;
223
+ const size = Math.min(query.limit ?? pageSize, pageSize);
224
+ const end = offset + size;
225
+ return end < items.length ? { items: items.slice(offset, end), next: end } : { items: items.slice(offset, end) };
226
+ };
227
+ var notFound = (provider, what, id) => new OutboundError("NotFound", `${what} ${id} was not found`, {
228
+ provider,
229
+ status: 404
230
+ });
231
+ var findCampaign = (store, id) => {
232
+ const seed = store.data.campaigns?.find((campaign) => campaign.id === id);
233
+ if (seed === void 0) {
234
+ throw notFound(store.identity.provider, "Campaign", id);
235
+ }
236
+ return seed;
237
+ };
238
+
239
+ // src/memory/account-reads.ts
240
+ var accountReads = (store) => {
241
+ const { data, identity, pageSize } = store;
242
+ const page = (items, query) => Promise.resolve(paginate(items, query, pageSize));
243
+ return {
244
+ getCampaignSettings: (id) => Promise.resolve(
245
+ toSettings(identity, id, findCampaign(store, id).settings ?? {})
246
+ ),
247
+ getSenderHealth: (id) => {
248
+ const seed = data.senders?.find((sender) => sender.id === id);
249
+ return seed === void 0 ? Promise.reject(notFound(identity.provider, "Sender", id)) : Promise.resolve(toHealth(identity, seed, seed.health ?? {}));
250
+ },
251
+ listBlocklist: (query) => page(
252
+ (data.blocklist ?? []).map((seed) => toBlockEntry(identity, seed)),
253
+ query
254
+ ),
255
+ listLists: (query) => page(
256
+ (data.lists ?? []).map(
257
+ (seed) => toList(
258
+ identity,
259
+ seed,
260
+ (data.leads ?? []).filter(
261
+ (lead) => (lead.listIds ?? []).includes(seed.id)
262
+ ).length
263
+ )
264
+ ),
265
+ query
266
+ ),
267
+ listSubsequences: (query) => {
268
+ const campaign = findCampaign(store, query.campaignId);
269
+ return page(
270
+ (campaign.subsequences ?? []).map(
271
+ (seed) => toSubsequence(identity, campaign, seed)
272
+ ),
273
+ query
274
+ );
275
+ },
276
+ listTags: (query) => page(
277
+ (data.tags ?? []).map((seed) => toTag(identity, seed)),
278
+ query
279
+ ),
280
+ listWebhooks: (query) => page(
281
+ (data.webhooks ?? []).flatMap(
282
+ (seed) => query.campaignId === void 0 || seed.campaignId === query.campaignId ? [toWebhook(identity, seed)] : []
283
+ ),
284
+ query
285
+ )
286
+ };
287
+ };
288
+
289
+ // src/memory/stats.ts
290
+ var matchesScope = (row, query) => {
291
+ switch (query.scope) {
292
+ case "workspace": {
293
+ return row.senderId === void 0 && row.stepIndex === void 0;
294
+ }
295
+ case "campaign": {
296
+ return row.campaignId === query.scopeId && row.senderId === void 0 && row.stepIndex === void 0;
297
+ }
298
+ case "step": {
299
+ return row.campaignId === query.scopeId && row.stepIndex !== void 0;
300
+ }
301
+ case "sender": {
302
+ return row.senderId === query.scopeId;
303
+ }
304
+ default: {
305
+ const unreachable = query.scope;
306
+ return unreachable;
307
+ }
308
+ }
309
+ };
310
+ var inRange = (row, query) => (query.from === void 0 || row.date >= query.from) && (query.to === void 0 || row.date <= query.to);
311
+ var groupKey = (row, query) => [
312
+ query.by === "day" ? row.date : "",
313
+ query.scope === "step" ? row.stepIndex : "",
314
+ query.scope === "step" ? row.variantKey ?? "" : ""
315
+ ].join("|");
316
+ var queryStats = (identity, seeds, query) => {
317
+ const groups = /* @__PURE__ */ new Map();
318
+ for (const row of seeds) {
319
+ if (matchesScope(row, query) && inRange(row, query)) {
320
+ const key = groupKey(row, query);
321
+ groups.set(key, [...groups.get(key) ?? [], row]);
322
+ }
323
+ }
324
+ return [...groups.values()].map((rows) => {
325
+ const [first] = rows;
326
+ return toMetricRow(
327
+ {
328
+ ...identity,
329
+ date: query.by === "day" ? first?.date ?? null : null,
330
+ scope: query.scope,
331
+ scopeId: query.scopeId ?? identity.workspaceId,
332
+ stepIndex: query.scope === "step" ? first?.stepIndex ?? null : null,
333
+ variantKey: query.scope === "step" ? first?.variantKey ?? null : null
334
+ },
335
+ sumCounts(rows.map((row) => ({ ...emptyCounts(), ...row.counts })))
336
+ );
337
+ }).toSorted(
338
+ (left, right) => (left.date ?? "").localeCompare(right.date ?? "") || (left.stepIndex ?? 0) - (right.stepIndex ?? 0) || (left.variantKey ?? "").localeCompare(right.variantKey ?? "")
339
+ );
340
+ };
341
+
342
+ // src/memory/adapter.ts
343
+ var FULL_CAPABILITIES = {
344
+ blocklist: true,
345
+ "campaigns.settings": true,
346
+ "campaigns.status": "server",
347
+ "leads.byCampaign": true,
348
+ "leads.engagement": true,
349
+ "leads.get": true,
350
+ "leads.list": true,
351
+ "leads.lookup": true,
352
+ "leads.since": "server",
353
+ "leads.timeline": true,
354
+ "lists.leads": true,
355
+ "lists.list": true,
356
+ "messages.body": "full",
357
+ "messages.byThread": true,
358
+ "messages.list": true,
359
+ "messages.since": "server",
360
+ "replies.category": "vendor",
361
+ "replies.list": true,
362
+ "replies.since": "server",
363
+ "senders.byCampaign": true,
364
+ "senders.get": true,
365
+ "senders.health": true,
366
+ "senders.list": true,
367
+ "senders.warmup": true,
368
+ sequence: true,
369
+ "sequence.subsequences": true,
370
+ "stats.byDay": "exact",
371
+ "stats.bySender": "exact",
372
+ "stats.byStep": "exact",
373
+ "stats.campaign": "exact",
374
+ "stats.workspace": "exact",
375
+ tags: true,
376
+ "webhooks.list": true,
377
+ workspaces: true
378
+ };
379
+ var within = (time, range) => time === void 0 ? range.since === void 0 && range.until === void 0 : (range.since === void 0 || time >= range.since) && (range.until === void 0 || time <= range.until);
380
+ var filtersByTime = (store, key) => store.capabilities[key] === "server";
381
+ var selectMessages = (store, query, key) => (store.data.messages ?? []).filter(
382
+ (message) => (query.campaignId === void 0 || message.campaignId === query.campaignId) && (query.leadId === void 0 || message.leadId === query.leadId) && (query.threadId === void 0 || message.threadId === query.threadId) && (!filtersByTime(store, key) || within(message.sentAt, query))
383
+ );
384
+ var selectLeads = (store, query) => (store.data.leads ?? []).filter(
385
+ (lead) => (query.campaignId === void 0 || lead.campaignId === query.campaignId) && (query.listId === void 0 || (lead.listIds ?? []).includes(query.listId)) && (query.email === void 0 || lead.email?.trim().toLowerCase() === query.email) && (query.linkedinUrl === void 0 || profileSlug(lead.linkedinUrl) !== null && profileSlug(lead.linkedinUrl) === profileSlug(query.linkedinUrl)) && (!filtersByTime(store, "leads.since") || within(lead.createdAt, query))
386
+ );
387
+ var getters = (store) => {
388
+ const { data, identity } = store;
389
+ return {
390
+ getCampaign: (id) => Promise.resolve(toCampaign(identity, findCampaign(store, id))),
391
+ getLead: (id) => {
392
+ const seed = data.leads?.find((lead) => lead.id === id);
393
+ return seed === void 0 ? Promise.reject(notFound(identity.provider, "Lead", id)) : Promise.resolve(toLead(identity, seed));
394
+ },
395
+ getSender: (id) => {
396
+ const seed = data.senders?.find((sender) => sender.id === id);
397
+ return seed === void 0 ? Promise.reject(notFound(identity.provider, "Sender", id)) : Promise.resolve(toSender(identity, seed));
398
+ },
399
+ getSequence: (id) => Promise.resolve(toSequence(identity, findCampaign(store, id)))
400
+ };
401
+ };
402
+ var listers = (store) => {
403
+ const { data, identity, pageSize } = store;
404
+ return {
405
+ listCampaigns: (query) => {
406
+ const filterHere = store.capabilities["campaigns.status"] === "server";
407
+ const seeds = (data.campaigns ?? []).filter(
408
+ (campaign) => !filterHere || query.status === void 0 || (campaign.status ?? "active") === query.status
409
+ );
410
+ return Promise.resolve(
411
+ paginate(
412
+ seeds.map((seed) => toCampaign(identity, seed)),
413
+ query,
414
+ pageSize
415
+ )
416
+ );
417
+ },
418
+ listLeads: (query) => {
419
+ const seeds = selectLeads(store, query);
420
+ return Promise.resolve(
421
+ paginate(
422
+ seeds.map((seed) => toLead(identity, seed)),
423
+ query,
424
+ pageSize
425
+ )
426
+ );
427
+ },
428
+ listMessages: (query) => Promise.resolve(
429
+ paginate(
430
+ selectMessages(store, query, "messages.since").map(
431
+ (seed) => toMessage(
432
+ identity,
433
+ seed,
434
+ store.channelOf(seed.campaignId),
435
+ query.includeBody
436
+ )
437
+ ),
438
+ query,
439
+ pageSize
440
+ )
441
+ ),
442
+ listReplies: (query) => Promise.resolve(
443
+ paginate(
444
+ selectMessages(store, query, "replies.since").filter(
445
+ (seed) => seed.direction === "in" && (query.category === void 0 || (seed.category ?? "unknown") === query.category)
446
+ ).map(
447
+ (seed) => toReply(
448
+ identity,
449
+ seed,
450
+ store.channelOf(seed.campaignId),
451
+ query.includeBody
452
+ )
453
+ ),
454
+ query,
455
+ pageSize
456
+ )
457
+ ),
458
+ listSenders: (query) => {
459
+ const seeds = (data.senders ?? []).filter(
460
+ (sender) => query.campaignId === void 0 || (sender.campaignIds ?? []).includes(query.campaignId)
461
+ );
462
+ return Promise.resolve(
463
+ paginate(
464
+ seeds.map((seed) => toSender(identity, seed)),
465
+ query,
466
+ pageSize
467
+ )
468
+ );
469
+ },
470
+ listWorkspaces: () => Promise.resolve({
471
+ items: [
472
+ {
473
+ ...recordBase(identity, identity.workspaceId, null),
474
+ name: identity.workspaceId
475
+ }
476
+ ]
477
+ }),
478
+ stats: (query) => {
479
+ const ofCampaign = query.scope === "campaign" || query.scope === "step";
480
+ return ofCampaign && !store.mentionsCampaign(query.scopeId) ? Promise.reject(
481
+ notFound(identity.provider, "Campaign", query.scopeId ?? "")
482
+ ) : Promise.resolve(queryStats(identity, data.stats ?? [], query));
483
+ }
484
+ };
485
+ };
486
+ var memory = (options = {}) => {
487
+ const provider = options.name ?? "memory";
488
+ const identity = {
489
+ provider,
490
+ workspaceId: assertWorkspaceId(options.workspaceId ?? "default", provider)
491
+ };
492
+ const data = options.data ?? {};
493
+ const capabilities = { ...FULL_CAPABILITIES, ...options.capabilities };
494
+ const channels = new Map(
495
+ (data.campaigns ?? []).map((seed) => [seed.id, seed.channel ?? "email"])
496
+ );
497
+ const mentioned = /* @__PURE__ */ new Set([
498
+ ...channels.keys(),
499
+ ...(data.stats ?? []).map((seed) => seed.campaignId),
500
+ ...(data.leads ?? []).map((seed) => seed.campaignId),
501
+ ...(data.messages ?? []).map((seed) => seed.campaignId),
502
+ ...(data.senders ?? []).flatMap((seed) => seed.campaignIds ?? [])
503
+ ]);
504
+ const store = {
505
+ capabilities,
506
+ channelOf: (campaignId) => (campaignId === void 0 ? void 0 : channels.get(campaignId)) ?? "email",
507
+ data,
508
+ identity,
509
+ mentionsCampaign: (campaignId) => campaignId !== void 0 && mentioned.has(campaignId),
510
+ pageSize: options.pageSize ?? 50
511
+ };
512
+ return {
513
+ ...getters(store),
514
+ ...listers(store),
515
+ ...accountReads(store),
516
+ capabilities,
517
+ costs: {},
518
+ // Nothing is rate limited in memory; the numbers only keep the engine's math defined.
519
+ limits: {
520
+ source: "in-memory adapter, not a vendor limit",
521
+ windows: [{ perMs: 1e3, requests: 1e6 }]
522
+ },
523
+ mapError: makeErrorMapper(provider),
524
+ maturity: "stable",
525
+ name: provider,
526
+ raw: {
527
+ authorize: (spec) => spec,
528
+ baseUrl: "memory://outbound-sdk",
529
+ // There is no vendor API behind this adapter, so raw has nothing to read.
530
+ isRead: () => false
531
+ },
532
+ secrets: [],
533
+ workspaceId: identity.workspaceId
534
+ };
535
+ };
536
+
537
+ // src/memory/demo.ts
538
+ var campaigns = [
539
+ {
540
+ createdAt: "2026-10-01T09:00:00.000Z",
541
+ id: "cmp_founders",
542
+ name: "Q4 SaaS founders",
543
+ settings: {
544
+ dailyLimit: 80,
545
+ dailyNewLeads: 30,
546
+ gapMinutes: 12,
547
+ schedule: [
548
+ {
549
+ days: [1, 2, 3, 4, 5],
550
+ from: "09:00",
551
+ name: "Weekdays",
552
+ timezone: "America/New_York",
553
+ to: "17:00"
554
+ }
555
+ ],
556
+ startDate: "2026-10-05",
557
+ stopOnAutoReply: false,
558
+ stopOnReply: true,
559
+ trackClicks: false,
560
+ trackOpens: true
561
+ },
562
+ status: "active",
563
+ steps: [
564
+ {
565
+ delayDays: 0,
566
+ variants: [
567
+ {
568
+ body: "Hi {{firstName}}, saw your launch.",
569
+ subject: "Quick question"
570
+ },
571
+ {
572
+ body: "Hi {{firstName}}, congrats on the launch.",
573
+ subject: "Congrats"
574
+ }
575
+ ]
576
+ },
577
+ {
578
+ delayDays: 3,
579
+ variants: [
580
+ { body: "Following up on my note.", subject: "Re: Quick question" }
581
+ ]
582
+ }
583
+ ],
584
+ tags: ["client-a"]
585
+ },
586
+ {
587
+ createdAt: "2026-09-12T09:00:00.000Z",
588
+ id: "cmp_agencies",
589
+ name: "Agency owners",
590
+ status: "paused",
591
+ steps: [
592
+ {
593
+ delayDays: 0,
594
+ variants: [
595
+ { body: "Hello {{firstName}}.", subject: "Idea for {{company}}" }
596
+ ]
597
+ }
598
+ ],
599
+ tags: ["client-b"]
600
+ }
601
+ ];
602
+ var leads = [
603
+ {
604
+ campaignId: "cmp_founders",
605
+ company: "Example Co",
606
+ createdAt: "2026-10-02T10:00:00.000Z",
607
+ email: "person1@example.com",
608
+ engagement: {
609
+ lastContactedAt: "2026-10-05T14:00:00.000Z",
610
+ lastRepliedAt: "2026-10-06T09:30:00.000Z",
611
+ opens: 2,
612
+ replies: 1,
613
+ stepIndex: 0
614
+ },
615
+ firstName: "Alex",
616
+ id: "lead_1",
617
+ interest: "Interested",
618
+ lastName: "Example",
619
+ listIds: ["lst_founders"],
620
+ status: "replied",
621
+ title: "Founder"
622
+ },
623
+ {
624
+ campaignId: "cmp_founders",
625
+ company: "Sample Ltd",
626
+ createdAt: "2026-10-03T10:00:00.000Z",
627
+ email: "person2@example.com",
628
+ firstName: "Sam",
629
+ id: "lead_2",
630
+ listIds: ["lst_founders"],
631
+ lastName: "Sample",
632
+ status: "active",
633
+ title: "CEO"
634
+ },
635
+ {
636
+ campaignId: "cmp_agencies",
637
+ company: "Demo Agency",
638
+ createdAt: "2026-09-13T10:00:00.000Z",
639
+ email: "person3@example.com",
640
+ firstName: "Dana",
641
+ id: "lead_3",
642
+ lastName: "Demo",
643
+ status: "bounced",
644
+ title: "Owner"
645
+ }
646
+ ];
647
+ var messages = [
648
+ {
649
+ body: "Hi Alex, saw your launch.",
650
+ campaignId: "cmp_founders",
651
+ direction: "out",
652
+ id: "msg_1",
653
+ leadId: "lead_1",
654
+ senderId: "mbx_1",
655
+ sentAt: "2026-10-05T14:00:00.000Z",
656
+ stepIndex: 0,
657
+ subject: "Quick question",
658
+ threadId: "thr_1",
659
+ variantKey: "A"
660
+ },
661
+ {
662
+ body: "Thanks, happy to chat next week.",
663
+ campaignId: "cmp_founders",
664
+ category: "positive",
665
+ direction: "in",
666
+ id: "msg_2",
667
+ isAuto: false,
668
+ leadId: "lead_1",
669
+ senderId: "mbx_1",
670
+ sentAt: "2026-10-06T09:30:00.000Z",
671
+ subject: "Re: Quick question",
672
+ threadId: "thr_1"
673
+ },
674
+ {
675
+ body: "Hi Sam, congrats on the launch.",
676
+ campaignId: "cmp_founders",
677
+ direction: "out",
678
+ id: "msg_3",
679
+ leadId: "lead_2",
680
+ senderId: "mbx_2",
681
+ sentAt: "2026-10-05T14:05:00.000Z",
682
+ stepIndex: 0,
683
+ subject: "Congrats",
684
+ variantKey: "B"
685
+ }
686
+ ];
687
+ var senders = [
688
+ {
689
+ address: "outreach1@example.com",
690
+ campaignIds: ["cmp_founders"],
691
+ dailyLimit: 40,
692
+ health: {
693
+ checkedAt: "2026-10-06T00:00:00.000Z",
694
+ connected: true,
695
+ dkim: true,
696
+ dmarc: true,
697
+ mx: true,
698
+ spf: true,
699
+ warmup: { inbox: 96, received: 90, score: 96, sent: 100, spam: 4 }
700
+ },
701
+ id: "mbx_1",
702
+ name: "Outreach One",
703
+ warmup: { enabled: true, score: 96 }
704
+ },
705
+ {
706
+ address: "outreach2@example.com",
707
+ campaignIds: ["cmp_founders", "cmp_agencies"],
708
+ dailyLimit: 40,
709
+ health: {
710
+ checkedAt: "2026-10-06T00:00:00.000Z",
711
+ connected: true,
712
+ dkim: false,
713
+ dmarc: true,
714
+ issues: ["DKIM selector not found"],
715
+ mx: true,
716
+ spf: true,
717
+ warmup: { inbox: 75, received: 70, score: 88, sent: 100, spam: 25 }
718
+ },
719
+ id: "mbx_2",
720
+ name: "Outreach Two",
721
+ warmup: { enabled: true, score: 88 }
722
+ }
723
+ ];
724
+ var stats = [
725
+ {
726
+ campaignId: "cmp_founders",
727
+ counts: {
728
+ bounced: 1,
729
+ contacted: 50,
730
+ delivered: 49,
731
+ opened: 30,
732
+ positive: 2,
733
+ replied: 4,
734
+ sent: 50
735
+ },
736
+ date: "2026-10-05"
737
+ },
738
+ {
739
+ campaignId: "cmp_founders",
740
+ counts: {
741
+ bounced: 0,
742
+ contacted: 40,
743
+ delivered: 40,
744
+ opened: 22,
745
+ positive: 1,
746
+ replied: 3,
747
+ sent: 40
748
+ },
749
+ date: "2026-10-06"
750
+ },
751
+ {
752
+ campaignId: "cmp_agencies",
753
+ counts: {
754
+ bounced: 4,
755
+ contacted: 60,
756
+ delivered: 56,
757
+ opened: 18,
758
+ positive: 0,
759
+ replied: 1,
760
+ sent: 60
761
+ },
762
+ date: "2026-10-05"
763
+ }
764
+ ];
765
+ var demoData = () => ({
766
+ blocklist: [{ id: "blk_1", value: "competitor.example" }],
767
+ campaigns,
768
+ lists: [
769
+ {
770
+ createdAt: "2026-09-30T09:00:00.000Z",
771
+ id: "lst_founders",
772
+ name: "SaaS founders"
773
+ }
774
+ ],
775
+ tags: [{ description: "Work for client A", id: "tag_a", name: "client-a" }],
776
+ webhooks: [
777
+ {
778
+ events: ["reply_received"],
779
+ id: "wh_1",
780
+ name: "Replies",
781
+ url: "https://hooks.example.com/replies"
782
+ }
783
+ ],
784
+ leads,
785
+ messages,
786
+ senders,
787
+ stats
788
+ });
789
+ export {
790
+ demoData,
791
+ memory
792
+ };