@konneal/engine 0.2.3 → 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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  handleAsk
3
- } from "./chunk-OGFH3RDM.js";
4
- import "./chunk-RLT4W2VX.js";
3
+ } from "./chunk-7K5XP4PB.js";
4
+ import "./chunk-GCL73ZLT.js";
5
5
  import "./chunk-EFQALN2Z.js";
6
6
  import "./chunk-DBBGOOMZ.js";
7
7
  import "./chunk-5MBWE7WD.js";
@@ -27,7 +27,7 @@ import {
27
27
  syntheticUnderstanding,
28
28
  telemetry,
29
29
  understandQuery
30
- } from "./chunk-RLT4W2VX.js";
30
+ } from "./chunk-GCL73ZLT.js";
31
31
  import {
32
32
  corsHeaders,
33
33
  err,
@@ -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;
@@ -7,7 +7,7 @@ import {
7
7
  sessionFrom,
8
8
  telemetry,
9
9
  understandQuery
10
- } from "./chunk-RLT4W2VX.js";
10
+ } from "./chunk-GCL73ZLT.js";
11
11
  import {
12
12
  corsHeaders,
13
13
  err,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  handleSearch
3
- } from "./chunk-THSHLUOS.js";
4
- import "./chunk-RLT4W2VX.js";
3
+ } from "./chunk-NRC4FBDQ.js";
4
+ import "./chunk-GCL73ZLT.js";
5
5
  import "./chunk-EFQALN2Z.js";
6
6
  import "./chunk-DBBGOOMZ.js";
7
7
  import "./chunk-5MBWE7WD.js";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  handleSearch
3
- } from "../../chunk-THSHLUOS.js";
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-OGFH3RDM.js";
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-RLT4W2VX.js";
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-YCDXMIZ4.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-7TO2RWQE.js")).handleSearch(env, ctx, inner, tier, key);
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
@@ -27,16 +27,14 @@
27
27
  "jsdom": "^29.1.1",
28
28
  "openapi-typescript": "^7.13.0",
29
29
  "playwright": "^1.62.1",
30
- "yaml": "^2.9.1"
31
- },
32
- "dependencies": {
30
+ "yaml": "^2.9.1",
33
31
  "@astrojs/markdown-satteri": "^0.4.1",
34
32
  "@astrojs/mdx": "^4.3.14",
35
- "@konneal/client": "github:konneal/client#22ce599",
36
- "@konneal/engine": "github:konneal/engine#2d6c39b",
33
+ "@konneal/client": "^0.2.1",
37
34
  "@oimlsmart/oiml-pubid": "^1.2.1"
38
35
  },
39
- "version": "0.2.3",
36
+ "dependencies": {},
37
+ "version": "0.2.5",
40
38
  "description": "The Konneal engine: the publisher-agnostic build pipeline and API plane for standards intelligence (retrieval, answer contract, verdicts, evaluation).",
41
39
  "license": "BSD-3-Clause",
42
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;