outbound-sdk 0.4.0 → 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 (90) 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 +635 -2
  8. package/dist/budget/index.d.ts +2 -0
  9. package/dist/budget/index.js +1 -0
  10. package/dist/cards/index.js +2 -1
  11. package/dist/chunks/{chunk-5CFO3CXG.js → chunk-3S32R2MH.js} +33 -67
  12. package/dist/chunks/{chunk-ZFVHM5JI.js → chunk-5J7GGV62.js} +11 -4
  13. package/dist/chunks/chunk-6TKFISG4.js +676 -0
  14. package/dist/chunks/{chunk-E6DSDCPI.js → chunk-BK5SLY32.js} +92 -101
  15. package/dist/chunks/{chunk-A6WVOCA4.js → chunk-BN6WCAWX.js} +4 -4
  16. package/dist/chunks/{chunk-IZFTTMJP.js → chunk-EHSJGQ5K.js} +5 -5
  17. package/dist/chunks/chunk-HPNGSG5E.js +51 -0
  18. package/dist/chunks/chunk-HWHI4LFY.js +102 -0
  19. package/dist/chunks/{chunk-Y5RAJ6PZ.js → chunk-OLPMBRXM.js} +3 -2
  20. package/dist/chunks/chunk-WGW3ROLY.js +18 -0
  21. package/dist/chunks/{chunk-7ZDS6SZD.js → chunk-WH6V3YNN.js} +25 -0
  22. package/dist/chunks/{chunk-7LNJJ2RO.js → chunk-X4RDBD4J.js} +102 -11
  23. package/dist/chunks/chunk-XL6LJVHJ.js +71 -0
  24. package/dist/chunks/{chunk-5FVKRIEJ.js → chunk-YYCT3NGV.js} +35 -11
  25. package/dist/cli/bin.js +13 -28
  26. package/dist/cli/index.d.ts +3 -0
  27. package/dist/cli/index.js +12 -11
  28. package/dist/cli/update.d.ts +15 -0
  29. package/dist/emailbison/account.d.ts +7 -0
  30. package/dist/emailbison/adapter.d.ts +5 -0
  31. package/dist/emailbison/capabilities.d.ts +78 -0
  32. package/dist/emailbison/client.d.ts +29 -0
  33. package/dist/emailbison/index.d.ts +30 -0
  34. package/dist/emailbison/index.js +1017 -0
  35. package/dist/emailbison/mail.d.ts +5 -0
  36. package/dist/emailbison/map-mail.d.ts +13 -0
  37. package/dist/emailbison/map-sequence.d.ts +12 -0
  38. package/dist/emailbison/map-stats.d.ts +47 -0
  39. package/dist/emailbison/map.d.ts +24 -0
  40. package/dist/emailbison/native-params.d.ts +5 -0
  41. package/dist/emailbison/native-workspace.d.ts +167 -0
  42. package/dist/emailbison/native.d.ts +327 -0
  43. package/dist/emailbison/stats.d.ts +4 -0
  44. package/dist/emailbison/webhooks.d.ts +2 -0
  45. package/dist/fixtures/index.js +6 -6
  46. package/dist/heyreach/capabilities.d.ts +3 -0
  47. package/dist/heyreach/index.js +20 -20
  48. package/dist/index.js +19 -18
  49. package/dist/insights/copy/copy-reuse.d.ts +6 -6
  50. package/dist/insights/copy/shared.d.ts +2 -2
  51. package/dist/insights/copy/step-funnel.d.ts +5 -5
  52. package/dist/insights/copy/variant-test.d.ts +2 -2
  53. package/dist/insights/cost.d.ts +91 -0
  54. package/dist/insights/define.d.ts +22 -1
  55. package/dist/insights/index.d.ts +4 -3
  56. package/dist/insights/index.js +331 -27
  57. package/dist/insights/inputs.generated.d.ts +4 -4
  58. package/dist/insights/ops/campaign-ranking.d.ts +3 -3
  59. package/dist/insights/ops/index.d.ts +2 -2
  60. package/dist/insights/ops/shared.d.ts +11 -1
  61. package/dist/insights/plugin.d.ts +19 -0
  62. package/dist/insights/registry.d.ts +2 -2
  63. package/dist/insights/run-cap.d.ts +35 -0
  64. package/dist/insights/senders/bounce-watch.d.ts +4 -4
  65. package/dist/insights/senders/domain-health.d.ts +2 -2
  66. package/dist/insights/senders/sender-load.d.ts +1 -1
  67. package/dist/insights/tools.d.ts +10 -0
  68. package/dist/instantly/capabilities.d.ts +13 -0
  69. package/dist/instantly/index.js +41 -28
  70. package/dist/internal/adapter.d.ts +12 -0
  71. package/dist/internal/outbound/outbound.d.ts +5 -1
  72. package/dist/internal/request-cap.d.ts +35 -0
  73. package/dist/loader/index.js +2 -2
  74. package/dist/memory/index.js +10 -10
  75. package/dist/providers/index.d.ts +21 -1
  76. package/dist/providers/index.js +1 -1
  77. package/dist/redact/index.js +4 -4
  78. package/dist/smartlead/capabilities.d.ts +5 -0
  79. package/dist/smartlead/index.js +24 -24
  80. package/dist/tools/ai-sdk.js +5 -3
  81. package/dist/tools/claude-agent.js +5 -3
  82. package/dist/tools/index.d.ts +2 -2
  83. package/dist/tools/index.js +11 -6
  84. package/dist/tools/registry.d.ts +20 -1
  85. package/dist/tools/shared.d.ts +20 -1
  86. package/dist/webhooks/index.js +16 -7
  87. package/package.json +8 -2
  88. package/dist/chunks/chunk-K4USHN4C.js +0 -40
  89. package/dist/chunks/chunk-LVQUSKEX.js +0 -17
  90. package/dist/chunks/{chunk-C4LS2HNV.js → chunk-JWGSB7PT.js} +3 -3
@@ -399,7 +399,7 @@ export interface InsightInputs {
399
399
  */
400
400
  readonly max_spam_rate?: number | undefined;
401
401
  /**
402
- * @deprecated Renamed to `max_spam_rate`. Removed in 0.5.0.
402
+ * @deprecated Renamed to `max_spam_rate`. Removed in 0.6.0.
403
403
  *
404
404
  * A number from 0 to 1.
405
405
  */
@@ -477,7 +477,7 @@ export interface InsightInputs {
477
477
  */
478
478
  readonly min_sent?: number | undefined;
479
479
  /**
480
- * @deprecated Renamed to `max_bounce_rate`. Removed in 0.5.0.
480
+ * @deprecated Renamed to `max_bounce_rate`. Removed in 0.6.0.
481
481
  *
482
482
  * A number from 0 to 1.
483
483
  */
@@ -663,7 +663,7 @@ export interface InsightInputs {
663
663
  */
664
664
  readonly min_weekly_hours?: number | undefined;
665
665
  /**
666
- * @deprecated Renamed to `days`. Removed in 0.5.0.
666
+ * @deprecated Renamed to `days`. Removed in 0.6.0.
667
667
  *
668
668
  * A whole number from 1 to 30.
669
669
  */
@@ -942,7 +942,7 @@ export interface InsightInputs {
942
942
  */
943
943
  readonly runway_days?: number | undefined;
944
944
  /**
945
- * @deprecated Renamed to `limit`. Removed in 0.5.0.
945
+ * @deprecated Renamed to `limit`. Removed in 0.6.0.
946
946
  *
947
947
  * A whole number from 1 to 20.
948
948
  */
@@ -2,8 +2,8 @@ import { z } from "zod";
2
2
  import type { CampaignsRead } from "../capped.ts";
3
3
  import type { CampaignLabel, CampaignTotals, Measured, OpenRange, ReplyBasis } from "./shared.ts";
4
4
  declare const metricSchema: z.ZodEnum<{
5
- reply_rate: "reply_rate";
6
5
  bounce_rate: "bounce_rate";
6
+ reply_rate: "reply_rate";
7
7
  positive_reply_rate: "positive_reply_rate";
8
8
  }>;
9
9
  export type RankingMetric = z.infer<typeof metricSchema>;
@@ -47,14 +47,14 @@ export interface CampaignRanking extends Ranking, CampaignsRead {
47
47
  */
48
48
  export declare const rankCampaigns: (entries: readonly CampaignTotals[], metric: RankingMetric, minSent: number, replyBasis?: ReplyBasis) => Ranking;
49
49
  export declare const campaignRanking: import("../define.ts").InsightDefinition<"campaignRanking", {
50
- metric: "reply_rate" | "bounce_rate" | "positive_reply_rate";
50
+ metric: "bounce_rate" | "reply_rate" | "positive_reply_rate";
51
51
  min_sent: number;
52
52
  max_campaigns: number;
53
53
  statuses: ("active" | "archived" | "completed" | "draft" | "paused" | "unknown")[];
54
54
  from: string | null;
55
55
  to: string | null;
56
56
  }, CampaignRanking, {
57
- metric?: "reply_rate" | "bounce_rate" | "positive_reply_rate" | undefined;
57
+ metric?: "bounce_rate" | "reply_rate" | "positive_reply_rate" | undefined;
58
58
  min_sent?: number | undefined;
59
59
  max_campaigns?: number | undefined;
60
60
  statuses?: ("active" | "archived" | "completed" | "draft" | "paused" | "unknown")[] | undefined;
@@ -61,14 +61,14 @@ export declare const OPS_INSIGHTS: readonly [import("../define.ts").InsightDefin
61
61
  max_campaigns?: number | undefined;
62
62
  statuses?: ("active" | "archived" | "completed" | "draft" | "paused" | "unknown")[] | undefined;
63
63
  }>, import("../define.ts").InsightDefinition<"campaignRanking", {
64
- metric: "reply_rate" | "bounce_rate" | "positive_reply_rate";
64
+ metric: "bounce_rate" | "reply_rate" | "positive_reply_rate";
65
65
  min_sent: number;
66
66
  max_campaigns: number;
67
67
  statuses: ("active" | "archived" | "completed" | "draft" | "paused" | "unknown")[];
68
68
  from: string | null;
69
69
  to: string | null;
70
70
  }, import("./campaign-ranking.ts").CampaignRanking, {
71
- metric?: "reply_rate" | "bounce_rate" | "positive_reply_rate" | undefined;
71
+ metric?: "bounce_rate" | "reply_rate" | "positive_reply_rate" | undefined;
72
72
  min_sent?: number | undefined;
73
73
  max_campaigns?: number | undefined;
74
74
  statuses?: ("active" | "archived" | "completed" | "draft" | "paused" | "unknown")[] | undefined;
@@ -2,6 +2,7 @@ import { z } from "zod";
2
2
  import type { Campaign, CampaignStatus } from "../../internal/entities.ts";
3
3
  import type { MetricCounts } from "../../internal/metrics.ts";
4
4
  import type { CampaignsRead } from "../capped.ts";
5
+ import type { Price } from "../cost.ts";
5
6
  import type { InsightContext } from "../define.ts";
6
7
  /** The UTC day of a time, as `YYYY-MM-DD`. */
7
8
  export declare const dayOf: (time: number) => string;
@@ -25,6 +26,15 @@ export interface OpenRange {
25
26
  readonly to: string | null;
26
27
  }
27
28
  /** Input fields the campaign-listing insights share. */
29
+ /**
30
+ * What `readCampaignTotals` costs: the listing, then one stats read per
31
+ * campaign, or one for all of them where the vendor reports every campaign
32
+ * in one call (and one each for the campaigns that report leaves out).
33
+ */
34
+ export declare const campaignTotalsCost: (input: {
35
+ readonly max_campaigns: number;
36
+ readonly statuses: readonly string[];
37
+ }, price: Price) => number;
28
38
  export declare const listFields: (costPerCampaign: string) => {
29
39
  max_campaigns: z.ZodDefault<z.ZodNumber>;
30
40
  statuses: z.ZodDefault<z.ZodArray<z.ZodEnum<{
@@ -40,7 +50,7 @@ export interface CampaignLabel {
40
50
  /** The campaign's ref. */
41
51
  readonly campaign: string;
42
52
  readonly campaignName: string;
43
- /** @deprecated Use `campaignName`. Removed in 0.5.0. */
53
+ /** @deprecated Use `campaignName`. Removed in 0.6.0. */
44
54
  readonly name: string;
45
55
  readonly status: CampaignStatus;
46
56
  readonly channel: "email" | "linkedin";
@@ -20,6 +20,25 @@ export interface InsightsExtension {
20
20
  }
21
21
  /** Runs one insight by its tool name or method name, with JSON input. Rejects with `Invalid` for an unknown name. */
22
22
  export declare const runInsightByName: (outbound: OutboundApi, name: string, input?: Json, options?: RunOptions) => Promise<InsightResult<Json>>;
23
+ /** What one run of an insight can cost, in vendor requests. */
24
+ export interface InsightCostEstimate {
25
+ /** The least it can send: what is refused before any request when over the cap. */
26
+ readonly min: number;
27
+ /** The most it can send without retries, every cap in its input reached. */
28
+ readonly max: number;
29
+ /** The cap it runs under when none is set. */
30
+ readonly defaultCap: number;
31
+ }
32
+ /**
33
+ * What an insight costs for this input on this instance, or `null` when the
34
+ * adapter declares no costs (a combined instance) or the insight states none.
35
+ * Throws `Invalid` for an unknown insight or an input its schema refuses.
36
+ *
37
+ * ```ts
38
+ * insightCost(outbound, "client_report"); // { min: 3, max: 226, defaultCap: 287 }
39
+ * ```
40
+ */
41
+ export declare const insightCost: (outbound: OutboundApi, name: string, input?: Json) => InsightCostEstimate | null;
23
42
  export interface ListedInsight {
24
43
  readonly name: string;
25
44
  readonly key: string;
@@ -276,14 +276,14 @@ export declare const INSIGHTS: readonly [import("./define.ts").InsightDefinition
276
276
  max_campaigns?: number | undefined;
277
277
  statuses?: ("active" | "archived" | "completed" | "draft" | "paused" | "unknown")[] | undefined;
278
278
  }>, import("./define.ts").InsightDefinition<"campaignRanking", {
279
- metric: "reply_rate" | "bounce_rate" | "positive_reply_rate";
279
+ metric: "bounce_rate" | "reply_rate" | "positive_reply_rate";
280
280
  min_sent: number;
281
281
  max_campaigns: number;
282
282
  statuses: ("active" | "archived" | "completed" | "draft" | "paused" | "unknown")[];
283
283
  from: string | null;
284
284
  to: string | null;
285
285
  }, import("./ops/campaign-ranking.ts").CampaignRanking, {
286
- metric?: "reply_rate" | "bounce_rate" | "positive_reply_rate" | undefined;
286
+ metric?: "bounce_rate" | "reply_rate" | "positive_reply_rate" | undefined;
287
287
  min_sent?: number | undefined;
288
288
  max_campaigns?: number | undefined;
289
289
  statuses?: ("active" | "archived" | "completed" | "draft" | "paused" | "unknown")[] | undefined;
@@ -0,0 +1,35 @@
1
+ import type { OutboundApi } from "../internal/outbound/api.ts";
2
+ import type { InsightCost } from "./cost.ts";
3
+ export interface CapOptions {
4
+ /**
5
+ * The most vendor requests the whole insight may send, retries included,
6
+ * across every read it makes. Replaces the default cap, which is worked
7
+ * out from the input; `Infinity` removes it. A `maxRequestsPerCall` on the
8
+ * instance and `budget()` still apply under it.
9
+ */
10
+ readonly maxRequests?: number | undefined;
11
+ /**
12
+ * Set by the insight tools: the default cap is at most this much, and the
13
+ * messages name `capSetting`. Not for direct use.
14
+ */
15
+ readonly capCeiling?: number | undefined;
16
+ /** The setting a cap message tells the caller to raise. Not for direct use. */
17
+ readonly capSetting?: string | undefined;
18
+ }
19
+ /** What of an insight the cap needs. */
20
+ export interface Capped<Input> {
21
+ readonly name: string;
22
+ readonly cost?: InsightCost<Input> | undefined;
23
+ readonly scales?: string | undefined;
24
+ }
25
+ export interface RunCap {
26
+ /** The instance to read through: every request on it is counted. */
27
+ readonly outbound: OutboundApi;
28
+ /** Refuses the run when the least `count` campaigns cost is over what it may spend. */
29
+ readonly campaignsFound: (count: number) => void;
30
+ /** Throws the cap's own error when the cap stopped a read, else `error`. */
31
+ readonly failed: (cause: unknown) => never;
32
+ /** The note for a run that finished without reads the cap stopped. */
33
+ readonly shortNote: () => string | undefined;
34
+ }
35
+ export declare const runCap: <Input>(outbound: OutboundApi, spec: Capped<Input>, input: Input, options: CapOptions) => RunCap;
@@ -5,7 +5,7 @@ export interface BounceCounts extends Measured {
5
5
  readonly sent: number;
6
6
  /** Bounced (`count`) divided by sent (`of`). `null` when nothing was sent. */
7
7
  readonly rate: number | null;
8
- /** @deprecated Use `low` and `high`, the Wilson interval of the rate. Removed in 0.5.0. */
8
+ /** @deprecated Use `low` and `high`, the Wilson interval of the rate. Removed in 0.6.0. */
9
9
  readonly interval: Interval | null;
10
10
  }
11
11
  export interface BounceSender extends BounceCounts {
@@ -16,7 +16,7 @@ export interface BounceSender extends BounceCounts {
16
16
  export interface BounceCampaign extends BounceCounts {
17
17
  readonly campaign: string;
18
18
  readonly campaignName: string;
19
- /** @deprecated Use `campaignName`. Removed in 0.5.0. */
19
+ /** @deprecated Use `campaignName`. Removed in 0.6.0. */
20
20
  readonly name: string;
21
21
  readonly status: string;
22
22
  readonly finding: string;
@@ -30,7 +30,7 @@ export interface BounceCampaign extends BounceCounts {
30
30
  export interface BounceUnknown {
31
31
  readonly campaign: string;
32
32
  readonly campaignName: string;
33
- /** @deprecated Use `campaignName`. Removed in 0.5.0. */
33
+ /** @deprecated Use `campaignName`. Removed in 0.6.0. */
34
34
  readonly name: string;
35
35
  readonly status: string;
36
36
  readonly reason: string;
@@ -55,7 +55,7 @@ export interface BounceWatch {
55
55
  };
56
56
  /** The `max_bounce_rate` the campaigns were held to. */
57
57
  readonly maxBounceRate: number;
58
- /** @deprecated Use `maxBounceRate`. Removed in 0.5.0. */
58
+ /** @deprecated Use `maxBounceRate`. Removed in 0.6.0. */
59
59
  readonly threshold: number;
60
60
  readonly minSent: number;
61
61
  /**
@@ -18,9 +18,9 @@ export interface DomainWarmup extends Measured {
18
18
  readonly mailboxes: number;
19
19
  readonly sent: number | null;
20
20
  readonly spam: number | null;
21
- /** @deprecated Use `rate`: warmup emails in spam (`count`) over those sent (`of`). Removed in 0.5.0. */
21
+ /** @deprecated Use `rate`: warmup emails in spam (`count`) over those sent (`of`). Removed in 0.6.0. */
22
22
  readonly spamRate: number | null;
23
- /** @deprecated Use `low` and `high`. Removed in 0.5.0. */
23
+ /** @deprecated Use `low` and `high`. Removed in 0.6.0. */
24
24
  readonly interval: Interval | null;
25
25
  }
26
26
  export interface DomainReport {
@@ -16,7 +16,7 @@ export type CampaignSenderIssue = "inactive_sender" | "no_sender" | "single_send
16
16
  export interface CampaignSenderRisk {
17
17
  readonly campaign: string;
18
18
  readonly campaignName: string;
19
- /** @deprecated Use `campaignName`. Removed in 0.5.0. */
19
+ /** @deprecated Use `campaignName`. Removed in 0.6.0. */
20
20
  readonly name: string;
21
21
  readonly senders: number;
22
22
  readonly issues: readonly CampaignSenderIssue[];
@@ -3,7 +3,17 @@ import type { OutboundTool } from "../tools/index.ts";
3
3
  export interface InsightToolsOptions {
4
4
  /** Offer only these insights, by tool name. Defaults to every one the adapter can serve. */
5
5
  readonly only?: readonly string[] | undefined;
6
+ /**
7
+ * The most vendor requests one tool call may send, retries included,
8
+ * across every read the insight makes. Without it a call may send what its
9
+ * input can cost (the insight's default cap), but never more than 500, so a
10
+ * model cannot buy a larger cap by raising a `max_*` input. `Infinity`
11
+ * removes the default.
12
+ */
13
+ readonly maxRequestsPerToolCall?: number | undefined;
6
14
  }
15
+ /** The most an insight tool call may send when no cap is set, whatever its input. */
16
+ export declare const INSIGHT_TOOL_CEILING = 500;
7
17
  /**
8
18
  * The insights this instance can serve, as tools. An insight whose adapter
9
19
  * lacks a capability or a field it needs, or that cannot match records while the redact
@@ -20,6 +20,7 @@ export declare const costs: {
20
20
  "blocklist.list": {
21
21
  pageSize: number;
22
22
  perPage: number;
23
+ perWalk: number;
23
24
  };
24
25
  "campaigns.get": {
25
26
  perPage: number;
@@ -27,28 +28,36 @@ export declare const costs: {
27
28
  "campaigns.list": {
28
29
  pageSize: number;
29
30
  perPage: number;
31
+ perWalk: number;
30
32
  };
31
33
  "campaigns.settings": {
32
34
  perPage: number;
33
35
  };
34
36
  "leads.get": {
35
37
  perPage: number;
38
+ perWalk: number;
36
39
  };
37
40
  "leads.list": {
38
41
  pageSize: number;
39
42
  perPage: number;
43
+ perPageAtMost: number;
44
+ perWalk: number;
40
45
  };
41
46
  "lists.list": {
42
47
  pageSize: number;
43
48
  perPage: number;
49
+ perWalk: number;
44
50
  };
45
51
  "messages.list": {
46
52
  pageSize: number;
47
53
  perPage: number;
54
+ perWalk: number;
48
55
  };
49
56
  "replies.list": {
50
57
  pageSize: number;
51
58
  perPage: number;
59
+ perPageAtMost: number;
60
+ perWalk: number;
52
61
  };
53
62
  "senders.get": {
54
63
  perPage: number;
@@ -59,6 +68,7 @@ export declare const costs: {
59
68
  "senders.list": {
60
69
  pageSize: number;
61
70
  perPage: number;
71
+ perWalk: number;
62
72
  };
63
73
  "sequence.get": {
64
74
  perPage: number;
@@ -66,6 +76,7 @@ export declare const costs: {
66
76
  "sequence.subsequences": {
67
77
  pageSize: number;
68
78
  perPage: number;
79
+ perWalk: number;
69
80
  };
70
81
  stats: {
71
82
  perPage: number;
@@ -73,10 +84,12 @@ export declare const costs: {
73
84
  "tags.list": {
74
85
  pageSize: number;
75
86
  perPage: number;
87
+ perWalk: number;
76
88
  };
77
89
  "webhooks.list": {
78
90
  pageSize: number;
79
91
  perPage: number;
92
+ perWalk: number;
80
93
  };
81
94
  "workspaces.list": {
82
95
  perPage: number;
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  EVENT_TYPES,
3
3
  instantlyEvents
4
- } from "../chunks/chunk-A6WVOCA4.js";
4
+ } from "../chunks/chunk-BN6WCAWX.js";
5
5
  import {
6
- createVendorClient,
7
6
  flatMapPage,
8
- listIn,
9
7
  mapPage,
10
- normalizeBody,
11
8
  withLeadFields,
12
9
  withMappedFields
13
- } from "../chunks/chunk-5CFO3CXG.js";
10
+ } from "../chunks/chunk-XL6LJVHJ.js";
14
11
  import {
12
+ createVendorClient,
15
13
  leadStanding,
14
+ listIn,
15
+ normalizeBody,
16
16
  toVariant,
17
17
  variantKey
18
- } from "../chunks/chunk-K4USHN4C.js";
18
+ } from "../chunks/chunk-3S32R2MH.js";
19
19
  import {
20
20
  defineNative,
21
21
  inBody,
@@ -24,17 +24,6 @@ import {
24
24
  inQuery,
25
25
  inQueryRequired
26
26
  } from "../chunks/chunk-NAKXLBA6.js";
27
- import {
28
- emptyCounts,
29
- metricRow,
30
- sumCounts
31
- } from "../chunks/chunk-PQSTQKRD.js";
32
- import "../chunks/chunk-NAWZ73QS.js";
33
- import "../chunks/chunk-FHKSLCVW.js";
34
- import {
35
- readEnv,
36
- requireCredential
37
- } from "../chunks/chunk-GFDNRWR3.js";
38
27
  import {
39
28
  eventTypesOf,
40
29
  recordBase,
@@ -42,10 +31,21 @@ import {
42
31
  refsTo
43
32
  } from "../chunks/chunk-2D42TQFU.js";
44
33
  import "../chunks/chunk-BOWXGMN3.js";
34
+ import {
35
+ emptyCounts,
36
+ metricRow,
37
+ sumCounts
38
+ } from "../chunks/chunk-PQSTQKRD.js";
45
39
  import "../chunks/chunk-QGRZDTX4.js";
46
40
  import {
47
41
  assertWorkspaceId
48
42
  } from "../chunks/chunk-QAKJ76HB.js";
43
+ import "../chunks/chunk-NAWZ73QS.js";
44
+ import "../chunks/chunk-FHKSLCVW.js";
45
+ import {
46
+ readEnv,
47
+ requireCredential
48
+ } from "../chunks/chunk-GFDNRWR3.js";
49
49
  import {
50
50
  OutboundError,
51
51
  makeErrorMapper,
@@ -511,26 +511,39 @@ var limits = {
511
511
  ]
512
512
  };
513
513
  var costs = {
514
- "blocklist.list": { pageSize: PAGE_SIZE, perPage: 1 },
514
+ "blocklist.list": { pageSize: PAGE_SIZE, perPage: 1, perWalk: 1 },
515
515
  // The campaign, its tag assignments, then the tags' names.
516
516
  "campaigns.get": { perPage: 3 },
517
517
  // The campaigns, their tag assignments, then the tags' names.
518
- "campaigns.list": { pageSize: PAGE_SIZE, perPage: 3 },
518
+ "campaigns.list": { pageSize: PAGE_SIZE, perPage: 3, perWalk: 1 },
519
519
  "campaigns.settings": { perPage: 1 },
520
- "leads.get": { perPage: 1 },
521
- "leads.list": { pageSize: PAGE_SIZE, perPage: 1 },
522
- "lists.list": { pageSize: PAGE_SIZE, perPage: 1 },
523
- "messages.list": { pageSize: PAGE_SIZE, perPage: 1 },
524
- "replies.list": { pageSize: PAGE_SIZE, perPage: 1 },
520
+ // A custom interest label costs one more read of the label list, made only
521
+ // when the lead or a page of leads holds one.
522
+ "leads.get": { perPage: 1, perWalk: 1 },
523
+ "leads.list": {
524
+ pageSize: PAGE_SIZE,
525
+ perPage: 1,
526
+ perPageAtMost: 2,
527
+ perWalk: 1
528
+ },
529
+ "lists.list": { pageSize: PAGE_SIZE, perPage: 1, perWalk: 1 },
530
+ "messages.list": { pageSize: PAGE_SIZE, perPage: 1, perWalk: 1 },
531
+ // The same label read, for a page of replies with a custom status.
532
+ "replies.list": {
533
+ pageSize: PAGE_SIZE,
534
+ perPage: 1,
535
+ perPageAtMost: 2,
536
+ perWalk: 1
537
+ },
525
538
  "senders.get": { perPage: 1 },
526
539
  // The account, its DNS test, then its warmup analytics.
527
540
  "senders.health": { perPage: 3 },
528
- "senders.list": { pageSize: PAGE_SIZE, perPage: 1 },
541
+ "senders.list": { pageSize: PAGE_SIZE, perPage: 1, perWalk: 1 },
529
542
  "sequence.get": { perPage: 1 },
530
- "sequence.subsequences": { pageSize: PAGE_SIZE, perPage: 1 },
543
+ "sequence.subsequences": { pageSize: PAGE_SIZE, perPage: 1, perWalk: 1 },
531
544
  stats: { perPage: 1 },
532
- "tags.list": { pageSize: PAGE_SIZE, perPage: 1 },
533
- "webhooks.list": { pageSize: PAGE_SIZE, perPage: 1 },
545
+ "tags.list": { pageSize: PAGE_SIZE, perPage: 1, perWalk: 1 },
546
+ "webhooks.list": { pageSize: PAGE_SIZE, perPage: 1, perWalk: 1 },
534
547
  "workspaces.list": { perPage: 1 }
535
548
  };
536
549
  var caveats = [
@@ -139,6 +139,18 @@ export interface OperationCost {
139
139
  readonly pageSize?: number | undefined;
140
140
  /** Extra requests per record, for example one per lead to fetch a body. */
141
141
  readonly perRecord?: number | undefined;
142
+ /**
143
+ * The most extra requests a listing makes once, whatever its length, for
144
+ * example a lookup of category names on its first page. Counted in the
145
+ * upper bound of an insight's cost, never in its lower bound.
146
+ */
147
+ readonly perWalk?: number | undefined;
148
+ /**
149
+ * The most requests one page can cost, when some pages cost more than
150
+ * `perPage`, for example a label lookup made only when a page holds a
151
+ * custom label. Counted in the upper bound of an insight's cost only.
152
+ */
153
+ readonly perPageAtMost?: number | undefined;
142
154
  }
143
155
  export interface Adapter<Native extends NativeCatalog = NoNative> {
144
156
  readonly name: string;
@@ -9,6 +9,8 @@ import type { Campaign, Lead, Message, Reply, Sender, Workspace } from "../entit
9
9
  import type { FieldCoverage } from "../fields.ts";
10
10
  import type { OutboundHooks } from "../hooks.ts";
11
11
  import type { NativeCatalog, NoNative } from "../native.ts";
12
+ import { CAPPED } from "../request-cap.ts";
13
+ import type { CappedAccess } from "../request-cap.ts";
12
14
  import type { CampaignFilters, CampaignHandle, Collection, Estimate, EstimateQuery, LeadFilters, LeadHandle, ListHandle, MessageFilters, NativeClient, OutboundApi, RawClient, ReadCollection, ReplyFilters, SenderFilters, SenderHandle, StatsResult, ThreadHandle, TopLevelStatsOptions, WebhookFilters } from "./api.ts";
13
15
  import type { OutboundPlugin } from "./plugins.ts";
14
16
  export interface OutboundOptions<Native extends NativeCatalog = NoNative> extends Omit<OperationOptions, "maxRequests"> {
@@ -54,7 +56,7 @@ export declare class Outbound<Native extends NativeCatalog = NoNative> implement
54
56
  readonly webhooks: Collection<WebhookSubscription, WebhookFilters>;
55
57
  readonly raw: RawClient;
56
58
  readonly native: NativeClient<Native>;
57
- constructor(options: OutboundOptions<Native>, engine?: RequestEngine);
59
+ constructor(options: OutboundOptions<Native>, engine?: RequestEngine, layers?: readonly OutboundPlugin[]);
58
60
  get provider(): string;
59
61
  get workspaceId(): string;
60
62
  get capabilities(): Capabilities;
@@ -73,6 +75,8 @@ export declare class Outbound<Native extends NativeCatalog = NoNative> implement
73
75
  * plugins and what they add, so `outbound.workspace(id).insights` works.
74
76
  */
75
77
  workspace(id: string): this;
78
+ /** For a cap shared across calls, as insights and tools use. Not public. */
79
+ get [CAPPED](): CappedAccess;
76
80
  stats(options?: TopLevelStatsOptions): Promise<StatsResult>;
77
81
  limits(): Promise<LimitsSnapshot[]>;
78
82
  estimate(query: EstimateQuery): Estimate;
@@ -0,0 +1,35 @@
1
+ import type { OperationCost } from "./adapter.ts";
2
+ import type { OutboundApi } from "./outbound/api.ts";
3
+ import type { OutboundPlugin } from "./outbound/plugins.ts";
4
+ export declare const CAPPED: unique symbol;
5
+ /** Counts requests as they are sent, and stops one that would pass the cap. */
6
+ export interface RequestGuard {
7
+ /** Throws when no request is left. Runs before the request is sent. */
8
+ readonly check: (provider: string) => void;
9
+ /** Counts the request being sent. */
10
+ readonly count: () => void;
11
+ }
12
+ export interface CappedAccess {
13
+ /** What the adapter's reads cost, or `undefined` when it declares none. */
14
+ readonly costs: Readonly<Record<string, OperationCost>> | undefined;
15
+ /** The same instance with `layer` innermost, kept out of `plugins`. */
16
+ readonly guarded: (layer: OutboundPlugin) => OutboundApi;
17
+ }
18
+ /** What an instance built by `createOutbound` offers for a shared cap; `undefined` on anything else. */
19
+ export declare const cappedAccess: (outbound: OutboundApi) => CappedAccess | undefined;
20
+ export interface RequestCounter extends RequestGuard {
21
+ /** Requests counted so far. */
22
+ readonly used: () => number;
23
+ /** `true` once a request was stopped at the cap. */
24
+ readonly stopped: () => boolean;
25
+ }
26
+ /**
27
+ * Allows `cap` requests in all. `stop` builds the error for the request that
28
+ * would pass it. `Infinity` counts without stopping.
29
+ */
30
+ export declare const requestCounter: (cap: number, stop: (provider: string) => Error) => RequestCounter;
31
+ /**
32
+ * `outbound` with every request counted by `guard`. An instance not built by
33
+ * `createOutbound` is returned as it is: there is nothing to count through.
34
+ */
35
+ export declare const withGuard: <Api extends OutboundApi>(outbound: Api, guard: RequestGuard) => Api;
@@ -3,11 +3,11 @@ import {
3
3
  configuredProviders,
4
4
  fromEnv,
5
5
  loadableProviders
6
- } from "../chunks/chunk-ZFVHM5JI.js";
6
+ } from "../chunks/chunk-5J7GGV62.js";
7
7
  import "../chunks/chunk-GFDNRWR3.js";
8
- import "../chunks/chunk-7ZDS6SZD.js";
9
8
  import "../chunks/chunk-J7DDZ4C2.js";
10
9
  import "../chunks/chunk-BLCJHP5H.js";
10
+ import "../chunks/chunk-WH6V3YNN.js";
11
11
  export {
12
12
  ALL_PROVIDERS,
13
13
  configuredProviders,
@@ -1,13 +1,3 @@
1
- import {
2
- emptyCounts,
3
- sumCounts
4
- } from "../chunks/chunk-PQSTQKRD.js";
5
- import {
6
- profileSlug
7
- } from "../chunks/chunk-NAWZ73QS.js";
8
- import {
9
- stableId
10
- } from "../chunks/chunk-FHKSLCVW.js";
11
1
  import {
12
2
  recordBase,
13
3
  refTo,
@@ -16,6 +6,10 @@ import {
16
6
  import {
17
7
  leadProgressSchema
18
8
  } from "../chunks/chunk-BOWXGMN3.js";
9
+ import {
10
+ emptyCounts,
11
+ sumCounts
12
+ } from "../chunks/chunk-PQSTQKRD.js";
19
13
  import {
20
14
  SCHEMA_VERSION
21
15
  } from "../chunks/chunk-QGRZDTX4.js";
@@ -23,6 +17,12 @@ import {
23
17
  assertWorkspaceId,
24
18
  makeRef
25
19
  } from "../chunks/chunk-QAKJ76HB.js";
20
+ import {
21
+ profileSlug
22
+ } from "../chunks/chunk-NAWZ73QS.js";
23
+ import {
24
+ stableId
25
+ } from "../chunks/chunk-FHKSLCVW.js";
26
26
  import {
27
27
  OutboundError,
28
28
  makeErrorMapper
@@ -64,6 +64,26 @@ declare const CATALOG: readonly [{
64
64
  readonly maturity: "beta";
65
65
  readonly name: "HeyReach";
66
66
  readonly note: "Its reads were run, read-only, against one live workspace. Fixtures are built from the documentation.";
67
+ }, {
68
+ readonly channels: readonly ["email"];
69
+ readonly docsUrl: "https://dedi.emailbison.com/api/reference";
70
+ readonly envVars: readonly [{
71
+ readonly description: "API key (an api-user key is scoped to one workspace).";
72
+ readonly name: "EMAILBISON_API_KEY";
73
+ readonly required: true;
74
+ }, {
75
+ readonly description: "The URL you log in to EmailBison with. Defaults to https://dedi.emailbison.com.";
76
+ readonly name: "EMAILBISON_BASE_URL";
77
+ readonly required: false;
78
+ }, {
79
+ readonly description: "A label for this client or workspace.";
80
+ readonly name: "EMAILBISON_WORKSPACE_ID";
81
+ readonly required: false;
82
+ }];
83
+ readonly id: "emailbison";
84
+ readonly maturity: "unverified";
85
+ readonly name: "EmailBison";
86
+ readonly note: "Never run against a live account. Written from the public documentation and tested offline only.";
67
87
  }, {
68
88
  readonly channels: readonly ["email", "linkedin"];
69
89
  readonly docsUrl: null;
@@ -73,7 +93,7 @@ declare const CATALOG: readonly [{
73
93
  readonly name: "In-memory (tests and demos)";
74
94
  readonly note: "Holds data in memory. For tests and demos; there is no vendor behind it.";
75
95
  }];
76
- /** The id of a provider in the catalog: `instantly`, `smartlead`, `heyreach` or `memory`. */
96
+ /** The id of a provider in the catalog: `instantly`, `smartlead`, `heyreach`, `emailbison` or `memory`. */
77
97
  export type ProviderId = (typeof CATALOG)[number]["id"];
78
98
  export declare const providers: readonly ProviderInfo[];
79
99
  /**
@@ -3,7 +3,7 @@ import {
3
3
  findProvider,
4
4
  isProviderId,
5
5
  providers
6
- } from "../chunks/chunk-7ZDS6SZD.js";
6
+ } from "../chunks/chunk-WH6V3YNN.js";
7
7
  export {
8
8
  PROVIDER_ENV,
9
9
  findProvider,