outbound-sdk 0.5.0 → 0.7.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 (130) hide show
  1. package/dist/alerts/check-schema.d.ts +1 -1
  2. package/dist/alerts/index.js +6 -6
  3. package/dist/audit/index.js +2 -2
  4. package/dist/benchmarks/index.js +4 -4
  5. package/dist/budget/index.js +2 -2
  6. package/dist/cards/format.d.ts +1 -1
  7. package/dist/cards/index.js +101 -62
  8. package/dist/cards/parts.d.ts +1 -6
  9. package/dist/chunks/{chunk-BLCJHP5H.js → chunk-45TXPJW7.js} +1 -0
  10. package/dist/chunks/chunk-4AVYRVN5.js +239 -0
  11. package/dist/chunks/{chunk-YYCT3NGV.js → chunk-65YAGEWZ.js} +24 -7
  12. package/dist/chunks/{chunk-BN6WCAWX.js → chunk-7I3EPR23.js} +3 -3
  13. package/dist/chunks/{chunk-3S32R2MH.js → chunk-BNDHEDHD.js} +2 -53
  14. package/dist/chunks/chunk-DNPNTD5W.js +81 -0
  15. package/dist/chunks/chunk-FALWG5U3.js +56 -0
  16. package/dist/chunks/{chunk-OLPMBRXM.js → chunk-GL7BABF2.js} +2 -2
  17. package/dist/chunks/{chunk-ZOAG2C6V.js → chunk-HIAK2GCI.js} +9 -2
  18. package/dist/chunks/{chunk-6TKFISG4.js → chunk-I7DXXGNZ.js} +42 -9
  19. package/dist/chunks/{chunk-BK5SLY32.js → chunk-JRL3QRBS.js} +264 -76
  20. package/dist/chunks/{chunk-EHSJGQ5K.js → chunk-KTYTE2BU.js} +4 -3
  21. package/dist/chunks/{chunk-JWGSB7PT.js → chunk-LD6F46UT.js} +2 -2
  22. package/dist/chunks/{chunk-2D42TQFU.js → chunk-LVZGIKNF.js} +2 -2
  23. package/dist/chunks/{chunk-PQSTQKRD.js → chunk-M2VXGLLZ.js} +35 -2
  24. package/dist/chunks/{chunk-5J7GGV62.js → chunk-MW4C6LTN.js} +2 -2
  25. package/dist/chunks/chunk-OK3GAZMT.js +51 -0
  26. package/dist/chunks/{chunk-BOWXGMN3.js → chunk-POBAY3TI.js} +80 -4
  27. package/dist/chunks/{chunk-J7DDZ4C2.js → chunk-QFC4ZHD3.js} +1 -1
  28. package/dist/chunks/{chunk-GFDNRWR3.js → chunk-UFQ4WMLU.js} +1 -1
  29. package/dist/chunks/{chunk-WGW3ROLY.js → chunk-Y7KECJAV.js} +1 -1
  30. package/dist/chunks/{chunk-QAKJ76HB.js → chunk-YW6FFVSZ.js} +1 -1
  31. package/dist/chunks/{chunk-X4RDBD4J.js → chunk-ZJCVLBAE.js} +445 -119
  32. package/dist/cli/bin.js +14 -14
  33. package/dist/cli/by-name.d.ts +28 -0
  34. package/dist/cli/commands.d.ts +2 -1
  35. package/dist/cli/config.d.ts +3 -2
  36. package/dist/cli/envelope.d.ts +50 -0
  37. package/dist/cli/index.d.ts +3 -0
  38. package/dist/cli/index.js +13 -13
  39. package/dist/cli/listing.d.ts +13 -0
  40. package/dist/cli/native.d.ts +4 -0
  41. package/dist/cli/options.d.ts +88 -0
  42. package/dist/cli/output.d.ts +21 -0
  43. package/dist/cli/suggest.d.ts +10 -0
  44. package/dist/clients/index.js +6 -6
  45. package/dist/combine/index.js +7 -7
  46. package/dist/emailbison/capabilities.d.ts +1 -0
  47. package/dist/emailbison/index.js +38 -13
  48. package/dist/emailbison/map-stats.d.ts +10 -0
  49. package/dist/exporter/index.js +2 -2
  50. package/dist/failover/index.js +2 -2
  51. package/dist/fixtures/index.js +4 -4
  52. package/dist/heyreach/capabilities.d.ts +3 -0
  53. package/dist/heyreach/index.js +36 -12
  54. package/dist/heyreach/map-account.d.ts +2 -2
  55. package/dist/identity/index.js +2 -2
  56. package/dist/index.js +9 -7
  57. package/dist/insights/copy/audit-samples.d.ts +24 -0
  58. package/dist/insights/copy/audit-variant.d.ts +34 -0
  59. package/dist/insights/copy/copy-audit.d.ts +26 -12
  60. package/dist/insights/copy/copy-preview.d.ts +71 -0
  61. package/dist/insights/copy/copy-reuse.d.ts +0 -13
  62. package/dist/insights/copy/index.d.ts +15 -0
  63. package/dist/insights/copy/reply-timing.d.ts +4 -0
  64. package/dist/insights/copy/reuse-base.d.ts +0 -2
  65. package/dist/insights/copy/shared.d.ts +7 -9
  66. package/dist/insights/copy/step-funnel.d.ts +21 -18
  67. package/dist/insights/copy/variant-test.d.ts +2 -8
  68. package/dist/insights/index.js +1357 -717
  69. package/dist/insights/inputs.generated.d.ts +67 -34
  70. package/dist/insights/ops/campaign-diagnosis.d.ts +2 -2
  71. package/dist/insights/ops/client-report.d.ts +0 -2
  72. package/dist/insights/ops/diagnosis-checks.d.ts +20 -1
  73. package/dist/insights/ops/index.d.ts +2 -4
  74. package/dist/insights/ops/pipeline-forecast.d.ts +17 -6
  75. package/dist/insights/ops/shared.d.ts +0 -2
  76. package/dist/insights/people/account-summary.d.ts +14 -1
  77. package/dist/insights/people/auto-replies.d.ts +14 -0
  78. package/dist/insights/people/dropped-replies.d.ts +1 -1
  79. package/dist/insights/people/hot-leads.d.ts +5 -1
  80. package/dist/insights/people/index.d.ts +4 -0
  81. package/dist/insights/people/lead-collisions.d.ts +11 -2
  82. package/dist/insights/people/person-summary.d.ts +19 -3
  83. package/dist/insights/people/personalization-gaps.d.ts +14 -8
  84. package/dist/insights/people/suppression-check.d.ts +9 -0
  85. package/dist/insights/registry.d.ts +20 -8
  86. package/dist/insights/senders/bounce-watch.d.ts +0 -11
  87. package/dist/insights/senders/domain-health.d.ts +0 -7
  88. package/dist/insights/senders/index.d.ts +0 -4
  89. package/dist/insights/senders/sender-load.d.ts +0 -2
  90. package/dist/insights/step.d.ts +15 -0
  91. package/dist/insights/types.d.ts +1 -1
  92. package/dist/insights/variables.d.ts +35 -0
  93. package/dist/instantly/capabilities.d.ts +4 -0
  94. package/dist/instantly/index.js +265 -53
  95. package/dist/instantly/map-stats.d.ts +4 -0
  96. package/dist/instantly/stats-tracking.d.ts +19 -0
  97. package/dist/instantly/thread.d.ts +9 -0
  98. package/dist/internal/adapter.d.ts +5 -0
  99. package/dist/internal/auto-reply.d.ts +20 -0
  100. package/dist/internal/capabilities.d.ts +2 -0
  101. package/dist/internal/entities-account.d.ts +1 -0
  102. package/dist/internal/entities.d.ts +79 -2
  103. package/dist/internal/fields.d.ts +37 -1
  104. package/dist/internal/metrics.d.ts +23 -1
  105. package/dist/internal/outbound/api.d.ts +2 -0
  106. package/dist/internal/records.d.ts +2 -2
  107. package/dist/internal/reply-people.d.ts +37 -0
  108. package/dist/internal/runway.d.ts +42 -0
  109. package/dist/internal/sender-screen.d.ts +9 -0
  110. package/dist/internal/tracking.d.ts +33 -0
  111. package/dist/loader/index.js +4 -4
  112. package/dist/memory/data.d.ts +2 -1
  113. package/dist/memory/index.js +23 -12
  114. package/dist/redact/index.js +3 -3
  115. package/dist/smartlead/capabilities.d.ts +4 -0
  116. package/dist/smartlead/index.js +154 -38
  117. package/dist/smartlead/map-account.d.ts +3 -0
  118. package/dist/smartlead/stats-tracking.d.ts +22 -0
  119. package/dist/sync/index.js +2 -2
  120. package/dist/tools/ai-sdk.js +8 -7
  121. package/dist/tools/by-name.d.ts +18 -0
  122. package/dist/tools/campaign-tools.d.ts +6 -2
  123. package/dist/tools/claude-agent.js +8 -7
  124. package/dist/tools/index.js +9 -8
  125. package/dist/tools/shared.d.ts +7 -0
  126. package/dist/tracing/index.js +2 -2
  127. package/dist/webhooks/index.js +12 -10
  128. package/package.json +1 -1
  129. package/dist/chunks/chunk-HWHI4LFY.js +0 -102
  130. package/dist/internal/renamed.d.ts +0 -28
@@ -13,7 +13,15 @@ import {
13
13
  toWorkspace,
14
14
  unwrap,
15
15
  withoutSecrets
16
- } from "../chunks/chunk-EHSJGQ5K.js";
16
+ } from "../chunks/chunk-KTYTE2BU.js";
17
+ import {
18
+ applyTracking,
19
+ ownTracking,
20
+ unlessFailed
21
+ } from "../chunks/chunk-DNPNTD5W.js";
22
+ import {
23
+ detectAutoReply
24
+ } from "../chunks/chunk-OK3GAZMT.js";
17
25
  import {
18
26
  flatMapPage,
19
27
  mapPage,
@@ -23,9 +31,11 @@ import {
23
31
  import {
24
32
  createVendorClient,
25
33
  fromOne,
26
- listIn,
34
+ listIn
35
+ } from "../chunks/chunk-BNDHEDHD.js";
36
+ import {
27
37
  normalizeBody
28
- } from "../chunks/chunk-3S32R2MH.js";
38
+ } from "../chunks/chunk-FALWG5U3.js";
29
39
  import {
30
40
  defineNative,
31
41
  inBody,
@@ -39,18 +49,18 @@ import {
39
49
  recordBase,
40
50
  refTo,
41
51
  refsTo
42
- } from "../chunks/chunk-2D42TQFU.js";
43
- import "../chunks/chunk-BOWXGMN3.js";
52
+ } from "../chunks/chunk-LVZGIKNF.js";
53
+ import "../chunks/chunk-POBAY3TI.js";
44
54
  import {
45
55
  emptyCounts,
46
56
  metricRow
47
- } from "../chunks/chunk-PQSTQKRD.js";
57
+ } from "../chunks/chunk-M2VXGLLZ.js";
48
58
  import {
49
59
  replyCategorySchema
50
60
  } from "../chunks/chunk-QGRZDTX4.js";
51
61
  import {
52
62
  assertWorkspaceId
53
- } from "../chunks/chunk-QAKJ76HB.js";
63
+ } from "../chunks/chunk-YW6FFVSZ.js";
54
64
  import "../chunks/chunk-NAWZ73QS.js";
55
65
  import {
56
66
  stableId
@@ -58,12 +68,12 @@ import {
58
68
  import {
59
69
  readEnv,
60
70
  requireCredential
61
- } from "../chunks/chunk-GFDNRWR3.js";
71
+ } from "../chunks/chunk-UFQ4WMLU.js";
62
72
  import {
63
73
  OutboundError,
64
74
  makeErrorMapper,
65
75
  requireObject
66
- } from "../chunks/chunk-J7DDZ4C2.js";
76
+ } from "../chunks/chunk-QFC4ZHD3.js";
67
77
  import {
68
78
  count,
69
79
  emailAddress,
@@ -78,7 +88,7 @@ import {
78
88
  stringMap,
79
89
  text,
80
90
  timestamp
81
- } from "../chunks/chunk-BLCJHP5H.js";
91
+ } from "../chunks/chunk-45TXPJW7.js";
82
92
 
83
93
  // src/smartlead/capabilities.ts
84
94
  var BASE_URL = "https://server.smartlead.ai/api/v1";
@@ -171,16 +181,28 @@ var capabilities = {
171
181
  workspaces: true
172
182
  };
173
183
  var fields = {
174
- campaignProgress: { failed: false },
184
+ campaignProgress: { failed: false, skipped: false },
175
185
  campaignSettings: { endDate: false },
176
- lead: { companyLinkedinUrl: false, engagement: false, title: false },
177
- message: { variantKey: false },
186
+ lead: {
187
+ companyLinkedinUrl: false,
188
+ engagement: false,
189
+ recipientMailProvider: false,
190
+ title: false
191
+ },
192
+ // A message is not marked automatic; a reply is.
193
+ message: { isAuto: false, isAutoSource: false, variantKey: false },
178
194
  metricRow: {
195
+ completed: false,
179
196
  connectionsAccepted: false,
180
197
  connectionsSent: false,
181
198
  contentHash: false,
182
199
  delivered: false,
183
200
  inmailsSent: false,
201
+ leads: false,
202
+ opportunities: false,
203
+ opportunityValue: false,
204
+ repliedAutoTotal: false,
205
+ repliedTotal: false,
184
206
  // total_reply_count less non_ooo_reply_count.
185
207
  repliedAuto: "derived"
186
208
  },
@@ -190,8 +212,10 @@ var fields = {
190
212
  // The lead's category, not a label on the message.
191
213
  category: "derived",
192
214
  categorySource: "derived",
193
- // Only an Out Of Office category says a reply was automatic.
215
+ // An Out Of Office category, or a fixed rule on the subject and body.
194
216
  isAuto: "derived",
217
+ isAutoSource: "derived",
218
+ leftCompany: "derived",
195
219
  // The master inbox does not say which step a reply answers.
196
220
  stepIndex: false,
197
221
  variantKey: false
@@ -215,6 +239,8 @@ var costs = {
215
239
  "campaigns.get": { perPage: 1 },
216
240
  // One request returns every campaign; there are no pages.
217
241
  "campaigns.list": { perPage: 1 },
242
+ // The campaign's top-level analytics.
243
+ "campaigns.progress": { perPage: 1 },
218
244
  "campaigns.settings": { perPage: 1 },
219
245
  // The lead, then its tags, then the category list when the lead has a
220
246
  // category.
@@ -238,7 +264,9 @@ var costs = {
238
264
  "sequence.subsequences": { pageSize: 1, perPage: 1, perWalk: 1 },
239
265
  // A mailbox's totals cost two: the mailbox for its address, then the list.
240
266
  // Daily rows cost two: the day-wise counts, then the positive replies.
241
- stats: { perPage: 1 },
267
+ // The counts (1 or 2 requests), then the tracking settings: the campaign,
268
+ // or for a workspace or mailbox the per-campaign report and the campaign list.
269
+ stats: { perPage: 2, perPageAtMost: 4 },
242
270
  "tags.list": { perPage: 1 },
243
271
  // One campaign per page; without a campaign, the first page also reads the
244
272
  // campaign list.
@@ -255,7 +283,7 @@ var caveats = [
255
283
  "leads.list({ email }) reads GET /leads/?email=: one record per campaign, all with the lead's id (listAll keeps one), status unknown unless unsubscribed, createdAt the lead's own. Address matching is undocumented; other addresses are dropped.",
256
284
  "No endpoint finds a lead by LinkedIn profile: leads.list({ linkedinUrl }) returns nothing and sends no request.",
257
285
  "A lead's status, campaign and creation time are per campaign; leads.get returns no campaign and its example looks illustrative.",
258
- "STOPPED maps to paused. A lead's status BLOCKED, which Smartlead describes as bounced or on the block list, sets bounced and leaves progress unknown. unsubscribed is is_unsubscribed. replied is email_stats.is_replied, which only leads.get carries, so a listed lead's replied is null.",
286
+ "STOPPED maps to paused. A lead's status BLOCKED, which Smartlead describes as bounced or on the block list, sets bounced and leaves progress unknown. A block-listed lead that was never sent to is therefore counted as bounced too: no documented lead field tells the two apart (email_stats.is_bounced and last_sent_time appear only on a reference page whose shape conflicts with the others), and the block list itself takes entries from bounces. Read from the documentation on 2026-11-16 only. unsubscribed is is_unsubscribed. replied is email_stats.is_replied, which only leads.get carries, so a listed lead's replied is null.",
259
287
  "Messages come from GET /campaigns/all-leads-activities (10 requests per 60 s, no campaign filter, pages of leads): campaign(id).messages reads the whole feed, and thread_replies is not read.",
260
288
  "senderRef is null on feed and history messages (mailbox named by address). leadRef on replies and thread messages needs lead.id or lead_id on the thread; documented examples show an address only.",
261
289
  "threadId is the lead-in-campaign mapping id; history messages have none. GET /master-inbox/{id} is documented without message ids or bodies; older history items are accepted too.",
@@ -315,6 +343,10 @@ var tracked = (value, off) => {
315
343
  const settings = parsed(value);
316
344
  return isJsonArray(settings) ? !settings.some((setting) => isString(setting) && setting.endsWith(off)) : null;
317
345
  };
346
+ var trackingFlags = (raw) => ({
347
+ clicks: tracked(raw.track_settings, "LINK_CLICK"),
348
+ opens: tracked(raw.track_settings, "EMAIL_OPEN")
349
+ });
318
350
  var STOP_ON_REPLY = /* @__PURE__ */ new Map([
319
351
  ["NEVER", false],
320
352
  ["REPLY_TO_AN_EMAIL", true]
@@ -344,10 +376,7 @@ var toSettings = (identity, campaignId, raw) => {
344
376
  startDate: timestamp(raw.schedule_start_time)?.slice(0, 10) ?? null,
345
377
  stopOnAutoReply: stopOnAutoReply(raw, stopOnReply),
346
378
  stopOnReply,
347
- tracking: {
348
- clicks: tracked(raw.track_settings, "LINK_CLICK"),
349
- opens: tracked(raw.track_settings, "EMAIL_OPEN")
350
- }
379
+ tracking: trackingFlags(raw)
351
380
  };
352
381
  };
353
382
  var toCampaignProgress = (identity, campaignId, raw) => {
@@ -362,6 +391,9 @@ var toCampaignProgress = (identity, campaignId, raw) => {
362
391
  inProgress: count(field(stats, "inprogress")),
363
392
  leads: count(field(stats, "total")),
364
393
  notStarted: count(field(stats, "notStarted")),
394
+ // campaign_lead_stats has no skipped count; a block-listed lead is in
395
+ // blocked, which cannot be told apart from a bounce.
396
+ skipped: null,
365
397
  stopped: count(field(stats, "stopped"))
366
398
  };
367
399
  };
@@ -638,17 +670,26 @@ var toInboxReplies = (identity, item, categories, includeBody) => {
638
670
  }
639
671
  ];
640
672
  const read = flag(item.is_read);
641
- return parts.map((part) => ({
642
- ...messageFields(identity, place, part, includeBody),
643
- category: category ?? "unknown",
644
- // The category is the lead's, not one message's.
645
- categorySource: category === void 0 ? null : "lead",
646
- direction: "in",
647
- // Smartlead's only automatic-reply signal is the Out Of Office category.
648
- isAuto: category === "ooo" ? true : null,
649
- // `is_read` is the thread's.
650
- unread: read === null ? null : !read
651
- }));
673
+ return parts.map((part) => {
674
+ const verdict = detectAutoReply({
675
+ body: part.body,
676
+ from: null,
677
+ subject: part.subject
678
+ });
679
+ const vendor = category === "ooo";
680
+ return {
681
+ ...messageFields(identity, place, part, includeBody),
682
+ category: category ?? "unknown",
683
+ // The category is the lead's, not one message's.
684
+ categorySource: category === void 0 ? null : "lead",
685
+ direction: "in",
686
+ isAuto: vendor || verdict.isAuto,
687
+ isAutoSource: vendor ? "vendor" : "rule",
688
+ leftCompany: verdict.leftCompany,
689
+ // `is_read` is the thread's.
690
+ unread: read === null ? null : !read
691
+ };
692
+ });
652
693
  };
653
694
 
654
695
  // src/smartlead/shared.ts
@@ -1253,6 +1294,60 @@ var stepRows = (scope, step) => {
1253
1294
  );
1254
1295
  };
1255
1296
 
1297
+ // src/smartlead/stats-tracking.ts
1298
+ var UNKNOWN = { clicks: null, opens: null };
1299
+ var campaignFlags = async (client, ctx, campaignId) => await unlessFailed(
1300
+ async () => trackingFlags(
1301
+ objectOf(
1302
+ client,
1303
+ await client.get(ctx, `/campaigns/${encodeURIComponent(campaignId)}`),
1304
+ "the campaign"
1305
+ )
1306
+ )
1307
+ );
1308
+ var everyCampaignFlags = async (client, ctx) => await unlessFailed(async () => {
1309
+ const campaigns = await campaignList(client, ctx);
1310
+ return new Map(
1311
+ campaigns.flatMap((campaign) => {
1312
+ const id = text(campaign.id);
1313
+ return id === null ? [] : [[id, trackingFlags(campaign)]];
1314
+ })
1315
+ );
1316
+ });
1317
+ var plus = (left, right) => left === null && right === null ? null : (left ?? 0) + (right ?? 0);
1318
+ var reportTracking = (raw, flags) => ({
1319
+ clicked: null,
1320
+ flags: flags ?? UNKNOWN,
1321
+ opened: plus(count(raw.unique_open_count), count(raw.opened)),
1322
+ sent: count(raw.sent)
1323
+ });
1324
+ var workspaceTracking = async (client, ctx, range) => {
1325
+ const report2 = await unlessFailed(
1326
+ async () => objects(
1327
+ field(
1328
+ objectOf(
1329
+ client,
1330
+ await client.get(ctx, "/analytics/campaign/overall-stats", {
1331
+ query: {
1332
+ end_date: range.to,
1333
+ full_data: true,
1334
+ start_date: range.from,
1335
+ timezone: TIMEZONE
1336
+ }
1337
+ }),
1338
+ "campaign performance"
1339
+ ),
1340
+ "campaign_wise_performance"
1341
+ )
1342
+ )
1343
+ );
1344
+ if (report2 === null) {
1345
+ return null;
1346
+ }
1347
+ const flags = await everyCampaignFlags(client, ctx);
1348
+ return flags === null ? null : report2.map((raw) => reportTracking(raw, flags.get(text(raw.id) ?? "")));
1349
+ };
1350
+
1256
1351
  // src/smartlead/stats.ts
1257
1352
  var DAY_MS2 = 864e5;
1258
1353
  var LIFETIME_START = "2000-01-01";
@@ -1344,14 +1439,20 @@ var everyCampaign = async (client, ctx, query) => {
1344
1439
  objectOf(client, body, "campaign performance"),
1345
1440
  "campaign_wise_performance"
1346
1441
  );
1442
+ const flags = await everyCampaignFlags(client, ctx);
1347
1443
  return objects(campaigns).flatMap((campaign) => {
1348
1444
  const scopeId = text(campaign.id);
1349
- return scopeId === null ? [] : [
1350
- overallRow(
1351
- { ...client.identity, scope: "campaign", scopeId },
1352
- campaign
1353
- )
1354
- ];
1445
+ if (scopeId === null) {
1446
+ return [];
1447
+ }
1448
+ const row = overallRow(
1449
+ { ...client.identity, scope: "campaign", scopeId },
1450
+ campaign
1451
+ );
1452
+ return applyTracking(
1453
+ [row],
1454
+ flags === null ? null : [{ ...reportTracking(campaign, flags.get(scopeId)), sent: null }]
1455
+ );
1355
1456
  });
1356
1457
  };
1357
1458
  var stepTotals = async (client, ctx, scope, query) => {
@@ -1398,7 +1499,7 @@ var senderTotal = async (client, ctx, scope, query) => {
1398
1499
  )
1399
1500
  ];
1400
1501
  };
1401
- var readStats = async (client, ctx, query) => {
1502
+ var readCounts = async (client, ctx, query) => {
1402
1503
  const scope = {
1403
1504
  ...client.identity,
1404
1505
  scope: query.scope,
@@ -1427,6 +1528,21 @@ var readStats = async (client, ctx, query) => {
1427
1528
  }
1428
1529
  return query.scope === "campaign" ? await campaignTotal(client, ctx, scope, query) : await workspaceTotal(client, ctx, scope, query);
1429
1530
  };
1531
+ var judged = async (client, ctx, query, rows) => {
1532
+ if (query.scope === "campaign" || query.scope === "step") {
1533
+ if (query.scopeId === void 0) {
1534
+ return rows;
1535
+ }
1536
+ const flags = await campaignFlags(client, ctx, query.scopeId);
1537
+ return applyTracking(
1538
+ rows,
1539
+ flags === null ? null : [ownTracking(flags, rows)]
1540
+ );
1541
+ }
1542
+ const range = resolveRange(query, query.by === "day");
1543
+ return applyTracking(rows, await workspaceTracking(client, ctx, range));
1544
+ };
1545
+ var readStats = async (client, ctx, query) => await judged(client, ctx, query, await readCounts(client, ctx, query));
1430
1546
 
1431
1547
  // src/smartlead/adapter.ts
1432
1548
  var listSenders = async (client, ctx, query) => {
@@ -1,6 +1,9 @@
1
1
  import type { BlockEntry, CampaignProgress, CampaignSettings, LeadList, PlacementTest, SenderHealth, Tag, WebhookSubscription } from "../internal/entities-account.ts";
2
2
  import type { Json, JsonObject } from "../internal/json.ts";
3
3
  import type { Identity } from "../internal/record.ts";
4
+ import type { TrackingFlags } from "../internal/tracking.ts";
5
+ /** Open and link tracking from a campaign's `track_settings`. */
6
+ export declare const trackingFlags: (raw: JsonObject) => TrackingFlags;
4
7
  /** `GET /campaigns/{id}` -> how the campaign is set up to send. */
5
8
  export declare const toSettings: (identity: Identity, campaignId: string, raw: JsonObject) => CampaignSettings;
6
9
  /**
@@ -0,0 +1,22 @@
1
+ import type { AdapterContext } from "../internal/adapter.ts";
2
+ import type { JsonObject } from "../internal/json.ts";
3
+ import type { CampaignTracking, TrackingFlags } from "../internal/tracking.ts";
4
+ import type { SmartleadClient } from "./client.ts";
5
+ /** One campaign's settings, or `null` when they could not be read. */
6
+ export declare const campaignFlags: (client: SmartleadClient, ctx: AdapterContext, campaignId: string) => Promise<TrackingFlags | null>;
7
+ /** Every campaign's settings by id, or `null` when the list failed. */
8
+ export declare const everyCampaignFlags: (client: SmartleadClient, ctx: AdapterContext) => Promise<Map<string, TrackingFlags> | null>;
9
+ /**
10
+ * One campaign's row of the per-campaign report with its settings. The
11
+ * report has no click count, so a campaign with link tracking off counts as
12
+ * not measuring clicks.
13
+ */
14
+ export declare const reportTracking: (raw: JsonObject, flags: TrackingFlags | undefined) => CampaignTracking;
15
+ /**
16
+ * Every campaign behind a workspace or mailbox total over the range, or
17
+ * `null` when either read failed.
18
+ */
19
+ export declare const workspaceTracking: (client: SmartleadClient, ctx: AdapterContext, range: {
20
+ readonly from: string;
21
+ readonly to: string;
22
+ }) => Promise<CampaignTracking[] | null>;
@@ -3,8 +3,8 @@ import {
3
3
  } from "../chunks/chunk-FHKSLCVW.js";
4
4
  import {
5
5
  OutboundError
6
- } from "../chunks/chunk-J7DDZ4C2.js";
7
- import "../chunks/chunk-BLCJHP5H.js";
6
+ } from "../chunks/chunk-QFC4ZHD3.js";
7
+ import "../chunks/chunk-45TXPJW7.js";
8
8
 
9
9
  // src/sync/plugin.ts
10
10
  var memoryCheckpointStore = () => {
@@ -1,16 +1,17 @@
1
1
  import {
2
2
  createTools
3
- } from "../chunks/chunk-BK5SLY32.js";
4
- import "../chunks/chunk-HWHI4LFY.js";
3
+ } from "../chunks/chunk-JRL3QRBS.js";
4
+ import "../chunks/chunk-4AVYRVN5.js";
5
+ import "../chunks/chunk-4PA526S7.js";
5
6
  import "../chunks/chunk-HZCTYL22.js";
6
7
  import "../chunks/chunk-HPNGSG5E.js";
7
8
  import "../chunks/chunk-PTZO4QXR.js";
8
- import "../chunks/chunk-BOWXGMN3.js";
9
- import "../chunks/chunk-PQSTQKRD.js";
9
+ import "../chunks/chunk-POBAY3TI.js";
10
+ import "../chunks/chunk-M2VXGLLZ.js";
10
11
  import "../chunks/chunk-QGRZDTX4.js";
11
- import "../chunks/chunk-QAKJ76HB.js";
12
- import "../chunks/chunk-J7DDZ4C2.js";
13
- import "../chunks/chunk-BLCJHP5H.js";
12
+ import "../chunks/chunk-YW6FFVSZ.js";
13
+ import "../chunks/chunk-QFC4ZHD3.js";
14
+ import "../chunks/chunk-45TXPJW7.js";
14
15
 
15
16
  // src/tools/ai-sdk.ts
16
17
  import { jsonSchema, tool } from "ai";
@@ -0,0 +1,18 @@
1
+ import type { ListAll, OutboundApi } from "../internal/outbound/api.ts";
2
+ /**
3
+ * Whether `value` is surely a ref or an id, so it is used with no lookup: a
4
+ * ref, an id in the vendor's documented form, or, on an instance whose id
5
+ * form is not known (a test adapter, your own adapter), any text without a
6
+ * space, as before names were accepted.
7
+ */
8
+ export declare const isIdentifier: (outbound: OutboundApi, value: string) => boolean;
9
+ /** Reads a whole listing. An insight passes its own, which counts the requests. */
10
+ export type ReadAll = <Item>(walk: ListAll<Item>) => Promise<Item[]>;
11
+ /** A campaign's ref or id as given, or the ref of the campaign it names. */
12
+ export declare const resolveCampaign: (outbound: OutboundApi, value: string, read?: ReadAll) => Promise<string>;
13
+ /** A lead list's ref or id as given, or the ref of the list it names. */
14
+ export declare const resolveList: (outbound: OutboundApi, value: string) => Promise<string>;
15
+ /** Whether the input's `campaign` is a name, which costs a campaign listing to look up. */
16
+ export declare const namesCampaign: <Input>(outbound: OutboundApi, input: Input) => boolean;
17
+ /** The input with its `campaign`, when it is text, resolved to a ref or id. */
18
+ export declare const withCampaign: <Input>(outbound: OutboundApi, input: Input, read?: ReadAll) => Promise<Input>;
@@ -16,7 +16,7 @@ declare const overviewInput: z.ZodObject<{
16
16
  export declare const campaignOverview: ToolDefinition<z.infer<typeof overviewInput>>;
17
17
  declare const trendInput: z.ZodObject<{
18
18
  campaign: z.ZodString;
19
- from: z.ZodString;
19
+ from: z.ZodOptional<z.ZodString>;
20
20
  metric: z.ZodDefault<z.ZodEnum<{
21
21
  positive: "positive";
22
22
  bounced: "bounced";
@@ -27,7 +27,7 @@ declare const trendInput: z.ZodObject<{
27
27
  opened: "opened";
28
28
  sent: "sent";
29
29
  }>>;
30
- to: z.ZodString;
30
+ to: z.ZodOptional<z.ZodString>;
31
31
  }, z.core.$strip>;
32
32
  export declare const campaignTrend: ToolDefinition<z.infer<typeof trendInput>>;
33
33
  declare const stepsInput: z.ZodObject<{
@@ -42,6 +42,10 @@ declare const healthInput: z.ZodObject<{
42
42
  export declare const senderHealth: ToolDefinition<z.infer<typeof healthInput>>;
43
43
  declare const samplesInput: z.ZodObject<{
44
44
  campaign: z.ZodOptional<z.ZodString>;
45
+ by: z.ZodDefault<z.ZodEnum<{
46
+ message: "message";
47
+ person: "person";
48
+ }>>;
45
49
  category: z.ZodOptional<z.ZodEnum<{
46
50
  unknown: "unknown";
47
51
  bounce: "bounce";
@@ -1,16 +1,17 @@
1
1
  import {
2
2
  createTools
3
- } from "../chunks/chunk-BK5SLY32.js";
4
- import "../chunks/chunk-HWHI4LFY.js";
3
+ } from "../chunks/chunk-JRL3QRBS.js";
4
+ import "../chunks/chunk-4AVYRVN5.js";
5
+ import "../chunks/chunk-4PA526S7.js";
5
6
  import "../chunks/chunk-HZCTYL22.js";
6
7
  import "../chunks/chunk-HPNGSG5E.js";
7
8
  import "../chunks/chunk-PTZO4QXR.js";
8
- import "../chunks/chunk-BOWXGMN3.js";
9
- import "../chunks/chunk-PQSTQKRD.js";
9
+ import "../chunks/chunk-POBAY3TI.js";
10
+ import "../chunks/chunk-M2VXGLLZ.js";
10
11
  import "../chunks/chunk-QGRZDTX4.js";
11
- import "../chunks/chunk-QAKJ76HB.js";
12
- import "../chunks/chunk-J7DDZ4C2.js";
13
- import "../chunks/chunk-BLCJHP5H.js";
12
+ import "../chunks/chunk-YW6FFVSZ.js";
13
+ import "../chunks/chunk-QFC4ZHD3.js";
14
+ import "../chunks/chunk-45TXPJW7.js";
14
15
 
15
16
  // src/tools/claude-agent.ts
16
17
  import { createSdkMcpServer, tool } from "@anthropic-ai/claude-agent-sdk";
@@ -1,24 +1,25 @@
1
1
  import {
2
2
  openaiTools
3
- } from "../chunks/chunk-OLPMBRXM.js";
3
+ } from "../chunks/chunk-GL7BABF2.js";
4
4
  import {
5
5
  TOOL_NAMES,
6
6
  createTools
7
- } from "../chunks/chunk-BK5SLY32.js";
7
+ } from "../chunks/chunk-JRL3QRBS.js";
8
8
  import {
9
9
  DEFAULT_BODY_CHARS,
10
10
  DEFAULT_TOOL_REQUESTS,
11
11
  UNTRUSTED_NOTE
12
- } from "../chunks/chunk-HWHI4LFY.js";
12
+ } from "../chunks/chunk-4AVYRVN5.js";
13
+ import "../chunks/chunk-4PA526S7.js";
13
14
  import "../chunks/chunk-HZCTYL22.js";
14
15
  import "../chunks/chunk-HPNGSG5E.js";
15
16
  import "../chunks/chunk-PTZO4QXR.js";
16
- import "../chunks/chunk-BOWXGMN3.js";
17
- import "../chunks/chunk-PQSTQKRD.js";
17
+ import "../chunks/chunk-POBAY3TI.js";
18
+ import "../chunks/chunk-M2VXGLLZ.js";
18
19
  import "../chunks/chunk-QGRZDTX4.js";
19
- import "../chunks/chunk-QAKJ76HB.js";
20
- import "../chunks/chunk-J7DDZ4C2.js";
21
- import "../chunks/chunk-BLCJHP5H.js";
20
+ import "../chunks/chunk-YW6FFVSZ.js";
21
+ import "../chunks/chunk-QFC4ZHD3.js";
22
+ import "../chunks/chunk-45TXPJW7.js";
22
23
  export {
23
24
  DEFAULT_BODY_CHARS,
24
25
  DEFAULT_TOOL_REQUESTS,
@@ -18,6 +18,13 @@ export interface ToolSuccess {
18
18
  * otherwise guesses the range it asks for.
19
19
  */
20
20
  readonly today?: string | undefined;
21
+ /**
22
+ * `false` when the answer covers part of what was asked, for example
23
+ * when `limit` cut a list or a cap stopped a read; `notes` says why.
24
+ */
25
+ readonly complete: boolean;
26
+ /** What to know before trusting the answer, for example what was left out. */
27
+ readonly notes: readonly string[];
21
28
  };
22
29
  /** What to ask next. */
23
30
  readonly next: string;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  OutboundError
3
- } from "../chunks/chunk-J7DDZ4C2.js";
4
- import "../chunks/chunk-BLCJHP5H.js";
3
+ } from "../chunks/chunk-QFC4ZHD3.js";
4
+ import "../chunks/chunk-45TXPJW7.js";
5
5
 
6
6
  // src/tracing/index.ts
7
7
  var OK = 1;
@@ -1,32 +1,34 @@
1
1
  import {
2
2
  instantlyEvents
3
- } from "../chunks/chunk-BN6WCAWX.js";
3
+ } from "../chunks/chunk-7I3EPR23.js";
4
4
  import {
5
5
  smartleadEvents
6
- } from "../chunks/chunk-EHSJGQ5K.js";
6
+ } from "../chunks/chunk-KTYTE2BU.js";
7
7
  import {
8
8
  heyreachEvents
9
- } from "../chunks/chunk-JWGSB7PT.js";
9
+ } from "../chunks/chunk-LD6F46UT.js";
10
10
  import {
11
11
  emailbisonEvents
12
- } from "../chunks/chunk-6TKFISG4.js";
13
- import "../chunks/chunk-3S32R2MH.js";
14
- import "../chunks/chunk-2D42TQFU.js";
15
- import "../chunks/chunk-BOWXGMN3.js";
12
+ } from "../chunks/chunk-I7DXXGNZ.js";
13
+ import "../chunks/chunk-OK3GAZMT.js";
14
+ import "../chunks/chunk-BNDHEDHD.js";
15
+ import "../chunks/chunk-FALWG5U3.js";
16
+ import "../chunks/chunk-LVZGIKNF.js";
17
+ import "../chunks/chunk-POBAY3TI.js";
16
18
  import {
17
19
  SCHEMA_VERSION
18
20
  } from "../chunks/chunk-QGRZDTX4.js";
19
- import "../chunks/chunk-QAKJ76HB.js";
21
+ import "../chunks/chunk-YW6FFVSZ.js";
20
22
  import "../chunks/chunk-NAWZ73QS.js";
21
23
  import {
22
24
  stableId
23
25
  } from "../chunks/chunk-FHKSLCVW.js";
24
26
  import {
25
27
  OutboundError
26
- } from "../chunks/chunk-J7DDZ4C2.js";
28
+ } from "../chunks/chunk-QFC4ZHD3.js";
27
29
  import {
28
30
  parseJson
29
- } from "../chunks/chunk-BLCJHP5H.js";
31
+ } from "../chunks/chunk-45TXPJW7.js";
30
32
 
31
33
  // src/webhooks/secret.ts
32
34
  var encoder = new TextEncoder();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "outbound-sdk",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "One small, typed, read-only API over outbound sending tools.",
5
5
  "keywords": [
6
6
  "cold-email",