UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

58 lines (57 loc) • 1.62 kB
import { n as appendRegularFile } from "./fs-safe-BbWvmdVn.mjs"; import "./security-runtime-C-zE_Zy_.mjs"; import path from "node:path"; import fs from "node:fs/promises"; import os from "node:os"; //#region extensions/file-transfer/src/shared/audit.ts let auditDirPromise = null; async function ensureAuditDir() { auditDirPromise ??= (async () => { const e = path.join(os.homedir(), ".openclaw", "audit"); await fs.mkdir(e, { recursive: true, mode: 448 }); return e; })().catch((e) => { auditDirPromise = null; throw e; }); return auditDirPromise; } function auditFilePath(e) { return path.join(e, "file-transfer.jsonl"); } /** * Append an audit record. Best-effort — failures are logged through console capture and * never propagated to the caller (the caller's operation is the source of * truth, not the audit write). */ async function appendFileTransferAudit(e) { try { const t = await ensureAuditDir(); const n = `${JSON.stringify({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), ...e })}\n`; await appendRegularFile({ filePath: auditFilePath(t), content: n, rejectSymlinkParents: true }); } catch (e) { console.warn(`[file-transfer:audit] append failed: ${String(e)}`); } } //#endregion //#region extensions/file-transfer/src/shared/audit-context.ts /** Keep one transfer's identity and original start time across its decision records. */ function bindFileTransferAudit(e, t) { return (n) => appendFileTransferAudit({ ...e, ...n, durationMs: Date.now() - t }); } //#endregion export { appendFileTransferAudit as n, bindFileTransferAudit as t };