


























@@ -1,4 +1,6 @@
11import "./fs-safe-defaults.js";
2+import path from "node:path";
3+import { writeViaSiblingTempPath } from "@openclaw/fs-safe/advanced";
24import { root as fsSafeRoot, type ReadResult } from "@openclaw/fs-safe/root";
3546export { FsSafeError, type FsSafeErrorCode } from "@openclaw/fs-safe/errors";
@@ -45,11 +47,32 @@ export {
4547type WalkDirectoryResult,
4648} from "@openclaw/fs-safe/walk";
4749export { withTimeout } from "@openclaw/fs-safe/advanced";
48-export {
49-writeExternalFileWithinRoot,
50-type ExternalFileWriteOptions,
51-type ExternalFileWriteResult,
52-} from "@openclaw/fs-safe/output";
50+51+export type ExternalFileWriteOptions = {
52+rootDir: string;
53+path: string;
54+write: (tempPath: string) => Promise<void>;
55+fallbackFileName?: string;
56+tempPrefix?: string;
57+};
58+59+export type ExternalFileWriteResult = {
60+path: string;
61+};
62+63+export async function writeExternalFileWithinRoot(
64+options: ExternalFileWriteOptions,
65+): Promise<ExternalFileWriteResult> {
66+const targetPath = path.resolve(options.rootDir, options.path);
67+await writeViaSiblingTempPath({
68+rootDir: options.rootDir,
69+ targetPath,
70+writeTemp: options.write,
71+fallbackFileName: options.fallbackFileName,
72+tempPrefix: options.tempPrefix,
73+});
74+return { path: targetPath };
75+}
53765477/** @deprecated Use root(rootDir).read(relativePath, options). */
5578export async function readFileWithinRoot(params: {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。