outbound-sdk 0.0.0-stage → 0.2.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 (284) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +119 -2
  3. package/dist/alerts/index.d.ts +2 -0
  4. package/dist/alerts/index.js +140 -0
  5. package/dist/alerts/plugin.d.ts +58 -0
  6. package/dist/audit/index.d.ts +33 -0
  7. package/dist/audit/index.js +60 -0
  8. package/dist/benchmarks/index.d.ts +29 -0
  9. package/dist/benchmarks/index.js +72 -0
  10. package/dist/budget/index.d.ts +21 -0
  11. package/dist/budget/index.js +71 -0
  12. package/dist/cache/index.d.ts +31 -0
  13. package/dist/cache/index.js +11 -0
  14. package/dist/cards/content.d.ts +43 -0
  15. package/dist/cards/copy-cards.d.ts +2 -0
  16. package/dist/cards/format.d.ts +39 -0
  17. package/dist/cards/index.d.ts +9 -0
  18. package/dist/cards/index.js +2070 -0
  19. package/dist/cards/notify-cards.d.ts +14 -0
  20. package/dist/cards/ops-cards.d.ts +2 -0
  21. package/dist/cards/parts.d.ts +22 -0
  22. package/dist/cards/people-cards.d.ts +2 -0
  23. package/dist/cards/render.d.ts +28 -0
  24. package/dist/cards/sender-cards.d.ts +2 -0
  25. package/dist/cards/slack-rich.d.ts +19 -0
  26. package/dist/cards/slack-text.d.ts +10 -0
  27. package/dist/cards/slack.d.ts +21 -0
  28. package/dist/cards/spec.d.ts +86 -0
  29. package/dist/cards/tool-cards.d.ts +4 -0
  30. package/dist/chunks/chunk-4O2HRTTI.js +75 -0
  31. package/dist/chunks/chunk-4PSO6JEK.js +357 -0
  32. package/dist/chunks/chunk-6CVZOUHB.js +152 -0
  33. package/dist/chunks/chunk-AFU5E5QB.js +714 -0
  34. package/dist/chunks/chunk-DJ2IUQEU.js +111 -0
  35. package/dist/chunks/chunk-E7JHLNLG.js +187 -0
  36. package/dist/chunks/chunk-FHKSLCVW.js +154 -0
  37. package/dist/chunks/chunk-FKH5N47I.js +40 -0
  38. package/dist/chunks/chunk-HZCTYL22.js +29 -0
  39. package/dist/chunks/chunk-IPUYZD4O.js +25 -0
  40. package/dist/chunks/chunk-IVH3NMQZ.js +61 -0
  41. package/dist/chunks/chunk-LVYG7XZJ.js +45 -0
  42. package/dist/chunks/chunk-NAKXLBA6.js +30 -0
  43. package/dist/chunks/chunk-NAWZ73QS.js +22 -0
  44. package/dist/chunks/chunk-PMSSUWD7.js +636 -0
  45. package/dist/chunks/chunk-PURHK3JU.js +432 -0
  46. package/dist/chunks/chunk-R3Y56YVF.js +43 -0
  47. package/dist/chunks/chunk-RCZ7ZZFU.js +92 -0
  48. package/dist/chunks/chunk-SBIZDCRY.js +106 -0
  49. package/dist/chunks/chunk-U2D34ARZ.js +41 -0
  50. package/dist/chunks/chunk-UAT3JSJZ.js +331 -0
  51. package/dist/chunks/chunk-VQSCHOBV.js +111 -0
  52. package/dist/chunks/chunk-XC6CZP73.js +80 -0
  53. package/dist/chunks/chunk-XNFESPZH.js +2307 -0
  54. package/dist/chunks/chunk-YOTW5ESM.js +118 -0
  55. package/dist/cli/bin.d.ts +2 -0
  56. package/dist/cli/bin.js +35 -0
  57. package/dist/cli/commands.d.ts +19 -0
  58. package/dist/cli/config.d.ts +22 -0
  59. package/dist/cli/index.d.ts +17 -0
  60. package/dist/cli/index.js +30 -0
  61. package/dist/cli/mcp.d.ts +14 -0
  62. package/dist/cli/stdio.d.ts +9 -0
  63. package/dist/clients/index.d.ts +2 -0
  64. package/dist/clients/index.js +117 -0
  65. package/dist/clients/plugin.d.ts +42 -0
  66. package/dist/combine/account.d.ts +4 -0
  67. package/dist/combine/adapter.d.ts +9 -0
  68. package/dist/combine/index.d.ts +2 -0
  69. package/dist/combine/index.js +420 -0
  70. package/dist/combine/route.d.ts +24 -0
  71. package/dist/exporter/index.d.ts +29 -0
  72. package/dist/exporter/index.js +77 -0
  73. package/dist/failover/index.d.ts +11 -0
  74. package/dist/failover/index.js +45 -0
  75. package/dist/fixtures/index.d.ts +27 -0
  76. package/dist/fixtures/index.js +260 -0
  77. package/dist/fixtures/scrub.d.ts +5 -0
  78. package/dist/heyreach/account.d.ts +11 -0
  79. package/dist/heyreach/adapter.d.ts +5 -0
  80. package/dist/heyreach/capabilities.d.ts +70 -0
  81. package/dist/heyreach/client.d.ts +18 -0
  82. package/dist/heyreach/inbox.d.ts +7 -0
  83. package/dist/heyreach/index.d.ts +25 -0
  84. package/dist/heyreach/index.js +1931 -0
  85. package/dist/heyreach/leads.d.ts +4 -0
  86. package/dist/heyreach/lookup.d.ts +15 -0
  87. package/dist/heyreach/map-account.d.ts +31 -0
  88. package/dist/heyreach/map-sequence.d.ts +5 -0
  89. package/dist/heyreach/map-stats.d.ts +13 -0
  90. package/dist/heyreach/map.d.ts +37 -0
  91. package/dist/heyreach/native-organization.d.ts +128 -0
  92. package/dist/heyreach/native-voice.d.ts +106 -0
  93. package/dist/heyreach/native.d.ts +496 -0
  94. package/dist/heyreach/paging.d.ts +7 -0
  95. package/dist/heyreach/webhooks.d.ts +3 -0
  96. package/dist/identity/index.d.ts +3 -0
  97. package/dist/identity/index.js +159 -0
  98. package/dist/identity/keys.d.ts +9 -0
  99. package/dist/identity/plugin.d.ts +34 -0
  100. package/dist/index.d.ts +33 -0
  101. package/dist/index.js +131 -0
  102. package/dist/insights/copy/copy-audit.d.ts +55 -0
  103. package/dist/insights/copy/copy-checks.d.ts +44 -0
  104. package/dist/insights/copy/copy-reuse.d.ts +59 -0
  105. package/dist/insights/copy/index.d.ts +67 -0
  106. package/dist/insights/copy/reply-timing.d.ts +63 -0
  107. package/dist/insights/copy/shared.d.ts +53 -0
  108. package/dist/insights/copy/step-funnel.d.ts +66 -0
  109. package/dist/insights/copy/variant-test.d.ts +64 -0
  110. package/dist/insights/define.d.ts +98 -0
  111. package/dist/insights/index.d.ts +10 -0
  112. package/dist/insights/index.js +4937 -0
  113. package/dist/insights/ops/anomalies.d.ts +80 -0
  114. package/dist/insights/ops/campaign-diagnosis.d.ts +39 -0
  115. package/dist/insights/ops/campaign-ranking.d.ts +56 -0
  116. package/dist/insights/ops/channel-mix.d.ts +44 -0
  117. package/dist/insights/ops/client-report.d.ts +76 -0
  118. package/dist/insights/ops/diagnosis-checks.d.ts +48 -0
  119. package/dist/insights/ops/index.d.ts +135 -0
  120. package/dist/insights/ops/period-comparison.d.ts +86 -0
  121. package/dist/insights/ops/pipeline-forecast.d.ts +44 -0
  122. package/dist/insights/ops/shared.d.ts +155 -0
  123. package/dist/insights/ops/tag-rollup.d.ts +32 -0
  124. package/dist/insights/people/account-summary.d.ts +68 -0
  125. package/dist/insights/people/dropped-replies.d.ts +51 -0
  126. package/dist/insights/people/find.d.ts +18 -0
  127. package/dist/insights/people/hot-leads.d.ts +67 -0
  128. package/dist/insights/people/index.d.ts +88 -0
  129. package/dist/insights/people/lead-collisions.d.ts +43 -0
  130. package/dist/insights/people/person-summary.d.ts +46 -0
  131. package/dist/insights/people/personalization-gaps.d.ts +60 -0
  132. package/dist/insights/people/read.d.ts +40 -0
  133. package/dist/insights/people/suppression-check.d.ts +53 -0
  134. package/dist/insights/plugin.d.ts +40 -0
  135. package/dist/insights/registry.d.ts +335 -0
  136. package/dist/insights/senders/bounce-watch.d.ts +70 -0
  137. package/dist/insights/senders/domain-health.d.ts +69 -0
  138. package/dist/insights/senders/index.d.ts +74 -0
  139. package/dist/insights/senders/read.d.ts +37 -0
  140. package/dist/insights/senders/sender-capacity.d.ts +67 -0
  141. package/dist/insights/senders/sender-load.d.ts +52 -0
  142. package/dist/insights/senders/settings-audit.d.ts +48 -0
  143. package/dist/insights/senders/warmup-readiness.d.ts +39 -0
  144. package/dist/insights/stats.d.ts +45 -0
  145. package/dist/insights/tools.d.ts +16 -0
  146. package/dist/insights/types.d.ts +4 -0
  147. package/dist/instantly/adapter-account.d.ts +5 -0
  148. package/dist/instantly/adapter-mail.d.ts +3 -0
  149. package/dist/instantly/adapter.d.ts +7 -0
  150. package/dist/instantly/capabilities.d.ts +85 -0
  151. package/dist/instantly/client.d.ts +24 -0
  152. package/dist/instantly/index.d.ts +27 -0
  153. package/dist/instantly/index.js +2627 -0
  154. package/dist/instantly/map-account.d.ts +38 -0
  155. package/dist/instantly/map-lead.d.ts +18 -0
  156. package/dist/instantly/map-stats.d.ts +25 -0
  157. package/dist/instantly/map.d.ts +22 -0
  158. package/dist/instantly/native-agents-sales.d.ts +161 -0
  159. package/dist/instantly/native-agents.d.ts +156 -0
  160. package/dist/instantly/native-campaigns.d.ts +101 -0
  161. package/dist/instantly/native-leads.d.ts +93 -0
  162. package/dist/instantly/native-params.d.ts +7 -0
  163. package/dist/instantly/native-search.d.ts +82 -0
  164. package/dist/instantly/native-senders.d.ts +182 -0
  165. package/dist/instantly/native-supersearch.d.ts +149 -0
  166. package/dist/instantly/native-workspace.d.ts +170 -0
  167. package/dist/instantly/native.d.ts +1081 -0
  168. package/dist/instantly/pages.d.ts +29 -0
  169. package/dist/instantly/stats.d.ts +5 -0
  170. package/dist/instantly/webhooks.d.ts +3 -0
  171. package/dist/internal/adapter.d.ts +211 -0
  172. package/dist/internal/capabilities.d.ts +104 -0
  173. package/dist/internal/client.d.ts +15 -0
  174. package/dist/internal/concurrency.d.ts +8 -0
  175. package/dist/internal/cursor.d.ts +10 -0
  176. package/dist/internal/engine/budget.d.ts +44 -0
  177. package/dist/internal/engine/engine.d.ts +45 -0
  178. package/dist/internal/engine/rate-store.d.ts +25 -0
  179. package/dist/internal/engine/request.d.ts +34 -0
  180. package/dist/internal/engine/retry.d.ts +21 -0
  181. package/dist/internal/engine/runtime.d.ts +13 -0
  182. package/dist/internal/entities-account.d.ts +205 -0
  183. package/dist/internal/entities.d.ts +493 -0
  184. package/dist/internal/env.d.ts +4 -0
  185. package/dist/internal/errors.d.ts +62 -0
  186. package/dist/internal/fields.d.ts +462 -0
  187. package/dist/internal/hooks.d.ts +55 -0
  188. package/dist/internal/json.d.ts +49 -0
  189. package/dist/internal/lead-fields.d.ts +21 -0
  190. package/dist/internal/lead-status.d.ts +13 -0
  191. package/dist/internal/limits.d.ts +34 -0
  192. package/dist/internal/metrics.d.ts +64 -0
  193. package/dist/internal/native.d.ts +81 -0
  194. package/dist/internal/outbound/api.d.ts +292 -0
  195. package/dist/internal/outbound/collections.d.ts +31 -0
  196. package/dist/internal/outbound/core.d.ts +36 -0
  197. package/dist/internal/outbound/create.d.ts +16 -0
  198. package/dist/internal/outbound/handles.d.ts +7 -0
  199. package/dist/internal/outbound/native.d.ts +4 -0
  200. package/dist/internal/outbound/operation-shared.d.ts +28 -0
  201. package/dist/internal/outbound/operations-account.d.ts +41 -0
  202. package/dist/internal/outbound/operations.d.ts +42 -0
  203. package/dist/internal/outbound/outbound.d.ts +67 -0
  204. package/dist/internal/outbound/plugins.d.ts +40 -0
  205. package/dist/internal/outbound/raw.d.ts +9 -0
  206. package/dist/internal/outbound/specs-account.d.ts +20 -0
  207. package/dist/internal/outbound/specs.d.ts +14 -0
  208. package/dist/internal/outbound/stats.d.ts +7 -0
  209. package/dist/internal/outbound/validate.d.ts +5 -0
  210. package/dist/internal/outbound/walker.d.ts +22 -0
  211. package/dist/internal/page.d.ts +14 -0
  212. package/dist/internal/record.d.ts +36 -0
  213. package/dist/internal/records.d.ts +7 -0
  214. package/dist/internal/redact.d.ts +18 -0
  215. package/dist/internal/ref.d.ts +16 -0
  216. package/dist/internal/sequence.d.ts +14 -0
  217. package/dist/internal/sha256.d.ts +6 -0
  218. package/dist/internal/text.d.ts +11 -0
  219. package/dist/internal/url.d.ts +9 -0
  220. package/dist/loader/index.d.ts +24 -0
  221. package/dist/loader/index.js +16 -0
  222. package/dist/memory/account-reads.d.ts +5 -0
  223. package/dist/memory/account.d.ts +81 -0
  224. package/dist/memory/adapter.d.ts +16 -0
  225. package/dist/memory/data.d.ts +137 -0
  226. package/dist/memory/demo.d.ts +7 -0
  227. package/dist/memory/index.d.ts +5 -0
  228. package/dist/memory/index.js +867 -0
  229. package/dist/memory/stats.d.ts +6 -0
  230. package/dist/memory/store.d.ts +18 -0
  231. package/dist/providers/index.d.ts +22 -0
  232. package/dist/providers/index.js +10 -0
  233. package/dist/reconcile/index.d.ts +2 -0
  234. package/dist/reconcile/index.js +72 -0
  235. package/dist/reconcile/plugin.d.ts +55 -0
  236. package/dist/redact/index.d.ts +2 -0
  237. package/dist/redact/index.js +197 -0
  238. package/dist/redact/plugin.d.ts +22 -0
  239. package/dist/redis/index.d.ts +41 -0
  240. package/dist/redis/index.js +114 -0
  241. package/dist/smartlead/account.d.ts +5 -0
  242. package/dist/smartlead/adapter.d.ts +5 -0
  243. package/dist/smartlead/capabilities.d.ts +87 -0
  244. package/dist/smartlead/client.d.ts +18 -0
  245. package/dist/smartlead/hmac.d.ts +7 -0
  246. package/dist/smartlead/index.d.ts +24 -0
  247. package/dist/smartlead/index.js +2329 -0
  248. package/dist/smartlead/leads.d.ts +9 -0
  249. package/dist/smartlead/lookup.d.ts +8 -0
  250. package/dist/smartlead/mail.d.ts +5 -0
  251. package/dist/smartlead/map-account.d.ts +34 -0
  252. package/dist/smartlead/map-messages.d.ts +31 -0
  253. package/dist/smartlead/map-stats.d.ts +36 -0
  254. package/dist/smartlead/map.d.ts +62 -0
  255. package/dist/smartlead/native-analytics.d.ts +242 -0
  256. package/dist/smartlead/native-campaigns.d.ts +211 -0
  257. package/dist/smartlead/native-inbox.d.ts +141 -0
  258. package/dist/smartlead/native-params.d.ts +12 -0
  259. package/dist/smartlead/native-services.d.ts +204 -0
  260. package/dist/smartlead/native.d.ts +785 -0
  261. package/dist/smartlead/shared.d.ts +29 -0
  262. package/dist/smartlead/stats.d.ts +5 -0
  263. package/dist/smartlead/webhooks.d.ts +3 -0
  264. package/dist/sync/index.d.ts +2 -0
  265. package/dist/sync/index.js +158 -0
  266. package/dist/sync/plugin.d.ts +58 -0
  267. package/dist/tools/account-tools.d.ts +21 -0
  268. package/dist/tools/ai-sdk.d.ts +8 -0
  269. package/dist/tools/ai-sdk.js +28 -0
  270. package/dist/tools/campaign-tools.d.ts +59 -0
  271. package/dist/tools/claude-agent.d.ts +18 -0
  272. package/dist/tools/claude-agent.js +42 -0
  273. package/dist/tools/index.d.ts +28 -0
  274. package/dist/tools/index.js +22 -0
  275. package/dist/tools/people-tools.d.ts +19 -0
  276. package/dist/tools/registry.d.ts +34 -0
  277. package/dist/tools/shared.d.ts +75 -0
  278. package/dist/tracing/index.d.ts +25 -0
  279. package/dist/tracing/index.js +69 -0
  280. package/dist/webhooks/index.d.ts +3 -0
  281. package/dist/webhooks/index.js +227 -0
  282. package/dist/webhooks/parse.d.ts +41 -0
  283. package/dist/webhooks/secret.d.ts +4 -0
  284. package/package.json +181 -4
@@ -0,0 +1,64 @@
1
+ import type { Interval } from "../stats.ts";
2
+ import type { RateBasis } from "./shared.ts";
3
+ declare const METRICS: readonly ["replied", "positive", "opened", "clicked"];
4
+ type Metric = (typeof METRICS)[number];
5
+ export type VariantVerdict = "no_difference_yet" | "too_little_data" | "winner";
6
+ export interface TestedVariant {
7
+ readonly variantKey: string;
8
+ readonly sent: number | null;
9
+ /** The metric's count. `null` when the vendor does not report it. */
10
+ readonly count: number | null;
11
+ /** What the rate is divided by. */
12
+ readonly trials: number | null;
13
+ readonly basis: RateBasis | null;
14
+ readonly rate: number | null;
15
+ readonly interval: Interval | null;
16
+ /** `false` when the base is under `min_sent` or the rate is unknown; such a variant is not compared. */
17
+ readonly enoughData: boolean;
18
+ /** Two-sided p-value against the leader. `null` for the leader, a variant not compared, and two rates that are both 0 or both 1. */
19
+ readonly pValueVsLeader: number | null;
20
+ }
21
+ export interface VariantStepTest {
22
+ /** Counted from 0. */
23
+ readonly step: number;
24
+ readonly verdict: VariantVerdict;
25
+ /** The variant with the highest rate among those with enough data. `null` when fewer than two have enough. */
26
+ readonly leader: string | null;
27
+ /** The p-value of the leader against its closest rival. */
28
+ readonly pValue: number | null;
29
+ /** A rough number of further sends, over all variants, before there can be a verdict. `null` when it cannot be estimated or there is a winner. */
30
+ readonly moreSendsNeeded: number | null;
31
+ readonly reason: string;
32
+ readonly variants: readonly TestedVariant[];
33
+ }
34
+ export interface VariantTest {
35
+ readonly campaign: string;
36
+ readonly metric: Metric;
37
+ readonly alpha: number;
38
+ /** `false` when the vendor's step stats carry no variant rows at all. */
39
+ readonly variantStatsReported: boolean;
40
+ /** Winners first, then steps with no difference yet, then steps with too little data. */
41
+ readonly steps: readonly VariantStepTest[];
42
+ readonly totals: {
43
+ readonly stepsTested: number;
44
+ readonly winners: number;
45
+ readonly noDifferenceYet: number;
46
+ readonly tooLittleData: number;
47
+ };
48
+ }
49
+ export declare const variantTest: import("../define.ts").InsightDefinition<"variantTest", {
50
+ alpha: number;
51
+ campaign: string;
52
+ from: string | null;
53
+ metric: "positive" | "replied" | "clicked" | "opened";
54
+ min_sent: number;
55
+ to: string | null;
56
+ }, VariantTest, {
57
+ campaign: string;
58
+ alpha?: number | undefined;
59
+ from?: string | null | undefined;
60
+ metric?: "positive" | "replied" | "clicked" | "opened" | undefined;
61
+ min_sent?: number | undefined;
62
+ to?: string | null | undefined;
63
+ }>;
64
+ export {};
@@ -0,0 +1,98 @@
1
+ import type { ZodObject, ZodType } from "zod";
2
+ import type { CapabilityKey } from "../internal/capabilities.ts";
3
+ import type { Evidence, MetricRow } from "../internal/entities.ts";
4
+ import type { Json } from "../internal/json.ts";
5
+ import type { ListAll, OutboundApi, PageResult, StatsResult, WithMeta } from "../internal/outbound/api.ts";
6
+ export interface InsightMeta {
7
+ /** `exact` only when every read behind the answer was exact. */
8
+ readonly evidence: Evidence;
9
+ /** Vendor requests the insight made. */
10
+ readonly requests: number;
11
+ /** `false` when a cap stopped a read early, so the answer covers part of the data. */
12
+ readonly complete: boolean;
13
+ /** What the reader should know before trusting the numbers. */
14
+ readonly notes: readonly string[];
15
+ readonly provider: string;
16
+ /** When the insight was computed, ISO 8601 UTC. */
17
+ readonly computedAt: string;
18
+ }
19
+ export interface InsightResult<Data> {
20
+ readonly insight: string;
21
+ readonly data: Data;
22
+ readonly meta: InsightMeta;
23
+ }
24
+ /** What an insight reads through. Every helper records the read's cost and evidence. */
25
+ export interface InsightContext {
26
+ readonly outbound: OutboundApi;
27
+ /** The time the insight runs at, in milliseconds. Fixed in tests. */
28
+ readonly now: number;
29
+ /** Records a page's cost and returns its items. An unfinished page marks the answer incomplete. */
30
+ readonly page: <Item>(page: PageResult<Item>) => readonly Item[];
31
+ /**
32
+ * Walks a listing to its end or its `max`, records the cost and returns the
33
+ * records. When `max` cut it short the answer is marked incomplete; `cap`
34
+ * names what was capped for the note, for example `50 campaigns`.
35
+ */
36
+ readonly all: <Item>(walk: ListAll<Item>, cap?: string) => Promise<Item[]>;
37
+ /** Records one lookup's cost and returns the record. */
38
+ readonly one: <Item>(item: WithMeta<Item>) => Item;
39
+ /** Records a stats read's cost and returns its rows. */
40
+ readonly rows: (stats: StatsResult) => readonly MetricRow[];
41
+ /** Adds a note to the answer. The same note is kept once. */
42
+ readonly note: (text: string) => void;
43
+ /** Marks the answer as covering part of the data, with the reason as a note. */
44
+ readonly partial: (reason: string) => void;
45
+ }
46
+ export interface RunOptions {
47
+ /** Replaces the clock. Meant for tests. */
48
+ readonly now?: number | undefined;
49
+ }
50
+ /** What every insight has in common, whatever its input and its answer. */
51
+ export interface InsightEntry {
52
+ /** The method name on `outbound.insights`, camelCase. */
53
+ readonly key: string;
54
+ /** The tool and CLI name, snake_case. */
55
+ readonly name: string;
56
+ /** Self-contained: a model needs no system prompt to use it. Says what it costs. */
57
+ readonly description: string;
58
+ /** A `z.object()`. Every field has a description and, where it can, a default. */
59
+ readonly inputSchema: ZodObject;
60
+ /** Capabilities the adapter must have. Checked before any request. */
61
+ readonly needs: readonly CapabilityKey[];
62
+ /** What to ask next, for an agent. */
63
+ readonly next: string;
64
+ /** Checks the input and the capabilities, then runs the insight. */
65
+ readonly execute: (outbound: OutboundApi, input?: Json, options?: RunOptions) => Promise<InsightResult<Json>>;
66
+ }
67
+ /**
68
+ * `Input` is what `run` receives, with every default applied. `Given` is what
69
+ * a caller writes, where a field with a default may be left out.
70
+ */
71
+ export interface InsightSpec<Key extends string, Input, Data, Given = Input> {
72
+ readonly key: Key;
73
+ readonly name: string;
74
+ readonly description: string;
75
+ readonly inputSchema: ZodObject & ZodType<Input, Given>;
76
+ readonly needs: readonly CapabilityKey[];
77
+ /**
78
+ * Capabilities this input needs on top of `needs`, when what is read
79
+ * depends on the input. Checked before any request, like `needs`.
80
+ */
81
+ readonly needsFor?: ((input: Input) => readonly CapabilityKey[]) | undefined;
82
+ readonly next: string;
83
+ readonly run: (context: InsightContext, input: Input) => Promise<Data>;
84
+ }
85
+ export interface InsightDefinition<Key extends string = string, Input = never, Data = Json, Given = Input> extends InsightEntry {
86
+ readonly key: Key;
87
+ readonly inputSchema: ZodObject & ZodType<Input, Given>;
88
+ readonly run: (context: InsightContext, input: Input) => Promise<Data>;
89
+ /** Never set. It carries the caller's input type to `outbound.insights`. */
90
+ readonly given?: Given;
91
+ }
92
+ /**
93
+ * Defines an insight. The key, the input type and the data type are kept as
94
+ * written, so `outbound.insights` is typed from the definitions.
95
+ */
96
+ export declare const defineInsight: <const Key extends string, Input, Data, Given>(spec: InsightSpec<Key, Input, Data, Given>) => InsightDefinition<Key, Input, Data, Given>;
97
+ /** Checks the input and the capabilities, then runs one insight, keeping its typed answer. */
98
+ export declare const runInsight: <Key extends string, Input, Data, Given>(outbound: OutboundApi, definition: InsightDefinition<Key, Input, Data, Given>, input: Given, options?: RunOptions) => Promise<InsightResult<Data>>;
@@ -0,0 +1,10 @@
1
+ export { insights, listInsights, runInsightByName } from "./plugin.ts";
2
+ export type { Insights, InsightsExtension } from "./plugin.ts";
3
+ export { insightTools } from "./tools.ts";
4
+ export type { InsightToolsOptions } from "./tools.ts";
5
+ export { defineInsight, runInsight } from "./define.ts";
6
+ export type { InsightContext, InsightDefinition, InsightMeta, InsightResult, RunOptions, } from "./define.ts";
7
+ export { INSIGHTS } from "./registry.ts";
8
+ export { compareRates, deviation, mean, median, percentile, rate, round, tally, total, wilson, zScore, } from "./stats.ts";
9
+ export type { Interval, ProportionTest, Sample } from "./stats.ts";
10
+ export type * from "./types.ts";