@konneal/engine 0.2.54 → 0.2.55
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.
|
@@ -2222,20 +2222,22 @@ async function handleAsk(env, ctx, req, tier, key) {
|
|
|
2222
2222
|
const warmQuery = retrievalQuery(q.query, prev);
|
|
2223
2223
|
const warmEmbed = embedWarm(env, warmQuery);
|
|
2224
2224
|
const conversationId = typeof body?.conversation_id === "string" && /^[A-Za-z0-9_-]{8,64}$/.test(body.conversation_id) ? body.conversation_id : null;
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2225
|
+
try {
|
|
2226
|
+
if (!effectiveImage && !attachIds.length && conversationId && env.DB && member) {
|
|
2227
|
+
const prior = await env.DB.prepare(
|
|
2228
|
+
"SELECT m.attachment_id AS aid, a.mime, a.r2_key FROM messages m JOIN attachments a ON a.id = m.attachment_id JOIN conversations c ON c.id = m.conversation_id AND c.sub = ?2 WHERE m.conversation_id = ?1 AND m.role = 'user' AND m.attachment_id IS NOT NULL ORDER BY m.created_at DESC LIMIT 1"
|
|
2229
|
+
).bind(conversationId, member.sub).first();
|
|
2230
|
+
if (prior) {
|
|
2231
2231
|
const obj = await env.CHAT_UPLOADS.get(prior.r2_key);
|
|
2232
2232
|
if (obj) {
|
|
2233
|
-
const
|
|
2234
|
-
|
|
2233
|
+
const bytes = new Uint8Array(await obj.arrayBuffer());
|
|
2234
|
+
let bin = "";
|
|
2235
|
+
for (let i = 0; i < bytes.length; i += 32768) bin += String.fromCharCode(...bytes.subarray(i, i + 32768));
|
|
2236
|
+
storedImage = `data:${prior.mime};base64,${btoa(bin)}`;
|
|
2235
2237
|
}
|
|
2236
|
-
} catch {
|
|
2237
2238
|
}
|
|
2238
2239
|
}
|
|
2240
|
+
} catch {
|
|
2239
2241
|
}
|
|
2240
2242
|
let convEntities = [];
|
|
2241
2243
|
if (conversationId) {
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
modelGroundingBlock,
|
|
10
10
|
scoreFaithfulness,
|
|
11
11
|
scoreJudge
|
|
12
|
-
} from "../../chunk-
|
|
12
|
+
} from "../../chunk-DKQXJN6G.js";
|
|
13
13
|
import {
|
|
14
14
|
buildMessages,
|
|
15
15
|
cfBlobs,
|
|
@@ -958,7 +958,7 @@ async function handleMcp(env, ctx, req, tier, key) {
|
|
|
958
958
|
// stream:false forces the JSON lane (anon defaults to SSE)
|
|
959
959
|
body: JSON.stringify({ ...args, stream: false })
|
|
960
960
|
});
|
|
961
|
-
const res = name === "ask" ? await (await import("../../ask-
|
|
961
|
+
const res = name === "ask" ? await (await import("../../ask-PJBGJIXF.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-PBOODCMQ.js")).handleSearch(env, ctx, inner, tier, key);
|
|
962
962
|
return res.json().catch(() => ({ error: { message: "tool transport failed", status: res.status } }));
|
|
963
963
|
});
|
|
964
964
|
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.
|
|
30
|
+
"version": "0.2.55",
|
|
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",
|
|
@@ -452,24 +452,30 @@ async function handleAsk(
|
|
|
452
452
|
const conversationId = typeof body?.conversation_id === "string" && /^[A-Za-z0-9_-]{8,64}$/.test(body.conversation_id) ? body.conversation_id : null;
|
|
453
453
|
|
|
454
454
|
// Tier-2 continuation: no new image, but the conversation carries one —
|
|
455
|
-
// its most recent stored image re-attaches to this question
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
if (
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
455
|
+
// its most recent stored image re-attaches to this question. The query
|
|
456
|
+
// scopes by the CONVERSATION'S OWNER (the messages table carries no
|
|
457
|
+
// sub; ownership rides the conversation row) and the whole resolution
|
|
458
|
+
// fails open: an optional feature never takes the ask down.
|
|
459
|
+
try {
|
|
460
|
+
if (!effectiveImage && !attachIds.length && conversationId && env.DB && member) {
|
|
461
|
+
const prior = await env.DB.prepare(
|
|
462
|
+
"SELECT m.attachment_id AS aid, a.mime, a.r2_key FROM messages m JOIN attachments a ON a.id = m.attachment_id JOIN conversations c ON c.id = m.conversation_id AND c.sub = ?2 WHERE m.conversation_id = ?1 AND m.role = 'user' AND m.attachment_id IS NOT NULL ORDER BY m.created_at DESC LIMIT 1",
|
|
463
|
+
).bind(conversationId, member.sub).first<{ aid: string; mime: string; r2_key: string }>();
|
|
464
|
+
if (prior) {
|
|
465
|
+
const obj = await (env as any).CHAT_UPLOADS.get(prior.r2_key);
|
|
466
|
+
if (obj) {
|
|
467
|
+
const bytes = new Uint8Array(await obj.arrayBuffer());
|
|
468
|
+
let bin = "";
|
|
469
|
+
for (let i = 0; i < bytes.length; i += 0x8000) bin += String.fromCharCode(...bytes.subarray(i, i + 0x8000));
|
|
470
|
+
storedImage = `data:${prior.mime};base64,${btoa(bin)}`;
|
|
471
|
+
}
|
|
469
472
|
}
|
|
470
473
|
}
|
|
474
|
+
} catch {
|
|
475
|
+
/* the reuse path is optional — the ask answers without the image */
|
|
471
476
|
}
|
|
472
|
-
|
|
477
|
+
|
|
478
|
+
let convEntities: Array<{ entity: string; kind: string }> = [];
|
|
473
479
|
if (conversationId) {
|
|
474
480
|
try {
|
|
475
481
|
const rows = await env.DB.prepare("SELECT entity, kind FROM conversation_entities WHERE conversation_id = ?1 LIMIT 12").bind(conversationId).all();
|