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.
- package/README.md +2 -2
- package/dist/alerts/check-evaluate.d.ts +53 -0
- package/dist/alerts/check-measure.d.ts +100 -0
- package/dist/alerts/check-schema.d.ts +184 -0
- package/dist/alerts/check-validate.d.ts +18 -0
- package/dist/alerts/index.d.ts +7 -0
- package/dist/alerts/index.js +635 -2
- package/dist/budget/index.d.ts +2 -0
- package/dist/budget/index.js +1 -0
- package/dist/cards/index.js +2 -1
- package/dist/chunks/{chunk-5CFO3CXG.js → chunk-3S32R2MH.js} +33 -67
- package/dist/chunks/{chunk-ZFVHM5JI.js → chunk-5J7GGV62.js} +11 -4
- package/dist/chunks/chunk-6TKFISG4.js +676 -0
- package/dist/chunks/{chunk-E6DSDCPI.js → chunk-BK5SLY32.js} +92 -101
- package/dist/chunks/{chunk-A6WVOCA4.js → chunk-BN6WCAWX.js} +4 -4
- package/dist/chunks/{chunk-IZFTTMJP.js → chunk-EHSJGQ5K.js} +5 -5
- package/dist/chunks/chunk-HPNGSG5E.js +51 -0
- package/dist/chunks/chunk-HWHI4LFY.js +102 -0
- package/dist/chunks/{chunk-Y5RAJ6PZ.js → chunk-OLPMBRXM.js} +3 -2
- package/dist/chunks/chunk-WGW3ROLY.js +18 -0
- package/dist/chunks/{chunk-7ZDS6SZD.js → chunk-WH6V3YNN.js} +25 -0
- package/dist/chunks/{chunk-7LNJJ2RO.js → chunk-X4RDBD4J.js} +102 -11
- package/dist/chunks/chunk-XL6LJVHJ.js +71 -0
- package/dist/chunks/{chunk-5FVKRIEJ.js → chunk-YYCT3NGV.js} +35 -11
- package/dist/cli/bin.js +13 -28
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.js +12 -11
- package/dist/cli/update.d.ts +15 -0
- package/dist/emailbison/account.d.ts +7 -0
- package/dist/emailbison/adapter.d.ts +5 -0
- package/dist/emailbison/capabilities.d.ts +78 -0
- package/dist/emailbison/client.d.ts +29 -0
- package/dist/emailbison/index.d.ts +30 -0
- package/dist/emailbison/index.js +1017 -0
- package/dist/emailbison/mail.d.ts +5 -0
- package/dist/emailbison/map-mail.d.ts +13 -0
- package/dist/emailbison/map-sequence.d.ts +12 -0
- package/dist/emailbison/map-stats.d.ts +47 -0
- package/dist/emailbison/map.d.ts +24 -0
- package/dist/emailbison/native-params.d.ts +5 -0
- package/dist/emailbison/native-workspace.d.ts +167 -0
- package/dist/emailbison/native.d.ts +327 -0
- package/dist/emailbison/stats.d.ts +4 -0
- package/dist/emailbison/webhooks.d.ts +2 -0
- package/dist/fixtures/index.js +6 -6
- package/dist/heyreach/capabilities.d.ts +3 -0
- package/dist/heyreach/index.js +20 -20
- package/dist/index.js +19 -18
- package/dist/insights/copy/copy-reuse.d.ts +6 -6
- package/dist/insights/copy/shared.d.ts +2 -2
- package/dist/insights/copy/step-funnel.d.ts +5 -5
- package/dist/insights/copy/variant-test.d.ts +2 -2
- package/dist/insights/cost.d.ts +91 -0
- package/dist/insights/define.d.ts +22 -1
- package/dist/insights/index.d.ts +4 -3
- package/dist/insights/index.js +331 -27
- package/dist/insights/inputs.generated.d.ts +4 -4
- package/dist/insights/ops/campaign-ranking.d.ts +3 -3
- package/dist/insights/ops/index.d.ts +2 -2
- package/dist/insights/ops/shared.d.ts +11 -1
- package/dist/insights/plugin.d.ts +19 -0
- package/dist/insights/registry.d.ts +2 -2
- package/dist/insights/run-cap.d.ts +35 -0
- package/dist/insights/senders/bounce-watch.d.ts +4 -4
- package/dist/insights/senders/domain-health.d.ts +2 -2
- package/dist/insights/senders/sender-load.d.ts +1 -1
- package/dist/insights/tools.d.ts +10 -0
- package/dist/instantly/capabilities.d.ts +13 -0
- package/dist/instantly/index.js +41 -28
- package/dist/internal/adapter.d.ts +12 -0
- package/dist/internal/outbound/outbound.d.ts +5 -1
- package/dist/internal/request-cap.d.ts +35 -0
- package/dist/loader/index.js +2 -2
- package/dist/memory/index.js +10 -10
- package/dist/providers/index.d.ts +21 -1
- package/dist/providers/index.js +1 -1
- package/dist/redact/index.js +4 -4
- package/dist/smartlead/capabilities.d.ts +5 -0
- package/dist/smartlead/index.js +24 -24
- package/dist/tools/ai-sdk.js +5 -3
- package/dist/tools/claude-agent.js +5 -3
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.js +11 -6
- package/dist/tools/registry.d.ts +20 -1
- package/dist/tools/shared.d.ts +20 -1
- package/dist/webhooks/index.js +16 -7
- package/package.json +8 -2
- package/dist/chunks/chunk-K4USHN4C.js +0 -40
- package/dist/chunks/chunk-LVQUSKEX.js +0 -17
- package/dist/chunks/{chunk-C4LS2HNV.js → chunk-JWGSB7PT.js} +3 -3
|
@@ -29,10 +29,12 @@ export declare const costs: {
|
|
|
29
29
|
"leads.list": {
|
|
30
30
|
pageSize: number;
|
|
31
31
|
perPage: number;
|
|
32
|
+
perWalk: number;
|
|
32
33
|
};
|
|
33
34
|
"leads.lookup": {
|
|
34
35
|
pageSize: number;
|
|
35
36
|
perPage: number;
|
|
37
|
+
perWalk: number;
|
|
36
38
|
};
|
|
37
39
|
"lists.list": {
|
|
38
40
|
pageSize: number;
|
|
@@ -55,6 +57,7 @@ export declare const costs: {
|
|
|
55
57
|
"senders.list": {
|
|
56
58
|
pageSize: number;
|
|
57
59
|
perPage: number;
|
|
60
|
+
perWalk: number;
|
|
58
61
|
};
|
|
59
62
|
"sequence.get": {
|
|
60
63
|
perPage: number;
|
package/dist/heyreach/index.js
CHANGED
|
@@ -1,27 +1,38 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EVENT_TYPES,
|
|
3
3
|
heyreachEvents
|
|
4
|
-
} from "../chunks/chunk-
|
|
4
|
+
} from "../chunks/chunk-JWGSB7PT.js";
|
|
5
5
|
import {
|
|
6
|
-
createVendorClient,
|
|
7
|
-
listIn,
|
|
8
6
|
mapPage,
|
|
9
|
-
normalizeBody,
|
|
10
7
|
withLeadFields,
|
|
11
8
|
withMappedFields
|
|
12
|
-
} from "../chunks/chunk-
|
|
9
|
+
} from "../chunks/chunk-XL6LJVHJ.js";
|
|
13
10
|
import {
|
|
11
|
+
createVendorClient,
|
|
14
12
|
leadStanding,
|
|
13
|
+
listIn,
|
|
14
|
+
normalizeBody,
|
|
15
15
|
toVariant,
|
|
16
16
|
variantKey
|
|
17
|
-
} from "../chunks/chunk-
|
|
17
|
+
} from "../chunks/chunk-3S32R2MH.js";
|
|
18
18
|
import {
|
|
19
19
|
defineNative
|
|
20
20
|
} from "../chunks/chunk-NAKXLBA6.js";
|
|
21
|
+
import {
|
|
22
|
+
eventTypesOf,
|
|
23
|
+
recordBase,
|
|
24
|
+
refTo,
|
|
25
|
+
refsTo
|
|
26
|
+
} from "../chunks/chunk-2D42TQFU.js";
|
|
27
|
+
import "../chunks/chunk-BOWXGMN3.js";
|
|
21
28
|
import {
|
|
22
29
|
emptyCounts,
|
|
23
30
|
metricRow
|
|
24
31
|
} from "../chunks/chunk-PQSTQKRD.js";
|
|
32
|
+
import "../chunks/chunk-QGRZDTX4.js";
|
|
33
|
+
import {
|
|
34
|
+
assertWorkspaceId
|
|
35
|
+
} from "../chunks/chunk-QAKJ76HB.js";
|
|
25
36
|
import {
|
|
26
37
|
profileSlug
|
|
27
38
|
} from "../chunks/chunk-NAWZ73QS.js";
|
|
@@ -32,17 +43,6 @@ import {
|
|
|
32
43
|
readEnv,
|
|
33
44
|
requireCredential
|
|
34
45
|
} from "../chunks/chunk-GFDNRWR3.js";
|
|
35
|
-
import {
|
|
36
|
-
eventTypesOf,
|
|
37
|
-
recordBase,
|
|
38
|
-
refTo,
|
|
39
|
-
refsTo
|
|
40
|
-
} from "../chunks/chunk-2D42TQFU.js";
|
|
41
|
-
import "../chunks/chunk-BOWXGMN3.js";
|
|
42
|
-
import "../chunks/chunk-QGRZDTX4.js";
|
|
43
|
-
import {
|
|
44
|
-
assertWorkspaceId
|
|
45
|
-
} from "../chunks/chunk-QAKJ76HB.js";
|
|
46
46
|
import {
|
|
47
47
|
OutboundError,
|
|
48
48
|
isHttpFailure,
|
|
@@ -488,12 +488,12 @@ var costs = {
|
|
|
488
488
|
"leads.get": { perPage: 2 },
|
|
489
489
|
// A campaign's leads. A saved list's leads come up to 1000 a page. Without
|
|
490
490
|
// a campaign or a list, each new page of campaigns costs one more request.
|
|
491
|
-
"leads.list": { pageSize: PAGE_SIZE, perPage: 1 },
|
|
491
|
+
"leads.list": { pageSize: PAGE_SIZE, perPage: 1, perWalk: 1 },
|
|
492
492
|
// One person by profile URL: the campaigns and the profile, two requests.
|
|
493
493
|
// By email it is three (campaigns, the lists the address is in, a name
|
|
494
494
|
// search in one list) and one more per profile read to find the address,
|
|
495
495
|
// eight at most; a later page is two again.
|
|
496
|
-
"leads.lookup": { pageSize: PAGE_SIZE, perPage: 2 },
|
|
496
|
+
"leads.lookup": { pageSize: PAGE_SIZE, perPage: 2, perWalk: 6 },
|
|
497
497
|
"lists.list": { pageSize: PAGE_SIZE, perPage: 1 },
|
|
498
498
|
// One conversation by thread id is a single request.
|
|
499
499
|
"messages.list": { pageSize: PAGE_SIZE, perPage: 1 },
|
|
@@ -501,7 +501,7 @@ var costs = {
|
|
|
501
501
|
"senders.get": { perPage: 1 },
|
|
502
502
|
"senders.health": { perPage: 1 },
|
|
503
503
|
// A campaign's senders cost one more request, once, to read the campaign.
|
|
504
|
-
"senders.list": { pageSize: PAGE_SIZE, perPage: 1 },
|
|
504
|
+
"senders.list": { pageSize: PAGE_SIZE, perPage: 1, perWalk: 1 },
|
|
505
505
|
"sequence.get": { perPage: 1 },
|
|
506
506
|
stats: { perPage: 1 },
|
|
507
507
|
"webhooks.list": { pageSize: PAGE_SIZE, perPage: 1 }
|
package/dist/index.js
CHANGED
|
@@ -3,27 +3,11 @@ import {
|
|
|
3
3
|
Outbound,
|
|
4
4
|
createOutbound,
|
|
5
5
|
fullJitterBackoff
|
|
6
|
-
} from "./chunks/chunk-
|
|
6
|
+
} from "./chunks/chunk-YYCT3NGV.js";
|
|
7
7
|
import {
|
|
8
8
|
MemoryRateLimitStore
|
|
9
9
|
} from "./chunks/chunk-4O2HRTTI.js";
|
|
10
|
-
import "./chunks/chunk-
|
|
11
|
-
import {
|
|
12
|
-
defineNative
|
|
13
|
-
} from "./chunks/chunk-NAKXLBA6.js";
|
|
14
|
-
import {
|
|
15
|
-
METRIC_DEFINITIONS,
|
|
16
|
-
computeRates,
|
|
17
|
-
emptyCounts,
|
|
18
|
-
sumCounts
|
|
19
|
-
} from "./chunks/chunk-PQSTQKRD.js";
|
|
20
|
-
import {
|
|
21
|
-
profileSlug
|
|
22
|
-
} from "./chunks/chunk-NAWZ73QS.js";
|
|
23
|
-
import {
|
|
24
|
-
sha256Hex,
|
|
25
|
-
stableId
|
|
26
|
-
} from "./chunks/chunk-FHKSLCVW.js";
|
|
10
|
+
import "./chunks/chunk-HPNGSG5E.js";
|
|
27
11
|
import {
|
|
28
12
|
CAPABILITY_KEYS,
|
|
29
13
|
NO_CAPABILITIES,
|
|
@@ -39,6 +23,10 @@ import {
|
|
|
39
23
|
tagSchema,
|
|
40
24
|
webhookSubscriptionSchema
|
|
41
25
|
} from "./chunks/chunk-ZOAG2C6V.js";
|
|
26
|
+
import "./chunks/chunk-PTZO4QXR.js";
|
|
27
|
+
import {
|
|
28
|
+
defineNative
|
|
29
|
+
} from "./chunks/chunk-NAKXLBA6.js";
|
|
42
30
|
import {
|
|
43
31
|
campaignSchema,
|
|
44
32
|
channelSchema,
|
|
@@ -59,6 +47,12 @@ import {
|
|
|
59
47
|
sequenceSchema,
|
|
60
48
|
workspaceSchema
|
|
61
49
|
} from "./chunks/chunk-BOWXGMN3.js";
|
|
50
|
+
import {
|
|
51
|
+
METRIC_DEFINITIONS,
|
|
52
|
+
computeRates,
|
|
53
|
+
emptyCounts,
|
|
54
|
+
sumCounts
|
|
55
|
+
} from "./chunks/chunk-PQSTQKRD.js";
|
|
62
56
|
import {
|
|
63
57
|
SCHEMA_VERSION,
|
|
64
58
|
campaignStatusSchema,
|
|
@@ -68,6 +62,13 @@ import {
|
|
|
68
62
|
makeRef,
|
|
69
63
|
parseRef
|
|
70
64
|
} from "./chunks/chunk-QAKJ76HB.js";
|
|
65
|
+
import {
|
|
66
|
+
profileSlug
|
|
67
|
+
} from "./chunks/chunk-NAWZ73QS.js";
|
|
68
|
+
import {
|
|
69
|
+
sha256Hex,
|
|
70
|
+
stableId
|
|
71
|
+
} from "./chunks/chunk-FHKSLCVW.js";
|
|
71
72
|
import {
|
|
72
73
|
OutboundError,
|
|
73
74
|
REDACTED_EMAIL,
|
|
@@ -14,11 +14,11 @@ export interface CopyUse {
|
|
|
14
14
|
};
|
|
15
15
|
/** What the rate divides by: leads contacted or messages sent. */
|
|
16
16
|
readonly basis: RateBasis | null;
|
|
17
|
-
/** @deprecated Use `rates.replyRate.of`. Removed in 0.
|
|
17
|
+
/** @deprecated Use `rates.replyRate.of`. Removed in 0.6.0. */
|
|
18
18
|
readonly trials: number | null;
|
|
19
|
-
/** @deprecated Use `rates.replyRate.rate`. Removed in 0.
|
|
19
|
+
/** @deprecated Use `rates.replyRate.rate`. Removed in 0.6.0. */
|
|
20
20
|
readonly replyRate: number | null;
|
|
21
|
-
/** @deprecated Use `rates.replyRate.low` and `.high`. Removed in 0.
|
|
21
|
+
/** @deprecated Use `rates.replyRate.low` and `.high`. Removed in 0.6.0. */
|
|
22
22
|
readonly replyRateInterval: Interval | null;
|
|
23
23
|
}
|
|
24
24
|
export interface CopyPiece {
|
|
@@ -34,11 +34,11 @@ export interface CopyPiece {
|
|
|
34
34
|
readonly replyRate: BasedRate;
|
|
35
35
|
};
|
|
36
36
|
readonly basis: RateBasis | null;
|
|
37
|
-
/** @deprecated Use `rates.replyRate.of`. Removed in 0.
|
|
37
|
+
/** @deprecated Use `rates.replyRate.of`. Removed in 0.6.0. */
|
|
38
38
|
readonly trials: number | null;
|
|
39
|
-
/** @deprecated Use `rates.replyRate.rate`. Removed in 0.
|
|
39
|
+
/** @deprecated Use `rates.replyRate.rate`. Removed in 0.6.0. */
|
|
40
40
|
readonly replyRate: number | null;
|
|
41
|
-
/** @deprecated Use `rates.replyRate.low` and `.high`. Removed in 0.
|
|
41
|
+
/** @deprecated Use `rates.replyRate.low` and `.high`. Removed in 0.6.0. */
|
|
42
42
|
readonly replyRateInterval: Interval | null;
|
|
43
43
|
}
|
|
44
44
|
export interface ReusedCopy extends CopyPiece {
|
|
@@ -49,9 +49,9 @@ export interface BasedRate extends Rate {
|
|
|
49
49
|
readonly basis: RateBasis | null;
|
|
50
50
|
}
|
|
51
51
|
export interface Measured extends BasedRate {
|
|
52
|
-
/** @deprecated Use `of`. Removed in 0.
|
|
52
|
+
/** @deprecated Use `of`. Removed in 0.6.0. */
|
|
53
53
|
readonly trials: number | null;
|
|
54
|
-
/** @deprecated Use `low` and `high`. Removed in 0.
|
|
54
|
+
/** @deprecated Use `low` and `high`. Removed in 0.6.0. */
|
|
55
55
|
readonly interval: Interval | null;
|
|
56
56
|
}
|
|
57
57
|
export declare const measure: (count: number | null, base: Base) => Measured;
|
|
@@ -9,9 +9,9 @@ export interface FunnelVariant {
|
|
|
9
9
|
readonly rates: {
|
|
10
10
|
readonly replyRate: BasedRate;
|
|
11
11
|
};
|
|
12
|
-
/** @deprecated Use `rates.replyRate.rate`. Removed in 0.
|
|
12
|
+
/** @deprecated Use `rates.replyRate.rate`. Removed in 0.6.0. */
|
|
13
13
|
readonly replyRate: number | null;
|
|
14
|
-
/** @deprecated Use `rates.replyRate.low` and `.high`. Removed in 0.
|
|
14
|
+
/** @deprecated Use `rates.replyRate.low` and `.high`. Removed in 0.6.0. */
|
|
15
15
|
readonly replyRateInterval: Interval | null;
|
|
16
16
|
}
|
|
17
17
|
export interface FunnelStep {
|
|
@@ -27,11 +27,11 @@ export interface FunnelStep {
|
|
|
27
27
|
readonly rates: {
|
|
28
28
|
readonly replyRate: BasedRate;
|
|
29
29
|
};
|
|
30
|
-
/** @deprecated Use `rates.replyRate.rate`. Removed in 0.
|
|
30
|
+
/** @deprecated Use `rates.replyRate.rate`. Removed in 0.6.0. */
|
|
31
31
|
readonly replyRate: number | null;
|
|
32
|
-
/** @deprecated Use `rates.replyRate.low` and `.high`. Removed in 0.
|
|
32
|
+
/** @deprecated Use `rates.replyRate.low` and `.high`. Removed in 0.6.0. */
|
|
33
33
|
readonly replyRateInterval: Interval | null;
|
|
34
|
-
/** @deprecated Use `rates.replyRate.basis`. Removed in 0.
|
|
34
|
+
/** @deprecated Use `rates.replyRate.basis`. Removed in 0.6.0. */
|
|
35
35
|
readonly replyRateBasis: RateBasis | null;
|
|
36
36
|
/** This step's replies divided by every reply in the campaign, unattributed ones included. */
|
|
37
37
|
readonly shareOfReplies: number | null;
|
|
@@ -16,9 +16,9 @@ export interface TestedVariant {
|
|
|
16
16
|
/** The 95% Wilson interval of the rate. `null` when the rate is unknown. */
|
|
17
17
|
readonly low: number | null;
|
|
18
18
|
readonly high: number | null;
|
|
19
|
-
/** @deprecated Use `of`. Removed in 0.
|
|
19
|
+
/** @deprecated Use `of`. Removed in 0.6.0. */
|
|
20
20
|
readonly trials: number | null;
|
|
21
|
-
/** @deprecated Use `low` and `high`. Removed in 0.
|
|
21
|
+
/** @deprecated Use `low` and `high`. Removed in 0.6.0. */
|
|
22
22
|
readonly interval: Interval | null;
|
|
23
23
|
/** `false` when the base is under `min_sent` or the rate is unknown; such a variant is not compared. */
|
|
24
24
|
readonly enoughData: boolean;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { Capabilities } from "../internal/capabilities.ts";
|
|
2
|
+
import { OutboundError } from "../internal/errors.ts";
|
|
3
|
+
import type { OutboundApi } from "../internal/outbound/api.ts";
|
|
4
|
+
/**
|
|
5
|
+
* Prices reads on the adapter an insight runs on. Write the insight's cost
|
|
6
|
+
* once with it: it is evaluated at the least and at the most each read and
|
|
7
|
+
* count can be.
|
|
8
|
+
*/
|
|
9
|
+
export interface Price {
|
|
10
|
+
/** What the instance can do, to price the same branches the insight takes. */
|
|
11
|
+
readonly capabilities: Capabilities;
|
|
12
|
+
/** A listing read up to `max` records: one page at the least, every page and its extras at the most. */
|
|
13
|
+
readonly list: (action: string, max: number) => number;
|
|
14
|
+
/**
|
|
15
|
+
* A listing read to its end, such as a lead's timeline or a thread, priced
|
|
16
|
+
* as one page: a thread longer than a page is not foreseen, and the 25%
|
|
17
|
+
* margin of the default cap absorbs the odd one.
|
|
18
|
+
*/
|
|
19
|
+
readonly walk: (action: string) => number;
|
|
20
|
+
/** One lookup, such as `stats` or `campaigns.get`. */
|
|
21
|
+
readonly one: (action: string) => number;
|
|
22
|
+
/** Leads found by an email or a profile, up to `max`: `leads.lookup` where the adapter prices it. */
|
|
23
|
+
readonly lookup: (max: number) => number;
|
|
24
|
+
/**
|
|
25
|
+
* A count only the data decides, up to `max`: 0 at the least, `max` at the
|
|
26
|
+
* most. For example the active campaigns among those read.
|
|
27
|
+
*/
|
|
28
|
+
readonly upTo: (max: number) => number;
|
|
29
|
+
/**
|
|
30
|
+
* The campaigns the insight reads, up to `max`: the number actually found
|
|
31
|
+
* once the listing is read, otherwise 0 at the least and `max` at the most.
|
|
32
|
+
*/
|
|
33
|
+
readonly campaigns: (max: number) => number;
|
|
34
|
+
/**
|
|
35
|
+
* The campaign listing of `readCampaignsIn` for `statuses` states, up to
|
|
36
|
+
* `max` campaigns: one walk per state where the vendor filters by state.
|
|
37
|
+
*/
|
|
38
|
+
readonly campaignsIn: (statuses: number, max: number) => number;
|
|
39
|
+
}
|
|
40
|
+
/** What a run of the insight costs, as a function of its input. */
|
|
41
|
+
export type InsightCost<Input> = (input: Input, price: Price) => number;
|
|
42
|
+
export interface Bounds {
|
|
43
|
+
readonly min: number;
|
|
44
|
+
readonly max: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The least and the most this input can cost on this instance, or `null`
|
|
48
|
+
* when the insight states no cost or the adapter declares none for a read it
|
|
49
|
+
* makes, as a combined instance does.
|
|
50
|
+
*/
|
|
51
|
+
export declare const boundsOf: <Input>(outbound: OutboundApi, cost: InsightCost<Input> | undefined, input: Input, found?: number) => Bounds | null;
|
|
52
|
+
/**
|
|
53
|
+
* The cap an insight runs under when none is set: the most it can cost, a
|
|
54
|
+
* quarter more for retries (each retry is a request too) and 4 on top.
|
|
55
|
+
*/
|
|
56
|
+
export declare const defaultCap: (bounds: Bounds | null) => number;
|
|
57
|
+
/** The cap a run is under, and where it came from, for the message when it stops. */
|
|
58
|
+
export interface CapInEffect {
|
|
59
|
+
readonly cap: number;
|
|
60
|
+
/** `true` when no cap was set and the default applies. */
|
|
61
|
+
readonly isDefault: boolean;
|
|
62
|
+
/** The setting that raises it: `maxRequests` or `maxRequestsPerToolCall`. */
|
|
63
|
+
readonly setting: string;
|
|
64
|
+
}
|
|
65
|
+
/** What made a run stop at its cap, for the tool result built from the error. */
|
|
66
|
+
export interface CapStop extends CapInEffect {
|
|
67
|
+
/** Requests sent before the stop. */
|
|
68
|
+
readonly requests: number;
|
|
69
|
+
/** The input to lower and the value that fits, when one does. */
|
|
70
|
+
readonly lower: Lower | undefined;
|
|
71
|
+
}
|
|
72
|
+
/** What a cap stop of an insight says, or `undefined` for any other error. */
|
|
73
|
+
export declare const capStopOf: (cause: unknown) => CapStop | undefined;
|
|
74
|
+
export declare const capError: (message: string, stop: CapStop, provider: string) => OutboundError;
|
|
75
|
+
/** The error for a run refused before a request it cannot afford. */
|
|
76
|
+
export declare const refusal: (name: string, bounds: Bounds, room: number, stop: CapStop, provider: string) => OutboundError;
|
|
77
|
+
/** The error for a run that reached its cap part way. */
|
|
78
|
+
export declare const stopped: (name: string, stop: CapStop, provider: string) => OutboundError;
|
|
79
|
+
/** An input to lower, and the value to lower it to. */
|
|
80
|
+
export interface Lower {
|
|
81
|
+
readonly input: string;
|
|
82
|
+
readonly to: number;
|
|
83
|
+
/** `true` when even the most a run can cost at that value fits; otherwise only its least does. */
|
|
84
|
+
readonly sure: boolean;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The largest value of `input` under its current one at which a run fits in
|
|
88
|
+
* `room`: where the most it can cost fits, or failing that where its least
|
|
89
|
+
* does. `undefined` when not even one does.
|
|
90
|
+
*/
|
|
91
|
+
export declare const fitting: <Input>(outbound: OutboundApi, cost: InsightCost<Input>, input: Input, name: string, room: number, found?: number) => Lower | undefined;
|
|
@@ -3,6 +3,8 @@ import type { CapabilityKey } from "../internal/capabilities.ts";
|
|
|
3
3
|
import type { Evidence, MetricRow } from "../internal/entities.ts";
|
|
4
4
|
import type { Json } from "../internal/json.ts";
|
|
5
5
|
import type { ListAll, OutboundApi, PageResult, StatsResult, WithMeta } from "../internal/outbound/api.ts";
|
|
6
|
+
import type { InsightCost } from "./cost.ts";
|
|
7
|
+
import type { CapOptions } from "./run-cap.ts";
|
|
6
8
|
export interface InsightMeta {
|
|
7
9
|
/** `exact` only when every read behind the answer was exact. */
|
|
8
10
|
readonly evidence: Evidence;
|
|
@@ -80,8 +82,13 @@ export interface InsightContext {
|
|
|
80
82
|
readonly note: (text: string) => void;
|
|
81
83
|
/** Marks the answer as covering part of the data, with the reason as a note. */
|
|
82
84
|
readonly partial: (reason: string) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Says how many campaigns the insight found, once its campaign listing is
|
|
87
|
+
* read. A run whose least cost for that many is over its cap stops there.
|
|
88
|
+
*/
|
|
89
|
+
readonly campaignsFound: (count: number) => void;
|
|
83
90
|
}
|
|
84
|
-
export interface RunOptions {
|
|
91
|
+
export interface RunOptions extends CapOptions {
|
|
85
92
|
/** Replaces the clock. Meant for tests. */
|
|
86
93
|
readonly now?: number | undefined;
|
|
87
94
|
}
|
|
@@ -103,6 +110,10 @@ export interface InsightEntry {
|
|
|
103
110
|
readonly maskedOut?: MaskedOut | undefined;
|
|
104
111
|
/** What the adapter does not report that the insight needs, beyond a capability. */
|
|
105
112
|
readonly lacks?: Lacks | undefined;
|
|
113
|
+
/** What a run costs, for the default cap and the check before the first request. */
|
|
114
|
+
readonly cost?: InsightCost<never> | undefined;
|
|
115
|
+
/** The input that makes the insight cheaper when lowered, named in cap messages. */
|
|
116
|
+
readonly scales?: string | undefined;
|
|
106
117
|
/** Checks the input and the capabilities, then runs the insight. */
|
|
107
118
|
readonly execute: (outbound: OutboundApi, input?: Json, options?: RunOptions) => Promise<InsightResult<Json>>;
|
|
108
119
|
}
|
|
@@ -134,12 +145,22 @@ export interface InsightSpec<Key extends string, Input, Data, Given = Input> {
|
|
|
134
145
|
* request, and an insight it refuses is not offered as a tool.
|
|
135
146
|
*/
|
|
136
147
|
readonly lacks?: Lacks | undefined;
|
|
148
|
+
/**
|
|
149
|
+
* What a run costs in vendor requests, written once with `price`. It is
|
|
150
|
+
* worked out at the least and the most every read can cost: the most sets
|
|
151
|
+
* the default cap, and a run whose least is over its cap is refused before
|
|
152
|
+
* the first request. Without it the insight has no default cap.
|
|
153
|
+
*/
|
|
154
|
+
readonly cost?: InsightCost<Input> | undefined;
|
|
155
|
+
/** The input that makes a run cheaper when lowered, such as `max_campaigns`. */
|
|
156
|
+
readonly scales?: (keyof Input & string) | undefined;
|
|
137
157
|
readonly run: (context: InsightContext, input: Input) => Promise<Data>;
|
|
138
158
|
}
|
|
139
159
|
export interface InsightDefinition<Key extends string = string, Input = never, Data = Json, Given = Input> extends InsightEntry {
|
|
140
160
|
readonly key: Key;
|
|
141
161
|
readonly inputSchema: ZodObject & ZodType<Input, Given>;
|
|
142
162
|
readonly run: (context: InsightContext, input: Input) => Promise<Data>;
|
|
163
|
+
readonly cost?: InsightCost<Input> | undefined;
|
|
143
164
|
/** Never set. It carries the caller's input type to `outbound.insights`. */
|
|
144
165
|
readonly given?: Given;
|
|
145
166
|
}
|
package/dist/insights/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { insights, listInsights, runInsightByName } from "./plugin.ts";
|
|
2
|
-
export type { Insights, InsightsExtension } from "./plugin.ts";
|
|
1
|
+
export { insightCost, insights, listInsights, runInsightByName, } from "./plugin.ts";
|
|
2
|
+
export type { InsightCostEstimate, Insights, InsightsExtension, } from "./plugin.ts";
|
|
3
|
+
export type { InsightCost, Price } from "./cost.ts";
|
|
3
4
|
export type { InsightInputs } from "./inputs.generated.ts";
|
|
4
|
-
export { insightTools } from "./tools.ts";
|
|
5
|
+
export { INSIGHT_TOOL_CEILING, insightTools } from "./tools.ts";
|
|
5
6
|
export type { InsightToolsOptions } from "./tools.ts";
|
|
6
7
|
export { defineInsight, runInsight } from "./define.ts";
|
|
7
8
|
export type { Cap, InsightContext, InsightDefinition, InsightMeta, InsightResult, RunOptions, } from "./define.ts";
|