UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

32 lines • 1.48 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 { eisdir } from "../../errors/fs.js"; import { fileEntry } from "../hierarchy/probe.js"; import { joinLines } from "../slug_tree/read.js"; import { scalarString } from "../slug_tree/rows.js"; import { iterPageChunks, pageChunks } from "./client.js"; import { renderPage } from "./render.js"; function pageSlug(path, entry) { const slug = scalarString(fileEntry(path, entry).extra.slug); if (slug === null) throw eisdir(path.virtual); return slug; } export async function read(accessor, path, entry = null) { return renderPage(await pageChunks(accessor, pageSlug(path, entry))); } export async function* readStream(accessor, path, entry = null) { yield* joinLines(iterPageChunks(accessor, pageSlug(path, entry))); } //# sourceMappingURL=read.js.map