@konneal/engine 0.1.0
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/LICENSE +29 -0
- package/README.md +13 -0
- package/dist/admin.d.ts +26 -0
- package/dist/ai.d.ts +6 -0
- package/dist/anchors.d.ts +6 -0
- package/dist/answercache.d.ts +22 -0
- package/dist/ask.d.ts +5 -0
- package/dist/auth.d.ts +12 -0
- package/dist/bubble.d.ts +14 -0
- package/dist/chunk-LLWPT2XV.js +49 -0
- package/dist/chunk-MB74PTRM.js +114 -0
- package/dist/chunk-WOGQM7DJ.js +197 -0
- package/dist/chunk-WWNCWKKC.js +42 -0
- package/dist/completion.d.ts +5 -0
- package/dist/config.d.ts +154 -0
- package/dist/config.js +37 -0
- package/dist/context.d.ts +115 -0
- package/dist/conversations.d.ts +5 -0
- package/dist/drafts.d.ts +129 -0
- package/dist/env.d.ts +57 -0
- package/dist/faithfulness.d.ts +5 -0
- package/dist/grader.d.ts +3 -0
- package/dist/graph.d.ts +13 -0
- package/dist/hybrid.d.ts +7 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +5373 -0
- package/dist/internal_gateway.d.ts +14 -0
- package/dist/lexical.d.ts +7 -0
- package/dist/livedata.d.ts +77 -0
- package/dist/memories.d.ts +10 -0
- package/dist/modelplane.d.ts +61 -0
- package/dist/oidc.d.ts +73 -0
- package/dist/pipeline.d.ts +57 -0
- package/dist/profile.d.ts +2 -0
- package/dist/profile.gen.d.ts +70 -0
- package/dist/profile.js +8 -0
- package/dist/projects.d.ts +8 -0
- package/dist/prompts/conversational.md +8 -0
- package/dist/prompts/enrichment.md +3 -0
- package/dist/prompts/faithfulness.md +1 -0
- package/dist/prompts/grader.md +5 -0
- package/dist/prompts/listwise.md +3 -0
- package/dist/prompts/precision.md +1 -0
- package/dist/prompts/reflect.md +1 -0
- package/dist/prompts/relevancy.md +1 -0
- package/dist/prompts/research.md +10 -0
- package/dist/prompts/section-summary.md +5 -0
- package/dist/prompts/summarize.md +1 -0
- package/dist/prompts/system.md +18 -0
- package/dist/prompts/understanding.md +17 -0
- package/dist/quota.d.ts +13 -0
- package/dist/reflect.d.ts +5 -0
- package/dist/refs.d.ts +40 -0
- package/dist/refusal.d.ts +9 -0
- package/dist/refusal.js +9 -0
- package/dist/requestScope.d.ts +26 -0
- package/dist/requestScope.js +10 -0
- package/dist/research.d.ts +8 -0
- package/dist/search.d.ts +4 -0
- package/dist/selfquery.d.ts +7 -0
- package/dist/session.d.ts +1 -0
- package/dist/share.d.ts +2 -0
- package/dist/structural.d.ts +27 -0
- package/dist/tablecontext.d.ts +11 -0
- package/dist/understand.d.ts +11 -0
- package/dist/understandContract.d.ts +29 -0
- package/dist/verdict.d.ts +24 -0
- package/docs/API.md +451 -0
- package/docs/ARCHITECTURE.md +302 -0
- package/docs/AUDIT-2026-08-24.md +71 -0
- package/docs/CONTRIBUTOR-AUDIT-2026-08-25.md +147 -0
- package/docs/INGEST-ARCHITECTURE.md +158 -0
- package/docs/MCP.md +92 -0
- package/docs/METANORMA-AI-SERIALIZATION.md +247 -0
- package/docs/MKO-EXPORT-PIPELINE.md +147 -0
- package/docs/REDESIGN-NORMATIVE-RAG-ETSI.md +485 -0
- package/docs/RESEARCH-SOTA-2026.md +243 -0
- package/docs/ROADMAP-SOTA.md +130 -0
- package/docs/SOTA-STAGE-SPECS.md +509 -0
- package/docs/annealment/F1-verdict.md +27 -0
- package/docs/annealment/F10-notes.md +19 -0
- package/docs/annealment/F11-composition.md +17 -0
- package/docs/annealment/F12-passport.md +17 -0
- package/docs/annealment/F2-counterfactual.md +20 -0
- package/docs/annealment/F3-absence.md +21 -0
- package/docs/annealment/F4-instance.md +18 -0
- package/docs/annealment/F5-workflow.md +21 -0
- package/docs/annealment/F6-impact.md +21 -0
- package/docs/annealment/F7-editions.md +18 -0
- package/docs/annealment/F8-selfverify.md +19 -0
- package/docs/annealment/F9-projection-qa.md +17 -0
- package/docs/annealment/L0-locate.md +19 -0
- package/docs/annealment/L1-extract.md +18 -0
- package/docs/annealment/L2-nomenclature.md +22 -0
- package/docs/annealment/L3-geometry.md +23 -0
- package/docs/annealment/L4-composition.md +21 -0
- package/docs/annealment/L5-cross-standard.md +20 -0
- package/docs/annealment/L6-diachrony.md +21 -0
- package/docs/annealment/L7-perception.md +20 -0
- package/docs/annealment/L8-computation.md +22 -0
- package/docs/annealment/L9-instance-process.md +23 -0
- package/docs/annealment/README.md +10 -0
- package/docs/guidelines-metanorma-ai-programme.md +279 -0
- package/docs/identity-onboarding-rag.md +65 -0
- package/docs/identity-service.md +219 -0
- package/docs/knowledge-annealment.md +273 -0
- package/docs/konneal-extraction-plan.md +481 -0
- package/docs/metanorma-for-ai.md +270 -0
- package/docs/mirror-plan.md +36 -0
- package/docs/multi-sdo-architecture.md +191 -0
- package/docs/paper-annealment-comparison.md +259 -0
- package/docs/paper-assets/architecture.svg +94 -0
- package/docs/paper-assets/contract-v2.svg +94 -0
- package/docs/paper-assets/mko-ingest.svg +91 -0
- package/docs/paper-oiml-bulletin.md +402 -0
- package/docs/paper-oiml-bulletin.mdx +419 -0
- package/docs/product-branding-options.md +172 -0
- package/docs/projects-design.md +88 -0
- package/docs/sota-mechanisms.md +184 -0
- package/docs/spec-api.md +77 -0
- package/docs/spec-pipeline.md +126 -0
- package/docs/vector-adapter.md +88 -0
- package/package.json +70 -0
- package/profile/corpora.yaml +5 -0
- package/profile/datasets.yaml +14 -0
- package/profile/prompts.yaml +5 -0
- package/profile/publisher.yaml +17 -0
- package/profile/retrieval.yaml +1 -0
- package/profile/sources.yaml +5 -0
- package/profile/ui.yaml +7 -0
- package/scripts/gen_profile.mjs +33 -0
- package/workers/shared/ai.ts +21 -0
- package/workers/shared/auth.ts +16 -0
- package/workers/shared/chunk.ts +108 -0
- package/workers/shared/oidc.ts +312 -0
- package/workers/shared/router.ts +45 -0
- package/workers/shared/session.ts +104 -0
- package/workers/worker_internal/src/index.ts +157 -0
- package/workers/worker_internal/tsconfig.json +15 -0
- package/workers/worker_internal/wrangler.toml +32 -0
- package/workers/worker_mcp/src/index.ts +175 -0
- package/workers/worker_mcp/tsconfig.json +13 -0
- package/workers/worker_mcp/wrangler.toml +18 -0
- package/workers/worker_public/migrations/0002_conversations.sql +22 -0
- package/workers/worker_public/migrations/0003_shared_conversations.sql +9 -0
- package/workers/worker_public/migrations/0004_graph.sql +16 -0
- package/workers/worker_public/migrations/0005_documents.sql +19 -0
- package/workers/worker_public/migrations/0006_conversation_entities.sql +11 -0
- package/workers/worker_public/migrations/0007_chunks_fts.sql +43 -0
- package/workers/worker_public/migrations/0008_unit_payloads.sql +15 -0
- package/workers/worker_public/migrations/0009_chunks_unit.sql +8 -0
- package/workers/worker_public/migrations/0009_message_context.sql +7 -0
- package/workers/worker_public/migrations/0010_model_nodes.sql +33 -0
- package/workers/worker_public/migrations/0011_schema_union.sql +38 -0
- package/workers/worker_public/migrations/0012_memories.sql +15 -0
- package/workers/worker_public/migrations/0013_projects.sql +21 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/2021-11-03/index.d.ts +16306 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/2021-11-03/index.ts +16261 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-01-31/index.d.ts +16373 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-01-31/index.ts +16328 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-03-21/index.d.ts +16382 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-03-21/index.ts +16337 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-08-04/index.d.ts +16383 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-08-04/index.ts +16338 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-10-31/index.d.ts +16403 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-10-31/index.ts +16358 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-11-30/index.d.ts +16408 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/2022-11-30/index.ts +16363 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/2023-03-01/index.d.ts +16414 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/2023-03-01/index.ts +16369 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/2023-07-01/index.d.ts +16414 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/2023-07-01/index.ts +16369 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/README.md +135 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/entrypoints.svg +53 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/experimental/index.d.ts +17095 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/experimental/index.ts +17050 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/index.d.ts +16306 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/index.ts +16261 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/latest/index.d.ts +16447 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/latest/index.ts +16402 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/oldest/index.d.ts +16306 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/oldest/index.ts +16261 -0
- package/workers/worker_public/node_modules/@cloudflare/workers-types/package.json +11 -0
- package/workers/worker_public/package.json +13 -0
- package/workers/worker_public/prompts/conversational.md +8 -0
- package/workers/worker_public/prompts/enrichment.md +3 -0
- package/workers/worker_public/prompts/faithfulness.md +1 -0
- package/workers/worker_public/prompts/grader.md +5 -0
- package/workers/worker_public/prompts/listwise.md +3 -0
- package/workers/worker_public/prompts/precision.md +1 -0
- package/workers/worker_public/prompts/reflect.md +1 -0
- package/workers/worker_public/prompts/relevancy.md +1 -0
- package/workers/worker_public/prompts/research.md +10 -0
- package/workers/worker_public/prompts/section-summary.md +5 -0
- package/workers/worker_public/prompts/summarize.md +1 -0
- package/workers/worker_public/prompts/system.md +18 -0
- package/workers/worker_public/prompts/understanding.md +17 -0
- package/workers/worker_public/public/app.js +166 -0
- package/workers/worker_public/public/index.html +48 -0
- package/workers/worker_public/public/style.css +147 -0
- package/workers/worker_public/schema.sql +248 -0
- package/workers/worker_public/src/admin.ts +358 -0
- package/workers/worker_public/src/ai.ts +71 -0
- package/workers/worker_public/src/anchors.ts +41 -0
- package/workers/worker_public/src/answercache.ts +72 -0
- package/workers/worker_public/src/ask.ts +1094 -0
- package/workers/worker_public/src/auth.ts +252 -0
- package/workers/worker_public/src/bubble.ts +111 -0
- package/workers/worker_public/src/completion.ts +75 -0
- package/workers/worker_public/src/config.ts +238 -0
- package/workers/worker_public/src/context.ts +238 -0
- package/workers/worker_public/src/conversations.ts +162 -0
- package/workers/worker_public/src/drafts.ts +497 -0
- package/workers/worker_public/src/env.ts +90 -0
- package/workers/worker_public/src/faithfulness.ts +63 -0
- package/workers/worker_public/src/grader.ts +89 -0
- package/workers/worker_public/src/graph.ts +63 -0
- package/workers/worker_public/src/hybrid.ts +77 -0
- package/workers/worker_public/src/index.ts +441 -0
- package/workers/worker_public/src/internal_gateway.ts +41 -0
- package/workers/worker_public/src/lexical.ts +86 -0
- package/workers/worker_public/src/lib/hit.ts +4 -0
- package/workers/worker_public/src/lib/http.ts +83 -0
- package/workers/worker_public/src/lib/router.ts +4 -0
- package/workers/worker_public/src/livedata.ts +334 -0
- package/workers/worker_public/src/memories.ts +81 -0
- package/workers/worker_public/src/modelplane.ts +213 -0
- package/workers/worker_public/src/oidc.ts +333 -0
- package/workers/worker_public/src/pipeline.ts +377 -0
- package/workers/worker_public/src/ports/blobs.ts +7 -0
- package/workers/worker_public/src/ports/cloudflare/adapters.ts +177 -0
- package/workers/worker_public/src/ports/kv.ts +8 -0
- package/workers/worker_public/src/ports/model.ts +28 -0
- package/workers/worker_public/src/ports/runtime.ts +13 -0
- package/workers/worker_public/src/ports/store.ts +20 -0
- package/workers/worker_public/src/ports/vector.ts +26 -0
- package/workers/worker_public/src/profile.gen.ts +101 -0
- package/workers/worker_public/src/profile.ts +16 -0
- package/workers/worker_public/src/projects.ts +108 -0
- package/workers/worker_public/src/prompts.d.ts +6 -0
- package/workers/worker_public/src/quota.ts +54 -0
- package/workers/worker_public/src/reflect.ts +67 -0
- package/workers/worker_public/src/refs.ts +107 -0
- package/workers/worker_public/src/refusal.ts +65 -0
- package/workers/worker_public/src/requestScope.ts +71 -0
- package/workers/worker_public/src/research.ts +126 -0
- package/workers/worker_public/src/search.ts +56 -0
- package/workers/worker_public/src/selfquery.ts +25 -0
- package/workers/worker_public/src/session.ts +4 -0
- package/workers/worker_public/src/share.ts +53 -0
- package/workers/worker_public/src/stages/conceptGraph.ts +68 -0
- package/workers/worker_public/src/stages/conceptSteer.ts +39 -0
- package/workers/worker_public/src/stages/corpusScope.ts +25 -0
- package/workers/worker_public/src/stages/dedup.ts +10 -0
- package/workers/worker_public/src/stages/dense.ts +73 -0
- package/workers/worker_public/src/stages/diversity.ts +33 -0
- package/workers/worker_public/src/stages/editionCover.ts +63 -0
- package/workers/worker_public/src/stages/editionSteer.ts +88 -0
- package/workers/worker_public/src/stages/familyBoost.ts +22 -0
- package/workers/worker_public/src/stages/federate.ts +22 -0
- package/workers/worker_public/src/stages/glossary.ts +65 -0
- package/workers/worker_public/src/stages/graphLane.ts +31 -0
- package/workers/worker_public/src/stages/hyde.ts +29 -0
- package/workers/worker_public/src/stages/index.ts +69 -0
- package/workers/worker_public/src/stages/lexicalUnion.ts +21 -0
- package/workers/worker_public/src/stages/multiQuery.ts +57 -0
- package/workers/worker_public/src/stages/overviewDemote.ts +14 -0
- package/workers/worker_public/src/stages/poolOpen.ts +10 -0
- package/workers/worker_public/src/stages/propagate.ts +15 -0
- package/workers/worker_public/src/stages/rerank.ts +47 -0
- package/workers/worker_public/src/stages/seal.ts +16 -0
- package/workers/worker_public/src/stages/sectionDescent.ts +61 -0
- package/workers/worker_public/src/stages/stdRefNudge.ts +35 -0
- package/workers/worker_public/src/stages/subQuery.ts +42 -0
- package/workers/worker_public/src/stages/termNudge.ts +24 -0
- package/workers/worker_public/src/stages/typedPin.ts +131 -0
- package/workers/worker_public/src/stages/types.ts +112 -0
- package/workers/worker_public/src/stages/windowFloor.ts +23 -0
- package/workers/worker_public/src/structural.ts +171 -0
- package/workers/worker_public/src/tablecontext.ts +41 -0
- package/workers/worker_public/src/understand.ts +72 -0
- package/workers/worker_public/src/understandContract.ts +67 -0
- package/workers/worker_public/src/verdict.ts +255 -0
- package/workers/worker_public/tsconfig.json +18 -0
- package/workers/worker_public/wrangler.toml +104 -0
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
export declare const MODELS: {
|
|
2
|
+
readonly embed: "@cf/qwen/qwen3-embedding-0.6b";
|
|
3
|
+
readonly rerank: "@cf/baai/bge-reranker-base";
|
|
4
|
+
readonly anon: "@cf/zai-org/glm-5.3-flash";
|
|
5
|
+
readonly member: "@cf/zai-org/glm-5.3-flash";
|
|
6
|
+
readonly understand: "@cf/qwen/qwen3-30b-a3b-fp8";
|
|
7
|
+
readonly fallback: "@cf/qwen/qwen3-30b-a3b-fp8";
|
|
8
|
+
readonly grader: "@cf/deepseek-ai/deepseek-v4-flash-0731";
|
|
9
|
+
readonly enrich: "@cf/deepseek-ai/deepseek-v4-pro-0813";
|
|
10
|
+
readonly listwise: "@cf/zai-org/glm-4.7-flash";
|
|
11
|
+
readonly research: "@cf/zai-org/glm-5.3-flash";
|
|
12
|
+
};
|
|
13
|
+
export declare const LIMITS: {
|
|
14
|
+
readonly maxInputChars: 8000;
|
|
15
|
+
readonly maxOutputTokens: 3072;
|
|
16
|
+
readonly retrieveK: 50;
|
|
17
|
+
readonly rerankKeep: 10;
|
|
18
|
+
readonly cacheTtlSec: number;
|
|
19
|
+
readonly inputTokenBudget: 16000;
|
|
20
|
+
readonly maxPassageTokens: 900;
|
|
21
|
+
};
|
|
22
|
+
/** Tuned retrieval thresholds — every number the pipeline steers by.
|
|
23
|
+
* Each carries the measurement that justifies it; changing one without
|
|
24
|
+
* re-running the gates (golden ×3 + annealment ×6) is a guess. */
|
|
25
|
+
export declare const THRESHOLDS: {
|
|
26
|
+
/** HyDE candidate score discount — hypothetical-answer vectors match
|
|
27
|
+
* differently than question vectors; 0.7 keeps them competitive
|
|
28
|
+
* without letting a bad hypothetical outrank the real query. */
|
|
29
|
+
readonly hydeDiscount: 0.7;
|
|
30
|
+
/** Graph-lane candidate discount — graph-filtered chunks enter the
|
|
31
|
+
* pool below the primary dense lane; they must earn their window
|
|
32
|
+
* slot under the cross-encoder, not by graph membership alone. */
|
|
33
|
+
readonly graphLaneDiscount: 0.75;
|
|
34
|
+
/** Concept-graph candidate discount — same rationale as the graph
|
|
35
|
+
* lane: definitional content enters discounted. */
|
|
36
|
+
readonly conceptGraphDiscount: 0.75;
|
|
37
|
+
/** Multi-hop sub-query discount — sub-question hits are unioned, not
|
|
38
|
+
* RRF-fused; the discount keeps them from dominating the primary
|
|
39
|
+
* ranking on their first appearance. */
|
|
40
|
+
readonly subQueryDiscount: 0.8;
|
|
41
|
+
/** Federated-ISO discount — the public corpus answers by default;
|
|
42
|
+
* internal ISO passages compete but don't preempt. */
|
|
43
|
+
readonly federateDiscount: 0.95;
|
|
44
|
+
/** Standard-reference nudge (L5): when the question asks about an
|
|
45
|
+
* invoked ISO/IEC standard, chunks that CARRY such a citation (their
|
|
46
|
+
* text contains an ISO/IEC identifier) get a spread-scaled boost —
|
|
47
|
+
* the citing clause is the answer, and generic family prose otherwise
|
|
48
|
+
* fills the window (measured: l5a-iso-humidity flips ~1/6 runs). */
|
|
49
|
+
readonly stdRefNudgeSpread: 0.35;
|
|
50
|
+
/** Edition cover — the score multiplier for current-edition chunks the
|
|
51
|
+
* cover stage fetches when a pool holds ONLY stale editions of a
|
|
52
|
+
* document. Just under the top: the point is REPRESENTATION (so
|
|
53
|
+
* edition steering can demote the stale siblings and diversity keeps
|
|
54
|
+
* the current overview), not free ranking. */
|
|
55
|
+
readonly editionCoverDiscount: 0.9;
|
|
56
|
+
/** Overview-chunk demotion — overview chunks repeat title/doctype
|
|
57
|
+
* boilerplate and embed strongly for name-like queries, crowding
|
|
58
|
+
* clause chunks out of the rerank window. */
|
|
59
|
+
readonly overviewDemotion: 0.85;
|
|
60
|
+
/** Glossary-link cosine floor — below this the dense match to a
|
|
61
|
+
* defined term is noise, not a candidate. Calibrated on the
|
|
62
|
+
* drifting→durability probe (durability-def 0.542, noise ~0.3). */
|
|
63
|
+
readonly glossaryCosineFloor: 0.5;
|
|
64
|
+
/** Exact-term nudge (spread multiplier) — clause chunks whose head IS
|
|
65
|
+
* the asked-for term get a decisive nudge because publication headers
|
|
66
|
+
* contain the title words and the reranker alone is unreliable there;
|
|
67
|
+
* >1 so it dominates the spread, unlike the additive steering boosts. */
|
|
68
|
+
readonly termNudgeSpread: 1.5;
|
|
69
|
+
/** Concept-steering rerank boost (spread fraction) — the vocabulary
|
|
70
|
+
* link's defining families get the edition-steering boost idiom.
|
|
71
|
+
* 0.15 is enough to lift in-family content past the cross-encoder's
|
|
72
|
+
* vocabulary bias without overriding genuine relevance. */
|
|
73
|
+
readonly conceptSteerSpread: 0.15;
|
|
74
|
+
/** Cross-publication recency boost (spread fraction) — a
|
|
75
|
+
* current-edition publication ranks over stale ones; composed with
|
|
76
|
+
* the family-relative demotion below. */
|
|
77
|
+
readonly crossPubRecencySpread: 0.1;
|
|
78
|
+
/** Family-relative edition demotion (spread fraction) — superseded
|
|
79
|
+
* editions are demoted when a newer edition of the same publication
|
|
80
|
+
* is in the pool; a sibling one revision back still competes. */
|
|
81
|
+
readonly familyDemoteSpread: 0.4;
|
|
82
|
+
/** Relevance-floored window — passages below this fraction of the
|
|
83
|
+
* top rerank score leave the window (the evidence-budget principle;
|
|
84
|
+
* structural units are exempt). */
|
|
85
|
+
readonly windowFloorFraction: 0.25;
|
|
86
|
+
/** Small-to-big parent fetch discount — the parent clause enters at
|
|
87
|
+
* a discount because it's supplementary grounding, not the answer. */
|
|
88
|
+
readonly smallToBigDiscount: 0.7;
|
|
89
|
+
/** Section-descent child discount — children fetched from a ranked
|
|
90
|
+
* depth-1 summary enter discounted. */
|
|
91
|
+
readonly sectionDescentDiscount: 0.8;
|
|
92
|
+
/** History budget share — the fraction of the context budget the
|
|
93
|
+
* conversation slice may consume; older turns overflow into the
|
|
94
|
+
* compacted summary instead of starving the passages. */
|
|
95
|
+
readonly historyBudgetShare: 0.3;
|
|
96
|
+
};
|
|
97
|
+
/** Process-expansion — appended to process-intent queries; publisher
|
|
98
|
+
* vocabulary from the profile (read at request time — see profile.ts). */
|
|
99
|
+
export declare function processExpansion(): string;
|
|
100
|
+
/** Per-deployment model override: <ROLE>_MODEL (e.g. UNDERSTAND_MODEL)
|
|
101
|
+
* replaces the pinned default for that role. Ops lever for A/B-ing a
|
|
102
|
+
* role's model without a code change; absent/invalid = the default. */
|
|
103
|
+
export declare function roleModel(env: any, role: keyof typeof MODELS): string;
|
|
104
|
+
/** Per-deployment effort override for the answer lane (ANSWER_EFFORT).
|
|
105
|
+
* The effort–accuracy curve is front-loaded (DeepSeek-V4.1-Flash report,
|
|
106
|
+
* Fig. 9): serving pins "low" for latency, and any move up must be
|
|
107
|
+
* measured on the golden set — this lever makes that measurable live,
|
|
108
|
+
* same pattern as roleModel. Absent/invalid = "low". */
|
|
109
|
+
export declare function answerEffort(env: any): string;
|
|
110
|
+
/** Per-request effort for the answer lane (the user-facing depth toggle).
|
|
111
|
+
* The vocabulary is validated; elevated efforts (medium+) are a member
|
|
112
|
+
* lane — same cost rule as research — and degrade to the deployment
|
|
113
|
+
* lever for anonymous or silent requests. */
|
|
114
|
+
/** Elevated effort reasons longer — the output budget must grow with it
|
|
115
|
+
* or reasoning starves the content (the GLM-5 rule; measured
|
|
116
|
+
* 2026-09-12: medium at the flat 3072 budget scored 5/38 on the golden
|
|
117
|
+
* set — empty answers — versus 37–38/38 at low). */
|
|
118
|
+
export declare function effortBudget(effort: string): number;
|
|
119
|
+
export declare function requestEffort(env: any, session: unknown, requested: unknown): string;
|
|
120
|
+
/** The corpus catalog — single source for /api/datasets, the assistant's
|
|
121
|
+
* self-description, and per-corpus model guidance. `session: true`
|
|
122
|
+
* datasets are enabled for signed-in members (federated via the internal
|
|
123
|
+
* service binding). `note` (optional) is injected into the system prompt
|
|
124
|
+
* when passages from this corpus are present — corpus behavior travels
|
|
125
|
+
* with the dataset, not with pipeline code. */
|
|
126
|
+
export interface Dataset {
|
|
127
|
+
id: string;
|
|
128
|
+
label: string;
|
|
129
|
+
description: string;
|
|
130
|
+
/** member-session gated (federated via the internal service binding) */
|
|
131
|
+
session?: boolean;
|
|
132
|
+
/** the estate permission (a role code set in the publisher's
|
|
133
|
+
* identity provider) the session must carry for a session-gated
|
|
134
|
+
* dataset — membership alone is not the bar */
|
|
135
|
+
permission?: string;
|
|
136
|
+
/** the corpora this dataset searches (profile datasets.yaml) — the
|
|
137
|
+
* engine maps no publisher names */
|
|
138
|
+
corpora?: string[];
|
|
139
|
+
note?: string;
|
|
140
|
+
}
|
|
141
|
+
export declare function DATASETS(): readonly Dataset[];
|
|
142
|
+
/** The estate permission gate: a session-gated dataset requires BOTH
|
|
143
|
+
* membership and the named permission (a role code the account carries
|
|
144
|
+
* in id.oimlsmart.org). Enforcement is server-side — the UI's lock is
|
|
145
|
+
* cosmetic; /api/ask federation and the scope intersect here too. */
|
|
146
|
+
export declare function hasPermission(session: unknown, code: string): boolean;
|
|
147
|
+
export declare function datasetAllowed(d: Dataset, session: unknown): boolean;
|
|
148
|
+
export declare function datasetsFor(session: unknown): unknown[];
|
|
149
|
+
/** Empty-state starter questions, served by /api/datasets — UI content
|
|
150
|
+
* comes from the API, never hardcoded in the client. */
|
|
151
|
+
export declare function SUGGESTIONS(): string[];
|
|
152
|
+
export declare function num(env: Record<string, unknown>, key: string, fallback: number): number;
|
|
153
|
+
export declare function today(): string;
|
|
154
|
+
export declare function sha256Hex(s: string): Promise<string>;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DATASETS,
|
|
3
|
+
LIMITS,
|
|
4
|
+
MODELS,
|
|
5
|
+
SUGGESTIONS,
|
|
6
|
+
THRESHOLDS,
|
|
7
|
+
answerEffort,
|
|
8
|
+
datasetAllowed,
|
|
9
|
+
datasetsFor,
|
|
10
|
+
effortBudget,
|
|
11
|
+
hasPermission,
|
|
12
|
+
num,
|
|
13
|
+
processExpansion,
|
|
14
|
+
requestEffort,
|
|
15
|
+
roleModel,
|
|
16
|
+
sha256Hex,
|
|
17
|
+
today
|
|
18
|
+
} from "./chunk-WOGQM7DJ.js";
|
|
19
|
+
import "./chunk-MB74PTRM.js";
|
|
20
|
+
export {
|
|
21
|
+
DATASETS,
|
|
22
|
+
LIMITS,
|
|
23
|
+
MODELS,
|
|
24
|
+
SUGGESTIONS,
|
|
25
|
+
THRESHOLDS,
|
|
26
|
+
answerEffort,
|
|
27
|
+
datasetAllowed,
|
|
28
|
+
datasetsFor,
|
|
29
|
+
effortBudget,
|
|
30
|
+
hasPermission,
|
|
31
|
+
num,
|
|
32
|
+
processExpansion,
|
|
33
|
+
requestEffort,
|
|
34
|
+
roleModel,
|
|
35
|
+
sha256Hex,
|
|
36
|
+
today
|
|
37
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export interface DeclaredContext {
|
|
2
|
+
kind: "page" | "entity" | "document" | "account";
|
|
3
|
+
/** display label ("this certificate R60/2021-A-EX1-26.01") — echoed
|
|
4
|
+
* into context_applied for the panel's context line */
|
|
5
|
+
label: string;
|
|
6
|
+
/** the publishing page's route (page/entity contexts) */
|
|
7
|
+
route?: string;
|
|
8
|
+
/** the corpus reference to scope retrieval to (entity/document
|
|
9
|
+
* contexts): the URN the SMART models carry as clause provenance
|
|
10
|
+
* (urn:oiml:pub:r:60-1:2021) or the plain docidentifier */
|
|
11
|
+
doc?: string;
|
|
12
|
+
edition?: string;
|
|
13
|
+
}
|
|
14
|
+
/** The account context's live-read echo (TODO.ai-platform/03): WHEN the
|
|
15
|
+
* live data was read, WHICH stores answered, and how many records the
|
|
16
|
+
* answer could ground in. Present only on a successful read — a failed
|
|
17
|
+
* or refused read reports through `note` instead, never silently. */
|
|
18
|
+
export interface LiveEcho {
|
|
19
|
+
read_at: string;
|
|
20
|
+
stores: string[];
|
|
21
|
+
records: number;
|
|
22
|
+
}
|
|
23
|
+
export interface AppliedContext {
|
|
24
|
+
kind: "page" | "entity" | "document" | "account" | "none";
|
|
25
|
+
label?: string;
|
|
26
|
+
/** the publication the DECLARED context actually scoped retrieval to
|
|
27
|
+
* ("OIML R 60:2021"); null when the declaration did not scope this
|
|
28
|
+
* answer (see `note` for the honest why) */
|
|
29
|
+
scoped_to?: string | null;
|
|
30
|
+
/** why a doc-carrying declaration did not scope the answer:
|
|
31
|
+
* the corpus does not carry it, or the question named its own
|
|
32
|
+
* publication (the user's explicit words always win over the chip);
|
|
33
|
+
* for the account kind: why the live data was NOT read (the honest
|
|
34
|
+
* degradation — sign in, the window lapsed, the cone refused) */
|
|
35
|
+
note?: "document-not-in-corpus" | "question-document-wins" | "sign-in-required" | "live-window-expired" | "live-unavailable";
|
|
36
|
+
/** the account kind's live-read echo (TODO.ai-platform/03) */
|
|
37
|
+
live?: LiveEcho;
|
|
38
|
+
/** the model plane's bound node (TODO.ai-platform/05): the model-aware
|
|
39
|
+
* chip grounded this answer in the model node itself — its constraint,
|
|
40
|
+
* its provenance, its tests */
|
|
41
|
+
model?: {
|
|
42
|
+
node_id: string;
|
|
43
|
+
kind: string;
|
|
44
|
+
standard: string;
|
|
45
|
+
clause?: string;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export declare const NO_CONTEXT: AppliedContext;
|
|
49
|
+
/** Parse + bound the ask body's optional `context` field. Anything
|
|
50
|
+
* malformed degrades to null (no context), never to a 400 — a context
|
|
51
|
+
* the service can't parse is a context it must not apply. */
|
|
52
|
+
export declare function parseContext(body: any): DeclaredContext | null;
|
|
53
|
+
export interface DocScope {
|
|
54
|
+
/** the Vectorize doc_number filter value (the publication FAMILY —
|
|
55
|
+
* an entity's clause provenance spans parts: R 60-1 requirements,
|
|
56
|
+
* R 60-2 tests) */
|
|
57
|
+
doc_number: string;
|
|
58
|
+
edition?: string;
|
|
59
|
+
/** the canonical label form for the echo + the prompt note */
|
|
60
|
+
label: string;
|
|
61
|
+
}
|
|
62
|
+
/** Parse the two reference forms the estate speaks: the URN the SMART
|
|
63
|
+
* models carry as clause provenance (urn:oiml:pub:r:60-1:2021) and the
|
|
64
|
+
* plain docidentifier (OIML R 60-1:2021 / R 60). Part designations
|
|
65
|
+
* parse but do not narrow the scope (the family IS the scope). */
|
|
66
|
+
export declare function parseDocRef(doc: string, edition?: string): DocScope | null;
|
|
67
|
+
/** Read the FIRST publication the question's own text names, in the
|
|
68
|
+
* letter+number forms the corpus speaks ("R 76", "r76-1", "OIML B 18",
|
|
69
|
+
* "R 60:2021"). "A document named in the question wins over the declared
|
|
70
|
+
* chip" is only honest when it is the user's own words that win — the
|
|
71
|
+
* understand stage's doc_number is an LLM extraction that also fires on
|
|
72
|
+
* domain priors ("maximum permissible errors" → R 76, no document named
|
|
73
|
+
* — the merged tree's ctx-document-r111 flake) and can miss a naming the
|
|
74
|
+
* text plainly carries; both directions are decided from the TEXT here.
|
|
75
|
+
* A glued single digit is a class/designation ("E2 weights"), never a
|
|
76
|
+
* naming; part designations parse but do not narrow the family. */
|
|
77
|
+
export declare function namedDocumentIn(query: string): DocScope | null;
|
|
78
|
+
/** Resolve the declared document against the publications registry: the
|
|
79
|
+
* family must exist in the corpus, else the scope honestly does not
|
|
80
|
+
* apply (the answer runs on the general corpus and context_applied's
|
|
81
|
+
* scoped_to stays null). A registry READ failure proceeds with the
|
|
82
|
+
* parsed scope — a scoped refusal is more honest than silently
|
|
83
|
+
* widening to the whole corpus. */
|
|
84
|
+
export declare function resolveDocScope(env: any, ctx: DeclaredContext): Promise<DocScope | null>;
|
|
85
|
+
export declare function appliedContext(declared: DeclaredContext | null, scope: DocScope | null, note?: AppliedContext["note"], live?: LiveEcho): AppliedContext;
|
|
86
|
+
/** Validate a context_applied object arriving from a client (the
|
|
87
|
+
* conversations API stores the echo with the message). Bounded and
|
|
88
|
+
* shape-checked; garbage degrades to null (nothing stored). */
|
|
89
|
+
export declare function parseAppliedContext(v: any): AppliedContext | null;
|
|
90
|
+
/** The prompt note the declared context contributes (rides the
|
|
91
|
+
* retrieval-note slot buildMessages already carries). The entity note
|
|
92
|
+
* is explicit about the wave-02 boundary: the entity's OWN DATA is not
|
|
93
|
+
* in scope (that is wave 03's live-data exchange) — the grounding is
|
|
94
|
+
* the governing publication's clauses. */
|
|
95
|
+
export declare function contextNote(declared: DeclaredContext | null, scope: DocScope | null): string | undefined;
|
|
96
|
+
/** A minimal knowledge-intent understanding for when the understand
|
|
97
|
+
* call failed but a declared document still scopes retrieval: the
|
|
98
|
+
* whole doc-scoped machinery (the family boost, the typed pin, the
|
|
99
|
+
* grade skip) keys off understanding.doc_number. */
|
|
100
|
+
export declare function syntheticUnderstanding(scope: DocScope): {
|
|
101
|
+
intent: "knowledge";
|
|
102
|
+
docidentifier: string;
|
|
103
|
+
doc_number: string;
|
|
104
|
+
edition: string | null;
|
|
105
|
+
language: null;
|
|
106
|
+
process_intent: boolean;
|
|
107
|
+
term: null;
|
|
108
|
+
defined_terms: never[];
|
|
109
|
+
standalone_query: string;
|
|
110
|
+
complexity: "simple";
|
|
111
|
+
query_variants: never[];
|
|
112
|
+
sub_queries: never[];
|
|
113
|
+
hypothetical_answer: string;
|
|
114
|
+
follow_ups: never[];
|
|
115
|
+
};
|
package/dist/drafts.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export interface DraftSample {
|
|
2
|
+
serial: string;
|
|
3
|
+
condition?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ApplicationPrefillFields {
|
|
6
|
+
/** the Recommendation, as the estate URN (urn:oiml:pub:r:60:2021) */
|
|
7
|
+
standard_doc: string;
|
|
8
|
+
/** display label ("OIML R 60:2021") */
|
|
9
|
+
standard_label?: string;
|
|
10
|
+
family_designation?: string;
|
|
11
|
+
group_label?: string;
|
|
12
|
+
model_designation?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
samples?: DraftSample[];
|
|
15
|
+
scheme?: "A" | "B";
|
|
16
|
+
}
|
|
17
|
+
export interface DraftDrop {
|
|
18
|
+
field: string;
|
|
19
|
+
value: string;
|
|
20
|
+
reason: string;
|
|
21
|
+
}
|
|
22
|
+
export interface DraftAct {
|
|
23
|
+
kind: "draft";
|
|
24
|
+
act: "application_prefill";
|
|
25
|
+
version: 1;
|
|
26
|
+
title: string;
|
|
27
|
+
prepared_at: string;
|
|
28
|
+
/** ALWAYS true — the draft is an input to the real form, never a
|
|
29
|
+
* channel; the user's own click is the only commit. */
|
|
30
|
+
requires_confirmation: true;
|
|
31
|
+
fields: ApplicationPrefillFields;
|
|
32
|
+
dropped?: DraftDrop[];
|
|
33
|
+
notes?: string[];
|
|
34
|
+
}
|
|
35
|
+
export interface DraftCitation {
|
|
36
|
+
docidentifier: string;
|
|
37
|
+
edition?: string;
|
|
38
|
+
status?: string;
|
|
39
|
+
}
|
|
40
|
+
export type DraftRefusalReason = "sign_in_required" | "not_configured" | "window_expired" | "exchange_refused" | "role_refused" | "standard_unresolved" | "extraction_failed";
|
|
41
|
+
export type DraftVerdict = {
|
|
42
|
+
status: "draft";
|
|
43
|
+
draft: DraftAct;
|
|
44
|
+
answer: string;
|
|
45
|
+
citation: DraftCitation | null;
|
|
46
|
+
} | {
|
|
47
|
+
status: "refused";
|
|
48
|
+
reason: DraftRefusalReason;
|
|
49
|
+
answer: string;
|
|
50
|
+
citation: DraftCitation | null;
|
|
51
|
+
};
|
|
52
|
+
/** The delegation outcome the ask handler computed (livedata.ts's
|
|
53
|
+
* exchange; this module never performs it). */
|
|
54
|
+
export type DraftDelegation = {
|
|
55
|
+
status: "ok";
|
|
56
|
+
token: string;
|
|
57
|
+
} | {
|
|
58
|
+
status: "unsigned" | "not_configured" | "window_expired" | "refused" | "op_unreachable";
|
|
59
|
+
};
|
|
60
|
+
export interface PrepareOpts {
|
|
61
|
+
act: "application_prefill";
|
|
62
|
+
query: string;
|
|
63
|
+
history: Array<{
|
|
64
|
+
role: string;
|
|
65
|
+
content: string;
|
|
66
|
+
}>;
|
|
67
|
+
member: {
|
|
68
|
+
sub: string;
|
|
69
|
+
} | null;
|
|
70
|
+
delegation: DraftDelegation;
|
|
71
|
+
/** the platform's client id at the OP (the service_roles key) */
|
|
72
|
+
platformClientId?: string;
|
|
73
|
+
/** the extraction model (the cheap understand lane) */
|
|
74
|
+
model: string;
|
|
75
|
+
}
|
|
76
|
+
/** The draft intent, or null. "What documents does an application
|
|
77
|
+
* need?" and "where is my application?" never trigger — no act verb. */
|
|
78
|
+
export declare function detectDraftIntent(query: string): "application_prefill" | null;
|
|
79
|
+
interface Extraction {
|
|
80
|
+
standard?: string;
|
|
81
|
+
family_designation?: {
|
|
82
|
+
value?: string;
|
|
83
|
+
source?: string;
|
|
84
|
+
};
|
|
85
|
+
group_label?: {
|
|
86
|
+
value?: string;
|
|
87
|
+
source?: string;
|
|
88
|
+
};
|
|
89
|
+
model_designation?: {
|
|
90
|
+
value?: string;
|
|
91
|
+
source?: string;
|
|
92
|
+
};
|
|
93
|
+
description?: {
|
|
94
|
+
value?: string;
|
|
95
|
+
source?: string;
|
|
96
|
+
};
|
|
97
|
+
scheme?: {
|
|
98
|
+
value?: string;
|
|
99
|
+
source?: string;
|
|
100
|
+
};
|
|
101
|
+
samples?: Array<{
|
|
102
|
+
serial?: string;
|
|
103
|
+
condition?: string;
|
|
104
|
+
source?: string;
|
|
105
|
+
}>;
|
|
106
|
+
}
|
|
107
|
+
export interface GuardedFields {
|
|
108
|
+
standard?: string;
|
|
109
|
+
family_designation?: string;
|
|
110
|
+
group_label?: string;
|
|
111
|
+
model_designation?: string;
|
|
112
|
+
description?: string;
|
|
113
|
+
scheme?: "A" | "B";
|
|
114
|
+
samples?: DraftSample[];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* THE GUARD: a proposed field rides the draft only when its source span
|
|
118
|
+
* appears in the user's own messages AND the value appears in the span —
|
|
119
|
+
* the proposal must be the user's words, never the model's completion.
|
|
120
|
+
* Every rejection is a named drop (the answer accounts for each). */
|
|
121
|
+
export declare function traceabilityGuard(extraction: Extraction, userTurns: string[]): {
|
|
122
|
+
kept: GuardedFields;
|
|
123
|
+
dropped: DraftDrop[];
|
|
124
|
+
};
|
|
125
|
+
/** The draft act's full path: the member gate → the delegation's honest
|
|
126
|
+
* states → the role permission (the platform's vocabulary) → the
|
|
127
|
+
* extraction → the guard → the registry anchor → the draft. */
|
|
128
|
+
export declare function prepareDraft(env: any, opts: PrepareOpts): Promise<DraftVerdict>;
|
|
129
|
+
export {};
|
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** The Workers AI binding — run() only. Domain code goes through
|
|
2
|
+
* portModelRunner(env); a precisely-typed AI closes the door on passing
|
|
3
|
+
* the raw binding where a ModelRunner is expected (the v2.107 outage). */
|
|
4
|
+
export interface AiBinding {
|
|
5
|
+
run(model: string, body: unknown): Promise<unknown>;
|
|
6
|
+
}
|
|
7
|
+
export interface Env {
|
|
8
|
+
AI: AiBinding;
|
|
9
|
+
VECTORIZE: any;
|
|
10
|
+
EXP_PRIMMEL: any;
|
|
11
|
+
EXP_COMPOSED: any;
|
|
12
|
+
EXP_PLAIN: any;
|
|
13
|
+
EXP_ADC: any;
|
|
14
|
+
EXP_MKO: any;
|
|
15
|
+
EXP_PFLAT: any;
|
|
16
|
+
GLOSSARY: any;
|
|
17
|
+
EXP_DB: D1Database;
|
|
18
|
+
CACHE: KVNamespace;
|
|
19
|
+
DB: D1Database;
|
|
20
|
+
ASSETS: Fetcher;
|
|
21
|
+
INDEX_VERSION: string;
|
|
22
|
+
UNIT_ASSETS: R2Bucket;
|
|
23
|
+
ANON_DAY_ASK: string;
|
|
24
|
+
ANON_DAY_SEARCH: string;
|
|
25
|
+
KEY_DAY_ASK_DEFAULT: string;
|
|
26
|
+
ANON_DAY_HARD_CAP: string;
|
|
27
|
+
ADMIN_TOKEN?: string;
|
|
28
|
+
MEMBER_DAY_ASK?: string;
|
|
29
|
+
ENRICH_MODEL?: string;
|
|
30
|
+
OIDC_ISSUER?: string;
|
|
31
|
+
OIDC_CLIENT_ID?: string;
|
|
32
|
+
OIDC_CLIENT_SECRET?: string;
|
|
33
|
+
OIDC_REDIRECT_URI?: string;
|
|
34
|
+
SESSION_SECRET?: string;
|
|
35
|
+
/** TODO.ai-platform/03 — the "my account" live-data delegation: the
|
|
36
|
+
* platform instance's API base + its client id at the OP (the
|
|
37
|
+
* delegation's scope target). Absent = the account chip honestly
|
|
38
|
+
* reports the live read unwired on this deployment. */
|
|
39
|
+
SMART_PLATFORM_API?: string;
|
|
40
|
+
SMART_PLATFORM_CLIENT_ID?: string;
|
|
41
|
+
INTERNAL_SERVICE?: {
|
|
42
|
+
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
import type { ModelRunner } from "./ports/model.ts";
|
|
46
|
+
import type { VectorIndex } from "./ports/vector.ts";
|
|
47
|
+
import type { Kv } from "./ports/kv.ts";
|
|
48
|
+
import type { Blobs } from "./ports/blobs.ts";
|
|
49
|
+
import type { Runtime } from "./ports/runtime.ts";
|
|
50
|
+
export declare function portModelRunner(env: Env): ModelRunner;
|
|
51
|
+
export declare function portIndex(env: Env, which?: "public" | "primmel" | "composed" | "plain" | "adoc" | "mko" | "pflat" | "glossary"): VectorIndex;
|
|
52
|
+
export declare function portKv(env: Env): Kv;
|
|
53
|
+
export declare function portBlobs(env: Env): Blobs;
|
|
54
|
+
/** Does the deployment bind this lane index? Presence wiring stays in
|
|
55
|
+
* the ports layer so domain stages never touch raw bindings. */
|
|
56
|
+
export declare function hasLane(env: Env, which: "glossary"): boolean;
|
|
57
|
+
export declare function portRuntime(ctx: ExecutionContext | undefined): Runtime;
|
package/dist/grader.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type RetrievalGrade = "good" | "weak" | "bad";
|
|
2
|
+
export declare function gradeRetrieval(ai: any, model: string, query: string, passages: string[]): Promise<RetrievalGrade>;
|
|
3
|
+
export declare function scoreJudge(ai: any, model: string, systemPrompt: string, userPrompt: string): Promise<number | null>;
|
package/dist/graph.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Env } from "./env";
|
|
2
|
+
export declare function graphExpand(env: Env, u: {
|
|
3
|
+
term?: string | null;
|
|
4
|
+
defined_terms?: string[];
|
|
5
|
+
docidentifier?: string | null;
|
|
6
|
+
} | null): Promise<string[] | undefined>;
|
|
7
|
+
/** Edition registry note (documents table): when the query names a
|
|
8
|
+
* publication, tell the model which editions are ACTIVE so superseded
|
|
9
|
+
* passages are treated as such — derived status from successor edges,
|
|
10
|
+
* not the fallible relaton status field. */
|
|
11
|
+
export declare function editionNote(env: Env, u: {
|
|
12
|
+
doc_number?: string | null;
|
|
13
|
+
} | null): Promise<string | undefined>;
|
package/dist/hybrid.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Hit } from "./pipeline";
|
|
2
|
+
/** Rank all candidates by keyword overlap against the query. */
|
|
3
|
+
export declare function keywordRank(query: string, hits: Hit[]): Hit[];
|
|
4
|
+
/** Fuse two rankings with Reciprocal Rank Fusion.
|
|
5
|
+
* score(d) = Σ 1/(k + rank_i(d)) — rank-agnostic, robust across
|
|
6
|
+
* heterogeneous scorers (dense + sparse). */
|
|
7
|
+
export declare function rrfFuse(dense: Hit[], keyword: Hit[], keep: number): Hit[];
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { setProfile } from "./profile.ts";
|
|
2
|
+
import type { Env } from "./env";
|
|
3
|
+
export type { Env };
|
|
4
|
+
import { type Route } from "./lib/router";
|
|
5
|
+
export declare const ROUTES: Route[];
|
|
6
|
+
declare const _default: {
|
|
7
|
+
fetch(req: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|