@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.
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  handleAsk
3
- } from "./chunk-AEVDR7DA.js";
3
+ } from "./chunk-IT3MS476.js";
4
4
  import "./chunk-ECOYO7EX.js";
5
- import "./chunk-PBHMQZKA.js";
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, (full, id) => {
36
- if (available.has(id)) return full;
37
- dropped.push(id);
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 };
@@ -32,7 +32,7 @@ import {
32
32
  tableRetyped,
33
33
  toolNote,
34
34
  verdictNote
35
- } from "./chunk-PBHMQZKA.js";
35
+ } from "./chunk-6OD35FOY.js";
36
36
  import {
37
37
  NO_CONTEXT,
38
38
  STAGE_NAMES,
@@ -4,7 +4,7 @@ import {
4
4
  parseToolCall,
5
5
  runTool,
6
6
  toolNote
7
- } from "./chunk-PBHMQZKA.js";
7
+ } from "./chunk-6OD35FOY.js";
8
8
  import "./chunk-NI4CIK6W.js";
9
9
  import "./chunk-4NXH5ZI6.js";
10
10
  import "./chunk-VT7DR6NQ.js";
@@ -4,13 +4,13 @@ import {
4
4
  handleMemories,
5
5
  scoreFaithfulness,
6
6
  scoreJudge
7
- } from "../../chunk-AEVDR7DA.js";
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-PBHMQZKA.js";
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-W5HGME7W.js");
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-ND63B3CF.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-FW5O32BY.js")).handleSearch(env, ctx, inner, tier, key);
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.162",
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
- const REF = /\[\[(u:[A-Za-z0-9_-]+)\]\]/g;
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, (full, id: string) => {
40
- if (available.has(id)) return full;
41
- dropped.push(id);
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 };