@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,33 @@
|
|
|
1
|
+
import type { CapabilityDeclaration } from './types.js';
|
|
2
|
+
export interface RegistryLookup {
|
|
3
|
+
get(id: string): CapabilityDeclaration | undefined;
|
|
4
|
+
awaitRegistration(id: string, timeoutMs: number): Promise<CapabilityDeclaration | undefined>;
|
|
5
|
+
list(): CapabilityDeclaration[];
|
|
6
|
+
register(declaration: CapabilityDeclaration): () => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Holds live handler functions. The manifest says what exists; this says what
|
|
10
|
+
* can actually run right now. They are deliberately separate: a route that is
|
|
11
|
+
* not mounted yet has a declaration but no handler.
|
|
12
|
+
*/
|
|
13
|
+
export declare class CapabilityRegistry implements RegistryLookup {
|
|
14
|
+
private entries;
|
|
15
|
+
private waiters;
|
|
16
|
+
register(declaration: CapabilityDeclaration): () => void;
|
|
17
|
+
unregister(id: string): void;
|
|
18
|
+
get(id: string): CapabilityDeclaration | undefined;
|
|
19
|
+
has(id: string): boolean;
|
|
20
|
+
list(): CapabilityDeclaration[];
|
|
21
|
+
clear(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Resolves once a handler registers, or with undefined on timeout. The
|
|
24
|
+
* runtime uses it after navigating to a capability's route: the handler
|
|
25
|
+
* lives in the module that the route mounts.
|
|
26
|
+
*/
|
|
27
|
+
awaitRegistration(id: string, timeoutMs?: number): Promise<CapabilityDeclaration | undefined>;
|
|
28
|
+
}
|
|
29
|
+
/** Process-wide registry used when the app does not create its own. */
|
|
30
|
+
export declare const registry: CapabilityRegistry;
|
|
31
|
+
/** Convenience: register into the process-wide registry, e.g. at feature-module import. */
|
|
32
|
+
export declare function registerCapability(declaration: CapabilityDeclaration): () => void;
|
|
33
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/core/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS,CAAC;IACnD,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAAC;IAC7F,IAAI,IAAI,qBAAqB,EAAE,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,qBAAqB,GAAG,MAAM,IAAI,CAAC;CAC1D;AAED;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,cAAc;IACvD,OAAO,CAAC,OAAO,CAA4C;IAC3D,OAAO,CAAC,OAAO,CAAsF;IAErG,QAAQ,CAAC,WAAW,EAAE,qBAAqB,GAAG,MAAM,IAAI;IAUxD,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAI5B,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS;IAIlD,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAIxB,IAAI,IAAI,qBAAqB,EAAE;IAI/B,KAAK,IAAI,IAAI;IAKb;;;;OAIG;IACH,iBAAiB,CACf,EAAE,EAAE,MAAM,EACV,SAAS,SAAO,GACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;CAyB9C;AAED,uEAAuE;AACvE,eAAO,MAAM,QAAQ,oBAA2B,CAAC;AAEjD,2FAA2F;AAC3F,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,qBAAqB,GAAG,MAAM,IAAI,CAEjF"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Holds live handler functions. The manifest says what exists; this says what
|
|
3
|
+
* can actually run right now. They are deliberately separate: a route that is
|
|
4
|
+
* not mounted yet has a declaration but no handler.
|
|
5
|
+
*/
|
|
6
|
+
export class CapabilityRegistry {
|
|
7
|
+
entries = new Map();
|
|
8
|
+
waiters = new Map();
|
|
9
|
+
register(declaration) {
|
|
10
|
+
this.entries.set(declaration.id, declaration);
|
|
11
|
+
const pending = this.waiters.get(declaration.id);
|
|
12
|
+
if (pending) {
|
|
13
|
+
this.waiters.delete(declaration.id);
|
|
14
|
+
for (const resolve of pending)
|
|
15
|
+
resolve(declaration);
|
|
16
|
+
}
|
|
17
|
+
return () => this.unregister(declaration.id);
|
|
18
|
+
}
|
|
19
|
+
unregister(id) {
|
|
20
|
+
this.entries.delete(id);
|
|
21
|
+
}
|
|
22
|
+
get(id) {
|
|
23
|
+
return this.entries.get(id);
|
|
24
|
+
}
|
|
25
|
+
has(id) {
|
|
26
|
+
return this.entries.has(id);
|
|
27
|
+
}
|
|
28
|
+
list() {
|
|
29
|
+
return [...this.entries.values()];
|
|
30
|
+
}
|
|
31
|
+
clear() {
|
|
32
|
+
this.entries.clear();
|
|
33
|
+
this.waiters.clear();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Resolves once a handler registers, or with undefined on timeout. The
|
|
37
|
+
* runtime uses it after navigating to a capability's route: the handler
|
|
38
|
+
* lives in the module that the route mounts.
|
|
39
|
+
*/
|
|
40
|
+
awaitRegistration(id, timeoutMs = 2000) {
|
|
41
|
+
const existing = this.entries.get(id);
|
|
42
|
+
if (existing)
|
|
43
|
+
return Promise.resolve(existing);
|
|
44
|
+
return new Promise((resolve) => {
|
|
45
|
+
let settled = false;
|
|
46
|
+
const finish = (declaration) => {
|
|
47
|
+
if (settled)
|
|
48
|
+
return;
|
|
49
|
+
settled = true;
|
|
50
|
+
clearTimeout(timer);
|
|
51
|
+
resolve(declaration);
|
|
52
|
+
};
|
|
53
|
+
const timer = setTimeout(() => {
|
|
54
|
+
const list = this.waiters.get(id) ?? [];
|
|
55
|
+
this.waiters.set(id, list.filter((fn) => fn !== finish));
|
|
56
|
+
finish(undefined);
|
|
57
|
+
}, timeoutMs);
|
|
58
|
+
if (typeof timer === 'object' && 'unref' in timer)
|
|
59
|
+
timer.unref();
|
|
60
|
+
const list = this.waiters.get(id) ?? [];
|
|
61
|
+
list.push(finish);
|
|
62
|
+
this.waiters.set(id, list);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** Process-wide registry used when the app does not create its own. */
|
|
67
|
+
export const registry = new CapabilityRegistry();
|
|
68
|
+
/** Convenience: register into the process-wide registry, e.g. at feature-module import. */
|
|
69
|
+
export function registerCapability(declaration) {
|
|
70
|
+
return registry.register(declaration);
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/core/registry.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IACrB,OAAO,GAAG,IAAI,GAAG,EAAiC,CAAC;IACnD,OAAO,GAAG,IAAI,GAAG,EAA2E,CAAC;IAErG,QAAQ,CAAC,WAAkC;QACzC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;QAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAA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,GAAG,IAAI,CAAC;gBACf,YAAY,CAAC,KAAK,CAAC,CAAC;gBACpB,OAAO,CAAC,WAAW,CAAC,CAAC;YACvB,CAAC,CAAC;YACF,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;gBACxC,IAAI,CAAC,OAAO,CAAC,GAAG,CACd,EAAE,EACF,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,MAAM,CAAC,CACnC,CAAC;gBACF,MAAM,CAAC,SAAS,CAAC,CAAC;YACpB,CAAC,EAAE,SAAS,CAAC,CAAC;YACd,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK;gBAAE,KAAK,CAAC,KAAK,EAAE,CAAC;YACjE,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;YACxC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAClB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,uEAAuE;AACvE,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,kBAAkB,EAAE,CAAC;AAEjD,2FAA2F;AAC3F,MAAM,UAAU,kBAAkB,CAAC,WAAkC;IACnE,OAAO,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ManifestCapability } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Splits a query into searchable terms. Handles camelCase, dotted ids and the
|
|
4
|
+
* plural forms that show up in UI copy ("invoices" should match "invoice").
|
|
5
|
+
*/
|
|
6
|
+
export declare function tokenize(input: string): string[];
|
|
7
|
+
export interface ScoredCapability {
|
|
8
|
+
capability: ManifestCapability;
|
|
9
|
+
score: number;
|
|
10
|
+
}
|
|
11
|
+
export interface RetrieverOptions {
|
|
12
|
+
/** BM25 term-frequency saturation. */
|
|
13
|
+
k1?: number;
|
|
14
|
+
/** BM25 length normalisation. */
|
|
15
|
+
b?: number;
|
|
16
|
+
/** Score added when a capability's route is the current route. */
|
|
17
|
+
routeExactBoost?: number;
|
|
18
|
+
/** Score added when the current route is a prefix of the capability route. */
|
|
19
|
+
routePrefixBoost?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A BM25 index over capability metadata. Small local models cannot hold the
|
|
23
|
+
* whole app in context, so retrieval decides what the prompt contains; a
|
|
24
|
+
* deterministic lexical scorer is easier to test than an embedding model and
|
|
25
|
+
* costs no download.
|
|
26
|
+
*/
|
|
27
|
+
export declare class CapabilityIndex {
|
|
28
|
+
private docs;
|
|
29
|
+
private df;
|
|
30
|
+
private avgLength;
|
|
31
|
+
private readonly k1;
|
|
32
|
+
private readonly b;
|
|
33
|
+
private readonly routeExactBoost;
|
|
34
|
+
private readonly routePrefixBoost;
|
|
35
|
+
constructor(capabilities: ManifestCapability[], options?: RetrieverOptions);
|
|
36
|
+
setCapabilities(capabilities: ManifestCapability[]): void;
|
|
37
|
+
/**
|
|
38
|
+
* Ranks capabilities for a query. `currentRoute` boosts what the user can
|
|
39
|
+
* see right now, which is the strongest signal an SPA has.
|
|
40
|
+
*/
|
|
41
|
+
search(query: string, options?: {
|
|
42
|
+
currentRoute?: string;
|
|
43
|
+
limit?: number;
|
|
44
|
+
boost?: boolean;
|
|
45
|
+
}): ScoredCapability[];
|
|
46
|
+
}
|
|
47
|
+
export declare function createCapabilityIndex(capabilities: ManifestCapability[], options?: RetrieverOptions): CapabilityIndex;
|
|
48
|
+
//# sourceMappingURL=retriever.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retriever.d.ts","sourceRoot":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BAAgB,GACzB,eAAe,CAEjB"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
const STOPWORDS = new Set([
|
|
2
|
+
'a', 'an', 'the', 'and', 'or', 'of', 'to', 'in', 'on', 'for', 'with', 'is', 'are',
|
|
3
|
+
'be', 'this', 'that', 'it', 'as', 'at', 'by', 'from', 'can', 'i', 'me', 'my', 'we',
|
|
4
|
+
'you', 'your', 'they', 'their', 'do', 'does', 'how', 'what', 'where', 'when', 'which',
|
|
5
|
+
// Pronouns carry no retrieval signal, and with a handful of capabilities their
|
|
6
|
+
// rarity inflates IDF: "where is he based" matched a rule about "what has he
|
|
7
|
+
// built" on the word "he" alone.
|
|
8
|
+
'he', 'him', 'his', 'she', 'her', 'hers', 'they', 'them', 'their', 'it', 'its', 'we', 'us',
|
|
9
|
+
'our', 'been', 'being', 'was', 'were', 'has', 'have', 'had', 'did', 'done', 'will', 'would',
|
|
10
|
+
'should', 'could', 'may', 'might', 'must',
|
|
11
|
+
// Quantifiers are never the subject. "How much has he written?" was matching a
|
|
12
|
+
// rule about project stacks and answering "No project stack lists much."
|
|
13
|
+
'much', 'many',
|
|
14
|
+
'please', 'want', 'wants', 'need', 'needs', 'would', 'like', 'help', 'user', 'users',
|
|
15
|
+
]);
|
|
16
|
+
/**
|
|
17
|
+
* Splits a query into searchable terms. Handles camelCase, dotted ids and the
|
|
18
|
+
* plural forms that show up in UI copy ("invoices" should match "invoice").
|
|
19
|
+
*/
|
|
20
|
+
export function tokenize(input) {
|
|
21
|
+
return input
|
|
22
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
23
|
+
.toLowerCase()
|
|
24
|
+
.split(/[^a-z0-9]+/)
|
|
25
|
+
.filter((t) => t.length > 1 && !STOPWORDS.has(t))
|
|
26
|
+
.map(stem);
|
|
27
|
+
}
|
|
28
|
+
function stem(term) {
|
|
29
|
+
if (term.length > 4 && term.endsWith('ies'))
|
|
30
|
+
return `${term.slice(0, -3)}y`;
|
|
31
|
+
if (term.length > 4 && term.endsWith('es'))
|
|
32
|
+
return term.slice(0, -2);
|
|
33
|
+
if (term.length > 3 && term.endsWith('s') && !term.endsWith('ss'))
|
|
34
|
+
return term.slice(0, -1);
|
|
35
|
+
return term;
|
|
36
|
+
}
|
|
37
|
+
/** Weighted fields: the title and keywords carry intent better than prose. */
|
|
38
|
+
const FIELD_WEIGHTS = { title: 3, keywords: 2, description: 1, id: 1.5, knowledge: 2.5 };
|
|
39
|
+
/**
|
|
40
|
+
* A BM25 index over capability metadata. Small local models cannot hold the
|
|
41
|
+
* whole app in context, so retrieval decides what the prompt contains; a
|
|
42
|
+
* deterministic lexical scorer is easier to test than an embedding model and
|
|
43
|
+
* costs no download.
|
|
44
|
+
*/
|
|
45
|
+
export class CapabilityIndex {
|
|
46
|
+
docs = [];
|
|
47
|
+
df = new Map();
|
|
48
|
+
avgLength = 0;
|
|
49
|
+
k1;
|
|
50
|
+
b;
|
|
51
|
+
routeExactBoost;
|
|
52
|
+
routePrefixBoost;
|
|
53
|
+
constructor(capabilities, options = {}) {
|
|
54
|
+
this.k1 = options.k1 ?? 1.4;
|
|
55
|
+
this.b = options.b ?? 0.75;
|
|
56
|
+
this.routeExactBoost = options.routeExactBoost ?? 3;
|
|
57
|
+
this.routePrefixBoost = options.routePrefixBoost ?? 1.2;
|
|
58
|
+
this.setCapabilities(capabilities);
|
|
59
|
+
}
|
|
60
|
+
setCapabilities(capabilities) {
|
|
61
|
+
this.docs = capabilities.map((capability) => {
|
|
62
|
+
const terms = new Map();
|
|
63
|
+
const add = (text, weight) => {
|
|
64
|
+
if (!text)
|
|
65
|
+
return;
|
|
66
|
+
for (const token of tokenize(text)) {
|
|
67
|
+
terms.set(token, (terms.get(token) ?? 0) + weight);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
add(capability.title, FIELD_WEIGHTS.title);
|
|
71
|
+
add(capability.id, FIELD_WEIGHTS.id);
|
|
72
|
+
add(capability.keywords?.join(' '), FIELD_WEIGHTS.keywords);
|
|
73
|
+
add(capability.description, FIELD_WEIGHTS.description);
|
|
74
|
+
add(capability.knowledge, FIELD_WEIGHTS.knowledge);
|
|
75
|
+
const length = [...terms.values()].reduce((sum, v) => sum + v, 0);
|
|
76
|
+
return { capability, terms, length };
|
|
77
|
+
});
|
|
78
|
+
this.df.clear();
|
|
79
|
+
for (const doc of this.docs) {
|
|
80
|
+
for (const term of doc.terms.keys()) {
|
|
81
|
+
this.df.set(term, (this.df.get(term) ?? 0) + 1);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
this.avgLength =
|
|
85
|
+
this.docs.reduce((sum, doc) => sum + doc.length, 0) / Math.max(this.docs.length, 1);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Ranks capabilities for a query. `currentRoute` boosts what the user can
|
|
89
|
+
* see right now, which is the strongest signal an SPA has.
|
|
90
|
+
*/
|
|
91
|
+
search(query, options = {}) {
|
|
92
|
+
const queryTerms = tokenize(query);
|
|
93
|
+
const { currentRoute, limit } = options;
|
|
94
|
+
const boost = options.boost ?? true;
|
|
95
|
+
const total = this.docs.length;
|
|
96
|
+
const scored = this.docs.map((doc) => {
|
|
97
|
+
let score = 0;
|
|
98
|
+
for (const term of queryTerms) {
|
|
99
|
+
const tf = doc.terms.get(term);
|
|
100
|
+
if (!tf)
|
|
101
|
+
continue;
|
|
102
|
+
const df = this.df.get(term) ?? 0;
|
|
103
|
+
const idf = Math.log(1 + (total - df + 0.5) / (df + 0.5));
|
|
104
|
+
const norm = this.k1 * (1 - this.b + (this.b * doc.length) / (this.avgLength || 1));
|
|
105
|
+
score += idf * ((tf * (this.k1 + 1)) / (tf + norm));
|
|
106
|
+
}
|
|
107
|
+
if (boost && score > 0 && currentRoute) {
|
|
108
|
+
const route = doc.capability.route;
|
|
109
|
+
if (route === currentRoute)
|
|
110
|
+
score += this.routeExactBoost;
|
|
111
|
+
else if (route && route !== '/' && currentRoute.startsWith(route))
|
|
112
|
+
score += this.routePrefixBoost;
|
|
113
|
+
}
|
|
114
|
+
return { capability: doc.capability, score };
|
|
115
|
+
});
|
|
116
|
+
const ranked = scored.filter((entry) => entry.score > 0).sort((a, b) => b.score - a.score);
|
|
117
|
+
return typeof limit === 'number' ? ranked.slice(0, limit) : ranked;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
export function createCapabilityIndex(capabilities, options) {
|
|
121
|
+
return new CapabilityIndex(capabilities, options);
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=retriever.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retriever.js","sourceRoot":"","sources":["../../src/core/retriever.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IACxB,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK;IACjF,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAClF,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO;IACrF,+EAA+E;IAC/E,6EAA6E;IAC7E,iCAAiC;IACjC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI;IAC1F,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,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IAAI,KAAK,GAAG,CAAC,IAAI,YAAY,EAAE,CAAC;gBACvC,MAAM,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC;gBACnC,IAAI,KAAK,KAAK,YAAY;oBAAE,KAAK,IAAI,IAAI,CAAC,eAAe,CAAC;qBACrD,IAAI,KAAK,IAAI,KAAK,KAAK,GAAG,IAAI,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC;oBAAE,KAAK,IAAI,IAAI,CAAC,gBAAgB,CAAC;YACpG,CAAC;YACD,OAAO,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC;QAC/C,CAAC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;QAC3F,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACrE,CAAC;CACF;AAED,MAAM,UAAU,qBAAqB,CACnC,YAAkC,EAClC,OAA0B;IAE1B,OAAO,IAAI,eAAe,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { JSONSchemaObject } from './types.js';
|
|
2
|
+
export interface SchemaErrorDetail {
|
|
3
|
+
/** Dotted path inside the arguments object, "" for the root. */
|
|
4
|
+
path: string;
|
|
5
|
+
keyword: string;
|
|
6
|
+
message: string;
|
|
7
|
+
}
|
|
8
|
+
export type SchemaValidation = {
|
|
9
|
+
valid: true;
|
|
10
|
+
value: Record<string, unknown>;
|
|
11
|
+
} | {
|
|
12
|
+
valid: false;
|
|
13
|
+
errors: SchemaErrorDetail[];
|
|
14
|
+
};
|
|
15
|
+
/** Keywords the runtime validator actually enforces. Anything else is reported by the build. */
|
|
16
|
+
export declare const SUPPORTED_KEYWORDS: Set<string>;
|
|
17
|
+
/** Keywords accepted in a declaration but never enforced at runtime. */
|
|
18
|
+
export declare const IGNORED_KEYWORDS: Set<string>;
|
|
19
|
+
export declare function unsupportedKeywords(schema: JSONSchemaObject | undefined, prefix?: string): string[];
|
|
20
|
+
/**
|
|
21
|
+
* Validates extracted tool arguments against the capability's schema.
|
|
22
|
+
* Errors are ordered by path so a model can read them top-down.
|
|
23
|
+
*/
|
|
24
|
+
export declare function validateParams(value: unknown, schema: JSONSchemaObject | undefined): SchemaValidation;
|
|
25
|
+
/** Turns validator output into the single line the model sees on a retry. */
|
|
26
|
+
export declare function formatSchemaErrors(errors: SchemaErrorDetail[]): string[];
|
|
27
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/core/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,WAAW,iBAAiB;IAChC,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,gBAAgB,GACxB;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAC/C;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,iBAAiB,EAAE,CAAA;CAAE,CAAC;AAElD,gGAAgG;AAChG,eAAO,MAAM,kBAAkB,aAyB7B,CAAC;AAEH,wEAAwE;AACxE,eAAO,MAAM,gBAAgB,aAAuF,CAAC;AAErH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,EAAE,MAAM,SAAK,GAAG,MAAM,EAAE,CAoB/F;AAqBD;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,gBAAgB,GAAG,SAAS,GACnC,gBAAgB,CAoBlB;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,EAAE,CAKxE"}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/** Keywords the runtime validator actually enforces. Anything else is reported by the build. */
|
|
2
|
+
export const SUPPORTED_KEYWORDS = new Set([
|
|
3
|
+
'$schema',
|
|
4
|
+
'$id',
|
|
5
|
+
'type',
|
|
6
|
+
'properties',
|
|
7
|
+
'required',
|
|
8
|
+
'additionalProperties',
|
|
9
|
+
'items',
|
|
10
|
+
'enum',
|
|
11
|
+
'const',
|
|
12
|
+
'anyOf',
|
|
13
|
+
'oneOf',
|
|
14
|
+
'minimum',
|
|
15
|
+
'maximum',
|
|
16
|
+
'exclusiveMinimum',
|
|
17
|
+
'exclusiveMaximum',
|
|
18
|
+
'minLength',
|
|
19
|
+
'maxLength',
|
|
20
|
+
'pattern',
|
|
21
|
+
'minItems',
|
|
22
|
+
'maxItems',
|
|
23
|
+
'description',
|
|
24
|
+
'title',
|
|
25
|
+
'default',
|
|
26
|
+
'examples',
|
|
27
|
+
]);
|
|
28
|
+
/** Keywords accepted in a declaration but never enforced at runtime. */
|
|
29
|
+
export const IGNORED_KEYWORDS = new Set(['format', 'examples', 'default', 'title', 'description', '$schema', '$id']);
|
|
30
|
+
export function unsupportedKeywords(schema, prefix = '') {
|
|
31
|
+
if (!schema)
|
|
32
|
+
return [];
|
|
33
|
+
const found = [];
|
|
34
|
+
for (const key of Object.keys(schema)) {
|
|
35
|
+
if (!SUPPORTED_KEYWORDS.has(key))
|
|
36
|
+
found.push(prefix ? `${prefix}.${key}` : key);
|
|
37
|
+
}
|
|
38
|
+
for (const [name, child] of Object.entries(schema.properties ?? {})) {
|
|
39
|
+
if (child === null || typeof child !== 'object' || Array.isArray(child))
|
|
40
|
+
continue;
|
|
41
|
+
found.push(...unsupportedKeywords(child, prefix ? `${prefix}.${name}` : name));
|
|
42
|
+
}
|
|
43
|
+
if (schema.items && !Array.isArray(schema.items)) {
|
|
44
|
+
found.push(...unsupportedKeywords(schema.items, prefix ? `${prefix}.items` : 'items'));
|
|
45
|
+
}
|
|
46
|
+
for (const [i, child] of (schema.anyOf ?? []).entries()) {
|
|
47
|
+
found.push(...unsupportedKeywords(child, `${prefix ? `${prefix}.` : ''}anyOf[${i}]`));
|
|
48
|
+
}
|
|
49
|
+
for (const [i, child] of (schema.oneOf ?? []).entries()) {
|
|
50
|
+
found.push(...unsupportedKeywords(child, `${prefix ? `${prefix}.` : ''}oneOf[${i}]`));
|
|
51
|
+
}
|
|
52
|
+
return found;
|
|
53
|
+
}
|
|
54
|
+
function typeOf(value) {
|
|
55
|
+
if (value === null)
|
|
56
|
+
return 'null';
|
|
57
|
+
if (Array.isArray(value))
|
|
58
|
+
return 'array';
|
|
59
|
+
if (typeof value === 'number')
|
|
60
|
+
return Number.isInteger(value) ? 'integer' : 'number';
|
|
61
|
+
return typeof value;
|
|
62
|
+
}
|
|
63
|
+
function matchesType(value, declared) {
|
|
64
|
+
const actual = typeOf(value);
|
|
65
|
+
if (declared === 'number')
|
|
66
|
+
return actual === 'number' || actual === 'integer';
|
|
67
|
+
if (declared === 'integer')
|
|
68
|
+
return actual === 'integer';
|
|
69
|
+
return actual === declared;
|
|
70
|
+
}
|
|
71
|
+
function joinPath(path, key) {
|
|
72
|
+
if (typeof key === 'number')
|
|
73
|
+
return `${path}[${key}]`;
|
|
74
|
+
return path ? `${path}.${key}` : key;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Validates extracted tool arguments against the capability's schema.
|
|
78
|
+
* Errors are ordered by path so a model can read them top-down.
|
|
79
|
+
*/
|
|
80
|
+
export function validateParams(value, schema) {
|
|
81
|
+
const errors = [];
|
|
82
|
+
if (!schema) {
|
|
83
|
+
if (value === undefined)
|
|
84
|
+
return { valid: true, value: {} };
|
|
85
|
+
if (value === null)
|
|
86
|
+
return { valid: true, value: {} };
|
|
87
|
+
if (typeof value !== 'object' || Array.isArray(value)) {
|
|
88
|
+
return {
|
|
89
|
+
valid: false,
|
|
90
|
+
errors: [{ path: '', keyword: 'type', message: 'arguments must be an object' }],
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return { valid: true, value: value };
|
|
94
|
+
}
|
|
95
|
+
walk(value, schema, '', errors);
|
|
96
|
+
const root = typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
97
|
+
if (errors.length === 0) {
|
|
98
|
+
return { valid: true, value: root ? value : {} };
|
|
99
|
+
}
|
|
100
|
+
errors.sort((a, b) => a.path.localeCompare(b.path));
|
|
101
|
+
return { valid: false, errors };
|
|
102
|
+
}
|
|
103
|
+
/** Turns validator output into the single line the model sees on a retry. */
|
|
104
|
+
export function formatSchemaErrors(errors) {
|
|
105
|
+
return errors.map((e) => {
|
|
106
|
+
const where = e.path ? `arguments.${e.path}` : 'arguments';
|
|
107
|
+
return `${where} ${e.message} (${e.keyword})`;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function walk(value, schema, path, errors) {
|
|
111
|
+
const push = (keyword, message) => errors.push({ path, keyword, message });
|
|
112
|
+
const where = path ? `arguments.${path}` : 'arguments';
|
|
113
|
+
if (schema.const !== undefined && JSON.stringify(value) !== JSON.stringify(schema.const)) {
|
|
114
|
+
push('const', `must equal ${JSON.stringify(schema.const)}`);
|
|
115
|
+
}
|
|
116
|
+
if (schema.enum) {
|
|
117
|
+
const ok = schema.enum.some((option) => JSON.stringify(option) === JSON.stringify(value));
|
|
118
|
+
if (!ok)
|
|
119
|
+
push('enum', `must be one of ${schema.enum.map((v) => JSON.stringify(v)).join(', ')}`);
|
|
120
|
+
}
|
|
121
|
+
if (schema.type) {
|
|
122
|
+
const declared = Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
123
|
+
if (!declared.some((t) => matchesType(value, t))) {
|
|
124
|
+
push('type', `must be ${declared.join(' | ')}, got ${typeOf(value)}`);
|
|
125
|
+
return; // further keywords assume the type held
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (schema.anyOf && schema.anyOf.length > 0) {
|
|
129
|
+
const attempts = schema.anyOf.map((sub) => {
|
|
130
|
+
const local = [];
|
|
131
|
+
walk(value, sub, path, local);
|
|
132
|
+
return local;
|
|
133
|
+
});
|
|
134
|
+
if (!attempts.some((a) => a.length === 0)) {
|
|
135
|
+
const summary = attempts
|
|
136
|
+
.map((a, i) => `option ${i + 1}: ${a.map((e) => e.message).join(', ') || 'no match'}`)
|
|
137
|
+
.join('; ');
|
|
138
|
+
push('anyOf', `must match one of the allowed shapes (${summary})`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (schema.oneOf && schema.oneOf.length > 0) {
|
|
142
|
+
const passing = schema.oneOf.filter((sub) => {
|
|
143
|
+
const local = [];
|
|
144
|
+
walk(value, sub, path, local);
|
|
145
|
+
return local.length === 0;
|
|
146
|
+
}).length;
|
|
147
|
+
if (passing !== 1)
|
|
148
|
+
push('oneOf', `must match exactly one shape, matched ${passing}`);
|
|
149
|
+
}
|
|
150
|
+
if (typeof value === 'string') {
|
|
151
|
+
if (schema.minLength !== undefined && value.length < schema.minLength) {
|
|
152
|
+
push('minLength', `must be at least ${schema.minLength} characters`);
|
|
153
|
+
}
|
|
154
|
+
if (schema.maxLength !== undefined && value.length > schema.maxLength) {
|
|
155
|
+
push('maxLength', `must be at most ${schema.maxLength} characters`);
|
|
156
|
+
}
|
|
157
|
+
if (schema.pattern) {
|
|
158
|
+
let re;
|
|
159
|
+
try {
|
|
160
|
+
re = new RegExp(schema.pattern);
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
push('pattern', `schema pattern is not a valid regular expression`);
|
|
164
|
+
}
|
|
165
|
+
if (re && !re.test(value))
|
|
166
|
+
push('pattern', `must match /${schema.pattern}/`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (typeof value === 'number') {
|
|
170
|
+
if (schema.minimum !== undefined && value < schema.minimum) {
|
|
171
|
+
push('minimum', `must be >= ${schema.minimum}`);
|
|
172
|
+
}
|
|
173
|
+
if (schema.maximum !== undefined && value > schema.maximum) {
|
|
174
|
+
push('maximum', `must be <= ${schema.maximum}`);
|
|
175
|
+
}
|
|
176
|
+
if (schema.exclusiveMinimum !== undefined && value <= schema.exclusiveMinimum) {
|
|
177
|
+
push('exclusiveMinimum', `must be > ${schema.exclusiveMinimum}`);
|
|
178
|
+
}
|
|
179
|
+
if (schema.exclusiveMaximum !== undefined && value >= schema.exclusiveMaximum) {
|
|
180
|
+
push('exclusiveMaximum', `must be < ${schema.exclusiveMaximum}`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (Array.isArray(value)) {
|
|
184
|
+
if (schema.minItems !== undefined && value.length < schema.minItems) {
|
|
185
|
+
push('minItems', `must contain at least ${schema.minItems} items`);
|
|
186
|
+
}
|
|
187
|
+
if (schema.maxItems !== undefined && value.length > schema.maxItems) {
|
|
188
|
+
push('maxItems', `must contain at most ${schema.maxItems} items`);
|
|
189
|
+
}
|
|
190
|
+
if (schema.items && !Array.isArray(schema.items)) {
|
|
191
|
+
value.forEach((item, i) => walk(item, schema.items, joinPath(path, i), errors));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
|
|
195
|
+
const record = value;
|
|
196
|
+
for (const key of schema.required ?? []) {
|
|
197
|
+
if (!(key in record) || record[key] === undefined) {
|
|
198
|
+
const missingPath = joinPath(path, key);
|
|
199
|
+
errors.push({
|
|
200
|
+
path: missingPath || key,
|
|
201
|
+
keyword: 'required',
|
|
202
|
+
message: `is required but was not provided`,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
for (const [key, sub] of Object.entries(schema.properties ?? {})) {
|
|
207
|
+
if (key in record && record[key] !== undefined) {
|
|
208
|
+
walk(record[key], sub, joinPath(path, key), errors);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (schema.additionalProperties === false) {
|
|
212
|
+
for (const key of Object.keys(record)) {
|
|
213
|
+
if (!(key in (schema.properties ?? {}))) {
|
|
214
|
+
errors.push({
|
|
215
|
+
path: joinPath(path, key),
|
|
216
|
+
keyword: 'additionalProperties',
|
|
217
|
+
message: `is not an allowed argument (allowed: ${Object.keys(schema.properties ?? {}).join(', ') || 'none'})`,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else if (schema.additionalProperties && typeof schema.additionalProperties === 'object') {
|
|
223
|
+
for (const key of Object.keys(record)) {
|
|
224
|
+
if (!(key in (schema.properties ?? {}))) {
|
|
225
|
+
walk(record[key], schema.additionalProperties, joinPath(path, key), errors);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/core/schema.ts"],"names":[],"mappings":"AAaA,gGAAgG;AAChG,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACxC,SAAS;IACT,KAAK;IACL,MAAM;IACN,YAAY;IACZ,UAAU;IACV,sBAAsB;IACtB,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,SAAS;IACT,SAAS;IACT,kBAAkB;IAClB,kBAAkB;IAClB,WAAW;IACX,WAAW;IACX,SAAS;IACT,UAAU;IACV,UAAU;IACV,aAAa;IACb,OAAO;IACP,SAAS;IACT,UAAU;CACX,CAAC,CAAC;AAEH,wEAAwE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