@konneal/engine 0.2.140 → 0.2.142

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-KAHL4SZU.js";
4
- import "./chunk-GBGRHXRU.js";
5
- import "./chunk-RKNN3WAV.js";
3
+ } from "./chunk-TMIRFD4I.js";
4
+ import "./chunk-45GD6334.js";
5
+ import "./chunk-CEHMIHYM.js";
6
6
  import "./chunk-XH5QGX2O.js";
7
7
  import "./chunk-NI4CIK6W.js";
8
8
  import "./chunk-W7J5SFXJ.js";
@@ -11,7 +11,7 @@ import {
11
11
  registerNote,
12
12
  registerTokens,
13
13
  searchRegister
14
- } from "./chunk-GBGRHXRU.js";
14
+ } from "./chunk-45GD6334.js";
15
15
  import "./chunk-3FYJM7LH.js";
16
16
  export {
17
17
  aggregateBlock,
@@ -32,11 +32,13 @@ async function registerAggregate(db, family) {
32
32
  }
33
33
  }
34
34
  function aggregateNote(agg) {
35
+ const series = agg.latest?.num?.match(/^[A-Za-z]+/)?.[0] ?? "";
36
+ const familyName = series ? `${series} ${agg.family}` : agg.family;
35
37
  const latest = agg.latest ? `The latest certificate in the snapshot is ${agg.latest.num} (holder ${agg.latest.holder}, model "${agg.latest.model}"${agg.latest.year ? `, issued ${agg.latest.year}` : ""}, status ${agg.latest.status}).` : "No certificate rows are present in the snapshot.";
36
38
  const link = agg.latest?.pdf_key ? ` Its document: https://www.oimlsmart.org/cert-pdf/${agg.latest.pdf_key}` : "";
37
39
  return [
38
40
  `CERTIFICATE REGISTER \u2014 THIS NOTE ANSWERS THE QUESTION. Answer from THIS note; do not refuse for want of passages (the retrieval passages are irrelevant for register questions).`,
39
- `The ${agg.family} family holds ${agg.count} certificate${agg.count === 1 ? "" : "s"} (${agg.valid} valid${agg.suspended ? `, ${agg.suspended} suspended` : ""}) \u2014 computed over the register snapshot; state these numbers verbatim.`,
41
+ `The ${familyName} family holds ${agg.count} certificate${agg.count === 1 ? "" : "s"} (${agg.valid} valid${agg.suspended ? `, ${agg.suspended} suspended` : ""}) \u2014 computed over the register snapshot; state these numbers verbatim.`,
40
42
  latest + link,
41
43
  "Certificates are issued per RECOMMENDATION FAMILY \u2014 the register carries no edition dimension, so an edition named in the question (e.g. 2021) does not narrow it; say so when the question names an edition. Qualify that the register is a snapshot, and cite the register."
42
44
  ].join("\n");
@@ -1441,7 +1441,7 @@ var certificatesSearch = {
1441
1441
  handler: async (env, args) => {
1442
1442
  const query = String(args?.query ?? "").trim().slice(0, 160);
1443
1443
  if (!query) return null;
1444
- const { searchRegister, registerNote, certificateLinks } = await import("./certificates-TMYS7XLD.js");
1444
+ const { searchRegister, registerNote, certificateLinks } = await import("./certificates-S3KZ37DQ.js");
1445
1445
  const reg = await searchRegister(env.DB, query, true);
1446
1446
  const output = reg?.rows?.length ? [registerNote(reg.rows), certificateLinks(reg.rows)].filter(Boolean).join("\n") : `No certificate was found for "${query}" in the certificates database (the register snapshot). State this as the search's result, with the searched string visible.`;
1447
1447
  return { name: "certificates.search", query, output };
@@ -7,7 +7,7 @@ import {
7
7
  registerAggregateIntent,
8
8
  registerNote,
9
9
  searchRegister
10
- } from "./chunk-GBGRHXRU.js";
10
+ } from "./chunk-45GD6334.js";
11
11
  import {
12
12
  TOOL_DECLARATION,
13
13
  bindConstraintByQuantities,
@@ -32,7 +32,7 @@ import {
32
32
  tableRetyped,
33
33
  toolNote,
34
34
  verdictNote
35
- } from "./chunk-RKNN3WAV.js";
35
+ } from "./chunk-CEHMIHYM.js";
36
36
  import {
37
37
  NO_CONTEXT,
38
38
  STAGE_NAMES,
@@ -2633,7 +2633,7 @@ Answer account questions from these records ONLY: name the record when you use i
2633
2633
  }
2634
2634
  }
2635
2635
  }
2636
- const canonical0 = exciseMisplacedPin(canonicalRefusal(full, refusalScope(answerCites(full))), answerCites(full));
2636
+ const canonical0 = exciseMisplacedPin(canonicalRefusal(full.replace(/^TOOL [a-z_.]+.*$\n?/gm, "").replace(/^\n+/, ""), refusalScope(answerCites(full))), answerCites(full));
2637
2637
  const c2 = canonical0.includes(refusalAnswer()) ? { text: canonical0, blocks: [], dropped: [] } : await contractV2(env.DB, canonical0, usedHits);
2638
2638
  send({
2639
2639
  type: "done",
@@ -2717,7 +2717,10 @@ Answer account questions from these records ONLY: name the record when you use i
2717
2717
  );
2718
2718
  answer = await generateOnce(env, MODELS.fallback, flat, routeEffort(routed.route));
2719
2719
  }
2720
+ const scrubToolLines = (t) => t.replace(/^TOOL [a-z_.]+.*$\n?/gm, "").replace(/^\n+/, "");
2721
+ if (answer) answer = scrubToolLines(answer);
2720
2722
  if (answer) answer = canonicalRefusal(answer, refusalScope(answerCites(answer)));
2723
+ if (answer) answer = scrubToolLines(answer);
2721
2724
  if (answer) answer = exciseMisplacedPin(answer, answerCites(answer));
2722
2725
  stageTiming.generate = Date.now() - tGen;
2723
2726
  let used = usedHits;
@@ -4,7 +4,7 @@ import {
4
4
  parseToolCall,
5
5
  runTool,
6
6
  toolNote
7
- } from "./chunk-RKNN3WAV.js";
7
+ } from "./chunk-CEHMIHYM.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-KAHL4SZU.js";
8
- import "../../chunk-GBGRHXRU.js";
7
+ } from "../../chunk-TMIRFD4I.js";
8
+ import "../../chunk-45GD6334.js";
9
9
  import {
10
10
  TOOLS_REGISTRY,
11
11
  bindModelNode,
12
12
  modelGroundingBlock
13
- } from "../../chunk-RKNN3WAV.js";
13
+ } from "../../chunk-CEHMIHYM.js";
14
14
  import {
15
15
  handleSearch
16
16
  } from "../../chunk-5WITTJQD.js";
@@ -1073,13 +1073,13 @@ async function callToolOnce(env, ctx, _req, tier, key, name, args, t0) {
1073
1073
  // stream:false forces the JSON lane (anon defaults to SSE)
1074
1074
  body: JSON.stringify({ ...args, stream: false })
1075
1075
  });
1076
- const { runTool, TOOLS_REGISTRY: TOOLS_REGISTRY2 } = await import("../../tools-EZRLYLTM.js");
1076
+ const { runTool, TOOLS_REGISTRY: TOOLS_REGISTRY2 } = await import("../../tools-5AGS4IO3.js");
1077
1077
  let payload;
1078
1078
  if (TOOLS_REGISTRY2.some((t) => t.name === name && t.audiences.includes("mcp"))) {
1079
1079
  const r = await runTool({ ...env, DB: env.DB }, { name, args }, "mcp");
1080
1080
  payload = r ? { tool: r.name, query: r.query, result: r.output } : { error: { message: `tool ${name} returned nothing for the given arguments` } };
1081
1081
  } else {
1082
- const res = name === "ask" ? await (await import("../../ask-YVGMSXVO.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-VEGQBEFC.js")).handleSearch(env, ctx, inner, tier, key);
1082
+ const res = name === "ask" ? await (await import("../../ask-FAZAUKM4.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-VEGQBEFC.js")).handleSearch(env, ctx, inner, tier, key);
1083
1083
  payload = await res.json().catch(() => ({ error: { message: "tool transport failed", status: res.status } }));
1084
1084
  }
1085
1085
  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.140",
30
+ "version": "0.2.142",
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",
@@ -1570,7 +1570,7 @@ let convEntities: Array<{ entity: string; kind: string }> = [];
1570
1570
  }
1571
1571
  // the misplaced-pin wall rides the streamed path too: a
1572
1572
  // CITED stream is not a refusal
1573
- const canonical0 = exciseMisplacedPin(canonicalRefusal(full, refusalScope(answerCites(full))), answerCites(full));
1573
+ const canonical0 = exciseMisplacedPin(canonicalRefusal(full.replace(/^TOOL [a-z_.]+.*$\n?/gm, "").replace(/^\n+/, ""), refusalScope(answerCites(full))), answerCites(full));
1574
1574
  // answer contract v2: validate [[u:]] refs, resolve typed blocks
1575
1575
  const c2 = canonical0.includes(refusalAnswer())
1576
1576
  ? { text: canonical0, blocks: [], dropped: [] as string[] }
@@ -1674,7 +1674,14 @@ let convEntities: Array<{ entity: string; kind: string }> = [];
1674
1674
  );
1675
1675
  answer = await generateOnce(env, MODELS.fallback, flat, routeEffort(routed.route));
1676
1676
  }
1677
+ // the protocol scrub: a TOOL line is the agent loop's wire protocol,
1678
+ // never user-facing prose — the answer model occasionally echoes the
1679
+ // line it just composed (observed live: 'TOOL db.find …' opened a
1680
+ // served answer). Stripped here and on the streamed path.
1681
+ const scrubToolLines = (t: string) => t.replace(/^TOOL [a-z_.]+.*$\n?/gm, "").replace(/^\n+/, "");
1682
+ if (answer) answer = scrubToolLines(answer);
1677
1683
  if (answer) answer = canonicalRefusal(answer, refusalScope(answerCites(answer)));
1684
+ if (answer) answer = scrubToolLines(answer);
1678
1685
  // the misplaced-pin wall: a CITED answer is not a refusal — excise
1679
1686
  // the pinned sentence if the model dropped it in as a disclaimer
1680
1687
  // (measured on chip-scoped asks: correct cited answers carrying the
@@ -82,6 +82,11 @@ export async function registerAggregate(db: any, family: string): Promise<Regist
82
82
  * model narrates, never recomputes. The edition disclaimer rides every
83
83
  * family-scoped answer (the register has no edition dimension). */
84
84
  export function aggregateNote(agg: RegisterAggregate): string {
85
+ // the register stores the family as digits ("60"); the user-facing
86
+ // name carries the series letter, which the certificate numbers
87
+ // themselves carry ("R60/…") — derived from the data, never hardcoded
88
+ const series = agg.latest?.num?.match(/^[A-Za-z]+/)?.[0] ?? "";
89
+ const familyName = series ? `${series} ${agg.family}` : agg.family;
85
90
  const latest = agg.latest
86
91
  ? `The latest certificate in the snapshot is ${agg.latest.num} (holder ${agg.latest.holder}, model "${agg.latest.model}"${agg.latest.year ? `, issued ${agg.latest.year}` : ""}, status ${agg.latest.status}).`
87
92
  : "No certificate rows are present in the snapshot.";
@@ -90,7 +95,7 @@ export function aggregateNote(agg: RegisterAggregate): string {
90
95
  : "";
91
96
  return [
92
97
  `CERTIFICATE REGISTER — THIS NOTE ANSWERS THE QUESTION. Answer from THIS note; do not refuse for want of passages (the retrieval passages are irrelevant for register questions).`,
93
- `The ${agg.family} family holds ${agg.count} certificate${agg.count === 1 ? "" : "s"} (${agg.valid} valid${agg.suspended ? `, ${agg.suspended} suspended` : ""}) — computed over the register snapshot; state these numbers verbatim.`,
98
+ `The ${familyName} family holds ${agg.count} certificate${agg.count === 1 ? "" : "s"} (${agg.valid} valid${agg.suspended ? `, ${agg.suspended} suspended` : ""}) — computed over the register snapshot; state these numbers verbatim.`,
94
99
  latest + link,
95
100
  "Certificates are issued per RECOMMENDATION FAMILY — the register carries no edition dimension, so an edition named in the question (e.g. 2021) does not narrow it; say so when the question names an edition. Qualify that the register is a snapshot, and cite the register.",
96
101
  ].join("\n");