outbound-sdk 0.2.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/README.md +2 -2
  2. package/dist/alerts/check-evaluate.d.ts +53 -0
  3. package/dist/alerts/check-measure.d.ts +100 -0
  4. package/dist/alerts/check-schema.d.ts +184 -0
  5. package/dist/alerts/check-validate.d.ts +18 -0
  6. package/dist/alerts/index.d.ts +7 -0
  7. package/dist/alerts/index.js +684 -20
  8. package/dist/alerts/plugin.d.ts +20 -3
  9. package/dist/audit/index.js +2 -2
  10. package/dist/benchmarks/index.js +5 -5
  11. package/dist/budget/index.d.ts +5 -2
  12. package/dist/budget/index.js +12 -10
  13. package/dist/cards/content.d.ts +6 -1
  14. package/dist/cards/format.d.ts +17 -2
  15. package/dist/cards/index.d.ts +1 -1
  16. package/dist/cards/index.js +298 -132
  17. package/dist/cards/parts.d.ts +9 -2
  18. package/dist/cards/render.d.ts +20 -3
  19. package/dist/chunks/{chunk-U2D34ARZ.js → chunk-2D42TQFU.js} +3 -3
  20. package/dist/chunks/{chunk-6CVZOUHB.js → chunk-3S32R2MH.js} +53 -63
  21. package/dist/chunks/chunk-4PA526S7.js +17 -0
  22. package/dist/chunks/{chunk-RCZ7ZZFU.js → chunk-5J7GGV62.js} +12 -5
  23. package/dist/chunks/chunk-6TKFISG4.js +676 -0
  24. package/dist/chunks/{chunk-AFU5E5QB.js → chunk-BK5SLY32.js} +104 -84
  25. package/dist/chunks/{chunk-VQSCHOBV.js → chunk-BLCJHP5H.js} +11 -4
  26. package/dist/chunks/{chunk-SBIZDCRY.js → chunk-BN6WCAWX.js} +7 -7
  27. package/dist/chunks/{chunk-4PSO6JEK.js → chunk-BOWXGMN3.js} +6 -21
  28. package/dist/chunks/{chunk-PURHK3JU.js → chunk-EHSJGQ5K.js} +8 -8
  29. package/dist/chunks/{chunk-IPUYZD4O.js → chunk-GFDNRWR3.js} +1 -1
  30. package/dist/chunks/chunk-HPNGSG5E.js +51 -0
  31. package/dist/chunks/chunk-HWHI4LFY.js +102 -0
  32. package/dist/chunks/{chunk-E7JHLNLG.js → chunk-J7DDZ4C2.js} +15 -2
  33. package/dist/chunks/{chunk-DJ2IUQEU.js → chunk-JWGSB7PT.js} +6 -6
  34. package/dist/chunks/{chunk-R3Y56YVF.js → chunk-OLPMBRXM.js} +4 -3
  35. package/dist/chunks/{chunk-YOTW5ESM.js → chunk-PQSTQKRD.js} +2 -2
  36. package/dist/chunks/chunk-PTZO4QXR.js +15 -0
  37. package/dist/chunks/{chunk-LVYG7XZJ.js → chunk-QAKJ76HB.js} +1 -1
  38. package/dist/chunks/chunk-QGRZDTX4.js +26 -0
  39. package/dist/chunks/chunk-WGW3ROLY.js +18 -0
  40. package/dist/chunks/{chunk-XC6CZP73.js → chunk-WH6V3YNN.js} +32 -1
  41. package/dist/chunks/{chunk-P3IJBJUI.js → chunk-X4RDBD4J.js} +296 -62
  42. package/dist/chunks/chunk-XL6LJVHJ.js +71 -0
  43. package/dist/chunks/{chunk-XNFESPZH.js → chunk-YYCT3NGV.js} +200 -39
  44. package/dist/chunks/{chunk-UAT3JSJZ.js → chunk-ZOAG2C6V.js} +2 -2
  45. package/dist/cli/bin.js +19 -30
  46. package/dist/cli/commands.d.ts +11 -0
  47. package/dist/cli/index.d.ts +3 -0
  48. package/dist/cli/index.js +18 -13
  49. package/dist/cli/mcp.d.ts +5 -0
  50. package/dist/cli/update.d.ts +15 -0
  51. package/dist/clients/index.d.ts +1 -1
  52. package/dist/clients/index.js +35 -10
  53. package/dist/clients/plugin.d.ts +9 -2
  54. package/dist/combine/index.js +7 -6
  55. package/dist/emailbison/account.d.ts +7 -0
  56. package/dist/emailbison/adapter.d.ts +5 -0
  57. package/dist/emailbison/capabilities.d.ts +78 -0
  58. package/dist/emailbison/client.d.ts +29 -0
  59. package/dist/emailbison/index.d.ts +30 -0
  60. package/dist/emailbison/index.js +1017 -0
  61. package/dist/emailbison/mail.d.ts +5 -0
  62. package/dist/emailbison/map-mail.d.ts +13 -0
  63. package/dist/emailbison/map-sequence.d.ts +12 -0
  64. package/dist/emailbison/map-stats.d.ts +47 -0
  65. package/dist/emailbison/map.d.ts +24 -0
  66. package/dist/emailbison/native-params.d.ts +5 -0
  67. package/dist/emailbison/native-workspace.d.ts +167 -0
  68. package/dist/emailbison/native.d.ts +327 -0
  69. package/dist/emailbison/stats.d.ts +4 -0
  70. package/dist/emailbison/webhooks.d.ts +2 -0
  71. package/dist/exporter/index.d.ts +5 -2
  72. package/dist/exporter/index.js +2 -2
  73. package/dist/failover/index.js +3 -3
  74. package/dist/fixtures/index.js +10 -9
  75. package/dist/heyreach/capabilities.d.ts +3 -0
  76. package/dist/heyreach/client.d.ts +2 -0
  77. package/dist/heyreach/index.js +83 -51
  78. package/dist/heyreach/map.d.ts +5 -2
  79. package/dist/identity/index.js +33 -17
  80. package/dist/identity/plugin.d.ts +2 -0
  81. package/dist/index.d.ts +2 -2
  82. package/dist/index.js +29 -25
  83. package/dist/insights/campaign.d.ts +3 -0
  84. package/dist/insights/capped.d.ts +29 -0
  85. package/dist/insights/copy/copy-audit.d.ts +2 -0
  86. package/dist/insights/copy/copy-reuse.d.ts +27 -3
  87. package/dist/insights/copy/index.d.ts +8 -8
  88. package/dist/insights/copy/reply-timing.d.ts +8 -0
  89. package/dist/insights/copy/reuse-base.d.ts +32 -0
  90. package/dist/insights/copy/shared.d.ts +39 -15
  91. package/dist/insights/copy/step-funnel.d.ts +16 -5
  92. package/dist/insights/copy/variant-test.d.ts +19 -8
  93. package/dist/insights/cost.d.ts +91 -0
  94. package/dist/insights/define.d.ts +78 -3
  95. package/dist/insights/fields.d.ts +16 -0
  96. package/dist/insights/index.d.ts +6 -4
  97. package/dist/insights/index.js +1816 -748
  98. package/dist/insights/inputs.generated.d.ts +951 -0
  99. package/dist/insights/ops/campaign-diagnosis.d.ts +3 -1
  100. package/dist/insights/ops/campaign-ranking.d.ts +15 -7
  101. package/dist/insights/ops/channel-mix.d.ts +2 -1
  102. package/dist/insights/ops/client-report.d.ts +18 -5
  103. package/dist/insights/ops/index.d.ts +8 -4
  104. package/dist/insights/ops/period-comparison.d.ts +14 -3
  105. package/dist/insights/ops/pipeline-forecast.d.ts +14 -4
  106. package/dist/insights/ops/shared.d.ts +39 -24
  107. package/dist/insights/ops/tag-rollup.d.ts +2 -1
  108. package/dist/insights/people/account-summary.d.ts +13 -0
  109. package/dist/insights/people/dropped-replies.d.ts +8 -0
  110. package/dist/insights/people/find.d.ts +7 -1
  111. package/dist/insights/people/hot-leads.d.ts +16 -1
  112. package/dist/insights/people/person-summary.d.ts +6 -0
  113. package/dist/insights/people/read.d.ts +26 -10
  114. package/dist/insights/people/suppression-check.d.ts +11 -2
  115. package/dist/insights/plugin.d.ts +26 -5
  116. package/dist/insights/ref.d.ts +6 -0
  117. package/dist/insights/registry.d.ts +30 -18
  118. package/dist/insights/run-cap.d.ts +35 -0
  119. package/dist/insights/senders/bounce-watch.d.ts +25 -8
  120. package/dist/insights/senders/capacity-sends.d.ts +22 -0
  121. package/dist/insights/senders/domain-health.d.ts +10 -4
  122. package/dist/insights/senders/index.d.ts +14 -6
  123. package/dist/insights/senders/read.d.ts +15 -14
  124. package/dist/insights/senders/sender-capacity.d.ts +5 -13
  125. package/dist/insights/senders/sender-load.d.ts +2 -0
  126. package/dist/insights/stats.d.ts +8 -0
  127. package/dist/insights/tools.d.ts +13 -2
  128. package/dist/instantly/capabilities.d.ts +13 -0
  129. package/dist/instantly/client.d.ts +2 -0
  130. package/dist/instantly/index.js +77 -49
  131. package/dist/instantly/map.d.ts +6 -2
  132. package/dist/internal/adapter.d.ts +12 -0
  133. package/dist/internal/engine/request.d.ts +5 -0
  134. package/dist/internal/entities.d.ts +3 -20
  135. package/dist/internal/errors.d.ts +44 -0
  136. package/dist/internal/fields.d.ts +1 -1
  137. package/dist/internal/json.d.ts +9 -2
  138. package/dist/internal/lists.d.ts +24 -0
  139. package/dist/internal/numbers.d.ts +8 -0
  140. package/dist/internal/outbound/collections.d.ts +4 -0
  141. package/dist/internal/outbound/create.d.ts +24 -3
  142. package/dist/internal/outbound/outbound.d.ts +18 -2
  143. package/dist/internal/outbound/validate.d.ts +4 -0
  144. package/dist/internal/outbound/walker.d.ts +3 -2
  145. package/dist/internal/plural.d.ts +12 -0
  146. package/dist/internal/renamed.d.ts +28 -0
  147. package/dist/internal/request-cap.d.ts +35 -0
  148. package/dist/internal/vocabulary.d.ts +20 -0
  149. package/dist/loader/index.js +5 -5
  150. package/dist/memory/adapter.d.ts +7 -0
  151. package/dist/memory/demo-stats.d.ts +3 -0
  152. package/dist/memory/demo.d.ts +14 -3
  153. package/dist/memory/index.d.ts +1 -0
  154. package/dist/memory/index.js +209 -104
  155. package/dist/providers/index.d.ts +92 -0
  156. package/dist/providers/index.js +3 -1
  157. package/dist/reconcile/index.js +5 -4
  158. package/dist/redact/index.js +13 -7
  159. package/dist/redact/plugin.d.ts +7 -0
  160. package/dist/smartlead/capabilities.d.ts +5 -0
  161. package/dist/smartlead/index.js +119 -66
  162. package/dist/smartlead/shared.d.ts +13 -0
  163. package/dist/sync/index.js +2 -2
  164. package/dist/tools/ai-sdk.js +10 -6
  165. package/dist/tools/campaign-tools.d.ts +1 -1
  166. package/dist/tools/claude-agent.js +10 -6
  167. package/dist/tools/index.d.ts +2 -2
  168. package/dist/tools/index.js +16 -9
  169. package/dist/tools/input-problem.d.ts +8 -0
  170. package/dist/tools/registry.d.ts +26 -2
  171. package/dist/tools/shared.d.ts +27 -1
  172. package/dist/tracing/index.js +2 -2
  173. package/dist/webhooks/index.js +22 -12
  174. package/package.json +8 -2
  175. package/dist/chunks/chunk-FKH5N47I.js +0 -40
@@ -2,11 +2,8 @@ import {
2
2
  defaultRateLimitStore
3
3
  } from "./chunk-4O2HRTTI.js";
4
4
  import {
5
- buildUrl
6
- } from "./chunk-NAWZ73QS.js";
7
- import {
8
- sha256Hex
9
- } from "./chunk-FHKSLCVW.js";
5
+ CAPPED
6
+ } from "./chunk-HPNGSG5E.js";
10
7
  import {
11
8
  CAPABILITY_KEYS,
12
9
  blockEntrySchema,
@@ -21,7 +18,10 @@ import {
21
18
  senderHealthSchema,
22
19
  tagSchema,
23
20
  webhookSubscriptionSchema
24
- } from "./chunk-UAT3JSJZ.js";
21
+ } from "./chunk-ZOAG2C6V.js";
22
+ import {
23
+ plural
24
+ } from "./chunk-PTZO4QXR.js";
25
25
  import {
26
26
  campaignSchema,
27
27
  leadSchema,
@@ -31,21 +31,28 @@ import {
31
31
  senderSchema,
32
32
  sequenceSchema,
33
33
  workspaceSchema
34
- } from "./chunk-4PSO6JEK.js";
34
+ } from "./chunk-BOWXGMN3.js";
35
35
  import {
36
36
  sourceIdFor
37
- } from "./chunk-LVYG7XZJ.js";
37
+ } from "./chunk-QAKJ76HB.js";
38
+ import {
39
+ buildUrl
40
+ } from "./chunk-NAWZ73QS.js";
41
+ import {
42
+ sha256Hex
43
+ } from "./chunk-FHKSLCVW.js";
38
44
  import {
39
45
  OutboundError,
40
46
  redactUrl
41
- } from "./chunk-E7JHLNLG.js";
47
+ } from "./chunk-J7DDZ4C2.js";
42
48
  import {
43
49
  count,
44
50
  field,
45
51
  isJsonObject,
46
52
  isString,
47
- parseJson
48
- } from "./chunk-VQSCHOBV.js";
53
+ parseJson,
54
+ strayKey
55
+ } from "./chunk-BLCJHP5H.js";
49
56
 
50
57
  // src/internal/limits.ts
51
58
  var DEFAULT_CONCURRENCY = 8;
@@ -273,7 +280,12 @@ var Budget = class {
273
280
  throw new OutboundError(
274
281
  "RateLimited",
275
282
  `${provider} rate budget is full and the deadline would pass before it frees up`,
276
- { provider, retryAfterMs: waitMs, timedOut: true }
283
+ {
284
+ limit: "deadline",
285
+ provider,
286
+ retryAfterMs: waitMs,
287
+ timedOut: true
288
+ }
277
289
  );
278
290
  }
279
291
  fire(hooks.onThrottle, { lane, provider, waitMs });
@@ -473,15 +485,17 @@ var attempt = async (spec, environment, attemptNumber) => {
473
485
  var assertRequestBudget = (environment) => {
474
486
  const { adapter, state } = environment;
475
487
  if (state.maxRequests !== void 0 && state.requests >= state.maxRequests) {
488
+ const setBy = state.maxRequestsSetBy ?? "maxRequests";
476
489
  throw new OutboundError(
477
490
  "RateLimited",
478
- `The call used its budget of ${state.maxRequests} request(s) to ${adapter.name}`,
479
- { provider: adapter.name }
491
+ `The call used its budget of ${plural(state.maxRequests, "request")} to ${adapter.name}. Raise ${setBy} or ask for less in one call.`,
492
+ { limit: "call", provider: adapter.name }
480
493
  );
481
494
  }
482
495
  };
483
496
  var exhausted = (error, timedOut) => timedOut ? new OutboundError(error.code, error.message, {
484
497
  cause: error.cause,
498
+ limit: error.limit,
485
499
  provider: error.provider,
486
500
  retryAfterMs: error.retryAfterMs,
487
501
  status: error.status,
@@ -575,6 +589,8 @@ var RequestEngine = class {
575
589
  beforeRequest: void 0,
576
590
  deadlineAt: merged.deadline === void 0 ? void 0 : this.now() + merged.deadline,
577
591
  maxRequests: merged.maxRequests,
592
+ // A cap from the instance is named by the option that set it there.
593
+ maxRequestsSetBy: options.maxRequests === void 0 && this.#defaults.maxRequests !== void 0 ? "maxRequestsPerCall" : void 0,
578
594
  requests: 0,
579
595
  retry: resolveRetryPolicy(merged.retries),
580
596
  signal: merged.signal,
@@ -721,11 +737,13 @@ var checked = (core, schema, records, action) => {
721
737
  // src/internal/outbound/validate.ts
722
738
  var DATE = /^\d{4}-\d{2}-\d{2}$/u;
723
739
  var invalid = (message) => new OutboundError("Invalid", message);
740
+ var DAY_MS = 864e5;
724
741
  var normalizeInstant = (value, name) => {
725
742
  if (value === void 0) {
726
743
  return void 0;
727
744
  }
728
- const time = Date.parse(value);
745
+ const parsed = Date.parse(value);
746
+ const time = name === "until" && DATE.test(value) ? parsed + DAY_MS - 1 : parsed;
729
747
  if (Number.isNaN(time)) {
730
748
  throw invalid(
731
749
  `${name} must be an ISO 8601 date or timestamp, got "${value}"`
@@ -753,8 +771,20 @@ var assertLimit = (limit) => {
753
771
  }
754
772
  return limit;
755
773
  };
774
+ var assertMax = (max) => {
775
+ if (max !== void 0 && (!Number.isInteger(max) || max < 1)) {
776
+ throw invalid(`max must be a positive integer, got ${max}`);
777
+ }
778
+ return max;
779
+ };
780
+ var assertIdIsString = (id, what) => {
781
+ if (typeof id !== "string") {
782
+ throw invalid(`${what} id must be a string, got ${String(id)}`);
783
+ }
784
+ return id;
785
+ };
756
786
  var assertId = (id, what) => {
757
- if (id.trim() === "") {
787
+ if (assertIdIsString(id, what).trim() === "") {
758
788
  throw invalid(`${what} id must not be empty`);
759
789
  }
760
790
  return id;
@@ -766,6 +796,7 @@ var PageWalker = class {
766
796
  #cursor;
767
797
  #meta;
768
798
  #truncated = false;
799
+ #state;
769
800
  constructor(options) {
770
801
  this.#options = options;
771
802
  this.#cursor = options.cursor;
@@ -780,13 +811,13 @@ var PageWalker = class {
780
811
  return this.#truncated;
781
812
  }
782
813
  async *[Symbol.asyncIterator]() {
783
- const { fetchPage: fetchPage2, keyOf, max } = this.#options;
814
+ const { begin, fetchPage: fetchPage2, keyOf, max } = this.#options;
784
815
  const seen = /* @__PURE__ */ new Set();
785
- let state;
816
+ const state = begin();
817
+ this.#state = state;
786
818
  let yielded = 0;
787
819
  for (; ; ) {
788
820
  const fetched = await fetchPage2(this.#cursor, state);
789
- ({ state } = fetched);
790
821
  this.#meta = fetched.page.meta;
791
822
  for (const item of fetched.page.items) {
792
823
  const key = keyOf(item);
@@ -814,8 +845,28 @@ var PageWalker = class {
814
845
  }
815
846
  async toArray() {
816
847
  const items = [];
817
- for await (const item of this) {
818
- items.push(item);
848
+ try {
849
+ for await (const item of this) {
850
+ items.push(item);
851
+ }
852
+ } catch (error) {
853
+ if (!OutboundError.is(error)) {
854
+ throw error;
855
+ }
856
+ throw new OutboundError(error.code, error.message, {
857
+ aborted: error.aborted,
858
+ cause: error,
859
+ limit: error.limit,
860
+ partial: {
861
+ cursor: this.#cursor,
862
+ items,
863
+ requests: this.#state?.requests ?? 0
864
+ },
865
+ provider: error.provider,
866
+ retryAfterMs: error.retryAfterMs,
867
+ status: error.status,
868
+ timedOut: error.timedOut
869
+ });
819
870
  }
820
871
  return items;
821
872
  }
@@ -823,6 +874,28 @@ var PageWalker = class {
823
874
 
824
875
  // src/internal/outbound/collections.ts
825
876
  var DEFAULT_BULK_CONCURRENCY = 4;
877
+ var LIST_ALL_KEYS = Object.keys({
878
+ cursor: true,
879
+ deadline: true,
880
+ limit: true,
881
+ max: true,
882
+ maxRequests: true,
883
+ retries: true,
884
+ signal: true,
885
+ timeout: true
886
+ });
887
+ var LIST_KEYS = LIST_ALL_KEYS.filter((key) => key !== "max");
888
+ var refuseUnknown = (spec, options, optionKeys) => {
889
+ const given = Object.entries(options ?? {}).filter(([, value]) => value !== void 0).map(([key]) => key);
890
+ const stray = strayKey(
891
+ [...Object.keys(spec.takes), ...optionKeys],
892
+ given,
893
+ "an option"
894
+ );
895
+ if (stray !== void 0) {
896
+ throw new OutboundError("Invalid", `${spec.action}: ${stray}`);
897
+ }
898
+ };
826
899
  var cursorScope = (core, action) => ({
827
900
  action,
828
901
  provider: core.adapter.name,
@@ -857,6 +930,7 @@ var fetchPage = (core, spec, request, options, shared) => perform(
857
930
  );
858
931
  var makeReadCollection = (core, spec) => ({
859
932
  list: async (options) => {
933
+ refuseUnknown(spec, options, LIST_KEYS);
860
934
  const filters = spec.prepare(options ?? {});
861
935
  const limit = assertLimit(options?.limit);
862
936
  const { page } = await fetchPage(
@@ -868,10 +942,13 @@ var makeReadCollection = (core, spec) => ({
868
942
  return page;
869
943
  },
870
944
  listAll: (options) => {
945
+ refuseUnknown(spec, options, LIST_ALL_KEYS);
871
946
  const filters = spec.prepare(options ?? {});
872
947
  const limit = assertLimit(options?.limit);
948
+ assertMax(options?.max);
873
949
  const walkOptions = options;
874
950
  return new PageWalker({
951
+ begin: () => core.engine.begin(options),
875
952
  cursor: walkOptions?.cursor,
876
953
  fetchPage: (cursor, state) => fetchPage(core, spec, { cursor, filters, limit }, options, state),
877
954
  keyOf: (item) => spec.keyOf(item, filters),
@@ -918,31 +995,39 @@ var makeGetter = (core, spec) => async (id, options) => {
918
995
  };
919
996
  var getMany = async (core, spec, ids, options) => {
920
997
  spec.prepare();
998
+ for (const id of ids) {
999
+ assertIdIsString(id, spec.what);
1000
+ }
921
1001
  const state = core.engine.begin(options);
922
- const results = [];
923
- const errors = [];
924
- const queue = [...ids];
1002
+ const distinct = [...new Set(ids)];
1003
+ const answers = /* @__PURE__ */ new Map();
1004
+ const queue = [...distinct];
925
1005
  const worker = async () => {
926
1006
  for (let id = queue.shift(); id !== void 0; id = queue.shift()) {
927
1007
  try {
928
1008
  const value = await getOne(core, spec, id, options, state, true);
929
- results.push({ id, value });
1009
+ answers.set(id, { value });
930
1010
  } catch (error) {
931
- errors.push({ error: toOutboundError(core, error), id });
1011
+ answers.set(id, { error: toOutboundError(core, error) });
932
1012
  }
933
1013
  }
934
1014
  };
935
1015
  const workers = Math.max(
936
1016
  1,
937
- Math.min(options?.concurrency ?? DEFAULT_BULK_CONCURRENCY, ids.length)
1017
+ Math.min(options?.concurrency ?? DEFAULT_BULK_CONCURRENCY, distinct.length)
938
1018
  );
939
1019
  await Promise.all(Array.from({ length: workers }, worker));
940
- const order = new Map(ids.map((id, index) => [id, index]));
941
- const byOrder = (left, right) => (order.get(left.id) ?? 0) - (order.get(right.id) ?? 0);
942
- return {
943
- errors: errors.toSorted(byOrder),
944
- results: results.toSorted(byOrder)
945
- };
1020
+ const results = [];
1021
+ const errors = [];
1022
+ for (const id of ids) {
1023
+ const answer = answers.get(id);
1024
+ if (answer !== void 0 && "value" in answer) {
1025
+ results.push({ id, value: answer.value });
1026
+ } else if (answer !== void 0) {
1027
+ errors.push({ error: answer.error, id });
1028
+ }
1029
+ }
1030
+ return { errors, results };
946
1031
  };
947
1032
  var makeCollection = (core, listSpec, getSpec) => ({
948
1033
  ...makeReadCollection(core, listSpec),
@@ -1001,6 +1086,7 @@ var healthGet = (core) => ({
1001
1086
  });
1002
1087
  var subsequenceList = (core) => ({
1003
1088
  action: "sequence.subsequences",
1089
+ takes: { campaignId: true },
1004
1090
  keyOf: refOf,
1005
1091
  prepare: (filters) => {
1006
1092
  requireCapability(
@@ -1023,6 +1109,7 @@ var subsequenceList = (core) => ({
1023
1109
  });
1024
1110
  var listList = (core) => ({
1025
1111
  action: "lists.list",
1112
+ takes: {},
1026
1113
  keyOf: refOf,
1027
1114
  prepare: () => {
1028
1115
  requireCapability(core.gate, "lists.list", "Listing lead lists");
@@ -1051,6 +1138,7 @@ var webhookGet = (core) => ({
1051
1138
  });
1052
1139
  var blocklistList = (core) => ({
1053
1140
  action: "blocklist.list",
1141
+ takes: {},
1054
1142
  keyOf: refOf,
1055
1143
  prepare: () => {
1056
1144
  requireCapability(core.gate, "blocklist", "Listing the block list");
@@ -1061,6 +1149,7 @@ var blocklistList = (core) => ({
1061
1149
  });
1062
1150
  var placementTestList = (core) => ({
1063
1151
  action: "placementTests.list",
1152
+ takes: {},
1064
1153
  keyOf: refOf,
1065
1154
  prepare: () => {
1066
1155
  requireCapability(
@@ -1078,6 +1167,7 @@ var placementTestList = (core) => ({
1078
1167
  });
1079
1168
  var tagList = (core) => ({
1080
1169
  action: "tags.list",
1170
+ takes: {},
1081
1171
  keyOf: refOf,
1082
1172
  prepare: () => {
1083
1173
  requireCapability(core.gate, "tags", "Listing tags");
@@ -1088,6 +1178,7 @@ var tagList = (core) => ({
1088
1178
  });
1089
1179
  var webhookList = (core) => ({
1090
1180
  action: "webhooks.list",
1181
+ takes: { campaignId: true },
1091
1182
  keyOf: refOf,
1092
1183
  prepare: (filters) => {
1093
1184
  requireCapability(core.gate, "webhooks.list", "Listing webhooks");
@@ -1106,6 +1197,7 @@ var hasRange = (filters) => filters.since !== void 0 || filters.until !== void 0
1106
1197
  var refOf2 = (item) => item.ref;
1107
1198
  var campaignList = (core) => ({
1108
1199
  action: "campaigns.list",
1200
+ takes: { senderId: true, status: true },
1109
1201
  keyOf: refOf2,
1110
1202
  prepare: (filters) => {
1111
1203
  if (filters.status !== void 0) {
@@ -1149,6 +1241,7 @@ var sequenceGet = (core) => ({
1149
1241
  });
1150
1242
  var senderList = (core) => ({
1151
1243
  action: "senders.list",
1244
+ takes: { campaignId: true },
1152
1245
  keyOf: refOf2,
1153
1246
  prepare: (filters) => {
1154
1247
  if (filters.campaignId === void 0) {
@@ -1179,6 +1272,14 @@ var senderGet = (core) => ({
1179
1272
  });
1180
1273
  var leadList = (core) => ({
1181
1274
  action: "leads.list",
1275
+ takes: {
1276
+ campaignId: true,
1277
+ email: true,
1278
+ linkedinUrl: true,
1279
+ listId: true,
1280
+ since: true,
1281
+ until: true
1282
+ },
1182
1283
  // A lookup returns one record per campaign the person is in. On a vendor
1183
1284
  // whose lead id is the same in every campaign those records share a ref,
1184
1285
  // so the campaign is part of what tells them apart.
@@ -1237,6 +1338,14 @@ var leadGet = (core) => ({
1237
1338
  });
1238
1339
  var messageList = (core) => ({
1239
1340
  action: "messages.list",
1341
+ takes: {
1342
+ campaignId: true,
1343
+ include: true,
1344
+ leadId: true,
1345
+ since: true,
1346
+ threadId: true,
1347
+ until: true
1348
+ },
1240
1349
  keyOf: refOf2,
1241
1350
  prepare: (filters) => {
1242
1351
  requireCapability(core.gate, "messages.list", "Listing messages");
@@ -1281,6 +1390,14 @@ var messageList = (core) => ({
1281
1390
  });
1282
1391
  var replyList = (core) => ({
1283
1392
  action: "replies.list",
1393
+ takes: {
1394
+ campaignId: true,
1395
+ category: true,
1396
+ include: true,
1397
+ since: true,
1398
+ unread: true,
1399
+ until: true
1400
+ },
1284
1401
  keyOf: refOf2,
1285
1402
  prepare: (filters) => {
1286
1403
  requireCapability(core.gate, "replies.list", "Listing replies");
@@ -1332,6 +1449,7 @@ var replyList = (core) => ({
1332
1449
  });
1333
1450
  var workspaceList = (core) => ({
1334
1451
  action: "workspaces.list",
1452
+ takes: {},
1335
1453
  keyOf: refOf2,
1336
1454
  prepare: () => {
1337
1455
  requireCapability(core.gate, "workspaces", "Listing workspaces");
@@ -2098,10 +2216,29 @@ var makeRawClient = (core, nativeOffBy) => {
2098
2216
  };
2099
2217
 
2100
2218
  // src/internal/outbound/outbound.ts
2219
+ var warnedMaxRequests = false;
2220
+ var perCallCap = (options) => {
2221
+ if (options.maxRequests === void 0) {
2222
+ return options.maxRequestsPerCall;
2223
+ }
2224
+ if (options.maxRequestsPerCall !== void 0) {
2225
+ throw new OutboundError(
2226
+ "Invalid",
2227
+ "Set maxRequestsPerCall or maxRequests on createOutbound, not both. maxRequests is the old name."
2228
+ );
2229
+ }
2230
+ if (!warnedMaxRequests) {
2231
+ warnedMaxRequests = true;
2232
+ console.warn(
2233
+ "outbound-sdk: maxRequests on createOutbound is deprecated. Rename it to maxRequestsPerCall: it caps each call, not the whole run. For a total, use budget({ maxRequests })."
2234
+ );
2235
+ }
2236
+ return options.maxRequests;
2237
+ };
2101
2238
  var engineFor = (options) => new RequestEngine({
2102
2239
  defaults: {
2103
2240
  deadline: options.deadline,
2104
- maxRequests: options.maxRequests,
2241
+ maxRequests: perCallCap(options),
2105
2242
  retries: options.retries,
2106
2243
  signal: options.signal,
2107
2244
  timeout: options.timeout
@@ -2118,6 +2255,8 @@ var Outbound = class _Outbound {
2118
2255
  #core;
2119
2256
  #options;
2120
2257
  #plugins;
2258
+ // Innermost layers a shared request cap adds; never listed in `plugins`.
2259
+ #layers;
2121
2260
  campaigns;
2122
2261
  senders;
2123
2262
  leads;
@@ -2131,14 +2270,14 @@ var Outbound = class _Outbound {
2131
2270
  webhooks;
2132
2271
  raw;
2133
2272
  native;
2134
- constructor(options, engine = engineFor(options)) {
2273
+ constructor(options, engine = engineFor(options), layers = []) {
2135
2274
  const { adapter } = options;
2136
2275
  const plugins = options.plugins ?? [];
2137
2276
  assertUniquePluginNames(plugins);
2138
2277
  const declared = resolveCapabilities(adapter.capabilities);
2139
2278
  const narrowed = narrowCapabilities(declared, plugins);
2140
2279
  const run = composeOperations(
2141
- plugins,
2280
+ [...plugins, ...layers],
2142
2281
  (operation, info) => dispatch(
2143
2282
  {
2144
2283
  adapter,
@@ -2150,6 +2289,7 @@ var Outbound = class _Outbound {
2150
2289
  );
2151
2290
  this.#options = options;
2152
2291
  this.#plugins = plugins;
2292
+ this.#layers = layers;
2153
2293
  this.#core = {
2154
2294
  adapter,
2155
2295
  allowWrites: options.allowWrites ?? false,
@@ -2258,10 +2398,28 @@ var Outbound = class _Outbound {
2258
2398
  }
2259
2399
  );
2260
2400
  }
2261
- const scoped2 = new _Outbound({ ...this.#options, adapter: member }, engine);
2401
+ const scoped2 = new _Outbound(
2402
+ { ...this.#options, adapter: member },
2403
+ engine,
2404
+ this.#layers
2405
+ );
2262
2406
  installExtensions(scoped2, this.#plugins);
2263
2407
  return scoped2;
2264
2408
  }
2409
+ /** For a cap shared across calls, as insights and tools use. Not public. */
2410
+ get [CAPPED]() {
2411
+ return {
2412
+ costs: this.#core.adapter.costs,
2413
+ guarded: (layer) => {
2414
+ const copy = new _Outbound(this.#options, this.#core.engine, [
2415
+ ...this.#layers,
2416
+ layer
2417
+ ]);
2418
+ installExtensions(copy, this.#plugins);
2419
+ return copy;
2420
+ }
2421
+ };
2422
+ }
2265
2423
  stats(options) {
2266
2424
  return readStats(this.#core, options);
2267
2425
  }
@@ -2281,12 +2439,15 @@ var Outbound = class _Outbound {
2281
2439
  }
2282
2440
  const pageSize = query.limit ?? cost.pageSize;
2283
2441
  if (query.records === void 0 || pageSize === void 0) {
2284
- return { basis: `${cost.perPage} request(s) per page`, requests: null };
2442
+ return {
2443
+ basis: `${plural(cost.perPage, "request")} per page`,
2444
+ requests: null
2445
+ };
2285
2446
  }
2286
2447
  const pages = Math.max(1, Math.ceil(query.records / pageSize));
2287
2448
  const requests = pages * cost.perPage + query.records * (cost.perRecord ?? 0);
2288
2449
  return {
2289
- basis: `${pages} page(s) of ${pageSize} at ${cost.perPage} request(s) each, plus ${cost.perRecord ?? 0} per record`,
2450
+ basis: `${plural(pages, "page")} of ${pageSize} at ${plural(cost.perPage, "request")} each, plus ${cost.perRecord ?? 0} per record`,
2290
2451
  requests
2291
2452
  };
2292
2453
  }
@@ -11,10 +11,10 @@ import {
11
11
  senderSchema,
12
12
  sequenceSchema,
13
13
  workspaceSchema
14
- } from "./chunk-4PSO6JEK.js";
14
+ } from "./chunk-BOWXGMN3.js";
15
15
  import {
16
16
  OutboundError
17
- } from "./chunk-E7JHLNLG.js";
17
+ } from "./chunk-J7DDZ4C2.js";
18
18
 
19
19
  // src/internal/capabilities.ts
20
20
  var NO_CAPABILITIES = {
package/dist/cli/bin.js CHANGED
@@ -1,35 +1,24 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- run
4
- } from "../chunks/chunk-P3IJBJUI.js";
5
- import "../chunks/chunk-R3Y56YVF.js";
6
- import "../chunks/chunk-AFU5E5QB.js";
2
+ import "../chunks/chunk-WGW3ROLY.js";
3
+ import "../chunks/chunk-X4RDBD4J.js";
4
+ import "../chunks/chunk-OLPMBRXM.js";
5
+ import "../chunks/chunk-BK5SLY32.js";
6
+ import "../chunks/chunk-HWHI4LFY.js";
7
+ import "../chunks/chunk-4PA526S7.js";
7
8
  import "../chunks/chunk-HZCTYL22.js";
8
- import "../chunks/chunk-XNFESPZH.js";
9
+ import "../chunks/chunk-YYCT3NGV.js";
9
10
  import "../chunks/chunk-4O2HRTTI.js";
10
- import "../chunks/chunk-YOTW5ESM.js";
11
+ import "../chunks/chunk-HPNGSG5E.js";
12
+ import "../chunks/chunk-ZOAG2C6V.js";
13
+ import "../chunks/chunk-PTZO4QXR.js";
14
+ import "../chunks/chunk-BOWXGMN3.js";
15
+ import "../chunks/chunk-PQSTQKRD.js";
16
+ import "../chunks/chunk-QGRZDTX4.js";
17
+ import "../chunks/chunk-QAKJ76HB.js";
11
18
  import "../chunks/chunk-NAWZ73QS.js";
12
19
  import "../chunks/chunk-FHKSLCVW.js";
13
- import "../chunks/chunk-RCZ7ZZFU.js";
14
- import "../chunks/chunk-IPUYZD4O.js";
15
- import "../chunks/chunk-XC6CZP73.js";
16
- import "../chunks/chunk-UAT3JSJZ.js";
17
- import "../chunks/chunk-4PSO6JEK.js";
18
- import "../chunks/chunk-LVYG7XZJ.js";
19
- import "../chunks/chunk-E7JHLNLG.js";
20
- import "../chunks/chunk-VQSCHOBV.js";
21
-
22
- // src/cli/bin.ts
23
- import process from "node:process";
24
- import { createInterface } from "node:readline";
25
- process.exitCode = await run(process.argv.slice(2), {
26
- stderr: (text) => {
27
- process.stderr.write(`${text}
28
- `);
29
- },
30
- stdin: () => createInterface({ input: process.stdin }),
31
- stdout: (text) => {
32
- process.stdout.write(`${text}
33
- `);
34
- }
35
- });
20
+ import "../chunks/chunk-5J7GGV62.js";
21
+ import "../chunks/chunk-GFDNRWR3.js";
22
+ import "../chunks/chunk-J7DDZ4C2.js";
23
+ import "../chunks/chunk-BLCJHP5H.js";
24
+ import "../chunks/chunk-WH6V3YNN.js";
@@ -4,16 +4,27 @@ import type { OutboundTool } from "../tools/index.ts";
4
4
  export interface CommandInput {
5
5
  readonly positionals: readonly string[];
6
6
  readonly flags: Readonly<Record<string, string | boolean | undefined>>;
7
+ /** Writes a line for the person to stderr, apart from the JSON on stdout. */
8
+ readonly note: (text: string) => void;
7
9
  }
8
10
  type Command = (outbound: OutboundApi, input: CommandInput) => Promise<Json>;
9
11
  /** The tools `outbound mcp` offers: the built-in ones, then the insights. */
10
12
  export declare const offeredTools: (outbound: OutboundApi) => Promise<OutboundTool[]>;
11
13
  export interface CommandSpec {
12
14
  readonly help: string;
15
+ /** The options this command takes, besides the ones every command takes. */
16
+ readonly flags: readonly string[];
13
17
  readonly run: Command;
14
18
  }
19
+ /** The options every command takes. */
20
+ export declare const GLOBAL_FLAGS: string[];
21
+ /** Refuses an option the command does not take, instead of ignoring it. */
22
+ export declare const checkFlags: (name: string, flags: readonly string[], given: readonly string[]) => void;
15
23
  export declare const COMMANDS: Map<string, CommandSpec>;
16
24
  /** The provider catalog. Needs no adapter and no key. */
17
25
  export declare const listProviders: () => Json;
26
+ /** Every command with its options, then the options every command takes. */
18
27
  export declare const helpText: () => string;
28
+ /** One command's options, then the options every command takes. */
29
+ export declare const commandHelp: (command: CommandSpec) => string;
19
30
  export {};
@@ -4,6 +4,7 @@ export type { CliConfig } from "./config.ts";
4
4
  export { createMcpServer, PROTOCOL_VERSIONS } from "./mcp.ts";
5
5
  export type { McpServer, McpServerOptions } from "./mcp.ts";
6
6
  export { serveStdio } from "./stdio.ts";
7
+ export type { NpmRunner } from "./update.ts";
7
8
  export type { StdioOptions } from "./stdio.ts";
8
9
  export interface CliIo {
9
10
  readonly stdout: (text: string) => void;
@@ -12,6 +13,8 @@ export interface CliIo {
12
13
  readonly stdin?: (() => AsyncIterable<string> | Iterable<string>) | undefined;
13
14
  /** Replaces the adapter the environment would choose. Meant for tests. */
14
15
  readonly adapter?: Adapter | undefined;
16
+ /** Runs npm for `outbound update` and resolves to its output. Meant for tests. */
17
+ readonly npm?: ((args: readonly string[]) => Promise<string>) | undefined;
15
18
  }
16
19
  /** Runs the CLI. Returns the process exit code. */
17
20
  export declare const run: (argv: readonly string[], io: CliIo) => Promise<number>;
package/dist/cli/index.js CHANGED
@@ -4,23 +4,28 @@ import {
4
4
  defineConfig,
5
5
  run,
6
6
  serveStdio
7
- } from "../chunks/chunk-P3IJBJUI.js";
8
- import "../chunks/chunk-R3Y56YVF.js";
9
- import "../chunks/chunk-AFU5E5QB.js";
7
+ } from "../chunks/chunk-X4RDBD4J.js";
8
+ import "../chunks/chunk-OLPMBRXM.js";
9
+ import "../chunks/chunk-BK5SLY32.js";
10
+ import "../chunks/chunk-HWHI4LFY.js";
11
+ import "../chunks/chunk-4PA526S7.js";
10
12
  import "../chunks/chunk-HZCTYL22.js";
11
- import "../chunks/chunk-XNFESPZH.js";
13
+ import "../chunks/chunk-YYCT3NGV.js";
12
14
  import "../chunks/chunk-4O2HRTTI.js";
13
- import "../chunks/chunk-YOTW5ESM.js";
15
+ import "../chunks/chunk-HPNGSG5E.js";
16
+ import "../chunks/chunk-ZOAG2C6V.js";
17
+ import "../chunks/chunk-PTZO4QXR.js";
18
+ import "../chunks/chunk-BOWXGMN3.js";
19
+ import "../chunks/chunk-PQSTQKRD.js";
20
+ import "../chunks/chunk-QGRZDTX4.js";
21
+ import "../chunks/chunk-QAKJ76HB.js";
14
22
  import "../chunks/chunk-NAWZ73QS.js";
15
23
  import "../chunks/chunk-FHKSLCVW.js";
16
- import "../chunks/chunk-RCZ7ZZFU.js";
17
- import "../chunks/chunk-IPUYZD4O.js";
18
- import "../chunks/chunk-XC6CZP73.js";
19
- import "../chunks/chunk-UAT3JSJZ.js";
20
- import "../chunks/chunk-4PSO6JEK.js";
21
- import "../chunks/chunk-LVYG7XZJ.js";
22
- import "../chunks/chunk-E7JHLNLG.js";
23
- import "../chunks/chunk-VQSCHOBV.js";
24
+ import "../chunks/chunk-5J7GGV62.js";
25
+ import "../chunks/chunk-GFDNRWR3.js";
26
+ import "../chunks/chunk-J7DDZ4C2.js";
27
+ import "../chunks/chunk-BLCJHP5H.js";
28
+ import "../chunks/chunk-WH6V3YNN.js";
24
29
  export {
25
30
  PROTOCOL_VERSIONS,
26
31
  createMcpServer,
package/dist/cli/mcp.d.ts CHANGED
@@ -4,6 +4,11 @@ import type { ToolsOptions } from "../tools/index.ts";
4
4
  export declare const PROTOCOL_VERSIONS: readonly ["2025-06-18", "2025-03-26", "2024-11-05"];
5
5
  export interface McpServerOptions extends ToolsOptions {
6
6
  readonly version?: string | undefined;
7
+ /**
8
+ * Tools left out of this server, by name, with the reason. A call to one
9
+ * is answered with the reason instead of `Unknown tool`.
10
+ */
11
+ readonly leftOut?: Readonly<Record<string, string>> | undefined;
7
12
  }
8
13
  export interface McpServer {
9
14
  /** Handles one JSON-RPC message. Returns `undefined` for a notification. */