@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
53 lines • 1.69 kB
JavaScript
import { Mem0Accessor } from "../../accessor/mem0.js";
import { readStream } from "../../core/mem0/read.js";
import { readdir } from "../../core/mem0/readdir.js";
import { searchMany } from "../../core/mem0/search.js";
import { stat } from "../../core/mem0/stat.js";
import {} from "../../io/types.js";
import { VFSName } from "../../types.js";
import { BaseVFS } from "../base.js";
import { Mem0Config } from "./config.js";
export const VFS_MD = `\`\`\`text
{prefix}
<memory-id>.json
\`\`\``;
export class Mem0VFS extends BaseVFS {
handed = {
read: ['entry'],
stat: ['entry'],
};
name = VFSName.MEM0;
cachesReads = true;
// readdir and stat store the rendered JSON's byte length and read
// serves those same bytes, so sizes are exact by construction.
sizesAlwaysKnown = true;
supportsSnapshot = false;
vfsMd = VFS_MD;
accessor;
config;
constructor(config) {
super();
this.config = config;
this.accessor = new Mem0Accessor(config);
}
readdir(path, handed) {
return readdir(this.accessor, path, null, null, handed?.limit);
}
// eslint-disable-next-line @typescript-eslint/require-await
async read(path, handed) {
return readStream(this.accessor, path, handed?.entry);
}
stat(path, handed) {
return stat(this.accessor, path, handed?.entry);
}
search(path, query) {
return searchMany(this.accessor, [path], query);
}
searchMany(paths, query) {
return searchMany(this.accessor, paths, query);
}
getState() {
return this.configState(Mem0Config, this.config);
}
}
//# sourceMappingURL=mem0.js.map