@dex-ai/knowledge-extension 0.1.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/package.json +33 -0
- package/src/index.ts +35 -0
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dex-ai/knowledge-extension",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Knowledge / RAG Extension for Dex. (Stub in v0.1.)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./src/index.ts",
|
|
9
|
+
"default": "./src/index.ts"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"src"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"typecheck": "tsc --noEmit",
|
|
17
|
+
"test": "echo \"(no tests)\"",
|
|
18
|
+
"changeset": "changeset",
|
|
19
|
+
"version": "changeset version",
|
|
20
|
+
"release": "changeset publish"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"typescript": "^5.6.3",
|
|
24
|
+
"@types/bun": "latest",
|
|
25
|
+
"bun-types": "latest",
|
|
26
|
+
"@changesets/cli": "^2.29.0"
|
|
27
|
+
},
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public",
|
|
31
|
+
"registry": "https://registry.npmjs.org/"
|
|
32
|
+
}
|
|
33
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @dex-ai/knowledge — RAG layer for Dex.
|
|
3
|
+
*
|
|
4
|
+
* v0.1: stub. Will ship knowledgeExtension following the @dex-ai/session
|
|
5
|
+
* pattern: the extension takes a KnowledgeAdapter (interface only; default
|
|
6
|
+
* impl is LanceDB-backed when it lands in v0.2). On onRequest, recalls
|
|
7
|
+
* k top-matches and prepends them as a synthetic system message — never
|
|
8
|
+
* persisted into actx.messages.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export interface Embedder {
|
|
12
|
+
readonly dimensions: number;
|
|
13
|
+
embed(texts: string[]): Promise<number[][]>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type IngestSource =
|
|
17
|
+
| { type: 'file'; path: string; title?: string }
|
|
18
|
+
| { type: 'text'; text: string; title?: string; source?: string }
|
|
19
|
+
| { type: 'url'; url: string };
|
|
20
|
+
|
|
21
|
+
export interface QueryMatch {
|
|
22
|
+
docId: string;
|
|
23
|
+
chunkId: string;
|
|
24
|
+
text: string;
|
|
25
|
+
score: number;
|
|
26
|
+
source: string;
|
|
27
|
+
title: string | null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface KnowledgeAdapter {
|
|
31
|
+
ingest(source: IngestSource): Promise<{ docId: string; chunkCount: number }>;
|
|
32
|
+
query(text: string, opts?: { k?: number; filter?: Record<string, string> }): Promise<QueryMatch[]>;
|
|
33
|
+
list(): Promise<Array<{ docId: string; title: string | null; source: string }>>;
|
|
34
|
+
delete(docId: string): Promise<void>;
|
|
35
|
+
}
|