@konneal/engine 0.2.187 → 0.2.189
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/ai.d.ts +7 -0
- package/dist/ask-LPNODCPM.js +16 -0
- package/dist/{chunk-IZ3GSYMD.js → chunk-22WB6IVC.js} +35 -30
- package/dist/{chunk-VDFOVWE6.js → chunk-5PKKAHY4.js} +5 -5
- package/dist/{chunk-MZQEI4VJ.js → chunk-7YMIUTPY.js} +1 -1
- package/dist/{chunk-BAOKHV2D.js → chunk-AVNHVFEB.js} +29 -6
- package/dist/{chunk-BMODSEKT.js → chunk-ECNBEZGK.js} +5 -5
- package/dist/{chunk-IDQND3AA.js → chunk-FCRTWZQE.js} +128 -31
- package/dist/{chunk-TLPUJMAF.js → chunk-GJQT4IMD.js} +1 -1
- package/dist/{chunk-YGQCVPX6.js → chunk-H6ZULBW2.js} +4 -1
- package/dist/{chunk-RBRBQJYT.js → chunk-Q7QL3457.js} +58 -44
- package/dist/config.d.ts +17 -11
- package/dist/context.d.ts +14 -0
- package/dist/docOverview.d.ts +35 -0
- package/dist/{env-BZWHCSCL.js → env-4LR6Y5CC.js} +1 -1
- package/dist/nameplate.d.ts +1 -1
- package/dist/prompts/understanding.md +2 -1
- package/dist/reflect.d.ts +1 -1
- package/dist/search-DE5ADCVM.js +14 -0
- package/dist/{tools-VMZSXLXM.js → tools-7GKMDWVB.js} +5 -5
- package/dist/understandContract.d.ts +3 -0
- 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 +11 -11
- package/dist/worker_public/src/requestScope.js +2 -2
- package/package.json +1 -1
- package/workers/worker_public/prompts/understanding.md +2 -1
- package/workers/worker_public/src/ai.ts +32 -9
- package/workers/worker_public/src/ask.ts +90 -23
- package/workers/worker_public/src/config.ts +44 -29
- package/workers/worker_public/src/context.ts +14 -0
- package/workers/worker_public/src/docOverview.ts +77 -0
- package/workers/worker_public/src/faithfulness.ts +11 -1
- package/workers/worker_public/src/lexical.ts +21 -19
- package/workers/worker_public/src/ports/cloudflare/adapters.ts +4 -2
- package/workers/worker_public/src/reflect.ts +8 -7
- package/workers/worker_public/src/stages/dense.ts +29 -42
- package/workers/worker_public/src/stages/glossary.ts +1 -1
- package/workers/worker_public/src/stages/rerank.ts +6 -2
- package/workers/worker_public/src/understand.ts +6 -6
- package/workers/worker_public/src/understandContract.ts +4 -0
- package/dist/ask-O7HJIZPK.js +0 -16
- package/dist/search-3H2ENWHQ.js +0 -14
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
embed,
|
|
3
3
|
rerank
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-AVNHVFEB.js";
|
|
5
5
|
import {
|
|
6
6
|
bubbleConfirmPage,
|
|
7
7
|
isAllowedBubbleOrigin
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-GJQT4IMD.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-22WB6IVC.js";
|
|
19
20
|
import {
|
|
20
21
|
P
|
|
21
22
|
} from "./chunk-3FYJM7LH.js";
|
|
@@ -25,7 +26,7 @@ import {
|
|
|
25
26
|
portIndex,
|
|
26
27
|
portModelRunner,
|
|
27
28
|
portStore
|
|
28
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-H6ZULBW2.js";
|
|
29
30
|
|
|
30
31
|
// node_modules/@pubid/pubid/dist/grammar/engine.js
|
|
31
32
|
var ParseFailed = class extends Error {
|
|
@@ -21865,6 +21866,10 @@ function matchesDocScope(meta, scopeDocNumber) {
|
|
|
21865
21866
|
const last = stem.split(/\s+/).pop()?.toLowerCase();
|
|
21866
21867
|
return last === scopeDocNumber.toLowerCase();
|
|
21867
21868
|
}
|
|
21869
|
+
function docScopeFilter(scopeDocNumber) {
|
|
21870
|
+
const base = scopeDocNumber.split("-")[0];
|
|
21871
|
+
return { doc_number: { $in: base === scopeDocNumber ? [scopeDocNumber] : [scopeDocNumber, base] } };
|
|
21872
|
+
}
|
|
21868
21873
|
async function resolveDocScope(env, ctx) {
|
|
21869
21874
|
if (!ctx.doc) return null;
|
|
21870
21875
|
const parsed = parseDocRef(ctx.doc, ctx.edition);
|
|
@@ -21929,6 +21934,7 @@ function syntheticUnderstanding(scope) {
|
|
|
21929
21934
|
edition: scope.edition ?? null,
|
|
21930
21935
|
language: null,
|
|
21931
21936
|
process_intent: false,
|
|
21937
|
+
doc_overview: false,
|
|
21932
21938
|
term: null,
|
|
21933
21939
|
defined_terms: [],
|
|
21934
21940
|
standalone_query: "",
|
|
@@ -22051,26 +22057,25 @@ function rowMeta(r) {
|
|
|
22051
22057
|
block: String(r.block ?? "") || void 0
|
|
22052
22058
|
};
|
|
22053
22059
|
}
|
|
22060
|
+
function lexicalScore(rank) {
|
|
22061
|
+
const bm25 = typeof rank === "number" && Number.isFinite(rank) ? rank : 0;
|
|
22062
|
+
const strength = Math.abs(bm25);
|
|
22063
|
+
return 0.5 * strength / (1 + strength);
|
|
22064
|
+
}
|
|
22054
22065
|
function rowsToHits(rows) {
|
|
22055
|
-
return rows.map((r) => {
|
|
22056
|
-
|
|
22057
|
-
|
|
22058
|
-
|
|
22059
|
-
|
|
22060
|
-
|
|
22061
|
-
text: String(r.text ?? "")
|
|
22062
|
-
};
|
|
22063
|
-
});
|
|
22066
|
+
return rows.map((r) => ({
|
|
22067
|
+
id: String(r.id),
|
|
22068
|
+
score: lexicalScore(r.rank),
|
|
22069
|
+
metadata: rowMeta(r),
|
|
22070
|
+
text: String(r.text ?? "")
|
|
22071
|
+
}));
|
|
22064
22072
|
}
|
|
22065
22073
|
function rowsToMatches(rows) {
|
|
22066
|
-
return rows.map((r) => {
|
|
22067
|
-
|
|
22068
|
-
|
|
22069
|
-
|
|
22070
|
-
|
|
22071
|
-
metadata: { ...rowMeta(r), chunk_text: String(r.text ?? "") }
|
|
22072
|
-
};
|
|
22073
|
-
});
|
|
22074
|
+
return rows.map((r) => ({
|
|
22075
|
+
id: String(r.id),
|
|
22076
|
+
score: lexicalScore(r.rank),
|
|
22077
|
+
metadata: { ...rowMeta(r), chunk_text: String(r.text ?? "") }
|
|
22078
|
+
}));
|
|
22074
22079
|
}
|
|
22075
22080
|
async function lexicalWithin(env, query, docNumbers, k = 12) {
|
|
22076
22081
|
const match2 = ftsMatchQuery(query);
|
|
@@ -22159,25 +22164,28 @@ var dense = {
|
|
|
22159
22164
|
}
|
|
22160
22165
|
if (filters?.doc_number) {
|
|
22161
22166
|
const allMatches = (await env.VECTORIZE.query(vector, q)).matches ?? [];
|
|
22162
|
-
|
|
22163
|
-
|
|
22164
|
-
|
|
22165
|
-
if (filters.edition) matches = matches.filter((m) => !m.metadata?.edition || String(m.metadata.edition) === filters.edition);
|
|
22166
|
-
console.log("dense scope (in code):", before, "\u2192", matches.length, "in doc", filters.doc_number, filters.edition ? `@${filters.edition}` : "");
|
|
22167
|
-
if (!matches.length) {
|
|
22167
|
+
const before = allMatches.length;
|
|
22168
|
+
let docMatches = allMatches.filter((m) => matchesDocScope(m.metadata ?? {}, filters.doc_number));
|
|
22169
|
+
if (docMatches.length < LIMITS.rerankKeep) {
|
|
22168
22170
|
try {
|
|
22169
|
-
const
|
|
22170
|
-
|
|
22171
|
-
|
|
22171
|
+
const own = await env.VECTORIZE.query(vector, { ...q, filter: docScopeFilter(filters.doc_number) });
|
|
22172
|
+
const ownMatches = (own.matches ?? []).filter((m) => matchesDocScope(m.metadata ?? {}, filters.doc_number));
|
|
22173
|
+
const seen = new Set(docMatches.map((m) => m.id));
|
|
22174
|
+
const added = ownMatches.filter((m) => !seen.has(m.id));
|
|
22175
|
+
if (added.length) {
|
|
22176
|
+
docMatches = [...docMatches, ...added];
|
|
22177
|
+
console.log("dense scope sparse \u2192 native doc filter:", docMatches.length, "doc members");
|
|
22178
|
+
}
|
|
22172
22179
|
} catch (e) {
|
|
22173
22180
|
console.log("dense scope starvation re-query failed:", String(e).slice(0, 120));
|
|
22174
22181
|
}
|
|
22175
22182
|
}
|
|
22183
|
+
let matches = filters.edition ? docMatches.filter((m) => !m.metadata?.edition || String(m.metadata.edition) === filters.edition) : docMatches;
|
|
22184
|
+
console.log("dense scope (in code):", before, "\u2192", matches.length, "in doc", filters.doc_number, filters.edition ? `@${filters.edition}` : "");
|
|
22176
22185
|
if (filters && filters.edition && matches.length < 3) {
|
|
22177
|
-
|
|
22178
|
-
|
|
22179
|
-
|
|
22180
|
-
matches = docOnly;
|
|
22186
|
+
if (docMatches.length > matches.length) {
|
|
22187
|
+
console.log("edition pin dropped:", filters.doc_number, "@", filters.edition, "\u2192", docMatches.length, "doc-scoped hits (edition not in corpus)");
|
|
22188
|
+
matches = docMatches;
|
|
22181
22189
|
filters.edition = void 0;
|
|
22182
22190
|
}
|
|
22183
22191
|
}
|
|
@@ -22336,7 +22344,7 @@ var glossary = {
|
|
|
22336
22344
|
definition: String(m.metadata?.chunk_text ?? "").split(" \u2014 ").slice(1).join(" \u2014 ").slice(0, 300),
|
|
22337
22345
|
docidentifier: String(m.metadata?.docidentifier ?? ""),
|
|
22338
22346
|
doc_number: String(m.metadata?.doc_number ?? ""),
|
|
22339
|
-
score: rs ? rs[i] : m.score
|
|
22347
|
+
score: rs && Number.isFinite(rs[i]) ? rs[i] : m.score
|
|
22340
22348
|
})).filter((x) => x.term && x.definition);
|
|
22341
22349
|
})();
|
|
22342
22350
|
},
|
|
@@ -22926,11 +22934,15 @@ var rerankStage = {
|
|
|
22926
22934
|
const scores = await rerank(portModelRunner(c.env), MODELS.rerank, c.query, c.hits.map((h) => h.text));
|
|
22927
22935
|
console.log("stage: rerank", Date.now() - tRerank, "ms over", c.hits.length, "candidates");
|
|
22928
22936
|
if (scores) {
|
|
22929
|
-
|
|
22937
|
+
const finite = scores.filter((s8) => Number.isFinite(s8));
|
|
22938
|
+
const minFinite = finite.length ? Math.min(...finite) : 0;
|
|
22939
|
+
const span = finite.length ? Math.max(...finite) - minFinite : 0;
|
|
22940
|
+
const floor = minFinite - Math.max(0.01, span);
|
|
22941
|
+
c.hits.forEach((h, i) => h.rerank_score = Number.isFinite(scores[i]) ? scores[i] : floor);
|
|
22930
22942
|
c.hits.sort((a, b) => (b.rerank_score ?? -Infinity) - (a.rerank_score ?? -Infinity));
|
|
22931
22943
|
if (c.filter?.doc_number) {
|
|
22932
22944
|
const families = c.hits.filter((h) => h.metadata.clause_anchor === "family" && String(h.metadata.doc_number ?? "").split("-")[0] === String(c.filter.doc_number).split("-")[0]);
|
|
22933
|
-
const own = families.length ? families : c.hits.filter((h) => String(h.metadata.doc_number ?? "") === String(c.filter.doc_number).split("-")[0] && /^(overview|)$/i.test(String(h.metadata.clause_anchor ?? "")));
|
|
22945
|
+
const own = families.length ? families : c.hits.filter((h) => h.text.trim().length > 0 && h.metadata.doctype !== "certificate" && String(h.metadata.doc_number ?? "") === String(c.filter.doc_number).split("-")[0] && /^(overview|)$/i.test(String(h.metadata.clause_anchor ?? "")));
|
|
22934
22946
|
if (own.length) {
|
|
22935
22947
|
const ownIds = new Set(own.map((h) => h.id));
|
|
22936
22948
|
c.hits = [...own, ...c.hits.filter((h) => !ownIds.has(h.id))];
|
|
@@ -24789,6 +24801,7 @@ function extractJson(text) {
|
|
|
24789
24801
|
edition: typeof raw.edition === "string" && /^\d{4}$/.test(raw.edition) ? raw.edition : null,
|
|
24790
24802
|
language: typeof raw.language === "string" && /^[a-z]{2}$/.test(raw.language) ? raw.language : null,
|
|
24791
24803
|
process_intent: raw.process_intent === true,
|
|
24804
|
+
doc_overview: raw.doc_overview === true,
|
|
24792
24805
|
term: typeof raw.term === "string" && raw.term.trim() ? raw.term.trim().slice(0, 60) : null,
|
|
24793
24806
|
defined_terms: Array.isArray(raw.defined_terms) ? raw.defined_terms.filter((t) => typeof t === "string" && t.trim()).map((t) => t.trim().slice(0, 60)).slice(0, 4) : [],
|
|
24794
24807
|
standalone_query: typeof raw.standalone_query === "string" && raw.standalone_query.trim() ? raw.standalone_query.trim().slice(0, 400) : "",
|
|
@@ -24807,12 +24820,13 @@ function extractJson(text) {
|
|
|
24807
24820
|
// workers/worker_public/prompts/understanding.md
|
|
24808
24821
|
var understanding_default = `You normalize a user question for a retrieval system over {{CORPUS_KIND_PLURAL}} (English corpus).
|
|
24809
24822
|
Reply with ONLY a JSON object, no prose, no markdown fence:
|
|
24810
|
-
{"intent": "knowledge", "docidentifier": "{{DOCID_EXAMPLE}}" | null, "docnumber": "76" | null, "edition": "2021" | null, "language": "en" | null, "process_intent": true | false, "term": "accuracy class" | null, "defined_terms": [], "standalone_query": "...", "complexity": "simple", "query_variants": [], "sub_queries": [], "hypothetical_answer": "...", "follow_ups": []}
|
|
24823
|
+
{"intent": "knowledge", "docidentifier": "{{DOCID_EXAMPLE}}" | null, "docnumber": "76" | null, "edition": "2021" | null, "language": "en" | null, "process_intent": true | false, "doc_overview": true | false, "term": "accuracy class" | null, "defined_terms": [], "standalone_query": "...", "complexity": "simple", "query_variants": [], "sub_queries": [], "hypothetical_answer": "...", "follow_ups": []}
|
|
24811
24824
|
Rules:
|
|
24812
24825
|
- intent: "conversational" ONLY when the latest message is about the assistant or this service itself (who you are, which model you are, what you can do, how you work) or is a pure social nicety (greeting, thanks, farewell, small talk) \u2014 e.g. "hi!", "who are you?", "what can you do?", "merci !", "was kannst du?". ANY question about a subject \u2014 legal metrology, other technical fields, cooking, sports, current events, ANYTHING \u2014 is "knowledge", even when the corpus cannot answer it; do NOT use "conversational" to mean off-topic.
|
|
24813
24826
|
- docidentifier: the publication the user names, in any spelling ({{SPELLING_EXAMPLES}}, "the nonautomatic weighing instruments recommendation" \u2192 resolve to the {{PUBLISHER_NAME}} identifier you can infer; include the part ("-1", "-2") only when clearly meant). docnumber is the base number without part.
|
|
24814
24827
|
- edition: only when the user pins a year.
|
|
24815
24828
|
- language: only when the user asks for a specific answer language; otherwise null (the corpus is English; answering in the user's language is handled elsewhere).
|
|
24829
|
+
- doc_overview: true ONLY when the question asks what the NAMED publication is or covers as a whole \u2014 an overview, purpose, scope or summary of the document itself ("what is R 60", "describe OIML D 11", "give me an overview of R 76-1") \u2014 and docidentifier is set. false for anything inside it (a requirement, value, term, test, table or citation question: "what is the MPE in R 76-1" \u2192 false), and false when no publication is named.
|
|
24816
24830
|
- citation questions ("what does X cite/reference/list?", "which standards does X reference?"): ALWAYS include a query variant that names the document's bibliography or normative-references section explicitly, WITHOUT edition scoping (e.g. for "What ISO standards does R 60 cite?" generate BOTH "R 60 bibliography normative references" AND "R 60 2017 bibliography ISO IEC") \u2014 bibliographies embed differently than the query's phrasing, and prior editions may carry references the current edition dropped; set edition to null for these queries so retrieval covers the whole family.
|
|
24817
24831
|
- process_intent: true when the question is about the GOVERNING SYSTEM around publications rather than a publication's own technical content \u2014 HOW to get certified/apply/comply, OR which framework/vocabulary/{{PROCESS_VOCAB}}. Naming a Recommendation (e.g. "R 60") inside such a question does NOT make it a technical-content question: leave process_intent true and still emit docnumber when named, but the retrieval path must NOT seal to that document alone.
|
|
24818
24832
|
- term: the defined term when the question asks what something is ("what is an accuracy class" \u2192 "accuracy class"); otherwise null.
|
|
@@ -24839,16 +24853,15 @@ async function understandQuery(ai, model, query, history, entities = []) {
|
|
|
24839
24853
|
],
|
|
24840
24854
|
// the model always reasons; reasoning tokens share this budget — too
|
|
24841
24855
|
// small and the JSON is never reached (understanding silently degrades).
|
|
24842
|
-
// GLM-5
|
|
24843
|
-
// not honored, so GLM needs
|
|
24844
|
-
max_tokens:
|
|
24856
|
+
// DeepSeek-V4 needs 3072+; GLM-5 defaults to reasoning_effort "max"
|
|
24857
|
+
// when the parameter is not honored, so GLM needs the same headroom.
|
|
24858
|
+
max_tokens: 3072,
|
|
24845
24859
|
reasoning_effort: "low",
|
|
24860
|
+
...generationSampling(model),
|
|
24846
24861
|
// Qwen3 thinking-mode sampling (model card): greedy/1.0 sampling
|
|
24847
24862
|
// degrades into repetition loops — the 10s/5s timeout nulls were the
|
|
24848
24863
|
// budget being eaten by loops, not by reasoning
|
|
24849
|
-
|
|
24850
|
-
top_p: 0.95,
|
|
24851
|
-
top_k: 20
|
|
24864
|
+
...model.includes("deepseek") ? {} : { top_k: 20 }
|
|
24852
24865
|
};
|
|
24853
24866
|
const ATTEMPT_TIMEOUTS = [1e4, 5e3];
|
|
24854
24867
|
for (let attempt2 = 0; attempt2 < ATTEMPT_TIMEOUTS.length; attempt2++) {
|
|
@@ -24993,6 +25006,7 @@ export {
|
|
|
24993
25006
|
machineOffers,
|
|
24994
25007
|
parseContext,
|
|
24995
25008
|
namedDocumentIn,
|
|
25009
|
+
matchesDocScope,
|
|
24996
25010
|
resolveDocScope,
|
|
24997
25011
|
appliedContext,
|
|
24998
25012
|
parseAppliedContext,
|
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/zai-org/glm-5.3";
|
|
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
|
|
@@ -56,7 +56,6 @@ export declare const THRESHOLDS: {
|
|
|
56
56
|
* not only the source rung. Fails open (a slow or unparseable check
|
|
57
57
|
* leaves the source-rung note unchanged). */
|
|
58
58
|
readonly compressShare: 0.6;
|
|
59
|
-
readonly denseStarveK: 100;
|
|
60
59
|
readonly decisionsGateMin: 0.5;
|
|
61
60
|
readonly decisionsMetBand: 0.8;
|
|
62
61
|
readonly decisionsRefuteBand: 0.2;
|
|
@@ -157,6 +156,13 @@ export declare function answerEffort(env: any): string;
|
|
|
157
156
|
* 2026-09-12: medium at the flat 3072 budget scored 5/38 on the golden
|
|
158
157
|
* set — empty answers — versus 37–38/38 at low). */
|
|
159
158
|
export declare function effortBudget(effort: string): number;
|
|
159
|
+
/** Sampling follows the model's card (the 2026-08-30/31 incidents): the
|
|
160
|
+
* DeepSeek-V4 family degrades under tight sampling (temp 1.0 / top_p 1.0);
|
|
161
|
+
* GLM and Qwen thinking modes take 0.6 / 0.95. */
|
|
162
|
+
export declare function generationSampling(model: string): {
|
|
163
|
+
temperature: number;
|
|
164
|
+
top_p: number;
|
|
165
|
+
};
|
|
160
166
|
export declare function requestEffort(env: any, session: unknown, requested: unknown): string;
|
|
161
167
|
/** The corpus catalog — single source for /api/datasets, the assistant's
|
|
162
168
|
* self-description, and per-corpus model guidance. `session: true`
|
package/dist/context.d.ts
CHANGED
|
@@ -123,6 +123,19 @@ export declare function matchesDocScope(meta: {
|
|
|
123
123
|
doc_number?: string;
|
|
124
124
|
docidentifier?: string;
|
|
125
125
|
}, scopeDocNumber: string): boolean;
|
|
126
|
+
/** The platform-side form of a doc scope. Vectorize filters return
|
|
127
|
+
* results only for the fields the index has indexed for filtering — on
|
|
128
|
+
* this index doc_number, edition, language and doctype; a filter on
|
|
129
|
+
* doc_id, clause_anchor or docidentifier returns nothing, and `$and` /
|
|
130
|
+
* `$or` arrays are rejected (measured 2026-12-03 on the production
|
|
131
|
+
* index). The scope's number is asked for as written and, for a part,
|
|
132
|
+
* as its family's base too: the index stores "60" on family grain and
|
|
133
|
+
* "60-1" on some planes. */
|
|
134
|
+
export declare function docScopeFilter(scopeDocNumber: string): {
|
|
135
|
+
doc_number: {
|
|
136
|
+
$in: string[];
|
|
137
|
+
};
|
|
138
|
+
};
|
|
126
139
|
export declare function resolveDocScope(env: any, ctx: DeclaredContext): Promise<DocScope | null>;
|
|
127
140
|
export declare function appliedContext(declared: DeclaredContext | null, scope: DocScope | null, note?: AppliedContext["note"], live?: LiveEcho): AppliedContext;
|
|
128
141
|
/** Validate a context_applied object arriving from a client (the
|
|
@@ -146,6 +159,7 @@ export declare function syntheticUnderstanding(scope: DocScope): {
|
|
|
146
159
|
edition: string | null;
|
|
147
160
|
language: null;
|
|
148
161
|
process_intent: boolean;
|
|
162
|
+
doc_overview: boolean;
|
|
149
163
|
term: null;
|
|
150
164
|
defined_terms: never[];
|
|
151
165
|
standalone_query: string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { QueryUnderstanding } from "./understandContract.ts";
|
|
2
|
+
type PassageMeta = {
|
|
3
|
+
doc_number?: string;
|
|
4
|
+
docidentifier?: string;
|
|
5
|
+
};
|
|
6
|
+
/** "OIML R 60-1:2021" → "r 60-1": the publisher prefix and the edition
|
|
7
|
+
* drop, the series letter and the number (with any part) stay. */
|
|
8
|
+
export declare function identKey(docidentifier: string | null | undefined): string | null;
|
|
9
|
+
/** A passage is the named publication's own when its identifier names
|
|
10
|
+
* the same series and number — every part of a base-named publication
|
|
11
|
+
* ("R 60" covers R 60-1, R 60-A, the 1991 edition), only the named part
|
|
12
|
+
* when a part is named. The identifier decides whenever the passage has
|
|
13
|
+
* one: index metadata keys the number inconsistently (the base "60" on
|
|
14
|
+
* family grain, a part as "60-1" on some planes) and carries no series,
|
|
15
|
+
* so the number alone cannot tell R 60 from a B 60 or R 60-2 from the
|
|
16
|
+
* named R 60-1. A passage with no identifier falls back to the engine's
|
|
17
|
+
* own scope matcher, at the named part's grain. */
|
|
18
|
+
export declare function isNamedDocumentPassage(meta: PassageMeta, docNumber: string, docidentifier: string | null | undefined): boolean;
|
|
19
|
+
/** How many of the prompt's passages are the named publication's own. */
|
|
20
|
+
export declare function inScopePassages(used: ReadonlyArray<{
|
|
21
|
+
metadata?: PassageMeta;
|
|
22
|
+
}>, docNumber: string, docidentifier: string | null | undefined): number;
|
|
23
|
+
export declare function docOverviewRefusal(args: {
|
|
24
|
+
answer: string;
|
|
25
|
+
refusal: string;
|
|
26
|
+
understanding: QueryUnderstanding | null | undefined;
|
|
27
|
+
used: ReadonlyArray<{
|
|
28
|
+
metadata?: PassageMeta;
|
|
29
|
+
}>;
|
|
30
|
+
}): boolean;
|
|
31
|
+
/** The regeneration's ground instruction: say what the publication is
|
|
32
|
+
* from its own passages, cite them, and still admit when none of them
|
|
33
|
+
* describes the publication. */
|
|
34
|
+
export declare function docOverviewInstruction(docidentifier: string): string;
|
|
35
|
+
export {};
|
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";
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
You normalize a user question for a retrieval system over {{CORPUS_KIND_PLURAL}} (English corpus).
|
|
2
2
|
Reply with ONLY a JSON object, no prose, no markdown fence:
|
|
3
|
-
{"intent": "knowledge", "docidentifier": "{{DOCID_EXAMPLE}}" | null, "docnumber": "76" | null, "edition": "2021" | null, "language": "en" | null, "process_intent": true | false, "term": "accuracy class" | null, "defined_terms": [], "standalone_query": "...", "complexity": "simple", "query_variants": [], "sub_queries": [], "hypothetical_answer": "...", "follow_ups": []}
|
|
3
|
+
{"intent": "knowledge", "docidentifier": "{{DOCID_EXAMPLE}}" | null, "docnumber": "76" | null, "edition": "2021" | null, "language": "en" | null, "process_intent": true | false, "doc_overview": true | false, "term": "accuracy class" | null, "defined_terms": [], "standalone_query": "...", "complexity": "simple", "query_variants": [], "sub_queries": [], "hypothetical_answer": "...", "follow_ups": []}
|
|
4
4
|
Rules:
|
|
5
5
|
- intent: "conversational" ONLY when the latest message is about the assistant or this service itself (who you are, which model you are, what you can do, how you work) or is a pure social nicety (greeting, thanks, farewell, small talk) — e.g. "hi!", "who are you?", "what can you do?", "merci !", "was kannst du?". ANY question about a subject — legal metrology, other technical fields, cooking, sports, current events, ANYTHING — is "knowledge", even when the corpus cannot answer it; do NOT use "conversational" to mean off-topic.
|
|
6
6
|
- docidentifier: the publication the user names, in any spelling ({{SPELLING_EXAMPLES}}, "the nonautomatic weighing instruments recommendation" → resolve to the {{PUBLISHER_NAME}} identifier you can infer; include the part ("-1", "-2") only when clearly meant). docnumber is the base number without part.
|
|
7
7
|
- edition: only when the user pins a year.
|
|
8
8
|
- language: only when the user asks for a specific answer language; otherwise null (the corpus is English; answering in the user's language is handled elsewhere).
|
|
9
|
+
- doc_overview: true ONLY when the question asks what the NAMED publication is or covers as a whole — an overview, purpose, scope or summary of the document itself ("what is R 60", "describe OIML D 11", "give me an overview of R 76-1") — and docidentifier is set. false for anything inside it (a requirement, value, term, test, table or citation question: "what is the MPE in R 76-1" → false), and false when no publication is named.
|
|
9
10
|
- citation questions ("what does X cite/reference/list?", "which standards does X reference?"): ALWAYS include a query variant that names the document's bibliography or normative-references section explicitly, WITHOUT edition scoping (e.g. for "What ISO standards does R 60 cite?" generate BOTH "R 60 bibliography normative references" AND "R 60 2017 bibliography ISO IEC") — bibliographies embed differently than the query's phrasing, and prior editions may carry references the current edition dropped; set edition to null for these queries so retrieval covers the whole family.
|
|
10
11
|
- process_intent: true when the question is about the GOVERNING SYSTEM around publications rather than a publication's own technical content — HOW to get certified/apply/comply, OR which framework/vocabulary/{{PROCESS_VOCAB}}. Naming a Recommendation (e.g. "R 60") inside such a question does NOT make it a technical-content question: leave process_intent true and still emit docnumber when named, but the retrieval path must NOT seal to that document alone.
|
|
11
12
|
- term: the defined term when the question asks what something is ("what is an accuracy class" → "accuracy class"); otherwise null.
|
package/dist/reflect.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export interface ReflectionResult {
|
|
|
2
2
|
grounded: boolean;
|
|
3
3
|
missing_info: string;
|
|
4
4
|
}
|
|
5
|
-
export declare function reflect(ai: any, model: string, question: string, answer: string, passages: string[]): Promise<ReflectionResult | null>;
|
|
5
|
+
export declare function reflect(ai: any, model: string, question: string, answer: string, passages: string[], notes?: string): Promise<ReflectionResult | null>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
handleSearch
|
|
3
|
+
} from "./chunk-5PKKAHY4.js";
|
|
4
|
+
import "./chunk-Q7QL3457.js";
|
|
5
|
+
import "./chunk-AVNHVFEB.js";
|
|
6
|
+
import "./chunk-GJQT4IMD.js";
|
|
7
|
+
import "./chunk-ETLSWSZ7.js";
|
|
8
|
+
import "./chunk-7YMIUTPY.js";
|
|
9
|
+
import "./chunk-22WB6IVC.js";
|
|
10
|
+
import "./chunk-3FYJM7LH.js";
|
|
11
|
+
import "./chunk-H6ZULBW2.js";
|
|
12
|
+
export {
|
|
13
|
+
handleSearch
|
|
14
|
+
};
|
|
@@ -4,12 +4,12 @@ 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-ECNBEZGK.js";
|
|
8
|
+
import "./chunk-AVNHVFEB.js";
|
|
9
|
+
import "./chunk-7YMIUTPY.js";
|
|
10
|
+
import "./chunk-22WB6IVC.js";
|
|
11
11
|
import "./chunk-3FYJM7LH.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-H6ZULBW2.js";
|
|
13
13
|
export {
|
|
14
14
|
TOOLS_REGISTRY,
|
|
15
15
|
TOOL_DECLARATION,
|
|
@@ -9,6 +9,9 @@ export interface QueryUnderstanding {
|
|
|
9
9
|
language?: string | null;
|
|
10
10
|
/** the question is about a process around publications (certify, apply…) */
|
|
11
11
|
process_intent: boolean;
|
|
12
|
+
/** the question asks what the NAMED publication is or covers as a whole
|
|
13
|
+
* (an overview of the document), not something inside it */
|
|
14
|
+
doc_overview: boolean;
|
|
12
15
|
/** definition-style question whose subject is `term` */
|
|
13
16
|
term: string | null;
|
|
14
17
|
/** corpus-terminology mapping of everyday wording (drift→creep) */
|
|
@@ -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-22WB6IVC.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-FCRTWZQE.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-ECNBEZGK.js";
|
|
19
19
|
import {
|
|
20
20
|
handleSearch
|
|
21
|
-
} from "../../chunk-
|
|
21
|
+
} from "../../chunk-5PKKAHY4.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-Q7QL3457.js";
|
|
47
47
|
import {
|
|
48
48
|
embed,
|
|
49
49
|
generateOnce
|
|
50
|
-
} from "../../chunk-
|
|
50
|
+
} from "../../chunk-AVNHVFEB.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-GJQT4IMD.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-7YMIUTPY.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-22WB6IVC.js";
|
|
78
78
|
import {
|
|
79
79
|
P,
|
|
80
80
|
setProfile
|
|
@@ -85,7 +85,7 @@ import {
|
|
|
85
85
|
cfStore,
|
|
86
86
|
cfVectorIndex,
|
|
87
87
|
portModelRunner
|
|
88
|
-
} from "../../chunk-
|
|
88
|
+
} from "../../chunk-H6ZULBW2.js";
|
|
89
89
|
|
|
90
90
|
// workers/worker_public/src/conversations.ts
|
|
91
91
|
var ID_RE = /^[a-zA-Z0-9_-]{8,64}$/;
|
|
@@ -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-7GKMDWVB.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-LPNODCPM.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-DE5ADCVM.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-7YMIUTPY.js";
|
|
8
|
+
import "../../chunk-22WB6IVC.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.189",
|
|
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",
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
You normalize a user question for a retrieval system over {{CORPUS_KIND_PLURAL}} (English corpus).
|
|
2
2
|
Reply with ONLY a JSON object, no prose, no markdown fence:
|
|
3
|
-
{"intent": "knowledge", "docidentifier": "{{DOCID_EXAMPLE}}" | null, "docnumber": "76" | null, "edition": "2021" | null, "language": "en" | null, "process_intent": true | false, "term": "accuracy class" | null, "defined_terms": [], "standalone_query": "...", "complexity": "simple", "query_variants": [], "sub_queries": [], "hypothetical_answer": "...", "follow_ups": []}
|
|
3
|
+
{"intent": "knowledge", "docidentifier": "{{DOCID_EXAMPLE}}" | null, "docnumber": "76" | null, "edition": "2021" | null, "language": "en" | null, "process_intent": true | false, "doc_overview": true | false, "term": "accuracy class" | null, "defined_terms": [], "standalone_query": "...", "complexity": "simple", "query_variants": [], "sub_queries": [], "hypothetical_answer": "...", "follow_ups": []}
|
|
4
4
|
Rules:
|
|
5
5
|
- intent: "conversational" ONLY when the latest message is about the assistant or this service itself (who you are, which model you are, what you can do, how you work) or is a pure social nicety (greeting, thanks, farewell, small talk) — e.g. "hi!", "who are you?", "what can you do?", "merci !", "was kannst du?". ANY question about a subject — legal metrology, other technical fields, cooking, sports, current events, ANYTHING — is "knowledge", even when the corpus cannot answer it; do NOT use "conversational" to mean off-topic.
|
|
6
6
|
- docidentifier: the publication the user names, in any spelling ({{SPELLING_EXAMPLES}}, "the nonautomatic weighing instruments recommendation" → resolve to the {{PUBLISHER_NAME}} identifier you can infer; include the part ("-1", "-2") only when clearly meant). docnumber is the base number without part.
|
|
7
7
|
- edition: only when the user pins a year.
|
|
8
8
|
- language: only when the user asks for a specific answer language; otherwise null (the corpus is English; answering in the user's language is handled elsewhere).
|
|
9
|
+
- doc_overview: true ONLY when the question asks what the NAMED publication is or covers as a whole — an overview, purpose, scope or summary of the document itself ("what is R 60", "describe OIML D 11", "give me an overview of R 76-1") — and docidentifier is set. false for anything inside it (a requirement, value, term, test, table or citation question: "what is the MPE in R 76-1" → false), and false when no publication is named.
|
|
9
10
|
- citation questions ("what does X cite/reference/list?", "which standards does X reference?"): ALWAYS include a query variant that names the document's bibliography or normative-references section explicitly, WITHOUT edition scoping (e.g. for "What ISO standards does R 60 cite?" generate BOTH "R 60 bibliography normative references" AND "R 60 2017 bibliography ISO IEC") — bibliographies embed differently than the query's phrasing, and prior editions may carry references the current edition dropped; set edition to null for these queries so retrieval covers the whole family.
|
|
10
11
|
- process_intent: true when the question is about the GOVERNING SYSTEM around publications rather than a publication's own technical content — HOW to get certified/apply/comply, OR which framework/vocabulary/{{PROCESS_VOCAB}}. Naming a Recommendation (e.g. "R 60") inside such a question does NOT make it a technical-content question: leave process_intent true and still emit docnumber when named, but the retrieval path must NOT seal to that document alone.
|
|
11
12
|
- term: the defined term when the question asks what something is ("what is an accuracy class" → "accuracy class"); otherwise null.
|