outbound-sdk 0.2.1 → 0.5.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 (175) hide show
  1. package/README.md +2 -2
  2. package/dist/alerts/check-evaluate.d.ts +53 -0
  3. package/dist/alerts/check-measure.d.ts +100 -0
  4. package/dist/alerts/check-schema.d.ts +184 -0
  5. package/dist/alerts/check-validate.d.ts +18 -0
  6. package/dist/alerts/index.d.ts +7 -0
  7. package/dist/alerts/index.js +684 -20
  8. package/dist/alerts/plugin.d.ts +20 -3
  9. package/dist/audit/index.js +2 -2
  10. package/dist/benchmarks/index.js +5 -5
  11. package/dist/budget/index.d.ts +5 -2
  12. package/dist/budget/index.js +12 -10
  13. package/dist/cards/content.d.ts +6 -1
  14. package/dist/cards/format.d.ts +17 -2
  15. package/dist/cards/index.d.ts +1 -1
  16. package/dist/cards/index.js +298 -132
  17. package/dist/cards/parts.d.ts +9 -2
  18. package/dist/cards/render.d.ts +20 -3
  19. package/dist/chunks/{chunk-U2D34ARZ.js → chunk-2D42TQFU.js} +3 -3
  20. package/dist/chunks/{chunk-6CVZOUHB.js → chunk-3S32R2MH.js} +53 -63
  21. package/dist/chunks/chunk-4PA526S7.js +17 -0
  22. package/dist/chunks/{chunk-RCZ7ZZFU.js → chunk-5J7GGV62.js} +12 -5
  23. package/dist/chunks/chunk-6TKFISG4.js +676 -0
  24. package/dist/chunks/{chunk-AFU5E5QB.js → chunk-BK5SLY32.js} +104 -84
  25. package/dist/chunks/{chunk-VQSCHOBV.js → chunk-BLCJHP5H.js} +11 -4
  26. package/dist/chunks/{chunk-SBIZDCRY.js → chunk-BN6WCAWX.js} +7 -7
  27. package/dist/chunks/{chunk-4PSO6JEK.js → chunk-BOWXGMN3.js} +6 -21
  28. package/dist/chunks/{chunk-PURHK3JU.js → chunk-EHSJGQ5K.js} +8 -8
  29. package/dist/chunks/{chunk-IPUYZD4O.js → chunk-GFDNRWR3.js} +1 -1
  30. package/dist/chunks/chunk-HPNGSG5E.js +51 -0
  31. package/dist/chunks/chunk-HWHI4LFY.js +102 -0
  32. package/dist/chunks/{chunk-E7JHLNLG.js → chunk-J7DDZ4C2.js} +15 -2
  33. package/dist/chunks/{chunk-DJ2IUQEU.js → chunk-JWGSB7PT.js} +6 -6
  34. package/dist/chunks/{chunk-R3Y56YVF.js → chunk-OLPMBRXM.js} +4 -3
  35. package/dist/chunks/{chunk-YOTW5ESM.js → chunk-PQSTQKRD.js} +2 -2
  36. package/dist/chunks/chunk-PTZO4QXR.js +15 -0
  37. package/dist/chunks/{chunk-LVYG7XZJ.js → chunk-QAKJ76HB.js} +1 -1
  38. package/dist/chunks/chunk-QGRZDTX4.js +26 -0
  39. package/dist/chunks/chunk-WGW3ROLY.js +18 -0
  40. package/dist/chunks/{chunk-XC6CZP73.js → chunk-WH6V3YNN.js} +32 -1
  41. package/dist/chunks/{chunk-P3IJBJUI.js → chunk-X4RDBD4J.js} +296 -62
  42. package/dist/chunks/chunk-XL6LJVHJ.js +71 -0
  43. package/dist/chunks/{chunk-XNFESPZH.js → chunk-YYCT3NGV.js} +200 -39
  44. package/dist/chunks/{chunk-UAT3JSJZ.js → chunk-ZOAG2C6V.js} +2 -2
  45. package/dist/cli/bin.js +19 -30
  46. package/dist/cli/commands.d.ts +11 -0
  47. package/dist/cli/index.d.ts +3 -0
  48. package/dist/cli/index.js +18 -13
  49. package/dist/cli/mcp.d.ts +5 -0
  50. package/dist/cli/update.d.ts +15 -0
  51. package/dist/clients/index.d.ts +1 -1
  52. package/dist/clients/index.js +35 -10
  53. package/dist/clients/plugin.d.ts +9 -2
  54. package/dist/combine/index.js +7 -6
  55. package/dist/emailbison/account.d.ts +7 -0
  56. package/dist/emailbison/adapter.d.ts +5 -0
  57. package/dist/emailbison/capabilities.d.ts +78 -0
  58. package/dist/emailbison/client.d.ts +29 -0
  59. package/dist/emailbison/index.d.ts +30 -0
  60. package/dist/emailbison/index.js +1017 -0
  61. package/dist/emailbison/mail.d.ts +5 -0
  62. package/dist/emailbison/map-mail.d.ts +13 -0
  63. package/dist/emailbison/map-sequence.d.ts +12 -0
  64. package/dist/emailbison/map-stats.d.ts +47 -0
  65. package/dist/emailbison/map.d.ts +24 -0
  66. package/dist/emailbison/native-params.d.ts +5 -0
  67. package/dist/emailbison/native-workspace.d.ts +167 -0
  68. package/dist/emailbison/native.d.ts +327 -0
  69. package/dist/emailbison/stats.d.ts +4 -0
  70. package/dist/emailbison/webhooks.d.ts +2 -0
  71. package/dist/exporter/index.d.ts +5 -2
  72. package/dist/exporter/index.js +2 -2
  73. package/dist/failover/index.js +3 -3
  74. package/dist/fixtures/index.js +10 -9
  75. package/dist/heyreach/capabilities.d.ts +3 -0
  76. package/dist/heyreach/client.d.ts +2 -0
  77. package/dist/heyreach/index.js +83 -51
  78. package/dist/heyreach/map.d.ts +5 -2
  79. package/dist/identity/index.js +33 -17
  80. package/dist/identity/plugin.d.ts +2 -0
  81. package/dist/index.d.ts +2 -2
  82. package/dist/index.js +29 -25
  83. package/dist/insights/campaign.d.ts +3 -0
  84. package/dist/insights/capped.d.ts +29 -0
  85. package/dist/insights/copy/copy-audit.d.ts +2 -0
  86. package/dist/insights/copy/copy-reuse.d.ts +27 -3
  87. package/dist/insights/copy/index.d.ts +8 -8
  88. package/dist/insights/copy/reply-timing.d.ts +8 -0
  89. package/dist/insights/copy/reuse-base.d.ts +32 -0
  90. package/dist/insights/copy/shared.d.ts +39 -15
  91. package/dist/insights/copy/step-funnel.d.ts +16 -5
  92. package/dist/insights/copy/variant-test.d.ts +19 -8
  93. package/dist/insights/cost.d.ts +91 -0
  94. package/dist/insights/define.d.ts +78 -3
  95. package/dist/insights/fields.d.ts +16 -0
  96. package/dist/insights/index.d.ts +6 -4
  97. package/dist/insights/index.js +1816 -748
  98. package/dist/insights/inputs.generated.d.ts +951 -0
  99. package/dist/insights/ops/campaign-diagnosis.d.ts +3 -1
  100. package/dist/insights/ops/campaign-ranking.d.ts +15 -7
  101. package/dist/insights/ops/channel-mix.d.ts +2 -1
  102. package/dist/insights/ops/client-report.d.ts +18 -5
  103. package/dist/insights/ops/index.d.ts +8 -4
  104. package/dist/insights/ops/period-comparison.d.ts +14 -3
  105. package/dist/insights/ops/pipeline-forecast.d.ts +14 -4
  106. package/dist/insights/ops/shared.d.ts +39 -24
  107. package/dist/insights/ops/tag-rollup.d.ts +2 -1
  108. package/dist/insights/people/account-summary.d.ts +13 -0
  109. package/dist/insights/people/dropped-replies.d.ts +8 -0
  110. package/dist/insights/people/find.d.ts +7 -1
  111. package/dist/insights/people/hot-leads.d.ts +16 -1
  112. package/dist/insights/people/person-summary.d.ts +6 -0
  113. package/dist/insights/people/read.d.ts +26 -10
  114. package/dist/insights/people/suppression-check.d.ts +11 -2
  115. package/dist/insights/plugin.d.ts +26 -5
  116. package/dist/insights/ref.d.ts +6 -0
  117. package/dist/insights/registry.d.ts +30 -18
  118. package/dist/insights/run-cap.d.ts +35 -0
  119. package/dist/insights/senders/bounce-watch.d.ts +25 -8
  120. package/dist/insights/senders/capacity-sends.d.ts +22 -0
  121. package/dist/insights/senders/domain-health.d.ts +10 -4
  122. package/dist/insights/senders/index.d.ts +14 -6
  123. package/dist/insights/senders/read.d.ts +15 -14
  124. package/dist/insights/senders/sender-capacity.d.ts +5 -13
  125. package/dist/insights/senders/sender-load.d.ts +2 -0
  126. package/dist/insights/stats.d.ts +8 -0
  127. package/dist/insights/tools.d.ts +13 -2
  128. package/dist/instantly/capabilities.d.ts +13 -0
  129. package/dist/instantly/client.d.ts +2 -0
  130. package/dist/instantly/index.js +77 -49
  131. package/dist/instantly/map.d.ts +6 -2
  132. package/dist/internal/adapter.d.ts +12 -0
  133. package/dist/internal/engine/request.d.ts +5 -0
  134. package/dist/internal/entities.d.ts +3 -20
  135. package/dist/internal/errors.d.ts +44 -0
  136. package/dist/internal/fields.d.ts +1 -1
  137. package/dist/internal/json.d.ts +9 -2
  138. package/dist/internal/lists.d.ts +24 -0
  139. package/dist/internal/numbers.d.ts +8 -0
  140. package/dist/internal/outbound/collections.d.ts +4 -0
  141. package/dist/internal/outbound/create.d.ts +24 -3
  142. package/dist/internal/outbound/outbound.d.ts +18 -2
  143. package/dist/internal/outbound/validate.d.ts +4 -0
  144. package/dist/internal/outbound/walker.d.ts +3 -2
  145. package/dist/internal/plural.d.ts +12 -0
  146. package/dist/internal/renamed.d.ts +28 -0
  147. package/dist/internal/request-cap.d.ts +35 -0
  148. package/dist/internal/vocabulary.d.ts +20 -0
  149. package/dist/loader/index.js +5 -5
  150. package/dist/memory/adapter.d.ts +7 -0
  151. package/dist/memory/demo-stats.d.ts +3 -0
  152. package/dist/memory/demo.d.ts +14 -3
  153. package/dist/memory/index.d.ts +1 -0
  154. package/dist/memory/index.js +209 -104
  155. package/dist/providers/index.d.ts +92 -0
  156. package/dist/providers/index.js +3 -1
  157. package/dist/reconcile/index.js +5 -4
  158. package/dist/redact/index.js +13 -7
  159. package/dist/redact/plugin.d.ts +7 -0
  160. package/dist/smartlead/capabilities.d.ts +5 -0
  161. package/dist/smartlead/index.js +119 -66
  162. package/dist/smartlead/shared.d.ts +13 -0
  163. package/dist/sync/index.js +2 -2
  164. package/dist/tools/ai-sdk.js +10 -6
  165. package/dist/tools/campaign-tools.d.ts +1 -1
  166. package/dist/tools/claude-agent.js +10 -6
  167. package/dist/tools/index.d.ts +2 -2
  168. package/dist/tools/index.js +16 -9
  169. package/dist/tools/input-problem.d.ts +8 -0
  170. package/dist/tools/registry.d.ts +26 -2
  171. package/dist/tools/shared.d.ts +27 -1
  172. package/dist/tracing/index.js +2 -2
  173. package/dist/webhooks/index.js +22 -12
  174. package/package.json +8 -2
  175. package/dist/chunks/chunk-FKH5N47I.js +0 -40
@@ -4,8 +4,13 @@ export declare const LEFT = "left";
4
4
  export declare const RIGHT = "right";
5
5
  /** A rate with `low` and `high` beside it, as the ops insights report one. */
6
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;
7
+ /**
8
+ * A rate with `low` and `high` beside it, or the `interval` object a result
9
+ * stored before those carries.
10
+ */
11
+ export declare const withInterval: (value: JsonObject, rateKey?: string, intervalKey?: string) => string;
12
+ /** A row's `rates.replyRate`, or its older `replyRate` and `replyRateInterval`. */
13
+ export declare const replyRate: (value: JsonObject) => string;
9
14
  /** Sent, replies, positive and bounced, as fields. */
10
15
  export declare const totalStats: (totals: Json | undefined) => Stat[];
11
16
  /** `🔴 finding` for an item with a `severity` and a `finding`. */
@@ -20,3 +25,5 @@ export declare const verdict: (checked: number | null, problem: string | null, c
20
25
  export declare const range: (period: Json | undefined) => string;
21
26
  /** `4.2%` as a chart value: one decimal, or `null`. */
22
27
  export declare const percentPoint: (rate: number | null) => number | null;
28
+ /** Says an answer stopped at `max_campaigns` with more campaigns left, or nothing. */
29
+ export declare const campaignsCapped: (data: Json | undefined) => string[];
@@ -3,12 +3,29 @@ import type { CardOptions } from "./content.ts";
3
3
  import type { CardSpec } from "./spec.ts";
4
4
  /** Every tool and insight that has a card of its own. */
5
5
  export declare const CARD_NAMES: readonly string[];
6
+ /** An insight method's result, as `outbound.insights.hotLeads()` returns it. */
7
+ export interface InsightResultLike {
8
+ readonly insight?: string | undefined;
9
+ readonly data: unknown;
10
+ readonly meta: {
11
+ readonly evidence: string;
12
+ readonly requests: number;
13
+ readonly provider: string;
14
+ readonly complete?: boolean | undefined;
15
+ readonly notes?: readonly string[] | undefined;
16
+ };
17
+ }
18
+ /** What `cardFor` draws: a tool's result, or an insight method's result. */
19
+ export type CardInput = InsightResultLike | ToolResult;
6
20
  /**
7
21
  * 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.
22
+ * `campaign_overview` or `hot_leads`. `result` is what the tool's `call`
23
+ * returned, or what the insight method returned, such as
24
+ * `await outbound.insights.hotLeads({})`. Never throws: a failed result
25
+ * becomes a card that says what failed, and anything else a card that says
26
+ * there is nothing to show.
10
27
  */
11
- export declare const cardFor: (name: string, result: ToolResult, options?: CardOptions) => CardSpec;
28
+ export declare const cardFor: (name: string, result: CardInput, options?: CardOptions) => CardSpec;
12
29
  export interface DigestSection {
13
30
  /** The tool's name, such as `bounce_watch`. */
14
31
  readonly name: string;
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  SCHEMA_VERSION
3
- } from "./chunk-4PSO6JEK.js";
3
+ } from "./chunk-QGRZDTX4.js";
4
4
  import {
5
5
  makeRef
6
- } from "./chunk-LVYG7XZJ.js";
6
+ } from "./chunk-QAKJ76HB.js";
7
7
  import {
8
8
  compactObject
9
- } from "./chunk-VQSCHOBV.js";
9
+ } from "./chunk-BLCJHP5H.js";
10
10
 
11
11
  // src/internal/record.ts
12
12
  var recordBase = (identity, sourceId, raw) => ({
@@ -1,72 +1,47 @@
1
1
  import {
2
2
  buildUrl
3
3
  } from "./chunk-NAWZ73QS.js";
4
+ import {
5
+ stableId
6
+ } from "./chunk-FHKSLCVW.js";
7
+ import {
8
+ OutboundError
9
+ } from "./chunk-J7DDZ4C2.js";
10
+ import {
11
+ count,
12
+ isJsonArray,
13
+ isJsonObject
14
+ } from "./chunk-BLCJHP5H.js";
4
15
 
5
- // src/internal/lead-fields.ts
6
- var MAPPABLE = [
7
- "company",
8
- "companyLinkedinUrl",
9
- "linkedinUrl",
10
- "location",
11
- "phone",
12
- "title",
13
- "website"
14
- ];
15
- var fillFromCustom = (lead, map) => {
16
- const filled = {};
17
- for (const field of MAPPABLE) {
18
- const name = map[field];
19
- const value = name === void 0 ? void 0 : lead.custom[name]?.trim();
20
- if (lead[field] === null && value !== void 0 && value !== "") {
21
- filled[field] = value;
22
- }
23
- }
24
- return { ...lead, ...filled };
16
+ // src/internal/sequence.ts
17
+ var variantKey = (index) => String.fromCodePoint(65 + index);
18
+ var toVariant = (subject, body, key) => ({
19
+ body,
20
+ contentHash: stableId(subject, body),
21
+ subject,
22
+ variantKey: key
23
+ });
24
+ var fromOne = (value) => {
25
+ const number = count(value);
26
+ return number === null || number < 1 ? null : number - 1;
25
27
  };
26
- var withLeadFields = (readers, map) => {
27
- if (map === void 0 || Object.keys(map).length === 0) {
28
- return readers;
28
+
29
+ // src/internal/lists.ts
30
+ var requireList = (value, provider, message) => {
31
+ if (!isJsonArray(value)) {
32
+ throw new OutboundError("Provider", message, { provider, status: 200 });
29
33
  }
30
- const { getLead, listLeads } = readers;
31
- const wrapped = {
32
- ...getLead && {
33
- getLead: async (id, ctx) => fillFromCustom(await getLead(id, ctx), map)
34
- },
35
- ...listLeads && {
36
- listLeads: async (query, ctx) => {
37
- const page = await listLeads(query, ctx);
38
- return {
39
- items: page.items.map((lead) => fillFromCustom(lead, map)),
40
- next: page.next
41
- };
42
- }
43
- }
44
- };
45
- return { ...readers, ...wrapped };
34
+ return value;
46
35
  };
47
- var withMappedFields = (declared, map) => {
48
- const lead = declared.lead === false ? void 0 : declared.lead;
49
- if (map === void 0 || lead === void 0) {
50
- return declared;
36
+ var noListMessage = (place) => `${place.vendor} returned no list for ${place.path}: expected ${place.key === void 0 ? "a JSON array" : `a JSON object with an array in \`${place.key}\``}`;
37
+ var listIn = (body, place) => {
38
+ let rows = body;
39
+ if (place.key !== void 0) {
40
+ rows = isJsonObject(body) ? body[place.key] : void 0;
51
41
  }
52
- const derived = Object.fromEntries(
53
- MAPPABLE.flatMap(
54
- (field) => map[field] !== void 0 && lead[field] === false ? [[field, "derived"]] : []
55
- )
56
- );
57
- return { ...declared, lead: { ...lead, ...derived } };
42
+ return requireList(rows, place.provider, noListMessage(place));
58
43
  };
59
44
 
60
- // src/internal/page.ts
61
- var mapPage = (page, toItem) => ({
62
- items: page.items.map((raw) => toItem(raw)),
63
- next: page.next
64
- });
65
- var flatMapPage = (page, toItems) => ({
66
- items: page.items.flatMap((raw) => toItems(raw)),
67
- next: page.next
68
- });
69
-
70
45
  // src/internal/client.ts
71
46
  var createVendorClient = (baseUrl, authorize) => ({
72
47
  get: async (ctx, path, options = {}) => {
@@ -92,6 +67,20 @@ var createVendorClient = (baseUrl, authorize) => ({
92
67
  }
93
68
  });
94
69
 
70
+ // src/internal/lead-status.ts
71
+ var leadStanding = (progress, outcome) => {
72
+ const headline = () => {
73
+ if (outcome.unsubscribed === true) {
74
+ return "unsubscribed";
75
+ }
76
+ if (outcome.bounced === true) {
77
+ return "bounced";
78
+ }
79
+ return outcome.replied === true ? "replied" : progress;
80
+ };
81
+ return { ...outcome, progress, status: headline() };
82
+ };
83
+
95
84
  // src/internal/text.ts
96
85
  var ENTITIES = /* @__PURE__ */ new Map([
97
86
  ["amp", "&"],
@@ -143,10 +132,11 @@ var normalizeBody = (body, includeBody) => {
143
132
  };
144
133
 
145
134
  export {
146
- withLeadFields,
147
- withMappedFields,
148
- mapPage,
149
- flatMapPage,
135
+ variantKey,
136
+ toVariant,
137
+ fromOne,
138
+ listIn,
139
+ leadStanding,
150
140
  normalizeBody,
151
141
  createVendorClient
152
142
  };
@@ -0,0 +1,17 @@
1
+ import {
2
+ noun
3
+ } from "./chunk-PTZO4QXR.js";
4
+
5
+ // src/internal/numbers.ts
6
+ var NUMBER = new Intl.NumberFormat("en-US", { maximumFractionDigits: 1 });
7
+ var count = (amount) => NUMBER.format(amount);
8
+ var points = (rate) => NUMBER.format(Math.round(rate * 1e3) / 10);
9
+ var percentOf = (rate) => `${points(rate)}%`;
10
+ var plural = (amount, one, many = `${one}s`) => `${count(amount)} ${noun(amount, one, many)}`;
11
+
12
+ export {
13
+ count,
14
+ points,
15
+ percentOf,
16
+ plural
17
+ };
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  readEnv
3
- } from "./chunk-IPUYZD4O.js";
3
+ } from "./chunk-GFDNRWR3.js";
4
+ import {
5
+ OutboundError
6
+ } from "./chunk-J7DDZ4C2.js";
4
7
  import {
5
8
  PROVIDER_ENV,
6
9
  providers
7
- } from "./chunk-XC6CZP73.js";
8
- import {
9
- OutboundError
10
- } from "./chunk-E7JHLNLG.js";
10
+ } from "./chunk-WH6V3YNN.js";
11
11
 
12
12
  // src/loader/index.ts
13
13
  var LOADERS = /* @__PURE__ */ new Map([
@@ -32,6 +32,13 @@ var LOADERS = /* @__PURE__ */ new Map([
32
32
  return heyreach();
33
33
  }
34
34
  ],
35
+ [
36
+ "emailbison",
37
+ async () => {
38
+ const { emailbison } = await import("../emailbison/index.js");
39
+ return emailbison();
40
+ }
41
+ ],
35
42
  [
36
43
  "memory",
37
44
  async () => {