@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
77 lines • 3.35 kB
JavaScript
// ========= 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 { QdrantAccessor } from "../../accessor/qdrant.js";
import { filesContaining } from "../../core/qdrant/search.js";
import { read, readdir, SEARCH, stat } from "../../core/qdrant/tree.js";
import { VFSName } from "../../types.js";
import { BaseVFS } from "../base.js";
import { redactQdrantConfig, resolveQdrantConfig } from "./config.js";
export const VFS_MD = `- A Qdrant vector database, exposed as a filesystem.
- At the root each directory is a collection, unless config pins a
single collection.
- Inside a collection, directories are the configured group-by payload
fields; descending one narrows a filter.
- Each matching point appears as files named by its Qdrant point id:
\`<id>.json\` (the full payload), \`<id>.txt\` (the embedded source text)
when a text field is configured, and \`<id>.<ext>\` (raw blob bytes)
when a blob field is configured. The embedding vector is never shown.
- \`ls\`, \`cd\`, \`cat\`, \`tree\`, \`find\`, \`wc\`, \`grep\` and \`rg\` work as
usual.`;
export class QdrantVFS extends BaseVFS {
name = VFSName.QDRANT;
// readdir seeds exact rendered sizes from the scroll payloads and stat
// falls back to rendering the row itself, so sizes are exact either way.
sizesAlwaysKnown = true;
supportsSnapshot = false;
vfsMd = VFS_MD;
config;
accessor;
constructor(options) {
super();
const config = 'config' in options ? options.config : options;
this.config = resolveQdrantConfig(config);
this.accessor = new QdrantAccessor(this.config);
}
getState() {
return {
type: this.name,
config: redactQdrantConfig(this.config),
// TypeScript cannot rebuild a config-backed mount from state:
// `buildMountArgs` substitutes a RAMVFS for anything it was
// not handed. Saying so out loud turns a silently empty mount
// into a refusal to load. Python rebuilds via its registry, so it
// writes this on only four mounts and reads it nowhere.
needs_override: true,
};
}
readdir(path) {
return readdir(this.accessor, path);
}
async read(path) {
return read(this.accessor, path);
}
stat(path) {
return stat(this.accessor, path);
}
filesContaining(path, text, _opts) {
return filesContaining(readdir, this.accessor, text, [path]);
}
search(path, query) {
return SEARCH.search(this.accessor, path, query);
}
searchMany(paths, query) {
return SEARCH.searchMany(this.accessor, paths, query);
}
}
//# sourceMappingURL=qdrant.js.map