outbound-sdk 0.11.0 → 0.12.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 (81) hide show
  1. package/dist/alerts/index.js +1 -1
  2. package/dist/cards/index.js +201 -92
  3. package/dist/cards/sender-tool-cards.d.ts +6 -0
  4. package/dist/chunks/{chunk-MEEJIIIA.js → chunk-2ADIGC2N.js} +77 -8
  5. package/dist/chunks/{chunk-V7JKTNRO.js → chunk-3DDYXUDG.js} +1 -1
  6. package/dist/chunks/{chunk-UAHYPASH.js → chunk-3LRIWQEJ.js} +2 -1
  7. package/dist/chunks/{chunk-UZLFZZ2U.js → chunk-AWNH4I5D.js} +11 -2
  8. package/dist/chunks/{chunk-A7DLJUA6.js → chunk-B72F56HF.js} +3 -1
  9. package/dist/chunks/{chunk-KMQHXFIZ.js → chunk-CTRYCW4G.js} +648 -182
  10. package/dist/chunks/{chunk-OVTYA3IB.js → chunk-HDTOGEVN.js} +532 -182
  11. package/dist/chunks/{chunk-POBAY3TI.js → chunk-HXCZMMSD.js} +21 -0
  12. package/dist/chunks/chunk-I7GBBHD2.js +80 -0
  13. package/dist/chunks/{chunk-FTK4JS65.js → chunk-KNWJIJVO.js} +73 -4
  14. package/dist/chunks/{chunk-UOJG4VYF.js → chunk-LD5OAELW.js} +1 -1
  15. package/dist/chunks/{chunk-YFJ3OQZS.js → chunk-OPLXELPS.js} +5 -1
  16. package/dist/chunks/{chunk-CVLGFVDC.js → chunk-UIINRLHQ.js} +11 -7
  17. package/dist/chunks/{chunk-OMCDMELK.js → chunk-UWNQEQIX.js} +1 -1
  18. package/dist/chunks/{chunk-MPE6VLLY.js → chunk-UZ4YWUZ7.js} +1 -1
  19. package/dist/chunks/{tools-AVJ3XJ5A.js → tools-EKLZKXZU.js} +5 -4
  20. package/dist/cli/bin.js +11 -10
  21. package/dist/cli/index.js +10 -9
  22. package/dist/combine/index.js +36 -2
  23. package/dist/emailbison/index.js +4 -4
  24. package/dist/fixtures/index.js +4 -4
  25. package/dist/heyreach/index.js +14 -6
  26. package/dist/identity/index.js +46 -11
  27. package/dist/identity/keys.d.ts +1 -1
  28. package/dist/index.js +8 -6
  29. package/dist/insights/define.d.ts +1 -1
  30. package/dist/insights/index.js +5 -4
  31. package/dist/insights/inputs.generated.d.ts +68 -5
  32. package/dist/insights/ops/channel-mix.d.ts +8 -1
  33. package/dist/insights/ops/period-comparison.d.ts +13 -2
  34. package/dist/insights/ops/shared.d.ts +11 -1
  35. package/dist/insights/ops/tag-rollup.d.ts +8 -1
  36. package/dist/insights/people/dropped-replies-check.d.ts +14 -2
  37. package/dist/insights/people/find.d.ts +5 -4
  38. package/dist/insights/people/hot-leads.d.ts +10 -1
  39. package/dist/insights/people/index.d.ts +26 -2
  40. package/dist/insights/people/person-summary.d.ts +15 -3
  41. package/dist/insights/people/thread-context.d.ts +79 -0
  42. package/dist/insights/people/thread-contexts.d.ts +59 -0
  43. package/dist/insights/people/thread-read.d.ts +22 -0
  44. package/dist/insights/registry.d.ts +25 -3
  45. package/dist/insights/senders/domain-health.d.ts +1 -1
  46. package/dist/insights/senders/index.d.ts +1 -1
  47. package/dist/insights/senders/read.d.ts +9 -0
  48. package/dist/instantly/adapter.d.ts +3 -2
  49. package/dist/instantly/capabilities.d.ts +5 -0
  50. package/dist/instantly/index.js +148 -45
  51. package/dist/instantly/senders.d.ts +3 -0
  52. package/dist/internal/adapter.d.ts +7 -0
  53. package/dist/internal/capabilities.d.ts +8 -0
  54. package/dist/internal/entities.d.ts +20 -0
  55. package/dist/internal/fields.d.ts +8 -0
  56. package/dist/internal/outbound/api.d.ts +12 -0
  57. package/dist/internal/outbound/operations-account.d.ts +4 -1
  58. package/dist/internal/outbound/outbound.d.ts +2 -1
  59. package/dist/internal/outbound/specs-account.d.ts +2 -1
  60. package/dist/internal/person.d.ts +32 -0
  61. package/dist/internal/records.d.ts +2 -2
  62. package/dist/internal/url.d.ts +2 -1
  63. package/dist/loader/index.js +1 -1
  64. package/dist/memory/data.d.ts +2 -1
  65. package/dist/memory/index.js +6 -4
  66. package/dist/redact/index.js +3 -3
  67. package/dist/smartlead/index.js +18 -7
  68. package/dist/tools/account-tools.d.ts +0 -5
  69. package/dist/tools/ai-sdk.js +5 -3
  70. package/dist/tools/campaign-tools.d.ts +0 -4
  71. package/dist/tools/claude-agent.js +5 -3
  72. package/dist/tools/deliverability-check.d.ts +9 -0
  73. package/dist/tools/index.js +6 -4
  74. package/dist/tools/people-tools.d.ts +4 -1
  75. package/dist/tools/person-input.d.ts +17 -0
  76. package/dist/tools/sender-health.d.ts +8 -0
  77. package/dist/tools/sender-impact.d.ts +38 -0
  78. package/dist/tools/shared.d.ts +5 -0
  79. package/dist/webhooks/index.js +6 -6
  80. package/package.json +1 -1
  81. /package/dist/chunks/{chunk-5XLR6XVV.js → chunk-TOZKA7JR.js} +0 -0
@@ -1,9 +1,16 @@
1
+ import {
2
+ PERSON_FORMS,
3
+ assertRefReadable,
4
+ leadRefParts,
5
+ personKey
6
+ } from "../chunks/chunk-I7GBBHD2.js";
1
7
  import {
2
8
  mapConcurrent
3
9
  } from "../chunks/chunk-HZCTYL22.js";
4
10
  import {
5
11
  profileSlug
6
- } from "../chunks/chunk-YFJ3OQZS.js";
12
+ } from "../chunks/chunk-OPLXELPS.js";
13
+ import "../chunks/chunk-HXB2IOJJ.js";
7
14
  import {
8
15
  OutboundError
9
16
  } from "../chunks/chunk-XYHM4KHC.js";
@@ -22,12 +29,11 @@ var keysOf = (record) => [emailKey(record.email), linkedinKey(record.linkedinUrl
22
29
  (key) => key !== null
23
30
  );
24
31
  var toKey = (identifier) => {
25
- const value = identifier.trim();
26
- const lower = value.toLowerCase();
27
- if (lower.startsWith("email:") || lower.startsWith("linkedin:")) {
32
+ const lower = identifier.trim().toLowerCase();
33
+ if (/^(?:email|linkedin):[^:]+$/u.test(lower)) {
28
34
  return lower;
29
35
  }
30
- return linkedinKey(value) ?? emailKey(value);
36
+ return personKey(identifier);
31
37
  };
32
38
 
33
39
  // src/identity/plugin.ts
@@ -120,24 +126,53 @@ var assertIdentifiersReadable = (outbound) => {
120
126
  }
121
127
  };
122
128
  var bySentAt = (left, right) => (left.sentAt ?? "").localeCompare(right.sentAt ?? "");
123
- var lookup = async (outbound, identifier, options) => {
124
- const key = toKey(identifier);
125
- if (key === null) {
129
+ var start = async (outbound, identifier, tally) => {
130
+ const ref = leadRefParts(identifier);
131
+ if (ref === null) {
132
+ const key2 = toKey(identifier);
133
+ if (key2 === null) {
134
+ throw new OutboundError(
135
+ "Invalid",
136
+ `person() needs a person key, or ${PERSON_FORMS}`,
137
+ { provider: outbound.provider }
138
+ );
139
+ }
140
+ return { key: key2, lead: null };
141
+ }
142
+ assertRefReadable(outbound, { ...ref, text: identifier.trim() });
143
+ const local = personKey(ref.sourceId);
144
+ if (local !== null) {
145
+ return { key: local, lead: null };
146
+ }
147
+ const lead = await outbound.leads.get(identifier.trim());
148
+ tally.requests += lead.meta.requests;
149
+ const [key] = keysOf(lead);
150
+ if (key === void 0) {
126
151
  throw new OutboundError(
127
- "Invalid",
128
- "person() needs a person key, an email address or a LinkedIn profile URL"
152
+ "NotFound",
153
+ `The lead ${identifier.trim()} has no email address or LinkedIn profile to link its records by`,
154
+ { provider: outbound.provider }
129
155
  );
130
156
  }
157
+ return { key, lead };
158
+ };
159
+ var lookup = async (outbound, identifier, options) => {
131
160
  assertIdentifiersReadable(outbound);
161
+ const tally = { requests: 0 };
162
+ const { key, lead } = await start(outbound, identifier, tally);
132
163
  const keys = /* @__PURE__ */ new Set([key]);
133
164
  const found = /* @__PURE__ */ new Map();
134
- const tally = { requests: 0 };
135
165
  if (outbound.capabilities["leads.lookup"] && options.campaignIds === void 0) {
136
166
  await find(outbound, keys, found, tally);
137
167
  } else if (await collect(outbound, options, keys, found, tally)) {
138
168
  await collect(outbound, options, keys, found, tally);
139
169
  }
140
170
  const records = [...found.values()];
171
+ if (lead !== null && !records.some(
172
+ (record) => record.ref === lead.ref && record.campaignRef === lead.campaignRef
173
+ )) {
174
+ records.unshift(lead);
175
+ }
141
176
  const wantsTimeline = (options.timeline ?? true) && outbound.capabilities["leads.timeline"];
142
177
  const timelines = wantsTimeline ? await Promise.all(
143
178
  records.map(
@@ -5,5 +5,5 @@ export declare const keysOf: (record: {
5
5
  readonly email: string | null;
6
6
  readonly linkedinUrl: string | null;
7
7
  }) => string[];
8
- /** Accepts a person key, an email address or a LinkedIn URL. */
8
+ /** Accepts a person key, an email address or a LinkedIn URL. A lead ref is not one. */
9
9
  export declare const toKey: (identifier: string) => string | null;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Outbound,
4
4
  createOutbound,
5
5
  fullJitterBackoff
6
- } from "./chunks/chunk-MEEJIIIA.js";
6
+ } from "./chunks/chunk-2ADIGC2N.js";
7
7
  import {
8
8
  MemoryRateLimitStore
9
9
  } from "./chunks/chunk-4O2HRTTI.js";
@@ -22,7 +22,7 @@ import {
22
22
  senderHealthSchema,
23
23
  tagSchema,
24
24
  webhookSubscriptionSchema
25
- } from "./chunks/chunk-A7DLJUA6.js";
25
+ } from "./chunks/chunk-B72F56HF.js";
26
26
  import "./chunks/chunk-PTZO4QXR.js";
27
27
  import {
28
28
  defineNative
@@ -37,6 +37,7 @@ import {
37
37
  leadSchema,
38
38
  leadStatusSchema,
39
39
  mailProviderSchema,
40
+ meetingStatusSchema,
40
41
  messageSchema,
41
42
  metricRowSchema,
42
43
  metricScopeSchema,
@@ -47,7 +48,7 @@ import {
47
48
  senderStatusSchema,
48
49
  sequenceSchema,
49
50
  workspaceSchema
50
- } from "./chunks/chunk-POBAY3TI.js";
51
+ } from "./chunks/chunk-HXCZMMSD.js";
51
52
  import {
52
53
  METRIC_DEFINITIONS,
53
54
  computeRates,
@@ -59,13 +60,13 @@ import {
59
60
  campaignStatusSchema,
60
61
  replyCategorySchema
61
62
  } from "./chunks/chunk-QGRZDTX4.js";
63
+ import {
64
+ profileSlug
65
+ } from "./chunks/chunk-OPLXELPS.js";
62
66
  import {
63
67
  makeRef,
64
68
  parseRef
65
69
  } from "./chunks/chunk-HXB2IOJJ.js";
66
- import {
67
- profileSlug
68
- } from "./chunks/chunk-YFJ3OQZS.js";
69
70
  import {
70
71
  sha256Hex,
71
72
  stableId
@@ -111,6 +112,7 @@ export {
111
112
  mailProviderSchema,
112
113
  makeErrorMapper,
113
114
  makeRef,
115
+ meetingStatusSchema,
114
116
  messageSchema,
115
117
  metricRowSchema,
116
118
  metricScopeSchema,
@@ -11,7 +11,7 @@ export interface InsightMeta {
11
11
  readonly evidence: Evidence;
12
12
  /** Vendor requests the insight made. */
13
13
  readonly requests: number;
14
- /** `false` when a cap stopped a read early, so the answer covers part of the data. */
14
+ /** `false` when the answer covers part of the data: a cap stopped a read early, or a record could not be checked. */
15
15
  readonly complete: boolean;
16
16
  /** What the reader should know before trusting the numbers. */
17
17
  readonly notes: readonly string[];
@@ -18,18 +18,19 @@ import {
18
18
  total,
19
19
  wilson,
20
20
  zScore
21
- } from "../chunks/chunk-KMQHXFIZ.js";
22
- import "../chunks/chunk-FTK4JS65.js";
21
+ } from "../chunks/chunk-CTRYCW4G.js";
22
+ import "../chunks/chunk-KNWJIJVO.js";
23
23
  import "../chunks/chunk-4PA526S7.js";
24
+ import "../chunks/chunk-I7GBBHD2.js";
24
25
  import "../chunks/chunk-HZCTYL22.js";
25
26
  import "../chunks/chunk-HPNGSG5E.js";
26
27
  import "../chunks/chunk-PTZO4QXR.js";
27
28
  import "../chunks/chunk-FALWG5U3.js";
28
- import "../chunks/chunk-POBAY3TI.js";
29
+ import "../chunks/chunk-HXCZMMSD.js";
29
30
  import "../chunks/chunk-CPACP4YD.js";
30
31
  import "../chunks/chunk-QGRZDTX4.js";
32
+ import "../chunks/chunk-OPLXELPS.js";
31
33
  import "../chunks/chunk-HXB2IOJJ.js";
32
- import "../chunks/chunk-YFJ3OQZS.js";
33
34
  import {
34
35
  OutboundError
35
36
  } from "../chunks/chunk-XYHM4KHC.js";
@@ -9,11 +9,29 @@ export interface InsightInputs {
9
9
  */
10
10
  readonly max_campaigns?: number | undefined;
11
11
  /**
12
- * The person's email address or LinkedIn profile URL, or a lead ref as the other people insights return
12
+ * The person's email address, for example jane@acme.com
13
13
  *
14
- * At least 3 characters. Required.
14
+ * Defaults to `null`.
15
+ */
16
+ readonly email?: string | undefined;
17
+ /**
18
+ * A lead ref exactly as another tool returned it (provider:workspace:id), for example a reply's leadRef or a lead's ref. A ref's provider picks the tool it is read from
19
+ *
20
+ * Defaults to `null`.
21
+ */
22
+ readonly lead_ref?: string | undefined;
23
+ /**
24
+ * The person's LinkedIn profile URL
25
+ *
26
+ * Defaults to `null`.
27
+ */
28
+ readonly linkedin_url?: string | undefined;
29
+ /**
30
+ * Any of an email address, a LinkedIn profile URL or a lead ref as another tool returned it (provider:workspace:id). Give exactly one of person, lead_ref, email and linkedin_url
31
+ *
32
+ * Defaults to `null`.
15
33
  */
16
- readonly person: string;
34
+ readonly person?: string | undefined;
17
35
  };
18
36
  /** The input of `accountSummary` (the `account_summary` tool). */
19
37
  readonly accountSummary: {
@@ -197,6 +215,12 @@ export interface InsightInputs {
197
215
  * Defaults to `["Interested","Meeting Booked","Meeting Completed"]`.
198
216
  */
199
217
  readonly positive_labels?: string[] | undefined;
218
+ /**
219
+ * Set to true to read each returned lead's conversation (one walk of messages each, up to limit) for who wrote last and a follow-up assessment. false leaves followUp.needed null with basis not_read; thread_context reads them later.
220
+ *
221
+ * Defaults to `false`.
222
+ */
223
+ readonly read_threads?: boolean | undefined;
200
224
  /**
201
225
  * A reply today earns the full recency points, fading evenly to none after this many days
202
226
  *
@@ -234,6 +258,45 @@ export interface InsightInputs {
234
258
  */
235
259
  readonly weight_reply?: number | undefined;
236
260
  };
261
+ /** The input of `threadContext` (the `thread_context` tool). */
262
+ readonly threadContext: {
263
+ /**
264
+ * snippet returns the first 280 characters of each message, wrapped as untrusted content; none returns no text
265
+ *
266
+ * Defaults to `"snippet"`.
267
+ */
268
+ readonly bodies?: "none" | "snippet" | undefined;
269
+ /**
270
+ * coverage.nextCursor from the previous call with the same leads and threads, to read the next page of conversations
271
+ *
272
+ * Not empty. Defaults to `null`.
273
+ */
274
+ readonly cursor?: string | null | undefined;
275
+ /**
276
+ * Lead refs (provider:workspace:id), as dropped_replies, hot_leads and person_summary return them. Each lead's conversation in its campaign is read.
277
+ *
278
+ * Defaults to `[]`.
279
+ */
280
+ readonly leads?: string[] | undefined;
281
+ /**
282
+ * The newest messages returned per conversation. Every message is still read, so the latest is always found.
283
+ *
284
+ * A whole number from 1 to 100. Defaults to `10`.
285
+ */
286
+ readonly max_messages?: number | undefined;
287
+ /**
288
+ * Conversations read per call. Each costs one walk of its messages.
289
+ *
290
+ * A whole number from 1 to 50. Defaults to `20`.
291
+ */
292
+ readonly page_size?: number | undefined;
293
+ /**
294
+ * Thread ids, from a message's or reply's threadId
295
+ *
296
+ * Defaults to `[]`.
297
+ */
298
+ readonly threads?: string[] | undefined;
299
+ };
237
300
  /** The input of `personalizationGaps` (the `personalization_gaps` tool). */
238
301
  readonly personalizationGaps: {
239
302
  /**
@@ -468,9 +531,9 @@ export interface InsightInputs {
468
531
  /** The input of `domainHealth` (the `domain_health` tool). */
469
532
  readonly domainHealth: {
470
533
  /**
471
- * The most senders to check. Each costs 1 request.
534
+ * The most senders to check. Leave out for 500 where the vendor reads health a page at a time (a few requests per 100 senders), or 50 where each sender costs 1 to 3 requests.
472
535
  *
473
- * A whole number from 1 to 500. Defaults to `50`.
536
+ * A whole number from 1 to 500. Defaults to `null`.
474
537
  */
475
538
  readonly max_senders?: number | undefined;
476
539
  /**
@@ -1,7 +1,7 @@
1
1
  import type { Channel } from "../../internal/entities.ts";
2
2
  import type { CampaignsRead } from "../capped.ts";
3
3
  import type { ProportionTest } from "../stats.ts";
4
- import type { Measured, OpenRange, Totals } from "./shared.ts";
4
+ import type { Measured, OpenRange, ReplyBasis, Totals } from "./shared.ts";
5
5
  export interface ChannelGroup extends Totals {
6
6
  readonly channel: Channel;
7
7
  readonly campaigns: number;
@@ -29,6 +29,13 @@ export interface ChannelMix extends CampaignsRead {
29
29
  readonly finding: string;
30
30
  /** The same numbers for each tool and channel. */
31
31
  readonly byProvider: readonly ProviderGroup[];
32
+ /**
33
+ * What every reply and positive reply rate divides by: leads contacted, or
34
+ * messages sent when a campaign has replies in the range but contacted no
35
+ * new lead in it.
36
+ * Always set by the insight; optional so a value built by hand stays valid.
37
+ */
38
+ readonly replyRateBasis?: ReplyBasis;
32
39
  }
33
40
  export declare const channelMix: import("../define.ts").InsightDefinition<"channelMix", {
34
41
  alpha: number;
@@ -3,10 +3,11 @@ import type { MetricCounts } from "../../internal/metrics.ts";
3
3
  import type { CampaignsRead, Capped } from "../capped.ts";
4
4
  import type { InsightContext } from "../define.ts";
5
5
  import type { ProportionTest } from "../stats.ts";
6
- import type { CampaignLabel, DayRange, ReplyBasis, Totals } from "./shared.ts";
6
+ import type { CampaignLabel, DayRange, Rates, ReplyBasis, Totals } from "./shared.ts";
7
7
  /**
8
8
  * Counts and rates for one period, or the change between two. `null` is
9
- * unknown. The reply and positive reply rates are over `replyRateBasis`.
9
+ * unknown. The reply and positive reply rates are over `replyRateBasis`,
10
+ * and `Comparison.rates` has the count and the denominator behind each.
10
11
  */
11
12
  export interface PeriodNumbers extends Totals {
12
13
  readonly replyRate: number | null;
@@ -24,6 +25,16 @@ export interface Comparison {
24
25
  readonly replyRateBasis: ReplyBasis;
25
26
  /** `current` minus `previous`, field by field. Rates change in points: 0.02 is two points. */
26
27
  readonly change: PeriodNumbers;
28
+ /**
29
+ * Each period's rates with the counts behind them. Over several campaigns
30
+ * a rate counts only those that report both sides, so its `count` and
31
+ * `of` can be less than the totals in `current` and `previous`.
32
+ * Always set by the insight; optional so a value built by hand stays valid.
33
+ */
34
+ readonly rates?: {
35
+ readonly current: Rates;
36
+ readonly previous: Rates;
37
+ };
27
38
  /** The two-proportion test on the reply rate. `null` when it cannot be run. */
28
39
  readonly replyRateTest: ProportionTest | null;
29
40
  /** Whether the reply rate moved by more than chance. */
@@ -87,6 +87,14 @@ export declare const baseIn: (basis: ReplyBasis) => Base;
87
87
  /** What a per-lead rate divides by: leads contacted, or messages sent when the vendor does not count leads. */
88
88
  export declare const perLeadBasis: (counts: Totals) => ReplyBasis;
89
89
  export declare const perLeadBase: Base;
90
+ /**
91
+ * What a rate over several rows divides replies by, the same for every row:
92
+ * leads contacted, unless a row has replies and messages sent but no lead
93
+ * contacted (its leads were first contacted before the range, so only
94
+ * follow-ups went out), when it is messages sent. A row that does not
95
+ * report the basis is left out of the rate, never divided by another count.
96
+ */
97
+ export declare const replyBasisAcross: (rows: readonly Totals[]) => ReplyBasis;
90
98
  /**
91
99
  * What two periods divide replies by, the same for both: messages sent when
92
100
  * both report them, since replies in a week answer messages sent that week
@@ -124,13 +132,15 @@ export interface MeasuredAcross extends RateCoverage {
124
132
  export declare const measureAcross: <Row>(rows: readonly Row[], countOf: (row: Row) => number | null, baseOf: (row: Row) => number | null) => MeasuredAcross;
125
133
  export interface RatesAcross {
126
134
  readonly rates: Rates;
135
+ /** What the reply and positive reply rates divide by, the same for every row. */
136
+ readonly replyRateBasis: ReplyBasis;
127
137
  /** The rates that leave rows out, in words: `bounce rate (1 of 2)`. Empty when every row is in every rate. */
128
138
  readonly partial: readonly string[];
129
139
  }
130
140
  /** Names a rate that leaves rows out, or nothing when every row is in it. */
131
141
  export declare const partialRate: (name: string, across: RateCoverage) => string[];
132
142
  /** The three rates over several rows of counts, each over the rows that report it. */
133
- export declare const ratesAcross: (rows: readonly Totals[], base?: Base) => RatesAcross;
143
+ export declare const ratesAcross: (rows: readonly Totals[], basis?: ReplyBasis) => RatesAcross;
134
144
  /** The note for rates that leave rows out. `where` names the group, for example `Tag saas`. */
135
145
  export declare const partialNote: (where: string, partial: readonly string[], rows?: string) => string;
136
146
  /** How much a campaign sent: messages, or leads contacted when messages are not reported. */
@@ -1,5 +1,5 @@
1
1
  import type { CampaignsRead } from "../capped.ts";
2
- import type { OpenRange, Rates, Totals } from "./shared.ts";
2
+ import type { OpenRange, Rates, ReplyBasis, Totals } from "./shared.ts";
3
3
  /**
4
4
  * A tag's counts are every campaign's added up. Each rate counts only the
5
5
  * campaigns that report both sides of it, so its `count` and `of` can be
@@ -17,6 +17,13 @@ export interface TagRollup extends CampaignsRead {
17
17
  /** Best first, by the low end of the reply rate interval. */
18
18
  readonly tags: readonly TagGroup[];
19
19
  readonly tooFewSends: readonly TagGroup[];
20
+ /**
21
+ * What every reply and positive reply rate divides by: leads contacted, or
22
+ * messages sent when a campaign has replies in the range but contacted no
23
+ * new lead in it.
24
+ * Always set by the insight; optional so a value built by hand stays valid.
25
+ */
26
+ readonly replyRateBasis?: ReplyBasis;
20
27
  }
21
28
  export declare const tagRollup: import("../define.ts").InsightDefinition<"tagRollup", {
22
29
  min_sent: number;
@@ -1,7 +1,13 @@
1
1
  import type { Message, Reply } from "../../internal/entities.ts";
2
2
  import type { InsightContext } from "../define.ts";
3
+ import type { LabelledReply, ThreadContext } from "./thread-context.ts";
3
4
  export declare const HOUR = 3600000;
4
- export interface DroppedReply {
5
+ /**
6
+ * The thread's context fields (`activity`, `meeting`, `vendorSentiment`,
7
+ * `followUp`) are always set by dropped_replies; optional so a value built
8
+ * by hand stays valid.
9
+ */
10
+ export interface DroppedReply extends Partial<ThreadContext> {
5
11
  /** The oldest reply in the conversation that got no answer. */
6
12
  readonly reply: string;
7
13
  readonly lead: string | null;
@@ -22,8 +28,14 @@ export interface DroppedReply {
22
28
  readonly unansweredReplies: number;
23
29
  /** Whether the conversation was read by its thread or by the lead's timeline. */
24
30
  readonly checkedBy: "thread" | "timeline";
31
+ /** What was found, with the latest message and any meeting the vendor records. */
25
32
  readonly finding: string;
26
33
  }
34
+ /** A dropped reply before its lead is read, with the conversation it was found in. */
35
+ export type FoundDropped = Omit<DroppedReply, keyof ThreadContext> & {
36
+ readonly labelled: LabelledReply;
37
+ readonly messages: readonly Message[];
38
+ };
27
39
  export interface Conversation {
28
40
  readonly by: "thread" | "timeline" | null;
29
41
  readonly id: string;
@@ -46,7 +58,7 @@ export interface Checkable extends Conversation {
46
58
  }
47
59
  interface Checked {
48
60
  answered: number;
49
- readonly dropped: DroppedReply[];
61
+ readonly dropped: FoundDropped[];
50
62
  tooRecent: number;
51
63
  /** Conversations whose read failed. */
52
64
  unread: number;
@@ -1,7 +1,5 @@
1
1
  import type { Lead } from "../../internal/entities.ts";
2
2
  import type { InsightContext } from "../define.ts";
3
- /** `email:<address>` or `linkedin:<slug>`, or `null` when the text is neither. */
4
- export declare const personKey: (identifier: string) => string | null;
5
3
  /** Every exact identifier a lead carries. */
6
4
  export declare const keysOfLead: (lead: Lead) => string[];
7
5
  export interface FoundPerson {
@@ -10,8 +8,11 @@ export interface FoundPerson {
10
8
  /** One record per campaign the person is in. */
11
9
  readonly records: readonly Lead[];
12
10
  }
13
- /** A lead ref, as the other people insights return, rather than an identifier. */
14
- export declare const isLeadRef: (identifier: string) => boolean;
11
+ /**
12
+ * A lead ref whose lead must be read (`leads.get`) for its identifiers. A
13
+ * ref whose vendor id is already an address or a profile URL needs no read.
14
+ */
15
+ export declare const refNeedsRead: (identifier: string) => boolean;
15
16
  /**
16
17
  * Asks the vendor for the person by each identifier. A record that carries a
17
18
  * second identifier is looked up under that one too, so an email address can
@@ -1,3 +1,4 @@
1
+ import type { ThreadContext } from "./thread-context.ts";
1
2
  /** Points per signal. `null` when the vendor reports nothing for that signal. */
2
3
  export interface HotLeadParts {
3
4
  readonly interest: number | null;
@@ -6,7 +7,13 @@ export interface HotLeadParts {
6
7
  readonly opens: number | null;
7
8
  readonly recency: number | null;
8
9
  }
9
- export interface HotLead {
10
+ /**
11
+ * The thread's context fields (`activity`, `meeting`, `vendorSentiment`,
12
+ * `followUp`) are always set by hot_leads; optional so a value built by hand
13
+ * stays valid. A score ranks interest; `followUp` says from the thread
14
+ * whether a reply is owed.
15
+ */
16
+ export interface HotLead extends Partial<ThreadContext> {
10
17
  readonly lead: string;
11
18
  readonly email: string | null;
12
19
  readonly linkedinUrl: string | null;
@@ -74,6 +81,7 @@ export declare const hotLeads: import("../define.ts").InsightDefinition<"hotLead
74
81
  max_age_days: number;
75
82
  include_engagement_only: boolean;
76
83
  positive_labels: string[];
84
+ read_threads: boolean;
77
85
  recency_days: number;
78
86
  weight_click: number;
79
87
  weight_interest: number;
@@ -89,6 +97,7 @@ export declare const hotLeads: import("../define.ts").InsightDefinition<"hotLead
89
97
  max_age_days?: number | undefined;
90
98
  include_engagement_only?: boolean | undefined;
91
99
  positive_labels?: string[] | undefined;
100
+ read_threads?: boolean | undefined;
92
101
  recency_days?: number | undefined;
93
102
  weight_click?: number | undefined;
94
103
  weight_interest?: number | undefined;
@@ -1,8 +1,14 @@
1
1
  export declare const PEOPLE_INSIGHTS: readonly [import("../define.ts").InsightDefinition<"personSummary", {
2
2
  max_campaigns: number;
3
- person: string;
3
+ email?: string | undefined;
4
+ lead_ref?: string | undefined;
5
+ linkedin_url?: string | undefined;
6
+ person?: string | undefined;
4
7
  }, import("./person-summary.ts").PersonSummary, {
5
- person: string;
8
+ email?: string | undefined;
9
+ lead_ref?: string | undefined;
10
+ linkedin_url?: string | undefined;
11
+ person?: string | undefined;
6
12
  max_campaigns?: number | undefined;
7
13
  }>, import("../define.ts").InsightDefinition<"accountSummary", {
8
14
  allow_free_domains: boolean;
@@ -61,6 +67,7 @@ export declare const PEOPLE_INSIGHTS: readonly [import("../define.ts").InsightDe
61
67
  max_age_days: number;
62
68
  include_engagement_only: boolean;
63
69
  positive_labels: string[];
70
+ read_threads: boolean;
64
71
  recency_days: number;
65
72
  weight_click: number;
66
73
  weight_interest: number;
@@ -76,12 +83,27 @@ export declare const PEOPLE_INSIGHTS: readonly [import("../define.ts").InsightDe
76
83
  max_age_days?: number | undefined;
77
84
  include_engagement_only?: boolean | undefined;
78
85
  positive_labels?: string[] | undefined;
86
+ read_threads?: boolean | undefined;
79
87
  recency_days?: number | undefined;
80
88
  weight_click?: number | undefined;
81
89
  weight_interest?: number | undefined;
82
90
  weight_open?: number | undefined;
83
91
  weight_recency?: number | undefined;
84
92
  weight_reply?: number | undefined;
93
+ }>, import("../define.ts").InsightDefinition<"threadContext", {
94
+ bodies: "none" | "snippet";
95
+ cursor: string | null;
96
+ leads: string[];
97
+ max_messages: number;
98
+ page_size: number;
99
+ threads: string[];
100
+ }, import("./thread-contexts.ts").ThreadContexts, {
101
+ bodies?: "none" | "snippet" | undefined;
102
+ cursor?: string | null | undefined;
103
+ leads?: string[] | undefined;
104
+ max_messages?: number | undefined;
105
+ page_size?: number | undefined;
106
+ threads?: string[] | undefined;
85
107
  }>, import("../define.ts").InsightDefinition<"personalizationGaps", {
86
108
  campaign: string;
87
109
  limit: number;
@@ -98,4 +120,6 @@ export type { HotLead, HotLeadParts, HotLeads } from "./hot-leads.ts";
98
120
  export type { CollisionCampaign, LeadCollision, LeadCollisions, } from "./lead-collisions.ts";
99
121
  export type { PersonCampaign, PersonSummary } from "./person-summary.ts";
100
122
  export type { CopyVariable, GapLead, PersonalizationGaps, VariableUse, } from "./personalization-gaps.ts";
123
+ export type { FollowUpAssessment, FollowUpBasis, LatestMessage, ThreadActivity, ThreadContext, VendorSentiment, } from "./thread-context.ts";
124
+ export type { ThreadContexts, ThreadMessage, ThreadRecord, Uncovered, } from "./thread-contexts.ts";
101
125
  export type { SuppressionCampaign, SuppressionCheck, SuppressionMatch, SuppressionViolation, } from "./suppression-check.ts";
@@ -1,4 +1,10 @@
1
- export interface PersonCampaign {
1
+ import type { ThreadContext } from "./thread-context.ts";
2
+ /**
3
+ * The thread's context fields (`activity`, `meeting`, `vendorSentiment`,
4
+ * `followUp`) are always set by person_summary; optional so a value built
5
+ * by hand stays valid.
6
+ */
7
+ export interface PersonCampaign extends Partial<ThreadContext> {
2
8
  readonly campaign: string | null;
3
9
  readonly campaignName: string | null;
4
10
  readonly campaignStatus: string | null;
@@ -61,8 +67,14 @@ export interface PersonSummary {
61
67
  }
62
68
  export declare const personSummary: import("../define.ts").InsightDefinition<"personSummary", {
63
69
  max_campaigns: number;
64
- person: string;
70
+ email?: string | undefined;
71
+ lead_ref?: string | undefined;
72
+ linkedin_url?: string | undefined;
73
+ person?: string | undefined;
65
74
  }, PersonSummary, {
66
- person: string;
75
+ email?: string | undefined;
76
+ lead_ref?: string | undefined;
77
+ linkedin_url?: string | undefined;
78
+ person?: string | undefined;
67
79
  max_campaigns?: number | undefined;
68
80
  }>;