UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

84 lines • 2.84 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 { BinAccessor } from "../../accessor/bin.js"; import { read as binRead } from "../../core/bin/read.js"; import { readdir as binReaddir } from "../../core/bin/readdir.js"; import { refuse } from "../../core/bin/refuse.js"; import { stat as binStat } from "../../core/bin/stat.js"; import { VFSName } from "../../types.js"; import { BaseVFS } from "../base.js"; import {} from "../types.js"; /** * Read-only view VFS backing the /usr/bin mount. Lists one executable * file per program, rendered from the workspace's command lookup on every * call; holds no storage of its own. */ export class BinViewVFS extends BaseVFS { name = VFSName.BIN; cachesReads = false; // A stub's size is its rendering: cheap, no network, never null. sizesAlwaysKnown = true; accessor; constructor(programs, note) { super(); this.accessor = new BinAccessor(programs, note); } readdir(path) { return binReaddir(this.accessor, path); } async read(path) { return binRead(this.accessor, path); } stat(path) { return binStat(this.accessor, path); } // Every write is its own refusal instead of a missing function, which // would answer "Operation not supported" where a read-only directory says // EROFS. write(path) { return refuse(this.accessor, path); } append(path) { return refuse(this.accessor, path); } pwrite(path) { return refuse(this.accessor, path); } create(path) { return refuse(this.accessor, path); } mkdir(path) { return refuse(this.accessor, path); } unlink(path) { return refuse(this.accessor, path); } rmdir(path) { return refuse(this.accessor, path); } rename(src) { return refuse(this.accessor, src); } truncate(path) { return refuse(this.accessor, path); } setattr(path, _fields) { return refuse(this.accessor, path); } /** The view owns nothing, so its type alone rebuilds it. */ getState() { return { type: this.name }; } } //# sourceMappingURL=bin.js.map