outbound-sdk 0.7.1 → 0.9.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 (120) hide show
  1. package/dist/alerts/index.js +3 -3
  2. package/dist/audit/index.js +1 -1
  3. package/dist/benchmarks/index.js +3 -3
  4. package/dist/budget/index.d.ts +7 -0
  5. package/dist/budget/index.js +3 -3
  6. package/dist/cache/index.js +2 -2
  7. package/dist/cards/index.js +17 -5
  8. package/dist/chunks/{chunk-6NSCPTOY.js → chunk-4BH5LRCS.js} +691 -441
  9. package/dist/chunks/{chunk-MW4C6LTN.js → chunk-5XLR6XVV.js} +2 -2
  10. package/dist/chunks/{chunk-HIAK2GCI.js → chunk-A7DLJUA6.js} +6 -1
  11. package/dist/chunks/{chunk-M2VXGLLZ.js → chunk-CPACP4YD.js} +1 -1
  12. package/dist/chunks/{chunk-4AVYRVN5.js → chunk-FTK4JS65.js} +31 -10
  13. package/dist/chunks/{chunk-YW6FFVSZ.js → chunk-HXB2IOJJ.js} +1 -1
  14. package/dist/chunks/{chunk-FHKSLCVW.js → chunk-KVAG5GM2.js} +19 -0
  15. package/dist/chunks/{chunk-65YAGEWZ.js → chunk-MEEJIIIA.js} +178 -39
  16. package/dist/chunks/{chunk-7I3EPR23.js → chunk-MPE6VLLY.js} +3 -3
  17. package/dist/chunks/{chunk-UFQ4WMLU.js → chunk-NFWWA7MI.js} +1 -1
  18. package/dist/chunks/{chunk-GL7BABF2.js → chunk-OMCDMELK.js} +1 -1
  19. package/dist/chunks/{chunk-JRL3QRBS.js → chunk-OVTYA3IB.js} +88 -28
  20. package/dist/chunks/{chunk-T5MJMW3R.js → chunk-QTWJ5FO7.js} +1 -1
  21. package/dist/chunks/chunk-REDFBY74.js +7285 -0
  22. package/dist/chunks/{chunk-OK3GAZMT.js → chunk-SYUMA3CP.js} +12 -0
  23. package/dist/chunks/{chunk-LVZGIKNF.js → chunk-U5AK6OJM.js} +1 -1
  24. package/dist/chunks/{chunk-KTYTE2BU.js → chunk-UAHYPASH.js} +20 -11
  25. package/dist/chunks/{chunk-BNDHEDHD.js → chunk-UOJG4VYF.js} +3 -3
  26. package/dist/chunks/{chunk-LD6F46UT.js → chunk-UWD65SK7.js} +2 -2
  27. package/dist/chunks/{chunk-I7DXXGNZ.js → chunk-UZLFZZ2U.js} +5 -5
  28. package/dist/chunks/{chunk-DNPNTD5W.js → chunk-VVDBCQLK.js} +1 -1
  29. package/dist/chunks/{chunk-IVH3NMQZ.js → chunk-WROJO6XB.js} +1 -1
  30. package/dist/chunks/{chunk-QFC4ZHD3.js → chunk-XYHM4KHC.js} +1 -1
  31. package/dist/chunks/{chunk-NAWZ73QS.js → chunk-YFJ3OQZS.js} +8 -1
  32. package/dist/chunks/tools-ATY622UC.js +23 -0
  33. package/dist/cli/args.d.ts +48 -0
  34. package/dist/cli/bin.js +14 -14
  35. package/dist/cli/commands.d.ts +0 -7
  36. package/dist/cli/config.d.ts +31 -2
  37. package/dist/cli/envelope.d.ts +2 -0
  38. package/dist/cli/index.d.ts +4 -0
  39. package/dist/cli/index.js +19 -15
  40. package/dist/cli/listing.d.ts +5 -2
  41. package/dist/cli/mcp.d.ts +9 -0
  42. package/dist/cli/offered.d.ts +10 -0
  43. package/dist/cli/options.d.ts +6 -0
  44. package/dist/cli/progress.d.ts +27 -0
  45. package/dist/cli/serve.d.ts +17 -0
  46. package/dist/clients/index.js +3 -3
  47. package/dist/combine/index.js +154 -35
  48. package/dist/combine/newest.d.ts +18 -0
  49. package/dist/combine/route.d.ts +19 -5
  50. package/dist/emailbison/index.js +22 -14
  51. package/dist/emailbison/map-sequence.d.ts +2 -1
  52. package/dist/exporter/index.js +1 -1
  53. package/dist/failover/index.js +3 -3
  54. package/dist/fixtures/index.js +4 -4
  55. package/dist/heyreach/capabilities.d.ts +4 -0
  56. package/dist/heyreach/conversations.d.ts +23 -0
  57. package/dist/heyreach/inbox.d.ts +0 -1
  58. package/dist/heyreach/index.js +251 -92
  59. package/dist/identity/index.js +2 -2
  60. package/dist/index.js +7 -7
  61. package/dist/insights/capped.d.ts +6 -6
  62. package/dist/insights/copy/index.d.ts +2 -0
  63. package/dist/insights/copy/reply-timing.d.ts +4 -0
  64. package/dist/insights/cost.d.ts +11 -1
  65. package/dist/insights/define.d.ts +25 -16
  66. package/dist/insights/inbox.d.ts +12 -0
  67. package/dist/insights/index.js +42 -6578
  68. package/dist/insights/inputs.generated.d.ts +62 -26
  69. package/dist/insights/ops/anomalies.d.ts +9 -0
  70. package/dist/insights/ops/index.d.ts +2 -0
  71. package/dist/insights/ops/period-comparison.d.ts +7 -8
  72. package/dist/insights/ops/pipeline-forecast.d.ts +16 -0
  73. package/dist/insights/ops/shared.d.ts +6 -1
  74. package/dist/insights/people/auto-replies.d.ts +11 -7
  75. package/dist/insights/people/dropped-replies.d.ts +13 -4
  76. package/dist/insights/people/hot-leads-read.d.ts +31 -0
  77. package/dist/insights/people/hot-leads.d.ts +15 -3
  78. package/dist/insights/people/index.d.ts +10 -2
  79. package/dist/insights/people/read.d.ts +1 -1
  80. package/dist/insights/registry.d.ts +14 -2
  81. package/dist/insights/run-cap.d.ts +10 -0
  82. package/dist/insights/senders/read.d.ts +0 -3
  83. package/dist/insights/tools.d.ts +12 -0
  84. package/dist/insights/tracked-reads.d.ts +53 -0
  85. package/dist/instantly/capabilities.d.ts +13 -1
  86. package/dist/instantly/index.js +128 -46
  87. package/dist/instantly/map-account.d.ts +2 -1
  88. package/dist/instantly/map-lead.d.ts +1 -0
  89. package/dist/instantly/map.d.ts +4 -3
  90. package/dist/internal/adapter.d.ts +19 -0
  91. package/dist/internal/capabilities.d.ts +15 -0
  92. package/dist/internal/engine/budget.d.ts +9 -1
  93. package/dist/internal/engine/engine.d.ts +2 -1
  94. package/dist/internal/engine/request.d.ts +2 -0
  95. package/dist/internal/errors.d.ts +5 -0
  96. package/dist/internal/hooks.d.ts +11 -0
  97. package/dist/internal/notes.d.ts +16 -0
  98. package/dist/internal/outbound/api.d.ts +16 -0
  99. package/dist/internal/outbound/core.d.ts +4 -1
  100. package/dist/internal/outbound/operation-shared.d.ts +2 -0
  101. package/dist/internal/sha256.d.ts +2 -0
  102. package/dist/internal/url.d.ts +1 -0
  103. package/dist/loader/index.js +3 -3
  104. package/dist/memory/index.js +11 -16
  105. package/dist/redact/index.d.ts +1 -1
  106. package/dist/redact/index.js +107 -19
  107. package/dist/redact/plugin.d.ts +26 -3
  108. package/dist/smartlead/index.js +22 -13
  109. package/dist/smartlead/map.d.ts +3 -2
  110. package/dist/sync/index.js +2 -2
  111. package/dist/tools/ai-sdk.js +5 -5
  112. package/dist/tools/by-name.d.ts +9 -1
  113. package/dist/tools/campaign-tools.d.ts +3 -1
  114. package/dist/tools/claude-agent.js +5 -5
  115. package/dist/tools/index.js +6 -6
  116. package/dist/tools/registry.d.ts +6 -0
  117. package/dist/tools/shared.d.ts +5 -1
  118. package/dist/tracing/index.js +1 -1
  119. package/dist/webhooks/index.js +11 -11
  120. package/package.json +1 -1
@@ -4,6 +4,17 @@ import {
4
4
  stripQuotedHistory
5
5
  } from "./chunk-FALWG5U3.js";
6
6
 
7
+ // src/internal/notes.ts
8
+ var notNegative = (value, { note, unit, vendor, what }) => {
9
+ if (value === null || value >= 0) {
10
+ return value;
11
+ }
12
+ note(
13
+ `${what} is negative in ${vendor} (${value}${unit === void 0 ? "" : ` ${unit}`}); left out.`
14
+ );
15
+ return null;
16
+ };
17
+
7
18
  // src/internal/auto-reply.ts
8
19
  var AUTO_REPLY_WITHIN_MS = 6e4;
9
20
  var MACHINE_SENDER = /^[^@]*(?:no-?reply|do-?not-?reply|auto-?respon|auto-?reply|mailer-daemon|postmaster)[^@]*@/iu;
@@ -46,6 +57,7 @@ var answeredAtOnce = (sentAt, repliedAt) => {
46
57
  };
47
58
 
48
59
  export {
60
+ notNegative,
49
61
  detectAutoReply,
50
62
  answeredAtOnce
51
63
  };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-QGRZDTX4.js";
4
4
  import {
5
5
  makeRef
6
- } from "./chunk-YW6FFVSZ.js";
6
+ } from "./chunk-HXB2IOJJ.js";
7
7
  import {
8
8
  compactObject
9
9
  } from "./chunk-45TXPJW7.js";
@@ -1,21 +1,24 @@
1
+ import {
2
+ notNegative
3
+ } from "./chunk-SYUMA3CP.js";
1
4
  import {
2
5
  fromOne,
3
6
  leadStanding,
4
7
  toVariant,
5
8
  variantKey
6
- } from "./chunk-BNDHEDHD.js";
9
+ } from "./chunk-UOJG4VYF.js";
7
10
  import {
8
11
  eventData,
9
12
  recordBase,
10
13
  refTo
11
- } from "./chunk-LVZGIKNF.js";
14
+ } from "./chunk-U5AK6OJM.js";
12
15
  import {
13
16
  SCHEMA_VERSION
14
17
  } from "./chunk-QGRZDTX4.js";
15
18
  import {
16
19
  sha256,
17
20
  stableId
18
- } from "./chunk-FHKSLCVW.js";
21
+ } from "./chunk-KVAG5GM2.js";
19
22
  import {
20
23
  count,
21
24
  emailAddress,
@@ -90,35 +93,41 @@ var variantOf = (raw, index) => toVariant(
90
93
  text(raw.variant_label) ?? variantKey(index)
91
94
  );
92
95
  var delayDays = (step) => count(field(step.seq_delay_details, "delay_in_days")) ?? count(field(step.seq_delay_details, "delayInDays"));
93
- var toStep = (step, position) => {
96
+ var toStep = (step, position, note) => {
94
97
  const variants = objects(step.sequence_variants).filter(
95
98
  (variant) => flag(variant.is_deleted) !== true
96
99
  );
100
+ const index = fromOne(step.seq_number) ?? position;
97
101
  return {
98
102
  action: "email",
99
103
  branch: null,
100
- delayDays: delayDays(step),
101
- index: fromOne(step.seq_number) ?? position,
104
+ delayDays: notNegative(delayDays(step), {
105
+ note,
106
+ unit: "days",
107
+ vendor: "Smartlead",
108
+ what: `Step ${index + 1}'s delay`
109
+ }),
110
+ index,
102
111
  parentIndex: null,
103
112
  // With no variants the copy is on the step itself.
104
113
  variants: (variants.length === 0 ? [step] : variants).map(variantOf)
105
114
  };
106
115
  };
107
- var toSteps = (steps) => objects(steps).map(toStep).toSorted((left, right) => left.index - right.index).map((step, position, sorted) => ({
116
+ var toSteps = (steps, note) => objects(steps).map((step, position) => toStep(step, position, note)).toSorted((left, right) => left.index - right.index).map((step, position, sorted) => ({
108
117
  ...step,
109
118
  parentIndex: sorted[position - 1]?.index ?? null
110
119
  }));
111
- var toSequence = (identity, campaignId, body) => {
120
+ var toSequence = (identity, campaignId, body, note) => {
112
121
  const steps = unwrap(body);
113
122
  return {
114
123
  ...recordBase(identity, campaignId, steps ?? null),
115
124
  campaignRef: refTo(identity, campaignId) ?? "",
116
125
  kind: "main",
117
126
  name: null,
118
- steps: toSteps(steps)
127
+ steps: toSteps(steps, note)
119
128
  };
120
129
  };
121
- var toSubsequence = (identity, parentId, campaign, body) => {
130
+ var toSubsequence = (identity, parentId, campaign, body, note) => {
122
131
  const steps = unwrap(body);
123
132
  return {
124
133
  ...recordBase(identity, text(campaign.id) ?? "", {
@@ -128,7 +137,7 @@ var toSubsequence = (identity, parentId, campaign, body) => {
128
137
  campaignRef: refTo(identity, parentId) ?? "",
129
138
  kind: "subsequence",
130
139
  name: text(campaign.name),
131
- steps: toSteps(steps)
140
+ steps: toSteps(steps, note)
132
141
  };
133
142
  };
134
143
  var senderStatus = (raw) => {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  buildUrl
3
- } from "./chunk-NAWZ73QS.js";
3
+ } from "./chunk-YFJ3OQZS.js";
4
4
  import {
5
5
  stableId
6
- } from "./chunk-FHKSLCVW.js";
6
+ } from "./chunk-KVAG5GM2.js";
7
7
  import {
8
8
  OutboundError
9
- } from "./chunk-QFC4ZHD3.js";
9
+ } from "./chunk-XYHM4KHC.js";
10
10
  import {
11
11
  count,
12
12
  isJsonArray,
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  eventData,
3
3
  refTo
4
- } from "./chunk-LVZGIKNF.js";
4
+ } from "./chunk-U5AK6OJM.js";
5
5
  import {
6
6
  SCHEMA_VERSION
7
7
  } from "./chunk-QGRZDTX4.js";
8
8
  import {
9
9
  stableId
10
- } from "./chunk-FHKSLCVW.js";
10
+ } from "./chunk-KVAG5GM2.js";
11
11
  import {
12
12
  compactObject,
13
13
  emailAddress,
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  detectAutoReply
3
- } from "./chunk-OK3GAZMT.js";
3
+ } from "./chunk-SYUMA3CP.js";
4
4
  import {
5
5
  createVendorClient,
6
6
  leadStanding,
7
7
  listIn
8
- } from "./chunk-BNDHEDHD.js";
8
+ } from "./chunk-UOJG4VYF.js";
9
9
  import {
10
10
  normalizeBody
11
11
  } from "./chunk-FALWG5U3.js";
@@ -14,16 +14,16 @@ import {
14
14
  eventTypesOf,
15
15
  recordBase,
16
16
  refTo
17
- } from "./chunk-LVZGIKNF.js";
17
+ } from "./chunk-U5AK6OJM.js";
18
18
  import {
19
19
  SCHEMA_VERSION
20
20
  } from "./chunk-QGRZDTX4.js";
21
21
  import {
22
22
  stableId
23
- } from "./chunk-FHKSLCVW.js";
23
+ } from "./chunk-KVAG5GM2.js";
24
24
  import {
25
25
  requireObject
26
- } from "./chunk-QFC4ZHD3.js";
26
+ } from "./chunk-XYHM4KHC.js";
27
27
  import {
28
28
  count,
29
29
  emailAddress,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  OutboundError
3
- } from "./chunk-QFC4ZHD3.js";
3
+ } from "./chunk-XYHM4KHC.js";
4
4
 
5
5
  // src/internal/tracking.ts
6
6
  var recorded = (campaign, metric) => (metric === "opens" ? campaign.opened : campaign.clicked) ?? 0;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  stableId
3
- } from "./chunk-FHKSLCVW.js";
3
+ } from "./chunk-KVAG5GM2.js";
4
4
 
5
5
  // src/cache/index.ts
6
6
  var memoryCacheStore = (maxEntries = 500) => {
@@ -112,7 +112,7 @@ var OutboundError = class extends Error {
112
112
  this.timedOut = options.timedOut ?? false;
113
113
  this.limit = code === "RateLimited" ? options.limit ?? (options.status === void 0 ? void 0 : "vendor") : void 0;
114
114
  this.partial = options.partial;
115
- this.permanent = this.aborted || !RETRYABLE.has(code) || this.limit === "call" || this.limit === "run";
115
+ this.permanent = options.permanent === true || this.aborted || !RETRYABLE.has(code) || this.limit === "call" || this.limit === "run";
116
116
  }
117
117
  /** Type guard that also recognises errors from another copy of the package. */
118
118
  static is(cause) {
@@ -13,7 +13,14 @@ var buildUrl = (baseUrl, path, query = {}) => {
13
13
  var LINKEDIN_PROFILE = /linkedin\.com\/(?:in|pub)\/(?<slug>[^/?#\s]+)/iu;
14
14
  var profileSlug = (url) => {
15
15
  const slug = url === null || url === void 0 ? void 0 : LINKEDIN_PROFILE.exec(url)?.groups?.slug;
16
- return slug === void 0 ? null : decodeURIComponent(slug).toLowerCase();
16
+ if (slug === void 0) {
17
+ return null;
18
+ }
19
+ try {
20
+ return decodeURIComponent(slug).toLowerCase();
21
+ } catch {
22
+ return slug.toLowerCase();
23
+ }
17
24
  };
18
25
 
19
26
  export {
@@ -0,0 +1,23 @@
1
+ import {
2
+ INSIGHT_TOOL_CEILING,
3
+ insightLeftOutReason,
4
+ insightTools
5
+ } from "./chunk-REDFBY74.js";
6
+ import "./chunk-FTK4JS65.js";
7
+ import "./chunk-4PA526S7.js";
8
+ import "./chunk-HZCTYL22.js";
9
+ import "./chunk-HPNGSG5E.js";
10
+ import "./chunk-PTZO4QXR.js";
11
+ import "./chunk-FALWG5U3.js";
12
+ import "./chunk-POBAY3TI.js";
13
+ import "./chunk-CPACP4YD.js";
14
+ import "./chunk-QGRZDTX4.js";
15
+ import "./chunk-HXB2IOJJ.js";
16
+ import "./chunk-YFJ3OQZS.js";
17
+ import "./chunk-XYHM4KHC.js";
18
+ import "./chunk-45TXPJW7.js";
19
+ export {
20
+ INSIGHT_TOOL_CEILING,
21
+ insightLeftOutReason,
22
+ insightTools
23
+ };
@@ -0,0 +1,48 @@
1
+ declare const parseStrict: (argv: readonly string[]) => {
2
+ values: {
3
+ bodies?: boolean;
4
+ by?: string;
5
+ cache?: string;
6
+ campaign?: string;
7
+ card?: boolean;
8
+ category?: string;
9
+ compact?: boolean;
10
+ config?: string;
11
+ from?: string;
12
+ help?: boolean;
13
+ "include-inbox"?: boolean;
14
+ input?: string;
15
+ limit?: string;
16
+ list?: string;
17
+ "max-requests"?: string;
18
+ "no-redact"?: boolean;
19
+ provider?: string;
20
+ raw?: boolean;
21
+ redact?: boolean;
22
+ search?: string;
23
+ sequence?: boolean;
24
+ settings?: boolean;
25
+ since?: string;
26
+ slack?: boolean;
27
+ stats?: boolean;
28
+ status?: string;
29
+ subsequences?: boolean;
30
+ to?: string;
31
+ tools?: string;
32
+ version?: boolean;
33
+ };
34
+ positionals: string[];
35
+ };
36
+ export interface Parsed {
37
+ readonly name: string | undefined;
38
+ readonly rest: readonly string[];
39
+ readonly values: ReturnType<typeof parseStrict>["values"];
40
+ /** The help to print instead of running anything. */
41
+ readonly help: string | undefined;
42
+ }
43
+ /**
44
+ * The arguments, checked against the command they name: a flag it does not
45
+ * take is refused with the command's name, never ignored.
46
+ */
47
+ export declare const parse: (given: readonly string[]) => Parsed;
48
+ export {};
package/dist/cli/bin.js CHANGED
@@ -1,24 +1,24 @@
1
1
  #!/usr/bin/env node
2
- import "../chunks/chunk-T5MJMW3R.js";
3
- import "../chunks/chunk-6NSCPTOY.js";
4
- import "../chunks/chunk-GL7BABF2.js";
5
- import "../chunks/chunk-JRL3QRBS.js";
6
- import "../chunks/chunk-4AVYRVN5.js";
2
+ import "../chunks/chunk-QTWJ5FO7.js";
3
+ import "../chunks/chunk-4BH5LRCS.js";
4
+ import "../chunks/chunk-OMCDMELK.js";
5
+ import "../chunks/chunk-OVTYA3IB.js";
6
+ import "../chunks/chunk-FTK4JS65.js";
7
7
  import "../chunks/chunk-4PA526S7.js";
8
8
  import "../chunks/chunk-HZCTYL22.js";
9
- import "../chunks/chunk-65YAGEWZ.js";
9
+ import "../chunks/chunk-MEEJIIIA.js";
10
10
  import "../chunks/chunk-4O2HRTTI.js";
11
11
  import "../chunks/chunk-HPNGSG5E.js";
12
- import "../chunks/chunk-HIAK2GCI.js";
12
+ import "../chunks/chunk-A7DLJUA6.js";
13
13
  import "../chunks/chunk-PTZO4QXR.js";
14
14
  import "../chunks/chunk-POBAY3TI.js";
15
- import "../chunks/chunk-M2VXGLLZ.js";
15
+ import "../chunks/chunk-CPACP4YD.js";
16
16
  import "../chunks/chunk-QGRZDTX4.js";
17
- import "../chunks/chunk-YW6FFVSZ.js";
18
- import "../chunks/chunk-NAWZ73QS.js";
19
- import "../chunks/chunk-FHKSLCVW.js";
20
- import "../chunks/chunk-MW4C6LTN.js";
21
- import "../chunks/chunk-UFQ4WMLU.js";
22
- import "../chunks/chunk-QFC4ZHD3.js";
17
+ import "../chunks/chunk-HXB2IOJJ.js";
18
+ import "../chunks/chunk-YFJ3OQZS.js";
19
+ import "../chunks/chunk-KVAG5GM2.js";
20
+ import "../chunks/chunk-5XLR6XVV.js";
21
+ import "../chunks/chunk-NFWWA7MI.js";
22
+ import "../chunks/chunk-XYHM4KHC.js";
23
23
  import "../chunks/chunk-45TXPJW7.js";
24
24
  import "../chunks/chunk-WH6V3YNN.js";
@@ -1,6 +1,5 @@
1
1
  import type { Json } from "../internal/json.ts";
2
2
  import type { OutboundApi } from "../internal/outbound/api.ts";
3
- import type { OutboundTool } from "../tools/index.ts";
4
3
  import type { Printed } from "./envelope.ts";
5
4
  export interface CommandInput {
6
5
  readonly positionals: readonly string[];
@@ -9,8 +8,6 @@ export interface CommandInput {
9
8
  readonly note: (text: string) => void;
10
9
  }
11
10
  type Command = (outbound: OutboundApi, input: CommandInput) => Promise<Printed>;
12
- /** The tools `outbound mcp` offers: the built-in ones, then the insights. */
13
- export declare const offeredTools: (outbound: OutboundApi) => Promise<OutboundTool[]>;
14
11
  export interface CommandSpec {
15
12
  readonly help: string;
16
13
  /** The options this command takes, besides the ones every command takes. */
@@ -24,8 +21,4 @@ export declare const checkFlags: (name: string, flags: readonly string[], given:
24
21
  export declare const COMMANDS: Map<string, CommandSpec>;
25
22
  /** The provider catalog. Needs no adapter and no key. */
26
23
  export declare const listProviders: () => Json;
27
- /** Every command with its options, then the options every command takes. */
28
- export declare const helpText: () => string;
29
- /** One command's options, then the options every command takes. */
30
- export declare const commandHelp: (command: CommandSpec) => string;
31
24
  export {};
@@ -1,8 +1,16 @@
1
+ import type { RateLimitStore } from "../internal/engine/rate-store.ts";
1
2
  import type { OutboundPlugin } from "../internal/outbound/plugins.ts";
2
3
  /** What a file passed to `--config` exports as its default. */
3
4
  export interface CliConfig {
4
5
  /** Plugins for the instance, outermost first, as in `createOutbound`. */
5
6
  readonly plugins?: readonly OutboundPlugin[] | undefined;
7
+ /**
8
+ * Where the rate budget is counted, as in `createOutbound`. A vendor's
9
+ * limit covers the whole workspace, so two terminals, or the CLI and an
10
+ * MCP server, on one key slow each other down unless they share a store
11
+ * such as `redisRateLimitStore()`. Defaults to this process alone.
12
+ */
13
+ readonly rateLimitStore?: RateLimitStore | undefined;
6
14
  }
7
15
  /** Returns the config unchanged. It exists so an editor can check its shape. */
8
16
  export declare const defineConfig: (config: CliConfig) => CliConfig;
@@ -13,11 +21,32 @@ export interface PluginFlags {
13
21
  readonly "max-requests"?: string | undefined;
14
22
  readonly cache?: string | undefined;
15
23
  }
24
+ /** What a cap message tells a CLI user to raise. */
25
+ export declare const capSetting: (mcp: boolean) => string;
26
+ /**
27
+ * The cap an insight runs under from the CLI: `--max-requests` when set,
28
+ * which replaces the insight's default cap as `budget()` caps the whole
29
+ * command, and messages that name the flag.
30
+ */
31
+ export interface InsightCaps {
32
+ readonly maxRequests: number | undefined;
33
+ readonly capSetting: string;
34
+ }
35
+ export declare const insightCaps: (flags: PluginFlags, mcp: boolean) => InsightCaps;
36
+ /** The same caps, as `insightTools` takes them. */
37
+ export interface InsightToolCaps {
38
+ readonly capSetting: string;
39
+ readonly maxRequestsPerToolCall: number | undefined;
40
+ }
41
+ export declare const insightToolCaps: (flags: PluginFlags, mcp: boolean) => InsightToolCaps;
16
42
  /**
17
43
  * The plugins for one command, outermost first: redact, then the config
18
44
  * file's plugins, then cache, then budget, then identity, next to the
19
- * request engine.
45
+ * request engine, and the config file's rate limit store.
20
46
  * `mcp` turns redact on unless `--no-redact` is set. `note` gets a line for
21
47
  * stderr when a flag will not do what its name suggests.
22
48
  */
23
- export declare const pluginsFor: (flags: PluginFlags, mcp: boolean, note: (text: string) => void) => Promise<OutboundPlugin[]>;
49
+ export declare const setupFor: (flags: PluginFlags, mcp: boolean, note: (text: string) => void) => Promise<{
50
+ plugins: OutboundPlugin[];
51
+ rateLimitStore: RateLimitStore | undefined;
52
+ }>;
@@ -34,6 +34,8 @@ export interface RunFacts {
34
34
  readonly provider: string | null;
35
35
  /** Vendor requests the command sent. */
36
36
  readonly requests: number;
37
+ /** Milliseconds the command spent waiting on rate limits, overlaps counted once. */
38
+ readonly throttledMs: number;
37
39
  }
38
40
  /** Counts every vendor request the command sends, for `meta.requests`. */
39
41
  export declare const requestCounter: () => OutboundPlugin & {
@@ -5,6 +5,8 @@ export type { CliConfig } from "./config.ts";
5
5
  export { createMcpServer, PROTOCOL_VERSIONS } from "./mcp.ts";
6
6
  export type { McpServer, McpServerOptions } from "./mcp.ts";
7
7
  export { serveStdio } from "./stdio.ts";
8
+ export { describeWait, throttleMonitor } from "./progress.ts";
9
+ export type { ThrottleMonitor, ThrottleTotal } from "./progress.ts";
8
10
  export type { NpmRunner } from "./update.ts";
9
11
  export type { StdioOptions } from "./stdio.ts";
10
12
  export interface CliIo {
@@ -16,6 +18,8 @@ export interface CliIo {
16
18
  readonly adapter?: Adapter | undefined;
17
19
  /** Replaces the `fetch` vendor requests are sent with. Meant for tests. */
18
20
  readonly fetch?: OutboundOptions["fetch"];
21
+ /** Replaces the clock and timers rate limit waits use. Meant for tests. */
22
+ readonly runtime?: OutboundOptions["runtime"];
19
23
  /** Runs npm for `outbound update` and resolves to its output. Meant for tests. */
20
24
  readonly npm?: ((args: readonly string[]) => Promise<string>) | undefined;
21
25
  /** Waits between `outbound update` install retries. Meant for tests. */
package/dist/cli/index.js CHANGED
@@ -2,34 +2,38 @@ import {
2
2
  PROTOCOL_VERSIONS,
3
3
  createMcpServer,
4
4
  defineConfig,
5
+ describeWait,
5
6
  run,
6
- serveStdio
7
- } from "../chunks/chunk-6NSCPTOY.js";
8
- import "../chunks/chunk-GL7BABF2.js";
9
- import "../chunks/chunk-JRL3QRBS.js";
10
- import "../chunks/chunk-4AVYRVN5.js";
7
+ serveStdio,
8
+ throttleMonitor
9
+ } from "../chunks/chunk-4BH5LRCS.js";
10
+ import "../chunks/chunk-OMCDMELK.js";
11
+ import "../chunks/chunk-OVTYA3IB.js";
12
+ import "../chunks/chunk-FTK4JS65.js";
11
13
  import "../chunks/chunk-4PA526S7.js";
12
14
  import "../chunks/chunk-HZCTYL22.js";
13
- import "../chunks/chunk-65YAGEWZ.js";
15
+ import "../chunks/chunk-MEEJIIIA.js";
14
16
  import "../chunks/chunk-4O2HRTTI.js";
15
17
  import "../chunks/chunk-HPNGSG5E.js";
16
- import "../chunks/chunk-HIAK2GCI.js";
18
+ import "../chunks/chunk-A7DLJUA6.js";
17
19
  import "../chunks/chunk-PTZO4QXR.js";
18
20
  import "../chunks/chunk-POBAY3TI.js";
19
- import "../chunks/chunk-M2VXGLLZ.js";
21
+ import "../chunks/chunk-CPACP4YD.js";
20
22
  import "../chunks/chunk-QGRZDTX4.js";
21
- import "../chunks/chunk-YW6FFVSZ.js";
22
- import "../chunks/chunk-NAWZ73QS.js";
23
- import "../chunks/chunk-FHKSLCVW.js";
24
- import "../chunks/chunk-MW4C6LTN.js";
25
- import "../chunks/chunk-UFQ4WMLU.js";
26
- import "../chunks/chunk-QFC4ZHD3.js";
23
+ import "../chunks/chunk-HXB2IOJJ.js";
24
+ import "../chunks/chunk-YFJ3OQZS.js";
25
+ import "../chunks/chunk-KVAG5GM2.js";
26
+ import "../chunks/chunk-5XLR6XVV.js";
27
+ import "../chunks/chunk-NFWWA7MI.js";
28
+ import "../chunks/chunk-XYHM4KHC.js";
27
29
  import "../chunks/chunk-45TXPJW7.js";
28
30
  import "../chunks/chunk-WH6V3YNN.js";
29
31
  export {
30
32
  PROTOCOL_VERSIONS,
31
33
  createMcpServer,
32
34
  defineConfig,
35
+ describeWait,
33
36
  run,
34
- serveStdio
37
+ serveStdio,
38
+ throttleMonitor
35
39
  };
@@ -4,10 +4,13 @@ import { Answer } from "./envelope.ts";
4
4
  export declare const listing: <Item>(walk: ListAll<Item>, input: {
5
5
  readonly note: (text: string) => void;
6
6
  }, one: string, many?: string) => Promise<Answer>;
7
+ /** The most records a listing reads for a time window when no --limit is given. */
8
+ export declare const WINDOW_LIMIT = 2000;
7
9
  /**
8
10
  * Replies, one record per message or, `byPerson`, one row per person. A note
9
- * says how many people sent them, since each record is a message.
11
+ * says how many people sent them, since each record is a message. A
12
+ * `windowed` walk read up to WINDOW_LIMIT, and its stop note says so.
10
13
  */
11
14
  export declare const listedReplies: (walk: ListAll<Reply>, input: {
12
15
  readonly note: (text: string) => void;
13
- }, byPerson: boolean) => Promise<Answer>;
16
+ }, byPerson: boolean, windowed?: boolean) => Promise<Answer>;
package/dist/cli/mcp.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Json, JsonObject } from "../internal/json.ts";
2
2
  import type { OutboundApi } from "../internal/outbound/api.ts";
3
3
  import type { ToolsOptions } from "../tools/index.ts";
4
+ import type { ThrottleTotal } from "./progress.ts";
4
5
  export declare const PROTOCOL_VERSIONS: readonly ["2025-06-18", "2025-03-26", "2024-11-05"];
5
6
  export interface McpServerOptions extends ToolsOptions {
6
7
  readonly version?: string | undefined;
@@ -9,6 +10,12 @@ export interface McpServerOptions extends ToolsOptions {
9
10
  * is answered with the reason instead of `Unknown tool`.
10
11
  */
11
12
  readonly leftOut?: Readonly<Record<string, string>> | undefined;
13
+ /**
14
+ * How long the server has waited on rate limits so far, and why it last
15
+ * did. A tool call that waits more than 5 s says so in `meta.notes`, so a
16
+ * model can tell a slow vendor limit from a hang.
17
+ */
18
+ readonly throttled?: (() => ThrottleTotal) | undefined;
12
19
  }
13
20
  export interface McpServer {
14
21
  /** Handles one JSON-RPC message. Returns `undefined` for a notification. */
@@ -16,4 +23,6 @@ export interface McpServer {
16
23
  /** Handles one line of input, which must be one JSON-RPC message. */
17
24
  readonly handleLine: (line: string) => Promise<string | undefined>;
18
25
  }
26
+ /** A tool call that waited longer than this on rate limits says so. */
27
+ export declare const NOTE_THROTTLE_AFTER_MS = 5000;
19
28
  export declare const createMcpServer: (outbound: OutboundApi, options?: McpServerOptions) => McpServer;
@@ -0,0 +1,10 @@
1
+ import type { Json } from "../internal/json.ts";
2
+ import type { OutboundApi } from "../internal/outbound/api.ts";
3
+ import type { OutboundTool } from "../tools/index.ts";
4
+ import type { PluginFlags } from "./config.ts";
5
+ /** The tools `outbound mcp` offers: the built-in ones, then the insights. */
6
+ export declare const offeredTools: (outbound: OutboundApi, flags: PluginFlags) => Promise<OutboundTool[]>;
7
+ /** A tool as `outbound tools` lists it: its inputs as JSON Schema, as `outbound insight` lists them. */
8
+ export declare const describeTool: (tool: OutboundTool) => Json;
9
+ /** Whether the tool has an input with no default, so it cannot run on none. */
10
+ export declare const requiresInput: (tool: OutboundTool) => boolean;
@@ -30,6 +30,9 @@ export declare const OPTIONS: {
30
30
  readonly short: "h";
31
31
  readonly type: "boolean";
32
32
  };
33
+ readonly "include-inbox": {
34
+ readonly type: "boolean";
35
+ };
33
36
  readonly input: {
34
37
  readonly type: "string";
35
38
  };
@@ -81,6 +84,9 @@ export declare const OPTIONS: {
81
84
  readonly to: {
82
85
  readonly type: "string";
83
86
  };
87
+ readonly tools: {
88
+ readonly type: "string";
89
+ };
84
90
  readonly version: {
85
91
  readonly short: "v";
86
92
  readonly type: "boolean";
@@ -0,0 +1,27 @@
1
+ import type { OutboundHooks, ThrottleEvent } from "../internal/hooks.ts";
2
+ /** A wait longer than this gets a line on stderr. */
3
+ export declare const SAY_AFTER_MS = 2000;
4
+ /** How long a run has waited on rate limits so far, and why it last did. */
5
+ export interface ThrottleTotal {
6
+ /**
7
+ * Wall-clock milliseconds spent with a wait under way, up to now: a wait
8
+ * counts as it elapses, not when it is booked, and waits that overlap are
9
+ * counted once.
10
+ */
11
+ readonly ms: number;
12
+ /** The last wait, in words, or `undefined` before any wait. */
13
+ readonly reason: string | undefined;
14
+ }
15
+ /** Hooks for `createOutbound`, not a plugin, so the MCP server does not list it among the plugins on. */
16
+ export interface ThrottleMonitor {
17
+ readonly hooks: OutboundHooks;
18
+ readonly total: () => ThrottleTotal;
19
+ }
20
+ /** One wait, in the words stderr and a tool note use. */
21
+ export declare const describeWait: (event: ThrottleEvent) => string;
22
+ /**
23
+ * Counts the time a run spends waiting on rate limits and, through `say`,
24
+ * prints one line when a wait passes `SAY_AFTER_MS`. Requests that wait
25
+ * together, as a call's parallel reads do, print one line between them.
26
+ */
27
+ export declare const throttleMonitor: (now: () => number, say: (text: string) => void) => ThrottleMonitor;
@@ -0,0 +1,17 @@
1
+ import type { OutboundApi } from "../internal/outbound/api.ts";
2
+ import type { InsightToolCaps } from "./config.ts";
3
+ import type { ThrottleTotal } from "./progress.ts";
4
+ /** The tools `--tools` names, or `undefined` without it: every tool. */
5
+ export declare const namedTools: (given: string | undefined) => Set<string> | undefined;
6
+ /** What `serve` reads messages from and writes answers to. */
7
+ export interface ServeIo {
8
+ readonly stdin?: (() => AsyncIterable<string> | Iterable<string>) | undefined;
9
+ readonly stdout: (text: string) => void;
10
+ /** How long the server has waited on rate limits, for the note on a slow tool call. */
11
+ readonly throttled?: (() => ThrottleTotal) | undefined;
12
+ }
13
+ /**
14
+ * Serves MCP on stdio. `unmasked` is the same instance without redact, to
15
+ * tell which tools redact left out; `wanted` is what `--tools` names.
16
+ */
17
+ export declare const serve: (outbound: OutboundApi, io: ServeIo, unmasked: OutboundApi | undefined, wanted: ReadonlySet<string> | undefined, caps: InsightToolCaps) => Promise<void>;
@@ -4,12 +4,12 @@ import {
4
4
  import {
5
5
  emptyCounts,
6
6
  sumMeasured
7
- } from "../chunks/chunk-M2VXGLLZ.js";
7
+ } from "../chunks/chunk-CPACP4YD.js";
8
8
  import "../chunks/chunk-QGRZDTX4.js";
9
9
  import {
10
10
  parseRef
11
- } from "../chunks/chunk-YW6FFVSZ.js";
12
- import "../chunks/chunk-QFC4ZHD3.js";
11
+ } from "../chunks/chunk-HXB2IOJJ.js";
12
+ import "../chunks/chunk-XYHM4KHC.js";
13
13
  import "../chunks/chunk-45TXPJW7.js";
14
14
 
15
15
  // src/clients/plugin.ts