openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
21 lines (20 loc) • 758 B
JavaScript
import { serialize } from "node:v8";
import { readRegularFile } from "@openclaw/fs-safe/advanced";
//#region src/agents/sessions/tools/read-file.worker.ts
let result;
try {
const e = process.argv[2];
if (!e) throw new Error("File read requires a path");
if (process.argv[3] === "page") {
const { captureReadFilePage: t } = await import("../../../read-file-page-czYlPPYr.mjs");
result = await t(e, JSON.parse(process.argv[4]));
} else result = { buffer: (await readRegularFile({ filePath: e })).buffer };
} catch (e) {
result = {
error: e instanceof Error ? e : new Error(String(e)),
...e instanceof Error && "code" in e && typeof e.code === "string" ? { code: e.code } : {}
};
}
process.stdout.write(serialize(result));
//#endregion
export {};