@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
55 lines • 2.3 kB
JavaScript
// ========= 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 { openStream } from "../../../rs/stream.js";
import { StreamRefusal } from "../../../rs/errors.js";
import { byteView } from "../../../shell/bytes.js";
import { command } from "../../config.js";
import { specOf } from "../../spec/builtins.js";
import { extraOperandError, missingOperandError } from "../../spec/usage.js";
import { UsageError } from "../../errors.js";
import { CommandName } from "../../spec/types.js";
import { FlagView } from "../../spec/flag_view.js";
import { streamOutput } from "../utils/stream.js";
async function seq(_accessor, _paths, texts, ctx) {
if (texts.length === 0)
throw missingOperandError(CommandName.SEQ, null);
if (texts.length > 3)
throw extraOperandError(CommandName.SEQ, texts[3] ?? '');
const fl = new FlagView(ctx.flags, specOf('seq'));
const typed = fl.asStr('format') ?? null;
const config = {
operands: texts.map((text) => byteView(text)),
format: typed === null ? null : byteView(typed),
equal_width: fl.asBool('equal_width'),
separator: byteView(fl.asStr('separator') ?? '\n'),
};
let engine;
try {
engine = await openStream('seq', config);
}
catch (err) {
if (err instanceof StreamRefusal)
throw new UsageError(err.message, 1);
throw err;
}
return [streamOutput(engine, new Uint8Array(0), ctx.signal), new IOResult()];
}
export const GENERAL_SEQ = command({
name: 'seq',
vfs: null,
spec: specOf('seq'),
fn: seq,
});
//# sourceMappingURL=seq.js.map