UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

33 lines • 1.91 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 { IOResult } from "../../../../../io/types.js"; import { teeGeneric } from "../../tee.js"; import { crossOpts, flatScopes, relayWrite, statOp, streamOp } from "../utils.js"; // Copy stdin to outputs on several mounts with one tee. One run sees every // output, so --output-error=exit checks that each can be opened before any // is written, as GNU opens them all first. Each output is written on the // mount that owns it, through the dispatcher, which also drops its cached // copy; -a goes through the append op, which a mount answers natively or by // rewriting the file. Mirrors Python's run_tee. export async function runTee(scopes, flagKwargs, dispatch, stdin, storageKey) { const write = (path, data) => relayWrite(dispatch, path, data); const append = async (path, data) => { await dispatch('append', path, [data]); }; const [out, io] = (await teeGeneric(flatScopes(scopes), [], { ...crossOpts(flagKwargs), stdin }, streamOp(dispatch), write, append, statOp(dispatch), storageKey)) ?? [null, new IOResult()]; // Relay writes are keyed by the dispatcher; keyed here they would be // prefixed onto one mount. return [out, io]; } //# sourceMappingURL=tee.js.map