@konneal/engine 0.2.187 → 0.2.188
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/dist/ask-TJK7DQ45.js +16 -0
- package/dist/{chunk-IZ3GSYMD.js → chunk-4AP763GX.js} +32 -25
- package/dist/{chunk-MZQEI4VJ.js → chunk-4BQA7PJ3.js} +1 -1
- package/dist/{chunk-IDQND3AA.js → chunk-A2HQNENL.js} +13 -12
- package/dist/{chunk-VDFOVWE6.js → chunk-G435JWGV.js} +4 -4
- package/dist/{chunk-BAOKHV2D.js → chunk-L32WSANI.js} +4 -4
- package/dist/{chunk-TLPUJMAF.js → chunk-NHYYMRZC.js} +1 -1
- package/dist/{chunk-RBRBQJYT.js → chunk-SLYQ6L52.js} +9 -9
- package/dist/{chunk-BMODSEKT.js → chunk-VT5ZHCOC.js} +3 -3
- package/dist/config.d.ts +17 -10
- package/dist/nameplate.d.ts +1 -1
- package/dist/search-FJAOGMEO.js +14 -0
- package/dist/{tools-VMZSXLXM.js → tools-CYSL26HX.js} +4 -4
- package/dist/worker_mcp/src/index.js +2 -2
- package/dist/worker_public/src/config.js +3 -1
- package/dist/worker_public/src/index.js +10 -10
- package/dist/worker_public/src/requestScope.js +2 -2
- package/package.json +1 -1
- package/workers/worker_public/src/ai.ts +2 -3
- package/workers/worker_public/src/ask.ts +7 -7
- package/workers/worker_public/src/config.ts +41 -24
- package/workers/worker_public/src/understand.ts +6 -6
- package/dist/ask-O7HJIZPK.js +0 -16
- package/dist/search-3H2ENWHQ.js +0 -14
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
handleAsk
|
|
3
|
+
} from "./chunk-A2HQNENL.js";
|
|
4
|
+
import "./chunk-IRCDOFP4.js";
|
|
5
|
+
import "./chunk-VT5ZHCOC.js";
|
|
6
|
+
import "./chunk-SLYQ6L52.js";
|
|
7
|
+
import "./chunk-L32WSANI.js";
|
|
8
|
+
import "./chunk-NHYYMRZC.js";
|
|
9
|
+
import "./chunk-ETLSWSZ7.js";
|
|
10
|
+
import "./chunk-4BQA7PJ3.js";
|
|
11
|
+
import "./chunk-4AP763GX.js";
|
|
12
|
+
import "./chunk-3FYJM7LH.js";
|
|
13
|
+
import "./chunk-YGQCVPX6.js";
|
|
14
|
+
export {
|
|
15
|
+
handleAsk
|
|
16
|
+
};
|
|
@@ -3,53 +3,56 @@ import {
|
|
|
3
3
|
} from "./chunk-3FYJM7LH.js";
|
|
4
4
|
|
|
5
5
|
// workers/worker_public/src/config.ts
|
|
6
|
+
var FLASH = "@cf/deepseek-ai/deepseek-v4.1-flash-1017";
|
|
6
7
|
var MODELS = {
|
|
7
8
|
embed: "@cf/qwen/qwen3-embedding-0.6b",
|
|
8
9
|
rerank: "@cf/baai/bge-reranker-base",
|
|
9
|
-
// ANSWER MODEL (all tiers
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
anon: "@cf/zai-org/glm-5.3-flash",
|
|
13
|
-
member: "@cf/zai-org/glm-5.3-flash",
|
|
10
|
+
// ANSWER MODEL (all tiers): natively multimodal (vision-unified contract)
|
|
11
|
+
anon: FLASH,
|
|
12
|
+
member: FLASH,
|
|
14
13
|
// figure captions + the vision lane (one-time, quality-first; the A/B
|
|
15
14
|
// lever is CAPTION_MODEL, the per-request arm is the admin route's
|
|
16
|
-
// body.model)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
|
|
15
|
+
// body.model). It emptied on 8/24 figure images in the 2026-10-27 A/B —
|
|
16
|
+
// those captions fall to the serve-raw path.
|
|
17
|
+
caption: FLASH,
|
|
18
|
+
// the pairwise vision judge (sees the image; a THIRD model never judges
|
|
19
|
+
// its own arm) — no other live multimodal model exists in the policy
|
|
20
|
+
// line, so a v4.1 caption arm is judged by its own family
|
|
21
|
+
visionJudge: FLASH,
|
|
22
|
+
// the VLM figure rerank (TODO.sota/18.3): a vision-capable MoE scores
|
|
23
|
+
// figure IMAGES against figure-seeking questions — one bounded call per
|
|
24
|
+
// figure question, ablatable stage
|
|
25
|
+
vlmFigure: FLASH,
|
|
25
26
|
// the decision pass (TODO.decisions/01): clef-flash gates the
|
|
26
27
|
// requirement-shaped questions, clef decides the derived checklist
|
|
27
28
|
decisionsGate: "@cf/cloudflare/clef-flash",
|
|
28
29
|
decisionsModel: "@cf/cloudflare/clef",
|
|
29
|
-
// hot-path understanding/summarize
|
|
30
|
-
understand:
|
|
30
|
+
// hot-path understanding/summarize (cost-first lane)
|
|
31
|
+
understand: FLASH,
|
|
31
32
|
// the api_call act's intent-to-act mapping (TODO.ai-platform/09) — the
|
|
32
33
|
// operations deployment points ACTS_MODEL at the stronger reasoning
|
|
33
34
|
// tier; the floor is the understand lane
|
|
34
|
-
acts:
|
|
35
|
-
// generation fallback when the answer model is unavailable
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
acts: FLASH,
|
|
36
|
+
// generation fallback when the answer model is unavailable — the same
|
|
37
|
+
// model as the primary while it is the only live cheap option: the
|
|
38
|
+
// retry inside generateOnce is the only diversity this lane has
|
|
39
|
+
fallback: FLASH,
|
|
40
|
+
grader: FLASH,
|
|
41
|
+
// CRAG grader + judges
|
|
39
42
|
// contextual enrichment is the QUALITY-FIRST lane (one-time spend over
|
|
40
43
|
// the corpus, its quality persists into every future retrieval)
|
|
41
|
-
enrich: "@cf/
|
|
44
|
+
enrich: "@cf/zai-org/glm-5.3",
|
|
42
45
|
// final-tier listwise reranker for hard/member queries (cascade:
|
|
43
46
|
// cross-encoder prunes, listwise orders jointly)
|
|
44
47
|
listwise: "@cf/zai-org/glm-4.7-flash",
|
|
45
48
|
// deep-research loop (G10): bounded agentic iterations, members-only
|
|
46
|
-
escalation:
|
|
47
|
-
research:
|
|
49
|
+
escalation: FLASH,
|
|
50
|
+
research: FLASH,
|
|
48
51
|
// speculative draft-verify (TODO.sota/02 row 2): the strong verifier
|
|
49
52
|
// over the cheap drafts — the research-tier model verifies; the drafter
|
|
50
53
|
// is the standard answer model (MODELS.member). VERIFIER_MODEL swaps it
|
|
51
54
|
// live, same lever as every role.
|
|
52
|
-
verifier: "@cf/zai-org/glm-5.
|
|
55
|
+
verifier: "@cf/zai-org/glm-5.3"
|
|
53
56
|
};
|
|
54
57
|
var LIMITS = {
|
|
55
58
|
/** Attachment quotas (TODO.new-era/8): per-member ceilings so a member's
|
|
@@ -199,6 +202,9 @@ function effortBudget(effort) {
|
|
|
199
202
|
if (effort === "high" || effort === "max") return LIMITS.maxOutputTokens * 4;
|
|
200
203
|
return LIMITS.maxOutputTokens;
|
|
201
204
|
}
|
|
205
|
+
function generationSampling(model) {
|
|
206
|
+
return model.includes("deepseek") ? { temperature: 1, top_p: 1 } : { temperature: 0.6, top_p: 0.95 };
|
|
207
|
+
}
|
|
202
208
|
function requestEffort(env, session, requested) {
|
|
203
209
|
if (typeof requested !== "string" || !EFFORTS.has(requested)) return answerEffort(env);
|
|
204
210
|
if (requested === "low") return requested;
|
|
@@ -253,6 +259,7 @@ export {
|
|
|
253
259
|
roleModel,
|
|
254
260
|
answerEffort,
|
|
255
261
|
effortBudget,
|
|
262
|
+
generationSampling,
|
|
256
263
|
requestEffort,
|
|
257
264
|
DATASETS,
|
|
258
265
|
hasPermission,
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
tableRetyped,
|
|
34
34
|
toolNote,
|
|
35
35
|
verdictNote
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-VT5ZHCOC.js";
|
|
37
37
|
import {
|
|
38
38
|
NO_CONTEXT,
|
|
39
39
|
STAGE_NAMES,
|
|
@@ -76,18 +76,18 @@ import {
|
|
|
76
76
|
tokenBudget,
|
|
77
77
|
understandQuery,
|
|
78
78
|
usageTotal
|
|
79
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-SLYQ6L52.js";
|
|
80
80
|
import {
|
|
81
81
|
embed,
|
|
82
82
|
generateOnce
|
|
83
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-L32WSANI.js";
|
|
84
84
|
import {
|
|
85
85
|
corsHeaders,
|
|
86
86
|
err,
|
|
87
87
|
json,
|
|
88
88
|
readJson,
|
|
89
89
|
validateQuery
|
|
90
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-NHYYMRZC.js";
|
|
91
91
|
import {
|
|
92
92
|
cacheableAnswer,
|
|
93
93
|
canonicalRefusal,
|
|
@@ -100,7 +100,7 @@ import {
|
|
|
100
100
|
requestSalt,
|
|
101
101
|
resolveRequestScope,
|
|
102
102
|
standardKeysFrom
|
|
103
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-4BQA7PJ3.js";
|
|
104
104
|
import {
|
|
105
105
|
ESCALATION_DAILY_DEFAULT,
|
|
106
106
|
LIMITS,
|
|
@@ -108,11 +108,12 @@ import {
|
|
|
108
108
|
THRESHOLDS,
|
|
109
109
|
answerEffort,
|
|
110
110
|
effortBudget,
|
|
111
|
+
generationSampling,
|
|
111
112
|
num,
|
|
112
113
|
requestEffort,
|
|
113
114
|
roleModel,
|
|
114
115
|
sha256Hex
|
|
115
|
-
} from "./chunk-
|
|
116
|
+
} from "./chunk-4AP763GX.js";
|
|
116
117
|
import {
|
|
117
118
|
P
|
|
118
119
|
} from "./chunk-3FYJM7LH.js";
|
|
@@ -2296,8 +2297,7 @@ async function generateStream(env, model, messages, effort) {
|
|
|
2296
2297
|
stream: true,
|
|
2297
2298
|
max_tokens: effortBudget(effort ?? answerEffort(env)),
|
|
2298
2299
|
reasoning_effort: effort ?? answerEffort(env),
|
|
2299
|
-
|
|
2300
|
-
top_p: 0.95
|
|
2300
|
+
...generationSampling(model)
|
|
2301
2301
|
});
|
|
2302
2302
|
if (res && typeof res.getReader === "function") return res;
|
|
2303
2303
|
if (res && res.body && typeof res.body.getReader === "function") return res.body;
|
|
@@ -2318,13 +2318,14 @@ async function summarizeHistory(env, model, turns) {
|
|
|
2318
2318
|
},
|
|
2319
2319
|
{ role: "user", content: convo }
|
|
2320
2320
|
],
|
|
2321
|
-
|
|
2321
|
+
// reasoning tokens share this budget — DeepSeek-V4 needs 3072+ or
|
|
2322
|
+
// the summary is never reached
|
|
2323
|
+
max_tokens: model.includes("deepseek") ? 3072 : 2048,
|
|
2322
2324
|
reasoning_effort: "low",
|
|
2325
|
+
...generationSampling(model),
|
|
2323
2326
|
// Qwen3 thinking-mode sampling (model card) — prevents the
|
|
2324
2327
|
// repetition loops that eat the budget before the summary lands
|
|
2325
|
-
|
|
2326
|
-
top_p: 0.95,
|
|
2327
|
-
top_k: 20
|
|
2328
|
+
...model.includes("deepseek") ? {} : { top_k: 20 }
|
|
2328
2329
|
});
|
|
2329
2330
|
const text = typeof res?.response === "string" ? res.response : res?.choices?.[0]?.message?.content;
|
|
2330
2331
|
return typeof text === "string" && text.trim() ? text.trim().slice(0, 1200) : null;
|
|
@@ -6,24 +6,24 @@ import {
|
|
|
6
6
|
sessionFrom,
|
|
7
7
|
telemetry,
|
|
8
8
|
understandQuery
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-SLYQ6L52.js";
|
|
10
10
|
import {
|
|
11
11
|
corsHeaders,
|
|
12
12
|
err,
|
|
13
13
|
json,
|
|
14
14
|
readJson,
|
|
15
15
|
validateQuery
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-NHYYMRZC.js";
|
|
17
17
|
import {
|
|
18
18
|
entitlementScope,
|
|
19
19
|
standardKeysFrom
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-4BQA7PJ3.js";
|
|
21
21
|
import {
|
|
22
22
|
LIMITS,
|
|
23
23
|
MODELS,
|
|
24
24
|
num,
|
|
25
25
|
sha256Hex
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-4AP763GX.js";
|
|
27
27
|
import {
|
|
28
28
|
portModelRunner
|
|
29
29
|
} from "./chunk-YGQCVPX6.js";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
answerEffort,
|
|
3
|
-
effortBudget
|
|
4
|
-
|
|
3
|
+
effortBudget,
|
|
4
|
+
generationSampling
|
|
5
|
+
} from "./chunk-4AP763GX.js";
|
|
5
6
|
|
|
6
7
|
// workers/worker_public/src/ai.ts
|
|
7
8
|
var delay = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
@@ -35,8 +36,7 @@ async function generateOnce(env, model, messages, effort) {
|
|
|
35
36
|
messages,
|
|
36
37
|
max_tokens: effortBudget(effort ?? answerEffort(env)),
|
|
37
38
|
reasoning_effort: effort ?? answerEffort(env),
|
|
38
|
-
|
|
39
|
-
top_p: 0.95
|
|
39
|
+
...generationSampling(model)
|
|
40
40
|
}),
|
|
41
41
|
new Promise((r) => setTimeout(() => r(null), 12e4))
|
|
42
42
|
]);
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
embed,
|
|
3
3
|
rerank
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-L32WSANI.js";
|
|
5
5
|
import {
|
|
6
6
|
bubbleConfirmPage,
|
|
7
7
|
isAllowedBubbleOrigin
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-NHYYMRZC.js";
|
|
9
9
|
import {
|
|
10
10
|
DATASETS,
|
|
11
11
|
LIMITS,
|
|
12
12
|
MODELS,
|
|
13
13
|
THRESHOLDS,
|
|
14
|
+
generationSampling,
|
|
14
15
|
num,
|
|
15
16
|
processExpansion,
|
|
16
17
|
sha256Hex,
|
|
17
18
|
today
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-4AP763GX.js";
|
|
19
20
|
import {
|
|
20
21
|
P
|
|
21
22
|
} from "./chunk-3FYJM7LH.js";
|
|
@@ -24839,16 +24840,15 @@ async function understandQuery(ai, model, query, history, entities = []) {
|
|
|
24839
24840
|
],
|
|
24840
24841
|
// the model always reasons; reasoning tokens share this budget — too
|
|
24841
24842
|
// small and the JSON is never reached (understanding silently degrades).
|
|
24842
|
-
// GLM-5
|
|
24843
|
-
// not honored, so GLM needs
|
|
24844
|
-
max_tokens:
|
|
24843
|
+
// DeepSeek-V4 needs 3072+; GLM-5 defaults to reasoning_effort "max"
|
|
24844
|
+
// when the parameter is not honored, so GLM needs the same headroom.
|
|
24845
|
+
max_tokens: 3072,
|
|
24845
24846
|
reasoning_effort: "low",
|
|
24847
|
+
...generationSampling(model),
|
|
24846
24848
|
// Qwen3 thinking-mode sampling (model card): greedy/1.0 sampling
|
|
24847
24849
|
// degrades into repetition loops — the 10s/5s timeout nulls were the
|
|
24848
24850
|
// budget being eaten by loops, not by reasoning
|
|
24849
|
-
|
|
24850
|
-
top_p: 0.95,
|
|
24851
|
-
top_k: 20
|
|
24851
|
+
...model.includes("deepseek") ? {} : { top_k: 20 }
|
|
24852
24852
|
};
|
|
24853
24853
|
const ATTEMPT_TIMEOUTS = [1e4, 5e3];
|
|
24854
24854
|
for (let attempt2 = 0; attempt2 < ATTEMPT_TIMEOUTS.length; attempt2++) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
embed
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-L32WSANI.js";
|
|
4
4
|
import {
|
|
5
5
|
standardKeysFrom
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4BQA7PJ3.js";
|
|
7
7
|
import {
|
|
8
8
|
THRESHOLDS
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4AP763GX.js";
|
|
10
10
|
import {
|
|
11
11
|
P
|
|
12
12
|
} from "./chunk-3FYJM7LH.js";
|
package/dist/config.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
export declare const MODELS: {
|
|
2
2
|
readonly embed: "@cf/qwen/qwen3-embedding-0.6b";
|
|
3
3
|
readonly rerank: "@cf/baai/bge-reranker-base";
|
|
4
|
-
readonly anon: "@cf/
|
|
5
|
-
readonly member: "@cf/
|
|
6
|
-
readonly caption: "@cf/
|
|
4
|
+
readonly anon: "@cf/deepseek-ai/deepseek-v4.1-flash-1017";
|
|
5
|
+
readonly member: "@cf/deepseek-ai/deepseek-v4.1-flash-1017";
|
|
6
|
+
readonly caption: "@cf/deepseek-ai/deepseek-v4.1-flash-1017";
|
|
7
7
|
readonly visionJudge: "@cf/deepseek-ai/deepseek-v4.1-flash-1017";
|
|
8
8
|
readonly vlmFigure: "@cf/deepseek-ai/deepseek-v4.1-flash-1017";
|
|
9
9
|
readonly decisionsGate: "@cf/cloudflare/clef-flash";
|
|
10
10
|
readonly decisionsModel: "@cf/cloudflare/clef";
|
|
11
|
-
readonly understand: "@cf/
|
|
12
|
-
readonly acts: "@cf/
|
|
13
|
-
readonly fallback: "@cf/
|
|
14
|
-
readonly grader: "@cf/deepseek-ai/deepseek-v4-flash-
|
|
15
|
-
readonly enrich: "@cf/
|
|
11
|
+
readonly understand: "@cf/deepseek-ai/deepseek-v4.1-flash-1017";
|
|
12
|
+
readonly acts: "@cf/deepseek-ai/deepseek-v4.1-flash-1017";
|
|
13
|
+
readonly fallback: "@cf/deepseek-ai/deepseek-v4.1-flash-1017";
|
|
14
|
+
readonly grader: "@cf/deepseek-ai/deepseek-v4.1-flash-1017";
|
|
15
|
+
readonly enrich: "@cf/zai-org/glm-5.3";
|
|
16
16
|
readonly listwise: "@cf/zai-org/glm-4.7-flash";
|
|
17
17
|
readonly escalation: "@cf/deepseek-ai/deepseek-v4.1-flash-1017";
|
|
18
|
-
readonly research: "@cf/
|
|
19
|
-
readonly verifier: "@cf/zai-org/glm-5.
|
|
18
|
+
readonly research: "@cf/deepseek-ai/deepseek-v4.1-flash-1017";
|
|
19
|
+
readonly verifier: "@cf/zai-org/glm-5.3";
|
|
20
20
|
};
|
|
21
21
|
export declare const LIMITS: {
|
|
22
22
|
/** Attachment quotas (TODO.new-era/8): per-member ceilings so a member's
|
|
@@ -157,6 +157,13 @@ export declare function answerEffort(env: any): string;
|
|
|
157
157
|
* 2026-09-12: medium at the flat 3072 budget scored 5/38 on the golden
|
|
158
158
|
* set — empty answers — versus 37–38/38 at low). */
|
|
159
159
|
export declare function effortBudget(effort: string): number;
|
|
160
|
+
/** Sampling follows the model's card (the 2026-08-30/31 incidents): the
|
|
161
|
+
* DeepSeek-V4 family degrades under tight sampling (temp 1.0 / top_p 1.0);
|
|
162
|
+
* GLM and Qwen thinking modes take 0.6 / 0.95. */
|
|
163
|
+
export declare function generationSampling(model: string): {
|
|
164
|
+
temperature: number;
|
|
165
|
+
top_p: number;
|
|
166
|
+
};
|
|
160
167
|
export declare function requestEffort(env: any, session: unknown, requested: unknown): string;
|
|
161
168
|
/** The corpus catalog — single source for /api/datasets, the assistant's
|
|
162
169
|
* self-description, and per-corpus model guidance. `session: true`
|
package/dist/nameplate.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import { nameplateRegisterQuery, type Nameplate } from "./nameplate-parse.ts";
|
|
|
2
2
|
export type { Nameplate };
|
|
3
3
|
export { nameplateRegisterQuery };
|
|
4
4
|
export declare function extractNameplate(ai: any, model: string, image: string): Promise<Nameplate | null>;
|
|
5
|
-
export declare const nameplateModel: () => "@cf/
|
|
5
|
+
export declare const nameplateModel: () => "@cf/deepseek-ai/deepseek-v4.1-flash-1017";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
handleSearch
|
|
3
|
+
} from "./chunk-G435JWGV.js";
|
|
4
|
+
import "./chunk-SLYQ6L52.js";
|
|
5
|
+
import "./chunk-L32WSANI.js";
|
|
6
|
+
import "./chunk-NHYYMRZC.js";
|
|
7
|
+
import "./chunk-ETLSWSZ7.js";
|
|
8
|
+
import "./chunk-4BQA7PJ3.js";
|
|
9
|
+
import "./chunk-4AP763GX.js";
|
|
10
|
+
import "./chunk-3FYJM7LH.js";
|
|
11
|
+
import "./chunk-YGQCVPX6.js";
|
|
12
|
+
export {
|
|
13
|
+
handleSearch
|
|
14
|
+
};
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
parseToolCall,
|
|
5
5
|
runTool,
|
|
6
6
|
toolNote
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-VT5ZHCOC.js";
|
|
8
|
+
import "./chunk-L32WSANI.js";
|
|
9
|
+
import "./chunk-4BQA7PJ3.js";
|
|
10
|
+
import "./chunk-4AP763GX.js";
|
|
11
11
|
import "./chunk-3FYJM7LH.js";
|
|
12
12
|
import "./chunk-YGQCVPX6.js";
|
|
13
13
|
export {
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
datasetAllowed,
|
|
11
11
|
datasetsFor,
|
|
12
12
|
effortBudget,
|
|
13
|
+
generationSampling,
|
|
13
14
|
hasPermission,
|
|
14
15
|
num,
|
|
15
16
|
processExpansion,
|
|
@@ -17,7 +18,7 @@ import {
|
|
|
17
18
|
roleModel,
|
|
18
19
|
sha256Hex,
|
|
19
20
|
today
|
|
20
|
-
} from "../../chunk-
|
|
21
|
+
} from "../../chunk-4AP763GX.js";
|
|
21
22
|
import "../../chunk-3FYJM7LH.js";
|
|
22
23
|
export {
|
|
23
24
|
DATASETS,
|
|
@@ -31,6 +32,7 @@ export {
|
|
|
31
32
|
datasetAllowed,
|
|
32
33
|
datasetsFor,
|
|
33
34
|
effortBudget,
|
|
35
|
+
generationSampling,
|
|
34
36
|
hasPermission,
|
|
35
37
|
num,
|
|
36
38
|
processExpansion,
|
|
@@ -9,16 +9,16 @@ import {
|
|
|
9
9
|
listUserDocuments,
|
|
10
10
|
scoreFaithfulness,
|
|
11
11
|
scoreJudge
|
|
12
|
-
} from "../../chunk-
|
|
12
|
+
} from "../../chunk-A2HQNENL.js";
|
|
13
13
|
import "../../chunk-IRCDOFP4.js";
|
|
14
14
|
import {
|
|
15
15
|
TOOLS_REGISTRY,
|
|
16
16
|
bindModelNode,
|
|
17
17
|
modelGroundingBlock
|
|
18
|
-
} from "../../chunk-
|
|
18
|
+
} from "../../chunk-VT5ZHCOC.js";
|
|
19
19
|
import {
|
|
20
20
|
handleSearch
|
|
21
|
-
} from "../../chunk-
|
|
21
|
+
} from "../../chunk-G435JWGV.js";
|
|
22
22
|
import {
|
|
23
23
|
buildMessages,
|
|
24
24
|
citations,
|
|
@@ -43,11 +43,11 @@ import {
|
|
|
43
43
|
sessionFrom,
|
|
44
44
|
telemetry,
|
|
45
45
|
understandQuery
|
|
46
|
-
} from "../../chunk-
|
|
46
|
+
} from "../../chunk-SLYQ6L52.js";
|
|
47
47
|
import {
|
|
48
48
|
embed,
|
|
49
49
|
generateOnce
|
|
50
|
-
} from "../../chunk-
|
|
50
|
+
} from "../../chunk-L32WSANI.js";
|
|
51
51
|
import {
|
|
52
52
|
authenticate,
|
|
53
53
|
corsHeaders,
|
|
@@ -56,14 +56,14 @@ import {
|
|
|
56
56
|
readJson,
|
|
57
57
|
validateQuery,
|
|
58
58
|
withCors
|
|
59
|
-
} from "../../chunk-
|
|
59
|
+
} from "../../chunk-NHYYMRZC.js";
|
|
60
60
|
import {
|
|
61
61
|
canonicalRefusal
|
|
62
62
|
} from "../../chunk-ETLSWSZ7.js";
|
|
63
63
|
import {
|
|
64
64
|
entitlementScope,
|
|
65
65
|
standardKeysFrom
|
|
66
|
-
} from "../../chunk-
|
|
66
|
+
} from "../../chunk-4BQA7PJ3.js";
|
|
67
67
|
import {
|
|
68
68
|
LIMITS,
|
|
69
69
|
MODELS,
|
|
@@ -74,7 +74,7 @@ import {
|
|
|
74
74
|
roleModel,
|
|
75
75
|
sha256Hex,
|
|
76
76
|
today
|
|
77
|
-
} from "../../chunk-
|
|
77
|
+
} from "../../chunk-4AP763GX.js";
|
|
78
78
|
import {
|
|
79
79
|
P,
|
|
80
80
|
setProfile
|
|
@@ -1183,13 +1183,13 @@ async function callToolOnce(env, ctx, _req, tier, key, name, args, t0) {
|
|
|
1183
1183
|
// stream:false forces the JSON lane (anon defaults to SSE)
|
|
1184
1184
|
body: JSON.stringify({ ...args, stream: false })
|
|
1185
1185
|
});
|
|
1186
|
-
const { runTool, TOOLS_REGISTRY: TOOLS_REGISTRY2 } = await import("../../tools-
|
|
1186
|
+
const { runTool, TOOLS_REGISTRY: TOOLS_REGISTRY2 } = await import("../../tools-CYSL26HX.js");
|
|
1187
1187
|
let payload;
|
|
1188
1188
|
if (TOOLS_REGISTRY2.some((t) => t.name === name && t.audiences.includes("mcp"))) {
|
|
1189
1189
|
const r = await runTool({ ...env, DB: env.DB }, { name, args }, "mcp");
|
|
1190
1190
|
payload = r ? { tool: r.name, query: r.query, result: r.output } : { error: { message: `tool ${name} returned nothing for the given arguments` } };
|
|
1191
1191
|
} else {
|
|
1192
|
-
const res = name === "ask" ? await (await import("../../ask-
|
|
1192
|
+
const res = name === "ask" ? await (await import("../../ask-TJK7DQ45.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-FJAOGMEO.js")).handleSearch(env, ctx, inner, tier, key);
|
|
1193
1193
|
payload = await res.json().catch(() => ({ error: { message: "tool transport failed", status: res.status } }));
|
|
1194
1194
|
}
|
|
1195
1195
|
telemetry(env, ctx, tier, `mcp:${name}`, null, !payload?.error, JSON.stringify(payload).length, await sha256Hex(`${name}:${JSON.stringify(args ?? {})}`), void 0, void 0, { durationMs: Date.now() - t0 });
|
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
requestSalt,
|
|
5
5
|
resolveRequestScope,
|
|
6
6
|
standardKeysFrom
|
|
7
|
-
} from "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
7
|
+
} from "../../chunk-4BQA7PJ3.js";
|
|
8
|
+
import "../../chunk-4AP763GX.js";
|
|
9
9
|
import "../../chunk-3FYJM7LH.js";
|
|
10
10
|
export {
|
|
11
11
|
entitlementScope,
|
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"playwright": "^1.62.1",
|
|
28
28
|
"yaml": "^2.9.1"
|
|
29
29
|
},
|
|
30
|
-
"version": "0.2.
|
|
30
|
+
"version": "0.2.188",
|
|
31
31
|
"description": "The Konneal engine: the publisher-agnostic build pipeline and API plane for standards intelligence (retrieval, answer contract, verdicts, evaluation).",
|
|
32
32
|
"license": "BSD-3-Clause",
|
|
33
33
|
"type": "module",
|
|
@@ -27,7 +27,7 @@ export async function embed(ai: ModelRunner, _model: string, text: string): Prom
|
|
|
27
27
|
throw new Error(`embed failed after retries: ${String(lastError)}`);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
import { answerEffort, effortBudget } from "./config.ts";
|
|
30
|
+
import { answerEffort, effortBudget, generationSampling } from "./config.ts";
|
|
31
31
|
|
|
32
32
|
export async function rerank(
|
|
33
33
|
ai: AnyAi,
|
|
@@ -62,8 +62,7 @@ export async function generateOnce(env: any, model: string, messages: any[], eff
|
|
|
62
62
|
messages,
|
|
63
63
|
max_tokens: effortBudget(effort ?? answerEffort(env)),
|
|
64
64
|
reasoning_effort: effort ?? answerEffort(env),
|
|
65
|
-
|
|
66
|
-
top_p: 0.95,
|
|
65
|
+
...generationSampling(model),
|
|
67
66
|
}),
|
|
68
67
|
new Promise<null>((r) => setTimeout(() => r(null), 120_000)),
|
|
69
68
|
]);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// echo — everything between "request validated" and "response written".
|
|
4
4
|
// index.ts routes here; this module owns the answer contract.
|
|
5
5
|
|
|
6
|
-
import { LIMITS, MODELS, THRESHOLDS, num, sha256Hex, roleModel, answerEffort, requestEffort, effortBudget } from "./config";
|
|
6
|
+
import { LIMITS, MODELS, THRESHOLDS, num, sha256Hex, roleModel, answerEffort, requestEffort, effortBudget, generationSampling } from "./config";
|
|
7
7
|
import { portModelRunner } from "./env.ts";
|
|
8
8
|
import { refCodec } from "./codecs";
|
|
9
9
|
import { buildMessages, citations, fill, promptVars, retrieve, retrievalQuery, identityNote, splitHistory, listwiseRerank, refusalAnswer, Hit } from "./pipeline";
|
|
@@ -227,8 +227,7 @@ async function generateStream(env: Env, model: string, messages: any[], effort?:
|
|
|
227
227
|
stream: true,
|
|
228
228
|
max_tokens: effortBudget(effort ?? answerEffort(env)),
|
|
229
229
|
reasoning_effort: effort ?? answerEffort(env),
|
|
230
|
-
|
|
231
|
-
top_p: 0.95,
|
|
230
|
+
...generationSampling(model),
|
|
232
231
|
});
|
|
233
232
|
if (res && typeof res.getReader === "function") return res as ReadableStream<Uint8Array>;
|
|
234
233
|
if (res && res.body && typeof res.body.getReader === "function") return res.body;
|
|
@@ -259,13 +258,14 @@ async function summarizeHistory(
|
|
|
259
258
|
},
|
|
260
259
|
{ role: "user", content: convo },
|
|
261
260
|
],
|
|
262
|
-
|
|
261
|
+
// reasoning tokens share this budget — DeepSeek-V4 needs 3072+ or
|
|
262
|
+
// the summary is never reached
|
|
263
|
+
max_tokens: model.includes("deepseek") ? 3072 : 2048,
|
|
263
264
|
reasoning_effort: "low",
|
|
265
|
+
...generationSampling(model),
|
|
264
266
|
// Qwen3 thinking-mode sampling (model card) — prevents the
|
|
265
267
|
// repetition loops that eat the budget before the summary lands
|
|
266
|
-
|
|
267
|
-
top_p: 0.95,
|
|
268
|
-
top_k: 20,
|
|
268
|
+
...(model.includes("deepseek") ? {} : { top_k: 20 }),
|
|
269
269
|
});
|
|
270
270
|
const text = typeof res?.response === "string" ? res.response : res?.choices?.[0]?.message?.content;
|
|
271
271
|
return typeof text === "string" && text.trim() ? text.trim().slice(0, 1200) : null;
|
|
@@ -1,50 +1,60 @@
|
|
|
1
1
|
import { P } from "./profile.ts";
|
|
2
2
|
|
|
3
|
+
// Cloudflare deprecated glm-5.3-flash, glm-5.2, qwen3-30b-a3b-fp8,
|
|
4
|
+
// deepseek-v4-flash-0731 and deepseek-v4-pro-0813 on 2026-11-20 (HTTP 410)
|
|
5
|
+
// and every generation role died with them. Owner decision 2026-12-03:
|
|
6
|
+
// deepseek-v4.1-flash-1017 carries the generation roles — natively
|
|
7
|
+
// multimodal, 1M ctx, reasoning none/low/high/max with HIGH as the default,
|
|
8
|
+
// so every call site states its effort explicitly.
|
|
9
|
+
const FLASH = "@cf/deepseek-ai/deepseek-v4.1-flash-1017";
|
|
10
|
+
|
|
3
11
|
export const MODELS = {
|
|
4
12
|
embed: "@cf/qwen/qwen3-embedding-0.6b", rerank: "@cf/baai/bge-reranker-base",
|
|
5
|
-
// ANSWER MODEL (all tiers
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
anon: "@cf/zai-org/glm-5.3-flash",
|
|
9
|
-
member: "@cf/zai-org/glm-5.3-flash",
|
|
13
|
+
// ANSWER MODEL (all tiers): natively multimodal (vision-unified contract)
|
|
14
|
+
anon: FLASH,
|
|
15
|
+
member: FLASH,
|
|
10
16
|
// figure captions + the vision lane (one-time, quality-first; the A/B
|
|
11
17
|
// lever is CAPTION_MODEL, the per-request arm is the admin route's
|
|
12
|
-
// body.model)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
//
|
|
20
|
-
|
|
18
|
+
// body.model). It emptied on 8/24 figure images in the 2026-10-27 A/B —
|
|
19
|
+
// those captions fall to the serve-raw path.
|
|
20
|
+
caption: FLASH,
|
|
21
|
+
// the pairwise vision judge (sees the image; a THIRD model never judges
|
|
22
|
+
// its own arm) — no other live multimodal model exists in the policy
|
|
23
|
+
// line, so a v4.1 caption arm is judged by its own family
|
|
24
|
+
visionJudge: FLASH,
|
|
25
|
+
// the VLM figure rerank (TODO.sota/18.3): a vision-capable MoE scores
|
|
26
|
+
// figure IMAGES against figure-seeking questions — one bounded call per
|
|
27
|
+
// figure question, ablatable stage
|
|
28
|
+
vlmFigure: FLASH,
|
|
21
29
|
// the decision pass (TODO.decisions/01): clef-flash gates the
|
|
22
30
|
// requirement-shaped questions, clef decides the derived checklist
|
|
23
31
|
decisionsGate: "@cf/cloudflare/clef-flash",
|
|
24
32
|
decisionsModel: "@cf/cloudflare/clef",
|
|
25
|
-
// hot-path understanding/summarize
|
|
26
|
-
understand:
|
|
33
|
+
// hot-path understanding/summarize (cost-first lane)
|
|
34
|
+
understand: FLASH,
|
|
27
35
|
// the api_call act's intent-to-act mapping (TODO.ai-platform/09) — the
|
|
28
36
|
// operations deployment points ACTS_MODEL at the stronger reasoning
|
|
29
37
|
// tier; the floor is the understand lane
|
|
30
|
-
acts:
|
|
31
|
-
// generation fallback when the answer model is unavailable
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
acts: FLASH,
|
|
39
|
+
// generation fallback when the answer model is unavailable — the same
|
|
40
|
+
// model as the primary while it is the only live cheap option: the
|
|
41
|
+
// retry inside generateOnce is the only diversity this lane has
|
|
42
|
+
fallback: FLASH,
|
|
43
|
+
grader: FLASH, // CRAG grader + judges
|
|
34
44
|
// contextual enrichment is the QUALITY-FIRST lane (one-time spend over
|
|
35
45
|
// the corpus, its quality persists into every future retrieval)
|
|
36
|
-
enrich: "@cf/
|
|
46
|
+
enrich: "@cf/zai-org/glm-5.3",
|
|
37
47
|
// final-tier listwise reranker for hard/member queries (cascade:
|
|
38
48
|
// cross-encoder prunes, listwise orders jointly)
|
|
39
49
|
listwise: "@cf/zai-org/glm-4.7-flash",
|
|
40
50
|
// deep-research loop (G10): bounded agentic iterations, members-only
|
|
41
|
-
escalation:
|
|
42
|
-
research:
|
|
51
|
+
escalation: FLASH,
|
|
52
|
+
research: FLASH,
|
|
43
53
|
// speculative draft-verify (TODO.sota/02 row 2): the strong verifier
|
|
44
54
|
// over the cheap drafts — the research-tier model verifies; the drafter
|
|
45
55
|
// is the standard answer model (MODELS.member). VERIFIER_MODEL swaps it
|
|
46
56
|
// live, same lever as every role.
|
|
47
|
-
verifier: "@cf/zai-org/glm-5.
|
|
57
|
+
verifier: "@cf/zai-org/glm-5.3",
|
|
48
58
|
} as const;
|
|
49
59
|
|
|
50
60
|
export const LIMITS = {
|
|
@@ -224,6 +234,13 @@ export function effortBudget(effort: string): number {
|
|
|
224
234
|
return LIMITS.maxOutputTokens;
|
|
225
235
|
}
|
|
226
236
|
|
|
237
|
+
/** Sampling follows the model's card (the 2026-08-30/31 incidents): the
|
|
238
|
+
* DeepSeek-V4 family degrades under tight sampling (temp 1.0 / top_p 1.0);
|
|
239
|
+
* GLM and Qwen thinking modes take 0.6 / 0.95. */
|
|
240
|
+
export function generationSampling(model: string): { temperature: number; top_p: number } {
|
|
241
|
+
return model.includes("deepseek") ? { temperature: 1.0, top_p: 1.0 } : { temperature: 0.6, top_p: 0.95 };
|
|
242
|
+
}
|
|
243
|
+
|
|
227
244
|
export function requestEffort(env: any, session: unknown, requested: unknown): string {
|
|
228
245
|
if (typeof requested !== "string" || !EFFORTS.has(requested)) return answerEffort(env);
|
|
229
246
|
if (requested === "low") return requested;
|
|
@@ -11,6 +11,7 @@ export type { QueryUnderstanding };
|
|
|
11
11
|
// The prompt is data (prompts/understanding.md), bundled as text.
|
|
12
12
|
import SYSTEM from "../prompts/understanding.md";
|
|
13
13
|
import { fill, promptVars } from "./pipeline.ts";
|
|
14
|
+
import { generationSampling } from "./config.ts";
|
|
14
15
|
|
|
15
16
|
/** Understand the query with the cheap model. Null = use the regex fallback. */
|
|
16
17
|
export async function understandQuery(
|
|
@@ -35,16 +36,15 @@ export async function understandQuery(
|
|
|
35
36
|
],
|
|
36
37
|
// the model always reasons; reasoning tokens share this budget — too
|
|
37
38
|
// small and the JSON is never reached (understanding silently degrades).
|
|
38
|
-
// GLM-5
|
|
39
|
-
// not honored, so GLM needs
|
|
40
|
-
max_tokens:
|
|
39
|
+
// DeepSeek-V4 needs 3072+; GLM-5 defaults to reasoning_effort "max"
|
|
40
|
+
// when the parameter is not honored, so GLM needs the same headroom.
|
|
41
|
+
max_tokens: 3072,
|
|
41
42
|
reasoning_effort: "low",
|
|
43
|
+
...generationSampling(model),
|
|
42
44
|
// Qwen3 thinking-mode sampling (model card): greedy/1.0 sampling
|
|
43
45
|
// degrades into repetition loops — the 10s/5s timeout nulls were the
|
|
44
46
|
// budget being eaten by loops, not by reasoning
|
|
45
|
-
|
|
46
|
-
top_p: 0.95,
|
|
47
|
-
top_k: 20,
|
|
47
|
+
...(model.includes("deepseek") ? {} : { top_k: 20 }),
|
|
48
48
|
};
|
|
49
49
|
// each attempt issues a FRESH call — re-racing a timed-out promise would
|
|
50
50
|
// retry nothing. Generous first attempt: reasoning + the full JSON must
|
package/dist/ask-O7HJIZPK.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
handleAsk
|
|
3
|
-
} from "./chunk-IDQND3AA.js";
|
|
4
|
-
import "./chunk-IRCDOFP4.js";
|
|
5
|
-
import "./chunk-BMODSEKT.js";
|
|
6
|
-
import "./chunk-RBRBQJYT.js";
|
|
7
|
-
import "./chunk-BAOKHV2D.js";
|
|
8
|
-
import "./chunk-TLPUJMAF.js";
|
|
9
|
-
import "./chunk-ETLSWSZ7.js";
|
|
10
|
-
import "./chunk-MZQEI4VJ.js";
|
|
11
|
-
import "./chunk-IZ3GSYMD.js";
|
|
12
|
-
import "./chunk-3FYJM7LH.js";
|
|
13
|
-
import "./chunk-YGQCVPX6.js";
|
|
14
|
-
export {
|
|
15
|
-
handleAsk
|
|
16
|
-
};
|
package/dist/search-3H2ENWHQ.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
handleSearch
|
|
3
|
-
} from "./chunk-VDFOVWE6.js";
|
|
4
|
-
import "./chunk-RBRBQJYT.js";
|
|
5
|
-
import "./chunk-BAOKHV2D.js";
|
|
6
|
-
import "./chunk-TLPUJMAF.js";
|
|
7
|
-
import "./chunk-ETLSWSZ7.js";
|
|
8
|
-
import "./chunk-MZQEI4VJ.js";
|
|
9
|
-
import "./chunk-IZ3GSYMD.js";
|
|
10
|
-
import "./chunk-3FYJM7LH.js";
|
|
11
|
-
import "./chunk-YGQCVPX6.js";
|
|
12
|
-
export {
|
|
13
|
-
handleSearch
|
|
14
|
-
};
|