outbound-sdk 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +119 -2
  3. package/dist/alerts/index.d.ts +2 -0
  4. package/dist/alerts/index.js +140 -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 +72 -0
  10. package/dist/budget/index.d.ts +21 -0
  11. package/dist/budget/index.js +71 -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-4PSO6JEK.js +357 -0
  32. package/dist/chunks/chunk-6CVZOUHB.js +152 -0
  33. package/dist/chunks/chunk-AFU5E5QB.js +714 -0
  34. package/dist/chunks/chunk-DJ2IUQEU.js +111 -0
  35. package/dist/chunks/chunk-E7JHLNLG.js +187 -0
  36. package/dist/chunks/chunk-FHKSLCVW.js +154 -0
  37. package/dist/chunks/chunk-FKH5N47I.js +40 -0
  38. package/dist/chunks/chunk-HZCTYL22.js +29 -0
  39. package/dist/chunks/chunk-IPUYZD4O.js +25 -0
  40. package/dist/chunks/chunk-IVH3NMQZ.js +61 -0
  41. package/dist/chunks/chunk-LVYG7XZJ.js +45 -0
  42. package/dist/chunks/chunk-NAKXLBA6.js +30 -0
  43. package/dist/chunks/chunk-NAWZ73QS.js +22 -0
  44. package/dist/chunks/chunk-PMSSUWD7.js +636 -0
  45. package/dist/chunks/chunk-PURHK3JU.js +432 -0
  46. package/dist/chunks/chunk-R3Y56YVF.js +43 -0
  47. package/dist/chunks/chunk-RCZ7ZZFU.js +92 -0
  48. package/dist/chunks/chunk-SBIZDCRY.js +106 -0
  49. package/dist/chunks/chunk-U2D34ARZ.js +41 -0
  50. package/dist/chunks/chunk-UAT3JSJZ.js +331 -0
  51. package/dist/chunks/chunk-VQSCHOBV.js +111 -0
  52. package/dist/chunks/chunk-XC6CZP73.js +80 -0
  53. package/dist/chunks/chunk-XNFESPZH.js +2307 -0
  54. package/dist/chunks/chunk-YOTW5ESM.js +118 -0
  55. package/dist/cli/bin.d.ts +2 -0
  56. package/dist/cli/bin.js +35 -0
  57. package/dist/cli/commands.d.ts +19 -0
  58. package/dist/cli/config.d.ts +22 -0
  59. package/dist/cli/index.d.ts +17 -0
  60. package/dist/cli/index.js +30 -0
  61. package/dist/cli/mcp.d.ts +14 -0
  62. package/dist/cli/stdio.d.ts +9 -0
  63. package/dist/clients/index.d.ts +2 -0
  64. package/dist/clients/index.js +117 -0
  65. package/dist/clients/plugin.d.ts +42 -0
  66. package/dist/combine/account.d.ts +4 -0
  67. package/dist/combine/adapter.d.ts +9 -0
  68. package/dist/combine/index.d.ts +2 -0
  69. package/dist/combine/index.js +420 -0
  70. package/dist/combine/route.d.ts +24 -0
  71. package/dist/exporter/index.d.ts +29 -0
  72. package/dist/exporter/index.js +77 -0
  73. package/dist/failover/index.d.ts +11 -0
  74. package/dist/failover/index.js +45 -0
  75. package/dist/fixtures/index.d.ts +27 -0
  76. package/dist/fixtures/index.js +260 -0
  77. package/dist/fixtures/scrub.d.ts +5 -0
  78. package/dist/heyreach/account.d.ts +11 -0
  79. package/dist/heyreach/adapter.d.ts +5 -0
  80. package/dist/heyreach/capabilities.d.ts +70 -0
  81. package/dist/heyreach/client.d.ts +18 -0
  82. package/dist/heyreach/inbox.d.ts +7 -0
  83. package/dist/heyreach/index.d.ts +25 -0
  84. package/dist/heyreach/index.js +1931 -0
  85. package/dist/heyreach/leads.d.ts +4 -0
  86. package/dist/heyreach/lookup.d.ts +15 -0
  87. package/dist/heyreach/map-account.d.ts +31 -0
  88. package/dist/heyreach/map-sequence.d.ts +5 -0
  89. package/dist/heyreach/map-stats.d.ts +13 -0
  90. package/dist/heyreach/map.d.ts +37 -0
  91. package/dist/heyreach/native-organization.d.ts +128 -0
  92. package/dist/heyreach/native-voice.d.ts +106 -0
  93. package/dist/heyreach/native.d.ts +496 -0
  94. package/dist/heyreach/paging.d.ts +7 -0
  95. package/dist/heyreach/webhooks.d.ts +3 -0
  96. package/dist/identity/index.d.ts +3 -0
  97. package/dist/identity/index.js +159 -0
  98. package/dist/identity/keys.d.ts +9 -0
  99. package/dist/identity/plugin.d.ts +34 -0
  100. package/dist/index.d.ts +33 -0
  101. package/dist/index.js +131 -0
  102. package/dist/insights/copy/copy-audit.d.ts +55 -0
  103. package/dist/insights/copy/copy-checks.d.ts +44 -0
  104. package/dist/insights/copy/copy-reuse.d.ts +59 -0
  105. package/dist/insights/copy/index.d.ts +67 -0
  106. package/dist/insights/copy/reply-timing.d.ts +63 -0
  107. package/dist/insights/copy/shared.d.ts +53 -0
  108. package/dist/insights/copy/step-funnel.d.ts +66 -0
  109. package/dist/insights/copy/variant-test.d.ts +64 -0
  110. package/dist/insights/define.d.ts +98 -0
  111. package/dist/insights/index.d.ts +10 -0
  112. package/dist/insights/index.js +4937 -0
  113. package/dist/insights/ops/anomalies.d.ts +80 -0
  114. package/dist/insights/ops/campaign-diagnosis.d.ts +39 -0
  115. package/dist/insights/ops/campaign-ranking.d.ts +56 -0
  116. package/dist/insights/ops/channel-mix.d.ts +44 -0
  117. package/dist/insights/ops/client-report.d.ts +76 -0
  118. package/dist/insights/ops/diagnosis-checks.d.ts +48 -0
  119. package/dist/insights/ops/index.d.ts +135 -0
  120. package/dist/insights/ops/period-comparison.d.ts +86 -0
  121. package/dist/insights/ops/pipeline-forecast.d.ts +44 -0
  122. package/dist/insights/ops/shared.d.ts +155 -0
  123. package/dist/insights/ops/tag-rollup.d.ts +32 -0
  124. package/dist/insights/people/account-summary.d.ts +68 -0
  125. package/dist/insights/people/dropped-replies.d.ts +51 -0
  126. package/dist/insights/people/find.d.ts +18 -0
  127. package/dist/insights/people/hot-leads.d.ts +67 -0
  128. package/dist/insights/people/index.d.ts +88 -0
  129. package/dist/insights/people/lead-collisions.d.ts +43 -0
  130. package/dist/insights/people/person-summary.d.ts +46 -0
  131. package/dist/insights/people/personalization-gaps.d.ts +60 -0
  132. package/dist/insights/people/read.d.ts +40 -0
  133. package/dist/insights/people/suppression-check.d.ts +53 -0
  134. package/dist/insights/plugin.d.ts +40 -0
  135. package/dist/insights/registry.d.ts +335 -0
  136. package/dist/insights/senders/bounce-watch.d.ts +70 -0
  137. package/dist/insights/senders/domain-health.d.ts +69 -0
  138. package/dist/insights/senders/index.d.ts +74 -0
  139. package/dist/insights/senders/read.d.ts +37 -0
  140. package/dist/insights/senders/sender-capacity.d.ts +67 -0
  141. package/dist/insights/senders/sender-load.d.ts +52 -0
  142. package/dist/insights/senders/settings-audit.d.ts +48 -0
  143. package/dist/insights/senders/warmup-readiness.d.ts +39 -0
  144. package/dist/insights/stats.d.ts +45 -0
  145. package/dist/insights/tools.d.ts +16 -0
  146. package/dist/insights/types.d.ts +4 -0
  147. package/dist/instantly/adapter-account.d.ts +5 -0
  148. package/dist/instantly/adapter-mail.d.ts +3 -0
  149. package/dist/instantly/adapter.d.ts +7 -0
  150. package/dist/instantly/capabilities.d.ts +85 -0
  151. package/dist/instantly/client.d.ts +24 -0
  152. package/dist/instantly/index.d.ts +27 -0
  153. package/dist/instantly/index.js +2627 -0
  154. package/dist/instantly/map-account.d.ts +38 -0
  155. package/dist/instantly/map-lead.d.ts +18 -0
  156. package/dist/instantly/map-stats.d.ts +25 -0
  157. package/dist/instantly/map.d.ts +22 -0
  158. package/dist/instantly/native-agents-sales.d.ts +161 -0
  159. package/dist/instantly/native-agents.d.ts +156 -0
  160. package/dist/instantly/native-campaigns.d.ts +101 -0
  161. package/dist/instantly/native-leads.d.ts +93 -0
  162. package/dist/instantly/native-params.d.ts +7 -0
  163. package/dist/instantly/native-search.d.ts +82 -0
  164. package/dist/instantly/native-senders.d.ts +182 -0
  165. package/dist/instantly/native-supersearch.d.ts +149 -0
  166. package/dist/instantly/native-workspace.d.ts +170 -0
  167. package/dist/instantly/native.d.ts +1081 -0
  168. package/dist/instantly/pages.d.ts +29 -0
  169. package/dist/instantly/stats.d.ts +5 -0
  170. package/dist/instantly/webhooks.d.ts +3 -0
  171. package/dist/internal/adapter.d.ts +211 -0
  172. package/dist/internal/capabilities.d.ts +104 -0
  173. package/dist/internal/client.d.ts +15 -0
  174. package/dist/internal/concurrency.d.ts +8 -0
  175. package/dist/internal/cursor.d.ts +10 -0
  176. package/dist/internal/engine/budget.d.ts +44 -0
  177. package/dist/internal/engine/engine.d.ts +45 -0
  178. package/dist/internal/engine/rate-store.d.ts +25 -0
  179. package/dist/internal/engine/request.d.ts +34 -0
  180. package/dist/internal/engine/retry.d.ts +21 -0
  181. package/dist/internal/engine/runtime.d.ts +13 -0
  182. package/dist/internal/entities-account.d.ts +205 -0
  183. package/dist/internal/entities.d.ts +493 -0
  184. package/dist/internal/env.d.ts +4 -0
  185. package/dist/internal/errors.d.ts +62 -0
  186. package/dist/internal/fields.d.ts +462 -0
  187. package/dist/internal/hooks.d.ts +55 -0
  188. package/dist/internal/json.d.ts +49 -0
  189. package/dist/internal/lead-fields.d.ts +21 -0
  190. package/dist/internal/lead-status.d.ts +13 -0
  191. package/dist/internal/limits.d.ts +34 -0
  192. package/dist/internal/metrics.d.ts +64 -0
  193. package/dist/internal/native.d.ts +81 -0
  194. package/dist/internal/outbound/api.d.ts +292 -0
  195. package/dist/internal/outbound/collections.d.ts +31 -0
  196. package/dist/internal/outbound/core.d.ts +36 -0
  197. package/dist/internal/outbound/create.d.ts +16 -0
  198. package/dist/internal/outbound/handles.d.ts +7 -0
  199. package/dist/internal/outbound/native.d.ts +4 -0
  200. package/dist/internal/outbound/operation-shared.d.ts +28 -0
  201. package/dist/internal/outbound/operations-account.d.ts +41 -0
  202. package/dist/internal/outbound/operations.d.ts +42 -0
  203. package/dist/internal/outbound/outbound.d.ts +67 -0
  204. package/dist/internal/outbound/plugins.d.ts +40 -0
  205. package/dist/internal/outbound/raw.d.ts +9 -0
  206. package/dist/internal/outbound/specs-account.d.ts +20 -0
  207. package/dist/internal/outbound/specs.d.ts +14 -0
  208. package/dist/internal/outbound/stats.d.ts +7 -0
  209. package/dist/internal/outbound/validate.d.ts +5 -0
  210. package/dist/internal/outbound/walker.d.ts +22 -0
  211. package/dist/internal/page.d.ts +14 -0
  212. package/dist/internal/record.d.ts +36 -0
  213. package/dist/internal/records.d.ts +7 -0
  214. package/dist/internal/redact.d.ts +18 -0
  215. package/dist/internal/ref.d.ts +16 -0
  216. package/dist/internal/sequence.d.ts +14 -0
  217. package/dist/internal/sha256.d.ts +6 -0
  218. package/dist/internal/text.d.ts +11 -0
  219. package/dist/internal/url.d.ts +9 -0
  220. package/dist/loader/index.d.ts +24 -0
  221. package/dist/loader/index.js +16 -0
  222. package/dist/memory/account-reads.d.ts +5 -0
  223. package/dist/memory/account.d.ts +81 -0
  224. package/dist/memory/adapter.d.ts +16 -0
  225. package/dist/memory/data.d.ts +137 -0
  226. package/dist/memory/demo.d.ts +7 -0
  227. package/dist/memory/index.d.ts +5 -0
  228. package/dist/memory/index.js +867 -0
  229. package/dist/memory/stats.d.ts +6 -0
  230. package/dist/memory/store.d.ts +18 -0
  231. package/dist/providers/index.d.ts +22 -0
  232. package/dist/providers/index.js +10 -0
  233. package/dist/reconcile/index.d.ts +2 -0
  234. package/dist/reconcile/index.js +72 -0
  235. package/dist/reconcile/plugin.d.ts +55 -0
  236. package/dist/redact/index.d.ts +2 -0
  237. package/dist/redact/index.js +197 -0
  238. package/dist/redact/plugin.d.ts +22 -0
  239. package/dist/redis/index.d.ts +41 -0
  240. package/dist/redis/index.js +114 -0
  241. package/dist/smartlead/account.d.ts +5 -0
  242. package/dist/smartlead/adapter.d.ts +5 -0
  243. package/dist/smartlead/capabilities.d.ts +87 -0
  244. package/dist/smartlead/client.d.ts +18 -0
  245. package/dist/smartlead/hmac.d.ts +7 -0
  246. package/dist/smartlead/index.d.ts +24 -0
  247. package/dist/smartlead/index.js +2329 -0
  248. package/dist/smartlead/leads.d.ts +9 -0
  249. package/dist/smartlead/lookup.d.ts +8 -0
  250. package/dist/smartlead/mail.d.ts +5 -0
  251. package/dist/smartlead/map-account.d.ts +34 -0
  252. package/dist/smartlead/map-messages.d.ts +31 -0
  253. package/dist/smartlead/map-stats.d.ts +36 -0
  254. package/dist/smartlead/map.d.ts +62 -0
  255. package/dist/smartlead/native-analytics.d.ts +242 -0
  256. package/dist/smartlead/native-campaigns.d.ts +211 -0
  257. package/dist/smartlead/native-inbox.d.ts +141 -0
  258. package/dist/smartlead/native-params.d.ts +12 -0
  259. package/dist/smartlead/native-services.d.ts +204 -0
  260. package/dist/smartlead/native.d.ts +785 -0
  261. package/dist/smartlead/shared.d.ts +29 -0
  262. package/dist/smartlead/stats.d.ts +5 -0
  263. package/dist/smartlead/webhooks.d.ts +3 -0
  264. package/dist/sync/index.d.ts +2 -0
  265. package/dist/sync/index.js +158 -0
  266. package/dist/sync/plugin.d.ts +58 -0
  267. package/dist/tools/account-tools.d.ts +21 -0
  268. package/dist/tools/ai-sdk.d.ts +8 -0
  269. package/dist/tools/ai-sdk.js +28 -0
  270. package/dist/tools/campaign-tools.d.ts +59 -0
  271. package/dist/tools/claude-agent.d.ts +18 -0
  272. package/dist/tools/claude-agent.js +42 -0
  273. package/dist/tools/index.d.ts +28 -0
  274. package/dist/tools/index.js +22 -0
  275. package/dist/tools/people-tools.d.ts +19 -0
  276. package/dist/tools/registry.d.ts +34 -0
  277. package/dist/tools/shared.d.ts +75 -0
  278. package/dist/tracing/index.d.ts +25 -0
  279. package/dist/tracing/index.js +69 -0
  280. package/dist/webhooks/index.d.ts +3 -0
  281. package/dist/webhooks/index.js +227 -0
  282. package/dist/webhooks/parse.d.ts +41 -0
  283. package/dist/webhooks/secret.d.ts +4 -0
  284. package/package.json +181 -4
@@ -0,0 +1,14 @@
1
+ import type { Alert } from "../alerts/index.ts";
2
+ import type { OutboundEvent } from "../internal/entities.ts";
3
+ import type { CardSpec } from "./spec.ts";
4
+ export interface EventCardOptions {
5
+ /**
6
+ * Show the message text. It was written by a prospect, so it is off unless
7
+ * asked for, cut to 500 characters and shown as a quote.
8
+ */
9
+ readonly includeText?: boolean | undefined;
10
+ }
11
+ /** A card for one webhook event, for posting to a channel as it arrives. */
12
+ export declare const eventCard: (event: OutboundEvent, options?: EventCardOptions) => CardSpec;
13
+ /** A card for one alert from the alerts plugin's `notify`. */
14
+ export declare const alertCard: (alert: Alert) => CardSpec;
@@ -0,0 +1,2 @@
1
+ import type { CardBuilder } from "./tool-cards.ts";
2
+ export declare const OPS_CARDS: ReadonlyMap<string, CardBuilder>;
@@ -0,0 +1,22 @@
1
+ import type { Json, JsonObject } from "../internal/json.ts";
2
+ import type { Stat } from "./content.ts";
3
+ export declare const LEFT = "left";
4
+ export declare const RIGHT = "right";
5
+ /** A rate with `low` and `high` beside it, as the ops insights report one. */
6
+ export declare const measured: (value: Json | undefined) => string;
7
+ /** A rate with an `interval` object beside it, as the copy insights report one. */
8
+ export declare const withInterval: (value: JsonObject, rateKey: string, intervalKey: string) => string;
9
+ /** Sent, replies, positive and bounced, as fields. */
10
+ export declare const totalStats: (totals: Json | undefined) => Stat[];
11
+ /** `🔴 finding` for an item with a `severity` and a `finding`. */
12
+ export declare const flagged: (item: JsonObject, prefix?: string) => string;
13
+ /** The counts in an object as fields, biggest first, zeroes left out. */
14
+ export declare const countStats: (counts: JsonObject) => Stat[];
15
+ /**
16
+ * The headline of a check. Says so when nothing was read, since a check that
17
+ * read nothing has not passed.
18
+ */
19
+ export declare const verdict: (checked: number | null, problem: string | null, clean: string) => string;
20
+ export declare const range: (period: Json | undefined) => string;
21
+ /** `4.2%` as a chart value: one decimal, or `null`. */
22
+ export declare const percentPoint: (rate: number | null) => number | null;
@@ -0,0 +1,2 @@
1
+ import type { CardBuilder } from "./tool-cards.ts";
2
+ export declare const PEOPLE_CARDS: ReadonlyMap<string, CardBuilder>;
@@ -0,0 +1,28 @@
1
+ import type { ToolResult } from "../tools/index.ts";
2
+ import type { CardOptions } from "./content.ts";
3
+ import type { CardSpec } from "./spec.ts";
4
+ /** Every tool and insight that has a card of its own. */
5
+ export declare const CARD_NAMES: readonly string[];
6
+ /**
7
+ * The card for one tool or insight result. `name` is the tool's name, such as
8
+ * `campaign_overview` or `hot_leads`. Never throws: a failed result becomes a
9
+ * card that says what failed.
10
+ */
11
+ export declare const cardFor: (name: string, result: ToolResult, options?: CardOptions) => CardSpec;
12
+ export interface DigestSection {
13
+ /** The tool's name, such as `bounce_watch`. */
14
+ readonly name: string;
15
+ readonly result: ToolResult;
16
+ }
17
+ export interface DigestOptions {
18
+ readonly title: string;
19
+ readonly subtitle?: string | undefined;
20
+ /** At most nine are shown, so the message stays inside a chat platform's limits. */
21
+ readonly sections: readonly DigestSection[];
22
+ readonly links?: CardOptions["links"];
23
+ }
24
+ /**
25
+ * One message made of several results, each cut down to its finding, its
26
+ * first numbers and its first lines. For a morning summary in a channel.
27
+ */
28
+ export declare const digest: (options: DigestOptions) => CardSpec;
@@ -0,0 +1,2 @@
1
+ import type { CardBuilder } from "./tool-cards.ts";
2
+ export declare const SENDER_CARDS: ReadonlyMap<string, CardBuilder>;
@@ -0,0 +1,19 @@
1
+ import type { JsonObject } from "../internal/json.ts";
2
+ import type { CardElement } from "./spec.ts";
3
+ type Lookup = (key: string) => CardElement | undefined;
4
+ /**
5
+ * A card's numbers as a bordered grid of tiles. A client that cannot draw a
6
+ * layout shows `plain`, the two-column list.
7
+ */
8
+ export declare const richFields: (element: CardElement, find: Lookup, plain: JsonObject) => JsonObject[];
9
+ /** A data table with typed cells, every row on one page. */
10
+ export declare const richTable: (caption: string, headers: readonly string[], rows: readonly (readonly string[])[]) => JsonObject;
11
+ /**
12
+ * A short table as cards side by side, when the table says which columns are
13
+ * a card's title, subtitle and body. `null` when it does not, or has too
14
+ * many rows to read as cards.
15
+ */
16
+ export declare const richPeople: (element: CardElement, headers: readonly string[], rows: readonly (readonly string[])[], plain: JsonObject) => JsonObject[] | null;
17
+ /** Link buttons, the first one in Slack's primary colour. */
18
+ export declare const richActions: (element: CardElement, find: Lookup) => JsonObject;
19
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { Json, JsonObject } from "../internal/json.ts";
2
+ import type { CardElement } from "./spec.ts";
3
+ export declare const cut: (value: string, max: number) => string;
4
+ export declare const filled: (value: string) => string;
5
+ /** The card format's `**bold**` is `*bold*` in Slack. */
6
+ export declare const bold: (value: string) => string;
7
+ export declare const mrkdwn: (value: string, max: number) => JsonObject;
8
+ export declare const plainText: (value: string, max: number) => JsonObject;
9
+ export declare const prop: (element: CardElement, key: string) => string;
10
+ export declare const cells: (row: Json) => string[];
@@ -0,0 +1,21 @@
1
+ import type { JsonObject } from "../internal/json.ts";
2
+ import type { CardSpec } from "./spec.ts";
3
+ export interface SlackOptions {
4
+ /**
5
+ * `rich` (the default) uses Slack's layout, card and typed table cells.
6
+ * `plain` writes exactly what Chat SDK's Slack adapter writes for the card.
7
+ */
8
+ readonly style?: "plain" | "rich" | undefined;
9
+ }
10
+ /**
11
+ * The card as Slack blocks, for `chat.postMessage({ blocks })` or an incoming
12
+ * webhook. Slack draws one table and two charts per message; a card with more
13
+ * shows the rest as aligned text.
14
+ */
15
+ export declare const toSlackBlocks: (spec: CardSpec, options?: SlackOptions) => JsonObject[];
16
+ export interface SlackMessage {
17
+ readonly text: string;
18
+ readonly blocks: JsonObject[];
19
+ }
20
+ /** A whole Slack message: spread it into `chat.postMessage` or post it to a webhook. */
21
+ export declare const toSlackMessage: (spec: CardSpec, options?: SlackOptions) => SlackMessage;
@@ -0,0 +1,86 @@
1
+ import type { JsonObject } from "../internal/json.ts";
2
+ export type CardComponent = "Actions" | "Card" | "Chart" | "Divider" | "Field" | "Fields" | "LinkButton" | "Table" | "Text";
3
+ export interface CardElement {
4
+ readonly type: CardComponent;
5
+ readonly props: JsonObject;
6
+ readonly children: readonly string[];
7
+ }
8
+ /** A json-render spec whose root is a `Card` from the chat catalog. */
9
+ export interface CardSpec {
10
+ readonly root: string;
11
+ readonly elements: Readonly<Record<string, CardElement>>;
12
+ }
13
+ export type TextStyle = "bold" | "muted" | "plain";
14
+ export type Align = "center" | "left" | "right";
15
+ export interface TableData {
16
+ readonly headers: readonly string[];
17
+ readonly rows: readonly (readonly string[])[];
18
+ readonly align?: readonly Align[] | undefined;
19
+ /** What the table is, for a screen reader and for Slack's table title. */
20
+ readonly caption?: string | undefined;
21
+ /**
22
+ * Which columns make a card when each row is a person or a thing: Slack
23
+ * then draws a short table as cards side by side.
24
+ */
25
+ readonly cards?: TableCards | undefined;
26
+ }
27
+ export interface TableCards {
28
+ readonly title: number;
29
+ readonly subtitle: readonly number[];
30
+ readonly body?: number | undefined;
31
+ }
32
+ export interface PieChart {
33
+ readonly type: "pie";
34
+ readonly segments: readonly {
35
+ readonly label: string;
36
+ readonly value: number;
37
+ }[];
38
+ }
39
+ export interface SeriesChart {
40
+ readonly type: "area" | "bar" | "line";
41
+ readonly categories: readonly string[];
42
+ readonly series: readonly {
43
+ readonly name: string;
44
+ readonly values: readonly number[];
45
+ }[];
46
+ readonly yLabel?: string | undefined;
47
+ }
48
+ export interface ChartData {
49
+ readonly title: string;
50
+ readonly chart: PieChart | SeriesChart;
51
+ }
52
+ export interface CardLink {
53
+ readonly label: string;
54
+ readonly url: string;
55
+ }
56
+ /** One piece of a card, before it is flattened into a spec. */
57
+ export type CardNode = {
58
+ readonly type: "Chart";
59
+ readonly chart: ChartData;
60
+ } | {
61
+ readonly type: "Divider";
62
+ } | {
63
+ readonly type: "Fields";
64
+ readonly fields: readonly (readonly [label: string, value: string])[];
65
+ } | {
66
+ readonly type: "Links";
67
+ readonly links: readonly CardLink[];
68
+ } | {
69
+ readonly type: "Section";
70
+ readonly title: string;
71
+ readonly children: readonly CardNode[];
72
+ } | {
73
+ readonly type: "Table";
74
+ readonly table: TableData;
75
+ } | {
76
+ readonly type: "Text";
77
+ readonly content: string;
78
+ readonly style: TextStyle;
79
+ };
80
+ export interface CardFrame {
81
+ readonly title: string;
82
+ readonly subtitle?: string | null | undefined;
83
+ readonly children: readonly CardNode[];
84
+ }
85
+ /** Flattens a card into a json-render spec. Element keys are stable. */
86
+ export declare const buildSpec: (frame: CardFrame) => CardSpec;
@@ -0,0 +1,4 @@
1
+ import type { Json } from "../internal/json.ts";
2
+ import type { CardContent } from "./content.ts";
3
+ export type CardBuilder = (data: Json) => CardContent;
4
+ export declare const TOOL_CARDS: ReadonlyMap<string, CardBuilder>;
@@ -0,0 +1,75 @@
1
+ // src/internal/engine/rate-store.ts
2
+ var firstInside = (times, cutoff) => {
3
+ let low = 0;
4
+ let high = times.length;
5
+ while (low < high) {
6
+ const middle = Math.floor((low + high) / 2);
7
+ if ((times[middle] ?? 0) > cutoff) {
8
+ high = middle;
9
+ } else {
10
+ low = middle + 1;
11
+ }
12
+ }
13
+ return low;
14
+ };
15
+ var waitFor = (bucket, window, now) => {
16
+ const start = firstInside(bucket.times, now - window.perMs);
17
+ const used = bucket.times.length - start;
18
+ if (used < window.requests) {
19
+ return 0;
20
+ }
21
+ const blocker = bucket.times[bucket.times.length - window.requests] ?? now;
22
+ return Math.max(1, blocker + window.perMs - now);
23
+ };
24
+ var MemoryRateLimitStore = class {
25
+ #buckets = /* @__PURE__ */ new Map();
26
+ #bucket(key) {
27
+ let bucket = this.#buckets.get(key);
28
+ if (bucket === void 0) {
29
+ bucket = { pausedUntil: 0, times: [] };
30
+ this.#buckets.set(key, bucket);
31
+ }
32
+ return bucket;
33
+ }
34
+ reserve(key, windows, now) {
35
+ const bucket = this.#bucket(key);
36
+ if (bucket.pausedUntil > now) {
37
+ return Promise.resolve(bucket.pausedUntil - now);
38
+ }
39
+ const wait = Math.max(
40
+ 0,
41
+ ...windows.map((window) => waitFor(bucket, window, now))
42
+ );
43
+ if (wait > 0) {
44
+ return Promise.resolve(wait);
45
+ }
46
+ const longest = Math.max(0, ...windows.map((window) => window.perMs));
47
+ bucket.times = bucket.times.slice(firstInside(bucket.times, now - longest));
48
+ bucket.times.push(now);
49
+ return Promise.resolve(0);
50
+ }
51
+ pause(key, until) {
52
+ const bucket = this.#bucket(key);
53
+ bucket.pausedUntil = Math.max(bucket.pausedUntil, until);
54
+ return Promise.resolve();
55
+ }
56
+ usage(key, windows, now) {
57
+ const bucket = this.#bucket(key);
58
+ return Promise.resolve(
59
+ windows.map(
60
+ (window) => bucket.times.length - firstInside(bucket.times, now - window.perMs)
61
+ )
62
+ );
63
+ }
64
+ };
65
+ var GLOBAL_STORE = /* @__PURE__ */ Symbol.for("outbound-sdk.rate-limit-store");
66
+ var defaultRateLimitStore = () => {
67
+ const scope = globalThis;
68
+ scope[GLOBAL_STORE] ??= new MemoryRateLimitStore();
69
+ return scope[GLOBAL_STORE];
70
+ };
71
+
72
+ export {
73
+ MemoryRateLimitStore,
74
+ defaultRateLimitStore
75
+ };
@@ -0,0 +1,357 @@
1
+ // src/internal/entities.ts
2
+ import { z } from "zod";
3
+ var SCHEMA_VERSION = 1;
4
+ var baseFields = {
5
+ provider: z.string().min(1),
6
+ raw: z.json(),
7
+ ref: z.string().min(1),
8
+ schemaVersion: z.literal(SCHEMA_VERSION),
9
+ sourceId: z.string().min(1),
10
+ workspaceId: z.string().min(1)
11
+ };
12
+ var base = baseFields;
13
+ var count = z.number().nonnegative().nullable();
14
+ var isoDateTime = z.iso.datetime({ offset: true }).nullable();
15
+ var channelSchema = z.enum(["email", "linkedin"]);
16
+ var campaignStatusSchema = z.enum([
17
+ "active",
18
+ "archived",
19
+ "completed",
20
+ "draft",
21
+ "paused",
22
+ "unknown"
23
+ ]);
24
+ var campaignSchema = z.object({
25
+ ...base,
26
+ channel: channelSchema,
27
+ createdAt: isoDateTime,
28
+ /** The vendor's name for it, or its id when the vendor gave none. Never empty. */
29
+ name: z.string().min(1),
30
+ status: campaignStatusSchema,
31
+ tags: z.array(z.string())
32
+ });
33
+ var sequenceVariantSchema = z.object({
34
+ /** Template text only, never a rendered message. */
35
+ body: z.string().nullable(),
36
+ /** A hash of subject and body, so stats can tell old copy from new. */
37
+ contentHash: z.string(),
38
+ subject: z.string().nullable(),
39
+ variantKey: z.string()
40
+ });
41
+ var sequenceStepSchema = z.object({
42
+ /** What the step does: `email`, or a LinkedIn action such as `connection_request`. */
43
+ action: z.string(),
44
+ /**
45
+ * The outcome of the parent step's condition that leads here, in the
46
+ * vendor's words, for example `accepted`. `null` on a straight path.
47
+ */
48
+ branch: z.string().nullable(),
49
+ delayDays: z.number().nonnegative().nullable(),
50
+ index: z.number().int().nonnegative(),
51
+ /** The step that runs before this one. `null` for the first step. */
52
+ parentIndex: z.number().int().nonnegative().nullable(),
53
+ variants: z.array(sequenceVariantSchema)
54
+ });
55
+ var sequenceSchema = z.object({
56
+ ...base,
57
+ campaignRef: z.string(),
58
+ /** `main` for the campaign's own steps, `subsequence` for a follow-up path. */
59
+ kind: z.enum(["main", "subsequence"]),
60
+ /** A subsequence's name. `null` for the main sequence. */
61
+ name: z.string().nullable(),
62
+ steps: z.array(sequenceStepSchema)
63
+ });
64
+ var senderStatusSchema = z.enum([
65
+ "active",
66
+ "disconnected",
67
+ "error",
68
+ "paused",
69
+ "unknown"
70
+ ]);
71
+ var mailProviderSchema = z.enum([
72
+ "google",
73
+ "microsoft",
74
+ "other",
75
+ "smtp"
76
+ ]);
77
+ var senderSchema = z.object({
78
+ ...base,
79
+ /** Lowercased mailbox address. `null` for a LinkedIn seat. */
80
+ address: z.string().nullable(),
81
+ dailyLimit: count,
82
+ kind: z.enum(["linkedin", "mailbox"]),
83
+ linkedinUrl: z.string().nullable(),
84
+ /** Who hosts the mailbox. `null` for a LinkedIn seat and when the vendor does not say. */
85
+ mailProvider: mailProviderSchema.nullable(),
86
+ name: z.string().nullable(),
87
+ status: senderStatusSchema,
88
+ /** The names of the tags on the sender. */
89
+ tags: z.array(z.string()),
90
+ warmup: z.object({
91
+ enabled: z.boolean().nullable(),
92
+ score: z.number().nullable()
93
+ }).nullable()
94
+ });
95
+ var replyCategorySchema = z.enum([
96
+ "bounce",
97
+ "negative",
98
+ "neutral",
99
+ "ooo",
100
+ "positive",
101
+ "unknown",
102
+ "unsubscribe"
103
+ ]);
104
+ var leadStatusSchema = z.enum([
105
+ "active",
106
+ "bounced",
107
+ "completed",
108
+ "paused",
109
+ "replied",
110
+ "unknown",
111
+ "unsubscribed"
112
+ ]);
113
+ var leadProgressSchema = z.enum([
114
+ "active",
115
+ "completed",
116
+ "paused",
117
+ "unknown"
118
+ ]);
119
+ var leadEngagementSchema = z.object({
120
+ clicks: count,
121
+ lastContactedAt: isoDateTime,
122
+ lastOpenedAt: isoDateTime,
123
+ lastRepliedAt: isoDateTime,
124
+ opens: count,
125
+ replies: count,
126
+ /** The step the lead replied to, counted from 0. `null` when the vendor does not say. */
127
+ repliedStepIndex: z.number().int().nonnegative().nullable(),
128
+ /** The last step sent to the lead, counted from 0. */
129
+ stepIndex: z.number().int().nonnegative().nullable()
130
+ });
131
+ var leadSchema = z.object({
132
+ ...base,
133
+ /** `true` once a message to the lead bounced. `null` when the vendor does not say. */
134
+ bounced: z.boolean().nullable(),
135
+ campaignRef: z.string().nullable(),
136
+ company: z.string().nullable(),
137
+ /** The company's LinkedIn page. */
138
+ companyLinkedinUrl: z.string().nullable(),
139
+ createdAt: isoDateTime,
140
+ /** The lead's custom fields as the vendor stores them. */
141
+ custom: z.record(z.string(), z.string()),
142
+ /** Lowercased and trimmed. */
143
+ email: z.string().nullable(),
144
+ /** `null` when the vendor reports no per-lead counts on this read. */
145
+ engagement: leadEngagementSchema.nullable(),
146
+ firstName: z.string().nullable(),
147
+ /** The vendor's own label for how interested the lead is, for example `Meeting Booked`. */
148
+ interest: z.string().nullable(),
149
+ /**
150
+ * What `interest` means, in the categories a reply uses. `null` when the
151
+ * lead has no label or the vendor does not say what the label means.
152
+ */
153
+ interestCategory: replyCategorySchema.nullable(),
154
+ lastName: z.string().nullable(),
155
+ linkedinUrl: z.string().nullable(),
156
+ /** Where the lead is, in the vendor's own words. */
157
+ location: z.string().nullable(),
158
+ phone: z.string().nullable(),
159
+ /** Where the lead is in its sequence, whatever came back from it. */
160
+ progress: leadProgressSchema,
161
+ /** `true` once the lead replied. `null` when the vendor does not say. */
162
+ replied: z.boolean().nullable(),
163
+ /**
164
+ * The headline: `unsubscribed`, `bounced` or `replied` when one of them is
165
+ * known to be true, in that order, and `progress` otherwise.
166
+ */
167
+ status: leadStatusSchema,
168
+ tags: z.array(z.string()),
169
+ title: z.string().nullable(),
170
+ /** `true` once the lead unsubscribed. `null` when the vendor does not say. */
171
+ unsubscribed: z.boolean().nullable(),
172
+ /** The company's website or domain, as the vendor stores it. */
173
+ website: z.string().nullable()
174
+ });
175
+ var messageFields = {
176
+ ...base,
177
+ /** `null` unless the call asked for bodies and the vendor returned one. */
178
+ bodyHtml: z.string().nullable(),
179
+ /** Plain text with quoted history removed. */
180
+ bodyText: z.string().nullable(),
181
+ campaignRef: z.string().nullable(),
182
+ channel: channelSchema,
183
+ leadRef: z.string().nullable(),
184
+ senderRef: z.string().nullable(),
185
+ sentAt: isoDateTime,
186
+ stepIndex: z.number().int().nonnegative().nullable(),
187
+ subject: z.string().nullable(),
188
+ threadId: z.string().nullable(),
189
+ variantKey: z.string().nullable()
190
+ };
191
+ var messageSchema = z.object({
192
+ ...messageFields,
193
+ direction: z.enum(["in", "out"])
194
+ });
195
+ var replySchema = z.object({
196
+ ...messageFields,
197
+ category: replyCategorySchema,
198
+ /**
199
+ * Who decided the category: `vendor` when the vendor labelled this reply,
200
+ * `lead` when it is the vendor's label for the lead who sent it, `rule` for
201
+ * a fixed rule. `null` when the category is `unknown`. Never a model.
202
+ */
203
+ categorySource: z.enum(["lead", "rule", "vendor"]).nullable(),
204
+ direction: z.literal("in"),
205
+ /** `true` for an auto-reply, `null` when the vendor does not say. */
206
+ isAuto: z.boolean().nullable(),
207
+ /** `true` while the reply, or the thread it is in, is unread in the vendor's inbox. */
208
+ unread: z.boolean().nullable()
209
+ });
210
+ var metricScopeSchema = z.enum([
211
+ "campaign",
212
+ "sender",
213
+ "step",
214
+ "workspace"
215
+ ]);
216
+ var evidenceSchema = z.enum(["derived", "exact", "sampled"]);
217
+ var metricRowSchema = z.object({
218
+ bounced: count,
219
+ /** Unique clicks: leads who clicked at least once. */
220
+ clicked: count,
221
+ /** Every click, repeats included. */
222
+ clickedTotal: count,
223
+ /** LinkedIn only. */
224
+ connectionsAccepted: count,
225
+ /** LinkedIn only. */
226
+ connectionsSent: count,
227
+ /** Unique leads contacted. */
228
+ contacted: count,
229
+ contentHash: z.string().nullable(),
230
+ /** `YYYY-MM-DD` in `timezone`. `null` for a total over the range. */
231
+ date: z.iso.date().nullable(),
232
+ delivered: count,
233
+ evidence: evidenceSchema,
234
+ /** LinkedIn only. */
235
+ inmailsSent: count,
236
+ /** Unique opens. `null` when open tracking is off. */
237
+ opened: count,
238
+ openedTotal: count,
239
+ positive: count,
240
+ provider: z.string().min(1),
241
+ /** Replies from people. Auto-replies are counted in `repliedAuto`. */
242
+ replied: count,
243
+ repliedAuto: count,
244
+ schemaVersion: z.literal(SCHEMA_VERSION),
245
+ scope: metricScopeSchema,
246
+ scopeRef: z.string(),
247
+ /** Messages sent. Email sends, or LinkedIn messages. */
248
+ sent: count,
249
+ stepIndex: z.number().int().nonnegative().nullable(),
250
+ /**
251
+ * The timezone the row's day boundaries are in: a daily row's `date`, or the
252
+ * ends of a dated total. `null` when the vendor does not say, and for a
253
+ * lifetime total. A vendor's "day" is not always UTC.
254
+ */
255
+ timezone: z.string().nullable(),
256
+ unsubscribed: count,
257
+ variantKey: z.string().nullable(),
258
+ workspaceId: z.string().min(1)
259
+ });
260
+ var workspaceSchema = z.object({
261
+ ...base,
262
+ name: z.string().min(1)
263
+ });
264
+ var eventTypeSchema = z.enum([
265
+ "campaign.status_changed",
266
+ "lead.status_changed",
267
+ "lead.unsubscribed",
268
+ "linkedin.connection_accepted",
269
+ "linkedin.connection_sent",
270
+ "linkedin.message_received",
271
+ "linkedin.message_sent",
272
+ "meeting.booked",
273
+ "message.bounced",
274
+ "message.clicked",
275
+ "message.opened",
276
+ "message.sent",
277
+ "reply.categorized",
278
+ "reply.received",
279
+ "sender.status_changed",
280
+ "unknown"
281
+ ]);
282
+ var said = z.string().nullable().optional();
283
+ var told = z.boolean().nullable().optional();
284
+ var eventDataSchema = z.object({
285
+ campaignName: said,
286
+ /** What a categorized reply was categorized as. */
287
+ category: replyCategorySchema.nullable().optional(),
288
+ /** The vendor's own name for that category. */
289
+ categoryName: said,
290
+ /** `true` for an automatic reply. */
291
+ isAuto: told,
292
+ /** `true` for the first event of its kind for the lead. */
293
+ isFirst: told,
294
+ /** `true` for a LinkedIn InMail. */
295
+ isInmail: told,
296
+ /** `true` for a test delivery the vendor sent on request. */
297
+ isTest: told,
298
+ /** Lowercased. */
299
+ leadEmail: said,
300
+ leadName: said,
301
+ senderEmail: said,
302
+ /** The step the message belongs to, counted from 0. */
303
+ stepIndex: z.number().int().nonnegative().nullable().optional(),
304
+ subject: said,
305
+ /** The message or reply text, when the vendor sends it. */
306
+ text: said,
307
+ /** `true` for a reply the vendor could not tie to a campaign. */
308
+ untracked: told,
309
+ variantKey: said,
310
+ /** The event's name in the vendor's own words. */
311
+ vendorEvent: said
312
+ }).catchall(z.json());
313
+ var outboundEventSchema = z.object({
314
+ campaignRef: z.string().nullable(),
315
+ /** What the event says beyond its refs: shared keys, then the vendor's extras. */
316
+ data: eventDataSchema,
317
+ /** Stable across redelivery, so handling an event twice is a no-op. */
318
+ id: z.string().min(1),
319
+ leadRef: z.string().nullable(),
320
+ messageRef: z.string().nullable(),
321
+ /** The vendor's time for the event. */
322
+ occurredAt: isoDateTime,
323
+ provider: z.string().min(1),
324
+ /** The original body, always kept. */
325
+ raw: z.json(),
326
+ schemaVersion: z.literal(SCHEMA_VERSION),
327
+ senderRef: z.string().nullable(),
328
+ type: eventTypeSchema,
329
+ workspaceId: z.string().min(1)
330
+ });
331
+
332
+ export {
333
+ SCHEMA_VERSION,
334
+ baseFields,
335
+ count,
336
+ isoDateTime,
337
+ channelSchema,
338
+ campaignStatusSchema,
339
+ campaignSchema,
340
+ sequenceSchema,
341
+ senderStatusSchema,
342
+ mailProviderSchema,
343
+ senderSchema,
344
+ replyCategorySchema,
345
+ leadStatusSchema,
346
+ leadProgressSchema,
347
+ leadSchema,
348
+ messageSchema,
349
+ replySchema,
350
+ metricScopeSchema,
351
+ evidenceSchema,
352
+ metricRowSchema,
353
+ workspaceSchema,
354
+ eventTypeSchema,
355
+ eventDataSchema,
356
+ outboundEventSchema
357
+ };