@linnlabs/linnkit 0.10.0 → 0.21.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/CHANGELOG.md +156 -1
- package/dist/{agent-invocation-BHcNfrBV.d.cts → agent-invocation-CAlm9qOw.d.cts} +1 -1
- package/dist/{agent-invocation-BznDaXDs.d.ts → agent-invocation-DKoEDLkl.d.ts} +1 -1
- package/dist/{ai-engine.types-vZRnQcJa.d.ts → ai-engine.types-CeLoM624.d.cts} +9 -1
- package/dist/{ai-engine.types-BpeU_XQG.d.cts → ai-engine.types-LqmnfR2W.d.ts} +9 -1
- package/dist/{audit-CtcfART1.d.ts → audit-BuWHoMEr.d.ts} +4 -2
- package/dist/{audit-LeOrm2hX.d.cts → audit-DnzNQzwq.d.cts} +4 -2
- package/dist/cli.cjs +565 -194
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +565 -194
- package/dist/cli.js.map +1 -1
- package/dist/context-manager.cjs +590 -26
- package/dist/context-manager.cjs.map +1 -1
- package/dist/context-manager.d.cts +84 -7
- package/dist/context-manager.d.ts +84 -7
- package/dist/context-manager.js +590 -26
- package/dist/context-manager.js.map +1 -1
- package/dist/{context-trace-BHKDS-eq.d.cts → context-trace-DrtvKac4.d.cts} +36 -3
- package/dist/{context-trace-CHbqHmyE.d.ts → context-trace-WV1HAZeB.d.ts} +36 -3
- package/dist/contracts.cjs +222 -1
- package/dist/contracts.cjs.map +1 -1
- package/dist/contracts.d.cts +5 -3
- package/dist/contracts.d.ts +5 -3
- package/dist/contracts.js +202 -2
- package/dist/contracts.js.map +1 -1
- package/dist/{defaultGraphExecutor-C2E59v_R.d.cts → defaultGraphExecutor-L1ri3oij.d.cts} +35 -7
- package/dist/{defaultGraphExecutor-B29_qTHy.d.ts → defaultGraphExecutor-QzzdudLQ.d.ts} +35 -7
- package/dist/{index-BAaUP9yU.d.cts → index-BeQO0rx2.d.cts} +328 -263
- package/dist/{index-Cvr23YCl.d.cts → index-CDofGr_4.d.ts} +24 -6
- package/dist/{index-CKQzzZ5Y.d.cts → index-Crl5E4eF.d.cts} +26 -3
- package/dist/{index-C0DAjsdX.d.ts → index-DWGKvssS.d.ts} +2 -2
- package/dist/{index-D0mKxTR5.d.ts → index-X5lYU1Lj.d.ts} +26 -3
- package/dist/{index-DDzuSb0n.d.ts → index-uCNCpJBg.d.cts} +24 -6
- package/dist/{index-BaVpVNi2.d.ts → index-wOZD-p2-.d.ts} +328 -263
- package/dist/{index-BnYCS8Zg.d.cts → index-wXVAHZ0D.d.cts} +2 -2
- package/dist/index.cjs +893 -312
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -14
- package/dist/index.d.ts +17 -14
- package/dist/index.js +893 -312
- package/dist/index.js.map +1 -1
- package/dist/{messages-XthmnHZ3.d.cts → messages-Br5SiLD3.d.cts} +706 -1
- package/dist/{messages-XthmnHZ3.d.ts → messages-Br5SiLD3.d.ts} +706 -1
- package/dist/{ports-s-tSp3sB.d.cts → ports-Dugizzje.d.cts} +4 -0
- package/dist/{ports-DpPTFhSd.d.ts → ports-fhp84x_C.d.ts} +4 -0
- package/dist/ports.d.cts +8 -5
- package/dist/ports.d.ts +8 -5
- package/dist/quickstart.cjs +564 -193
- package/dist/quickstart.cjs.map +1 -1
- package/dist/quickstart.d.cts +9 -8
- package/dist/quickstart.d.ts +9 -8
- package/dist/quickstart.js +564 -193
- package/dist/quickstart.js.map +1 -1
- package/dist/{runAgent-C6F-399C.d.ts → runAgent-BmMSju8I.d.ts} +4 -4
- package/dist/{runAgent-ilEj66Ik.d.cts → runAgent-CKgcRSRH.d.cts} +4 -4
- package/dist/{runHandle-BNOqS-Bl.d.cts → runHandle-DH4VmQx6.d.cts} +4 -2
- package/dist/{runHandle-BdLXOFqF.d.ts → runHandle-o3p06Nva.d.ts} +4 -2
- package/dist/runtime-kernel/events.cjs +201 -1
- package/dist/runtime-kernel/events.cjs.map +1 -1
- package/dist/runtime-kernel/events.d.cts +3 -3
- package/dist/runtime-kernel/events.d.ts +3 -3
- package/dist/runtime-kernel/events.js +201 -1
- package/dist/runtime-kernel/events.js.map +1 -1
- package/dist/runtime-kernel.cjs +824 -264
- package/dist/runtime-kernel.cjs.map +1 -1
- package/dist/runtime-kernel.d.cts +14 -12
- package/dist/runtime-kernel.d.ts +14 -12
- package/dist/runtime-kernel.js +816 -265
- package/dist/runtime-kernel.js.map +1 -1
- package/dist/testkit.cjs +847 -264
- package/dist/testkit.cjs.map +1 -1
- package/dist/testkit.d.cts +14 -12
- package/dist/testkit.d.ts +14 -12
- package/dist/testkit.js +847 -264
- package/dist/testkit.js.map +1 -1
- package/dist/{agentSpec-Du4Iye0q.d.cts → token-accounting-CwpSPg4y.d.cts} +1265 -1
- package/dist/{agentSpec-Du4Iye0q.d.ts → token-accounting-CwpSPg4y.d.ts} +1265 -1
- package/dist/token-calibration-Cxv6dDYF.d.cts +327 -0
- package/dist/token-calibration-Cxv6dDYF.d.ts +327 -0
- package/dist/token-counter-CFfP8PQb.d.cts +26 -0
- package/dist/token-counter-SFyyTeaG.d.ts +26 -0
- package/dist/token-usage-CqwT7-5K.d.cts +133 -0
- package/dist/token-usage-CqwT7-5K.d.ts +133 -0
- package/dist/{tokenizer-DFL4I7-I.d.ts → tokenizer-BFJNCHFX.d.ts} +1 -1
- package/dist/{tokenizer-DH_JXv-H.d.cts → tokenizer-DoGsBE3A.d.cts} +1 -1
- package/docs/README.md +1 -1
- package/docs/integration/README.md +2 -2
- package/docs/integration/agent-registration-guide.md +2 -0
- package/docs/integration/context-engineering.md +53 -1
- package/docs/integration/context-fences.md +12 -0
- package/package.json +2 -2
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 上下文预算校准样本。
|
|
5
|
+
*
|
|
6
|
+
* 中文备注:sample 只描述“一次实际发送前的本地估算”和“响应后的真实输入占用”。
|
|
7
|
+
* 是否采纳 actual、是否匹配 route 由 context-manager 的纯函数判断,避免 host 注入时夹带策略。
|
|
8
|
+
*/
|
|
9
|
+
declare const TokenUsageCalibrationSample: z.ZodObject<{
|
|
10
|
+
route: z.ZodObject<{
|
|
11
|
+
providerId: z.ZodString;
|
|
12
|
+
baseURL: z.ZodOptional<z.ZodString>;
|
|
13
|
+
modelId: z.ZodString;
|
|
14
|
+
providerModelId: z.ZodOptional<z.ZodString>;
|
|
15
|
+
capabilities: z.ZodOptional<z.ZodObject<{
|
|
16
|
+
supportsRemoteTokenCount: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
+
supportsResponseUsage: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
+
supportsImageInput: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
supportsCachedInputBilling: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
+
supportsReasoningTokens: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
23
|
+
supportsResponseUsage?: boolean | undefined;
|
|
24
|
+
supportsImageInput?: boolean | undefined;
|
|
25
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
26
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
29
|
+
supportsResponseUsage?: boolean | undefined;
|
|
30
|
+
supportsImageInput?: boolean | undefined;
|
|
31
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
32
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
33
|
+
}>>;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
modelId: string;
|
|
36
|
+
providerId: string;
|
|
37
|
+
capabilities?: {
|
|
38
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
39
|
+
supportsResponseUsage?: boolean | undefined;
|
|
40
|
+
supportsImageInput?: boolean | undefined;
|
|
41
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
42
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
43
|
+
} | undefined;
|
|
44
|
+
baseURL?: string | undefined;
|
|
45
|
+
providerModelId?: string | undefined;
|
|
46
|
+
}, {
|
|
47
|
+
modelId: string;
|
|
48
|
+
providerId: string;
|
|
49
|
+
capabilities?: {
|
|
50
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
51
|
+
supportsResponseUsage?: boolean | undefined;
|
|
52
|
+
supportsImageInput?: boolean | undefined;
|
|
53
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
54
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
55
|
+
} | undefined;
|
|
56
|
+
baseURL?: string | undefined;
|
|
57
|
+
providerModelId?: string | undefined;
|
|
58
|
+
}>;
|
|
59
|
+
localEstimateTokens: z.ZodNumber;
|
|
60
|
+
actualInputTokens: z.ZodNumber;
|
|
61
|
+
source: z.ZodEnum<["provider-response-usage", "host-supplied", "test-fixture"]>;
|
|
62
|
+
confidence: z.ZodLiteral<"actual">;
|
|
63
|
+
observedAt: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
65
|
+
ledgerEntryId: z.ZodOptional<z.ZodString>;
|
|
66
|
+
}, "strip", z.ZodTypeAny, {
|
|
67
|
+
source: "provider-response-usage" | "host-supplied" | "test-fixture";
|
|
68
|
+
confidence: "actual";
|
|
69
|
+
route: {
|
|
70
|
+
modelId: string;
|
|
71
|
+
providerId: string;
|
|
72
|
+
capabilities?: {
|
|
73
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
74
|
+
supportsResponseUsage?: boolean | undefined;
|
|
75
|
+
supportsImageInput?: boolean | undefined;
|
|
76
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
77
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
78
|
+
} | undefined;
|
|
79
|
+
baseURL?: string | undefined;
|
|
80
|
+
providerModelId?: string | undefined;
|
|
81
|
+
};
|
|
82
|
+
localEstimateTokens: number;
|
|
83
|
+
actualInputTokens: number;
|
|
84
|
+
runId?: string | undefined;
|
|
85
|
+
observedAt?: number | undefined;
|
|
86
|
+
ledgerEntryId?: string | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
source: "provider-response-usage" | "host-supplied" | "test-fixture";
|
|
89
|
+
confidence: "actual";
|
|
90
|
+
route: {
|
|
91
|
+
modelId: string;
|
|
92
|
+
providerId: string;
|
|
93
|
+
capabilities?: {
|
|
94
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
95
|
+
supportsResponseUsage?: boolean | undefined;
|
|
96
|
+
supportsImageInput?: boolean | undefined;
|
|
97
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
98
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
99
|
+
} | undefined;
|
|
100
|
+
baseURL?: string | undefined;
|
|
101
|
+
providerModelId?: string | undefined;
|
|
102
|
+
};
|
|
103
|
+
localEstimateTokens: number;
|
|
104
|
+
actualInputTokens: number;
|
|
105
|
+
runId?: string | undefined;
|
|
106
|
+
observedAt?: number | undefined;
|
|
107
|
+
ledgerEntryId?: string | undefined;
|
|
108
|
+
}>;
|
|
109
|
+
type TokenUsageCalibrationSample = z.infer<typeof TokenUsageCalibrationSample>;
|
|
110
|
+
declare const TokenUsageCalibrationTrace: z.ZodObject<{
|
|
111
|
+
enabled: z.ZodBoolean;
|
|
112
|
+
applied: z.ZodBoolean;
|
|
113
|
+
route: z.ZodOptional<z.ZodObject<{
|
|
114
|
+
providerId: z.ZodString;
|
|
115
|
+
baseURL: z.ZodOptional<z.ZodString>;
|
|
116
|
+
modelId: z.ZodString;
|
|
117
|
+
providerModelId: z.ZodOptional<z.ZodString>;
|
|
118
|
+
capabilities: z.ZodOptional<z.ZodObject<{
|
|
119
|
+
supportsRemoteTokenCount: z.ZodOptional<z.ZodBoolean>;
|
|
120
|
+
supportsResponseUsage: z.ZodOptional<z.ZodBoolean>;
|
|
121
|
+
supportsImageInput: z.ZodOptional<z.ZodBoolean>;
|
|
122
|
+
supportsCachedInputBilling: z.ZodOptional<z.ZodBoolean>;
|
|
123
|
+
supportsReasoningTokens: z.ZodOptional<z.ZodBoolean>;
|
|
124
|
+
}, "strip", z.ZodTypeAny, {
|
|
125
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
126
|
+
supportsResponseUsage?: boolean | undefined;
|
|
127
|
+
supportsImageInput?: boolean | undefined;
|
|
128
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
129
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
130
|
+
}, {
|
|
131
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
132
|
+
supportsResponseUsage?: boolean | undefined;
|
|
133
|
+
supportsImageInput?: boolean | undefined;
|
|
134
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
135
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
136
|
+
}>>;
|
|
137
|
+
}, "strip", z.ZodTypeAny, {
|
|
138
|
+
modelId: string;
|
|
139
|
+
providerId: string;
|
|
140
|
+
capabilities?: {
|
|
141
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
142
|
+
supportsResponseUsage?: boolean | undefined;
|
|
143
|
+
supportsImageInput?: boolean | undefined;
|
|
144
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
145
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
146
|
+
} | undefined;
|
|
147
|
+
baseURL?: string | undefined;
|
|
148
|
+
providerModelId?: string | undefined;
|
|
149
|
+
}, {
|
|
150
|
+
modelId: string;
|
|
151
|
+
providerId: string;
|
|
152
|
+
capabilities?: {
|
|
153
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
154
|
+
supportsResponseUsage?: boolean | undefined;
|
|
155
|
+
supportsImageInput?: boolean | undefined;
|
|
156
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
157
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
158
|
+
} | undefined;
|
|
159
|
+
baseURL?: string | undefined;
|
|
160
|
+
providerModelId?: string | undefined;
|
|
161
|
+
}>>;
|
|
162
|
+
sampleCount: z.ZodNumber;
|
|
163
|
+
coefficient: z.ZodOptional<z.ZodNumber>;
|
|
164
|
+
minSamples: z.ZodOptional<z.ZodNumber>;
|
|
165
|
+
minCoefficient: z.ZodOptional<z.ZodNumber>;
|
|
166
|
+
maxCoefficient: z.ZodOptional<z.ZodNumber>;
|
|
167
|
+
localEstimateTokens: z.ZodOptional<z.ZodNumber>;
|
|
168
|
+
calibratedEstimateTokens: z.ZodOptional<z.ZodNumber>;
|
|
169
|
+
deltaTokens: z.ZodOptional<z.ZodNumber>;
|
|
170
|
+
sampleLedgerEntryIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
171
|
+
}, "strip", z.ZodTypeAny, {
|
|
172
|
+
enabled: boolean;
|
|
173
|
+
applied: boolean;
|
|
174
|
+
sampleCount: number;
|
|
175
|
+
minSamples?: number | undefined;
|
|
176
|
+
minCoefficient?: number | undefined;
|
|
177
|
+
maxCoefficient?: number | undefined;
|
|
178
|
+
route?: {
|
|
179
|
+
modelId: string;
|
|
180
|
+
providerId: string;
|
|
181
|
+
capabilities?: {
|
|
182
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
183
|
+
supportsResponseUsage?: boolean | undefined;
|
|
184
|
+
supportsImageInput?: boolean | undefined;
|
|
185
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
186
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
187
|
+
} | undefined;
|
|
188
|
+
baseURL?: string | undefined;
|
|
189
|
+
providerModelId?: string | undefined;
|
|
190
|
+
} | undefined;
|
|
191
|
+
localEstimateTokens?: number | undefined;
|
|
192
|
+
coefficient?: number | undefined;
|
|
193
|
+
calibratedEstimateTokens?: number | undefined;
|
|
194
|
+
deltaTokens?: number | undefined;
|
|
195
|
+
sampleLedgerEntryIds?: string[] | undefined;
|
|
196
|
+
}, {
|
|
197
|
+
enabled: boolean;
|
|
198
|
+
applied: boolean;
|
|
199
|
+
sampleCount: number;
|
|
200
|
+
minSamples?: number | undefined;
|
|
201
|
+
minCoefficient?: number | undefined;
|
|
202
|
+
maxCoefficient?: number | undefined;
|
|
203
|
+
route?: {
|
|
204
|
+
modelId: string;
|
|
205
|
+
providerId: string;
|
|
206
|
+
capabilities?: {
|
|
207
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
208
|
+
supportsResponseUsage?: boolean | undefined;
|
|
209
|
+
supportsImageInput?: boolean | undefined;
|
|
210
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
211
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
212
|
+
} | undefined;
|
|
213
|
+
baseURL?: string | undefined;
|
|
214
|
+
providerModelId?: string | undefined;
|
|
215
|
+
} | undefined;
|
|
216
|
+
localEstimateTokens?: number | undefined;
|
|
217
|
+
coefficient?: number | undefined;
|
|
218
|
+
calibratedEstimateTokens?: number | undefined;
|
|
219
|
+
deltaTokens?: number | undefined;
|
|
220
|
+
sampleLedgerEntryIds?: string[] | undefined;
|
|
221
|
+
}>;
|
|
222
|
+
type TokenUsageCalibrationTrace = z.infer<typeof TokenUsageCalibrationTrace>;
|
|
223
|
+
/**
|
|
224
|
+
* 一次 context build 最终发送消息的构建期 token 估算。
|
|
225
|
+
*
|
|
226
|
+
* 中文备注:
|
|
227
|
+
* - localEstimateTokens 是未校准的本地 tokenizer 合计,用于和响应后 actual 输入配对成样本;
|
|
228
|
+
* - calibratedEstimateTokens/finalTokens 是本轮实际参与预算与截断的构建期口径;
|
|
229
|
+
* - 这里不表达 provider preflight count 或响应后 actual usage,避免把不同来源混成一个数字。
|
|
230
|
+
*/
|
|
231
|
+
declare const ContextBuildTokenEstimate: z.ZodObject<{
|
|
232
|
+
route: z.ZodOptional<z.ZodObject<{
|
|
233
|
+
providerId: z.ZodString;
|
|
234
|
+
baseURL: z.ZodOptional<z.ZodString>;
|
|
235
|
+
modelId: z.ZodString;
|
|
236
|
+
providerModelId: z.ZodOptional<z.ZodString>;
|
|
237
|
+
capabilities: z.ZodOptional<z.ZodObject<{
|
|
238
|
+
supportsRemoteTokenCount: z.ZodOptional<z.ZodBoolean>;
|
|
239
|
+
supportsResponseUsage: z.ZodOptional<z.ZodBoolean>;
|
|
240
|
+
supportsImageInput: z.ZodOptional<z.ZodBoolean>;
|
|
241
|
+
supportsCachedInputBilling: z.ZodOptional<z.ZodBoolean>;
|
|
242
|
+
supportsReasoningTokens: z.ZodOptional<z.ZodBoolean>;
|
|
243
|
+
}, "strip", z.ZodTypeAny, {
|
|
244
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
245
|
+
supportsResponseUsage?: boolean | undefined;
|
|
246
|
+
supportsImageInput?: boolean | undefined;
|
|
247
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
248
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
249
|
+
}, {
|
|
250
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
251
|
+
supportsResponseUsage?: boolean | undefined;
|
|
252
|
+
supportsImageInput?: boolean | undefined;
|
|
253
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
254
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
255
|
+
}>>;
|
|
256
|
+
}, "strip", z.ZodTypeAny, {
|
|
257
|
+
modelId: string;
|
|
258
|
+
providerId: string;
|
|
259
|
+
capabilities?: {
|
|
260
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
261
|
+
supportsResponseUsage?: boolean | undefined;
|
|
262
|
+
supportsImageInput?: boolean | undefined;
|
|
263
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
264
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
265
|
+
} | undefined;
|
|
266
|
+
baseURL?: string | undefined;
|
|
267
|
+
providerModelId?: string | undefined;
|
|
268
|
+
}, {
|
|
269
|
+
modelId: string;
|
|
270
|
+
providerId: string;
|
|
271
|
+
capabilities?: {
|
|
272
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
273
|
+
supportsResponseUsage?: boolean | undefined;
|
|
274
|
+
supportsImageInput?: boolean | undefined;
|
|
275
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
276
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
277
|
+
} | undefined;
|
|
278
|
+
baseURL?: string | undefined;
|
|
279
|
+
providerModelId?: string | undefined;
|
|
280
|
+
}>>;
|
|
281
|
+
localEstimateTokens: z.ZodNumber;
|
|
282
|
+
calibratedEstimateTokens: z.ZodNumber;
|
|
283
|
+
finalTokens: z.ZodNumber;
|
|
284
|
+
source: z.ZodLiteral<"local-estimate">;
|
|
285
|
+
confidence: z.ZodLiteral<"estimate">;
|
|
286
|
+
}, "strip", z.ZodTypeAny, {
|
|
287
|
+
source: "local-estimate";
|
|
288
|
+
confidence: "estimate";
|
|
289
|
+
localEstimateTokens: number;
|
|
290
|
+
calibratedEstimateTokens: number;
|
|
291
|
+
finalTokens: number;
|
|
292
|
+
route?: {
|
|
293
|
+
modelId: string;
|
|
294
|
+
providerId: string;
|
|
295
|
+
capabilities?: {
|
|
296
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
297
|
+
supportsResponseUsage?: boolean | undefined;
|
|
298
|
+
supportsImageInput?: boolean | undefined;
|
|
299
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
300
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
301
|
+
} | undefined;
|
|
302
|
+
baseURL?: string | undefined;
|
|
303
|
+
providerModelId?: string | undefined;
|
|
304
|
+
} | undefined;
|
|
305
|
+
}, {
|
|
306
|
+
source: "local-estimate";
|
|
307
|
+
confidence: "estimate";
|
|
308
|
+
localEstimateTokens: number;
|
|
309
|
+
calibratedEstimateTokens: number;
|
|
310
|
+
finalTokens: number;
|
|
311
|
+
route?: {
|
|
312
|
+
modelId: string;
|
|
313
|
+
providerId: string;
|
|
314
|
+
capabilities?: {
|
|
315
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
316
|
+
supportsResponseUsage?: boolean | undefined;
|
|
317
|
+
supportsImageInput?: boolean | undefined;
|
|
318
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
319
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
320
|
+
} | undefined;
|
|
321
|
+
baseURL?: string | undefined;
|
|
322
|
+
providerModelId?: string | undefined;
|
|
323
|
+
} | undefined;
|
|
324
|
+
}>;
|
|
325
|
+
type ContextBuildTokenEstimate = z.infer<typeof ContextBuildTokenEstimate>;
|
|
326
|
+
|
|
327
|
+
export { ContextBuildTokenEstimate as C, TokenUsageCalibrationTrace as T, TokenUsageCalibrationSample as a };
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 上下文预算校准样本。
|
|
5
|
+
*
|
|
6
|
+
* 中文备注:sample 只描述“一次实际发送前的本地估算”和“响应后的真实输入占用”。
|
|
7
|
+
* 是否采纳 actual、是否匹配 route 由 context-manager 的纯函数判断,避免 host 注入时夹带策略。
|
|
8
|
+
*/
|
|
9
|
+
declare const TokenUsageCalibrationSample: z.ZodObject<{
|
|
10
|
+
route: z.ZodObject<{
|
|
11
|
+
providerId: z.ZodString;
|
|
12
|
+
baseURL: z.ZodOptional<z.ZodString>;
|
|
13
|
+
modelId: z.ZodString;
|
|
14
|
+
providerModelId: z.ZodOptional<z.ZodString>;
|
|
15
|
+
capabilities: z.ZodOptional<z.ZodObject<{
|
|
16
|
+
supportsRemoteTokenCount: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
+
supportsResponseUsage: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
+
supportsImageInput: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
supportsCachedInputBilling: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
+
supportsReasoningTokens: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
23
|
+
supportsResponseUsage?: boolean | undefined;
|
|
24
|
+
supportsImageInput?: boolean | undefined;
|
|
25
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
26
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
29
|
+
supportsResponseUsage?: boolean | undefined;
|
|
30
|
+
supportsImageInput?: boolean | undefined;
|
|
31
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
32
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
33
|
+
}>>;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
modelId: string;
|
|
36
|
+
providerId: string;
|
|
37
|
+
capabilities?: {
|
|
38
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
39
|
+
supportsResponseUsage?: boolean | undefined;
|
|
40
|
+
supportsImageInput?: boolean | undefined;
|
|
41
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
42
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
43
|
+
} | undefined;
|
|
44
|
+
baseURL?: string | undefined;
|
|
45
|
+
providerModelId?: string | undefined;
|
|
46
|
+
}, {
|
|
47
|
+
modelId: string;
|
|
48
|
+
providerId: string;
|
|
49
|
+
capabilities?: {
|
|
50
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
51
|
+
supportsResponseUsage?: boolean | undefined;
|
|
52
|
+
supportsImageInput?: boolean | undefined;
|
|
53
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
54
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
55
|
+
} | undefined;
|
|
56
|
+
baseURL?: string | undefined;
|
|
57
|
+
providerModelId?: string | undefined;
|
|
58
|
+
}>;
|
|
59
|
+
localEstimateTokens: z.ZodNumber;
|
|
60
|
+
actualInputTokens: z.ZodNumber;
|
|
61
|
+
source: z.ZodEnum<["provider-response-usage", "host-supplied", "test-fixture"]>;
|
|
62
|
+
confidence: z.ZodLiteral<"actual">;
|
|
63
|
+
observedAt: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
65
|
+
ledgerEntryId: z.ZodOptional<z.ZodString>;
|
|
66
|
+
}, "strip", z.ZodTypeAny, {
|
|
67
|
+
source: "provider-response-usage" | "host-supplied" | "test-fixture";
|
|
68
|
+
confidence: "actual";
|
|
69
|
+
route: {
|
|
70
|
+
modelId: string;
|
|
71
|
+
providerId: string;
|
|
72
|
+
capabilities?: {
|
|
73
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
74
|
+
supportsResponseUsage?: boolean | undefined;
|
|
75
|
+
supportsImageInput?: boolean | undefined;
|
|
76
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
77
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
78
|
+
} | undefined;
|
|
79
|
+
baseURL?: string | undefined;
|
|
80
|
+
providerModelId?: string | undefined;
|
|
81
|
+
};
|
|
82
|
+
localEstimateTokens: number;
|
|
83
|
+
actualInputTokens: number;
|
|
84
|
+
runId?: string | undefined;
|
|
85
|
+
observedAt?: number | undefined;
|
|
86
|
+
ledgerEntryId?: string | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
source: "provider-response-usage" | "host-supplied" | "test-fixture";
|
|
89
|
+
confidence: "actual";
|
|
90
|
+
route: {
|
|
91
|
+
modelId: string;
|
|
92
|
+
providerId: string;
|
|
93
|
+
capabilities?: {
|
|
94
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
95
|
+
supportsResponseUsage?: boolean | undefined;
|
|
96
|
+
supportsImageInput?: boolean | undefined;
|
|
97
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
98
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
99
|
+
} | undefined;
|
|
100
|
+
baseURL?: string | undefined;
|
|
101
|
+
providerModelId?: string | undefined;
|
|
102
|
+
};
|
|
103
|
+
localEstimateTokens: number;
|
|
104
|
+
actualInputTokens: number;
|
|
105
|
+
runId?: string | undefined;
|
|
106
|
+
observedAt?: number | undefined;
|
|
107
|
+
ledgerEntryId?: string | undefined;
|
|
108
|
+
}>;
|
|
109
|
+
type TokenUsageCalibrationSample = z.infer<typeof TokenUsageCalibrationSample>;
|
|
110
|
+
declare const TokenUsageCalibrationTrace: z.ZodObject<{
|
|
111
|
+
enabled: z.ZodBoolean;
|
|
112
|
+
applied: z.ZodBoolean;
|
|
113
|
+
route: z.ZodOptional<z.ZodObject<{
|
|
114
|
+
providerId: z.ZodString;
|
|
115
|
+
baseURL: z.ZodOptional<z.ZodString>;
|
|
116
|
+
modelId: z.ZodString;
|
|
117
|
+
providerModelId: z.ZodOptional<z.ZodString>;
|
|
118
|
+
capabilities: z.ZodOptional<z.ZodObject<{
|
|
119
|
+
supportsRemoteTokenCount: z.ZodOptional<z.ZodBoolean>;
|
|
120
|
+
supportsResponseUsage: z.ZodOptional<z.ZodBoolean>;
|
|
121
|
+
supportsImageInput: z.ZodOptional<z.ZodBoolean>;
|
|
122
|
+
supportsCachedInputBilling: z.ZodOptional<z.ZodBoolean>;
|
|
123
|
+
supportsReasoningTokens: z.ZodOptional<z.ZodBoolean>;
|
|
124
|
+
}, "strip", z.ZodTypeAny, {
|
|
125
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
126
|
+
supportsResponseUsage?: boolean | undefined;
|
|
127
|
+
supportsImageInput?: boolean | undefined;
|
|
128
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
129
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
130
|
+
}, {
|
|
131
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
132
|
+
supportsResponseUsage?: boolean | undefined;
|
|
133
|
+
supportsImageInput?: boolean | undefined;
|
|
134
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
135
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
136
|
+
}>>;
|
|
137
|
+
}, "strip", z.ZodTypeAny, {
|
|
138
|
+
modelId: string;
|
|
139
|
+
providerId: string;
|
|
140
|
+
capabilities?: {
|
|
141
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
142
|
+
supportsResponseUsage?: boolean | undefined;
|
|
143
|
+
supportsImageInput?: boolean | undefined;
|
|
144
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
145
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
146
|
+
} | undefined;
|
|
147
|
+
baseURL?: string | undefined;
|
|
148
|
+
providerModelId?: string | undefined;
|
|
149
|
+
}, {
|
|
150
|
+
modelId: string;
|
|
151
|
+
providerId: string;
|
|
152
|
+
capabilities?: {
|
|
153
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
154
|
+
supportsResponseUsage?: boolean | undefined;
|
|
155
|
+
supportsImageInput?: boolean | undefined;
|
|
156
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
157
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
158
|
+
} | undefined;
|
|
159
|
+
baseURL?: string | undefined;
|
|
160
|
+
providerModelId?: string | undefined;
|
|
161
|
+
}>>;
|
|
162
|
+
sampleCount: z.ZodNumber;
|
|
163
|
+
coefficient: z.ZodOptional<z.ZodNumber>;
|
|
164
|
+
minSamples: z.ZodOptional<z.ZodNumber>;
|
|
165
|
+
minCoefficient: z.ZodOptional<z.ZodNumber>;
|
|
166
|
+
maxCoefficient: z.ZodOptional<z.ZodNumber>;
|
|
167
|
+
localEstimateTokens: z.ZodOptional<z.ZodNumber>;
|
|
168
|
+
calibratedEstimateTokens: z.ZodOptional<z.ZodNumber>;
|
|
169
|
+
deltaTokens: z.ZodOptional<z.ZodNumber>;
|
|
170
|
+
sampleLedgerEntryIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
171
|
+
}, "strip", z.ZodTypeAny, {
|
|
172
|
+
enabled: boolean;
|
|
173
|
+
applied: boolean;
|
|
174
|
+
sampleCount: number;
|
|
175
|
+
minSamples?: number | undefined;
|
|
176
|
+
minCoefficient?: number | undefined;
|
|
177
|
+
maxCoefficient?: number | undefined;
|
|
178
|
+
route?: {
|
|
179
|
+
modelId: string;
|
|
180
|
+
providerId: string;
|
|
181
|
+
capabilities?: {
|
|
182
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
183
|
+
supportsResponseUsage?: boolean | undefined;
|
|
184
|
+
supportsImageInput?: boolean | undefined;
|
|
185
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
186
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
187
|
+
} | undefined;
|
|
188
|
+
baseURL?: string | undefined;
|
|
189
|
+
providerModelId?: string | undefined;
|
|
190
|
+
} | undefined;
|
|
191
|
+
localEstimateTokens?: number | undefined;
|
|
192
|
+
coefficient?: number | undefined;
|
|
193
|
+
calibratedEstimateTokens?: number | undefined;
|
|
194
|
+
deltaTokens?: number | undefined;
|
|
195
|
+
sampleLedgerEntryIds?: string[] | undefined;
|
|
196
|
+
}, {
|
|
197
|
+
enabled: boolean;
|
|
198
|
+
applied: boolean;
|
|
199
|
+
sampleCount: number;
|
|
200
|
+
minSamples?: number | undefined;
|
|
201
|
+
minCoefficient?: number | undefined;
|
|
202
|
+
maxCoefficient?: number | undefined;
|
|
203
|
+
route?: {
|
|
204
|
+
modelId: string;
|
|
205
|
+
providerId: string;
|
|
206
|
+
capabilities?: {
|
|
207
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
208
|
+
supportsResponseUsage?: boolean | undefined;
|
|
209
|
+
supportsImageInput?: boolean | undefined;
|
|
210
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
211
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
212
|
+
} | undefined;
|
|
213
|
+
baseURL?: string | undefined;
|
|
214
|
+
providerModelId?: string | undefined;
|
|
215
|
+
} | undefined;
|
|
216
|
+
localEstimateTokens?: number | undefined;
|
|
217
|
+
coefficient?: number | undefined;
|
|
218
|
+
calibratedEstimateTokens?: number | undefined;
|
|
219
|
+
deltaTokens?: number | undefined;
|
|
220
|
+
sampleLedgerEntryIds?: string[] | undefined;
|
|
221
|
+
}>;
|
|
222
|
+
type TokenUsageCalibrationTrace = z.infer<typeof TokenUsageCalibrationTrace>;
|
|
223
|
+
/**
|
|
224
|
+
* 一次 context build 最终发送消息的构建期 token 估算。
|
|
225
|
+
*
|
|
226
|
+
* 中文备注:
|
|
227
|
+
* - localEstimateTokens 是未校准的本地 tokenizer 合计,用于和响应后 actual 输入配对成样本;
|
|
228
|
+
* - calibratedEstimateTokens/finalTokens 是本轮实际参与预算与截断的构建期口径;
|
|
229
|
+
* - 这里不表达 provider preflight count 或响应后 actual usage,避免把不同来源混成一个数字。
|
|
230
|
+
*/
|
|
231
|
+
declare const ContextBuildTokenEstimate: z.ZodObject<{
|
|
232
|
+
route: z.ZodOptional<z.ZodObject<{
|
|
233
|
+
providerId: z.ZodString;
|
|
234
|
+
baseURL: z.ZodOptional<z.ZodString>;
|
|
235
|
+
modelId: z.ZodString;
|
|
236
|
+
providerModelId: z.ZodOptional<z.ZodString>;
|
|
237
|
+
capabilities: z.ZodOptional<z.ZodObject<{
|
|
238
|
+
supportsRemoteTokenCount: z.ZodOptional<z.ZodBoolean>;
|
|
239
|
+
supportsResponseUsage: z.ZodOptional<z.ZodBoolean>;
|
|
240
|
+
supportsImageInput: z.ZodOptional<z.ZodBoolean>;
|
|
241
|
+
supportsCachedInputBilling: z.ZodOptional<z.ZodBoolean>;
|
|
242
|
+
supportsReasoningTokens: z.ZodOptional<z.ZodBoolean>;
|
|
243
|
+
}, "strip", z.ZodTypeAny, {
|
|
244
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
245
|
+
supportsResponseUsage?: boolean | undefined;
|
|
246
|
+
supportsImageInput?: boolean | undefined;
|
|
247
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
248
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
249
|
+
}, {
|
|
250
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
251
|
+
supportsResponseUsage?: boolean | undefined;
|
|
252
|
+
supportsImageInput?: boolean | undefined;
|
|
253
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
254
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
255
|
+
}>>;
|
|
256
|
+
}, "strip", z.ZodTypeAny, {
|
|
257
|
+
modelId: string;
|
|
258
|
+
providerId: string;
|
|
259
|
+
capabilities?: {
|
|
260
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
261
|
+
supportsResponseUsage?: boolean | undefined;
|
|
262
|
+
supportsImageInput?: boolean | undefined;
|
|
263
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
264
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
265
|
+
} | undefined;
|
|
266
|
+
baseURL?: string | undefined;
|
|
267
|
+
providerModelId?: string | undefined;
|
|
268
|
+
}, {
|
|
269
|
+
modelId: string;
|
|
270
|
+
providerId: string;
|
|
271
|
+
capabilities?: {
|
|
272
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
273
|
+
supportsResponseUsage?: boolean | undefined;
|
|
274
|
+
supportsImageInput?: boolean | undefined;
|
|
275
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
276
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
277
|
+
} | undefined;
|
|
278
|
+
baseURL?: string | undefined;
|
|
279
|
+
providerModelId?: string | undefined;
|
|
280
|
+
}>>;
|
|
281
|
+
localEstimateTokens: z.ZodNumber;
|
|
282
|
+
calibratedEstimateTokens: z.ZodNumber;
|
|
283
|
+
finalTokens: z.ZodNumber;
|
|
284
|
+
source: z.ZodLiteral<"local-estimate">;
|
|
285
|
+
confidence: z.ZodLiteral<"estimate">;
|
|
286
|
+
}, "strip", z.ZodTypeAny, {
|
|
287
|
+
source: "local-estimate";
|
|
288
|
+
confidence: "estimate";
|
|
289
|
+
localEstimateTokens: number;
|
|
290
|
+
calibratedEstimateTokens: number;
|
|
291
|
+
finalTokens: number;
|
|
292
|
+
route?: {
|
|
293
|
+
modelId: string;
|
|
294
|
+
providerId: string;
|
|
295
|
+
capabilities?: {
|
|
296
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
297
|
+
supportsResponseUsage?: boolean | undefined;
|
|
298
|
+
supportsImageInput?: boolean | undefined;
|
|
299
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
300
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
301
|
+
} | undefined;
|
|
302
|
+
baseURL?: string | undefined;
|
|
303
|
+
providerModelId?: string | undefined;
|
|
304
|
+
} | undefined;
|
|
305
|
+
}, {
|
|
306
|
+
source: "local-estimate";
|
|
307
|
+
confidence: "estimate";
|
|
308
|
+
localEstimateTokens: number;
|
|
309
|
+
calibratedEstimateTokens: number;
|
|
310
|
+
finalTokens: number;
|
|
311
|
+
route?: {
|
|
312
|
+
modelId: string;
|
|
313
|
+
providerId: string;
|
|
314
|
+
capabilities?: {
|
|
315
|
+
supportsRemoteTokenCount?: boolean | undefined;
|
|
316
|
+
supportsResponseUsage?: boolean | undefined;
|
|
317
|
+
supportsImageInput?: boolean | undefined;
|
|
318
|
+
supportsCachedInputBilling?: boolean | undefined;
|
|
319
|
+
supportsReasoningTokens?: boolean | undefined;
|
|
320
|
+
} | undefined;
|
|
321
|
+
baseURL?: string | undefined;
|
|
322
|
+
providerModelId?: string | undefined;
|
|
323
|
+
} | undefined;
|
|
324
|
+
}>;
|
|
325
|
+
type ContextBuildTokenEstimate = z.infer<typeof ContextBuildTokenEstimate>;
|
|
326
|
+
|
|
327
|
+
export { ContextBuildTokenEstimate as C, TokenUsageCalibrationTrace as T, TokenUsageCalibrationSample as a };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { T as TokenRoute, b as TokenCountSource, a as TokenCountConfidence } from './token-usage-CqwT7-5K.cjs';
|
|
2
|
+
import { a as LlmRequestMessage } from './ai-engine.types-CeLoM624.cjs';
|
|
3
|
+
|
|
4
|
+
interface TokenCountResult {
|
|
5
|
+
inputTokens: number;
|
|
6
|
+
imageInputTokens?: number;
|
|
7
|
+
toolSchemaTokens?: number;
|
|
8
|
+
source: Extract<TokenCountSource, 'provider-preflight-count' | 'host-supplied' | 'test-fixture'>;
|
|
9
|
+
confidence: Extract<TokenCountConfidence, 'provider-estimate' | 'actual'>;
|
|
10
|
+
raw?: unknown;
|
|
11
|
+
}
|
|
12
|
+
interface TokenCounterPort {
|
|
13
|
+
/**
|
|
14
|
+
* Route-aware 的发送前 token 计数。
|
|
15
|
+
*
|
|
16
|
+
* 中文备注:host 必须按 input.route 调用对应 endpoint;禁止只看 modelId 后绕去“模型官网”。
|
|
17
|
+
*/
|
|
18
|
+
countMessages(input: {
|
|
19
|
+
route: TokenRoute;
|
|
20
|
+
messages: LlmRequestMessage[];
|
|
21
|
+
tools?: unknown;
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
}): Promise<TokenCountResult>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type { TokenCounterPort as T, TokenCountResult as a };
|