@appinternalleads/ui 0.3.0 → 0.4.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/dist/cjs/agent/base.js +25 -0
- package/dist/cjs/agent/base.js.map +1 -0
- package/dist/cjs/agent/catalog.js +0 -32
- package/dist/cjs/agent/catalog.js.map +1 -1
- package/dist/cjs/agent/core.js +22 -20
- package/dist/cjs/agent/core.js.map +1 -1
- package/dist/cjs/agent/index.js +6 -5
- package/dist/cjs/agent/index.js.map +1 -1
- package/dist/cjs/agent/search/document.js +50 -0
- package/dist/cjs/agent/search/document.js.map +1 -0
- package/dist/cjs/agent/search/embedding.js +107 -0
- package/dist/cjs/agent/search/embedding.js.map +1 -0
- package/dist/cjs/agent/search/index.js +25 -0
- package/dist/cjs/agent/search/index.js.map +1 -0
- package/dist/cjs/agent/search/lexical.js +28 -0
- package/dist/cjs/agent/search/lexical.js.map +1 -0
- package/dist/cjs/agent/search/normalize.js +15 -0
- package/dist/cjs/agent/search/normalize.js.map +1 -0
- package/dist/cjs/agent/search/search.js +123 -0
- package/dist/cjs/agent/search/search.js.map +1 -0
- package/dist/cjs/agent/search/searchIndex.js +120 -0
- package/dist/cjs/agent/search/searchIndex.js.map +1 -0
- package/dist/cjs/agent/search/types.js +8 -0
- package/dist/cjs/agent/search/types.js.map +1 -0
- package/dist/cjs/agent/search/weights.js +34 -0
- package/dist/cjs/agent/search/weights.js.map +1 -0
- package/dist/cjs/agent/search/wordvectors.json +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/agent/base.d.ts +11 -0
- package/dist/esm/agent/base.d.ts.map +1 -0
- package/dist/esm/agent/base.js +11 -0
- package/dist/esm/agent/base.js.map +1 -0
- package/dist/esm/agent/catalog.d.ts +0 -8
- package/dist/esm/agent/catalog.d.ts.map +1 -1
- package/dist/esm/agent/catalog.js +0 -31
- package/dist/esm/agent/catalog.js.map +1 -1
- package/dist/esm/agent/core.d.ts +6 -7
- package/dist/esm/agent/core.d.ts.map +1 -1
- package/dist/esm/agent/core.js +6 -7
- package/dist/esm/agent/core.js.map +1 -1
- package/dist/esm/agent/index.d.ts +6 -5
- package/dist/esm/agent/index.d.ts.map +1 -1
- package/dist/esm/agent/index.js +6 -5
- package/dist/esm/agent/index.js.map +1 -1
- package/dist/esm/agent/search/document.d.ts +6 -0
- package/dist/esm/agent/search/document.d.ts.map +1 -0
- package/dist/esm/agent/search/document.js +46 -0
- package/dist/esm/agent/search/document.js.map +1 -0
- package/dist/esm/agent/search/embedding.d.ts +31 -0
- package/dist/esm/agent/search/embedding.d.ts.map +1 -0
- package/dist/esm/agent/search/embedding.js +103 -0
- package/dist/esm/agent/search/embedding.js.map +1 -0
- package/dist/esm/agent/search/index.d.ts +10 -0
- package/dist/esm/agent/search/index.d.ts.map +1 -0
- package/dist/esm/agent/search/index.js +17 -0
- package/dist/esm/agent/search/index.js.map +1 -0
- package/dist/esm/agent/search/lexical.d.ts +3 -0
- package/dist/esm/agent/search/lexical.d.ts.map +1 -0
- package/dist/esm/agent/search/lexical.js +25 -0
- package/dist/esm/agent/search/lexical.js.map +1 -0
- package/dist/esm/agent/search/normalize.d.ts +13 -0
- package/dist/esm/agent/search/normalize.d.ts.map +1 -0
- package/dist/esm/agent/search/normalize.js +12 -0
- package/dist/esm/agent/search/normalize.js.map +1 -0
- package/dist/esm/agent/search/search.d.ts +42 -0
- package/dist/esm/agent/search/search.d.ts.map +1 -0
- package/dist/esm/agent/search/search.js +119 -0
- package/dist/esm/agent/search/search.js.map +1 -0
- package/dist/esm/agent/search/searchIndex.d.ts +42 -0
- package/dist/esm/agent/search/searchIndex.d.ts.map +1 -0
- package/dist/esm/agent/search/searchIndex.js +114 -0
- package/dist/esm/agent/search/searchIndex.js.map +1 -0
- package/dist/esm/agent/search/types.d.ts +67 -0
- package/dist/esm/agent/search/types.d.ts.map +1 -0
- package/dist/esm/agent/search/types.js +7 -0
- package/dist/esm/agent/search/types.js.map +1 -0
- package/dist/esm/agent/search/weights.d.ts +22 -0
- package/dist/esm/agent/search/weights.d.ts.map +1 -0
- package/dist/esm/agent/search/weights.js +31 -0
- package/dist/esm/agent/search/weights.js.map +1 -0
- package/dist/esm/agent/search/wordvectors.json +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -1
- package/src/agent/base.ts +17 -0
- package/src/agent/catalog.ts +0 -32
- package/src/agent/core.ts +6 -14
- package/src/agent/index.ts +6 -5
- package/src/agent/search/document.ts +46 -0
- package/src/agent/search/embedding.ts +95 -0
- package/src/agent/search/index.ts +20 -0
- package/src/agent/search/lexical.ts +25 -0
- package/src/agent/search/normalize.ts +17 -0
- package/src/agent/search/search.ts +148 -0
- package/src/agent/search/searchIndex.ts +107 -0
- package/src/agent/search/types.ts +68 -0
- package/src/agent/search/weights.ts +32 -0
- package/src/index.ts +1 -1
- package/tools/ask/dist/components.mjs +348 -12
package/dist/cjs/index.js
CHANGED
|
@@ -37,6 +37,6 @@ __exportStar(require("./widgets"), exports);
|
|
|
37
37
|
nothing is implemented. See docs/architecture/COMPONENT-FAMILIES.md. */
|
|
38
38
|
__exportStar(require("./components"), exports);
|
|
39
39
|
__exportStar(require("./sheets"), exports);
|
|
40
|
-
/* The agent component contract:
|
|
40
|
+
/* The agent component contract for the renderer: AgentComponent, describe, render/1 validation, result/1. Search is in `@appinternalleads/ui/agent`. */
|
|
41
41
|
__exportStar(require("./agent"), exports);
|
|
42
42
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,uCAAqB;AACrB,+CAAmE;AAA1D,qGAAA,KAAK,OAAA;AAAE,yGAAA,SAAS,OAAA;AAAE,qGAAA,KAAK,OAAA;AAAE,wGAAA,QAAQ,OAAA;AAC1C,2CAAyB;AACzB,4CAA0B;AAC1B;0EAC0E;AAC1E,+CAA6B;AAC7B,2CAAyB;AACzB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,uCAAqB;AACrB,+CAAmE;AAA1D,qGAAA,KAAK,OAAA;AAAE,yGAAA,SAAS,OAAA;AAAE,qGAAA,KAAK,OAAA;AAAE,wGAAA,QAAQ,OAAA;AAC1C,2CAAyB;AACzB,4CAA0B;AAC1B;0EAC0E;AAC1E,+CAA6B;AAC7B,2CAAyB;AACzB,wJAAwJ;AACxJ,0CAAwB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **The agent contract without search** — describe, `render/1` validation, `result/1`, the types.
|
|
3
|
+
* Small and React-free. Both entry points carry it: `@appinternalleads/ui/agent` (`./core`) adds
|
|
4
|
+
* `searchComponents`; the main entry adds `AgentComponent`. Search is not here on purpose — its
|
|
5
|
+
* word-vector table is 2.8 MB, and an app that renders components must not bundle it.
|
|
6
|
+
*/
|
|
7
|
+
export { AGENT_COMPONENTS, agentAvailability, describeComponent, isAgentComponent, listAgentComponents, } from './catalog';
|
|
8
|
+
export { validateRenderRequest } from './validate';
|
|
9
|
+
export { RESULT_EVENTS, makeResult } from './result';
|
|
10
|
+
export { CAPABILITY_SCHEMA, RENDER_SCHEMA, RESULT_SCHEMA, type AgentButtonAction, type AgentCapability, type CapabilityAction, type CapabilityCard, type CapabilityEvent, type CapabilityKind, type CopySpec as AgentCopySpec, type DataOrigin, type FieldSpec as AgentFieldSpec, type IssueCode, type IssueLayer, type Owner as AgentOwner, type RenderCheck, type RenderIssue, type RenderPreview, type RenderRequest, type RenderResult, type Section as AgentSection, } from './types';
|
|
11
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/agent/base.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,mBAAmB,GAC9F,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EACL,iBAAiB,EAAE,aAAa,EAAE,aAAa,EAC/C,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EACnI,KAAK,QAAQ,IAAI,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,IAAI,cAAc,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,KAAK,IAAI,UAAU,EAC5I,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,OAAO,IAAI,YAAY,GAC5H,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **The agent contract without search** — describe, `render/1` validation, `result/1`, the types.
|
|
3
|
+
* Small and React-free. Both entry points carry it: `@appinternalleads/ui/agent` (`./core`) adds
|
|
4
|
+
* `searchComponents`; the main entry adds `AgentComponent`. Search is not here on purpose — its
|
|
5
|
+
* word-vector table is 2.8 MB, and an app that renders components must not bundle it.
|
|
6
|
+
*/
|
|
7
|
+
export { AGENT_COMPONENTS, agentAvailability, describeComponent, isAgentComponent, listAgentComponents, } from './catalog';
|
|
8
|
+
export { validateRenderRequest } from './validate';
|
|
9
|
+
export { RESULT_EVENTS, makeResult } from './result';
|
|
10
|
+
export { CAPABILITY_SCHEMA, RENDER_SCHEMA, RESULT_SCHEMA, } from './types';
|
|
11
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/agent/base.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,mBAAmB,GAC9F,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EACL,iBAAiB,EAAE,aAAa,EAAE,aAAa,GAIhD,MAAM,SAAS,CAAC"}
|
|
@@ -27,12 +27,4 @@ export declare function agentAvailability(id: string): {
|
|
|
27
27
|
agentEditable: boolean;
|
|
28
28
|
reason?: string;
|
|
29
29
|
};
|
|
30
|
-
/**
|
|
31
|
-
* **Intent → candidates.** A short list of cards, best first. Scored on the component's own
|
|
32
|
-
* selection signals (a whole phrase in the request counts most), then its name and purpose, then
|
|
33
|
-
* when to use it. Deterministic: the same words give the same order.
|
|
34
|
-
*/
|
|
35
|
-
export declare function searchComponents(query: string, limit?: number): (CapabilityCard & {
|
|
36
|
-
score: number;
|
|
37
|
-
})[];
|
|
38
30
|
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/agent/catalog.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAE9D,OAAO,EAAqB,KAAK,eAAe,EAAE,KAAK,cAAc,EAAiB,MAAM,SAAS,CAAC;AAEtG;;;;;GAKG;AAE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AAM,KAAG,QAAQ,GAAG,SAA0B,CAAC;AAE9E,gHAAgH;AAChH,wBAAgB,WAAW,CAAC,CAAC,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAGvD;AAgDD,kHAAkH;AAClH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAGzE;AAID,gDAAgD;AAChD,wBAAgB,mBAAmB,IAAI,cAAc,EAAE,CAEtD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAM5G"}
|
|
@@ -82,35 +82,4 @@ export function agentAvailability(id) {
|
|
|
82
82
|
}
|
|
83
83
|
return { component: id, agentEditable: false, reason: 'No such component.' };
|
|
84
84
|
}
|
|
85
|
-
/* ── Search ────────────────────────────────────────────────────────────────────────────────── */
|
|
86
|
-
const STOP = new Set('a an the of for to and or in on at by with my me i we our you your it is are be this that these those can could would should please make create show give get want need some any what how which who when from as into about'.split(' '));
|
|
87
|
-
const stem = (w) => w.replace(/(ies)$/, 'y').replace(/(ing|ed|es|s)$/, '');
|
|
88
|
-
const words = (s) => s.toLowerCase().replace(/[^\p{L}\p{N}\s'-]/gu, ' ').split(/[\s'-]+/).filter(w => w.length > 1 && !STOP.has(w)).map(stem);
|
|
89
|
-
/**
|
|
90
|
-
* **Intent → candidates.** A short list of cards, best first. Scored on the component's own
|
|
91
|
-
* selection signals (a whole phrase in the request counts most), then its name and purpose, then
|
|
92
|
-
* when to use it. Deterministic: the same words give the same order.
|
|
93
|
-
*/
|
|
94
|
-
export function searchComponents(query, limit = 5) {
|
|
95
|
-
const q = ` ${query.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu, ' ').replace(/\s+/g, ' ')} `;
|
|
96
|
-
const qw = new Set(words(query));
|
|
97
|
-
const scored = [...CAPABILITIES.values()].map((c, order) => {
|
|
98
|
-
let score = 0;
|
|
99
|
-
for (const s of c.signals) {
|
|
100
|
-
const phrase = ` ${s.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu, ' ').replace(/\s+/g, ' ')} `;
|
|
101
|
-
if (q.includes(phrase))
|
|
102
|
-
score += 6 + 2 * (phrase.trim().split(' ').length - 1);
|
|
103
|
-
else
|
|
104
|
-
score += words(s).filter(w => qw.has(w)).length * 2;
|
|
105
|
-
}
|
|
106
|
-
score += words(`${c.name} ${c.purpose}`).filter(w => qw.has(w)).length;
|
|
107
|
-
score += new Set(words(c.useWhen.join(' ')).filter(w => qw.has(w))).size * 0.5;
|
|
108
|
-
return { card: cardOf(c), score, order };
|
|
109
|
-
});
|
|
110
|
-
return scored
|
|
111
|
-
.filter(s => s.score > 0)
|
|
112
|
-
.sort((a, b) => b.score - a.score || a.order - b.order)
|
|
113
|
-
.slice(0, limit)
|
|
114
|
-
.map(s => ({ ...s.card, score: s.score }));
|
|
115
|
-
}
|
|
116
85
|
//# sourceMappingURL=catalog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../../src/agent/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAC3G,OAAO,EAAE,iBAAiB,EAAwB,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,aAAa,EAAoB,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAA4D,MAAM,SAAS,CAAC;AAUtG,MAAM,SAAS,GAAwB,CAAC,GAAG,aAAa,EAAE,GAAG,iBAAiB,CAAC,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CAAC,EAAU;IAC1C,IAAI,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;QAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;IACxE,IAAK,qBAA2C,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;QAC9D,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,uIAAuI,EAAE,CAAC;IAClM,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,oBAAoB,EAAE,CAAC;AAC/E,CAAC"}
|
package/dist/esm/agent/core.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* `render/1` validation and `result/1`: what a backend or an MCP server needs,
|
|
4
|
-
* plain Node.
|
|
2
|
+
* **`@appinternalleads/ui/agent` — the agent contract, with search, without React.** Search,
|
|
3
|
+
* describe, `render/1` validation and `result/1`: what a backend or an MCP server needs, all of it in
|
|
4
|
+
* plain Node. `searchComponents` lives only here (and its word-vector table with it); the renderer,
|
|
5
|
+
* `AgentComponent`, is in the main entry. `docs/AGENT-COMPONENT-CONTRACT.md`.
|
|
5
6
|
*/
|
|
6
|
-
export
|
|
7
|
-
export {
|
|
8
|
-
export { RESULT_EVENTS, makeResult } from './result';
|
|
9
|
-
export { CAPABILITY_SCHEMA, RENDER_SCHEMA, RESULT_SCHEMA, type AgentButtonAction, type AgentCapability, type CapabilityAction, type CapabilityCard, type CapabilityEvent, type CapabilityKind, type CopySpec as AgentCopySpec, type DataOrigin, type FieldSpec as AgentFieldSpec, type IssueCode, type IssueLayer, type Owner as AgentOwner, type RenderCheck, type RenderIssue, type RenderPreview, type RenderRequest, type RenderResult, type Section as AgentSection, } from './types';
|
|
7
|
+
export * from './base';
|
|
8
|
+
export { searchComponents } from './search';
|
|
10
9
|
//# sourceMappingURL=core.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../src/agent/core.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../src/agent/core.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/esm/agent/core.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* `render/1` validation and `result/1`: what a backend or an MCP server needs,
|
|
4
|
-
* plain Node.
|
|
2
|
+
* **`@appinternalleads/ui/agent` — the agent contract, with search, without React.** Search,
|
|
3
|
+
* describe, `render/1` validation and `result/1`: what a backend or an MCP server needs, all of it in
|
|
4
|
+
* plain Node. `searchComponents` lives only here (and its word-vector table with it); the renderer,
|
|
5
|
+
* `AgentComponent`, is in the main entry. `docs/AGENT-COMPONENT-CONTRACT.md`.
|
|
5
6
|
*/
|
|
6
|
-
export
|
|
7
|
-
export {
|
|
8
|
-
export { RESULT_EVENTS, makeResult } from './result';
|
|
9
|
-
export { CAPABILITY_SCHEMA, RENDER_SCHEMA, RESULT_SCHEMA, } from './types';
|
|
7
|
+
export * from './base';
|
|
8
|
+
export { searchComponents } from './search';
|
|
10
9
|
//# sourceMappingURL=core.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/agent/core.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/agent/core.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* **The agent
|
|
2
|
+
* **The agent contract, as the main entry carries it** — for the app that renders: `AgentComponent`,
|
|
3
|
+
* `AGENT_RENDERABLE`, and the small React-free contract they use (describe, validate, results).
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Not `searchComponents`: component search belongs to the agent, and its word-vector table must not
|
|
6
|
+
* reach an app's bundle. Import it from `@appinternalleads/ui/agent`. `tests/agent/boundary.test.ts`
|
|
7
|
+
* holds this line on the built package.
|
|
7
8
|
*/
|
|
8
|
-
export * from './
|
|
9
|
+
export * from './base';
|
|
9
10
|
export { AgentComponent, AGENT_RENDERABLE, type AgentComponentProps } from './AgentComponent';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/esm/agent/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* **The agent
|
|
2
|
+
* **The agent contract, as the main entry carries it** — for the app that renders: `AgentComponent`,
|
|
3
|
+
* `AGENT_RENDERABLE`, and the small React-free contract they use (describe, validate, results).
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Not `searchComponents`: component search belongs to the agent, and its word-vector table must not
|
|
6
|
+
* reach an app's bundle. Import it from `@appinternalleads/ui/agent`. `tests/agent/boundary.test.ts`
|
|
7
|
+
* holds this line on the built package.
|
|
7
8
|
*/
|
|
8
|
-
export * from './
|
|
9
|
+
export * from './base';
|
|
9
10
|
export { AgentComponent, AGENT_RENDERABLE } from './AgentComponent';
|
|
10
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agent/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAA4B,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AgentCapability } from '../types';
|
|
2
|
+
import type { SearchDocument } from './types';
|
|
3
|
+
export declare function searchDocumentOf(c: AgentCapability, order: number, allIds: readonly string[]): SearchDocument;
|
|
4
|
+
/** FNV-1a over the documents: the catalogue's search version. Any change to what search reads changes it. */
|
|
5
|
+
export declare function versionOf(value: unknown): string;
|
|
6
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../../src/agent/search/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAa,MAAM,UAAU,CAAC;AAC3D,OAAO,KAAK,EAAa,cAAc,EAAE,MAAM,SAAS,CAAC;AAsBzD,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,cAAc,CAc7G;AAED,6GAA6G;AAC7G,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKhD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **A component's search document, derived from its capability.** It says what problem the
|
|
3
|
+
* component solves — purpose, when to use it, its selection signals, its case studies' scenarios,
|
|
4
|
+
* what a person can do with it, what it shows and what it reports — and, separately, what it is not
|
|
5
|
+
* for (`avoidWhen`). Nothing is written for search alone, so a new approved component is searchable
|
|
6
|
+
* the moment it has a capability. No source, no implementation, no runtime values.
|
|
7
|
+
*/
|
|
8
|
+
/** "…statement over time — use budget-tracker or a list." → "…statement over time": the pointer to another component is advice, not meaning. */
|
|
9
|
+
function ownMeaning(text, ids) {
|
|
10
|
+
let t = text.replace(/\s[—–-]+\s*use\s.*$/i, '').replace(/:\s*use\s.*$/i, '');
|
|
11
|
+
for (const id of ids)
|
|
12
|
+
t = t.split(id).join(' ');
|
|
13
|
+
return t.replace(/\s+/g, ' ').trim();
|
|
14
|
+
}
|
|
15
|
+
const describeData = (key, spec) => {
|
|
16
|
+
const words = key.replace(/([a-z])([A-Z])/g, '$1 $2').toLowerCase();
|
|
17
|
+
return `${words}: ${spec.description}`;
|
|
18
|
+
};
|
|
19
|
+
export function searchDocumentOf(c, order, allIds) {
|
|
20
|
+
const positive = [];
|
|
21
|
+
const add = (type, text) => { const t = text && ownMeaning(text, allIds); if (t)
|
|
22
|
+
positive.push({ type, text: t }); };
|
|
23
|
+
add('name', c.name);
|
|
24
|
+
add('purpose', c.purpose);
|
|
25
|
+
c.signals.forEach(s => add('signal', s));
|
|
26
|
+
c.useWhen.forEach(s => add('useWhen', s));
|
|
27
|
+
c.presets.forEach(p => add('scenario', `${p.title}. ${p.scenario}`));
|
|
28
|
+
c.actions.forEach(a => add('action', a.description));
|
|
29
|
+
c.states.forEach(s => add('state', s.description));
|
|
30
|
+
c.events.forEach(e => add('event', e.description));
|
|
31
|
+
for (const [k, spec] of Object.entries(c.data))
|
|
32
|
+
add('data', describeData(k, spec));
|
|
33
|
+
const negative = c.avoidWhen.map(t => ownMeaning(t, allIds)).filter(Boolean).map(text => ({ text }));
|
|
34
|
+
return { component: c.component, order, positive, negative };
|
|
35
|
+
}
|
|
36
|
+
/** FNV-1a over the documents: the catalogue's search version. Any change to what search reads changes it. */
|
|
37
|
+
export function versionOf(value) {
|
|
38
|
+
const s = JSON.stringify(value);
|
|
39
|
+
let h = 0x811c9dc5;
|
|
40
|
+
for (let i = 0; i < s.length; i++) {
|
|
41
|
+
h ^= s.charCodeAt(i);
|
|
42
|
+
h = Math.imul(h, 0x01000193);
|
|
43
|
+
}
|
|
44
|
+
return (h >>> 0).toString(16).padStart(8, '0');
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../../../src/agent/search/document.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AAEH,gJAAgJ;AAChJ,SAAS,UAAU,CAAC,IAAY,EAAE,GAAsB;IACtD,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IAC9E,KAAK,MAAM,EAAE,IAAI,GAAG;QAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChD,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AACvC,CAAC;AAED,MAAM,YAAY,GAAG,CAAC,GAAW,EAAE,IAAe,EAAU,EAAE;IAC5D,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IACpE,OAAO,GAAG,KAAK,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC;AACzC,CAAC,CAAC;AAEF,MAAM,UAAU,gBAAgB,CAAC,CAAkB,EAAE,KAAa,EAAE,MAAyB;IAC3F,MAAM,QAAQ,GAAwC,EAAE,CAAC;IACzD,MAAM,GAAG,GAAG,CAAC,IAAe,EAAE,IAAwB,EAAE,EAAE,GAAG,MAAM,CAAC,GAAG,IAAI,IAAI,UAAU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AAC;IACnF,MAAM,QAAQ,GAAG,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACrG,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAC/D,CAAC;AAED,6GAA6G;AAC7G,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAChC,IAAI,CAAC,GAAG,UAAU,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IAAC,CAAC;IAC1F,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { EmbeddingProvider } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* **Embedding providers.** The search asks a provider for vectors and nothing else, so the one
|
|
4
|
+
* below — pretrained word vectors shipped in the package, no network — can be replaced by a hosted
|
|
5
|
+
* model without touching retrieval or ranking.
|
|
6
|
+
*/
|
|
7
|
+
/** `bits`: 8 — int8 per value; 4 — two values per byte, each stored as value + 8 (−7…7). */
|
|
8
|
+
export type WordVectorTable = {
|
|
9
|
+
dims: number;
|
|
10
|
+
count: number;
|
|
11
|
+
words: string;
|
|
12
|
+
data: string;
|
|
13
|
+
bits?: 4 | 8;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* **Word vectors, averaged — offline and deterministic.** A text's vector is the average of its
|
|
17
|
+
* words' vectors, each weighted by how rare the word is (Arora et al.'s smooth inverse frequency,
|
|
18
|
+
* with the table's frequency order standing in for counts), so "the" counts for almost nothing and
|
|
19
|
+
* "receipt" for a lot. A word the table lacks is tried without a plural or tense ending; failing
|
|
20
|
+
* that it is skipped (lexical matching still sees it).
|
|
21
|
+
*/
|
|
22
|
+
export declare function createWordVectorProvider(table: WordVectorTable, opts?: {
|
|
23
|
+
smoothing?: number;
|
|
24
|
+
}): EmbeddingProvider;
|
|
25
|
+
/**
|
|
26
|
+
* **For tests: deterministic vectors, no model.** Each word hashes to a few dimensions, so equal words
|
|
27
|
+
* give equal vectors and different words mostly do not. It proves the machinery — indexing, ranking,
|
|
28
|
+
* filtering, fallback — not semantic quality.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createFakeEmbeddingProvider(dims?: number): EmbeddingProvider;
|
|
31
|
+
//# sourceMappingURL=embedding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../../../src/agent/search/embedding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD;;;;GAIG;AAEH,4FAA4F;AAC5F,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;CAAE,CAAC;AAwBzG;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,iBAAiB,CAmCrH;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,SAAK,GAAG,iBAAiB,CAYxE"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
const bytesOf = (b64) => {
|
|
2
|
+
if (typeof Buffer !== 'undefined') {
|
|
3
|
+
const b = Buffer.from(b64, 'base64');
|
|
4
|
+
return new Uint8Array(b.buffer, b.byteOffset, b.length);
|
|
5
|
+
}
|
|
6
|
+
const bin = atob(b64);
|
|
7
|
+
const out = new Uint8Array(bin.length);
|
|
8
|
+
for (let i = 0; i < bin.length; i++)
|
|
9
|
+
out[i] = bin.charCodeAt(i);
|
|
10
|
+
return out;
|
|
11
|
+
};
|
|
12
|
+
/* One signed value per entry, whatever the storage. Only directions matter (vectors are averaged and normalised), so no rescaling. */
|
|
13
|
+
function decode(t) {
|
|
14
|
+
const bytes = bytesOf(t.data);
|
|
15
|
+
if (t.bits !== 4)
|
|
16
|
+
return new Int8Array(bytes.buffer, bytes.byteOffset, bytes.length);
|
|
17
|
+
const out = new Int8Array(t.count * t.dims);
|
|
18
|
+
for (let i = 0; i < out.length; i++)
|
|
19
|
+
out[i] = ((bytes[i >> 1] >> ((i & 1) * 4)) & 15) - 8;
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
const unit = (v) => {
|
|
23
|
+
let n = 0;
|
|
24
|
+
for (const x of v)
|
|
25
|
+
n += x * x;
|
|
26
|
+
n = Math.sqrt(n);
|
|
27
|
+
if (n > 0)
|
|
28
|
+
for (let i = 0; i < v.length; i++)
|
|
29
|
+
v[i] /= n;
|
|
30
|
+
return v;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* **Word vectors, averaged — offline and deterministic.** A text's vector is the average of its
|
|
34
|
+
* words' vectors, each weighted by how rare the word is (Arora et al.'s smooth inverse frequency,
|
|
35
|
+
* with the table's frequency order standing in for counts), so "the" counts for almost nothing and
|
|
36
|
+
* "receipt" for a lot. A word the table lacks is tried without a plural or tense ending; failing
|
|
37
|
+
* that it is skipped (lexical matching still sees it).
|
|
38
|
+
*/
|
|
39
|
+
export function createWordVectorProvider(table, opts = {}) {
|
|
40
|
+
let index = null;
|
|
41
|
+
let data = null;
|
|
42
|
+
const a = opts.smoothing ?? 1e-3;
|
|
43
|
+
/* Zipf: a word's share of text ∝ 1 / rank. H is the normaliser for the table's size. */
|
|
44
|
+
const H = Math.log(table.count) + 0.5772;
|
|
45
|
+
const load = () => {
|
|
46
|
+
if (index)
|
|
47
|
+
return;
|
|
48
|
+
index = new Map(table.words.split(' ').map((w, i) => [w, i]));
|
|
49
|
+
data = decode(table);
|
|
50
|
+
};
|
|
51
|
+
const lookup = (w) => {
|
|
52
|
+
const m = index;
|
|
53
|
+
return m.get(w) ?? m.get(w.replace(/'s$/, '')) ?? m.get(w.replace(/ies$/, 'y')) ?? m.get(w.replace(/s$/, ''))
|
|
54
|
+
?? m.get(w.replace(/ing$/, '')) ?? m.get(w.replace(/ing$/, 'e')) ?? m.get(w.replace(/ed$/, '')) ?? m.get(w.replace(/d$/, ''));
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
id: `word-vectors:${table.dims}x${table.count}x${table.bits ?? 8}bit:sif-${a}`,
|
|
58
|
+
embed(texts) {
|
|
59
|
+
load();
|
|
60
|
+
return texts.map(text => {
|
|
61
|
+
const v = new Float32Array(table.dims);
|
|
62
|
+
for (const raw of text.toLowerCase().split(/[^\p{L}']+/u)) {
|
|
63
|
+
if (!raw)
|
|
64
|
+
continue;
|
|
65
|
+
const r = lookup(raw);
|
|
66
|
+
if (r === undefined)
|
|
67
|
+
continue;
|
|
68
|
+
const p = 1 / ((r + 1) * H);
|
|
69
|
+
const w = a / (a + p);
|
|
70
|
+
const off = r * table.dims;
|
|
71
|
+
for (let d = 0; d < table.dims; d++)
|
|
72
|
+
v[d] += w * data[off + d];
|
|
73
|
+
}
|
|
74
|
+
return unit(v);
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* **For tests: deterministic vectors, no model.** Each word hashes to a few dimensions, so equal words
|
|
81
|
+
* give equal vectors and different words mostly do not. It proves the machinery — indexing, ranking,
|
|
82
|
+
* filtering, fallback — not semantic quality.
|
|
83
|
+
*/
|
|
84
|
+
export function createFakeEmbeddingProvider(dims = 64) {
|
|
85
|
+
const hash = (s, seed) => { let h = 0x811c9dc5 ^ seed; for (let i = 0; i < s.length; i++) {
|
|
86
|
+
h ^= s.charCodeAt(i);
|
|
87
|
+
h = Math.imul(h, 0x01000193);
|
|
88
|
+
} return h >>> 0; };
|
|
89
|
+
return {
|
|
90
|
+
id: `fake:${dims}`,
|
|
91
|
+
embed(texts) {
|
|
92
|
+
return texts.map(t => {
|
|
93
|
+
const v = new Float32Array(dims);
|
|
94
|
+
for (const w of t.toLowerCase().split(/[^\p{L}\p{N}]+/u))
|
|
95
|
+
if (w)
|
|
96
|
+
for (let s = 0; s < 3; s++)
|
|
97
|
+
v[hash(w, s) % dims] += (hash(w, s + 7) & 1) ? 1 : -1;
|
|
98
|
+
return unit(v);
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=embedding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedding.js","sourceRoot":"","sources":["../../../../src/agent/search/embedding.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,GAAG,CAAC,GAAW,EAAc,EAAE;IAC1C,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAAC,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAAC,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IAAC,CAAC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C,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACpJ,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;YACjB,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type SearchCard } from './search';
|
|
2
|
+
import type { SearchOptions } from './types';
|
|
3
|
+
/** Intent → candidate cards, best first. `options.available` is the host's policy: only those components may be offered. */
|
|
4
|
+
export declare function searchComponents(query: string, limit?: number, options?: SearchOptions): SearchCard[];
|
|
5
|
+
/** Development only: why each component scored what it did. Not part of the agent's result. */
|
|
6
|
+
export declare const explainSearch: (query: string, options?: SearchOptions) => import("./types").ScoreBreakdown[] & {
|
|
7
|
+
mode: "hybrid" | "lexical";
|
|
8
|
+
version: string;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/agent/search/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAW7C,4HAA4H;AAC5H,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAI,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,UAAU,EAAE,CAEhG;AAED,+FAA+F;AAC/F,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,UAAU,aAAa;;;CAAmC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createWordVectorProvider } from './embedding';
|
|
2
|
+
import { createComponentSearch } from './search';
|
|
3
|
+
import { DEFAULT_WEIGHTS } from './weights';
|
|
4
|
+
import table from './wordvectors.json';
|
|
5
|
+
/**
|
|
6
|
+
* **`searchComponents` — the package's one search.** The MCP tool and the site's API call this; the
|
|
7
|
+
* hybrid engine behind it (`search.ts`) uses the offline word-vector provider shipped with the
|
|
8
|
+
* package, so it needs no network and gives the same answer every time.
|
|
9
|
+
*/
|
|
10
|
+
const engine = createComponentSearch({ provider: createWordVectorProvider(table), weights: DEFAULT_WEIGHTS });
|
|
11
|
+
/** Intent → candidate cards, best first. `options.available` is the host's policy: only those components may be offered. */
|
|
12
|
+
export function searchComponents(query, limit = 5, options) {
|
|
13
|
+
return engine.search(query, limit, options);
|
|
14
|
+
}
|
|
15
|
+
/** Development only: why each component scored what it did. Not part of the agent's result. */
|
|
16
|
+
export const explainSearch = (query, options) => engine.explain(query, options);
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/agent/search/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAwB,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAmB,MAAM,UAAU,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,MAAM,oBAAoB,CAAC;AAEvC;;;;GAIG;AACH,MAAM,MAAM,GAAG,qBAAqB,CAAC,EAAE,QAAQ,EAAE,wBAAwB,CAAC,KAAwB,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;AAEjI,4HAA4H;AAC5H,MAAM,UAAU,gBAAgB,CAAC,KAAa,EAAE,KAAK,GAAG,CAAC,EAAE,OAAuB;IAChF,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,+FAA+F;AAC/F,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAa,EAAE,OAAuB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexical.d.ts","sourceRoot":"","sources":["../../../../src/agent/search/lexical.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAYhD,wBAAgB,YAAY,CAAC,CAAC,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAYtE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **Lexical scoring — the search as it shipped in 0.3.0, unchanged.** Whole selection-signal phrases
|
|
3
|
+
* in the request count most, then shared words with the signals, the name and purpose, then when to
|
|
4
|
+
* use it. It is one input to the hybrid ranking, and on its own it is the fallback whenever semantic
|
|
5
|
+
* retrieval is unavailable.
|
|
6
|
+
*/
|
|
7
|
+
const STOP = new Set('a an the of for to and or in on at by with my me i we our you your it is are be this that these those can could would should please make create show give get want need some any what how which who when from as into about'.split(' '));
|
|
8
|
+
const stem = (w) => w.replace(/(ies)$/, 'y').replace(/(ing|ed|es|s)$/, '');
|
|
9
|
+
const words = (s) => s.toLowerCase().replace(/[^\p{L}\p{N}\s'-]/gu, ' ').split(/[\s'-]+/).filter(w => w.length > 1 && !STOP.has(w)).map(stem);
|
|
10
|
+
export function lexicalScore(c, query) {
|
|
11
|
+
const q = ` ${query.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu, ' ').replace(/\s+/g, ' ')} `;
|
|
12
|
+
const qw = new Set(words(query));
|
|
13
|
+
let score = 0;
|
|
14
|
+
for (const s of c.signals) {
|
|
15
|
+
const phrase = ` ${s.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu, ' ').replace(/\s+/g, ' ')} `;
|
|
16
|
+
if (q.includes(phrase))
|
|
17
|
+
score += 6 + 2 * (phrase.trim().split(' ').length - 1);
|
|
18
|
+
else
|
|
19
|
+
score += words(s).filter(w => qw.has(w)).length * 2;
|
|
20
|
+
}
|
|
21
|
+
score += words(`${c.name} ${c.purpose}`).filter(w => qw.has(w)).length;
|
|
22
|
+
score += new Set(words(c.useWhen.join(' ')).filter(w => qw.has(w))).size * 0.5;
|
|
23
|
+
return score;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=lexical.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexical.js","sourceRoot":"","sources":["../../../../src/agent/search/lexical.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,6NAA6N,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/P,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AACnF,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAEtJ,MAAM,UAAU,YAAY,CAAC,CAAkB,EAAE,KAAa;IAC5D,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC;IAC5F,MAAM,EAAE,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IACjC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;QAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC;QAC7F,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;;YAC1E,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3D,CAAC;IACD,KAAK,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACvE,KAAK,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC;IAC/E,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **Query normalisation** — whitespace, case, obvious punctuation and repeated words. Nothing that
|
|
3
|
+
* changes meaning: no synonyms, no spelling rewrites. The original stays available for lexical
|
|
4
|
+
* phrase matching and for debugging.
|
|
5
|
+
*/
|
|
6
|
+
export type NormalizedQuery = {
|
|
7
|
+
original: string;
|
|
8
|
+
text: string;
|
|
9
|
+
tokens: string[];
|
|
10
|
+
empty: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare function normalizeQuery(query: unknown): NormalizedQuery;
|
|
13
|
+
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../../../src/agent/search/normalize.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAEnG,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAS9D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function normalizeQuery(query) {
|
|
2
|
+
const original = typeof query === 'string' ? query : '';
|
|
3
|
+
const text = original.toLowerCase().normalize('NFKC').replace(/[^\p{L}\p{N}\s'-]/gu, ' ').replace(/\s+/g, ' ').trim();
|
|
4
|
+
const tokens = [];
|
|
5
|
+
for (const t of text.split(/[\s-]+/)) {
|
|
6
|
+
const w = t.replace(/^'+|'+$/g, '');
|
|
7
|
+
if (w && tokens[tokens.length - 1] !== w)
|
|
8
|
+
tokens.push(w);
|
|
9
|
+
}
|
|
10
|
+
return { original, text: tokens.join(' '), tokens, empty: tokens.length === 0 };
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../../../src/agent/search/normalize.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,MAAM,QAAQ,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IACxD,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACtH,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;AAClF,CAAC"}
|