@konneal/engine 0.2.21 → 0.2.22

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.
@@ -7,7 +7,7 @@ import {
7
7
  sessionFrom,
8
8
  telemetry,
9
9
  understandQuery
10
- } from "./chunk-DGFJUA2C.js";
10
+ } from "./chunk-4XBU4J6B.js";
11
11
  import {
12
12
  corsHeaders,
13
13
  err,
@@ -27,7 +27,7 @@ import {
27
27
  syntheticUnderstanding,
28
28
  telemetry,
29
29
  understandQuery
30
- } from "./chunk-DGFJUA2C.js";
30
+ } from "./chunk-4XBU4J6B.js";
31
31
  import {
32
32
  corsHeaders,
33
33
  err,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  handleSearch
3
- } from "./chunk-SLZ4TZNO.js";
4
- import "./chunk-DGFJUA2C.js";
3
+ } from "./chunk-IROEVHEV.js";
4
+ import "./chunk-4XBU4J6B.js";
5
5
  import "./chunk-BV7IKH3N.js";
6
6
  import "./chunk-FNJ457SE.js";
7
7
  import "./chunk-COKARI7O.js";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  handleSearch
3
- } from "../../chunk-SLZ4TZNO.js";
3
+ } from "../../chunk-IROEVHEV.js";
4
4
  import {
5
5
  checkQuoteAnchors,
6
6
  handleAsk,
7
7
  handleMemories,
8
8
  scoreJudge,
9
9
  standardForDocNumber
10
- } from "../../chunk-EE6V6X6D.js";
10
+ } from "../../chunk-M24JWPVN.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-DGFJUA2C.js";
32
+ } from "../../chunk-4XBU4J6B.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-36JS3555.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-YA6TD6QJ.js")).handleSearch(env, ctx, inner, tier, key);
982
+ const res = name === "ask" ? await (await import("../../ask-HLELROYT.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-GVDELP3N.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
@@ -16,19 +16,19 @@
16
16
  "gen:profile": "node scripts/gen_profile.mjs"
17
17
  },
18
18
  "devDependencies": {
19
+ "@astrojs/markdown-satteri": "^0.4.1",
20
+ "@astrojs/mdx": "^4.3.14",
19
21
  "@cloudflare/workers-types": "^5.20260911.1",
22
+ "@konneal/client": "^0.2.1",
23
+ "@oimlsmart/oiml-pubid": "^1.2.1",
24
+ "@pubid/pubid": "^0.1.4",
20
25
  "esbuild": "^0.28.2",
21
26
  "jsdom": "^29.1.1",
22
27
  "openapi-typescript": "^7.13.0",
23
28
  "playwright": "^1.62.1",
24
- "yaml": "^2.9.1",
25
- "@astrojs/markdown-satteri": "^0.4.1",
26
- "@astrojs/mdx": "^4.3.14",
27
- "@konneal/client": "^0.2.1",
28
- "@oimlsmart/oiml-pubid": "^1.2.1"
29
+ "yaml": "^2.9.1"
29
30
  },
30
- "dependencies": {},
31
- "version": "0.2.21",
31
+ "version": "0.2.22",
32
32
  "description": "The Konneal engine: the publisher-agnostic build pipeline and API plane for standards intelligence (retrieval, answer contract, verdicts, evaluation).",
33
33
  "license": "BSD-3-Clause",
34
34
  "type": "module",
@@ -29,9 +29,54 @@ export interface RefCodec {
29
29
  // the CS family — beyond what any regex here carried). This codec's
30
30
  // job is the ADAPTATION: the parser takes the prefixed form and
31
31
  // returns null for everything else; our callers also send bare forms
32
- // ("R 60-1:2021") and the URN provenance shape. Corpi: the package
33
- // ships the shared conformance corpus; our tests run against it.
32
+ // ("R 60-1:2021") and the URN provenance shape. The ONE construct the
33
+ // strict grammar deliberately does not own is the DUAL-PUBLISHED print
34
+ // ("ISO 4064-1:2024|OIML R 49-1:2024") — that lives in the unified
35
+ // pubid grammar (@pubid/pubid, single-flavor import so the worker
36
+ // bundle carries only the OIML grammar), and the retrieval spine of a
37
+ // dual is its OIML side, whichever side prints first.
34
38
  import { parseOimlPubid } from "@oimlsmart/oiml-pubid";
39
+ import { oimlGrammarImplementation } from "@pubid/pubid/dist/flavors/oiml/implementation.js";
40
+
41
+ const oimlParser = oimlGrammarImplementation();
42
+
43
+ const TYPE_LETTER: Record<string, string> = {
44
+ recommendation: "R", document: "D", basic_publication: "B",
45
+ "basic-publication": "B", guide: "G", expert_report: "E",
46
+ "expert-report": "E", vocabulary: "V", seminar_report: "S",
47
+ "seminar-report": "S",
48
+ };
49
+
50
+ interface PubidHash {
51
+ _type?: string;
52
+ number?: string | number;
53
+ part?: string;
54
+ year?: string;
55
+ edition?: string;
56
+ }
57
+
58
+ /** The OIML side of a dual-published print, through the unified
59
+ * grammar. Singles go through the strict grammar above — this path
60
+ * exists for the pipe construct and nothing else. */
61
+ function dualOimlSpine(side: string): { doc_number: string; edition?: string; label: string } | null {
62
+ try {
63
+ const h = oimlParser.parse(side.trim()).toHash() as PubidHash;
64
+ if (h.number === undefined) return null;
65
+ const kind = String(h._type ?? "").split(":").pop() ?? "";
66
+ const letter = TYPE_LETTER[kind] ?? "";
67
+ if (!letter) return null;
68
+ const num = String(Number(h.number));
69
+ const part = h.part !== undefined ? String(h.part) : undefined;
70
+ const ed = h.year !== undefined ? String(h.year) : h.edition !== undefined ? String(h.edition) : undefined;
71
+ return {
72
+ doc_number: num,
73
+ ...(ed ? { edition: ed } : {}),
74
+ label: `OIML ${letter} ${num}${part ? `-${part}` : ""}${ed ? `:${ed}` : ""}`,
75
+ };
76
+ } catch {
77
+ return null;
78
+ }
79
+ }
35
80
 
36
81
  /** urn:oiml:pub:r:60-1:2021 (pub) / urn:oiml:pub:cs:pd-06 (CS) → the
37
82
  * prefixed display form the parser takes. */
@@ -53,6 +98,14 @@ const parsePubid = (doc: string) => {
53
98
  * edition is never part of the number. */
54
99
  export const oimlPubid: RefCodec = {
55
100
  parse(doc, edition) {
101
+ // the dual-published print: the OIML side is the spine, whichever
102
+ // side prints first — resolved before the strict grammar, whose
103
+ // null would otherwise be the whole answer
104
+ if (!/^urn:/i.test(doc) && doc.includes("|")) {
105
+ const side = doc.split("|").map((s) => s.trim()).find((s) => /^(?:OIML|oiml)\b/i.test(s));
106
+ const dual = side ? dualOimlSpine(side) : null;
107
+ if (dual) return dual;
108
+ }
56
109
  const p = parsePubid(doc);
57
110
  if (!p || p.series !== "pub") return null;
58
111
  const type = p.family.toUpperCase();