@konneal/engine 0.2.50 → 0.2.52

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.
@@ -0,0 +1,12 @@
1
+ import {
2
+ handleAsk
3
+ } from "./chunk-SU4FO7TN.js";
4
+ import "./chunk-TPV5GPY2.js";
5
+ import "./chunk-SPKPH54J.js";
6
+ import "./chunk-A3QHHUN5.js";
7
+ import "./chunk-LVZTWUVJ.js";
8
+ import "./chunk-2PCUAJJO.js";
9
+ import "./chunk-3FYJM7LH.js";
10
+ export {
11
+ handleAsk
12
+ };
@@ -31,6 +31,11 @@ var MODELS = {
31
31
  research: "@cf/zai-org/glm-5.3-flash"
32
32
  };
33
33
  var LIMITS = {
34
+ /** Attachment quotas (TODO.new-era/8): per-member ceilings so a member's
35
+ * uploads cannot grow without bound — count AND total bytes, checked
36
+ * before every upload writes. */
37
+ attachMaxCount: 50,
38
+ attachMaxTotalBytes: 50 * 1024 * 1024,
34
39
  // input sizes: generous — real questions can be long (pasted scenarios,
35
40
  // multi-part asks). The context BUDGET is the real governor of what the
36
41
  // model sees; these caps only bound abuse.
@@ -7,24 +7,24 @@ import {
7
7
  sessionFrom,
8
8
  telemetry,
9
9
  understandQuery
10
- } from "./chunk-VVLNUHW2.js";
10
+ } from "./chunk-TPV5GPY2.js";
11
11
  import {
12
12
  corsHeaders,
13
13
  err,
14
14
  json,
15
15
  readJson,
16
16
  validateQuery
17
- } from "./chunk-JWTIPQ4L.js";
17
+ } from "./chunk-SPKPH54J.js";
18
18
  import {
19
19
  entitlementScope,
20
20
  standardKeysFrom
21
- } from "./chunk-O6VZIDPW.js";
21
+ } from "./chunk-LVZTWUVJ.js";
22
22
  import {
23
23
  LIMITS,
24
24
  MODELS,
25
25
  num,
26
26
  sha256Hex
27
- } from "./chunk-Z24IAKB6.js";
27
+ } from "./chunk-2PCUAJJO.js";
28
28
 
29
29
  // workers/worker_public/src/search.ts
30
30
  async function handleSearch(env, ctx, req, tier, key) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DATASETS,
3
3
  datasetAllowed
4
- } from "./chunk-Z24IAKB6.js";
4
+ } from "./chunk-2PCUAJJO.js";
5
5
  import {
6
6
  P
7
7
  } from "./chunk-3FYJM7LH.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  LIMITS,
3
3
  sha256Hex
4
- } from "./chunk-Z24IAKB6.js";
4
+ } from "./chunk-2PCUAJJO.js";
5
5
  import {
6
6
  P
7
7
  } from "./chunk-3FYJM7LH.js";
@@ -35,14 +35,14 @@ import {
35
35
  syntheticUnderstanding,
36
36
  telemetry,
37
37
  understandQuery
38
- } from "./chunk-VVLNUHW2.js";
38
+ } from "./chunk-TPV5GPY2.js";
39
39
  import {
40
40
  corsHeaders,
41
41
  err,
42
42
  json,
43
43
  readJson,
44
44
  validateQuery
45
- } from "./chunk-JWTIPQ4L.js";
45
+ } from "./chunk-SPKPH54J.js";
46
46
  import {
47
47
  canonicalRefusal,
48
48
  refusalAnswer
@@ -52,7 +52,7 @@ import {
52
52
  requestSalt,
53
53
  resolveRequestScope,
54
54
  standardKeysFrom
55
- } from "./chunk-O6VZIDPW.js";
55
+ } from "./chunk-LVZTWUVJ.js";
56
56
  import {
57
57
  LIMITS,
58
58
  MODELS,
@@ -63,7 +63,7 @@ import {
63
63
  requestEffort,
64
64
  roleModel,
65
65
  sha256Hex
66
- } from "./chunk-Z24IAKB6.js";
66
+ } from "./chunk-2PCUAJJO.js";
67
67
  import {
68
68
  P
69
69
  } from "./chunk-3FYJM7LH.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  bubbleConfirmPage,
3
3
  isAllowedBubbleOrigin
4
- } from "./chunk-JWTIPQ4L.js";
4
+ } from "./chunk-SPKPH54J.js";
5
5
  import {
6
6
  DATASETS,
7
7
  LIMITS,
@@ -12,7 +12,7 @@ import {
12
12
  processExpansion,
13
13
  sha256Hex,
14
14
  today
15
- } from "./chunk-Z24IAKB6.js";
15
+ } from "./chunk-2PCUAJJO.js";
16
16
  import {
17
17
  P
18
18
  } from "./chunk-3FYJM7LH.js";
package/dist/config.d.ts CHANGED
@@ -12,6 +12,11 @@ export declare const MODELS: {
12
12
  readonly research: "@cf/zai-org/glm-5.3-flash";
13
13
  };
14
14
  export declare const LIMITS: {
15
+ /** Attachment quotas (TODO.new-era/8): per-member ceilings so a member's
16
+ * uploads cannot grow without bound — count AND total bytes, checked
17
+ * before every upload writes. */
18
+ readonly attachMaxCount: 50;
19
+ readonly attachMaxTotalBytes: number;
15
20
  readonly maxInputChars: 8000;
16
21
  readonly maxOutputTokens: 3072;
17
22
  readonly retrieveK: 50;
@@ -0,0 +1,12 @@
1
+ import {
2
+ handleSearch
3
+ } from "./chunk-FLNX4O7C.js";
4
+ import "./chunk-TPV5GPY2.js";
5
+ import "./chunk-SPKPH54J.js";
6
+ import "./chunk-A3QHHUN5.js";
7
+ import "./chunk-LVZTWUVJ.js";
8
+ import "./chunk-2PCUAJJO.js";
9
+ import "./chunk-3FYJM7LH.js";
10
+ export {
11
+ handleSearch
12
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  authenticate
3
- } from "../../chunk-JWTIPQ4L.js";
4
- import "../../chunk-Z24IAKB6.js";
3
+ } from "../../chunk-SPKPH54J.js";
4
+ import "../../chunk-2PCUAJJO.js";
5
5
  import {
6
6
  P,
7
7
  setProfile
@@ -16,7 +16,7 @@ import {
16
16
  roleModel,
17
17
  sha256Hex,
18
18
  today
19
- } from "../../chunk-Z24IAKB6.js";
19
+ } from "../../chunk-2PCUAJJO.js";
20
20
  import "../../chunk-3FYJM7LH.js";
21
21
  export {
22
22
  DATASETS,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  handleSearch
3
- } from "../../chunk-DMIOBGQU.js";
3
+ } from "../../chunk-FLNX4O7C.js";
4
4
  import {
5
5
  bindModelNode,
6
6
  checkQuoteAnchors,
@@ -10,7 +10,7 @@ import {
10
10
  scoreFaithfulness,
11
11
  scoreJudge,
12
12
  standardForDocNumber
13
- } from "../../chunk-HT2MDJ5S.js";
13
+ } from "../../chunk-SU4FO7TN.js";
14
14
  import {
15
15
  buildMessages,
16
16
  cfBlobs,
@@ -37,7 +37,7 @@ import {
37
37
  sessionFrom,
38
38
  telemetry,
39
39
  understandQuery
40
- } from "../../chunk-VVLNUHW2.js";
40
+ } from "../../chunk-TPV5GPY2.js";
41
41
  import {
42
42
  authenticate,
43
43
  corsHeaders,
@@ -46,14 +46,14 @@ import {
46
46
  readJson,
47
47
  validateQuery,
48
48
  withCors
49
- } from "../../chunk-JWTIPQ4L.js";
49
+ } from "../../chunk-SPKPH54J.js";
50
50
  import {
51
51
  canonicalRefusal
52
52
  } from "../../chunk-A3QHHUN5.js";
53
53
  import {
54
54
  entitlementScope,
55
55
  standardKeysFrom
56
- } from "../../chunk-O6VZIDPW.js";
56
+ } from "../../chunk-LVZTWUVJ.js";
57
57
  import {
58
58
  LIMITS,
59
59
  MODELS,
@@ -64,7 +64,7 @@ import {
64
64
  roleModel,
65
65
  sha256Hex,
66
66
  today
67
- } from "../../chunk-Z24IAKB6.js";
67
+ } from "../../chunk-2PCUAJJO.js";
68
68
  import {
69
69
  P,
70
70
  setProfile
@@ -857,6 +857,13 @@ async function uploadAttachment(deps, sub, dataUrl) {
857
857
  if (!parsed) {
858
858
  return new Response(JSON.stringify({ error: { code: "invalid_input", message: "A PNG, JPEG, WebP or GIF image of at most 4 MB is required" } }), { status: 400, headers: { "content-type": "application/json" } });
859
859
  }
860
+ const usage = await deps.store.prepare("SELECT COUNT(*) AS n, COALESCE(SUM(bytes), 0) AS total FROM attachments WHERE sub = ?1").bind(sub).first();
861
+ if ((usage?.n ?? 0) >= LIMITS.attachMaxCount) {
862
+ return new Response(JSON.stringify({ error: { code: "attachment_count_cap", message: `Attachment limit reached (${LIMITS.attachMaxCount} files). Delete one to upload another.` } }), { status: 409, headers: { "content-type": "application/json" } });
863
+ }
864
+ if ((usage?.total ?? 0) + parsed.bytes.length > LIMITS.attachMaxTotalBytes) {
865
+ return new Response(JSON.stringify({ error: { code: "attachment_bytes_cap", message: `Attachment storage limit reached (${Math.round(LIMITS.attachMaxTotalBytes / 1048576)} MB). Delete an image to upload another.` } }), { status: 409, headers: { "content-type": "application/json" } });
866
+ }
860
867
  const id = crypto.randomUUID();
861
868
  const key = `att/${sub}/${id}`;
862
869
  await deps.blobs.put(key, parsed.bytes.buffer, parsed.mime);
@@ -947,7 +954,7 @@ async function handleMcp(env, ctx, req, tier, key) {
947
954
  // stream:false forces the JSON lane (anon defaults to SSE)
948
955
  body: JSON.stringify({ ...args, stream: false })
949
956
  });
950
- const res = name === "ask" ? await (await import("../../ask-FZA3ZFVB.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-KNB2S2PS.js")).handleSearch(env, ctx, inner, tier, key);
957
+ const res = name === "ask" ? await (await import("../../ask-27TMC7PV.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-PBOODCMQ.js")).handleSearch(env, ctx, inner, tier, key);
951
958
  return res.json().catch(() => ({ error: { message: "tool transport failed", status: res.status } }));
952
959
  });
953
960
  if (out.ok && "accepted" in out) return new Response(null, { status: 202 });
@@ -4,8 +4,8 @@ import {
4
4
  requestSalt,
5
5
  resolveRequestScope,
6
6
  standardKeysFrom
7
- } from "../../chunk-O6VZIDPW.js";
8
- import "../../chunk-Z24IAKB6.js";
7
+ } from "../../chunk-LVZTWUVJ.js";
8
+ import "../../chunk-2PCUAJJO.js";
9
9
  import "../../chunk-3FYJM7LH.js";
10
10
  export {
11
11
  entitlementScope,
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.50",
30
+ "version": "0.2.52",
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",
@@ -14,8 +14,10 @@ info:
14
14
  administrator; signed-in members obtain a higher allowance together
15
15
  with conversation synchronisation, project memory and research mode.
16
16
  servers:
17
+ - url: https://www.ommisa.org
18
+ description: Production (the canonical door)
17
19
  - url: https://ai.oimlsmart.org
18
- description: Production
20
+ description: The institutional origin — a permanent, method-preserving redirect to the canonical door
19
21
  tags:
20
22
  - name: Ask
21
23
  description: Ask a question and receive a citation-grounded answer.
@@ -14,6 +14,7 @@
14
14
  // Storage rides the Blobs port and the row rides the StoreQuery port —
15
15
  // the module never names a provider binding (the ports purity lint).
16
16
 
17
+ import { LIMITS } from "./config.ts";
17
18
  import type { Blobs } from "./ports/blobs.ts";
18
19
  import type { StoreQuery } from "./ports/store.ts";
19
20
 
@@ -67,6 +68,18 @@ export async function uploadAttachment(deps: AttachmentDeps, sub: string, dataUr
67
68
  if (!parsed) {
68
69
  return new Response(JSON.stringify({ error: { code: "invalid_input", message: "A PNG, JPEG, WebP or GIF image of at most 4 MB is required" } }), { status: 400, headers: { "content-type": "application/json" } });
69
70
  }
71
+ // the per-member ceilings: count first, then total bytes — both
72
+ // checked against the member's own rows before anything writes
73
+ const usage = await deps.store
74
+ .prepare("SELECT COUNT(*) AS n, COALESCE(SUM(bytes), 0) AS total FROM attachments WHERE sub = ?1")
75
+ .bind(sub)
76
+ .first<{ n: number; total: number }>();
77
+ if ((usage?.n ?? 0) >= LIMITS.attachMaxCount) {
78
+ return new Response(JSON.stringify({ error: { code: "attachment_count_cap", message: `Attachment limit reached (${LIMITS.attachMaxCount} files). Delete one to upload another.` } }), { status: 409, headers: { "content-type": "application/json" } });
79
+ }
80
+ if ((usage?.total ?? 0) + parsed.bytes.length > LIMITS.attachMaxTotalBytes) {
81
+ return new Response(JSON.stringify({ error: { code: "attachment_bytes_cap", message: `Attachment storage limit reached (${Math.round(LIMITS.attachMaxTotalBytes / 1048576)} MB). Delete an image to upload another.` } }), { status: 409, headers: { "content-type": "application/json" } });
82
+ }
70
83
  const id = crypto.randomUUID();
71
84
  // the key embeds the owner — the storage partition IS the isolation
72
85
  const key = `att/${sub}/${id}`;
@@ -27,6 +27,12 @@ export const MODELS = {
27
27
  } as const;
28
28
 
29
29
  export const LIMITS = {
30
+ /** Attachment quotas (TODO.new-era/8): per-member ceilings so a member's
31
+ * uploads cannot grow without bound — count AND total bytes, checked
32
+ * before every upload writes. */
33
+ attachMaxCount: 50,
34
+ attachMaxTotalBytes: 50 * 1024 * 1024,
35
+
30
36
  // input sizes: generous — real questions can be long (pasted scenarios,
31
37
  // multi-part asks). The context BUDGET is the real governor of what the
32
38
  // model sees; these caps only bound abuse.
@@ -1,12 +0,0 @@
1
- import {
2
- handleAsk
3
- } from "./chunk-HT2MDJ5S.js";
4
- import "./chunk-VVLNUHW2.js";
5
- import "./chunk-JWTIPQ4L.js";
6
- import "./chunk-A3QHHUN5.js";
7
- import "./chunk-O6VZIDPW.js";
8
- import "./chunk-Z24IAKB6.js";
9
- import "./chunk-3FYJM7LH.js";
10
- export {
11
- handleAsk
12
- };
@@ -1,12 +0,0 @@
1
- import {
2
- handleSearch
3
- } from "./chunk-DMIOBGQU.js";
4
- import "./chunk-VVLNUHW2.js";
5
- import "./chunk-JWTIPQ4L.js";
6
- import "./chunk-A3QHHUN5.js";
7
- import "./chunk-O6VZIDPW.js";
8
- import "./chunk-Z24IAKB6.js";
9
- import "./chunk-3FYJM7LH.js";
10
- export {
11
- handleSearch
12
- };