outbound-sdk 0.11.0 → 0.13.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 (105) hide show
  1. package/dist/alerts/index.js +1 -1
  2. package/dist/budget/index.js +1 -1
  3. package/dist/cards/index.js +217 -100
  4. package/dist/cards/sender-tool-cards.d.ts +6 -0
  5. package/dist/chunks/{chunk-UAHYPASH.js → chunk-3LRIWQEJ.js} +2 -1
  6. package/dist/chunks/{chunk-UZLFZZ2U.js → chunk-6BSFR5SF.js} +14 -2
  7. package/dist/chunks/{chunk-FTK4JS65.js → chunk-BTIJ24UY.js} +89 -9
  8. package/dist/chunks/{chunk-OVTYA3IB.js → chunk-EAG5NIPM.js} +614 -206
  9. package/dist/chunks/{chunk-A7DLJUA6.js → chunk-FT6HMMMP.js} +3 -1
  10. package/dist/chunks/chunk-I7GBBHD2.js +80 -0
  11. package/dist/chunks/{chunk-UOJG4VYF.js → chunk-LD5OAELW.js} +1 -1
  12. package/dist/chunks/{chunk-KMQHXFIZ.js → chunk-LJNU4LAR.js} +2094 -1014
  13. package/dist/chunks/{chunk-POBAY3TI.js → chunk-NLYGMVXS.js} +30 -0
  14. package/dist/chunks/{chunk-V7JKTNRO.js → chunk-OE45PREW.js} +1 -1
  15. package/dist/chunks/{chunk-MEEJIIIA.js → chunk-OP2GL7ZT.js} +77 -8
  16. package/dist/chunks/{chunk-YFJ3OQZS.js → chunk-OPLXELPS.js} +5 -1
  17. package/dist/chunks/{chunk-CVLGFVDC.js → chunk-PDYE6CWS.js} +136 -64
  18. package/dist/chunks/{chunk-OMCDMELK.js → chunk-PUIHJFK4.js} +1 -1
  19. package/dist/chunks/{chunk-MPE6VLLY.js → chunk-UZ4YWUZ7.js} +1 -1
  20. package/dist/chunks/{tools-AVJ3XJ5A.js → tools-VCCH3JNL.js} +13 -6
  21. package/dist/cli/bin.js +11 -10
  22. package/dist/cli/config.d.ts +0 -2
  23. package/dist/cli/index.js +10 -9
  24. package/dist/cli/offered.d.ts +31 -2
  25. package/dist/cli/serve.d.ts +4 -2
  26. package/dist/combine/index.js +60 -4
  27. package/dist/emailbison/index.js +4 -4
  28. package/dist/fixtures/index.js +4 -4
  29. package/dist/heyreach/index.js +17 -6
  30. package/dist/identity/index.js +46 -11
  31. package/dist/identity/keys.d.ts +1 -1
  32. package/dist/index.js +8 -6
  33. package/dist/insights/capped.d.ts +14 -1
  34. package/dist/insights/define.d.ts +8 -6
  35. package/dist/insights/index.d.ts +1 -1
  36. package/dist/insights/index.js +12 -61
  37. package/dist/insights/inputs.generated.d.ts +91 -16
  38. package/dist/insights/ops/campaign-ranking.d.ts +8 -1
  39. package/dist/insights/ops/channel-mix.d.ts +8 -1
  40. package/dist/insights/ops/client-report.d.ts +28 -18
  41. package/dist/insights/ops/client-runway.d.ts +43 -0
  42. package/dist/insights/ops/index.d.ts +6 -1
  43. package/dist/insights/ops/period-comparison.d.ts +35 -2
  44. package/dist/insights/ops/pipeline-forecast.d.ts +14 -9
  45. package/dist/insights/ops/shared.d.ts +49 -2
  46. package/dist/insights/ops/tag-rollup.d.ts +8 -1
  47. package/dist/insights/people/coverage.d.ts +26 -0
  48. package/dist/insights/people/dropped-replies-check.d.ts +19 -3
  49. package/dist/insights/people/dropped-replies.d.ts +6 -2
  50. package/dist/insights/people/find.d.ts +5 -4
  51. package/dist/insights/people/hot-leads.d.ts +10 -1
  52. package/dist/insights/people/index.d.ts +26 -2
  53. package/dist/insights/people/lead-collisions.d.ts +18 -1
  54. package/dist/insights/people/person-summary.d.ts +15 -3
  55. package/dist/insights/people/suppression-check.d.ts +18 -1
  56. package/dist/insights/people/thread-context.d.ts +79 -0
  57. package/dist/insights/people/thread-contexts.d.ts +59 -0
  58. package/dist/insights/people/thread-read.d.ts +33 -0
  59. package/dist/insights/registry.d.ts +29 -3
  60. package/dist/insights/senders/domain-health.d.ts +1 -1
  61. package/dist/insights/senders/index.d.ts +1 -1
  62. package/dist/insights/senders/read.d.ts +9 -0
  63. package/dist/insights/tools.d.ts +35 -2
  64. package/dist/instantly/adapter.d.ts +3 -2
  65. package/dist/instantly/capabilities.d.ts +5 -0
  66. package/dist/instantly/index.js +255 -66
  67. package/dist/instantly/lead-ids.d.ts +11 -0
  68. package/dist/instantly/map-lead.d.ts +19 -2
  69. package/dist/instantly/senders.d.ts +3 -0
  70. package/dist/internal/adapter.d.ts +7 -0
  71. package/dist/internal/capabilities.d.ts +8 -0
  72. package/dist/internal/entities.d.ts +24 -1
  73. package/dist/internal/fields.d.ts +10 -0
  74. package/dist/internal/outbound/api.d.ts +12 -0
  75. package/dist/internal/outbound/operations-account.d.ts +4 -1
  76. package/dist/internal/outbound/outbound.d.ts +2 -1
  77. package/dist/internal/outbound/specs-account.d.ts +2 -1
  78. package/dist/internal/person.d.ts +32 -0
  79. package/dist/internal/records.d.ts +2 -2
  80. package/dist/internal/reply-people.d.ts +25 -7
  81. package/dist/internal/runway.d.ts +38 -5
  82. package/dist/internal/url.d.ts +2 -1
  83. package/dist/loader/index.js +1 -1
  84. package/dist/memory/data.d.ts +2 -1
  85. package/dist/memory/index.js +6 -4
  86. package/dist/redact/index.d.ts +1 -1
  87. package/dist/redact/index.js +62 -31
  88. package/dist/redact/plugin.d.ts +13 -11
  89. package/dist/redact/tokens.d.ts +18 -1
  90. package/dist/smartlead/index.js +21 -7
  91. package/dist/tools/account-tools.d.ts +0 -5
  92. package/dist/tools/ai-sdk.js +5 -3
  93. package/dist/tools/campaign-tools.d.ts +0 -4
  94. package/dist/tools/claude-agent.js +5 -3
  95. package/dist/tools/deliverability-check.d.ts +9 -0
  96. package/dist/tools/index.js +6 -4
  97. package/dist/tools/people-tools.d.ts +4 -1
  98. package/dist/tools/person-input.d.ts +17 -0
  99. package/dist/tools/registry.d.ts +8 -1
  100. package/dist/tools/sender-health.d.ts +8 -0
  101. package/dist/tools/sender-impact.d.ts +38 -0
  102. package/dist/tools/shared.d.ts +5 -0
  103. package/dist/webhooks/index.js +6 -6
  104. package/package.json +1 -1
  105. /package/dist/chunks/{chunk-5XLR6XVV.js → chunk-HNYJO6B4.js} +0 -0
@@ -113,6 +113,18 @@ export declare const recipientMailProviderSchema: z.ZodEnum<{
113
113
  other: "other";
114
114
  }>;
115
115
  export type RecipientMailProvider = z.infer<typeof recipientMailProviderSchema>;
116
+ /**
117
+ * Where a lead's meeting stands, as the vendor records it on the lead:
118
+ * `booked`, `completed`, `no_show` (booked and missed) or `won` (the deal
119
+ * closed, so the meeting happened).
120
+ */
121
+ export declare const meetingStatusSchema: z.ZodEnum<{
122
+ completed: "completed";
123
+ booked: "booked";
124
+ no_show: "no_show";
125
+ won: "won";
126
+ }>;
127
+ export type MeetingStatus = z.infer<typeof meetingStatusSchema>;
116
128
  export declare const senderSchema: z.ZodObject<{
117
129
  address: z.ZodNullable<z.ZodString>;
118
130
  dailyLimit: z.ZodNullable<z.ZodNumber>;
@@ -216,6 +228,12 @@ export declare const leadSchema: z.ZodObject<{
216
228
  }>>;
217
229
  lastName: z.ZodNullable<z.ZodString>;
218
230
  linkedinUrl: z.ZodNullable<z.ZodString>;
231
+ meeting: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
232
+ completed: "completed";
233
+ booked: "booked";
234
+ no_show: "no_show";
235
+ won: "won";
236
+ }>>>;
219
237
  location: z.ZodNullable<z.ZodString>;
220
238
  phone: z.ZodNullable<z.ZodString>;
221
239
  progress: z.ZodEnum<{
@@ -276,12 +294,14 @@ export declare const messageSchema: z.ZodObject<{
276
294
  email: "email";
277
295
  linkedin: "linkedin";
278
296
  }>;
297
+ leadEmail: z.ZodOptional<z.ZodNullable<z.ZodString>>;
279
298
  leadRef: z.ZodNullable<z.ZodString>;
280
299
  senderRef: z.ZodNullable<z.ZodString>;
281
300
  sentAt: z.ZodNullable<z.ZodISODateTime>;
282
301
  stepIndex: z.ZodNullable<z.ZodNumber>;
283
302
  subject: z.ZodNullable<z.ZodString>;
284
303
  threadId: z.ZodNullable<z.ZodString>;
304
+ url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
285
305
  variantKey: z.ZodNullable<z.ZodString>;
286
306
  provider: z.ZodString;
287
307
  raw: z.ZodJSONSchema;
@@ -293,7 +313,8 @@ export declare const messageSchema: z.ZodObject<{
293
313
  export type Message = z.infer<typeof messageSchema>;
294
314
  /**
295
315
  * One received message, not one person: a lead who replies twice in a thread
296
- * is two replies. Count people by `leadRef`, as `MetricRow.replied` does.
316
+ * is two replies. Count people by `leadEmail` where it is present, since
317
+ * one person in two campaigns is two leads, and otherwise by `leadRef`.
297
318
  */
298
319
  export declare const replySchema: z.ZodObject<{
299
320
  category: z.ZodEnum<{
@@ -325,12 +346,14 @@ export declare const replySchema: z.ZodObject<{
325
346
  email: "email";
326
347
  linkedin: "linkedin";
327
348
  }>;
349
+ leadEmail: z.ZodOptional<z.ZodNullable<z.ZodString>>;
328
350
  leadRef: z.ZodNullable<z.ZodString>;
329
351
  senderRef: z.ZodNullable<z.ZodString>;
330
352
  sentAt: z.ZodNullable<z.ZodISODateTime>;
331
353
  stepIndex: z.ZodNullable<z.ZodNumber>;
332
354
  subject: z.ZodNullable<z.ZodString>;
333
355
  threadId: z.ZodNullable<z.ZodString>;
356
+ url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
334
357
  variantKey: z.ZodNullable<z.ZodString>;
335
358
  provider: z.ZodString;
336
359
  raw: z.ZodJSONSchema;
@@ -117,6 +117,12 @@ export declare const RECORD_SCHEMAS: {
117
117
  }>>;
118
118
  lastName: z.ZodNullable<z.ZodString>;
119
119
  linkedinUrl: z.ZodNullable<z.ZodString>;
120
+ meeting: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
121
+ completed: "completed";
122
+ booked: "booked";
123
+ no_show: "no_show";
124
+ won: "won";
125
+ }>>>;
120
126
  location: z.ZodNullable<z.ZodString>;
121
127
  phone: z.ZodNullable<z.ZodString>;
122
128
  progress: z.ZodEnum<{
@@ -185,12 +191,14 @@ export declare const RECORD_SCHEMAS: {
185
191
  email: "email";
186
192
  linkedin: "linkedin";
187
193
  }>;
194
+ leadEmail: z.ZodOptional<z.ZodNullable<z.ZodString>>;
188
195
  leadRef: z.ZodNullable<z.ZodString>;
189
196
  senderRef: z.ZodNullable<z.ZodString>;
190
197
  sentAt: z.ZodNullable<z.ZodISODateTime>;
191
198
  stepIndex: z.ZodNullable<z.ZodNumber>;
192
199
  subject: z.ZodNullable<z.ZodString>;
193
200
  threadId: z.ZodNullable<z.ZodString>;
201
+ url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
194
202
  variantKey: z.ZodNullable<z.ZodString>;
195
203
  provider: z.ZodString;
196
204
  raw: z.ZodJSONSchema;
@@ -308,12 +316,14 @@ export declare const RECORD_SCHEMAS: {
308
316
  email: "email";
309
317
  linkedin: "linkedin";
310
318
  }>;
319
+ leadEmail: z.ZodOptional<z.ZodNullable<z.ZodString>>;
311
320
  leadRef: z.ZodNullable<z.ZodString>;
312
321
  senderRef: z.ZodNullable<z.ZodString>;
313
322
  sentAt: z.ZodNullable<z.ZodISODateTime>;
314
323
  stepIndex: z.ZodNullable<z.ZodNumber>;
315
324
  subject: z.ZodNullable<z.ZodString>;
316
325
  threadId: z.ZodNullable<z.ZodString>;
326
+ url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
317
327
  variantKey: z.ZodNullable<z.ZodString>;
318
328
  provider: z.ZodString;
319
329
  raw: z.ZodJSONSchema;
@@ -151,6 +151,12 @@ export interface TopLevelStatsOptions extends StatsOptions {
151
151
  * The `campaign` scope without one returns a row per campaign, in one call.
152
152
  */
153
153
  readonly scopeId?: string | undefined;
154
+ /**
155
+ * Several senders in one read, for the `sender` scope in place of
156
+ * `scopeId`. Each row's `scopeRef` says which sender it is; a sender the
157
+ * vendor has no rows for has none. Needs `stats.bySenders`.
158
+ */
159
+ readonly scopeIds?: readonly string[] | undefined;
154
160
  }
155
161
  export interface StatsResult {
156
162
  readonly rows: readonly MetricRow[];
@@ -276,6 +282,12 @@ export interface OutboundApi {
276
282
  readonly fields: FieldCoverage;
277
283
  readonly campaigns: Collection<Campaign, CampaignFilters>;
278
284
  readonly senders: Collection<Sender, SenderFilters>;
285
+ /**
286
+ * Every sender's health, listed like `senders`: DNS records, connection
287
+ * state and warmup traffic in a few requests a page, where one sender's
288
+ * `health()` costs a few requests each. Needs `senders.healthList`.
289
+ */
290
+ readonly senderHealth: ReadCollection<SenderHealth, SenderFilters>;
279
291
  readonly leads: Collection<Lead, LeadFilters>;
280
292
  readonly messages: ReadCollection<Message, MessageFilters>;
281
293
  readonly replies: ReadCollection<Reply, ReplyFilters>;
@@ -1,4 +1,4 @@
1
- import type { PageQuery, SubsequenceQuery, WebhookQuery } from "../adapter.ts";
1
+ import type { PageQuery, SenderQuery, SubsequenceQuery, WebhookQuery } from "../adapter.ts";
2
2
  import type { DispatchTarget, OperationOutput } from "./operation-shared.ts";
3
3
  export type AccountOperation = {
4
4
  readonly kind: "blocklist.list";
@@ -21,6 +21,9 @@ export type AccountOperation = {
21
21
  } | {
22
22
  readonly kind: "senders.health";
23
23
  readonly id: string;
24
+ } | {
25
+ readonly kind: "senders.healthList";
26
+ readonly query: SenderQuery;
24
27
  } | {
25
28
  readonly kind: "sequence.subsequences";
26
29
  readonly query: SubsequenceQuery;
@@ -4,7 +4,7 @@ import { RequestEngine } from "../engine/engine.ts";
4
4
  import type { LimitsSnapshot, OperationOptions } from "../engine/engine.ts";
5
5
  import type { RateLimitStore } from "../engine/rate-store.ts";
6
6
  import type { Runtime } from "../engine/runtime.ts";
7
- import type { BlockEntry, LeadList, PlacementTest, Tag, WebhookSubscription } from "../entities-account.ts";
7
+ import type { BlockEntry, LeadList, PlacementTest, SenderHealth, Tag, WebhookSubscription } from "../entities-account.ts";
8
8
  import type { Campaign, Lead, Message, Reply, Sender, Workspace } from "../entities.ts";
9
9
  import type { FieldCoverage } from "../fields.ts";
10
10
  import type { OutboundHooks } from "../hooks.ts";
@@ -45,6 +45,7 @@ export declare class Outbound<Native extends NativeCatalog = NoNative> implement
45
45
  #private;
46
46
  readonly campaigns: Collection<Campaign, CampaignFilters>;
47
47
  readonly senders: Collection<Sender, SenderFilters>;
48
+ readonly senderHealth: ReadCollection<SenderHealth, SenderFilters>;
48
49
  readonly leads: Collection<Lead, LeadFilters>;
49
50
  readonly messages: ReadCollection<Message, MessageFilters>;
50
51
  readonly replies: ReadCollection<Reply, ReplyFilters>;
@@ -1,12 +1,13 @@
1
1
  import type { BlockEntry, CampaignProgress, CampaignSettings, LeadList, PlacementTest, SenderHealth, Tag, WebhookSubscription } from "../entities-account.ts";
2
2
  import type { Sequence } from "../entities.ts";
3
- import type { WebhookFilters } from "./api.ts";
3
+ import type { SenderFilters, WebhookFilters } from "./api.ts";
4
4
  import type { GetSpec, ListSpec } from "./collections.ts";
5
5
  import type { Core } from "./core.ts";
6
6
  type NoFilters = Record<never, never>;
7
7
  export declare const settingsGet: (core: Core) => GetSpec<CampaignSettings>;
8
8
  export declare const progressGet: (core: Core) => GetSpec<CampaignProgress>;
9
9
  export declare const healthGet: (core: Core) => GetSpec<SenderHealth>;
10
+ export declare const healthList: (core: Core) => ListSpec<SenderHealth, SenderFilters>;
10
11
  export declare const subsequenceList: (core: Core) => ListSpec<Sequence, {
11
12
  readonly campaignId?: string | undefined;
12
13
  }>;
@@ -0,0 +1,32 @@
1
+ import type { OutboundApi } from "./outbound/api.ts";
2
+ import type { RefParts } from "./ref.ts";
3
+ /** What a person input accepts, for the messages that refuse one. */
4
+ export declare const PERSON_FORMS = "an email address, a LinkedIn profile URL or a lead ref as another tool returned it (provider:workspace:id)";
5
+ /** The provider, workspace and vendor id of a lead ref, or `null` when the text is not one. */
6
+ export declare const leadRefParts: (identifier: string) => RefParts | null;
7
+ /** `email:<address>` or `linkedin:<slug>`, or `null` when the text is neither, a lead ref included. */
8
+ export declare const personKey: (identifier: string) => string | null;
9
+ /** Why the text names no person. */
10
+ export declare const notAPerson: (identifier: string) => string;
11
+ export interface PersonInput {
12
+ /**
13
+ * The identifier to look the person up by. For a lead ref, the one its
14
+ * vendor id already is (an Instantly reply's ref holds the address, a
15
+ * HeyReach ref the profile URL); `null` when the lead must be read for it.
16
+ */
17
+ readonly key: string | null;
18
+ /** Set when the input is a lead ref. */
19
+ readonly ref: (RefParts & {
20
+ readonly text: string;
21
+ }) | null;
22
+ }
23
+ /** Reads a person input, or throws `Invalid` saying what is accepted. */
24
+ export declare const parsePerson: (identifier: string, provider: string) => PersonInput;
25
+ type Instance = Pick<OutboundApi, "provider" | "workspace" | "workspaceId">;
26
+ /**
27
+ * Refuses, before any request, a lead ref of a tool or workspace this
28
+ * instance does not read. On a combined instance the ref's provider and
29
+ * workspace name the member that reads it.
30
+ */
31
+ export declare const assertRefReadable: (outbound: Instance, ref: NonNullable<PersonInput["ref"]>) => void;
32
+ export {};
@@ -1,5 +1,5 @@
1
- export { campaignSchema, campaignStatusSchema, channelSchema, eventDataSchema, eventTypeSchema, evidenceSchema, leadProgressSchema, leadSchema, leadStatusSchema, mailProviderSchema, messageSchema, metricRowSchema, metricScopeSchema, outboundEventSchema, recipientMailProviderSchema, replyCategorySchema, replySchema, SCHEMA_VERSION, senderSchema, senderStatusSchema, sequenceSchema, workspaceSchema, } from "./entities.ts";
2
- export type { Campaign, CampaignStatus, Channel, EventData, EventType, Evidence, Lead, LeadEngagement, LeadProgress, LeadStatus, MailProvider, Message, MetricRow, MetricScope, OutboundEvent, RecipientMailProvider, Reply, ReplyCategory, Sender, SenderStatus, Sequence, SequenceStep, SequenceVariant, Workspace, } from "./entities.ts";
1
+ export { campaignSchema, campaignStatusSchema, channelSchema, eventDataSchema, eventTypeSchema, evidenceSchema, leadProgressSchema, leadSchema, leadStatusSchema, mailProviderSchema, meetingStatusSchema, messageSchema, metricRowSchema, metricScopeSchema, outboundEventSchema, recipientMailProviderSchema, replyCategorySchema, replySchema, SCHEMA_VERSION, senderSchema, senderStatusSchema, sequenceSchema, workspaceSchema, } from "./entities.ts";
2
+ export type { Campaign, CampaignStatus, Channel, EventData, EventType, Evidence, Lead, LeadEngagement, LeadProgress, LeadStatus, MailProvider, MeetingStatus, Message, MetricRow, MetricScope, OutboundEvent, RecipientMailProvider, Reply, ReplyCategory, Sender, SenderStatus, Sequence, SequenceStep, SequenceVariant, Workspace, } from "./entities.ts";
3
3
  export { blockEntrySchema, campaignProgressSchema, campaignSettingsSchema, leadListSchema, placementTestSchema, senderHealthSchema, tagSchema, webhookSubscriptionSchema, } from "./entities-account.ts";
4
4
  export type { BlockEntry, CampaignProgress, CampaignSettings, Entity, LeadList, PlacementTest, SenderHealth, SendingWindow, Tag, WebhookSubscription, } from "./entities-account.ts";
5
5
  export { resolveFields } from "./fields.ts";
@@ -1,25 +1,42 @@
1
1
  import type { Reply, ReplyCategory } from "./entities.ts";
2
- type Counted = Pick<Reply, "leadRef" | "threadId">;
2
+ type Counted = Pick<Reply, "isAuto" | "leadEmail" | "leadRef" | "threadId">;
3
3
  export interface ReplyCounts {
4
4
  /** Reply messages. */
5
5
  readonly messages: number;
6
- /** Distinct `leadRef`s. `null` when any reply has no `leadRef`. */
6
+ /**
7
+ * Distinct people, by `leadEmail` or else `leadRef`. `null` when any
8
+ * reply has neither.
9
+ */
7
10
  readonly people: number | null;
8
11
  /** Distinct `threadId`s. `null` when any reply has no `threadId`. */
9
12
  readonly threads: number | null;
13
+ /**
14
+ * Replies flagged automatic (`isAuto: true`), counted among `messages`,
15
+ * so a category count can leave them out. `null` when any reply's
16
+ * `isAuto` is unknown.
17
+ */
18
+ readonly automatic: number | null;
10
19
  }
11
20
  /** How many messages, people and threads a list of replies holds. */
12
21
  export declare const countReplies: (replies: readonly Counted[]) => ReplyCounts;
13
- /** `40 messages from 21 people in 9 threads`, leaving out what is unknown. */
22
+ /**
23
+ * `40 messages from 21 people in 9 threads, 4 of them automatic`, leaving out
24
+ * what is unknown.
25
+ */
14
26
  export declare const describeReplyCounts: (counts: ReplyCounts) => string;
15
27
  /** One person's replies, from `repliesByPerson`. */
16
28
  export interface ReplyPerson {
17
29
  /**
18
30
  * The lead who sent them. `null` for replies with no lead: those are
19
- * grouped by thread instead, one row per thread.
31
+ * grouped by thread instead, one row per thread. A person in two
32
+ * campaigns is two leads; this is the first one's.
20
33
  */
21
34
  readonly leadRef: string | null;
35
+ /** Their address, where the vendor names one. */
36
+ readonly leadEmail: string | null;
22
37
  readonly messages: number;
38
+ /** Of `messages`, those flagged automatic. `null` when any one's `isAuto` is unknown. */
39
+ readonly automatic: number | null;
23
40
  /** The earliest and latest `sentAt`. `null` when no reply has one. */
24
41
  readonly firstAt: string | null;
25
42
  readonly lastAt: string | null;
@@ -28,10 +45,11 @@ export interface ReplyPerson {
28
45
  /** Each thread the replies are in, in the order first seen. */
29
46
  readonly threadIds: readonly string[];
30
47
  }
31
- type Grouped = Pick<Reply, "category" | "leadRef" | "sentAt" | "threadId">;
48
+ type Grouped = Pick<Reply, "category" | "isAuto" | "leadEmail" | "leadRef" | "sentAt" | "threadId">;
32
49
  /**
33
- * One row per person, in the order each person first appears. A reply with
34
- * no `leadRef` is grouped by its thread, or stands alone without one.
50
+ * One row per person, by `leadEmail` or else `leadRef`, in the order each
51
+ * person first appears. A reply with neither is grouped by its thread, or
52
+ * stands alone without one.
35
53
  */
36
54
  export declare const repliesByPerson: (replies: readonly Grouped[]) => ReplyPerson[];
37
55
  export {};
@@ -34,9 +34,42 @@ export declare const splitActive: (leads: readonly Lead[]) => ActiveSplit;
34
34
  /** The leads runway divides: those not yet started, or every active lead when the split is unknown. */
35
35
  export declare const leadsToStart: (split: ActiveSplit) => number;
36
36
  /**
37
- * Days until no lead is left to start: `leadsToStart` divided by the pace.
38
- * `0` when every lead was read, none has an unknown status and none is left
39
- * to start. `null` when the count is unknown (`complete` false, or a lead's
40
- * status unknown) and none was found, or when some are left with no pace.
37
+ * Where a campaign's leads stand:
38
+ *
39
+ * - `draining`: leads are left to start and new ones started in the window,
40
+ * so `daysLeft` is how long they last at that pace.
41
+ * - `stalled`: leads are left to start, but none was started in the window,
42
+ * or the vendor reports no count of leads started, so there is no pace.
43
+ * - `out_of_leads`: every lead was counted and none is left to start.
44
+ * - `unknown`: the leads left to start were not all counted (a cap stopped
45
+ * the read, or a lead's status is unknown) and none was found.
41
46
  */
42
- export declare const runwayDays: (split: ActiveSplit, byStatus: Readonly<Pick<Record<LeadStatus, number>, "unknown">>, complete: boolean, pace: number | null) => number | null;
47
+ export type RunwayState = "draining" | "out_of_leads" | "stalled" | "unknown";
48
+ export interface Runway {
49
+ readonly state: RunwayState;
50
+ /** Leads not yet started: active ones with no step sent and no contact, or every active lead when the split is unknown. */
51
+ readonly remaining: number;
52
+ /** Active leads partway through the sequence. `null` when the vendor does not say which have started. */
53
+ readonly inSequence: number | null;
54
+ /** New leads started per day. `null` when the vendor reports no daily count of leads started. */
55
+ readonly pace: number | null;
56
+ /**
57
+ * `remaining` divided by `pace`. `null` when the pace is `null` or 0,
58
+ * since no time can be divided out of it, and when `state` is `unknown`.
59
+ * A minimum when the read was not complete.
60
+ */
61
+ readonly daysLeft: number | null;
62
+ }
63
+ /**
64
+ * The runway of a campaign from its leads split by start, the count of leads
65
+ * of unknown status, whether every lead was read, and the recent pace. The one
66
+ * runway calculation: pipeline_forecast, client_report, campaign_diagnosis and
67
+ * lead_runway all call it.
68
+ */
69
+ export declare const runwayOf: (split: ActiveSplit, byStatus: Readonly<Pick<Record<LeadStatus, number>, "unknown">>, complete: boolean, pace: number | null) => Runway;
70
+ /** What lead_runway and client_report read a campaign's leads with, so both count the same leads. */
71
+ export declare const RUNWAY_MAX_LEADS = 5000;
72
+ /** The lead status a runway read asks for: only the active leads where the tool can list them alone. */
73
+ export declare const runwayStatus: (capabilities: {
74
+ readonly "leads.byStatus"?: boolean | undefined;
75
+ }) => "active" | undefined;
@@ -1,4 +1,5 @@
1
- export type QueryValue = string | number | boolean | null | undefined;
1
+ /** A list is sent as the key repeated, once per item. */
2
+ export type QueryValue = string | number | boolean | readonly string[] | null | undefined;
2
3
  /** Joins a base URL and a path and appends the defined query values. */
3
4
  export declare const buildUrl: (baseUrl: string, path: string, query?: Readonly<Record<string, QueryValue>>) => string;
4
5
  /**
@@ -3,7 +3,7 @@ import {
3
3
  configuredProviders,
4
4
  fromEnv,
5
5
  loadableProviders
6
- } from "../chunks/chunk-5XLR6XVV.js";
6
+ } from "../chunks/chunk-HNYJO6B4.js";
7
7
  import "../chunks/chunk-NFWWA7MI.js";
8
8
  import "../chunks/chunk-XYHM4KHC.js";
9
9
  import "../chunks/chunk-45TXPJW7.js";
@@ -1,4 +1,4 @@
1
- import type { Campaign, CampaignStatus, Channel, Lead, LeadEngagement, LeadProgress, LeadStatus, MailProvider, Message, MetricRow, RecipientMailProvider, Reply, ReplyCategory, Sender, SenderStatus, Sequence } from "../internal/entities.ts";
1
+ import type { Campaign, CampaignStatus, Channel, Lead, LeadEngagement, LeadProgress, LeadStatus, MailProvider, Message, MetricRow, MeetingStatus, RecipientMailProvider, Reply, ReplyCategory, Sender, SenderStatus, Sequence } from "../internal/entities.ts";
2
2
  import type { MetricCounts } from "../internal/metrics.ts";
3
3
  import type { Identity } from "../internal/record.ts";
4
4
  import type { MemoryBlockEntry, MemoryHealth, MemoryList, MemoryPlacementTest, MemorySettings, MemoryTag, MemoryWebhook } from "./account.ts";
@@ -72,6 +72,7 @@ export interface MemoryLead {
72
72
  readonly companyLinkedinUrl?: string;
73
73
  readonly recipientMailProvider?: RecipientMailProvider;
74
74
  readonly location?: string;
75
+ readonly meeting?: MeetingStatus;
75
76
  readonly phone?: string;
76
77
  readonly website?: string;
77
78
  readonly tags?: readonly string[];
@@ -5,7 +5,7 @@ import {
5
5
  } from "../chunks/chunk-U5AK6OJM.js";
6
6
  import {
7
7
  leadProgressSchema
8
- } from "../chunks/chunk-POBAY3TI.js";
8
+ } from "../chunks/chunk-NLYGMVXS.js";
9
9
  import {
10
10
  emptyCounts,
11
11
  sumCounts
@@ -13,13 +13,13 @@ import {
13
13
  import {
14
14
  SCHEMA_VERSION
15
15
  } from "../chunks/chunk-QGRZDTX4.js";
16
+ import {
17
+ profileSlug
18
+ } from "../chunks/chunk-OPLXELPS.js";
16
19
  import {
17
20
  assertWorkspaceId,
18
21
  makeRef
19
22
  } from "../chunks/chunk-HXB2IOJJ.js";
20
- import {
21
- profileSlug
22
- } from "../chunks/chunk-YFJ3OQZS.js";
23
23
  import {
24
24
  stableId
25
25
  } from "../chunks/chunk-KVAG5GM2.js";
@@ -212,6 +212,7 @@ var toLead = (identity, seed) => ({
212
212
  lastName: seed.lastName ?? null,
213
213
  linkedinUrl: seed.linkedinUrl ?? null,
214
214
  location: seed.location ?? null,
215
+ meeting: seed.meeting ?? null,
215
216
  phone: seed.phone ?? null,
216
217
  recipientMailProvider: seed.recipientMailProvider ?? null,
217
218
  title: seed.title ?? null,
@@ -229,6 +230,7 @@ var messageFields = (identity, seed, channel, includeBody) => ({
229
230
  stepIndex: seed.stepIndex ?? null,
230
231
  subject: seed.subject ?? null,
231
232
  threadId: seed.threadId ?? null,
233
+ url: null,
232
234
  variantKey: seed.variantKey ?? null
233
235
  });
234
236
  var toMessage = (identity, seed, channel, includeBody) => {
@@ -1,2 +1,2 @@
1
- export { ALL_FIELDS, KNOWN_TOKENS, MASK, MIN_KEY_LENGTH, redact, } from "./plugin.ts";
1
+ export { ALL_FIELDS, KNOWN_TOKENS, MASK, MIN_KEY_LENGTH, REDACT_KEY_ENV, redact, } from "./plugin.ts";
2
2
  export type { RedactExtension, RedactField, RedactOptions } from "./plugin.ts";
@@ -1,14 +1,17 @@
1
+ import {
2
+ profileSlug
3
+ } from "../chunks/chunk-OPLXELPS.js";
1
4
  import {
2
5
  makeRef,
3
6
  parseRef
4
7
  } from "../chunks/chunk-HXB2IOJJ.js";
5
- import {
6
- profileSlug
7
- } from "../chunks/chunk-YFJ3OQZS.js";
8
8
  import {
9
9
  hmacSha256Hex,
10
10
  stableId
11
11
  } from "../chunks/chunk-KVAG5GM2.js";
12
+ import {
13
+ readEnv
14
+ } from "../chunks/chunk-NFWWA7MI.js";
12
15
  import {
13
16
  OutboundError
14
17
  } from "../chunks/chunk-XYHM4KHC.js";
@@ -20,27 +23,32 @@ import {
20
23
 
21
24
  // src/redact/tokens.ts
22
25
  var MIN_KEY_LENGTH = 32;
26
+ var REDACT_KEY_ENV = "OUTBOUND_REDACT_KEY";
23
27
  var keyedToken = (secret) => {
24
28
  const key = secret === void 0 ? crypto.getRandomValues(new Uint8Array(32)) : new TextEncoder().encode(secret);
25
29
  return (value) => `redacted:${hmacSha256Hex(key, value).slice(0, 16)}`;
26
30
  };
27
- var checkedKey = (key, strategy) => {
28
- if (key === void 0) {
29
- return void 0;
31
+ var checkedKey = (key) => {
32
+ const given = key ?? readEnv(REDACT_KEY_ENV);
33
+ if (given === void 0 || given.length >= MIN_KEY_LENGTH) {
34
+ return given;
30
35
  }
31
- if (strategy !== "mask") {
32
- throw new OutboundError(
33
- "Invalid",
34
- 'redact takes a key only with strategy "mask": "hash" writes the same token without one'
35
- );
36
- }
37
- if (key.length < MIN_KEY_LENGTH) {
38
- throw new OutboundError(
39
- "Invalid",
40
- `The redact key must be at least ${MIN_KEY_LENGTH} characters. It is a secret: make one with \`openssl rand -hex 32\``
41
- );
36
+ const source = key === void 0 ? ` in ${REDACT_KEY_ENV}` : "";
37
+ throw new OutboundError(
38
+ "Invalid",
39
+ `The redact key${source} must be at least ${MIN_KEY_LENGTH} characters. It is a secret: make one with \`openssl rand -hex 32\``
40
+ );
41
+ };
42
+ var KEYLESS_NOTES = {
43
+ hash: `redact's hash strategy has no key, so anyone can compute a token from a guessed email address or profile. Unkeyed hash is deprecated: set ${REDACT_KEY_ENV} or pass redact({ key }) to key it.`,
44
+ mask: `redact has no key, so its tokens for addresses and profiles hold only within this instance or process and do not join across runs. Set ${REDACT_KEY_ENV} or pass redact({ key }) to keep them.`
45
+ };
46
+ var warnedUnkeyedHash = false;
47
+ var warnUnkeyedHash = () => {
48
+ if (!warnedUnkeyedHash) {
49
+ warnedUnkeyedHash = true;
50
+ console.warn(`outbound-sdk: ${KEYLESS_NOTES.hash}`);
42
51
  }
43
- return key;
44
52
  };
45
53
  var KNOWN_TOKENS = 1e4;
46
54
  var TOKEN = /redacted:[0-9a-f]{16}/gu;
@@ -69,6 +77,17 @@ var knownTokens = () => {
69
77
  unmask: (text) => text.replaceAll(TOKEN, (token) => values.get(token)?.value ?? token)
70
78
  };
71
79
  };
80
+ var UNKNOWN_TOKEN_REMEDY = "Redact keeps what each token stands for in memory, only in the process that wrote it, so it is not sent to the vendor. Run the tool that returned it again in this session. The redact key (redact's key option, or OUTBOUND_REDACT_KEY in the environment) keeps tokens the same across runs, so a token you kept matches its records again once they are read in the new session.";
81
+ var refuseUnknownTokens = (operation, provider) => {
82
+ const [token] = JSON.stringify(operation).match(TOKEN) ?? [];
83
+ if (token !== void 0) {
84
+ throw new OutboundError(
85
+ "NotFound",
86
+ `"${token}" is a redacted token from another session or process. ${UNKNOWN_TOKEN_REMEDY}`,
87
+ { provider }
88
+ );
89
+ }
90
+ };
72
91
 
73
92
  // src/redact/plugin.ts
74
93
  var ALL_FIELDS = [
@@ -82,15 +101,18 @@ var ALL_FIELDS = [
82
101
  "subject"
83
102
  ];
84
103
  var MASK = "[redacted]";
85
- var replacer = (strategy) => (value) => {
86
- if (value === null) {
87
- return null;
88
- }
89
- return strategy === "mask" ? MASK : `redacted:${stableId(value).slice(0, 16)}`;
104
+ var replacer = (strategy, secret) => {
105
+ const hashed = secret === void 0 ? (value) => `redacted:${stableId(value).slice(0, 16)}` : keyedToken(secret);
106
+ return (value) => {
107
+ if (value === null) {
108
+ return null;
109
+ }
110
+ return strategy === "mask" ? MASK : hashed(value);
111
+ };
90
112
  };
91
113
  var maskIdentifier = (masks, field, value) => masks.has(field) ? masks.identifier(field, value) : value;
92
114
  var masksFor = (fields, strategy, secret) => {
93
- const replace = replacer(strategy);
115
+ const replace = replacer(strategy, secret);
94
116
  const has = (field) => fields.has(field);
95
117
  const known = knownTokens();
96
118
  if (strategy === "hash") {
@@ -171,13 +193,17 @@ var redactFields = (masks, record) => {
171
193
  return record;
172
194
  }
173
195
  if ("direction" in record) {
174
- return {
196
+ const message = {
175
197
  ...record,
176
198
  bodyHtml: maskIf(masks, "body", record.bodyHtml),
177
199
  bodyText: maskIf(masks, "body", record.bodyText),
178
200
  raw: null,
179
201
  subject: maskIf(masks, "subject", record.subject)
180
202
  };
203
+ if (record.leadEmail !== void 0) {
204
+ message.leadEmail = maskIdentifier(masks, "email", record.leadEmail);
205
+ }
206
+ return message;
181
207
  }
182
208
  if ("custom" in record) {
183
209
  return {
@@ -276,7 +302,12 @@ var unmasked = (known, operation) => {
276
302
  var redact = (options = {}) => {
277
303
  const fields = new Set(options.fields ?? ALL_FIELDS);
278
304
  const strategy = options.strategy ?? "mask";
279
- const masks = masksFor(fields, strategy, checkedKey(options.key, strategy));
305
+ const key = checkedKey(options.key);
306
+ const masks = masksFor(fields, strategy, key);
307
+ const note = key === void 0 ? KEYLESS_NOTES[strategy] : void 0;
308
+ if (strategy === "hash" && key === void 0) {
309
+ warnUnkeyedHash();
310
+ }
280
311
  return {
281
312
  // Asking for bodies while they are being removed is a contradiction, so
282
313
  // the capability is turned off and the request is refused up front.
@@ -302,18 +333,17 @@ var redact = (options = {}) => {
302
333
  }
303
334
  }),
304
335
  name: "redact",
305
- wrap: async (operation, next) => {
336
+ wrap: async (operation, next, info) => {
306
337
  const sent = unmasked(masks.known, operation);
338
+ refuseUnknownTokens(sent, info.provider);
307
339
  let output;
308
340
  try {
309
341
  output = await next(sent);
310
342
  } catch (error) {
311
343
  throw sent !== operation && OutboundError.is(error) ? remasked(masks.known, error) : error;
312
344
  }
313
- return {
314
- ...output,
315
- items: output.items.map((record) => redactRecord(masks, record))
316
- };
345
+ const items = output.items.map((record) => redactRecord(masks, record));
346
+ return note === void 0 || JSON.stringify(items).match(TOKEN) === null ? { ...output, items } : { ...output, items, notes: [...output.notes ?? [], note] };
317
347
  }
318
348
  };
319
349
  };
@@ -322,5 +352,6 @@ export {
322
352
  KNOWN_TOKENS,
323
353
  MASK,
324
354
  MIN_KEY_LENGTH,
355
+ REDACT_KEY_ENV,
325
356
  redact
326
357
  };