@soulcraft/brainy 3.9.1 → 3.10.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/README.md +64 -6
- package/dist/augmentations/KnowledgeAugmentation.d.ts +40 -0
- package/dist/augmentations/KnowledgeAugmentation.js +251 -0
- package/dist/augmentations/defaultAugmentations.d.ts +1 -0
- package/dist/augmentations/defaultAugmentations.js +5 -0
- package/dist/brainy.d.ts +11 -0
- package/dist/brainy.js +87 -1
- package/dist/embeddings/EmbeddingManager.js +14 -2
- package/dist/utils/mutex.d.ts +2 -0
- package/dist/utils/mutex.js +14 -3
- package/dist/vfs/ConceptSystem.d.ts +202 -0
- package/dist/vfs/ConceptSystem.js +598 -0
- package/dist/vfs/EntityManager.d.ts +75 -0
- package/dist/vfs/EntityManager.js +216 -0
- package/dist/vfs/EventRecorder.d.ts +83 -0
- package/dist/vfs/EventRecorder.js +292 -0
- package/dist/vfs/FSCompat.d.ts +85 -0
- package/dist/vfs/FSCompat.js +257 -0
- package/dist/vfs/GitBridge.d.ts +167 -0
- package/dist/vfs/GitBridge.js +537 -0
- package/dist/vfs/KnowledgeAugmentation.d.ts +104 -0
- package/dist/vfs/KnowledgeAugmentation.js +146 -0
- package/dist/vfs/KnowledgeLayer.d.ts +35 -0
- package/dist/vfs/KnowledgeLayer.js +443 -0
- package/dist/vfs/PathResolver.d.ts +96 -0
- package/dist/vfs/PathResolver.js +362 -0
- package/dist/vfs/PersistentEntitySystem.d.ts +163 -0
- package/dist/vfs/PersistentEntitySystem.js +525 -0
- package/dist/vfs/SemanticVersioning.d.ts +105 -0
- package/dist/vfs/SemanticVersioning.js +318 -0
- package/dist/vfs/VirtualFileSystem.d.ts +246 -0
- package/dist/vfs/VirtualFileSystem.js +1927 -0
- package/dist/vfs/importers/DirectoryImporter.d.ts +86 -0
- package/dist/vfs/importers/DirectoryImporter.js +298 -0
- package/dist/vfs/index.d.ts +19 -0
- package/dist/vfs/index.js +26 -0
- package/dist/vfs/streams/VFSReadStream.d.ts +19 -0
- package/dist/vfs/streams/VFSReadStream.js +54 -0
- package/dist/vfs/streams/VFSWriteStream.d.ts +21 -0
- package/dist/vfs/streams/VFSWriteStream.js +70 -0
- package/dist/vfs/types.d.ts +330 -0
- package/dist/vfs/types.js +46 -0
- package/package.json +1 -1
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Virtual Filesystem Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* REAL types for production VFS implementation
|
|
5
|
+
* No mocks, no stubs, actual working definitions
|
|
6
|
+
*/
|
|
7
|
+
import { Entity, Relation } from '../types/brainy.types.js';
|
|
8
|
+
import { VerbType } from '../types/graphTypes.js';
|
|
9
|
+
import { Vector } from '../coreTypes.js';
|
|
10
|
+
/**
|
|
11
|
+
* Todo item for task tracking
|
|
12
|
+
*/
|
|
13
|
+
export interface VFSTodo {
|
|
14
|
+
id: string;
|
|
15
|
+
task: string;
|
|
16
|
+
priority: 'low' | 'medium' | 'high';
|
|
17
|
+
status: 'pending' | 'in_progress' | 'completed';
|
|
18
|
+
assignee?: string;
|
|
19
|
+
due?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* VFS-specific metadata that extends entity metadata
|
|
23
|
+
* This is what makes a Brainy entity a "file" or "directory"
|
|
24
|
+
*/
|
|
25
|
+
export interface VFSMetadata {
|
|
26
|
+
path: string;
|
|
27
|
+
name: string;
|
|
28
|
+
parent?: string;
|
|
29
|
+
vfsType: 'file' | 'directory' | 'symlink';
|
|
30
|
+
size: number;
|
|
31
|
+
mimeType?: string;
|
|
32
|
+
extension?: string;
|
|
33
|
+
permissions: number;
|
|
34
|
+
owner: string;
|
|
35
|
+
group: string;
|
|
36
|
+
accessed: number;
|
|
37
|
+
modified: number;
|
|
38
|
+
storage?: {
|
|
39
|
+
type: 'inline' | 'reference' | 'chunked';
|
|
40
|
+
key?: string;
|
|
41
|
+
chunks?: string[];
|
|
42
|
+
compressed?: boolean;
|
|
43
|
+
};
|
|
44
|
+
attributes?: Record<string, any>;
|
|
45
|
+
rawData?: string;
|
|
46
|
+
tags?: string[];
|
|
47
|
+
concepts?: Array<{
|
|
48
|
+
name: string;
|
|
49
|
+
confidence: number;
|
|
50
|
+
}>;
|
|
51
|
+
todos?: VFSTodo[];
|
|
52
|
+
dependencies?: string[];
|
|
53
|
+
exports?: string[];
|
|
54
|
+
language?: string;
|
|
55
|
+
lineCount?: number;
|
|
56
|
+
wordCount?: number;
|
|
57
|
+
charset?: string;
|
|
58
|
+
hash?: string;
|
|
59
|
+
symlinkTarget?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Complete VFS Entity - a file or directory in the virtual filesystem
|
|
63
|
+
*/
|
|
64
|
+
export interface VFSEntity extends Entity<VFSMetadata> {
|
|
65
|
+
metadata: VFSMetadata;
|
|
66
|
+
data?: Buffer | Uint8Array | string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* File stat information (Node.js fs.Stats compatible)
|
|
70
|
+
*/
|
|
71
|
+
export interface VFSStats {
|
|
72
|
+
size: number;
|
|
73
|
+
mode: number;
|
|
74
|
+
uid: number;
|
|
75
|
+
gid: number;
|
|
76
|
+
atime: Date;
|
|
77
|
+
mtime: Date;
|
|
78
|
+
ctime: Date;
|
|
79
|
+
birthtime: Date;
|
|
80
|
+
isFile(): boolean;
|
|
81
|
+
isDirectory(): boolean;
|
|
82
|
+
isSymbolicLink(): boolean;
|
|
83
|
+
path: string;
|
|
84
|
+
entityId: string;
|
|
85
|
+
vector?: Vector;
|
|
86
|
+
connections?: number;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Directory entry (for readdir)
|
|
90
|
+
*/
|
|
91
|
+
export interface VFSDirent {
|
|
92
|
+
name: string;
|
|
93
|
+
path: string;
|
|
94
|
+
type: 'file' | 'directory' | 'symlink';
|
|
95
|
+
entityId: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Error codes matching Node.js fs errors
|
|
99
|
+
*/
|
|
100
|
+
export declare enum VFSErrorCode {
|
|
101
|
+
ENOENT = "ENOENT",// No such file or directory
|
|
102
|
+
EEXIST = "EEXIST",// File exists
|
|
103
|
+
ENOTDIR = "ENOTDIR",// Not a directory
|
|
104
|
+
EISDIR = "EISDIR",// Is a directory
|
|
105
|
+
ENOTEMPTY = "ENOTEMPTY",// Directory not empty
|
|
106
|
+
EACCES = "EACCES",// Permission denied
|
|
107
|
+
EINVAL = "EINVAL",// Invalid argument
|
|
108
|
+
EMFILE = "EMFILE",// Too many open files
|
|
109
|
+
ENOSPC = "ENOSPC",// No space left
|
|
110
|
+
EIO = "EIO",// I/O error
|
|
111
|
+
ELOOP = "ELOOP"
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* VFS-specific error class
|
|
115
|
+
*/
|
|
116
|
+
export declare class VFSError extends Error {
|
|
117
|
+
code: VFSErrorCode;
|
|
118
|
+
path?: string;
|
|
119
|
+
syscall?: string;
|
|
120
|
+
constructor(code: VFSErrorCode, message: string, path?: string, syscall?: string);
|
|
121
|
+
}
|
|
122
|
+
export interface WriteOptions {
|
|
123
|
+
encoding?: BufferEncoding;
|
|
124
|
+
mode?: number;
|
|
125
|
+
flag?: string;
|
|
126
|
+
generateEmbedding?: boolean;
|
|
127
|
+
extractMetadata?: boolean;
|
|
128
|
+
compress?: boolean;
|
|
129
|
+
deduplicate?: boolean;
|
|
130
|
+
metadata?: Record<string, any>;
|
|
131
|
+
}
|
|
132
|
+
export interface ReadOptions {
|
|
133
|
+
encoding?: BufferEncoding;
|
|
134
|
+
flag?: string;
|
|
135
|
+
cache?: boolean;
|
|
136
|
+
decompress?: boolean;
|
|
137
|
+
}
|
|
138
|
+
export interface MkdirOptions {
|
|
139
|
+
recursive?: boolean;
|
|
140
|
+
mode?: number;
|
|
141
|
+
metadata?: Partial<VFSMetadata>;
|
|
142
|
+
}
|
|
143
|
+
export interface ReaddirOptions {
|
|
144
|
+
encoding?: BufferEncoding;
|
|
145
|
+
withFileTypes?: boolean;
|
|
146
|
+
recursive?: boolean;
|
|
147
|
+
limit?: number;
|
|
148
|
+
offset?: number;
|
|
149
|
+
cursor?: string;
|
|
150
|
+
filter?: {
|
|
151
|
+
pattern?: string;
|
|
152
|
+
type?: 'file' | 'directory';
|
|
153
|
+
minSize?: number;
|
|
154
|
+
maxSize?: number;
|
|
155
|
+
modifiedAfter?: Date;
|
|
156
|
+
modifiedBefore?: Date;
|
|
157
|
+
};
|
|
158
|
+
sort?: 'name' | 'size' | 'modified' | 'created';
|
|
159
|
+
order?: 'asc' | 'desc';
|
|
160
|
+
}
|
|
161
|
+
export interface CopyOptions {
|
|
162
|
+
overwrite?: boolean;
|
|
163
|
+
preserveTimestamps?: boolean;
|
|
164
|
+
preserveVector?: boolean;
|
|
165
|
+
preserveRelationships?: boolean;
|
|
166
|
+
deepCopy?: boolean;
|
|
167
|
+
}
|
|
168
|
+
export interface SearchOptions {
|
|
169
|
+
path?: string;
|
|
170
|
+
recursive?: boolean;
|
|
171
|
+
type?: 'file' | 'directory' | 'any';
|
|
172
|
+
where?: Record<string, any>;
|
|
173
|
+
limit?: number;
|
|
174
|
+
offset?: number;
|
|
175
|
+
includeContent?: boolean;
|
|
176
|
+
includeVector?: boolean;
|
|
177
|
+
explain?: boolean;
|
|
178
|
+
}
|
|
179
|
+
export interface SimilarOptions {
|
|
180
|
+
limit?: number;
|
|
181
|
+
threshold?: number;
|
|
182
|
+
type?: 'file' | 'directory' | 'any';
|
|
183
|
+
withinPath?: string;
|
|
184
|
+
}
|
|
185
|
+
export interface SearchResult {
|
|
186
|
+
path: string;
|
|
187
|
+
entityId: string;
|
|
188
|
+
score: number;
|
|
189
|
+
type: 'file' | 'directory' | 'symlink';
|
|
190
|
+
size: number;
|
|
191
|
+
modified: Date;
|
|
192
|
+
explanation?: {
|
|
193
|
+
vectorScore?: number;
|
|
194
|
+
metadataScore?: number;
|
|
195
|
+
graphScore?: number;
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
export interface RelatedOptions {
|
|
199
|
+
depth?: number;
|
|
200
|
+
types?: VerbType[];
|
|
201
|
+
limit?: number;
|
|
202
|
+
}
|
|
203
|
+
export interface ReadStreamOptions {
|
|
204
|
+
encoding?: BufferEncoding;
|
|
205
|
+
start?: number;
|
|
206
|
+
end?: number;
|
|
207
|
+
highWaterMark?: number;
|
|
208
|
+
}
|
|
209
|
+
export interface WriteStreamOptions {
|
|
210
|
+
encoding?: BufferEncoding;
|
|
211
|
+
mode?: number;
|
|
212
|
+
autoClose?: boolean;
|
|
213
|
+
emitClose?: boolean;
|
|
214
|
+
}
|
|
215
|
+
export interface WatchOptions {
|
|
216
|
+
persistent?: boolean;
|
|
217
|
+
recursive?: boolean;
|
|
218
|
+
encoding?: BufferEncoding;
|
|
219
|
+
}
|
|
220
|
+
export type WatchEventType = 'rename' | 'change' | 'error';
|
|
221
|
+
export interface WatchListener {
|
|
222
|
+
(eventType: WatchEventType, filename: string | null): void;
|
|
223
|
+
}
|
|
224
|
+
export interface VFSConfig {
|
|
225
|
+
root?: string;
|
|
226
|
+
rootEntityId?: string;
|
|
227
|
+
cache?: {
|
|
228
|
+
enabled?: boolean;
|
|
229
|
+
maxPaths?: number;
|
|
230
|
+
maxContent?: number;
|
|
231
|
+
ttl?: number;
|
|
232
|
+
};
|
|
233
|
+
storage?: {
|
|
234
|
+
inline?: {
|
|
235
|
+
maxSize?: number;
|
|
236
|
+
};
|
|
237
|
+
chunking?: {
|
|
238
|
+
enabled?: boolean;
|
|
239
|
+
chunkSize?: number;
|
|
240
|
+
parallel?: number;
|
|
241
|
+
};
|
|
242
|
+
compression?: {
|
|
243
|
+
enabled?: boolean;
|
|
244
|
+
minSize?: number;
|
|
245
|
+
algorithm?: 'gzip' | 'brotli' | 'zstd';
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
intelligence?: {
|
|
249
|
+
enabled?: boolean;
|
|
250
|
+
autoEmbed?: boolean;
|
|
251
|
+
autoExtract?: boolean;
|
|
252
|
+
autoTag?: boolean;
|
|
253
|
+
autoConcepts?: boolean;
|
|
254
|
+
};
|
|
255
|
+
knowledgeLayer?: {
|
|
256
|
+
enabled?: boolean;
|
|
257
|
+
eventRecording?: boolean;
|
|
258
|
+
semanticVersioning?: boolean;
|
|
259
|
+
persistentEntities?: boolean;
|
|
260
|
+
concepts?: boolean;
|
|
261
|
+
gitBridge?: boolean;
|
|
262
|
+
};
|
|
263
|
+
permissions?: {
|
|
264
|
+
defaultFile?: number;
|
|
265
|
+
defaultDirectory?: number;
|
|
266
|
+
umask?: number;
|
|
267
|
+
};
|
|
268
|
+
limits?: {
|
|
269
|
+
maxFileSize?: number;
|
|
270
|
+
maxPathLength?: number;
|
|
271
|
+
maxDirectoryEntries?: number;
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
export interface IVirtualFileSystem {
|
|
275
|
+
init(config?: VFSConfig): Promise<void>;
|
|
276
|
+
close(): Promise<void>;
|
|
277
|
+
readFile(path: string, options?: ReadOptions): Promise<Buffer>;
|
|
278
|
+
writeFile(path: string, data: Buffer | string, options?: WriteOptions): Promise<void>;
|
|
279
|
+
appendFile(path: string, data: Buffer | string, options?: WriteOptions): Promise<void>;
|
|
280
|
+
unlink(path: string): Promise<void>;
|
|
281
|
+
mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
|
282
|
+
rmdir(path: string, options?: {
|
|
283
|
+
recursive?: boolean;
|
|
284
|
+
}): Promise<void>;
|
|
285
|
+
readdir(path: string, options?: ReaddirOptions): Promise<string[] | VFSDirent[]>;
|
|
286
|
+
stat(path: string): Promise<VFSStats>;
|
|
287
|
+
lstat(path: string): Promise<VFSStats>;
|
|
288
|
+
exists(path: string): Promise<boolean>;
|
|
289
|
+
chmod(path: string, mode: number): Promise<void>;
|
|
290
|
+
chown(path: string, uid: number, gid: number): Promise<void>;
|
|
291
|
+
utimes(path: string, atime: Date, mtime: Date): Promise<void>;
|
|
292
|
+
rename(oldPath: string, newPath: string): Promise<void>;
|
|
293
|
+
copy(src: string, dest: string, options?: CopyOptions): Promise<void>;
|
|
294
|
+
move(src: string, dest: string): Promise<void>;
|
|
295
|
+
symlink(target: string, path: string): Promise<void>;
|
|
296
|
+
readlink(path: string): Promise<string>;
|
|
297
|
+
realpath(path: string): Promise<string>;
|
|
298
|
+
getxattr(path: string, name: string): Promise<any>;
|
|
299
|
+
setxattr(path: string, name: string, value: any): Promise<void>;
|
|
300
|
+
listxattr(path: string): Promise<string[]>;
|
|
301
|
+
removexattr(path: string, name: string): Promise<void>;
|
|
302
|
+
search(query: string, options?: SearchOptions): Promise<SearchResult[]>;
|
|
303
|
+
findSimilar(path: string, options?: SimilarOptions): Promise<SearchResult[]>;
|
|
304
|
+
getRelated(path: string, options?: RelatedOptions): Promise<Array<{
|
|
305
|
+
path: string;
|
|
306
|
+
relationship: string;
|
|
307
|
+
direction: 'from' | 'to';
|
|
308
|
+
}>>;
|
|
309
|
+
addRelationship(from: string, to: string, type: string): Promise<void>;
|
|
310
|
+
removeRelationship(from: string, to: string, type?: string): Promise<void>;
|
|
311
|
+
getRelationships(path: string): Promise<Relation[]>;
|
|
312
|
+
getTodos(path: string): Promise<VFSTodo[] | undefined>;
|
|
313
|
+
setTodos(path: string, todos: VFSTodo[]): Promise<void>;
|
|
314
|
+
addTodo(path: string, todo: VFSTodo): Promise<void>;
|
|
315
|
+
getMetadata(path: string): Promise<VFSMetadata | undefined>;
|
|
316
|
+
setMetadata(path: string, metadata: Partial<VFSMetadata>): Promise<void>;
|
|
317
|
+
createReadStream(path: string, options?: ReadStreamOptions): NodeJS.ReadableStream;
|
|
318
|
+
createWriteStream(path: string, options?: WriteStreamOptions): NodeJS.WritableStream;
|
|
319
|
+
watch(path: string, listener: WatchListener): {
|
|
320
|
+
close(): void;
|
|
321
|
+
};
|
|
322
|
+
watchFile(path: string, listener: WatchListener): void;
|
|
323
|
+
unwatchFile(path: string): void;
|
|
324
|
+
getEntity(path: string): Promise<VFSEntity>;
|
|
325
|
+
getEntityById(id: string): Promise<VFSEntity>;
|
|
326
|
+
resolvePath(path: string, from?: string): Promise<string>;
|
|
327
|
+
}
|
|
328
|
+
export declare function isFile(stats: VFSStats): boolean;
|
|
329
|
+
export declare function isDirectory(stats: VFSStats): boolean;
|
|
330
|
+
export declare function isSymlink(stats: VFSStats): boolean;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Virtual Filesystem Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* REAL types for production VFS implementation
|
|
5
|
+
* No mocks, no stubs, actual working definitions
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Error codes matching Node.js fs errors
|
|
9
|
+
*/
|
|
10
|
+
export var VFSErrorCode;
|
|
11
|
+
(function (VFSErrorCode) {
|
|
12
|
+
VFSErrorCode["ENOENT"] = "ENOENT";
|
|
13
|
+
VFSErrorCode["EEXIST"] = "EEXIST";
|
|
14
|
+
VFSErrorCode["ENOTDIR"] = "ENOTDIR";
|
|
15
|
+
VFSErrorCode["EISDIR"] = "EISDIR";
|
|
16
|
+
VFSErrorCode["ENOTEMPTY"] = "ENOTEMPTY";
|
|
17
|
+
VFSErrorCode["EACCES"] = "EACCES";
|
|
18
|
+
VFSErrorCode["EINVAL"] = "EINVAL";
|
|
19
|
+
VFSErrorCode["EMFILE"] = "EMFILE";
|
|
20
|
+
VFSErrorCode["ENOSPC"] = "ENOSPC";
|
|
21
|
+
VFSErrorCode["EIO"] = "EIO";
|
|
22
|
+
VFSErrorCode["ELOOP"] = "ELOOP"; // Too many symbolic links
|
|
23
|
+
})(VFSErrorCode || (VFSErrorCode = {}));
|
|
24
|
+
/**
|
|
25
|
+
* VFS-specific error class
|
|
26
|
+
*/
|
|
27
|
+
export class VFSError extends Error {
|
|
28
|
+
constructor(code, message, path, syscall) {
|
|
29
|
+
super(message);
|
|
30
|
+
this.name = 'VFSError';
|
|
31
|
+
this.code = code;
|
|
32
|
+
this.path = path;
|
|
33
|
+
this.syscall = syscall;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Export utility type guards
|
|
37
|
+
export function isFile(stats) {
|
|
38
|
+
return stats.isFile();
|
|
39
|
+
}
|
|
40
|
+
export function isDirectory(stats) {
|
|
41
|
+
return stats.isDirectory();
|
|
42
|
+
}
|
|
43
|
+
export function isSymlink(stats) {
|
|
44
|
+
return stats.isSymbolicLink();
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=types.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.0",
|
|
4
4
|
"description": "Universal Knowledge Protocol™ - World's first Triple Intelligence database unifying vector, graph, and document search in one API. 31 nouns × 40 verbs for infinite expressiveness.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|