UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

56 lines • 2.26 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 { HistoryAccessor } from "../../accessor/history.js"; import { read as historyRead } from "../../core/history/read.js"; import { readdir as historyReaddir } from "../../core/history/readdir.js"; import { stat as historyStat } from "../../core/history/stat.js"; import { VFSName } from "../../types.js"; import { BaseVFS } from "../base.js"; import {} from "../types.js"; export const HISTORY_PREFIX = '/.bash_history'; /** * Read-only view VFS backing the /.bash_history mount. Renders GNU * views from the workspace's hidden recorder on every read; holds no * storage of its own. */ export class HistoryViewVFS extends BaseVFS { name = VFSName.HISTORY; cachesReads = false; // The view renders from in-memory events, so stat() sizes it by // rendering: cheap, no network, and never null. sizesAlwaysKnown = true; accessor; constructor(observer, session = null) { super(); this.accessor = new HistoryAccessor(observer, session); } /** The view one session reads: its own commands, whatever else is bound. */ forSession(session) { return new HistoryViewVFS(this.accessor.observer, session); } readdir(path) { return historyReaddir(this.accessor, path); } async read(path) { return historyRead(this.accessor, path); } stat(path) { return historyStat(this.accessor, path); } /** The view owns nothing, so its type alone rebuilds it. */ getState() { return { type: this.name }; } } //# sourceMappingURL=history.js.map