@openclaw/fs-safe 0.8.2 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +1 -1
- package/dist/advanced.d.ts +2 -2
- package/dist/advanced.d.ts.map +1 -1
- package/dist/advanced.js +2 -2
- package/dist/archive-kind.d.ts +1 -0
- package/dist/archive-kind.d.ts.map +1 -1
- package/dist/archive-kind.js +6 -0
- package/dist/archive-limits.d.ts +0 -1
- package/dist/archive-limits.d.ts.map +1 -1
- package/dist/archive-limits.js +0 -3
- package/dist/archive-native.d.ts.map +1 -1
- package/dist/archive-native.js +5 -8
- package/dist/archive-parser-errors.d.ts +2 -0
- package/dist/archive-parser-errors.d.ts.map +1 -0
- package/dist/archive-parser-errors.js +12 -0
- package/dist/archive-read.d.ts.map +1 -1
- package/dist/archive-read.js +7 -13
- package/dist/archive-tar-wasm.d.ts +1 -1
- package/dist/archive-tar-wasm.d.ts.map +1 -1
- package/dist/archive-tar-wasm.js +5 -8
- package/dist/archive.d.ts.map +1 -1
- package/dist/archive.js +43 -6
- package/dist/atomic.d.ts +1 -1
- package/dist/atomic.d.ts.map +1 -1
- package/dist/atomic.js +1 -1
- package/dist/bounded-read-stream.d.ts +1 -5
- package/dist/bounded-read-stream.d.ts.map +1 -1
- package/dist/bounded-read-stream.js +5 -13
- package/dist/byte-budget.d.ts +0 -1
- package/dist/byte-budget.d.ts.map +1 -1
- package/dist/byte-budget.js +1 -1
- package/dist/directory-mode-owner.d.ts.map +1 -1
- package/dist/directory-mode-owner.js +2 -0
- package/dist/error-detail.d.ts +1 -0
- package/dist/error-detail.d.ts.map +1 -1
- package/dist/error-detail.js +6 -0
- package/dist/file-store-boundary.d.ts +1 -1
- package/dist/file-store-boundary.d.ts.map +1 -1
- package/dist/file-store-boundary.js +2 -13
- package/dist/file-store.js +1 -1
- package/dist/file-sync.d.ts +5 -0
- package/dist/file-sync.d.ts.map +1 -0
- package/dist/file-sync.js +19 -0
- package/dist/guarded-mutation.d.ts +3 -0
- package/dist/guarded-mutation.d.ts.map +1 -1
- package/dist/guarded-mutation.js +5 -1
- package/dist/home-dir.d.ts +0 -10
- package/dist/home-dir.d.ts.map +1 -1
- package/dist/home-dir.js +0 -28
- package/dist/json-durable-queue-ownership.d.ts +1 -0
- package/dist/json-durable-queue-ownership.d.ts.map +1 -1
- package/dist/json-durable-queue-ownership.js +139 -18
- package/dist/json-durable-queue.d.ts.map +1 -1
- package/dist/json-durable-queue.js +5 -10
- package/dist/json-store.d.ts.map +1 -1
- package/dist/json-store.js +1 -1
- package/dist/local-roots.d.ts.map +1 -1
- package/dist/local-roots.js +2 -3
- package/dist/move-path-cleanup.d.ts +1 -1
- package/dist/move-path-cleanup.d.ts.map +1 -1
- package/dist/move-path-cleanup.js +4 -2
- package/dist/move-path.d.ts +9 -0
- package/dist/move-path.d.ts.map +1 -1
- package/dist/move-path.js +53 -16
- package/dist/native-operations.d.ts +0 -1
- package/dist/native-operations.d.ts.map +1 -1
- package/dist/native-operations.js +0 -10
- package/dist/native-pinned-write-windows.d.ts.map +1 -1
- package/dist/native-pinned-write-windows.js +5 -4
- package/dist/native-staged-file.d.ts +8 -1
- package/dist/native-staged-file.d.ts.map +1 -1
- package/dist/native-staged-file.js +30 -9
- package/dist/opened-realpath.d.ts +12 -1
- package/dist/opened-realpath.d.ts.map +1 -1
- package/dist/opened-realpath.js +8 -7
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +26 -2
- package/dist/path-policy.js +1 -1
- package/dist/permissions.d.ts +1 -0
- package/dist/permissions.d.ts.map +1 -1
- package/dist/permissions.js +3 -0
- package/dist/pinned-write.d.ts +1 -2
- package/dist/pinned-write.d.ts.map +1 -1
- package/dist/pinned-write.js +2 -11
- package/dist/private-temp-workspace.js +1 -1
- package/dist/publish-file.js +2 -2
- package/dist/replace-file-copy-source.d.ts.map +1 -1
- package/dist/replace-file-copy-source.js +2 -7
- package/dist/replace-file-descriptor.d.ts.map +1 -1
- package/dist/replace-file-descriptor.js +3 -16
- package/dist/replace-file-temp-owner.d.ts.map +1 -1
- package/dist/replace-file-temp-owner.js +2 -7
- package/dist/replace-file.d.ts.map +1 -1
- package/dist/replace-file.js +21 -8
- package/dist/root-errors.d.ts +1 -0
- package/dist/root-errors.d.ts.map +1 -1
- package/dist/root-errors.js +9 -0
- package/dist/root-file.d.ts.map +1 -1
- package/dist/root-file.js +17 -28
- package/dist/root-impl.d.ts.map +1 -1
- package/dist/root-impl.js +12 -33
- package/dist/root-path.d.ts.map +1 -1
- package/dist/root-path.js +49 -94
- package/dist/root-write-mode.d.ts +6 -0
- package/dist/root-write-mode.d.ts.map +1 -0
- package/dist/root-write-mode.js +60 -0
- package/dist/root-write-verification.js +2 -2
- package/dist/safe-path-segment.d.ts +1 -0
- package/dist/safe-path-segment.d.ts.map +1 -1
- package/dist/safe-path-segment.js +1 -1
- package/dist/secret-file.d.ts.map +1 -1
- package/dist/secret-file.js +2 -9
- package/dist/secret-read-async.d.ts.map +1 -1
- package/dist/secret-read-async.js +2 -10
- package/dist/secret-read-policy.d.ts +4 -0
- package/dist/secret-read-policy.d.ts.map +1 -1
- package/dist/secret-read-policy.js +12 -0
- package/dist/sibling-staged-file.d.ts.map +1 -1
- package/dist/sibling-staged-file.js +2 -7
- package/dist/sidecar-lock-policy.d.ts +0 -1
- package/dist/sidecar-lock-policy.d.ts.map +1 -1
- package/dist/sidecar-lock-policy.js +0 -4
- package/dist/string-coerce.d.ts +0 -9
- package/dist/string-coerce.d.ts.map +1 -1
- package/dist/string-coerce.js +0 -56
- package/dist/temp-target.d.ts.map +1 -1
- package/dist/temp-target.js +1 -12
- package/docs/atomic.md +53 -19
- package/docs/staged-file.md +6 -2
- package/docs/writing.md +5 -0
- package/package.json +8 -8
- package/dist/archive-tar-extract.d.ts +0 -11
- package/dist/archive-tar-extract.d.ts.map +0 -1
- package/dist/archive-tar-extract.js +0 -49
- package/dist/fsync.d.ts +0 -2
- package/dist/fsync.d.ts.map +0 -1
- package/dist/fsync.js +0 -1
- package/dist/json-durable-queue-retirement.d.ts +0 -9
- package/dist/json-durable-queue-retirement.d.ts.map +0 -1
- package/dist/json-durable-queue-retirement.js +0 -126
- package/dist/json-durable-queue-transfer-lock.d.ts +0 -2
- package/dist/json-durable-queue-transfer-lock.d.ts.map +0 -1
- package/dist/json-durable-queue-transfer-lock.js +0 -19
- package/dist/mode.d.ts +0 -2
- package/dist/mode.d.ts.map +0 -1
- package/dist/mode.js +0 -3
- package/dist/output-sibling.d.ts +0 -8
- package/dist/output-sibling.d.ts.map +0 -1
- package/dist/output-sibling.js +0 -30
- package/dist/read-error.d.ts +0 -2
- package/dist/read-error.d.ts.map +0 -1
- package/dist/read-error.js +0 -11
- package/dist/short-path.d.ts +0 -2
- package/dist/short-path.d.ts.map +0 -1
- package/dist/short-path.js +0 -7
- package/dist/staged-file.d.ts +0 -10
- package/dist/staged-file.d.ts.map +0 -1
- package/dist/staged-file.js +0 -15
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { sha256Hex } from "./file-identity.js";
|
|
4
|
-
import { withSidecarLock } from "./sidecar-lock.js";
|
|
5
|
-
export async function withQueueTransferLock(filePath, run) {
|
|
6
|
-
const lockPath = path.join(path.dirname(filePath), `.fs-safe-transfer-${sha256Hex(path.basename(filePath)).slice(0, 32)}.lock`);
|
|
7
|
-
return await withSidecarLock(filePath, {
|
|
8
|
-
managerKey: "fs-safe.queue-transfer",
|
|
9
|
-
lockPath,
|
|
10
|
-
staleMs: 30_000,
|
|
11
|
-
staleRecovery: "fail-closed",
|
|
12
|
-
timeoutMs: 45_000,
|
|
13
|
-
payload: () => ({
|
|
14
|
-
ownerToken: randomUUID(),
|
|
15
|
-
createdAt: new Date().toISOString(),
|
|
16
|
-
}),
|
|
17
|
-
retry: { retries: 180, minTimeout: 25, maxTimeout: 250, factor: 1.1 },
|
|
18
|
-
}, run);
|
|
19
|
-
}
|
package/dist/mode.d.ts
DELETED
package/dist/mode.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mode.d.ts","sourceRoot":"","sources":["../src/mode.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
package/dist/mode.js
DELETED
package/dist/output-sibling.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"output-sibling.d.ts","sourceRoot":"","sources":["../src/output-sibling.ts"],"names":[],"mappings":"AAuBA,wBAAsB,2BAA2B,CAAC,CAAC,EAAE,MAAM,EAAE;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,CAAC,CAAC,CAYb"}
|
package/dist/output-sibling.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { fitFileNameToPortableComponent, sanitizeUntrustedFileName } from "./filename.js";
|
|
4
|
-
import { writeCallbackSibling } from "./sibling-staged-file.js";
|
|
5
|
-
function safeFallbackFileName(fallbackFileName) {
|
|
6
|
-
return sanitizeUntrustedFileName(fallbackFileName ?? "output.bin", "output.bin");
|
|
7
|
-
}
|
|
8
|
-
function buildSiblingTempPath(targetPath, fallbackFileName) {
|
|
9
|
-
const prefix = `.fs-safe-output-${process.pid}-${randomUUID()}-`;
|
|
10
|
-
const suffix = ".part";
|
|
11
|
-
const safeTail = fitFileNameToPortableComponent({
|
|
12
|
-
prefix,
|
|
13
|
-
fileName: sanitizeUntrustedFileName(path.basename(targetPath), safeFallbackFileName(fallbackFileName)),
|
|
14
|
-
suffix,
|
|
15
|
-
});
|
|
16
|
-
return path.join(path.dirname(targetPath), `${prefix}${safeTail}${suffix}`);
|
|
17
|
-
}
|
|
18
|
-
export async function writeExternalFileViaSibling(params) {
|
|
19
|
-
const finalPath = path.resolve(params.finalPath);
|
|
20
|
-
const { result } = await writeCallbackSibling({
|
|
21
|
-
tempPath: buildSiblingTempPath(finalPath, params.fallbackFileName),
|
|
22
|
-
write: params.write,
|
|
23
|
-
resolveFinalPath: () => finalPath,
|
|
24
|
-
mode: params.mode,
|
|
25
|
-
maxBytes: params.maxBytes,
|
|
26
|
-
syncTempFile: true,
|
|
27
|
-
syncParentDir: true,
|
|
28
|
-
});
|
|
29
|
-
return result;
|
|
30
|
-
}
|
package/dist/read-error.d.ts
DELETED
package/dist/read-error.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"read-error.d.ts","sourceRoot":"","sources":["../src/read-error.ts"],"names":[],"mappings":"AAGA,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAQzE"}
|
package/dist/read-error.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { FsSafeError } from "./errors.js";
|
|
2
|
-
import { isNodeError } from "./path.js";
|
|
3
|
-
export function throwFsSafeReadError(error, label) {
|
|
4
|
-
if (error instanceof FsSafeError) {
|
|
5
|
-
throw error;
|
|
6
|
-
}
|
|
7
|
-
if (isNodeError(error)) {
|
|
8
|
-
throw new FsSafeError("read-failed", `${label} target could not be read`, { cause: error });
|
|
9
|
-
}
|
|
10
|
-
throw error;
|
|
11
|
-
}
|
package/dist/short-path.d.ts
DELETED
package/dist/short-path.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"short-path.d.ts","sourceRoot":"","sources":["../src/short-path.ts"],"names":[],"mappings":"AAGA,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAI/C"}
|
package/dist/short-path.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import os from "node:os";
|
|
2
|
-
import { formatErrorDetail } from "./error-detail.js";
|
|
3
|
-
export function shortPath(value) {
|
|
4
|
-
const home = os.homedir();
|
|
5
|
-
const shortened = value.startsWith(home) ? `~${value.slice(home.length)}` : value;
|
|
6
|
-
return formatErrorDetail(shortened);
|
|
7
|
-
}
|
package/dist/staged-file.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { DirectoryReceipt } from "./directory-durability.js";
|
|
2
|
-
import type { StagedFile } from "./staged-file-types.js";
|
|
3
|
-
export type { PublishedFileReceipt, StagedFile, StagedFileCleanupReceipt, StagedFileFailureDetails, StagedFilePublication, StagedFileReceipt, } from "./staged-file-types.js";
|
|
4
|
-
export declare function stageFileInDirectory(options: {
|
|
5
|
-
directory: string | DirectoryReceipt;
|
|
6
|
-
content: string | Uint8Array;
|
|
7
|
-
/** Published mode; the unpublished stage stays at 0600. Defaults to 0600. */
|
|
8
|
-
mode?: number;
|
|
9
|
-
}): Promise<StagedFile>;
|
|
10
|
-
//# sourceMappingURL=staged-file.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"staged-file.d.ts","sourceRoot":"","sources":["../src/staged-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAKlE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,YAAY,EACV,oBAAoB,EAAE,UAAU,EAAE,wBAAwB,EAAE,wBAAwB,EACpF,qBAAqB,EAAE,iBAAiB,GACzC,MAAM,wBAAwB,CAAC;AAEhC,wBAAsB,oBAAoB,CAAC,OAAO,EAAE;IAClD,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAAC;IACrC,OAAO,EAAE,MAAM,GAAG,UAAU,CAAC;IAC7B,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,UAAU,CAAC,CAUtB"}
|
package/dist/staged-file.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { FsSafeError } from "./errors.js";
|
|
2
|
-
import { assertNativeStaging, createNativeStage } from "./native-staged-file.js";
|
|
3
|
-
import { requireNativeBinding } from "./native.js";
|
|
4
|
-
import { openStagedDirectory } from "./staged-directory.js";
|
|
5
|
-
export async function stageFileInDirectory(options) {
|
|
6
|
-
if (process.platform !== "linux" && process.platform !== "darwin") {
|
|
7
|
-
throw new FsSafeError("unsupported-platform", "retained-directory staging requires Linux or macOS");
|
|
8
|
-
}
|
|
9
|
-
const binding = requireNativeBinding();
|
|
10
|
-
assertNativeStaging(binding);
|
|
11
|
-
const input = { kind: "buffer", data: Buffer.from(options.content) };
|
|
12
|
-
const mode = options.mode ?? 0o600;
|
|
13
|
-
const parent = openStagedDirectory(options.directory);
|
|
14
|
-
return await createNativeStage(binding, parent.fd, parent.receipt, input, mode);
|
|
15
|
-
}
|