@konneal/engine 0.2.4 → 0.2.5
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-YCDXMIZ4.js → ask-RX3W5JJW.js} +2 -2
- package/dist/{chunk-OGFH3RDM.js → chunk-7K5XP4PB.js} +1 -1
- package/dist/{chunk-RLT4W2VX.js → chunk-GCL73ZLT.js} +1 -0
- package/dist/{chunk-THSHLUOS.js → chunk-NRC4FBDQ.js} +1 -1
- package/dist/{search-7TO2RWQE.js → search-OXHXXT5S.js} +2 -2
- package/dist/worker_public/src/index.js +4 -4
- package/package.json +1 -1
- package/workers/worker_internal/src/index.ts +29 -0
- package/workers/worker_public/src/pipeline.ts +5 -0
|
@@ -1939,6 +1939,7 @@ ${context}` }
|
|
|
1939
1939
|
};
|
|
1940
1940
|
}
|
|
1941
1941
|
function publicationUrl(meta) {
|
|
1942
|
+
if (meta.corpus && !["oiml", "dirty", "clean"].includes(meta.corpus)) return void 0;
|
|
1942
1943
|
const tpl = P().publisher.catalog_url_template;
|
|
1943
1944
|
if (!tpl || !meta.doctype || !meta.doc_number) return void 0;
|
|
1944
1945
|
return tpl.replace("{type}", meta.doctype.toLowerCase()) + meta.doc_number;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
handleSearch
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-NRC4FBDQ.js";
|
|
4
4
|
import {
|
|
5
5
|
checkQuoteAnchors,
|
|
6
6
|
handleAsk,
|
|
7
7
|
handleMemories,
|
|
8
8
|
scoreJudge,
|
|
9
9
|
standardForDocNumber
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-7K5XP4PB.js";
|
|
11
11
|
import {
|
|
12
12
|
buildMessages,
|
|
13
13
|
citations,
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
sessionFrom,
|
|
30
30
|
telemetry,
|
|
31
31
|
understandQuery
|
|
32
|
-
} from "../../chunk-
|
|
32
|
+
} from "../../chunk-GCL73ZLT.js";
|
|
33
33
|
import {
|
|
34
34
|
authenticate,
|
|
35
35
|
corsHeaders,
|
|
@@ -979,7 +979,7 @@ async function handleMcp(env, ctx, req, tier, key) {
|
|
|
979
979
|
// stream:false forces the JSON lane (anon defaults to SSE)
|
|
980
980
|
body: JSON.stringify({ ...args, stream: false })
|
|
981
981
|
});
|
|
982
|
-
const res = name === "ask" ? await (await import("../../ask-
|
|
982
|
+
const res = name === "ask" ? await (await import("../../ask-RX3W5JJW.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-OXHXXT5S.js")).handleSearch(env, ctx, inner, tier, key);
|
|
983
983
|
return res.json().catch(() => ({ error: { message: "tool transport failed", status: res.status } }));
|
|
984
984
|
});
|
|
985
985
|
if (out.ok && "accepted" in out) return new Response(null, { status: 202 });
|
package/package.json
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@oimlsmart/oiml-pubid": "^1.2.1"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {},
|
|
37
|
-
"version": "0.2.
|
|
37
|
+
"version": "0.2.5",
|
|
38
38
|
"description": "The Konneal engine: the publisher-agnostic build pipeline and API plane for standards intelligence (retrieval, answer contract, verdicts, evaluation).",
|
|
39
39
|
"license": "BSD-3-Clause",
|
|
40
40
|
"type": "module",
|
|
@@ -17,6 +17,7 @@ export interface Env {
|
|
|
17
17
|
AI: any;
|
|
18
18
|
PUBLIC: any; // idx_oiml_public_v2
|
|
19
19
|
INTERNAL: any; // idx_iso_internal
|
|
20
|
+
DOCS: any; // rag-internal-docs — the internal renderings
|
|
20
21
|
CACHE: KVNamespace;
|
|
21
22
|
SESSION_SECRET: string;
|
|
22
23
|
INDEX_VERSION: string;
|
|
@@ -137,10 +138,38 @@ async function retrieveRoute(c: RouteContext): Promise<Response> {
|
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
140
|
|
|
141
|
+
// The internal corpus's document door: rendered publications and their
|
|
142
|
+
// clause-anchor maps, session-gated like retrieval (the admin token also
|
|
143
|
+
// opens it for ops verification). Only docs/<name> shapes are served —
|
|
144
|
+
// html and the anchors map, nothing else.
|
|
145
|
+
async function docRoute(c: RouteContext): Promise<Response> {
|
|
146
|
+
const { env, req } = c;
|
|
147
|
+
const file = c.params.file ?? "";
|
|
148
|
+
if (!/^docs\/[a-z0-9-]+\.(html|anchors\.json)$/.test(`docs/${file}`)) {
|
|
149
|
+
return err(400, "invalid_input", "docs/<slug>.html or docs/<slug>.anchors.json");
|
|
150
|
+
}
|
|
151
|
+
const session = await sessionFrom(req, env as any);
|
|
152
|
+
const admin = env.ADMIN_TOKEN && req.headers.get("x-admin-token") === env.ADMIN_TOKEN;
|
|
153
|
+
if (!session && !admin) return err(401, "unauthorized", "Sign in required — internal corpus documents are member content.");
|
|
154
|
+
try {
|
|
155
|
+
const obj = await env.DOCS.get(`docs/${file}`);
|
|
156
|
+
if (!obj) return err(404, "not_found", "No rendered document at this address.");
|
|
157
|
+
return new Response(obj.body, {
|
|
158
|
+
headers: {
|
|
159
|
+
"content-type": file.endsWith(".json") ? "application/json" : "text/html; charset=utf-8",
|
|
160
|
+
"cache-control": "private, max-age=86400",
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
} catch {
|
|
164
|
+
return err(503, "docs_unavailable", "The document store is briefly busy.");
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
140
168
|
// the same declarative route table the public worker dispatches through
|
|
141
169
|
// (TODO.impl/31) — one HTTP idiom across workers.
|
|
142
170
|
const ROUTES: Route[] = [
|
|
143
171
|
{ method: "GET", pattern: "/health", handler: healthRoute },
|
|
172
|
+
{ method: "GET", pattern: "/docs/:file", handler: docRoute },
|
|
144
173
|
{ method: "POST", pattern: "/admin/sync", handler: adminSyncRoute },
|
|
145
174
|
{ method: "POST", pattern: "/retrieve", handler: retrieveRoute },
|
|
146
175
|
{ method: "POST", pattern: "/api/retrieve", handler: retrieveRoute },
|
|
@@ -380,6 +380,11 @@ export function buildMessages(
|
|
|
380
380
|
* URL template ({type} = lowercase doctype, then the number); no
|
|
381
381
|
* template, no catalog link. */
|
|
382
382
|
function publicationUrl(meta: ChunkMeta): string | undefined {
|
|
383
|
+
// the catalog template names THIS publisher's store - an internal or
|
|
384
|
+
// foreign-corpus chunk has no entry in it, and a fabricated url is
|
|
385
|
+
// worse than none (the door for internal renderings is the internal
|
|
386
|
+
// origin, wired by the site's doc-base configuration)
|
|
387
|
+
if (meta.corpus && !["oiml", "dirty", "clean"].includes(meta.corpus)) return undefined;
|
|
383
388
|
const tpl = P().publisher.catalog_url_template;
|
|
384
389
|
if (!tpl || !meta.doctype || !meta.doc_number) return undefined;
|
|
385
390
|
return tpl.replace("{type}", meta.doctype.toLowerCase()) + meta.doc_number;
|