UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

46 lines • 2.28 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 { relayWalkOf } from "../../../generic_bind/archive_io.js"; import { dispatchedReadTree } from "../../../generic_bind/files.js"; import { zipGeneric } from "../../zip_cmd.js"; import { crossOpts, flatScopes, statOp, streamOp } from "../utils.js"; import { Files } from "../../../../../workspace/files.js"; import { linkLocation, linkView, mountView, owedNames } from "../../../utils/links.js"; /** * Run a zip whose archive and operands span mounts. * * Pure wiring: the shared generic plans on dispatch-relayed calls, so * each operand is walked on the mount that owns it and the archive lands * on its own. The scan still stops at a mount nested under an operand, * exactly as it does when the whole line is on one mount. */ export async function runZip(scopes, flagKwargs, dispatch, // The symlinks and mount boundaries the scan merges into each walk. vfs) { const links = linkView(vfs); const tree = vfs === undefined ? undefined : dispatchedReadTree(dispatch, mountView(vfs), links === undefined ? null : (virtual) => linkLocation(links, virtual), true); const result = await zipGeneric(flatScopes(scopes), { ...crossOpts(flagKwargs), vfs: vfs ?? new Files(dispatch, null, null, { ledger: false }).servedBy(null), }, { stream: streamOp(dispatch), stat: statOp(dispatch), walk: relayWalkOf(dispatch, (dir) => owedNames(vfs, dir), 'zip', tree), }); return result ?? [null, new IOResult()]; } //# sourceMappingURL=zip_cmd.js.map