@konneal/engine 0.2.162 → 0.2.163
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-ND63B3CF.js → ask-DP5HOH4K.js} +2 -2
- package/dist/{chunk-PBHMQZKA.js → chunk-6OD35FOY.js} +9 -5
- package/dist/{chunk-AEVDR7DA.js → chunk-IT3MS476.js} +1 -1
- package/dist/{tools-W5HGME7W.js → tools-GDHKPEZR.js} +1 -1
- package/dist/worker_public/src/index.js +4 -4
- package/package.json +1 -1
- package/workers/worker_public/src/refs.ts +19 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
handleAsk
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IT3MS476.js";
|
|
4
4
|
import "./chunk-ECOYO7EX.js";
|
|
5
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-6OD35FOY.js";
|
|
6
6
|
import "./chunk-MTIAHAOK.js";
|
|
7
7
|
import "./chunk-NI4CIK6W.js";
|
|
8
8
|
import "./chunk-W7J5SFXJ.js";
|
|
@@ -18,7 +18,10 @@ import {
|
|
|
18
18
|
} from "./chunk-LSZTJI7V.js";
|
|
19
19
|
|
|
20
20
|
// workers/worker_public/src/refs.ts
|
|
21
|
-
var REF = /\[\[(u:[A-Za-z0-9_-]+)\]\]/g;
|
|
21
|
+
var REF = /\[\[(u:(?:u:)?[A-Za-z0-9_-]+)\]\]/g;
|
|
22
|
+
function normalizeRef(id) {
|
|
23
|
+
return id.startsWith("u:u:") ? id.slice(2) : id;
|
|
24
|
+
}
|
|
22
25
|
function availableUnitIds(hits) {
|
|
23
26
|
const ids = /* @__PURE__ */ new Set();
|
|
24
27
|
for (const h of hits) {
|
|
@@ -28,13 +31,14 @@ function availableUnitIds(hits) {
|
|
|
28
31
|
return ids;
|
|
29
32
|
}
|
|
30
33
|
function parseRefs(text) {
|
|
31
|
-
return [...text.matchAll(REF)].map((m) => m[1]);
|
|
34
|
+
return [...text.matchAll(REF)].map((m) => normalizeRef(m[1]));
|
|
32
35
|
}
|
|
33
36
|
function sanitizeRefs(text, available) {
|
|
34
37
|
const dropped = [];
|
|
35
|
-
const out = text.replace(REF, (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
const out = text.replace(REF, (_full, id) => {
|
|
39
|
+
const normalized = normalizeRef(id);
|
|
40
|
+
if (available.has(normalized)) return `[[${normalized}]]`;
|
|
41
|
+
dropped.push(normalized);
|
|
38
42
|
return "";
|
|
39
43
|
});
|
|
40
44
|
return { text: out, dropped };
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
handleMemories,
|
|
5
5
|
scoreFaithfulness,
|
|
6
6
|
scoreJudge
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-IT3MS476.js";
|
|
8
8
|
import "../../chunk-ECOYO7EX.js";
|
|
9
9
|
import {
|
|
10
10
|
TOOLS_REGISTRY,
|
|
11
11
|
bindModelNode,
|
|
12
12
|
modelGroundingBlock
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-6OD35FOY.js";
|
|
14
14
|
import {
|
|
15
15
|
handleSearch
|
|
16
16
|
} from "../../chunk-IGAGXQHV.js";
|
|
@@ -1165,13 +1165,13 @@ async function callToolOnce(env, ctx, _req, tier, key, name, args, t0) {
|
|
|
1165
1165
|
// stream:false forces the JSON lane (anon defaults to SSE)
|
|
1166
1166
|
body: JSON.stringify({ ...args, stream: false })
|
|
1167
1167
|
});
|
|
1168
|
-
const { runTool, TOOLS_REGISTRY: TOOLS_REGISTRY2 } = await import("../../tools-
|
|
1168
|
+
const { runTool, TOOLS_REGISTRY: TOOLS_REGISTRY2 } = await import("../../tools-GDHKPEZR.js");
|
|
1169
1169
|
let payload;
|
|
1170
1170
|
if (TOOLS_REGISTRY2.some((t) => t.name === name && t.audiences.includes("mcp"))) {
|
|
1171
1171
|
const r = await runTool({ ...env, DB: env.DB }, { name, args }, "mcp");
|
|
1172
1172
|
payload = r ? { tool: r.name, query: r.query, result: r.output } : { error: { message: `tool ${name} returned nothing for the given arguments` } };
|
|
1173
1173
|
} else {
|
|
1174
|
-
const res = name === "ask" ? await (await import("../../ask-
|
|
1174
|
+
const res = name === "ask" ? await (await import("../../ask-DP5HOH4K.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-FW5O32BY.js")).handleSearch(env, ctx, inner, tier, key);
|
|
1175
1175
|
payload = await res.json().catch(() => ({ error: { message: "tool transport failed", status: res.status } }));
|
|
1176
1176
|
}
|
|
1177
1177
|
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 });
|
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.163",
|
|
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",
|
|
@@ -15,7 +15,18 @@ export interface ResolvedBlock {
|
|
|
15
15
|
payload: Record<string, unknown>;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
// The passage headers show `unit u:<id> (table)`, so the model copies
|
|
19
|
+
// the WHOLE prefixed id into the token — `[[u:u:<id>]]` — and the inner
|
|
20
|
+
// colon makes the strict grammar unparseable: neither resolved nor
|
|
21
|
+
// sanitized, the raw token leaked to the client (observed live on the
|
|
22
|
+
// R 134-2 figure question, 0.2.162). The grammar tolerates the doubled
|
|
23
|
+
// prefix; normalizeRef folds it back to the single form every other
|
|
24
|
+
// layer keys on.
|
|
25
|
+
const REF = /\[\[(u:(?:u:)?[A-Za-z0-9_-]+)\]\]/g;
|
|
26
|
+
|
|
27
|
+
function normalizeRef(id: string): string {
|
|
28
|
+
return id.startsWith("u:u:") ? id.slice(2) : id;
|
|
29
|
+
}
|
|
19
30
|
|
|
20
31
|
/** unit ids the passages actually contain (chunk metadata carries
|
|
21
32
|
* unit_id on typed MKO chunks). */
|
|
@@ -29,16 +40,19 @@ export function availableUnitIds(hits: ReadonlyArray<{ metadata: { unit_id?: str
|
|
|
29
40
|
}
|
|
30
41
|
|
|
31
42
|
export function parseRefs(text: string): string[] {
|
|
32
|
-
return [...text.matchAll(REF)].map((m) => m[1]);
|
|
43
|
+
return [...text.matchAll(REF)].map((m) => normalizeRef(m[1]));
|
|
33
44
|
}
|
|
34
45
|
|
|
35
46
|
/** Drop refs that don't resolve to a used passage unit — a dangling ref
|
|
36
47
|
* renders as nothing (the token removed), and the violation is logged. */
|
|
37
48
|
export function sanitizeRefs(text: string, available: ReadonlySet<string>): { text: string; dropped: string[] } {
|
|
38
49
|
const dropped: string[] = [];
|
|
39
|
-
const out = text.replace(REF, (
|
|
40
|
-
|
|
41
|
-
|
|
50
|
+
const out = text.replace(REF, (_full, id: string) => {
|
|
51
|
+
const normalized = normalizeRef(id);
|
|
52
|
+
// normalized already carries the single "u:" prefix — the template
|
|
53
|
+
// must not add another
|
|
54
|
+
if (available.has(normalized)) return `[[${normalized}]]`;
|
|
55
|
+
dropped.push(normalized);
|
|
42
56
|
return "";
|
|
43
57
|
});
|
|
44
58
|
return { text: out, dropped };
|