UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

70 lines (69 loc) • 2.88 kB
// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. ========= // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // ========= Copyright 2026 @ Strukto.AI All Rights Reserved. ========= import { streamAny as mongodbStream } from "../../core/mongodb/read.js"; import { readdir as mongodbReaddir } from "../../core/mongodb/readdir.js"; import { linesContaining as mongodbLinesContaining } from "../../core/mongodb/search.js"; import { stat as mongodbStat } from "../../core/mongodb/stat.js"; import { follow as mongodbFollow, lastLines as mongodbLastLines, lineCount as mongodbLineCount, } from "../../core/mongodb/stream.js"; import { BaseVFS } from "../base.js"; export const VFS_MD = `\`\`\`text {prefix} <database>/ database.json # collection and view names collections/<collection>/ schema.json # sampled field types, validator, indexes documents.jsonl # streamed BSON Extended JSON documents views/<view>/ schema.json documents.jsonl \`\`\` - Read \`database.json\` first to discover entities, and \`schema.json\` before reading a large document stream. - \`head\`, \`tail\`, \`wc\`, \`grep\`, \`rg\` and \`jq\` understand \`documents.jsonl\`; \`grep\` and \`rg\` fetch only the documents that may match. - An unknown size displays as \`-\`; \`wc -c\` measures bytes and \`wc -l\` counts documents on demand. These counts may scan the collection.`; /** * MongoDB's functions over its accessor, which the node and browser * packages build over their own transport. */ export class MongoDBVFS extends BaseVFS { handed = { stat: ['entry'], }; readdir(path) { return mongodbReaddir(this.accessor, path); } // eslint-disable-next-line @typescript-eslint/require-await async read(path) { return mongodbStream(this.accessor, path); } stat(path, handed) { return mongodbStat(this.accessor, path, handed?.entry); } linesContaining(path, text) { return mongodbLinesContaining(this.accessor, path, text); } lastLines(path, n) { return mongodbLastLines(this.accessor, path, n); } lineCount(path) { return mongodbLineCount(this.accessor, path); } follow(path, n, _interval) { return mongodbFollow(this.accessor, path, n); } } //# sourceMappingURL=mongodb.js.map