@workglow/knowledge-base 0.0.115
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 +201 -0
- package/README.md +670 -0
- package/dist/browser.js +1071 -0
- package/dist/browser.js.map +23 -0
- package/dist/bun.js +1072 -0
- package/dist/bun.js.map +23 -0
- package/dist/chunk/ChunkSchema.d.ts +206 -0
- package/dist/chunk/ChunkSchema.d.ts.map +1 -0
- package/dist/chunk/ChunkVectorStorageSchema.d.ts +64 -0
- package/dist/chunk/ChunkVectorStorageSchema.d.ts.map +1 -0
- package/dist/common-server.d.ts +7 -0
- package/dist/common-server.d.ts.map +1 -0
- package/dist/common.d.ts +20 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/document/Document.d.ts +51 -0
- package/dist/document/Document.d.ts.map +1 -0
- package/dist/document/DocumentNode.d.ts +32 -0
- package/dist/document/DocumentNode.d.ts.map +1 -0
- package/dist/document/DocumentSchema.d.ts +1203 -0
- package/dist/document/DocumentSchema.d.ts.map +1 -0
- package/dist/document/DocumentStorageSchema.d.ts +43 -0
- package/dist/document/DocumentStorageSchema.d.ts.map +1 -0
- package/dist/document/StructuralParser.d.ts +30 -0
- package/dist/document/StructuralParser.d.ts.map +1 -0
- package/dist/knowledge-base/InMemoryKnowledgeBaseRepository.d.ts +13 -0
- package/dist/knowledge-base/InMemoryKnowledgeBaseRepository.d.ts.map +1 -0
- package/dist/knowledge-base/KnowledgeBase.d.ts +123 -0
- package/dist/knowledge-base/KnowledgeBase.d.ts.map +1 -0
- package/dist/knowledge-base/KnowledgeBaseRegistry.d.ts +38 -0
- package/dist/knowledge-base/KnowledgeBaseRegistry.d.ts.map +1 -0
- package/dist/knowledge-base/KnowledgeBaseRepository.d.ts +74 -0
- package/dist/knowledge-base/KnowledgeBaseRepository.d.ts.map +1 -0
- package/dist/knowledge-base/KnowledgeBaseSchema.d.ts +50 -0
- package/dist/knowledge-base/KnowledgeBaseSchema.d.ts.map +1 -0
- package/dist/knowledge-base/createKnowledgeBase.d.ts +30 -0
- package/dist/knowledge-base/createKnowledgeBase.d.ts.map +1 -0
- package/dist/node.js +1071 -0
- package/dist/node.js.map +23 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/util/DatasetSchema.d.ts +40 -0
- package/dist/util/DatasetSchema.d.ts.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocumentSchema.d.ts","sourceRoot":"","sources":["../../src/document/DocumentSchema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;;CAMX,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;AAMhE;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;CAgBO,CAAC;AAEpC,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;CAqBU,CAAC;AAEpC,MAAM,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AAErD;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsBE,CAAC;AAEpC,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAErE;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwBA,CAAC;AAEpC;;;;GAIG;AACH,eAAO,MAAM,kBA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AED;;GAEG;AACH,MAAM,MAAM,YAAY,GACpB,gBAAgB,GAChB,WAAW,GACX,aAAa,GACb,YAAY,GACZ,SAAS,CAAC;AAMd;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;CAqBK,CAAC;AAEpC,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAM/D;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;CAqBA,CAAC;AAEpC,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { ITabularStorage } from "@workglow/storage";
|
|
7
|
+
import { TypedArraySchemaOptions, type FromSchema } from "@workglow/util";
|
|
8
|
+
/**
|
|
9
|
+
* Schema for storing documents in tabular storage
|
|
10
|
+
*/
|
|
11
|
+
export declare const DocumentStorageSchema: {
|
|
12
|
+
readonly type: "object";
|
|
13
|
+
readonly properties: {
|
|
14
|
+
readonly doc_id: {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
readonly "x-auto-generated": true;
|
|
17
|
+
readonly title: "Document ID";
|
|
18
|
+
readonly description: "Unique identifier for the document";
|
|
19
|
+
};
|
|
20
|
+
readonly data: {
|
|
21
|
+
readonly type: "string";
|
|
22
|
+
readonly title: "Document Data";
|
|
23
|
+
readonly description: "JSON-serialized document";
|
|
24
|
+
};
|
|
25
|
+
readonly metadata: {
|
|
26
|
+
readonly type: "object";
|
|
27
|
+
readonly title: "Metadata";
|
|
28
|
+
readonly description: "Metadata of the document";
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
readonly required: readonly ["doc_id", "data"];
|
|
32
|
+
readonly additionalProperties: true;
|
|
33
|
+
};
|
|
34
|
+
export type DocumentStorageSchema = typeof DocumentStorageSchema;
|
|
35
|
+
export declare const DocumentStorageKey: readonly ["doc_id"];
|
|
36
|
+
export type DocumentStorageKey = typeof DocumentStorageKey;
|
|
37
|
+
export type DocumentStorageEntity = FromSchema<DocumentStorageSchema, TypedArraySchemaOptions>;
|
|
38
|
+
/**
|
|
39
|
+
* Type for inserting documents - doc_id is optional (auto-generated)
|
|
40
|
+
*/
|
|
41
|
+
export type InsertDocumentStorageEntity = Omit<DocumentStorageEntity, "doc_id"> & Partial<Pick<DocumentStorageEntity, "doc_id">>;
|
|
42
|
+
export type DocumentTabularStorage = ITabularStorage<typeof DocumentStorageSchema, DocumentStorageKey, DocumentStorageEntity>;
|
|
43
|
+
//# sourceMappingURL=DocumentStorageSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocumentStorageSchema.d.ts","sourceRoot":"","sources":["../../src/document/DocumentStorageSchema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,uBAAuB,EAEvB,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;CAsBO,CAAC;AAC1C,MAAM,MAAM,qBAAqB,GAAG,OAAO,qBAAqB,CAAC;AAEjE,eAAO,MAAM,kBAAkB,qBAAsB,CAAC;AACtD,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC;AAE3D,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,qBAAqB,EAAE,uBAAuB,CAAC,CAAC;AAE/F;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CAAC,GAC7E,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEjD,MAAM,MAAM,sBAAsB,GAAG,eAAe,CAClD,OAAO,qBAAqB,EAC5B,kBAAkB,EAClB,qBAAqB,CACtB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { type DocumentRootNode } from "./DocumentSchema";
|
|
7
|
+
/**
|
|
8
|
+
* Parse markdown into a hierarchical DocumentNode tree
|
|
9
|
+
*/
|
|
10
|
+
export declare class StructuralParser {
|
|
11
|
+
/**
|
|
12
|
+
* Parse markdown text into a hierarchical document tree
|
|
13
|
+
*/
|
|
14
|
+
static parseMarkdown(doc_id: string, text: string, title: string): Promise<DocumentRootNode>;
|
|
15
|
+
/**
|
|
16
|
+
* Parse plain text into a hierarchical document tree
|
|
17
|
+
* Splits by double newlines to create paragraphs
|
|
18
|
+
*/
|
|
19
|
+
static parsePlainText(doc_id: string, text: string, title: string): Promise<DocumentRootNode>;
|
|
20
|
+
/**
|
|
21
|
+
* Auto-detect format and parse
|
|
22
|
+
*/
|
|
23
|
+
static parse(doc_id: string, text: string, title: string, format?: "markdown" | "text"): Promise<DocumentRootNode>;
|
|
24
|
+
/**
|
|
25
|
+
* Check if text contains markdown header patterns
|
|
26
|
+
* Looks for lines starting with 1-6 hash symbols followed by whitespace
|
|
27
|
+
*/
|
|
28
|
+
private static looksLikeMarkdown;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=StructuralParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StructuralParser.d.ts","sourceRoot":"","sources":["../../src/document/StructuralParser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,KAAK,gBAAgB,EAItB,MAAM,kBAAkB,CAAC;AAE1B;;GAEG;AACH,qBAAa,gBAAgB;IAC3B;;OAEG;WACU,aAAa,CACxB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,gBAAgB,CAAC;IAqH5B;;;OAGG;WACU,cAAc,CACzB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,gBAAgB,CAAC;IAoE5B;;OAEG;IACH,MAAM,CAAC,KAAK,CACV,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,GAC3B,OAAO,CAAC,gBAAgB,CAAC;IAO5B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;CAIjC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { KnowledgeBaseRepository } from "./KnowledgeBaseRepository";
|
|
7
|
+
/**
|
|
8
|
+
* In-memory implementation of a knowledge base repository.
|
|
9
|
+
*/
|
|
10
|
+
export declare class InMemoryKnowledgeBaseRepository extends KnowledgeBaseRepository {
|
|
11
|
+
constructor();
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=InMemoryKnowledgeBaseRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InMemoryKnowledgeBaseRepository.d.ts","sourceRoot":"","sources":["../../src/knowledge-base/InMemoryKnowledgeBaseRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAGpE;;GAEG;AACH,qBAAa,+BAAgC,SAAQ,uBAAuB;;CAI3E"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { HybridSearchOptions, VectorSearchOptions } from "@workglow/storage";
|
|
7
|
+
import type { TypedArray } from "@workglow/util";
|
|
8
|
+
import type { ChunkRecord } from "../chunk/ChunkSchema";
|
|
9
|
+
import type { ChunkSearchResult, ChunkVectorEntity, ChunkVectorStorage, InsertChunkVectorEntity } from "../chunk/ChunkVectorStorageSchema";
|
|
10
|
+
import { Document } from "../document/Document";
|
|
11
|
+
import type { DocumentNode } from "../document/DocumentSchema";
|
|
12
|
+
import type { DocumentTabularStorage } from "../document/DocumentStorageSchema";
|
|
13
|
+
/**
|
|
14
|
+
* Unified KnowledgeBase that owns both document and vector storage,
|
|
15
|
+
* providing lifecycle management and cascading deletes.
|
|
16
|
+
*/
|
|
17
|
+
export declare class KnowledgeBase {
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly title: string;
|
|
20
|
+
readonly description: string;
|
|
21
|
+
private tabularStorage;
|
|
22
|
+
private chunkStorage;
|
|
23
|
+
constructor(name: string, documentStorage: DocumentTabularStorage, chunkStorage: ChunkVectorStorage, title?: string, description?: string);
|
|
24
|
+
/**
|
|
25
|
+
* Upsert a document.
|
|
26
|
+
* @returns The document with the generated doc_id if it was auto-generated
|
|
27
|
+
*/
|
|
28
|
+
upsertDocument(document: Document): Promise<Document>;
|
|
29
|
+
/**
|
|
30
|
+
* Get a document by ID
|
|
31
|
+
*/
|
|
32
|
+
getDocument(doc_id: string): Promise<Document | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* Delete a document and all its chunks (cascading delete).
|
|
35
|
+
*/
|
|
36
|
+
deleteDocument(doc_id: string): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* List all document IDs
|
|
39
|
+
*/
|
|
40
|
+
listDocuments(): Promise<string[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Get a specific node by ID from a document
|
|
43
|
+
*/
|
|
44
|
+
getNode(doc_id: string, nodeId: string): Promise<DocumentNode | undefined>;
|
|
45
|
+
/**
|
|
46
|
+
* Get ancestors of a node (from root to target node)
|
|
47
|
+
*/
|
|
48
|
+
getAncestors(doc_id: string, nodeId: string): Promise<DocumentNode[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Upsert a single chunk vector entity
|
|
51
|
+
*/
|
|
52
|
+
upsertChunk(chunk: InsertChunkVectorEntity): Promise<ChunkVectorEntity>;
|
|
53
|
+
/**
|
|
54
|
+
* Upsert multiple chunk vector entities
|
|
55
|
+
*/
|
|
56
|
+
upsertChunksBulk(chunks: InsertChunkVectorEntity[]): Promise<ChunkVectorEntity[]>;
|
|
57
|
+
/**
|
|
58
|
+
* Delete all chunks for a specific document
|
|
59
|
+
*/
|
|
60
|
+
deleteChunksForDocument(doc_id: string): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Get all chunks for a specific document
|
|
63
|
+
*/
|
|
64
|
+
getChunksForDocument(doc_id: string): Promise<ChunkVectorEntity[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Search for similar chunks using vector similarity
|
|
67
|
+
*/
|
|
68
|
+
similaritySearch(query: TypedArray, options?: VectorSearchOptions<ChunkRecord>): Promise<ChunkSearchResult[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Hybrid search combining vector similarity and full-text search
|
|
71
|
+
*/
|
|
72
|
+
hybridSearch(query: TypedArray, options: HybridSearchOptions<ChunkRecord>): Promise<ChunkSearchResult[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Prepare a document for re-indexing: deletes all chunks but keeps the document.
|
|
75
|
+
* @returns The document if found, undefined otherwise
|
|
76
|
+
*/
|
|
77
|
+
prepareReindex(doc_id: string): Promise<Document | undefined>;
|
|
78
|
+
/**
|
|
79
|
+
* Setup the underlying databases
|
|
80
|
+
*/
|
|
81
|
+
setupDatabase(): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Destroy storage instances
|
|
84
|
+
*/
|
|
85
|
+
destroy(): void;
|
|
86
|
+
/**
|
|
87
|
+
* Get a chunk by ID
|
|
88
|
+
*/
|
|
89
|
+
getChunk(chunk_id: string): Promise<ChunkVectorEntity | undefined>;
|
|
90
|
+
/**
|
|
91
|
+
* Store a single chunk (alias for upsertChunk)
|
|
92
|
+
*/
|
|
93
|
+
put(chunk: InsertChunkVectorEntity): Promise<ChunkVectorEntity>;
|
|
94
|
+
/**
|
|
95
|
+
* Store multiple chunks (alias for upsertChunksBulk)
|
|
96
|
+
*/
|
|
97
|
+
putBulk(chunks: InsertChunkVectorEntity[]): Promise<ChunkVectorEntity[]>;
|
|
98
|
+
/**
|
|
99
|
+
* Get all chunks
|
|
100
|
+
*/
|
|
101
|
+
getAllChunks(): Promise<ChunkVectorEntity[] | undefined>;
|
|
102
|
+
/**
|
|
103
|
+
* Get chunk count
|
|
104
|
+
*/
|
|
105
|
+
chunkCount(): Promise<number>;
|
|
106
|
+
/**
|
|
107
|
+
* Clear all chunks
|
|
108
|
+
*/
|
|
109
|
+
clearChunks(): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Get vector dimensions
|
|
112
|
+
*/
|
|
113
|
+
getVectorDimensions(): number;
|
|
114
|
+
/**
|
|
115
|
+
* Get chunks from the document JSON (not from vector storage)
|
|
116
|
+
*/
|
|
117
|
+
getDocumentChunks(doc_id: string): Promise<ChunkRecord[]>;
|
|
118
|
+
/**
|
|
119
|
+
* Find chunks in document JSON that contain a specific nodeId in their path
|
|
120
|
+
*/
|
|
121
|
+
findChunksByNodeId(doc_id: string, nodeId: string): Promise<ChunkRecord[]>;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=KnowledgeBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KnowledgeBase.d.ts","sourceRoot":"","sources":["../../src/knowledge-base/KnowledgeBase.ts"],"names":[],"mappings":"AAAA;;;;GAIG;A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AEG;IACG,YAAY,IAAI,OAAO,CAAC,iBAAiB,EAAE,GAAG,SAAS,CAAC;IAI9D;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAInC;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAIlC;;OAEG;IACH,mBAAmB,IAAI,MAAM;IAQ7B;;OAEG;IACG,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAQ/D;;OAEG;IACG,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;CAOjF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { KnowledgeBase } from "./KnowledgeBase";
|
|
7
|
+
import { KnowledgeBaseRepository } from "./KnowledgeBaseRepository";
|
|
8
|
+
/**
|
|
9
|
+
* Service token for the knowledge base registry
|
|
10
|
+
* Maps knowledge base IDs to KnowledgeBase instances
|
|
11
|
+
*/
|
|
12
|
+
export declare const KNOWLEDGE_BASES: import("@workglow/util").ServiceToken<Map<string, KnowledgeBase>>;
|
|
13
|
+
/**
|
|
14
|
+
* Service token for the knowledge base repository
|
|
15
|
+
*/
|
|
16
|
+
export declare const KNOWLEDGE_BASE_REPOSITORY: import("@workglow/util").ServiceToken<KnowledgeBaseRepository>;
|
|
17
|
+
/**
|
|
18
|
+
* Gets the global knowledge base registry
|
|
19
|
+
*/
|
|
20
|
+
export declare function getGlobalKnowledgeBases(): Map<string, KnowledgeBase>;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the global knowledge base repository instance
|
|
23
|
+
*/
|
|
24
|
+
export declare function getGlobalKnowledgeBaseRepository(): KnowledgeBaseRepository;
|
|
25
|
+
/**
|
|
26
|
+
* Sets the global knowledge base repository instance
|
|
27
|
+
*/
|
|
28
|
+
export declare function setGlobalKnowledgeBaseRepository(repository: KnowledgeBaseRepository): void;
|
|
29
|
+
/**
|
|
30
|
+
* Registers a knowledge base globally by ID.
|
|
31
|
+
* Adds to both the live Map and the persistent repository.
|
|
32
|
+
*/
|
|
33
|
+
export declare function registerKnowledgeBase(id: string, kb: KnowledgeBase): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Gets a knowledge base by ID from the global registry
|
|
36
|
+
*/
|
|
37
|
+
export declare function getKnowledgeBase(id: string): KnowledgeBase | undefined;
|
|
38
|
+
//# sourceMappingURL=KnowledgeBaseRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KnowledgeBaseRegistry.d.ts","sourceRoot":"","sources":["../../src/knowledge-base/KnowledgeBaseRegistry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAGpE;;;GAGG;AACH,eAAO,MAAM,eAAe,mEAC+C,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,yBAAyB,gEACoC,CAAC;AAoB3E;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAEpE;AAED;;GAEG;AACH,wBAAgB,gCAAgC,IAAI,uBAAuB,CAE1E;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAAC,UAAU,EAAE,uBAAuB,GAAG,IAAI,CAE1F;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBxF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAEtE"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { type BaseTabularStorage } from "@workglow/storage";
|
|
7
|
+
import { EventEmitter, type EventParameters } from "@workglow/util";
|
|
8
|
+
import { KnowledgeBasePrimaryKeyNames, type KnowledgeBaseRecord, KnowledgeBaseRecordSchema } from "./KnowledgeBaseSchema";
|
|
9
|
+
/**
|
|
10
|
+
* Events that can be emitted by the KnowledgeBaseRepository
|
|
11
|
+
*/
|
|
12
|
+
export type KnowledgeBaseEventListeners = {
|
|
13
|
+
knowledge_base_added: (record: KnowledgeBaseRecord) => void;
|
|
14
|
+
knowledge_base_removed: (record: KnowledgeBaseRecord) => void;
|
|
15
|
+
knowledge_base_updated: (record: KnowledgeBaseRecord) => void;
|
|
16
|
+
};
|
|
17
|
+
export type KnowledgeBaseEvents = keyof KnowledgeBaseEventListeners;
|
|
18
|
+
export type KnowledgeBaseEventListener<Event extends KnowledgeBaseEvents> = KnowledgeBaseEventListeners[Event];
|
|
19
|
+
export type KnowledgeBaseEventParameters<Event extends KnowledgeBaseEvents> = EventParameters<KnowledgeBaseEventListeners, Event>;
|
|
20
|
+
/**
|
|
21
|
+
* Repository for persisting KnowledgeBase metadata to tabular storage.
|
|
22
|
+
* Follows the same pattern as ModelRepository.
|
|
23
|
+
*/
|
|
24
|
+
export declare class KnowledgeBaseRepository {
|
|
25
|
+
/**
|
|
26
|
+
* Storage for KnowledgeBase records
|
|
27
|
+
*/
|
|
28
|
+
protected readonly storage: BaseTabularStorage<typeof KnowledgeBaseRecordSchema, typeof KnowledgeBasePrimaryKeyNames>;
|
|
29
|
+
constructor(storage: BaseTabularStorage<typeof KnowledgeBaseRecordSchema, typeof KnowledgeBasePrimaryKeyNames>);
|
|
30
|
+
/** Event emitter for repository events */
|
|
31
|
+
protected events: EventEmitter<KnowledgeBaseEventListeners>;
|
|
32
|
+
/**
|
|
33
|
+
* Sets up the database for the repository.
|
|
34
|
+
* Must be called before using any other methods.
|
|
35
|
+
*/
|
|
36
|
+
setupDatabase(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Registers an event listener for the specified event
|
|
39
|
+
*/
|
|
40
|
+
on<Event extends KnowledgeBaseEvents>(name: Event, fn: KnowledgeBaseEventListener<Event>): void;
|
|
41
|
+
/**
|
|
42
|
+
* Removes an event listener for the specified event
|
|
43
|
+
*/
|
|
44
|
+
off<Event extends KnowledgeBaseEvents>(name: Event, fn: KnowledgeBaseEventListener<Event>): void;
|
|
45
|
+
/**
|
|
46
|
+
* Adds an event listener that will only be called once
|
|
47
|
+
*/
|
|
48
|
+
once<Event extends KnowledgeBaseEvents>(name: Event, fn: KnowledgeBaseEventListener<Event>): void;
|
|
49
|
+
/**
|
|
50
|
+
* Returns when the event was emitted (promise form of once)
|
|
51
|
+
*/
|
|
52
|
+
waitOn<Event extends KnowledgeBaseEvents>(name: Event): Promise<import("@workglow/util").EmittedReturnType<KnowledgeBaseEventListeners, Event>>;
|
|
53
|
+
/**
|
|
54
|
+
* Adds a new knowledge base record to the repository
|
|
55
|
+
*/
|
|
56
|
+
addKnowledgeBase(record: KnowledgeBaseRecord): Promise<KnowledgeBaseRecord>;
|
|
57
|
+
/**
|
|
58
|
+
* Removes a knowledge base record from the repository
|
|
59
|
+
*/
|
|
60
|
+
removeKnowledgeBase(kb_id: string): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves a knowledge base record by ID
|
|
63
|
+
*/
|
|
64
|
+
getKnowledgeBase(kb_id: string): Promise<KnowledgeBaseRecord | undefined>;
|
|
65
|
+
/**
|
|
66
|
+
* Enumerates all knowledge base records
|
|
67
|
+
*/
|
|
68
|
+
enumerateAll(): Promise<KnowledgeBaseRecord[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Gets the total number of knowledge base records
|
|
71
|
+
*/
|
|
72
|
+
size(): Promise<number>;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=KnowledgeBaseRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KnowledgeBaseRepository.d.ts","sourceRoot":"","sources":["../../src/knowledge-base/KnowledgeBaseRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEpE,OAAO,EACL,4BAA4B,EAC5B,KAAK,mBAAmB,EACxB,yBAAyB,EAC1B,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AAEH,MAAM,MAAM,2BAA2B,GAAG;IACxC,oBAAoB,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC5D,sBAAsB,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC9D,sBAAsB,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;CAC/D,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,MAAM,2BAA2B,CAAC;AAEpE,MAAM,MAAM,0BAA0B,CAAC,KAAK,SAAS,mBAAmB,IACtE,2BAA2B,CAAC,KAAK,CAAC,CAAC;AAErC,MAAM,MAAM,4BAA4B,CAAC,KAAK,SAAS,mBAAmB,IAAI,eAAe,CAC3F,2BAA2B,EAC3B,KAAK,CACN,CAAC;AAEF;;;GAGG;AACH,qBAAa,uBAAuB;IAClC;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAC5C,OAAO,yBAAyB,EAChC,OAAO,4BAA4B,CACpC,CAAC;gBAGA,OAAO,EAAE,kBAAkB,CACzB,OAAO,yBAAyB,EAChC,OAAO,4BAA4B,CACpC;IAKH,0CAA0C;IAC1C,SAAS,CAAC,MAAM,4CAAmD;IAEnE;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAIpC;;OAEG;IACH,EAAE,CAAC,KAAK,SAAS,mBAAmB,EAClC,IAAI,EAAE,KAAK,EACX,EAAE,EAAE,0BAA0B,CAAC,KAAK,CAAC;IAKvC;;OAEG;IACH,GAAG,CAAC,KAAK,SAAS,mBAAmB,EACnC,IAAI,EAAE,KAAK,EACX,EAAE,EAAE,0BAA0B,CAAC,KAAK,CAAC;IAKvC;;OAEG;IACH,IAAI,CAAC,KAAK,SAAS,mBAAmB,EACpC,IAAI,EAAE,KAAK,EACX,EAAE,EAAE,0BAA0B,CAAC,KAAK,CAAC;IAKvC;;OAEG;IACH,MAAM,CAAC,KAAK,SAAS,mBAAmB,EAAE,IAAI,EAAE,KAAK;IAIrD;;OAEG;IACG,gBAAgB,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAMjF;;OAEG;IACG,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASvD;;OAEG;IACG,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC;IAM/E;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAMpD;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;CAG9B"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { FromSchema } from "@workglow/util";
|
|
7
|
+
/**
|
|
8
|
+
* Schema for persisting KnowledgeBase metadata to tabular storage.
|
|
9
|
+
*/
|
|
10
|
+
export declare const KnowledgeBaseRecordSchema: {
|
|
11
|
+
readonly type: "object";
|
|
12
|
+
readonly properties: {
|
|
13
|
+
readonly kb_id: {
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
};
|
|
16
|
+
readonly title: {
|
|
17
|
+
readonly type: "string";
|
|
18
|
+
};
|
|
19
|
+
readonly description: {
|
|
20
|
+
readonly type: "string";
|
|
21
|
+
};
|
|
22
|
+
readonly vector_dimensions: {
|
|
23
|
+
readonly type: "integer";
|
|
24
|
+
};
|
|
25
|
+
readonly document_table: {
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
};
|
|
28
|
+
readonly chunk_table: {
|
|
29
|
+
readonly type: "string";
|
|
30
|
+
};
|
|
31
|
+
readonly created_at: {
|
|
32
|
+
readonly type: "string";
|
|
33
|
+
};
|
|
34
|
+
readonly updated_at: {
|
|
35
|
+
readonly type: "string";
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
readonly required: readonly ["kb_id", "title", "description", "vector_dimensions", "document_table", "chunk_table", "created_at", "updated_at"];
|
|
39
|
+
readonly additionalProperties: false;
|
|
40
|
+
};
|
|
41
|
+
export type KnowledgeBaseRecord = FromSchema<typeof KnowledgeBaseRecordSchema>;
|
|
42
|
+
export declare const KnowledgeBasePrimaryKeyNames: readonly ["kb_id"];
|
|
43
|
+
/**
|
|
44
|
+
* Generates SQL-safe table names for a knowledge base's document and chunk storage.
|
|
45
|
+
*/
|
|
46
|
+
export declare function knowledgeBaseTableNames(kbId: string): {
|
|
47
|
+
readonly documentTable: string;
|
|
48
|
+
readonly chunkTable: string;
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=KnowledgeBaseSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KnowledgeBaseSchema.d.ts","sourceRoot":"","sources":["../../src/knowledge-base/KnowledgeBaseSchema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAwB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEvE;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuBG,CAAC;AAE1C,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC/E,eAAO,MAAM,4BAA4B,oBAAqB,CAAC;AAE/D;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG;IACrD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,CAMA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { TypedArray } from "@workglow/util";
|
|
7
|
+
import { KnowledgeBase } from "./KnowledgeBase";
|
|
8
|
+
export interface CreateKnowledgeBaseOptions {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly vectorDimensions: number;
|
|
11
|
+
readonly vectorType?: {
|
|
12
|
+
new (array: number[]): TypedArray;
|
|
13
|
+
};
|
|
14
|
+
readonly register?: boolean;
|
|
15
|
+
readonly title?: string;
|
|
16
|
+
readonly description?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Factory function to create a KnowledgeBase with minimal configuration.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const kb = await createKnowledgeBase({
|
|
24
|
+
* name: "my-kb",
|
|
25
|
+
* vectorDimensions: 1024,
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function createKnowledgeBase(options: CreateKnowledgeBaseOptions): Promise<KnowledgeBase>;
|
|
30
|
+
//# sourceMappingURL=createKnowledgeBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createKnowledgeBase.d.ts","sourceRoot":"","sources":["../../src/knowledge-base/createKnowledgeBase.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAKjD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,UAAU,CAAC,EAAE;QAAE,KAAK,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,CAAA;KAAE,CAAC;IAC5D,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,aAAa,CAAC,CAsCxB"}
|