@konneal/engine 0.2.66 → 0.2.68

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,6 +1,6 @@
1
1
  import {
2
2
  handleAsk
3
- } from "./chunk-YZA5XAU7.js";
3
+ } from "./chunk-G7COZIAM.js";
4
4
  import "./chunk-TPV5GPY2.js";
5
5
  import "./chunk-SPKPH54J.js";
6
6
  import "./chunk-A3QHHUN5.js";
@@ -2310,7 +2310,7 @@ async function handleAsk(env, ctx, req, tier, key) {
2310
2310
  if (bridgeImage && /certificate|certified|certification/i.test(q.query)) {
2311
2311
  const np = await extractNameplate(env.AI, MODELS.member, bridgeImage);
2312
2312
  if (np?.manufacturer) {
2313
- const bridged = await searchRegister(env.DB, nameplateRegisterQuery(np, q.query));
2313
+ const bridged = await searchRegister(env.DB, nameplateRegisterQuery(np, q.query), true);
2314
2314
  if (bridged?.rows?.length) {
2315
2315
  register = bridged;
2316
2316
  console.log("nameplate-bridge:", np.manufacturer, np.model ?? "", "\u2192", bridged.rows.length, "register rows");
@@ -2670,6 +2670,7 @@ Answer account questions from these records ONLY: name the record when you use i
2670
2670
  budget
2671
2671
  );
2672
2672
  await attachFigureImages(env, messages, usedHits, q.query);
2673
+ const pendingTools = [];
2673
2674
  if (/certificate|certified|certification/i.test(q.query) && env.DB) {
2674
2675
  try {
2675
2676
  const probe = await env.AI.run(model, {
@@ -2685,6 +2686,7 @@ ${q.query}` }],
2685
2686
  const result = await runTool(env.DB, call);
2686
2687
  if (result) {
2687
2688
  messages.push({ role: "system", content: toolNote(result) });
2689
+ pendingTools.push(result);
2688
2690
  console.log("agent-tool:", result.name, JSON.stringify(result.query), "->", result.output.slice(0, 80));
2689
2691
  }
2690
2692
  }
@@ -2718,6 +2720,12 @@ ${q.query}` }],
2718
2720
  const send = (obj) => controller.enqueue(encoder.encode(`data: ${JSON.stringify(obj)}
2719
2721
 
2720
2722
  `));
2723
+ for (const t of pendingTools) {
2724
+ try {
2725
+ send({ type: "tool", name: t.name, query: t.query });
2726
+ } catch {
2727
+ }
2728
+ }
2721
2729
  send({ type: "read", read: readAs() });
2722
2730
  const sourceQuality = answerQuality(cites.map((c) => c.quality));
2723
2731
  send({ type: "citations", citations: cites, context_applied: ctxApplied, ...sourceQuality ? { source_quality: sourceQuality, confidence_note: qualityNote(sourceQuality), ...sourceQuality === "ocr" ? { experimental_sources: experimentalSourceLabels(cites) } : {} } : {}, ...liveRecords ? { records: liveRecords } : {}, quota });
@@ -6,7 +6,7 @@ import {
6
6
  modelGroundingBlock,
7
7
  scoreFaithfulness,
8
8
  scoreJudge
9
- } from "../../chunk-YZA5XAU7.js";
9
+ } from "../../chunk-G7COZIAM.js";
10
10
  import {
11
11
  handleSearch
12
12
  } from "../../chunk-FLNX4O7C.js";
@@ -959,7 +959,7 @@ async function handleMcp(env, ctx, req, tier, key) {
959
959
  // stream:false forces the JSON lane (anon defaults to SSE)
960
960
  body: JSON.stringify({ ...args, stream: false })
961
961
  });
962
- const res = name === "ask" ? await (await import("../../ask-LAYLNLDK.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-PBOODCMQ.js")).handleSearch(env, ctx, inner, tier, key);
962
+ const res = name === "ask" ? await (await import("../../ask-BA6MBTBA.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-PBOODCMQ.js")).handleSearch(env, ctx, inner, tier, key);
963
963
  return res.json().catch(() => ({ error: { message: "tool transport failed", status: res.status } }));
964
964
  });
965
965
  if (out.ok && "accepted" in out) return new Response(null, { status: 202 });
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.66",
30
+ "version": "0.2.68",
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",
@@ -632,7 +632,7 @@ let convEntities: Array<{ entity: string; kind: string }> = [];
632
632
  if (bridgeImage && /certificate|certified|certification/i.test(q.query)) {
633
633
  const np = await extractNameplate((env as any).AI, MODELS.member, bridgeImage);
634
634
  if (np?.manufacturer) {
635
- const bridged = await searchRegister(env.DB, nameplateRegisterQuery(np, q.query));
635
+ const bridged = await searchRegister(env.DB, nameplateRegisterQuery(np, q.query), true);
636
636
  if (bridged?.rows?.length) {
637
637
  register = bridged;
638
638
  console.log("nameplate-bridge:", np.manufacturer, np.model ?? "", "→", bridged.rows.length, "register rows");
@@ -1155,7 +1155,10 @@ let convEntities: Array<{ entity: string; kind: string }> = [];
1155
1155
  // round, armed only where a tool can help. The model may call
1156
1156
  // register_search through the strict line protocol; the worker
1157
1157
  // executes it deterministically and the ATTRIBUTED result joins the
1158
- // messages — what the tool returned, for the string it asked.
1158
+ // messages — what the tool returned, for the string it asked. The
1159
+ // invocations record into pendingTools; the stream emits them as its
1160
+ // first events (the UI shows what the agent consulted).
1161
+ const pendingTools: { name: string; query: string; output: string }[] = [];
1159
1162
  if (/certificate|certified|certification/i.test(q.query) && env.DB) {
1160
1163
  try {
1161
1164
  const probe = await (env as any).AI.run(model, {
@@ -1169,6 +1172,7 @@ let convEntities: Array<{ entity: string; kind: string }> = [];
1169
1172
  const result = await runTool(env.DB, call);
1170
1173
  if (result) {
1171
1174
  messages.push({ role: "system", content: toolNote(result) });
1175
+ pendingTools.push(result);
1172
1176
  console.log("agent-tool:", result.name, JSON.stringify(result.query), "->", result.output.slice(0, 80));
1173
1177
  }
1174
1178
  }
@@ -1215,6 +1219,9 @@ let convEntities: Array<{ entity: string; kind: string }> = [];
1215
1219
  const send = (obj: unknown) => controller.enqueue(encoder.encode(`data: ${JSON.stringify(obj)}\n\n`));
1216
1220
  // the reading arrives first: the interpretation that steered
1217
1221
  // retrieval, before a single token of the answer
1222
+ for (const t of pendingTools) {
1223
+ try { send({ type: "tool", name: t.name, query: t.query }); } catch { /* never block the answer */ }
1224
+ }
1218
1225
  send({ type: "read", read: readAs() });
1219
1226
  const sourceQuality = answerQuality(cites.map((c: any) => c.quality));
1220
1227
  send({ type: "citations", citations: cites, context_applied: ctxApplied, ...(sourceQuality ? { source_quality: sourceQuality, confidence_note: qualityNote(sourceQuality), ...(sourceQuality === "ocr" ? { experimental_sources: experimentalSourceLabels(cites) } : {}) } : {}), ...(liveRecords ? { records: liveRecords } : {}), quota, });