dsh-llm-verifier 0.1.16 → 0.1.17
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 +9 -5
- package/lib/{caller-BWwSVNZf.js → caller-D1ZQNsVU.js} +108 -58
- package/lib/caller-D1ZQNsVU.js.map +1 -0
- package/lib/caller.js +1 -1
- package/lib/client.js +93 -27
- package/lib/client.js.map +1 -1
- package/lib/core.js +21 -6
- package/lib/core.js.map +1 -1
- package/lib/index.js +292 -48
- package/lib/index.js.map +1 -1
- package/lib/types/auto.d.ts +18 -0
- package/lib/types/auto.d.ts.map +1 -1
- package/lib/types/auto.js +19 -0
- package/lib/types/auto.js.map +1 -1
- package/lib/types/caller.d.ts.map +1 -1
- package/lib/types/caller.js +64 -35
- package/lib/types/caller.js.map +1 -1
- package/lib/types/client-i18n.d.ts +6 -0
- package/lib/types/client-i18n.d.ts.map +1 -1
- package/lib/types/client-i18n.js +5 -1
- package/lib/types/client-i18n.js.map +1 -1
- package/lib/types/client.d.ts.map +1 -1
- package/lib/types/client.js +55 -21
- package/lib/types/client.js.map +1 -1
- package/lib/types/config.d.ts +2 -0
- package/lib/types/config.d.ts.map +1 -1
- package/lib/types/config.js +6 -5
- package/lib/types/config.js.map +1 -1
- package/lib/types/core.d.ts +9 -0
- package/lib/types/core.d.ts.map +1 -1
- package/lib/types/core.js +20 -5
- package/lib/types/core.js.map +1 -1
- package/lib/types/images.d.ts +8 -0
- package/lib/types/images.d.ts.map +1 -1
- package/lib/types/images.js +26 -1
- package/lib/types/images.js.map +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +97 -18
- package/lib/types/index.js.map +1 -1
- package/lib/types/plan-gate.d.ts.map +1 -1
- package/lib/types/plan-gate.js +6 -0
- package/lib/types/plan-gate.js.map +1 -1
- package/lib/types/router.d.ts +32 -3
- package/lib/types/router.d.ts.map +1 -1
- package/lib/types/router.js +133 -11
- package/lib/types/router.js.map +1 -1
- package/lib/types/session.d.ts.map +1 -1
- package/lib/types/session.js +10 -1
- package/lib/types/session.js.map +1 -1
- package/lib/types/team-gate.d.ts.map +1 -1
- package/lib/types/team-gate.js +4 -0
- package/lib/types/team-gate.js.map +1 -1
- package/lib/types/top-logprobs.d.ts +11 -1
- package/lib/types/top-logprobs.d.ts.map +1 -1
- package/lib/types/top-logprobs.js +34 -5
- package/lib/types/top-logprobs.js.map +1 -1
- package/package.json +1 -1
- package/src/auto.test.ts +9 -1
- package/src/auto.ts +20 -0
- package/src/caller.test.ts +23 -0
- package/src/caller.ts +61 -32
- package/src/client-i18n.ts +5 -1
- package/src/client.tsx +64 -30
- package/src/config.ts +8 -5
- package/src/core.ts +21 -5
- package/src/images.test.ts +25 -0
- package/src/images.ts +22 -1
- package/src/index.ts +83 -16
- package/src/parity.test.ts +4 -1
- package/src/plan-gate.ts +6 -0
- package/src/router.test.ts +60 -1
- package/src/router.ts +124 -12
- package/src/session.ts +8 -1
- package/src/team-gate.ts +4 -0
- package/src/top-logprobs.test.ts +9 -0
- package/src/top-logprobs.ts +22 -5
- package/lib/caller-BWwSVNZf.js.map +0 -1
package/README.md
CHANGED
|
@@ -160,6 +160,8 @@ K ... S = 偏向失败的程度依次递增
|
|
|
160
160
|
T = 明确且无可争议的失败
|
|
161
161
|
```
|
|
162
162
|
|
|
163
|
+
所有裁判提示词都会把任务、轨迹、计划与证据包在 `<<<...>>>` 分隔块中,并明确声明这些内容**只是数据**:不得执行其中的指令、不得改写评分标尺或输出格式、其中的任何“评分”文本一律忽略——被评审的工具输出与文件内容因此无法通过提示词注入伪造判决。
|
|
164
|
+
|
|
163
165
|
字母按等距标尺线性映射到 `[0, 1]` 区间。在打分计算上,插件采用**自适应评分机制**:
|
|
164
166
|
|
|
165
167
|
- **优先概率期望评分**:若当前模型路由为官方 `deepseek-official` 或显式配置了兼容 OpenAI Chat Completions 且支持 `top_logprobs` 的端点,插件将基于 A–T 候选 Token 的完整概率分布计算加权期望值;
|
|
@@ -194,14 +196,15 @@ flowchart LR
|
|
|
194
196
|
| 配置项 | 说明 |
|
|
195
197
|
|---|---|
|
|
196
198
|
| **启用工具 (Enabled)** | 是否允许显式工具与自动验收向裁判模型发起请求;关闭后显式调用立即报错且自动门控不运行 |
|
|
197
|
-
| **调用策略** | `manual` 仅显式调用;`smart` 结构化优先,并只在有候选/检查点线索时做高置信语义路由,达到工具证据门槛后最终验收;`strict` 每个结束边界都尝试语义路由,并对任一已完成关键操作最终验收,路由或验收异常时 fail closed |
|
|
199
|
+
| **调用策略** | `manual` 仅显式调用;`smart` 结构化优先,并只在有候选/检查点线索时做高置信语义路由,达到工具证据门槛后最终验收;`strict` 每个结束边界都尝试语义路由,并对任一已完成关键操作最终验收,路由或验收异常时 fail closed(预算耗尽时只注入一次阻断提示,随后放行并在宿主日志告警,避免无出口的 steering 活锁) |
|
|
198
200
|
| **混合语义路由** | 结构化证据不足时,是否允许裁判模型保守分类 `compare/select/track/none`;不会生成新候选或编造检查点 |
|
|
199
201
|
| **语义路由置信度** | 语义识别达到该值才执行对应工具,默认 `0.9` |
|
|
200
202
|
| **最多候选数** | 自动 `select` 一次最多纳入的候选数,默认 `8` |
|
|
201
|
-
| **每任务/每会话最多路由** | 独立于最终验收预算,限制 `compare/select/track`
|
|
203
|
+
| **每任务/每会话最多路由** | 独立于最终验收预算,限制 `compare/select/track` 及语义分类的自动次数;预算按真实对局数估算(8 候选约需 54 次调用),被拒绝时写入宿主日志,strict 下额外注入一次提示 |
|
|
204
|
+
| **同时验收子 Agent** | 默认关闭;开启后 `subagent` / fork 子会话也会执行自动路由与最终验收 |
|
|
202
205
|
| **进度完成阈值** | `track` 任一检查点低于该值时 steering 要求继续工作,默认 `0.8` |
|
|
203
|
-
| **单项/总证据字符上限** | 自动候选与检查点脱敏后的单项、整次路由输入硬上限,默认 `20000 / 60000
|
|
204
|
-
| **任务/会话模型调用预算** | 分类、compare/select/track 与最终验收共享的估算请求预算,默认 `
|
|
206
|
+
| **单项/总证据字符上限** | 自动候选与检查点脱敏后的单项、整次路由输入硬上限,默认 `20000 / 60000`;同时约束语义路由提示词的总长度(只保留预算内最新证据)。截断标记本身也计入上限,因此截断后的条目不会被判定为超限 |
|
|
207
|
+
| **任务/会话模型调用预算** | 分类、compare/select/track 与最终验收共享的估算请求预算,默认 `64 / 240`(按真实对局数估算:8 候选的完整锦标赛约 18 场对决 × 3 标准 = 54 次调用) |
|
|
205
208
|
| **通过阈值** | 自动会话验收要求证据分数达到阈值且胜过“未执行有效工作”基线 |
|
|
206
209
|
| **自动评估轮次** | 自动验收每个标准的重复轮次;默认 1,作为低成本初筛 |
|
|
207
210
|
| **智能模式最少工具调用** | `smart` 策略需要的最少非 Verifier 工具调用数 |
|
|
@@ -250,7 +253,8 @@ flowchart LR
|
|
|
250
253
|
}
|
|
251
254
|
```
|
|
252
255
|
|
|
253
|
-
- 同一任务内至少两个内容或状态发生真实变化的 `todo/write`
|
|
256
|
+
- 同一任务内至少两个内容或状态发生真实变化的 `todo/write` 快照形成进度检查点;完全相同的重复快照会被折叠;
|
|
257
|
+
- 每个进度检查点都会附带**该时刻之前最近一次成功工具输出**(`tool/result` / `tool/ptc-dispatch` 原文,脱敏并限长)。只有 todo 文本的检查点无法证明"已完成",裁判提示词明确拒绝给无实测输出的状态打高分,因此证据随检查点一同送入——否则一个真正完成的任务也会稳定被打回继续工作。
|
|
254
258
|
|
|
255
259
|
显式调用过对应的 `verifier_compare`、`verifier_select` 或 `verifier_track` 后,自动 Router 不会再对同类结构化对象重复执行。每个输入还会计算稳定指纹,同一证据不会重复消费预算。
|
|
256
260
|
|
|
@@ -10,6 +10,19 @@ var TopLogprobsUnsupportedError = class extends Error {
|
|
|
10
10
|
this.name = "TopLogprobsUnsupportedError";
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* A provider-level rejection of the direct transport that is not a logprobs
|
|
15
|
+
* capability answer (bad request, auth, quota, malformed body). It downgrades
|
|
16
|
+
* this topic to the DSH stream instead of failing the whole verification.
|
|
17
|
+
*/
|
|
18
|
+
var TopLogprobsRouteError = class extends TopLogprobsUnsupportedError {
|
|
19
|
+
status;
|
|
20
|
+
constructor(message, status) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.status = status;
|
|
23
|
+
this.name = "TopLogprobsRouteError";
|
|
24
|
+
}
|
|
25
|
+
};
|
|
13
26
|
function object(value) {
|
|
14
27
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
15
28
|
}
|
|
@@ -53,7 +66,7 @@ async function resolveTopLogprobRoute(ctx, provider) {
|
|
|
53
66
|
deepSeekThinking: false
|
|
54
67
|
};
|
|
55
68
|
}
|
|
56
|
-
async function callTopLogprobs(route, model, prompt, maxTokens, reasoningEffort, signal, images) {
|
|
69
|
+
async function callTopLogprobs(route, model, prompt, maxTokens, reasoningEffort, signal, images, attempt = 1) {
|
|
57
70
|
const content = images?.length ? [{
|
|
58
71
|
type: "text",
|
|
59
72
|
text: prompt
|
|
@@ -90,6 +103,7 @@ async function callTopLogprobs(route, model, prompt, maxTokens, reasoningEffort,
|
|
|
90
103
|
const raw = await response.text();
|
|
91
104
|
if (!response.ok) {
|
|
92
105
|
const excerpt = raw.slice(0, 1e3);
|
|
106
|
+
const message = "llm-verifier: top_logprobs request failed with HTTP " + response.status + ": " + excerpt;
|
|
93
107
|
if ([
|
|
94
108
|
400,
|
|
95
109
|
404,
|
|
@@ -97,13 +111,14 @@ async function callTopLogprobs(route, model, prompt, maxTokens, reasoningEffort,
|
|
|
97
111
|
415,
|
|
98
112
|
422
|
|
99
113
|
].includes(response.status) && /logprob|top_logprobs|unsupported|unknown (?:field|parameter)|unrecognized (?:field|parameter)|not support/i.test(excerpt)) throw new TopLogprobsUnsupportedError("provider rejected top_logprobs: HTTP " + response.status + " " + excerpt);
|
|
100
|
-
|
|
114
|
+
if (response.status === 408 || response.status === 409 || response.status === 429 || response.status >= 500) throw new Error(message);
|
|
115
|
+
throw new TopLogprobsRouteError(message, response.status);
|
|
101
116
|
}
|
|
102
117
|
let body;
|
|
103
118
|
try {
|
|
104
119
|
body = object(JSON.parse(raw)) ?? {};
|
|
105
120
|
} catch {
|
|
106
|
-
throw new
|
|
121
|
+
throw new TopLogprobsRouteError("llm-verifier: top_logprobs endpoint returned invalid JSON", response.status);
|
|
107
122
|
}
|
|
108
123
|
const choice = object((Array.isArray(body.choices) ? body.choices : [])[0]);
|
|
109
124
|
const message = object(choice?.message);
|
|
@@ -142,8 +157,8 @@ async function callTopLogprobs(route, model, prompt, maxTokens, reasoningEffort,
|
|
|
142
157
|
scoringMode: "top-logprobs",
|
|
143
158
|
usage: {
|
|
144
159
|
calls: 1,
|
|
145
|
-
attempts:
|
|
146
|
-
retries:
|
|
160
|
+
attempts: attempt,
|
|
161
|
+
retries: attempt - 1,
|
|
147
162
|
inputTokens: Math.max(0, input - cached),
|
|
148
163
|
cachedInputTokens: cached,
|
|
149
164
|
outputTokens: Number(rawUsage.completion_tokens ?? 0) || 0,
|
|
@@ -166,8 +181,16 @@ var TopLogprobCapabilityCache = class {
|
|
|
166
181
|
this.file = file;
|
|
167
182
|
this.now = now;
|
|
168
183
|
}
|
|
184
|
+
/** Expired marks are dropped so a provider that later gains logprobs support is re-probed. */
|
|
169
185
|
isUnsupported(provider, model) {
|
|
170
|
-
|
|
186
|
+
const key = provider + "\0" + model;
|
|
187
|
+
const markedAt = this.unsupported.get(key);
|
|
188
|
+
if (markedAt === void 0) return false;
|
|
189
|
+
if (this.now() - markedAt > 864e5) {
|
|
190
|
+
this.unsupported.delete(key);
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
return true;
|
|
171
194
|
}
|
|
172
195
|
/** Hydrates persisted marks once; in-process marks always win over file contents. */
|
|
173
196
|
async ensureLoaded() {
|
|
@@ -248,61 +271,37 @@ function usage(attempts, value = {}) {
|
|
|
248
271
|
reasoningTokens: value.reasoningTokens ?? 0
|
|
249
272
|
};
|
|
250
273
|
}
|
|
251
|
-
|
|
274
|
+
/** Transient failures worth another attempt; anything else fails fast. */
|
|
275
|
+
const RETRYABLE_MESSAGE = /rate|quota|timeout|timed out|temporar|network|fetch|socket|5\d\d/i;
|
|
276
|
+
/**
|
|
277
|
+
* Run one logical verifier request under the configured timeout, retrying
|
|
278
|
+
* transient failures with exponential backoff.
|
|
279
|
+
*
|
|
280
|
+
* Every channel goes through this wrapper — including the direct top_logprobs
|
|
281
|
+
* transport, which used to bypass both the timeout and the retry budget.
|
|
282
|
+
* @param config - resolved verifier client configuration.
|
|
283
|
+
* @param signal - caller's abort signal (tool call or turn boundary).
|
|
284
|
+
* @param run - one attempt; receives its own deadline signal and 1-based attempt number.
|
|
285
|
+
* @returns The first successful completion.
|
|
286
|
+
*/
|
|
287
|
+
async function retrying(config, signal, run) {
|
|
252
288
|
let attempt = 0;
|
|
253
289
|
while (true) {
|
|
254
290
|
attempt += 1;
|
|
255
291
|
const controller = new AbortController();
|
|
256
|
-
|
|
292
|
+
let timedOut = false;
|
|
293
|
+
const timeout = setTimeout(() => {
|
|
294
|
+
timedOut = true;
|
|
295
|
+
controller.abort(/* @__PURE__ */ new Error("llm-verifier: request timed out"));
|
|
296
|
+
}, config.timeoutMs);
|
|
257
297
|
const abort = () => controller.abort(signal?.reason);
|
|
258
298
|
signal?.addEventListener("abort", abort, { once: true });
|
|
259
299
|
try {
|
|
260
|
-
|
|
261
|
-
type: "text",
|
|
262
|
-
text: prompt
|
|
263
|
-
}];
|
|
264
|
-
for (const image of images ?? []) {
|
|
265
|
-
const ref = await config.attachments.saveImage({
|
|
266
|
-
data: image.data,
|
|
267
|
-
mediaType: image.mediaType
|
|
268
|
-
});
|
|
269
|
-
content.push({
|
|
270
|
-
type: "image",
|
|
271
|
-
attachment: ref
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
const messages = [createUserMessage({
|
|
275
|
-
content,
|
|
276
|
-
source: {
|
|
277
|
-
kind: "plugin",
|
|
278
|
-
plugin: "dsh-llm-verifier"
|
|
279
|
-
}
|
|
280
|
-
})];
|
|
281
|
-
const assembler = new BlockAssembler();
|
|
282
|
-
const options = deepFreeze({
|
|
283
|
-
provider: config.provider,
|
|
284
|
-
model: config.model,
|
|
285
|
-
...config.reasoningEffort ? { reasoningEffort: ReasoningEffortId(config.reasoningEffort) } : {},
|
|
286
|
-
messages,
|
|
287
|
-
maxTokens: config.maxTokens,
|
|
288
|
-
temperature: 1,
|
|
289
|
-
signal: controller.signal
|
|
290
|
-
});
|
|
291
|
-
for await (const chunk of config.llm.stream(options)) assembler.push(chunk);
|
|
292
|
-
const failed = failureMessage(assembler.finish);
|
|
293
|
-
if (failed !== void 0) throw new Error("llm-verifier: model call failed: " + failed);
|
|
294
|
-
const text = assembler.blocks().filter((block) => block.type === "text").map((block) => block.text).join("");
|
|
295
|
-
if (!text.trim()) throw new Error("llm-verifier: selected DSH model produced no text");
|
|
296
|
-
return {
|
|
297
|
-
text,
|
|
298
|
-
tokens: [],
|
|
299
|
-
positions: [],
|
|
300
|
-
scoringMode: "explicit-tag",
|
|
301
|
-
usage: usage(attempt, assembler.usage)
|
|
302
|
-
};
|
|
300
|
+
return await run(controller.signal, attempt);
|
|
303
301
|
} catch (error) {
|
|
304
302
|
if (signal?.aborted) throw signal.reason;
|
|
305
|
-
|
|
303
|
+
const retryable = timedOut || error instanceof Error && RETRYABLE_MESSAGE.test(error.message);
|
|
304
|
+
if (attempt > config.maxRetries || !retryable) throw error;
|
|
306
305
|
await delay(Math.min(3e4, config.retryBaseDelayMs * 2 ** (attempt - 1) * (.8 + Math.random() * .4)), signal);
|
|
307
306
|
} finally {
|
|
308
307
|
clearTimeout(timeout);
|
|
@@ -310,6 +309,57 @@ async function callExplicitTag(config, prompt, signal, images) {
|
|
|
310
309
|
}
|
|
311
310
|
}
|
|
312
311
|
}
|
|
312
|
+
/** One attachment per image object per process: retries must not duplicate attachments. */
|
|
313
|
+
const imageRefs = /* @__PURE__ */ new WeakMap();
|
|
314
|
+
async function callExplicitTag(config, prompt, signal, images, attempt) {
|
|
315
|
+
const content = [{
|
|
316
|
+
type: "text",
|
|
317
|
+
text: prompt
|
|
318
|
+
}];
|
|
319
|
+
for (const image of images ?? []) {
|
|
320
|
+
let pending = imageRefs.get(image);
|
|
321
|
+
if (pending === void 0) {
|
|
322
|
+
pending = config.attachments.saveImage({
|
|
323
|
+
data: image.data,
|
|
324
|
+
mediaType: image.mediaType
|
|
325
|
+
});
|
|
326
|
+
imageRefs.set(image, pending);
|
|
327
|
+
}
|
|
328
|
+
content.push({
|
|
329
|
+
type: "image",
|
|
330
|
+
attachment: await pending
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
const messages = [createUserMessage({
|
|
334
|
+
content,
|
|
335
|
+
source: {
|
|
336
|
+
kind: "plugin",
|
|
337
|
+
plugin: "dsh-llm-verifier"
|
|
338
|
+
}
|
|
339
|
+
})];
|
|
340
|
+
const assembler = new BlockAssembler();
|
|
341
|
+
const options = deepFreeze({
|
|
342
|
+
provider: config.provider,
|
|
343
|
+
model: config.model,
|
|
344
|
+
...config.reasoningEffort ? { reasoningEffort: ReasoningEffortId(config.reasoningEffort) } : {},
|
|
345
|
+
messages,
|
|
346
|
+
maxTokens: config.maxTokens,
|
|
347
|
+
temperature: 1,
|
|
348
|
+
signal
|
|
349
|
+
});
|
|
350
|
+
for await (const chunk of config.llm.stream(options)) assembler.push(chunk);
|
|
351
|
+
const failed = failureMessage(assembler.finish);
|
|
352
|
+
if (failed !== void 0) throw new Error("llm-verifier: model call failed: " + failed);
|
|
353
|
+
const text = assembler.blocks().filter((block) => block.type === "text").map((block) => block.text).join("");
|
|
354
|
+
if (!text.trim()) throw new Error("llm-verifier: selected DSH model produced no text");
|
|
355
|
+
return {
|
|
356
|
+
text,
|
|
357
|
+
tokens: [],
|
|
358
|
+
positions: [],
|
|
359
|
+
scoringMode: "explicit-tag",
|
|
360
|
+
usage: usage(attempt, assembler.usage)
|
|
361
|
+
};
|
|
362
|
+
}
|
|
313
363
|
var RequestLimiter = class {
|
|
314
364
|
limit;
|
|
315
365
|
active = 0;
|
|
@@ -347,27 +397,27 @@ async function predictScoringChannel(config) {
|
|
|
347
397
|
await config.topLogprobCapabilities.ensureLoaded();
|
|
348
398
|
return config.topLogprobCapabilities.isUnsupported(config.provider, config.model) ? "explicit-tag" : "top-logprobs";
|
|
349
399
|
}
|
|
350
|
-
async function callAutomatic(config, prompt, signal, images) {
|
|
400
|
+
async function callAutomatic(config, prompt, signal, images, attempt) {
|
|
351
401
|
await config.topLogprobCapabilities.ensureLoaded();
|
|
352
402
|
if (!config.topLogprobCapabilities.isUnsupported(config.provider, config.model)) {
|
|
353
403
|
const route = await resolveTopLogprobRoute(config.ctx, config.provider);
|
|
354
404
|
if (route !== void 0) try {
|
|
355
|
-
return await callTopLogprobs(route, config.model, prompt, config.maxTokens, config.reasoningEffort, signal, images);
|
|
405
|
+
return await callTopLogprobs(route, config.model, prompt, config.maxTokens, config.reasoningEffort, signal, images, attempt);
|
|
356
406
|
} catch (error) {
|
|
357
407
|
if (!(error instanceof TopLogprobsUnsupportedError)) throw error;
|
|
358
408
|
config.topLogprobCapabilities.markUnsupported(config.provider, config.model);
|
|
359
409
|
}
|
|
360
410
|
else config.topLogprobCapabilities.markUnsupported(config.provider, config.model);
|
|
361
411
|
}
|
|
362
|
-
return callExplicitTag(config, prompt, signal, images);
|
|
412
|
+
return callExplicitTag(config, prompt, signal, images, attempt);
|
|
363
413
|
}
|
|
364
414
|
async function callVerifier(config, prompt, signal, images) {
|
|
365
|
-
const invoke = () => callAutomatic(config, prompt,
|
|
415
|
+
const invoke = () => retrying(config, signal, (attemptSignal, attempt) => callAutomatic(config, prompt, attemptSignal, images, attempt));
|
|
366
416
|
return config.limiter === void 0 ? invoke() : config.limiter.run(invoke, signal);
|
|
367
417
|
}
|
|
368
418
|
/** Plain-text verifier call for conservative JSON routing; probability labels are intentionally bypassed. */
|
|
369
419
|
async function callVerifierText(config, prompt, signal) {
|
|
370
|
-
const invoke = () => callExplicitTag(config, prompt,
|
|
420
|
+
const invoke = () => retrying(config, signal, (attemptSignal, attempt) => callExplicitTag(config, prompt, attemptSignal, void 0, attempt));
|
|
371
421
|
return config.limiter === void 0 ? invoke() : config.limiter.run(invoke, signal);
|
|
372
422
|
}
|
|
373
423
|
function addUsage(target, source) {
|
|
@@ -395,4 +445,4 @@ function emptyUsage() {
|
|
|
395
445
|
//#endregion
|
|
396
446
|
export { emptyUsage as a, resolveCapabilityFile as c, callVerifierText as i, addUsage as n, predictScoringChannel as o, callVerifier as r, TopLogprobCapabilityCache as s, RequestLimiter as t };
|
|
397
447
|
|
|
398
|
-
//# sourceMappingURL=caller-
|
|
448
|
+
//# sourceMappingURL=caller-D1ZQNsVU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caller-D1ZQNsVU.js","names":[],"sources":["../src/top-logprobs.ts","../src/caller.ts"],"sourcesContent":["import type { Context } from '@deepseek-ai/cordis'\nimport { credentialRef } from '@deepseek-ai/dsh-credentials'\nimport { mkdir, readFile, rename, unlink, writeFile } from 'node:fs/promises'\nimport { dirname, isAbsolute, join, resolve } from 'node:path'\nimport type { CompletionLogprobs, TokenAlternative } from './core.ts'\nimport type { UsageStats, VerifierImage } from './caller.ts'\n\nexport interface TopLogprobRoute {\n baseURL: string\n apiKey?: string\n headers?: Record<string, string>\n deepSeekThinking: boolean\n}\nexport interface TopLogprobCompletion extends CompletionLogprobs { usage: UsageStats; scoringMode: 'top-logprobs' }\nexport class TopLogprobsUnsupportedError extends Error { constructor(message: string) { super(message); this.name = 'TopLogprobsUnsupportedError' } }\n/**\n * A provider-level rejection of the direct transport that is not a logprobs\n * capability answer (bad request, auth, quota, malformed body). It downgrades\n * this topic to the DSH stream instead of failing the whole verification.\n */\nexport class TopLogprobsRouteError extends TopLogprobsUnsupportedError { constructor(message: string, readonly status?: number) { super(message); this.name = 'TopLogprobsRouteError' } }\n\nfunction object(value: unknown): Record<string, unknown> | undefined { return typeof value === 'object' && value !== null && !Array.isArray(value) ? value as Record<string, unknown> : undefined }\nfunction text(value: unknown): string | undefined { return typeof value === 'string' && value.trim() ? value.trim() : undefined }\nfunction endpoint(baseURL: string): string { return baseURL.replace(/\\/+$/, '') + '/chat/completions' }\nfunction dataUrl(image: VerifierImage): string { return 'data:' + image.mediaType + ';base64,' + Buffer.from(image.data.buffer, image.data.byteOffset, image.data.byteLength).toString('base64') }\n\nasync function credential(ctx: Context, name: string | undefined): Promise<string | undefined> {\n if (!name) return undefined\n const provider = ctx.get('credentials')\n return (await provider?.resolve(credentialRef(name)))?.value\n}\n\nexport async function resolveTopLogprobRoute(ctx: Context, provider: string): Promise<TopLogprobRoute | undefined> {\n const settings = ctx.get('settings')\n if (provider === 'deepseek-official') {\n const value = settings ? object(settings.get('llm-deepseek' as never)) ?? {} : {}\n const apiKeyEnv = text(value.apiKeyEnv) ?? 'DEEPSEEK_API_KEY'\n const apiKey = await credential(ctx, apiKeyEnv)\n if (!apiKey) return undefined\n return { baseURL: text(value.baseURL) ?? 'https://api.deepseek.com', apiKey, deepSeekThinking: true }\n }\n if (!settings) return undefined\n const root = object(settings.get('llm-pi-ai' as never))\n const profiles = object(root?.providers)\n const profile = object(profiles?.[provider])\n // Only explicitly OpenAI-compatible profiles are safe to serialize directly.\n // Other DSH adapters keep their private protocol and use the explicit-tag fallback.\n if (!profile || profile.api !== 'openai-completions') return undefined\n const baseURL = text(profile.baseURL)\n if (!baseURL || !/^https:\\/\\//i.test(baseURL)) return undefined\n const apiKey = await credential(ctx, text(profile.apiKeyEnv))\n const rawHeaders = object(profile.headers)\n const headers = rawHeaders === undefined ? undefined : Object.fromEntries(Object.entries(rawHeaders).filter((entry): entry is [string, string] => typeof entry[1] === 'string'))\n return { baseURL, ...(apiKey ? { apiKey } : {}), ...(headers ? { headers } : {}), deepSeekThinking: false }\n}\n\nexport async function callTopLogprobs(route: TopLogprobRoute, model: string, prompt: string, maxTokens: number, reasoningEffort: string | undefined, signal?: AbortSignal, images?: readonly VerifierImage[], attempt = 1): Promise<TopLogprobCompletion> {\n const content: string | Record<string, unknown>[] = images?.length ? [{ type: 'text', text: prompt }, ...images.map(image => ({ type: 'image_url', image_url: { url: dataUrl(image) } }))] : prompt\n const thinking = route.deepSeekThinking && reasoningEffort ? reasoningEffort === 'off' ? { thinking: { type: 'disabled' } } : { thinking: { type: 'enabled' }, reasoning_effort: reasoningEffort } : {}\n const response = await fetch(endpoint(route.baseURL), {\n method: 'POST', redirect: 'error', signal,\n headers: { 'content-type': 'application/json', ...(route.apiKey ? { authorization: 'Bearer ' + route.apiKey } : {}), ...route.headers },\n body: JSON.stringify({ model, messages: [{ role: 'user', content }], max_tokens: maxTokens, temperature: 1, logprobs: true, top_logprobs: 20, ...thinking }),\n })\n const raw = await response.text()\n if (!response.ok) {\n const excerpt = raw.slice(0, 1000)\n const message = 'llm-verifier: top_logprobs request failed with HTTP ' + response.status + ': ' + excerpt\n if ([400, 404, 405, 415, 422].includes(response.status) && /logprob|top_logprobs|unsupported|unknown (?:field|parameter)|unrecognized (?:field|parameter)|not support/i.test(excerpt)) throw new TopLogprobsUnsupportedError('provider rejected top_logprobs: HTTP ' + response.status + ' ' + excerpt)\n // Throttling and server faults stay generic so the shared retry wrapper can\n // attempt again; every other rejection downgrades to the DSH stream.\n if (response.status === 408 || response.status === 409 || response.status === 429 || response.status >= 500) throw new Error(message)\n throw new TopLogprobsRouteError(message, response.status)\n }\n let body: Record<string, unknown>\n try { body = object(JSON.parse(raw)) ?? {} } catch { throw new TopLogprobsRouteError('llm-verifier: top_logprobs endpoint returned invalid JSON', response.status) }\n const choices = Array.isArray(body.choices) ? body.choices : []\n const choice = object(choices[0])\n const message = object(choice?.message)\n const answer = typeof message?.content === 'string' ? message.content : ''\n const logprobs = object(choice?.logprobs)\n const rows = Array.isArray(logprobs?.content) ? logprobs.content : []\n if (!rows.length) throw new TopLogprobsUnsupportedError('provider returned no token logprobs')\n const tokens: string[] = []\n const positions: TokenAlternative[][] = []\n for (const rawRow of rows) {\n const row = object(rawRow) ?? {}\n const token = typeof row.token === 'string' ? row.token : ''\n tokens.push(token)\n const top = Array.isArray(row.top_logprobs) ? row.top_logprobs : []\n const alternatives = top.flatMap(value => { const item = object(value); return item && typeof item.token === 'string' && typeof item.logprob === 'number' ? [{ token: item.token, logprob: item.logprob }] : [] })\n if (!alternatives.length && typeof row.logprob === 'number') alternatives.push({ token, logprob: row.logprob })\n positions.push(alternatives)\n }\n const rawUsage = object(body.usage) ?? {}\n const promptDetails = object(rawUsage.prompt_tokens_details) ?? {}\n const completionDetails = object(rawUsage.completion_tokens_details) ?? {}\n const cached = Number(rawUsage.prompt_cache_hit_tokens ?? promptDetails.cached_tokens ?? 0) || 0\n const input = Number(rawUsage.prompt_tokens ?? 0) || 0\n return { text: answer, tokens, positions, scoringMode: 'top-logprobs', usage: { calls: 1, attempts: attempt, retries: attempt - 1, inputTokens: Math.max(0, input - cached), cachedInputTokens: cached, outputTokens: Number(rawUsage.completion_tokens ?? 0) || 0, reasoningTokens: Number(completionDetails.reasoning_tokens ?? 0) || 0 } }\n}\n\n/** Marks older than this are dropped on hydration so a provider that later gains logprobs support is re-probed. */\nexport const CAPABILITY_TTL_MS = 24 * 60 * 60 * 1000\n\ninterface CapabilityDocument { version: 1; entries: Record<string, number> }\n\n/** Resolves the capability memory file beside the score cache inside the topic verifier directory. */\nexport function resolveCapabilityFile(cacheDir: string, cwd = process.cwd()): string {\n const root = isAbsolute(cacheDir) ? cacheDir : resolve(cwd, cacheDir)\n return join(root, 'capabilities-v1.json')\n}\n\nexport class TopLogprobCapabilityCache {\n private readonly unsupported = new Map<string, number>()\n private loaded = false\n private hydrating: Promise<void> | undefined\n private writing: Promise<void> = Promise.resolve()\n\n constructor(private readonly file?: string, private readonly now: () => number = Date.now) {}\n\n /** Expired marks are dropped so a provider that later gains logprobs support is re-probed. */\n isUnsupported(provider: string, model: string): boolean {\n const key = provider + '\\0' + model\n const markedAt = this.unsupported.get(key)\n if (markedAt === undefined) return false\n if (this.now() - markedAt > CAPABILITY_TTL_MS) { this.unsupported.delete(key); return false }\n return true\n }\n\n /** Hydrates persisted marks once; in-process marks always win over file contents. */\n async ensureLoaded(): Promise<void> {\n if (this.loaded || this.file === undefined) return\n this.hydrating ??= (async () => {\n try {\n const document = JSON.parse(await readFile(this.file!, 'utf8')) as CapabilityDocument\n const entries = document !== null && typeof document === 'object' && document.version === 1 && typeof document.entries === 'object' && document.entries !== null ? document.entries : {}\n const now = this.now()\n for (const [key, markedAt] of Object.entries(entries)) {\n if (typeof markedAt !== 'number' || !Number.isFinite(markedAt) || markedAt < 0 || now - markedAt > CAPABILITY_TTL_MS) continue\n // Max-merge: never let an older persisted stamp clobber a fresher in-process probe.\n const existing = this.unsupported.get(key)\n if (existing === undefined || existing < markedAt) this.unsupported.set(key, markedAt)\n }\n } catch { /* a missing or unreadable file simply starts empty */ }\n this.loaded = true\n })()\n await this.hydrating\n }\n\n markUnsupported(provider: string, model: string): void {\n this.unsupported.set(provider + '\\0' + model, this.now())\n if (this.file === undefined) return\n // Serialize behind hydration so an early mark never clobbers not-yet-loaded entries.\n this.writing = this.writing\n .then(() => this.ensureLoaded())\n .then(async () => {\n const snapshot: CapabilityDocument = { version: 1, entries: Object.fromEntries(this.unsupported) }\n await mkdir(dirname(this.file!), { recursive: true })\n const temporary = this.file! + '.tmp-' + process.pid\n await writeFile(temporary, JSON.stringify(snapshot), 'utf8')\n try { await rename(temporary, this.file!) } catch (error) { await unlink(temporary).catch(() => {}); throw error }\n })\n .catch(() => { /* capability memory is best-effort; the next mark rewrites the file */ })\n }\n\n /** Resolves once the trailing persistence attempt settles; exposed for tests. */\n flush(): Promise<void> { return this.writing }\n}\n","import { BlockAssembler, ReasoningEffortId, createUserMessage, type ContentBlock, type FinishReason, type LlmRuntime } from '@deepseek-ai/dsh-llm'\nimport * as LlmModule from '@deepseek-ai/dsh-llm'\n\nfunction deepFreeze<T>(value: T): T {\n const mod = LlmModule as unknown as Record<string, unknown>\n if (typeof mod.deepFreeze === 'function') {\n return (mod.deepFreeze as Function)(value)\n }\n if (value && typeof value === 'object' && !Object.isFrozen(value)) {\n Object.freeze(value)\n for (const key of Object.keys(value)) {\n deepFreeze((value as Record<string, unknown>)[key])\n }\n }\n return value\n}\nimport type { AttachmentStore } from '@deepseek-ai/dsh-attachment'\nimport type { CompletionLogprobs } from './core.ts'\nimport { TopLogprobCapabilityCache, TopLogprobsUnsupportedError, callTopLogprobs, resolveTopLogprobRoute } from './top-logprobs.ts'\nimport type { Context } from '@deepseek-ai/cordis'\n\nexport interface VerifierClientConfig {\n ctx: Context\n llm: LlmRuntime\n attachments: AttachmentStore\n topLogprobCapabilities: TopLogprobCapabilityCache\n provider: string\n model: string\n reasoningEffort?: string\n maxTokens: number\n timeoutMs: number\n maxRetries: number\n retryBaseDelayMs: number\n limiter?: RequestLimiter\n}\n\nexport interface VerifierImage {\n data: Uint8Array\n mediaType: 'image/png' | 'image/jpeg' | 'image/webp' | 'image/gif'\n}\n\nexport interface UsageStats {\n calls: number\n attempts: number\n retries: number\n inputTokens: number\n cachedInputTokens: number\n outputTokens: number\n reasoningTokens: number\n}\n\nexport type ScoringMode = 'top-logprobs' | 'explicit-tag'\nexport interface VerifierCompletion extends CompletionLogprobs { usage: UsageStats; scoringMode: ScoringMode }\n\nfunction failureMessage(finish: FinishReason): string | undefined {\n if (finish.kind === 'error' || finish.kind === 'aborted') return finish.failure.message\n if (finish.kind === 'max-tokens') return 'verifier response reached max tokens before completing its answer'\n return undefined\n}\n\nasync function delay(ms: number, signal?: AbortSignal): Promise<void> {\n if (signal?.aborted) throw signal.reason\n await new Promise<void>((resolve, reject) => {\n const timer = setTimeout(resolve, ms)\n const abort = () => { clearTimeout(timer); reject(signal?.reason) }\n signal?.addEventListener('abort', abort, { once: true })\n })\n}\n\nfunction usage(attempts: number, value = {} as { inputTokens?: number; outputTokens?: number; cacheReadTokens?: number; cacheWriteTokens?: number; reasoningTokens?: number }): UsageStats {\n return { calls: 1, attempts, retries: attempts - 1, inputTokens: value.inputTokens ?? 0, cachedInputTokens: (value.cacheReadTokens ?? 0) + (value.cacheWriteTokens ?? 0), outputTokens: value.outputTokens ?? 0, reasoningTokens: value.reasoningTokens ?? 0 }\n}\n\n/** Transient failures worth another attempt; anything else fails fast. */\nconst RETRYABLE_MESSAGE = /rate|quota|timeout|timed out|temporar|network|fetch|socket|5\\d\\d/i\n\n/**\n * Run one logical verifier request under the configured timeout, retrying\n * transient failures with exponential backoff.\n *\n * Every channel goes through this wrapper — including the direct top_logprobs\n * transport, which used to bypass both the timeout and the retry budget.\n * @param config - resolved verifier client configuration.\n * @param signal - caller's abort signal (tool call or turn boundary).\n * @param run - one attempt; receives its own deadline signal and 1-based attempt number.\n * @returns The first successful completion.\n */\nasync function retrying<T>(config: VerifierClientConfig, signal: AbortSignal | undefined, run: (signal: AbortSignal, attempt: number) => Promise<T>): Promise<T> {\n let attempt = 0\n while (true) {\n attempt += 1\n const controller = new AbortController()\n let timedOut = false\n const timeout = setTimeout(() => { timedOut = true; controller.abort(new Error('llm-verifier: request timed out')) }, config.timeoutMs)\n const abort = () => controller.abort(signal?.reason)\n signal?.addEventListener('abort', abort, { once: true })\n try {\n return await run(controller.signal, attempt)\n } catch (error) {\n if (signal?.aborted) throw signal.reason\n // A deadline abort is retryable even when the adapter wraps the reason in\n // its own error type with an unrelated message.\n const retryable = timedOut || (error instanceof Error && RETRYABLE_MESSAGE.test(error.message))\n if (attempt > config.maxRetries || !retryable) throw error\n await delay(Math.min(30000, config.retryBaseDelayMs * 2 ** (attempt - 1) * (0.8 + Math.random() * 0.4)), signal)\n } finally {\n clearTimeout(timeout)\n signal?.removeEventListener('abort', abort)\n }\n }\n}\n\n/** One attachment per image object per process: retries must not duplicate attachments. */\nconst imageRefs = new WeakMap<VerifierImage, Promise<unknown>>()\n\nasync function callExplicitTag(config: VerifierClientConfig, prompt: string, signal: AbortSignal | undefined, images: readonly VerifierImage[] | undefined, attempt: number): Promise<VerifierCompletion> {\n const content: ContentBlock[] = [{ type: 'text', text: prompt }]\n for (const image of images ?? []) {\n let pending = imageRefs.get(image)\n if (pending === undefined) { pending = config.attachments.saveImage({ data: image.data, mediaType: image.mediaType }); imageRefs.set(image, pending) }\n content.push({ type: 'image', attachment: await pending as never })\n }\n const messages = [createUserMessage({ content, source: { kind: 'plugin', plugin: 'dsh-llm-verifier' } })]\n const assembler = new BlockAssembler()\n const options = deepFreeze({\n provider: config.provider,\n model: config.model,\n ...(config.reasoningEffort ? { reasoningEffort: ReasoningEffortId(config.reasoningEffort) } : {}),\n messages,\n maxTokens: config.maxTokens,\n temperature: 1,\n signal,\n })\n for await (const chunk of config.llm.stream(options)) assembler.push(chunk)\n const failed = failureMessage(assembler.finish)\n if (failed !== undefined) throw new Error('llm-verifier: model call failed: ' + failed)\n const text = assembler.blocks().filter((block): block is Extract<ContentBlock, { type: 'text' }> => block.type === 'text').map(block => block.text).join('')\n if (!text.trim()) throw new Error('llm-verifier: selected DSH model produced no text')\n // DSH adapters expose provider-neutral text/usage but not top-logprob candidates.\n // extractScore() therefore uses the model's explicit final A–T tags.\n return { text, tokens: [], positions: [], scoringMode: 'explicit-tag', usage: usage(attempt, assembler.usage) }\n}\n\nexport class RequestLimiter {\n private active = 0\n private readonly queue: Array<() => void> = []\n constructor(readonly limit: number) { if (!Number.isSafeInteger(limit) || limit < 1) throw new Error('llm-verifier: request concurrency limit must be a positive integer') }\n async run<T>(operation: () => Promise<T>, signal?: AbortSignal): Promise<T> {\n if (this.active >= this.limit) await new Promise<void>((resolve, reject) => {\n const enter = () => { signal?.removeEventListener('abort', abort); resolve() }\n const abort = () => { const index = this.queue.indexOf(enter); if (index >= 0) this.queue.splice(index, 1); reject(signal?.reason) }\n this.queue.push(enter); signal?.addEventListener('abort', abort, { once: true })\n })\n if (signal?.aborted) throw signal.reason\n this.active += 1\n try { return await operation() } finally { this.active -= 1; this.queue.shift()?.() }\n }\n}\n\n/** Best-effort pre-call channel prediction for cache identity only; callAutomatic() stays the runtime source of truth. */\nexport async function predictScoringChannel(config: VerifierClientConfig): Promise<ScoringMode> {\n await config.topLogprobCapabilities.ensureLoaded()\n return config.topLogprobCapabilities.isUnsupported(config.provider, config.model) ? 'explicit-tag' : 'top-logprobs'\n}\n\nasync function callAutomatic(config: VerifierClientConfig, prompt: string, signal: AbortSignal | undefined, images: readonly VerifierImage[] | undefined, attempt: number): Promise<VerifierCompletion> {\n await config.topLogprobCapabilities.ensureLoaded()\n if (!config.topLogprobCapabilities.isUnsupported(config.provider, config.model)) {\n const route = await resolveTopLogprobRoute(config.ctx, config.provider)\n if (route !== undefined) {\n try { return await callTopLogprobs(route, config.model, prompt, config.maxTokens, config.reasoningEffort, signal, images, attempt) }\n catch (error) {\n // Both a capability rejection and a non-retryable provider rejection of\n // the direct transport fall back to the DSH stream instead of failing\n // the whole verification.\n if (!(error instanceof TopLogprobsUnsupportedError)) throw error\n config.topLogprobCapabilities.markUnsupported(config.provider, config.model)\n }\n } else config.topLogprobCapabilities.markUnsupported(config.provider, config.model)\n }\n return callExplicitTag(config, prompt, signal, images, attempt)\n}\n\nexport async function callVerifier(config: VerifierClientConfig, prompt: string, signal?: AbortSignal, images?: readonly VerifierImage[]): Promise<VerifierCompletion> {\n const invoke = () => retrying(config, signal, (attemptSignal, attempt) => callAutomatic(config, prompt, attemptSignal, images, attempt))\n return config.limiter === undefined ? invoke() : config.limiter.run(invoke, signal)\n}\n\n/** Plain-text verifier call for conservative JSON routing; probability labels are intentionally bypassed. */\nexport async function callVerifierText(config: VerifierClientConfig, prompt: string, signal?: AbortSignal): Promise<VerifierCompletion> {\n const invoke = () => retrying(config, signal, (attemptSignal, attempt) => callExplicitTag(config, prompt, attemptSignal, undefined, attempt))\n return config.limiter === undefined ? invoke() : config.limiter.run(invoke, signal)\n}\nexport function addUsage(target: UsageStats, source: UsageStats): void { for (const key of ['calls', 'attempts', 'retries', 'inputTokens', 'cachedInputTokens', 'outputTokens', 'reasoningTokens'] as const) target[key] += source[key] }\nexport function emptyUsage(): UsageStats { return { cal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AAgB,OAAO,OAAO,OAAO,QAAQ,OAAO,WAAW,OAAO,iBAAiB,QAAQ,QAAQ,OAAO;EAAE,SAC5H,OAAO;GAIZ,IAAI,EAAE,iBAAiB,8BAA8B,MAAM;GAC3D,OAAO,uBAAuB,gBAAgB,OAAO,UAAU,OAAO,KAAK;EAC7E;OACK,OAAO,uBAAuB,gBAAgB,OAAO,UAAU,OAAO,KAAK;CACpF;CACA,OAAO,gBAAgB,QAAQ,QAAQ,QAAQ,QAAQ,OAAO;AAChE;AAEA,eAAsB,aAAa,QAA8B,QAAgB,QAAsB,QAAgE;CACrK,MAAM,eAAe,SAAS,QAAQ,SAAS,eAAe,YAAY,cAAc,QAAQ,QAAQ,eAAe,QAAQ,OAAO,CAAC;CACvI,OAAO,OAAO,YAAY,KAAA,IAAY,OAAO,IAAI,OAAO,QAAQ,IAAI,QAAQ,MAAM;AACpF;;AAGA,eAAsB,iBAAiB,QAA8B,QAAgB,QAAmD;CACtI,MAAM,eAAe,SAAS,QAAQ,SAAS,eAAe,YAAY,gBAAgB,QAAQ,QAAQ,eAAe,KAAA,GAAW,OAAO,CAAC;CAC5I,OAAO,OAAO,YAAY,KAAA,IAAY,OAAO,IAAI,OAAO,QAAQ,IAAI,QAAQ,MAAM;AACpF;AACA,SAAgB,SAAS,QAAoB,QAA0B;CAAE,KAAK,MAAM,OAAO;EAAC;EAAS;EAAY;EAAW;EAAe;EAAqB;EAAgB;CAAiB,GAAY,OAAO,QAAQ,OAAO;AAAK;AACxO,SAAgB,aAAyB;CAAE,OAAO;EAAE,OAAO;EAAG,UAAU;EAAG,SAAS;EAAG,aAAa;EAAG,mBAAmB;EAAG,cAAc;EAAG,iBAAiB;CAAE;AAAE"}
|
package/lib/caller.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as emptyUsage, i as callVerifierText, n as addUsage, o as predictScoringChannel, r as callVerifier, t as RequestLimiter } from "./caller-
|
|
1
|
+
import { a as emptyUsage, i as callVerifierText, n as addUsage, o as predictScoringChannel, r as callVerifier, t as RequestLimiter } from "./caller-D1ZQNsVU.js";
|
|
2
2
|
export { RequestLimiter, addUsage, callVerifier, callVerifierText, emptyUsage, predictScoringChannel };
|