outbound-sdk 0.6.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 (118) 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/index.js +54 -44
  7. package/dist/chunks/{chunk-BLCJHP5H.js → chunk-45TXPJW7.js} +1 -0
  8. package/dist/chunks/chunk-4AVYRVN5.js +239 -0
  9. package/dist/chunks/{chunk-YYCT3NGV.js → chunk-65YAGEWZ.js} +24 -7
  10. package/dist/chunks/{chunk-W22SDX6S.js → chunk-7I3EPR23.js} +3 -3
  11. package/dist/chunks/{chunk-MGR6HREO.js → chunk-BNDHEDHD.js} +2 -2
  12. package/dist/chunks/chunk-DNPNTD5W.js +81 -0
  13. package/dist/chunks/{chunk-53DCVFUB.js → chunk-FALWG5U3.js} +1 -0
  14. package/dist/chunks/{chunk-OLPMBRXM.js → chunk-GL7BABF2.js} +2 -2
  15. package/dist/chunks/{chunk-ZOAG2C6V.js → chunk-HIAK2GCI.js} +9 -2
  16. package/dist/chunks/{chunk-SXGCKCAR.js → chunk-I7DXXGNZ.js} +40 -9
  17. package/dist/chunks/{chunk-BK5SLY32.js → chunk-JRL3QRBS.js} +264 -76
  18. package/dist/chunks/{chunk-PHNQ3WC2.js → chunk-KTYTE2BU.js} +4 -3
  19. package/dist/chunks/{chunk-JWGSB7PT.js → chunk-LD6F46UT.js} +2 -2
  20. package/dist/chunks/{chunk-2D42TQFU.js → chunk-LVZGIKNF.js} +2 -2
  21. package/dist/chunks/{chunk-PQSTQKRD.js → chunk-M2VXGLLZ.js} +35 -2
  22. package/dist/chunks/{chunk-UWUPUMM2.js → chunk-MW4C6LTN.js} +2 -2
  23. package/dist/chunks/chunk-OK3GAZMT.js +51 -0
  24. package/dist/chunks/{chunk-BOWXGMN3.js → chunk-POBAY3TI.js} +80 -4
  25. package/dist/chunks/{chunk-J7DDZ4C2.js → chunk-QFC4ZHD3.js} +1 -1
  26. package/dist/chunks/{chunk-GFDNRWR3.js → chunk-UFQ4WMLU.js} +1 -1
  27. package/dist/chunks/{chunk-TFICTGM2.js → chunk-Y7KECJAV.js} +1 -1
  28. package/dist/chunks/{chunk-QAKJ76HB.js → chunk-YW6FFVSZ.js} +1 -1
  29. package/dist/chunks/{chunk-3JOC5DGD.js → chunk-ZJCVLBAE.js} +424 -117
  30. package/dist/cli/bin.js +14 -14
  31. package/dist/cli/by-name.d.ts +28 -0
  32. package/dist/cli/commands.d.ts +2 -1
  33. package/dist/cli/config.d.ts +3 -2
  34. package/dist/cli/envelope.d.ts +50 -0
  35. package/dist/cli/index.d.ts +3 -0
  36. package/dist/cli/index.js +13 -13
  37. package/dist/cli/listing.d.ts +13 -0
  38. package/dist/cli/native.d.ts +4 -0
  39. package/dist/cli/options.d.ts +88 -0
  40. package/dist/cli/output.d.ts +13 -1
  41. package/dist/cli/suggest.d.ts +10 -0
  42. package/dist/clients/index.js +6 -6
  43. package/dist/combine/index.js +7 -7
  44. package/dist/emailbison/capabilities.d.ts +1 -0
  45. package/dist/emailbison/index.js +38 -14
  46. package/dist/emailbison/map-stats.d.ts +10 -0
  47. package/dist/exporter/index.js +2 -2
  48. package/dist/failover/index.js +2 -2
  49. package/dist/fixtures/index.js +4 -4
  50. package/dist/heyreach/capabilities.d.ts +3 -0
  51. package/dist/heyreach/index.js +34 -12
  52. package/dist/heyreach/map-account.d.ts +2 -2
  53. package/dist/identity/index.js +2 -2
  54. package/dist/index.js +9 -7
  55. package/dist/insights/copy/audit-samples.d.ts +24 -0
  56. package/dist/insights/copy/audit-variant.d.ts +34 -0
  57. package/dist/insights/copy/copy-audit.d.ts +26 -12
  58. package/dist/insights/copy/copy-preview.d.ts +16 -3
  59. package/dist/insights/copy/index.d.ts +6 -0
  60. package/dist/insights/copy/reply-timing.d.ts +4 -0
  61. package/dist/insights/copy/shared.d.ts +4 -1
  62. package/dist/insights/copy/step-funnel.d.ts +20 -6
  63. package/dist/insights/copy/variant-test.d.ts +2 -3
  64. package/dist/insights/index.js +1138 -589
  65. package/dist/insights/inputs.generated.d.ts +47 -11
  66. package/dist/insights/ops/campaign-diagnosis.d.ts +2 -0
  67. package/dist/insights/ops/diagnosis-checks.d.ts +20 -1
  68. package/dist/insights/ops/index.d.ts +2 -0
  69. package/dist/insights/ops/pipeline-forecast.d.ts +17 -6
  70. package/dist/insights/people/account-summary.d.ts +14 -1
  71. package/dist/insights/people/auto-replies.d.ts +14 -0
  72. package/dist/insights/people/dropped-replies.d.ts +1 -1
  73. package/dist/insights/people/hot-leads.d.ts +5 -1
  74. package/dist/insights/people/index.d.ts +4 -0
  75. package/dist/insights/people/lead-collisions.d.ts +11 -2
  76. package/dist/insights/people/person-summary.d.ts +19 -3
  77. package/dist/insights/people/personalization-gaps.d.ts +14 -8
  78. package/dist/insights/people/suppression-check.d.ts +9 -0
  79. package/dist/insights/registry.d.ts +12 -0
  80. package/dist/insights/step.d.ts +15 -0
  81. package/dist/insights/variables.d.ts +2 -0
  82. package/dist/instantly/capabilities.d.ts +4 -0
  83. package/dist/instantly/index.js +263 -53
  84. package/dist/instantly/map-stats.d.ts +4 -0
  85. package/dist/instantly/stats-tracking.d.ts +19 -0
  86. package/dist/instantly/thread.d.ts +9 -0
  87. package/dist/internal/adapter.d.ts +5 -0
  88. package/dist/internal/auto-reply.d.ts +20 -0
  89. package/dist/internal/capabilities.d.ts +2 -0
  90. package/dist/internal/entities-account.d.ts +1 -0
  91. package/dist/internal/entities.d.ts +79 -2
  92. package/dist/internal/fields.d.ts +37 -1
  93. package/dist/internal/metrics.d.ts +23 -1
  94. package/dist/internal/outbound/api.d.ts +2 -0
  95. package/dist/internal/records.d.ts +2 -2
  96. package/dist/internal/reply-people.d.ts +37 -0
  97. package/dist/internal/runway.d.ts +42 -0
  98. package/dist/internal/sender-screen.d.ts +9 -0
  99. package/dist/internal/tracking.d.ts +33 -0
  100. package/dist/loader/index.js +4 -4
  101. package/dist/memory/data.d.ts +2 -1
  102. package/dist/memory/index.js +23 -12
  103. package/dist/redact/index.js +3 -3
  104. package/dist/smartlead/capabilities.d.ts +4 -0
  105. package/dist/smartlead/index.js +152 -38
  106. package/dist/smartlead/map-account.d.ts +3 -0
  107. package/dist/smartlead/stats-tracking.d.ts +22 -0
  108. package/dist/sync/index.js +2 -2
  109. package/dist/tools/ai-sdk.js +8 -7
  110. package/dist/tools/by-name.d.ts +18 -0
  111. package/dist/tools/campaign-tools.d.ts +6 -2
  112. package/dist/tools/claude-agent.js +8 -7
  113. package/dist/tools/index.js +9 -8
  114. package/dist/tools/shared.d.ts +7 -0
  115. package/dist/tracing/index.js +2 -2
  116. package/dist/webhooks/index.js +12 -11
  117. package/package.json +1 -1
  118. package/dist/chunks/chunk-HWHI4LFY.js +0 -102
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  makeRef,
3
3
  parseRef
4
- } from "../chunks/chunk-QAKJ76HB.js";
4
+ } from "../chunks/chunk-YW6FFVSZ.js";
5
5
  import {
6
6
  profileSlug
7
7
  } from "../chunks/chunk-NAWZ73QS.js";
@@ -10,12 +10,12 @@ import {
10
10
  } from "../chunks/chunk-FHKSLCVW.js";
11
11
  import {
12
12
  OutboundError
13
- } from "../chunks/chunk-J7DDZ4C2.js";
13
+ } from "../chunks/chunk-QFC4ZHD3.js";
14
14
  import {
15
15
  isJsonArray,
16
16
  isJsonObject,
17
17
  isString
18
- } from "../chunks/chunk-BLCJHP5H.js";
18
+ } from "../chunks/chunk-45TXPJW7.js";
19
19
 
20
20
  // src/redact/plugin.ts
21
21
  var ALL_FIELDS = [
@@ -32,6 +32,9 @@ export declare const costs: {
32
32
  "campaigns.list": {
33
33
  perPage: number;
34
34
  };
35
+ "campaigns.progress": {
36
+ perPage: number;
37
+ };
35
38
  "campaigns.settings": {
36
39
  perPage: number;
37
40
  };
@@ -77,6 +80,7 @@ export declare const costs: {
77
80
  };
78
81
  stats: {
79
82
  perPage: number;
83
+ perPageAtMost: number;
80
84
  };
81
85
  "tags.list": {
82
86
  perPage: number;
@@ -13,7 +13,15 @@ import {
13
13
  toWorkspace,
14
14
  unwrap,
15
15
  withoutSecrets
16
- } from "../chunks/chunk-PHNQ3WC2.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,
@@ -24,10 +32,10 @@ import {
24
32
  createVendorClient,
25
33
  fromOne,
26
34
  listIn
27
- } from "../chunks/chunk-MGR6HREO.js";
35
+ } from "../chunks/chunk-BNDHEDHD.js";
28
36
  import {
29
37
  normalizeBody
30
- } from "../chunks/chunk-53DCVFUB.js";
38
+ } from "../chunks/chunk-FALWG5U3.js";
31
39
  import {
32
40
  defineNative,
33
41
  inBody,
@@ -41,18 +49,18 @@ import {
41
49
  recordBase,
42
50
  refTo,
43
51
  refsTo
44
- } from "../chunks/chunk-2D42TQFU.js";
45
- import "../chunks/chunk-BOWXGMN3.js";
52
+ } from "../chunks/chunk-LVZGIKNF.js";
53
+ import "../chunks/chunk-POBAY3TI.js";
46
54
  import {
47
55
  emptyCounts,
48
56
  metricRow
49
- } from "../chunks/chunk-PQSTQKRD.js";
57
+ } from "../chunks/chunk-M2VXGLLZ.js";
50
58
  import {
51
59
  replyCategorySchema
52
60
  } from "../chunks/chunk-QGRZDTX4.js";
53
61
  import {
54
62
  assertWorkspaceId
55
- } from "../chunks/chunk-QAKJ76HB.js";
63
+ } from "../chunks/chunk-YW6FFVSZ.js";
56
64
  import "../chunks/chunk-NAWZ73QS.js";
57
65
  import {
58
66
  stableId
@@ -60,12 +68,12 @@ import {
60
68
  import {
61
69
  readEnv,
62
70
  requireCredential
63
- } from "../chunks/chunk-GFDNRWR3.js";
71
+ } from "../chunks/chunk-UFQ4WMLU.js";
64
72
  import {
65
73
  OutboundError,
66
74
  makeErrorMapper,
67
75
  requireObject
68
- } from "../chunks/chunk-J7DDZ4C2.js";
76
+ } from "../chunks/chunk-QFC4ZHD3.js";
69
77
  import {
70
78
  count,
71
79
  emailAddress,
@@ -80,7 +88,7 @@ import {
80
88
  stringMap,
81
89
  text,
82
90
  timestamp
83
- } from "../chunks/chunk-BLCJHP5H.js";
91
+ } from "../chunks/chunk-45TXPJW7.js";
84
92
 
85
93
  // src/smartlead/capabilities.ts
86
94
  var BASE_URL = "https://server.smartlead.ai/api/v1";
@@ -173,16 +181,28 @@ var capabilities = {
173
181
  workspaces: true
174
182
  };
175
183
  var fields = {
176
- campaignProgress: { failed: false },
184
+ campaignProgress: { failed: false, skipped: false },
177
185
  campaignSettings: { endDate: false },
178
- lead: { companyLinkedinUrl: false, engagement: false, title: false },
179
- 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 },
180
194
  metricRow: {
195
+ completed: false,
181
196
  connectionsAccepted: false,
182
197
  connectionsSent: false,
183
198
  contentHash: false,
184
199
  delivered: false,
185
200
  inmailsSent: false,
201
+ leads: false,
202
+ opportunities: false,
203
+ opportunityValue: false,
204
+ repliedAutoTotal: false,
205
+ repliedTotal: false,
186
206
  // total_reply_count less non_ooo_reply_count.
187
207
  repliedAuto: "derived"
188
208
  },
@@ -192,8 +212,10 @@ var fields = {
192
212
  // The lead's category, not a label on the message.
193
213
  category: "derived",
194
214
  categorySource: "derived",
195
- // 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.
196
216
  isAuto: "derived",
217
+ isAutoSource: "derived",
218
+ leftCompany: "derived",
197
219
  // The master inbox does not say which step a reply answers.
198
220
  stepIndex: false,
199
221
  variantKey: false
@@ -217,6 +239,8 @@ var costs = {
217
239
  "campaigns.get": { perPage: 1 },
218
240
  // One request returns every campaign; there are no pages.
219
241
  "campaigns.list": { perPage: 1 },
242
+ // The campaign's top-level analytics.
243
+ "campaigns.progress": { perPage: 1 },
220
244
  "campaigns.settings": { perPage: 1 },
221
245
  // The lead, then its tags, then the category list when the lead has a
222
246
  // category.
@@ -240,7 +264,9 @@ var costs = {
240
264
  "sequence.subsequences": { pageSize: 1, perPage: 1, perWalk: 1 },
241
265
  // A mailbox's totals cost two: the mailbox for its address, then the list.
242
266
  // Daily rows cost two: the day-wise counts, then the positive replies.
243
- 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 },
244
270
  "tags.list": { perPage: 1 },
245
271
  // One campaign per page; without a campaign, the first page also reads the
246
272
  // campaign list.
@@ -257,7 +283,7 @@ var caveats = [
257
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.",
258
284
  "No endpoint finds a lead by LinkedIn profile: leads.list({ linkedinUrl }) returns nothing and sends no request.",
259
285
  "A lead's status, campaign and creation time are per campaign; leads.get returns no campaign and its example looks illustrative.",
260
- "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.",
261
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.",
262
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.",
263
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.",
@@ -317,6 +343,10 @@ var tracked = (value, off) => {
317
343
  const settings = parsed(value);
318
344
  return isJsonArray(settings) ? !settings.some((setting) => isString(setting) && setting.endsWith(off)) : null;
319
345
  };
346
+ var trackingFlags = (raw) => ({
347
+ clicks: tracked(raw.track_settings, "LINK_CLICK"),
348
+ opens: tracked(raw.track_settings, "EMAIL_OPEN")
349
+ });
320
350
  var STOP_ON_REPLY = /* @__PURE__ */ new Map([
321
351
  ["NEVER", false],
322
352
  ["REPLY_TO_AN_EMAIL", true]
@@ -346,10 +376,7 @@ var toSettings = (identity, campaignId, raw) => {
346
376
  startDate: timestamp(raw.schedule_start_time)?.slice(0, 10) ?? null,
347
377
  stopOnAutoReply: stopOnAutoReply(raw, stopOnReply),
348
378
  stopOnReply,
349
- tracking: {
350
- clicks: tracked(raw.track_settings, "LINK_CLICK"),
351
- opens: tracked(raw.track_settings, "EMAIL_OPEN")
352
- }
379
+ tracking: trackingFlags(raw)
353
380
  };
354
381
  };
355
382
  var toCampaignProgress = (identity, campaignId, raw) => {
@@ -364,6 +391,9 @@ var toCampaignProgress = (identity, campaignId, raw) => {
364
391
  inProgress: count(field(stats, "inprogress")),
365
392
  leads: count(field(stats, "total")),
366
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,
367
397
  stopped: count(field(stats, "stopped"))
368
398
  };
369
399
  };
@@ -640,17 +670,26 @@ var toInboxReplies = (identity, item, categories, includeBody) => {
640
670
  }
641
671
  ];
642
672
  const read = flag(item.is_read);
643
- return parts.map((part) => ({
644
- ...messageFields(identity, place, part, includeBody),
645
- category: category ?? "unknown",
646
- // The category is the lead's, not one message's.
647
- categorySource: category === void 0 ? null : "lead",
648
- direction: "in",
649
- // Smartlead's only automatic-reply signal is the Out Of Office category.
650
- isAuto: category === "ooo" ? true : null,
651
- // `is_read` is the thread's.
652
- unread: read === null ? null : !read
653
- }));
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
+ });
654
693
  };
655
694
 
656
695
  // src/smartlead/shared.ts
@@ -1255,6 +1294,60 @@ var stepRows = (scope, step) => {
1255
1294
  );
1256
1295
  };
1257
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
+
1258
1351
  // src/smartlead/stats.ts
1259
1352
  var DAY_MS2 = 864e5;
1260
1353
  var LIFETIME_START = "2000-01-01";
@@ -1346,14 +1439,20 @@ var everyCampaign = async (client, ctx, query) => {
1346
1439
  objectOf(client, body, "campaign performance"),
1347
1440
  "campaign_wise_performance"
1348
1441
  );
1442
+ const flags = await everyCampaignFlags(client, ctx);
1349
1443
  return objects(campaigns).flatMap((campaign) => {
1350
1444
  const scopeId = text(campaign.id);
1351
- return scopeId === null ? [] : [
1352
- overallRow(
1353
- { ...client.identity, scope: "campaign", scopeId },
1354
- campaign
1355
- )
1356
- ];
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
+ );
1357
1456
  });
1358
1457
  };
1359
1458
  var stepTotals = async (client, ctx, scope, query) => {
@@ -1400,7 +1499,7 @@ var senderTotal = async (client, ctx, scope, query) => {
1400
1499
  )
1401
1500
  ];
1402
1501
  };
1403
- var readStats = async (client, ctx, query) => {
1502
+ var readCounts = async (client, ctx, query) => {
1404
1503
  const scope = {
1405
1504
  ...client.identity,
1406
1505
  scope: query.scope,
@@ -1429,6 +1528,21 @@ var readStats = async (client, ctx, query) => {
1429
1528
  }
1430
1529
  return query.scope === "campaign" ? await campaignTotal(client, ctx, scope, query) : await workspaceTotal(client, ctx, scope, query);
1431
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));
1432
1546
 
1433
1547
  // src/smartlead/adapter.ts
1434
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,33 +1,34 @@
1
1
  import {
2
2
  instantlyEvents
3
- } from "../chunks/chunk-W22SDX6S.js";
3
+ } from "../chunks/chunk-7I3EPR23.js";
4
4
  import {
5
5
  smartleadEvents
6
- } from "../chunks/chunk-PHNQ3WC2.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-SXGCKCAR.js";
13
- import "../chunks/chunk-MGR6HREO.js";
14
- import "../chunks/chunk-53DCVFUB.js";
15
- import "../chunks/chunk-2D42TQFU.js";
16
- 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";
17
18
  import {
18
19
  SCHEMA_VERSION
19
20
  } from "../chunks/chunk-QGRZDTX4.js";
20
- import "../chunks/chunk-QAKJ76HB.js";
21
+ import "../chunks/chunk-YW6FFVSZ.js";
21
22
  import "../chunks/chunk-NAWZ73QS.js";
22
23
  import {
23
24
  stableId
24
25
  } from "../chunks/chunk-FHKSLCVW.js";
25
26
  import {
26
27
  OutboundError
27
- } from "../chunks/chunk-J7DDZ4C2.js";
28
+ } from "../chunks/chunk-QFC4ZHD3.js";
28
29
  import {
29
30
  parseJson
30
- } from "../chunks/chunk-BLCJHP5H.js";
31
+ } from "../chunks/chunk-45TXPJW7.js";
31
32
 
32
33
  // src/webhooks/secret.ts
33
34
  var encoder = new TextEncoder();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "outbound-sdk",
3
- "version": "0.6.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",