@shobyde/boaz 0.0.0-stage → 0.8.2
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 +21 -0
- package/README.md +422 -2
- package/dist/build/codes.d.ts +16 -0
- package/dist/build/codes.d.ts.map +1 -0
- package/dist/build/codes.js +72 -0
- package/dist/build/codes.js.map +1 -0
- package/dist/build/extract.d.ts +45 -0
- package/dist/build/extract.d.ts.map +1 -0
- package/dist/build/extract.js +484 -0
- package/dist/build/extract.js.map +1 -0
- package/dist/build/glob.d.ts +11 -0
- package/dist/build/glob.d.ts.map +1 -0
- package/dist/build/glob.js +88 -0
- package/dist/build/glob.js.map +1 -0
- package/dist/build/index.d.ts +7 -0
- package/dist/build/index.d.ts.map +1 -0
- package/dist/build/index.js +4 -0
- package/dist/build/index.js.map +1 -0
- package/dist/build/probes.d.ts +41 -0
- package/dist/build/probes.d.ts.map +1 -0
- package/dist/build/probes.js +134 -0
- package/dist/build/probes.js.map +1 -0
- package/dist/build/report.d.ts +11 -0
- package/dist/build/report.d.ts.map +1 -0
- package/dist/build/report.js +39 -0
- package/dist/build/report.js.map +1 -0
- package/dist/cli/audit.d.ts +15 -0
- package/dist/cli/audit.d.ts.map +1 -0
- package/dist/cli/audit.js +68 -0
- package/dist/cli/audit.js.map +1 -0
- package/dist/cli/bench.d.ts +7 -0
- package/dist/cli/bench.d.ts.map +1 -0
- package/dist/cli/bench.js +147 -0
- package/dist/cli/bench.js.map +1 -0
- package/dist/cli/harness.d.ts +45 -0
- package/dist/cli/harness.d.ts.map +1 -0
- package/dist/cli/harness.js +90 -0
- package/dist/cli/harness.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +404 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/probes.d.ts +20 -0
- package/dist/cli/probes.d.ts.map +1 -0
- package/dist/cli/probes.js +27 -0
- package/dist/cli/probes.js.map +1 -0
- package/dist/cli/skill-template.d.ts +2 -0
- package/dist/cli/skill-template.d.ts.map +1 -0
- package/dist/cli/skill-template.js +254 -0
- package/dist/cli/skill-template.js.map +1 -0
- package/dist/core/actions.d.ts +67 -0
- package/dist/core/actions.d.ts.map +1 -0
- package/dist/core/actions.js +357 -0
- package/dist/core/actions.js.map +1 -0
- package/dist/core/define.d.ts +25 -0
- package/dist/core/define.d.ts.map +1 -0
- package/dist/core/define.js +76 -0
- package/dist/core/define.js.map +1 -0
- package/dist/core/execute.d.ts +75 -0
- package/dist/core/execute.d.ts.map +1 -0
- package/dist/core/execute.js +145 -0
- package/dist/core/execute.js.map +1 -0
- package/dist/core/index.d.ts +35 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +20 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/lemmas.d.ts +32 -0
- package/dist/core/lemmas.d.ts.map +1 -0
- package/dist/core/lemmas.js +80 -0
- package/dist/core/lemmas.js.map +1 -0
- package/dist/core/lexical-engine.d.ts +18 -0
- package/dist/core/lexical-engine.d.ts.map +1 -0
- package/dist/core/lexical-engine.js +296 -0
- package/dist/core/lexical-engine.js.map +1 -0
- package/dist/core/loop.d.ts +51 -0
- package/dist/core/loop.d.ts.map +1 -0
- package/dist/core/loop.js +432 -0
- package/dist/core/loop.js.map +1 -0
- package/dist/core/mcp.d.ts +119 -0
- package/dist/core/mcp.d.ts.map +1 -0
- package/dist/core/mcp.js +253 -0
- package/dist/core/mcp.js.map +1 -0
- package/dist/core/memory.d.ts +106 -0
- package/dist/core/memory.d.ts.map +1 -0
- package/dist/core/memory.js +185 -0
- package/dist/core/memory.js.map +1 -0
- package/dist/core/plan.d.ts +83 -0
- package/dist/core/plan.d.ts.map +1 -0
- package/dist/core/plan.js +258 -0
- package/dist/core/plan.js.map +1 -0
- package/dist/core/preferences.d.ts +54 -0
- package/dist/core/preferences.d.ts.map +1 -0
- package/dist/core/preferences.js +83 -0
- package/dist/core/preferences.js.map +1 -0
- package/dist/core/prompt.d.ts +23 -0
- package/dist/core/prompt.d.ts.map +1 -0
- package/dist/core/prompt.js +76 -0
- package/dist/core/prompt.js.map +1 -0
- package/dist/core/question.d.ts +96 -0
- package/dist/core/question.d.ts.map +1 -0
- package/dist/core/question.js +501 -0
- package/dist/core/question.js.map +1 -0
- package/dist/core/registry.d.ts +33 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/registry.js +72 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/retriever.d.ts +48 -0
- package/dist/core/retriever.d.ts.map +1 -0
- package/dist/core/retriever.js +123 -0
- package/dist/core/retriever.js.map +1 -0
- package/dist/core/schema.d.ts +27 -0
- package/dist/core/schema.d.ts.map +1 -0
- package/dist/core/schema.js +231 -0
- package/dist/core/schema.js.map +1 -0
- package/dist/core/skill.d.ts +105 -0
- package/dist/core/skill.d.ts.map +1 -0
- package/dist/core/skill.js +205 -0
- package/dist/core/skill.js.map +1 -0
- package/dist/core/summarise.d.ts +52 -0
- package/dist/core/summarise.d.ts.map +1 -0
- package/dist/core/summarise.js +146 -0
- package/dist/core/summarise.js.map +1 -0
- package/dist/core/tools.d.ts +21 -0
- package/dist/core/tools.d.ts.map +1 -0
- package/dist/core/tools.js +120 -0
- package/dist/core/tools.js.map +1 -0
- package/dist/core/types.d.ts +199 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +5 -0
- package/dist/core/types.js.map +1 -0
- package/dist/dom/index.d.ts +22 -0
- package/dist/dom/index.d.ts.map +1 -0
- package/dist/dom/index.js +94 -0
- package/dist/dom/index.js.map +1 -0
- package/dist/extract/index.d.ts +36 -0
- package/dist/extract/index.d.ts.map +1 -0
- package/dist/extract/index.js +86 -0
- package/dist/extract/index.js.map +1 -0
- package/dist/react/index.d.ts +52 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +131 -0
- package/dist/react/index.js.map +1 -0
- package/dist/rules/engine.d.ts +152 -0
- package/dist/rules/engine.d.ts.map +1 -0
- package/dist/rules/engine.js +364 -0
- package/dist/rules/engine.js.map +1 -0
- package/dist/rules/facts.d.ts +63 -0
- package/dist/rules/facts.d.ts.map +1 -0
- package/dist/rules/facts.js +115 -0
- package/dist/rules/facts.js.map +1 -0
- package/dist/rules/index.d.ts +10 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +5 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/knowledge.d.ts +78 -0
- package/dist/rules/knowledge.d.ts.map +1 -0
- package/dist/rules/knowledge.js +254 -0
- package/dist/rules/knowledge.js.map +1 -0
- package/dist/vite/index.d.ts +26 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +112 -0
- package/dist/vite/index.js.map +1 -0
- package/package.json +108 -4
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { CapabilityIndex, tokenize } from '../core/retriever.js';
|
|
2
|
+
import { analyzeQuestion } from '../core/question.js';
|
|
3
|
+
import { createLexicalEngine } from '../core/lexical-engine.js';
|
|
4
|
+
import { createFieldScanner, requestedFields, } from '../extract/index.js';
|
|
5
|
+
import { KnowledgeBase } from './knowledge.js';
|
|
6
|
+
/** Facts the engine injects per turn: what the visitor asked about, and what the page said. */
|
|
7
|
+
const ASKED = 'asked';
|
|
8
|
+
const FIELD = 'field';
|
|
9
|
+
/**
|
|
10
|
+
* A request that names a controller verb ("show me the archive", "open the
|
|
11
|
+
* newest article") is asking the app to do something, not asking the knowledge
|
|
12
|
+
* base a question. Answer rules stay out of the way so the capability decides.
|
|
13
|
+
*/
|
|
14
|
+
const DEFAULT_CONTROLLER = 'show|open|go|take|read|expand|copy|download|print|visit|browse|scroll|jump|navigate|see';
|
|
15
|
+
function controllerPattern(extra = []) {
|
|
16
|
+
const verbs = [
|
|
17
|
+
...DEFAULT_CONTROLLER.split('|'),
|
|
18
|
+
...extra.map((verb) => verb.replace(/[^a-z]/gi, '')).filter(Boolean),
|
|
19
|
+
];
|
|
20
|
+
return new RegExp(`^(${verbs.join('|')})\\b`, 'i');
|
|
21
|
+
}
|
|
22
|
+
/** "and…", "what about…", "his…" and bare continuations lean on the last turn. */
|
|
23
|
+
const FOLLOW_UP = /^(and|also|what about|how about|then|more|why)\b|^(his|her|their|its)\b/i;
|
|
24
|
+
/** Words that carry no subject of their own: a query made only of these is an ellipsis. */
|
|
25
|
+
const ELLIPSIS_WORDS = new Set([
|
|
26
|
+
'and', 'also', 'what', 'about', 'how', 'then', 'more', 'why', 'his', 'her', 'their', 'its',
|
|
27
|
+
'it', 'that', 'those', 'them', 'one', 'ones', 'please', 'tell', 'me', 'again', 'else', 'any',
|
|
28
|
+
]);
|
|
29
|
+
function callTool(id, args) {
|
|
30
|
+
return ['```json', JSON.stringify({ tool: id, arguments: args }), '```'].join('\n');
|
|
31
|
+
}
|
|
32
|
+
const QUERY_RESULT = /^\[boaz\] Query "([^"]+)" returned ([\s\S]*)$/;
|
|
33
|
+
const ACTION_RESULT = /^\[boaz\] "([^"]+)" ran successfully and returned ([\s\S]*)$/;
|
|
34
|
+
/** Results of calls made since the visitor's last message, keyed by capability. */
|
|
35
|
+
function observationsThisTurn(request) {
|
|
36
|
+
const users = [];
|
|
37
|
+
request.messages.forEach((message, index) => {
|
|
38
|
+
if (message.role === 'user' && !message.content.startsWith('[boaz]'))
|
|
39
|
+
users.push(index);
|
|
40
|
+
});
|
|
41
|
+
const lastUser = users[users.length - 1] ?? -1;
|
|
42
|
+
const found = new Map();
|
|
43
|
+
for (const message of request.messages.slice(lastUser + 1)) {
|
|
44
|
+
if (message.role !== 'user')
|
|
45
|
+
continue;
|
|
46
|
+
const match = QUERY_RESULT.exec(message.content) ?? ACTION_RESULT.exec(message.content);
|
|
47
|
+
if (!match)
|
|
48
|
+
continue;
|
|
49
|
+
const [, id, raw] = match;
|
|
50
|
+
const body = (raw ?? '').replace(/\.\s*$/, '');
|
|
51
|
+
try {
|
|
52
|
+
found.set(id, JSON.parse(body));
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
found.set(id, body);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return found;
|
|
59
|
+
}
|
|
60
|
+
function lastUserMessage(request) {
|
|
61
|
+
const users = request.messages.filter((message) => message.role === 'user' && !message.content.startsWith('[boaz]'));
|
|
62
|
+
return users[users.length - 1]?.content ?? '';
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* A rule that joins on `asked(?T)` exists to answer "which X uses the Y the
|
|
66
|
+
* visitor named". When the question does name a declared constant, that rule is
|
|
67
|
+
* the right one even if a rule about the same nouns scores a little higher.
|
|
68
|
+
*/
|
|
69
|
+
function joinsAskedConstant(rule, knowledge) {
|
|
70
|
+
const rel = rule.goal.split('(')[0]?.trim();
|
|
71
|
+
if (!rel)
|
|
72
|
+
return false;
|
|
73
|
+
return knowledge.rules.some((candidate) => candidate.head.rel === rel && candidate.body.some((atom) => atom.rel === 'asked'));
|
|
74
|
+
}
|
|
75
|
+
function answerCapability(rule) {
|
|
76
|
+
return {
|
|
77
|
+
id: rule.id,
|
|
78
|
+
kind: 'query',
|
|
79
|
+
title: rule.title,
|
|
80
|
+
description: rule.title,
|
|
81
|
+
keywords: rule.keywords,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export function createRulesEngine(options) {
|
|
85
|
+
const { knowledge } = options;
|
|
86
|
+
const answers = options.answers;
|
|
87
|
+
const index = new CapabilityIndex(answers.map(answerCapability));
|
|
88
|
+
const fallback = options.fallback ?? createLexicalEngine({ capabilities: options.capabilities ?? [] });
|
|
89
|
+
const baseFacts = options.facts ?? [];
|
|
90
|
+
for (const constant of options.constants ?? [])
|
|
91
|
+
knowledge.declare(constant);
|
|
92
|
+
const scanner = options.grounding
|
|
93
|
+
? (options.grounding.scanner ?? createFieldScanner(options.grounding.patterns ? { patterns: options.grounding.patterns } : {}))
|
|
94
|
+
: undefined;
|
|
95
|
+
const controller = controllerPattern(options.controllerVerbs);
|
|
96
|
+
const memoryEnabled = options.memory !== false;
|
|
97
|
+
const memoryLimit = (typeof options.memory === 'object' && options.memory.turns) || 6;
|
|
98
|
+
const memory = {
|
|
99
|
+
ruleId: null,
|
|
100
|
+
planned: null,
|
|
101
|
+
terms: [],
|
|
102
|
+
fields: [],
|
|
103
|
+
hits: [],
|
|
104
|
+
entities: [],
|
|
105
|
+
recentQueries: [],
|
|
106
|
+
excludes: [],
|
|
107
|
+
turns: 0,
|
|
108
|
+
};
|
|
109
|
+
const runRule = (rule, query, terms, hits, assume, observed = {}, kb = knowledge, mentions = [], excludes = [], combine = null) => {
|
|
110
|
+
const solutions = kb.query(rule.goal, { assume });
|
|
111
|
+
const context = {
|
|
112
|
+
query,
|
|
113
|
+
bindings: solutions[0]?.bindings ?? {},
|
|
114
|
+
solutions,
|
|
115
|
+
knowledge: kb,
|
|
116
|
+
terms,
|
|
117
|
+
mentions,
|
|
118
|
+
exclude: excludes,
|
|
119
|
+
combine,
|
|
120
|
+
hits,
|
|
121
|
+
observed,
|
|
122
|
+
// What the app can do, so a rule can answer questions about the assistant
|
|
123
|
+
// itself ("what can you do?") from the same manifest the UI advertises.
|
|
124
|
+
capabilities: (options.capabilities ?? []).map((capability) => ({
|
|
125
|
+
id: capability.id,
|
|
126
|
+
...(capability.title ? { title: capability.title } : {}),
|
|
127
|
+
})),
|
|
128
|
+
lookup: (goal) => kb.query(goal, { assume }),
|
|
129
|
+
};
|
|
130
|
+
const text = rule.compose(context).trim();
|
|
131
|
+
if (!text)
|
|
132
|
+
return null;
|
|
133
|
+
if (memoryEnabled) {
|
|
134
|
+
memory.ruleId = rule.id;
|
|
135
|
+
memory.planned = null;
|
|
136
|
+
memory.terms = terms;
|
|
137
|
+
memory.fields = hits.map((hit) => hit.kind);
|
|
138
|
+
memory.hits = hits;
|
|
139
|
+
memory.entities = [...new Set(solutions.flatMap((solution) => Object.values(solution.bindings)))];
|
|
140
|
+
memory.excludes = excludes;
|
|
141
|
+
memory.recentQueries = [...memory.recentQueries, query].slice(-memoryLimit);
|
|
142
|
+
memory.turns += 1;
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
text,
|
|
146
|
+
steps: [
|
|
147
|
+
{
|
|
148
|
+
type: 'inference',
|
|
149
|
+
capabilityId: rule.id,
|
|
150
|
+
goal: rule.goal,
|
|
151
|
+
terms,
|
|
152
|
+
solutions: solutions.map((solution) => solution.bindings),
|
|
153
|
+
rule: kb.rules.find((r) => r.head.rel === rule.goal.split('(')[0]?.trim())?.source,
|
|
154
|
+
...(rule.explain ? { label: rule.explain(context).trim() } : {}),
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
return {
|
|
160
|
+
id: 'rules',
|
|
161
|
+
memory,
|
|
162
|
+
resetMemory() {
|
|
163
|
+
memory.ruleId = null;
|
|
164
|
+
memory.planned = null;
|
|
165
|
+
memory.terms = [];
|
|
166
|
+
memory.fields = [];
|
|
167
|
+
memory.hits = [];
|
|
168
|
+
memory.entities = [];
|
|
169
|
+
memory.recentQueries = [];
|
|
170
|
+
memory.excludes = [];
|
|
171
|
+
memory.turns = 0;
|
|
172
|
+
},
|
|
173
|
+
async complete(request) {
|
|
174
|
+
const query = lastUserMessage(request).trim();
|
|
175
|
+
if (!query)
|
|
176
|
+
return fallback.complete(request);
|
|
177
|
+
const followUp = FOLLOW_UP.test(query);
|
|
178
|
+
// Fields the question names: read the host's text for them. Grounding runs
|
|
179
|
+
// whether or not a fact exists, so a rule can prefer facts and fall back to
|
|
180
|
+
// what the page actually says.
|
|
181
|
+
const fields = requestedFields(query);
|
|
182
|
+
const hits = [];
|
|
183
|
+
if (scanner && options.grounding && fields.length > 0) {
|
|
184
|
+
try {
|
|
185
|
+
const text = await options.grounding.read(query);
|
|
186
|
+
hits.push(...scanner.scan(text, fields));
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
// Reading the page is best effort; a failure is not an answer failure.
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// Pick the rule before resolving terms: a rule with steps does not know
|
|
193
|
+
// its vocabulary until the tool has run, so retrieval must use the words
|
|
194
|
+
// the visitor typed, not the constants the page happens to declare.
|
|
195
|
+
// A short question is still a question: "where is he based?" must not
|
|
196
|
+
// inherit the previous rule just because it has two words.
|
|
197
|
+
const shortEllipsis = tokenize(query).every((word) => ELLIPSIS_WORDS.has(word)) && fields.length === 0;
|
|
198
|
+
const hint = memoryEnabled && (followUp || shortEllipsis) && shortEllipsis;
|
|
199
|
+
const retrieval = [
|
|
200
|
+
hint ? memory.ruleId : '',
|
|
201
|
+
hint ? memory.recentQueries.slice(-2).join(' ') : '',
|
|
202
|
+
query,
|
|
203
|
+
]
|
|
204
|
+
.filter(Boolean)
|
|
205
|
+
.join(' ');
|
|
206
|
+
const controllerRequest = controller.test(query);
|
|
207
|
+
let best;
|
|
208
|
+
const explicit = controllerRequest ? undefined : answers.find((answer) => answer.match?.(query));
|
|
209
|
+
if (explicit) {
|
|
210
|
+
best = { capability: answerCapability(explicit), score: Number.POSITIVE_INFINITY };
|
|
211
|
+
}
|
|
212
|
+
else if (answers.length > 0 && !controllerRequest) {
|
|
213
|
+
const hits = index.search(retrieval, { limit: 3, boost: false });
|
|
214
|
+
const words = retrieval.split(/[^A-Za-z0-9+#.]+/).filter((word) => word.length > 1);
|
|
215
|
+
const namesConstant = words.some((word) => knowledge.canonicalFor(word).length > 0);
|
|
216
|
+
if (namesConstant) {
|
|
217
|
+
// A question that names a declared value belongs to the rule that
|
|
218
|
+
// consumes values, even when the phrasing shares no keyword with it
|
|
219
|
+
// ("what's built with python?") — so that rule enters the shortlist
|
|
220
|
+
// even when it scored nothing.
|
|
221
|
+
const seen = new Set(hits.map((hit) => hit.capability.id));
|
|
222
|
+
for (const answer of answers) {
|
|
223
|
+
if (seen.has(answer.id) || !joinsAskedConstant(answer, knowledge))
|
|
224
|
+
continue;
|
|
225
|
+
hits.push({ capability: answerCapability(answer), score: 2.5 });
|
|
226
|
+
}
|
|
227
|
+
for (const hit of hits) {
|
|
228
|
+
const candidate = answers.find((answer) => answer.id === hit.capability.id);
|
|
229
|
+
if (candidate && joinsAskedConstant(candidate, knowledge)) {
|
|
230
|
+
hit.score = Math.max(hit.score * 1.4, 2.5);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
hits.sort((a, b) => b.score - a.score);
|
|
234
|
+
}
|
|
235
|
+
[best] = hits;
|
|
236
|
+
}
|
|
237
|
+
const rule = best ? answers.find((answer) => answer.id === best.capability.id) : undefined;
|
|
238
|
+
// Absolute BM25 scores shrink with the corpus: with one answer rule the
|
|
239
|
+
// best possible phrase match scores about 1.2, so a flat 1.0 threshold
|
|
240
|
+
// silently drops real matches. Scale the default to how many rules exist.
|
|
241
|
+
const threshold = rule?.threshold ?? options.threshold ?? Math.min(1, Math.max(0.35, 0.35 * answers.length));
|
|
242
|
+
const byScore = rule && best && best.score >= threshold ? rule : undefined;
|
|
243
|
+
// A rule with tools needs something to look up. "What is his stack?" is not
|
|
244
|
+
// a question about a technology, so planning projects.list for it wastes a
|
|
245
|
+
// call and a trace line before the keyword engine answers anyway.
|
|
246
|
+
const ruleWordsForMatch = new Set(byScore ? tokenize([byScore.title, ...(byScore.keywords ?? [])].join(' ')) : []);
|
|
247
|
+
const wordsNow = [
|
|
248
|
+
...new Set(query.split(/[^A-Za-z0-9+#.]+/).filter((word) => word.length > 1)),
|
|
249
|
+
];
|
|
250
|
+
const hasSubject = wordsNow.some((word) => {
|
|
251
|
+
const [stem] = tokenize(word);
|
|
252
|
+
return Boolean(stem) && !ruleWordsForMatch.has(stem);
|
|
253
|
+
});
|
|
254
|
+
// Only a rule that consumes constants needs a subject. A listing rule
|
|
255
|
+
// ("which invoices are overdue") has nothing to look up by name and should
|
|
256
|
+
// run whenever it matches; requiring a subject made it vanish silently.
|
|
257
|
+
const needsSubject = byScore?.requiresSubject !== false && byScore ? joinsAskedConstant(byScore, knowledge) : false;
|
|
258
|
+
const matched = byScore && byScore.steps?.length && needsSubject && !hasSubject ? undefined : byScore;
|
|
259
|
+
// Run the rule's read-only tools first, one per turn, and turn their
|
|
260
|
+
// results into facts. This is the loop an LLM gets from tool calling, with
|
|
261
|
+
// the plan declared instead of guessed.
|
|
262
|
+
// Structured results when the runtime supplies them (it does), plus the
|
|
263
|
+
// transcript fallback for hosts that drive the engine by hand. Structured
|
|
264
|
+
// values win: the transcript copy is clipped for prompt budgets.
|
|
265
|
+
const observed = observationsThisTurn(request);
|
|
266
|
+
for (const [id, value] of Object.entries(request.observations ?? {}))
|
|
267
|
+
observed.set(id, value);
|
|
268
|
+
const factErrors = [];
|
|
269
|
+
const stepFacts = [];
|
|
270
|
+
if (matched?.steps?.length) {
|
|
271
|
+
for (const step of matched.steps) {
|
|
272
|
+
if (!observed.has(step.capabilityId)) {
|
|
273
|
+
if (memoryEnabled)
|
|
274
|
+
memory.planned = { ruleId: matched.id, capabilityId: step.capabilityId };
|
|
275
|
+
return { text: callTool(step.capabilityId, step.args ?? {}) };
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
for (const step of matched.steps) {
|
|
279
|
+
try {
|
|
280
|
+
stepFacts.push(...step.toFacts(observed.get(step.capabilityId)));
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
// A broken adapter must not crash the turn, but it must not vanish
|
|
284
|
+
// either: silent fact failures once hid an undefined helper for a
|
|
285
|
+
// whole deploy.
|
|
286
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
287
|
+
factErrors.push(`${step.capabilityId} facts failed: ${message}`);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
// Facts for this turn: declared rows, plus whatever the tools just read.
|
|
292
|
+
const turnKnowledge = stepFacts.length > 0
|
|
293
|
+
? new KnowledgeBase({ facts: [...knowledge.facts(), ...stepFacts], rules: knowledge.rules })
|
|
294
|
+
: knowledge;
|
|
295
|
+
// Declared constants the question names, resolved against this turn's data.
|
|
296
|
+
// A constant inside a negation scope is never asserted: "not sqlite" must
|
|
297
|
+
// not let the stack rule answer "Readback uses SQLite".
|
|
298
|
+
const analysis = analyzeQuestion(query, { subjects: turnKnowledge.constants() });
|
|
299
|
+
const excludes = analysis.slots.exclude;
|
|
300
|
+
const terms = [];
|
|
301
|
+
for (const token of new Set(tokenize(query))) {
|
|
302
|
+
for (const constant of turnKnowledge.canonicalFor(token)) {
|
|
303
|
+
if (excludes.includes(constant))
|
|
304
|
+
continue;
|
|
305
|
+
if (!terms.includes(constant))
|
|
306
|
+
terms.push(constant);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
// A continuation inherits the previous turn only when it has no subject of
|
|
310
|
+
// its own: "and?" does, "and SQLite?" names a new term and must not repeat
|
|
311
|
+
// the old answer if that term is unknown.
|
|
312
|
+
const ellipsis = followUp && tokenize(query).every((word) => ELLIPSIS_WORDS.has(word));
|
|
313
|
+
const effectiveTerms = terms.length === 0 && ellipsis ? memory.terms : terms;
|
|
314
|
+
const effectiveHits = hits.length === 0 && ellipsis ? memory.hits : hits;
|
|
315
|
+
const assume = [
|
|
316
|
+
...baseFacts,
|
|
317
|
+
...effectiveTerms.map((term) => [ASKED, term]),
|
|
318
|
+
...effectiveHits.map((hit) => [FIELD, hit.kind, hit.value]),
|
|
319
|
+
];
|
|
320
|
+
if (matched) {
|
|
321
|
+
const ruleWords = new Set(tokenize([matched.title, ...(matched.keywords ?? [])].join(' ')));
|
|
322
|
+
const resolved = new Set(effectiveTerms.flatMap((term) => tokenize(term)));
|
|
323
|
+
// Surface words, not stems: an app writing "no stack lists TypeScript"
|
|
324
|
+
// cannot use "type" because the stemmer ate the rest of the word.
|
|
325
|
+
const mentions = [
|
|
326
|
+
...new Set(
|
|
327
|
+
// Keep the visitor's own capitalisation: echoing "TypeScript" reads
|
|
328
|
+
// like a person, echoing "typescript" reads like a log line.
|
|
329
|
+
query.split(/[^A-Za-z0-9+#.]+/).filter((word) => word.length > 1)),
|
|
330
|
+
].filter((word) => {
|
|
331
|
+
const [stem] = tokenize(word);
|
|
332
|
+
if (!stem)
|
|
333
|
+
return false;
|
|
334
|
+
return (!ruleWords.has(stem) &&
|
|
335
|
+
!resolved.has(stem) &&
|
|
336
|
+
!ELLIPSIS_WORDS.has(stem) &&
|
|
337
|
+
!ELLIPSIS_WORDS.has(word));
|
|
338
|
+
});
|
|
339
|
+
const completion = runRule(matched, query, effectiveTerms, effectiveHits, assume, Object.fromEntries(observed), turnKnowledge, mentions, excludes, analysis.slots.combine);
|
|
340
|
+
if (completion) {
|
|
341
|
+
if (factErrors.length) {
|
|
342
|
+
completion.steps = [
|
|
343
|
+
...factErrors.map((message) => ({ type: 'error', message, capabilityId: matched.id })),
|
|
344
|
+
...(completion.steps ?? []),
|
|
345
|
+
];
|
|
346
|
+
}
|
|
347
|
+
return completion;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
// A bare continuation ("and?", "more") with no retrieval signal of its own
|
|
351
|
+
// repeats the last rule against the new turn's assumptions.
|
|
352
|
+
if (memoryEnabled && followUp && memory.ruleId) {
|
|
353
|
+
const previous = answers.find((answer) => answer.id === memory.ruleId);
|
|
354
|
+
if (previous && previous !== matched) {
|
|
355
|
+
const completion = runRule(previous, query, effectiveTerms, effectiveHits, assume, Object.fromEntries(observed), turnKnowledge);
|
|
356
|
+
if (completion)
|
|
357
|
+
return completion;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return fallback.complete(request);
|
|
361
|
+
},
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/rules/engine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAgB,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,E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
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { FactRow } from './knowledge.js';
|
|
2
|
+
/** Text of one fact, the way a reader would say it. */
|
|
3
|
+
export declare function factText(row: FactRow): string;
|
|
4
|
+
/**
|
|
5
|
+
* A number in a fact value: "99.95%", "12", "4", "tier 2", "400 days".
|
|
6
|
+
* Percentages and counts compare directly once the unit is stripped; a tier is
|
|
7
|
+
* a rank, so the digit is the value. Returns undefined when there is no number,
|
|
8
|
+
* which keeps the caller from ranking on a misread.
|
|
9
|
+
*/
|
|
10
|
+
export declare function numberOf(value: string): number | undefined;
|
|
11
|
+
export interface RankedFact {
|
|
12
|
+
/** The subject, the first argument of the row. */
|
|
13
|
+
subject: string;
|
|
14
|
+
/** The attribute, the second argument, when the row has one. */
|
|
15
|
+
attribute?: string;
|
|
16
|
+
/** The value the number came from. */
|
|
17
|
+
value: string;
|
|
18
|
+
number: number;
|
|
19
|
+
row: FactRow;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Ranks facts of one relation and attribute by the number inside the value.
|
|
23
|
+
*
|
|
24
|
+
* rankFacts(facts, { relation: 'product', attribute: 'sla', direction: 'max' })
|
|
25
|
+
*
|
|
26
|
+
* Only rows that carry a number are ranked: a fact with "high" in it is not a
|
|
27
|
+
* contender for the highest, and silently treating it as zero would let it win.
|
|
28
|
+
*/
|
|
29
|
+
export declare function rankFacts(facts: FactRow[], options: {
|
|
30
|
+
relation: string;
|
|
31
|
+
attribute?: string;
|
|
32
|
+
direction?: 'max' | 'min';
|
|
33
|
+
}): RankedFact[];
|
|
34
|
+
/** The one row that wins a ranking, or undefined when nothing is rankable. */
|
|
35
|
+
export declare function topFact(facts: FactRow[], options: {
|
|
36
|
+
relation: string;
|
|
37
|
+
attribute?: string;
|
|
38
|
+
direction?: 'max' | 'min';
|
|
39
|
+
}): RankedFact | undefined;
|
|
40
|
+
export interface FactIndexOptions {
|
|
41
|
+
/** A floor on the score, so a single shared word is not a match. */
|
|
42
|
+
minScore?: number;
|
|
43
|
+
/** BM25 constants; the defaults are the usual ones. */
|
|
44
|
+
k1?: number;
|
|
45
|
+
b?: number;
|
|
46
|
+
}
|
|
47
|
+
export interface FactHit {
|
|
48
|
+
row: FactRow;
|
|
49
|
+
text: string;
|
|
50
|
+
score: number;
|
|
51
|
+
}
|
|
52
|
+
export declare function indexTokens(text: string): string[];
|
|
53
|
+
/**
|
|
54
|
+
* A small BM25 over the fact sentences. It is the retrieval an app needs for
|
|
55
|
+
* prose facts (a policy, a description) where the question names the topic and
|
|
56
|
+
* not the subject. Same shape as the capability index, different corpus.
|
|
57
|
+
*/
|
|
58
|
+
export declare function createFactIndex(facts: FactRow[], options?: FactIndexOptions): {
|
|
59
|
+
size: number;
|
|
60
|
+
search: (query: string, limit?: number) => FactHit[];
|
|
61
|
+
};
|
|
62
|
+
export type FactIndex = ReturnType<typeof createFactIndex>;
|
|
63
|
+
//# sourceMappingURL=facts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"facts.d.ts","sourceRoot":"","sources":["../../src/rules/facts.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,uDAAuD;AACvD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAO7C;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG1D;AAED,MAAM,WAAW,UAAU;IACzB,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,OAAO,CAAC;CACd;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,OAAO,EAAE,EAChB,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,CAAA;CAAE,GAC3E,UAAU,EAAE,CAed;AAED,8EAA8E;AAC9E,wBAAgB,OAAO,CACrB,KAAK,EAAE,OAAO,EAAE,EAChB,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,CAAA;CAAE,GAC3E,UAAU,GAAG,SAAS,CAExB;AAED,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAQD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAKlD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,GAAE,gBAAqB;;oBAcvD,MAAM,qBAAc,OAAO,EAAE;EAqBrD;AAED,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Facts are a table; these are the two questions a table cannot answer by
|
|
2
|
+
// joining alone.
|
|
3
|
+
//
|
|
4
|
+
// A join finds the row that matches. It cannot say which row is the largest,
|
|
5
|
+
// and it cannot answer a question that names a topic instead of a subject
|
|
6
|
+
// ("what happens during a sev 1?"). Both are ordinary questions to a person and
|
|
7
|
+
// both are reachable without a model: rank the values, or rank the sentences.
|
|
8
|
+
/** Text of one fact, the way a reader would say it. */
|
|
9
|
+
export function factText(row) {
|
|
10
|
+
const [relation, ...args] = row;
|
|
11
|
+
if (args.length === 0)
|
|
12
|
+
return relation;
|
|
13
|
+
if (args.length === 1)
|
|
14
|
+
return `${args[0]} is a ${relation}.`;
|
|
15
|
+
if (args.length === 2)
|
|
16
|
+
return `${args[0]}: ${args[1]}.`;
|
|
17
|
+
if (args.length === 3)
|
|
18
|
+
return `${args[0]}: ${args[1]} is ${args[2]}.`;
|
|
19
|
+
return `${args[0]} ${args[1]} is ${args.slice(2).join(' ')}.`;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A number in a fact value: "99.95%", "12", "4", "tier 2", "400 days".
|
|
23
|
+
* Percentages and counts compare directly once the unit is stripped; a tier is
|
|
24
|
+
* a rank, so the digit is the value. Returns undefined when there is no number,
|
|
25
|
+
* which keeps the caller from ranking on a misread.
|
|
26
|
+
*/
|
|
27
|
+
export function numberOf(value) {
|
|
28
|
+
const match = String(value).match(/-?\d+(?:\.\d+)?/);
|
|
29
|
+
return match ? Number(match[0]) : undefined;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Ranks facts of one relation and attribute by the number inside the value.
|
|
33
|
+
*
|
|
34
|
+
* rankFacts(facts, { relation: 'product', attribute: 'sla', direction: 'max' })
|
|
35
|
+
*
|
|
36
|
+
* Only rows that carry a number are ranked: a fact with "high" in it is not a
|
|
37
|
+
* contender for the highest, and silently treating it as zero would let it win.
|
|
38
|
+
*/
|
|
39
|
+
export function rankFacts(facts, options) {
|
|
40
|
+
const direction = options.direction ?? 'max';
|
|
41
|
+
const ranked = [];
|
|
42
|
+
for (const row of facts) {
|
|
43
|
+
const [relation, subject, ...rest] = row;
|
|
44
|
+
if (relation !== options.relation || !subject)
|
|
45
|
+
continue;
|
|
46
|
+
const attribute = options.attribute;
|
|
47
|
+
const value = attribute ? (rest[0] === attribute ? rest[1] : undefined) : rest[rest.length - 1];
|
|
48
|
+
if (value === undefined)
|
|
49
|
+
continue;
|
|
50
|
+
const number = numberOf(value);
|
|
51
|
+
if (number === undefined)
|
|
52
|
+
continue;
|
|
53
|
+
ranked.push({ subject, attribute, value, number, row });
|
|
54
|
+
}
|
|
55
|
+
ranked.sort((a, b) => (direction === 'max' ? b.number - a.number : a.number - b.number));
|
|
56
|
+
return ranked;
|
|
57
|
+
}
|
|
58
|
+
/** The one row that wins a ranking, or undefined when nothing is rankable. */
|
|
59
|
+
export function topFact(facts, options) {
|
|
60
|
+
return rankFacts(facts, options)[0];
|
|
61
|
+
}
|
|
62
|
+
const STOP = new Set([
|
|
63
|
+
'the', 'a', 'an', 'is', 'are', 'was', 'were', 'of', 'to', 'in', 'on', 'for', 'and', 'or',
|
|
64
|
+
'what', 'which', 'who', 'how', 'does', 'do', 'did', 'with', 'at', 'by', 'it', 'its', 'that',
|
|
65
|
+
'this', 'there', 'when', 'where', 'why', 'can', 'i', 'we', 'you', 'me', 'my', 'our',
|
|
66
|
+
]);
|
|
67
|
+
export function indexTokens(text) {
|
|
68
|
+
return String(text)
|
|
69
|
+
.toLowerCase()
|
|
70
|
+
.split(/[^a-z0-9%]+/)
|
|
71
|
+
.filter((word) => word.length > 1 && !STOP.has(word));
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A small BM25 over the fact sentences. It is the retrieval an app needs for
|
|
75
|
+
* prose facts (a policy, a description) where the question names the topic and
|
|
76
|
+
* not the subject. Same shape as the capability index, different corpus.
|
|
77
|
+
*/
|
|
78
|
+
export function createFactIndex(facts, options = {}) {
|
|
79
|
+
// The floor is what keeps one shared noun from being an answer. It is a score,
|
|
80
|
+
// not a match count, because a policy question may share exactly one word and
|
|
81
|
+
// still be the right one ("sev 1").
|
|
82
|
+
const minScore = options.minScore ?? 1.15;
|
|
83
|
+
const k1 = options.k1 ?? 1.2;
|
|
84
|
+
const b = options.b ?? 0.75;
|
|
85
|
+
const docs = facts.map((row) => ({ row, text: factText(row), tokens: indexTokens(factText(row)) }));
|
|
86
|
+
const average = docs.length ? docs.reduce((sum, doc) => sum + doc.tokens.length, 0) / docs.length : 0;
|
|
87
|
+
const documentFrequency = new Map();
|
|
88
|
+
for (const doc of docs) {
|
|
89
|
+
for (const token of new Set(doc.tokens))
|
|
90
|
+
documentFrequency.set(token, (documentFrequency.get(token) ?? 0) + 1);
|
|
91
|
+
}
|
|
92
|
+
function search(query, limit = 3) {
|
|
93
|
+
const terms = [...new Set(indexTokens(query))];
|
|
94
|
+
if (!terms.length)
|
|
95
|
+
return [];
|
|
96
|
+
const scored = docs.map((doc) => {
|
|
97
|
+
let score = 0;
|
|
98
|
+
for (const term of terms) {
|
|
99
|
+
const frequency = doc.tokens.filter((token) => token === term).length;
|
|
100
|
+
if (!frequency)
|
|
101
|
+
continue;
|
|
102
|
+
const df = documentFrequency.get(term) ?? 0;
|
|
103
|
+
const idf = Math.log(1 + (docs.length - df + 0.5) / (df + 0.5));
|
|
104
|
+
score += idf * ((frequency * (k1 + 1)) / (frequency + k1 * (1 - b + (b * doc.tokens.length) / (average || 1))));
|
|
105
|
+
}
|
|
106
|
+
return { row: doc.row, text: doc.text, score };
|
|
107
|
+
});
|
|
108
|
+
return scored
|
|
109
|
+
.filter((hit) => hit.score >= minScore)
|
|
110
|
+
.sort((a, b2) => b2.score - a.score)
|
|
111
|
+
.slice(0, limit);
|
|
112
|
+
}
|
|
113
|
+
return { size: docs.length, search };
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=facts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"facts.js","sourceRoot":"","sources":["../../src/rules/facts.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,iBAAiB;AACjB,EAAE;AACF,6EAA6E;AAC7E,0EAA0E;AAC1E,gFAAgF;AAChF,8EAA8E;AAI9E,uDAAuD;AACvD,MAAM,UAAU,QAAQ,CAAC,GAAY;IACnC,MAAM,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC;IAChC,I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CAAC,SAAS,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAClH,CAAC;YACD,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;QACjD,CAAC,CAAC,CAAC;QACH,OAAO,MAAM;aACV,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,IAAI,QAAQ,CAAC;aACtC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;aACnC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACrB,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { KnowledgeBase, fact, parseAtom, parseRule, formatAtom, } from './knowledge.js';
|
|
2
|
+
export type { Atom, Bindings, FactRow, KnowledgeBaseOptions, ProofStep, QueryOptions, Rule, Solution, Term, } from './knowledge.js';
|
|
3
|
+
export { createFactIndex, factText, indexTokens, numberOf, rankFacts, topFact, } from './facts.js';
|
|
4
|
+
export type { FactHit, FactIndex, FactIndexOptions, RankedFact } from './facts.js';
|
|
5
|
+
export { createRulesEngine } from './engine.js';
|
|
6
|
+
export type { AnswerContext, AnswerRule, RulesEngineOptions } from './engine.js';
|
|
7
|
+
export type { Combine } from '../core/question.js';
|
|
8
|
+
export { createFieldScanner, requestedFields, DEFAULT_PATTERNS, FIELD_SYNONYMS } from '../extract/index.js';
|
|
9
|
+
export type { FieldKind, FieldScanner, FieldScannerOptions, ScanHit } from '../extract/index.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,IAAI,EACJ,SAAS,EACT,SAAS,EACT,UAAU,GACX,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,oBAAoB,EACpB,SAAS,EACT,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,IAAI,GACL,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EACf,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,SAAS,EACT,OAAO,GACR,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjF,YAAY,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC5G,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { KnowledgeBase, fact, parseAtom, parseRule, formatAtom, } from './knowledge.js';
|
|
2
|
+
export { createFactIndex, factText, indexTokens, numberOf, rankFacts, topFact, } from './facts.js';
|
|
3
|
+
export { createRulesEngine } from './engine.js';
|
|
4
|
+
export { createFieldScanner, requestedFields, DEFAULT_PATTERNS, FIELD_SYNONYMS } from '../extract/index.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,IAAI,EACJ,SAAS,EACT,SAAS,EACT,UAAU,GACX,MAAM,gBAAgB,CAAC;AAYxB,OAAO,EACL,eAAe,EACf,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,SAAS,EACT,OAAO,GACR,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|