UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

31 lines • 1.41 kB
import {} from 'zod'; import { specOf } from "../../../spec/builtins.js"; import { FlagView, specFlagNames } from "../../../spec/flag_view.js"; import { IOResult } from "../../../../io/types.js"; import { byteView } from "../../../../shell/bytes.js"; import { StreamHost, hostedStream } from "../../utils/stream_host.js"; import {} from "../adapter.js"; import { commandFiles, resolveOrEmpty } from "../files.js"; export const BUILDER = { name: 'od', read: true, fn: async (_accessor, paths, _texts, ctx) => { const files = commandFiles(ctx, paths); const resolved = await resolveOrEmpty(files, paths); // mirage-rs reads every option in the order typed, each value as typed, // and the operands, which an offset or a label may end. Mirrors the // Python builder. const spec = specOf('od'); const options = new FlagView(ctx.flags, spec) .occurrences(...specFlagNames(spec)) .map(([name, value]) => [name, typeof value === 'boolean' ? value : byteView(String(value))]); const config = { options, operands: resolved.map((path) => byteView(path.rawPath)), }; const host = new StreamHost(resolved, files.read, ctx, true, 'od'); const io = new IOResult(); return [hostedStream('od', config, host, io, ctx.signal), io]; }, }; //# sourceMappingURL=od.js.map