@openclaw/fs-safe 0.4.6 → 0.5.0
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 +69 -0
- package/README.md +110 -41
- package/dist/archive-entry.d.ts.map +1 -1
- package/dist/archive-entry.js +5 -4
- package/dist/archive-errors.d.ts +11 -0
- package/dist/archive-errors.d.ts.map +1 -0
- package/dist/archive-errors.js +16 -0
- package/dist/archive-input.d.ts +12 -0
- package/dist/archive-input.d.ts.map +1 -0
- package/dist/archive-input.js +72 -0
- package/dist/archive-kind.d.ts +1 -1
- package/dist/archive-kind.d.ts.map +1 -1
- package/dist/archive-kind.js +18 -0
- package/dist/archive-limits.d.ts +10 -0
- package/dist/archive-limits.d.ts.map +1 -1
- package/dist/archive-limits.js +18 -0
- package/dist/archive-native.d.ts +18 -0
- package/dist/archive-native.d.ts.map +1 -0
- package/dist/archive-native.js +115 -0
- package/dist/archive-options.d.ts +21 -0
- package/dist/archive-options.d.ts.map +1 -0
- package/dist/archive-options.js +1 -0
- package/dist/archive-policy.d.ts +20 -0
- package/dist/archive-policy.d.ts.map +1 -0
- package/dist/archive-policy.js +29 -0
- package/dist/archive-read.d.ts +6 -0
- package/dist/archive-read.d.ts.map +1 -0
- package/dist/archive-read.js +200 -0
- package/dist/archive-staging.d.ts +2 -5
- package/dist/archive-staging.d.ts.map +1 -1
- package/dist/archive-staging.js +19 -10
- package/dist/archive-tar-meta.d.ts +6 -0
- package/dist/archive-tar-meta.d.ts.map +1 -0
- package/dist/archive-tar-meta.js +143 -0
- package/dist/archive-tar-runtime.d.ts +43 -0
- package/dist/archive-tar-runtime.d.ts.map +1 -0
- package/dist/archive-tar-runtime.js +8 -0
- package/dist/archive-tar.d.ts +5 -1
- package/dist/archive-tar.d.ts.map +1 -1
- package/dist/archive-tar.js +24 -6
- package/dist/archive-zip-entry.d.ts +15 -0
- package/dist/archive-zip-entry.d.ts.map +1 -0
- package/dist/archive-zip-entry.js +17 -0
- package/dist/archive.d.ts +7 -17
- package/dist/archive.d.ts.map +1 -1
- package/dist/archive.js +111 -108
- package/dist/atomic.d.ts +1 -1
- package/dist/atomic.d.ts.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/containment.d.ts +2 -0
- package/dist/containment.d.ts.map +1 -0
- package/dist/containment.js +1 -0
- package/dist/directory-durability.d.ts +44 -0
- package/dist/directory-durability.d.ts.map +1 -0
- package/dist/directory-durability.js +299 -0
- package/dist/durability.d.ts +4 -0
- package/dist/durability.d.ts.map +1 -0
- package/dist/durability.js +3 -0
- package/dist/errors.d.ts +4 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +2 -0
- package/dist/file-hash.d.ts +10 -0
- package/dist/file-hash.d.ts.map +1 -0
- package/dist/file-hash.js +73 -0
- package/dist/file-lock-sync.d.ts +35 -0
- package/dist/file-lock-sync.d.ts.map +1 -0
- package/dist/file-lock-sync.js +233 -0
- package/dist/file-lock.d.ts +2 -0
- package/dist/file-lock.d.ts.map +1 -1
- package/dist/file-lock.js +1 -0
- package/dist/filename.d.ts.map +1 -1
- package/dist/filename.js +4 -1
- package/dist/fsync.d.ts +1 -1
- package/dist/fsync.d.ts.map +1 -1
- package/dist/fsync.js +1 -21
- package/dist/guarded-mkdir.d.ts +7 -1
- package/dist/guarded-mkdir.d.ts.map +1 -1
- package/dist/guarded-mkdir.js +45 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/json-document-store.d.ts.map +1 -1
- package/dist/json-document-store.js +30 -15
- package/dist/move-path.d.ts.map +1 -1
- package/dist/move-path.js +101 -17
- package/dist/native/darwin-arm64/fs-safe-native.node +0 -0
- package/dist/native/darwin-x64/fs-safe-native.node +0 -0
- package/dist/native/linux-arm64-gnu/fs-safe-native.node +0 -0
- package/dist/native/linux-arm64-musl/fs-safe-native.node +0 -0
- package/dist/native/linux-x64-gnu/fs-safe-native.node +0 -0
- package/dist/native/linux-x64-musl/fs-safe-native.node +0 -0
- package/dist/native/win32-x64-msvc/fs-safe-native.node +0 -0
- package/dist/native-binding.d.ts +79 -0
- package/dist/native-binding.d.ts.map +1 -0
- package/dist/native-binding.js +1 -0
- package/dist/native-config.d.ts +17 -0
- package/dist/native-config.d.ts.map +1 -0
- package/dist/native-config.js +71 -0
- package/dist/native-operations.d.ts +21 -0
- package/dist/native-operations.d.ts.map +1 -0
- package/dist/native-operations.js +115 -0
- package/dist/native-pinned-write.d.ts +5 -0
- package/dist/native-pinned-write.d.ts.map +1 -0
- package/dist/native-pinned-write.js +115 -0
- package/dist/native.d.ts +14 -0
- package/dist/native.d.ts.map +1 -0
- package/dist/native.js +204 -0
- package/dist/output-sibling.d.ts +8 -0
- package/dist/output-sibling.d.ts.map +1 -0
- package/dist/output-sibling.js +122 -0
- package/dist/output.d.ts +2 -0
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +32 -5
- package/dist/owner-dacl.d.ts +31 -0
- package/dist/owner-dacl.d.ts.map +1 -0
- package/dist/owner-dacl.js +27 -0
- package/dist/path-policy.js +1 -1
- package/dist/permissions-public.d.ts +2 -0
- package/dist/permissions-public.d.ts.map +1 -1
- package/dist/permissions-public.js +2 -0
- package/dist/permissions.d.ts.map +1 -1
- package/dist/permissions.js +6 -0
- package/dist/pinned-operation.d.ts +2 -0
- package/dist/pinned-operation.d.ts.map +1 -0
- package/dist/pinned-operation.js +35 -0
- package/dist/pinned-write.d.ts +3 -16
- package/dist/pinned-write.d.ts.map +1 -1
- package/dist/pinned-write.js +20 -85
- package/dist/private-directory.d.ts +5 -0
- package/dist/private-directory.d.ts.map +1 -0
- package/dist/private-directory.js +13 -0
- package/dist/private-temp-workspace.d.ts +6 -2
- package/dist/private-temp-workspace.d.ts.map +1 -1
- package/dist/private-temp-workspace.js +40 -13
- package/dist/publish-file-failure.d.ts +27 -0
- package/dist/publish-file-failure.d.ts.map +1 -0
- package/dist/publish-file-failure.js +21 -0
- package/dist/publish-file.d.ts +21 -0
- package/dist/publish-file.d.ts.map +1 -0
- package/dist/publish-file.js +351 -0
- package/dist/read-opened-file.d.ts +3 -0
- package/dist/read-opened-file.d.ts.map +1 -1
- package/dist/read-opened-file.js +1 -0
- package/dist/replace-file-copy-fallback.d.ts +34 -0
- package/dist/replace-file-copy-fallback.d.ts.map +1 -0
- package/dist/replace-file-copy-fallback.js +339 -0
- package/dist/replace-file.d.ts +6 -2
- package/dist/replace-file.d.ts.map +1 -1
- package/dist/replace-file.js +39 -90
- package/dist/root-context.d.ts +4 -1
- package/dist/root-context.d.ts.map +1 -1
- package/dist/root-context.js +20 -1
- package/dist/root-impl.d.ts +5 -0
- package/dist/root-impl.d.ts.map +1 -1
- package/dist/root-impl.js +128 -225
- package/dist/root-path-existing.d.ts +3 -0
- package/dist/root-path-existing.d.ts.map +1 -0
- package/dist/root-path-existing.js +69 -0
- package/dist/root-path.d.ts +1 -2
- package/dist/root-path.d.ts.map +1 -1
- package/dist/root-path.js +67 -81
- package/dist/root-walk.d.ts +41 -0
- package/dist/root-walk.d.ts.map +1 -0
- package/dist/root-walk.js +114 -0
- package/dist/root.d.ts +2 -0
- package/dist/root.d.ts.map +1 -1
- package/dist/secret-file.d.ts +5 -2
- package/dist/secret-file.d.ts.map +1 -1
- package/dist/secret-file.js +20 -2
- package/dist/secret-read-async.d.ts +4 -0
- package/dist/secret-read-async.d.ts.map +1 -0
- package/dist/secret-read-async.js +95 -0
- package/dist/secret.d.ts +2 -1
- package/dist/secret.d.ts.map +1 -1
- package/dist/secret.js +2 -1
- package/dist/sibling-temp.d.ts.map +1 -1
- package/dist/sibling-temp.js +2 -13
- package/dist/sidecar-lock-handle.d.ts +20 -0
- package/dist/sidecar-lock-handle.d.ts.map +1 -0
- package/dist/sidecar-lock-handle.js +28 -0
- package/dist/sidecar-lock-policy.d.ts +10 -0
- package/dist/sidecar-lock-policy.d.ts.map +1 -0
- package/dist/sidecar-lock-policy.js +29 -0
- package/dist/sidecar-lock-reclaim.d.ts +22 -6
- package/dist/sidecar-lock-reclaim.d.ts.map +1 -1
- package/dist/sidecar-lock-reclaim.js +106 -20
- package/dist/sidecar-lock-types.d.ts +56 -0
- package/dist/sidecar-lock-types.d.ts.map +1 -0
- package/dist/sidecar-lock-types.js +1 -0
- package/dist/sidecar-lock.d.ts +2 -45
- package/dist/sidecar-lock.d.ts.map +1 -1
- package/dist/sidecar-lock.js +94 -55
- package/dist/temp-cleanup.d.ts +7 -1
- package/dist/temp-cleanup.d.ts.map +1 -1
- package/dist/temp-cleanup.js +35 -5
- package/dist/temp.d.ts +2 -1
- package/dist/temp.d.ts.map +1 -1
- package/dist/test-hooks.d.ts +3 -0
- package/dist/test-hooks.d.ts.map +1 -1
- package/dist/windows-permissions-native.d.ts +9 -0
- package/dist/windows-permissions-native.d.ts.map +1 -0
- package/dist/windows-permissions-native.js +31 -0
- package/docs/advanced.md +1 -1
- package/docs/archive.md +131 -13
- package/docs/atomic.md +30 -1
- package/docs/config.md +51 -21
- package/docs/durability.md +299 -0
- package/docs/errors.md +36 -6
- package/docs/filename.md +0 -0
- package/docs/index.md +11 -7
- package/docs/install.md +27 -26
- package/docs/json-store.md +18 -3
- package/docs/migrating-to-0.5.md +196 -0
- package/docs/native-helper.md +85 -0
- package/docs/native.md +134 -0
- package/docs/output.md +37 -11
- package/docs/path.md +1 -1
- package/docs/permissions.md +84 -1
- package/docs/quickstart.md +5 -2
- package/docs/reading.md +4 -4
- package/docs/root.md +31 -15
- package/docs/secret-file.md +50 -1
- package/docs/security-model.md +42 -8
- package/docs/sidecar-lock.md +92 -7
- package/docs/temp.md +24 -1
- package/docs/test-hooks.md +22 -2
- package/docs/testing.md +18 -7
- package/docs/types.md +3 -1
- package/docs/walk.md +55 -0
- package/docs/writing.md +3 -3
- package/package.json +12 -2
- package/dist/pinned-helper.d.ts +0 -9
- package/dist/pinned-helper.d.ts.map +0 -1
- package/dist/pinned-helper.js +0 -19
- package/dist/pinned-path.d.ts +0 -7
- package/dist/pinned-path.d.ts.map +0 -1
- package/dist/pinned-path.js +0 -21
- package/dist/pinned-python-config.d.ts +0 -9
- package/dist/pinned-python-config.d.ts.map +0 -1
- package/dist/pinned-python-config.js +0 -38
- package/dist/pinned-python.d.ts +0 -12
- package/dist/pinned-python.d.ts.map +0 -1
- package/dist/pinned-python.js +0 -688
- package/docs/python-helper.md +0 -103
package/docs/walk.md
CHANGED
|
@@ -67,7 +67,62 @@ type WalkDirectoryOptions = {
|
|
|
67
67
|
|
|
68
68
|
Unreadable directories are skipped rather than throwing, but every skipped directory is recorded in `failedDirs`. This keeps the helper suitable for best-effort inventories while letting pruning jobs tell an incomplete scan from an empty one: a destructive reconcile that deletes state for paths missing from `entries` must first confirm `failedDirs` holds no real read failures, or a transient `EIO`/`EACCES` blip would be mistaken for mass deletion. Use a stricter root-bounded operation when every entry must be accounted for.
|
|
69
69
|
|
|
70
|
+
## Root-bounded async iteration
|
|
71
|
+
|
|
72
|
+
`Root.walk(rel, options)` is the root-bounded counterpart to these standalone
|
|
73
|
+
inventory helpers. It yields `{ relativePath, kind, size }` incrementally and
|
|
74
|
+
accepts `maxDepth`, `maxEntries`, `symlinkPolicy: "skip" |
|
|
75
|
+
"follow-within-root"`, and an `AbortSignal`. The default budget behavior yields
|
|
76
|
+
one `kind: "truncated"` marker and ends; pass `limitBehavior: "throw"` for a
|
|
77
|
+
typed `FsSafeError("too-large")` instead.
|
|
78
|
+
|
|
79
|
+
`entryFilter` is evaluated for each resolved file, directory, or other entry:
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
for await (const entry of capability.walk("", {
|
|
83
|
+
symlinkPolicy: "skip",
|
|
84
|
+
entryFilter: (entry) =>
|
|
85
|
+
entry.kind === "directory" && entry.relativePath === ".git"
|
|
86
|
+
? "skip-subtree"
|
|
87
|
+
: "include",
|
|
88
|
+
onDirectoryError: "skip-and-report",
|
|
89
|
+
})) {
|
|
90
|
+
if (entry.kind === "directory-error") {
|
|
91
|
+
console.warn("incomplete subtree", entry.relativePath, entry.error);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
consume(entry);
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The result values are `"include"`, `"skip"`, and `"skip-subtree"`. Plain
|
|
99
|
+
`"skip"` omits an entry but still descends when it is a directory;
|
|
100
|
+
`"skip-subtree"` omits that directory and prunes its descendants. Returning
|
|
101
|
+
`"skip-subtree"` for a non-directory is equivalent to `"skip"`.
|
|
102
|
+
|
|
103
|
+
`onDirectoryError` defaults to `"throw"`, preserving the original fail-fast
|
|
104
|
+
contract. `"skip-and-report"` yields a discriminated
|
|
105
|
+
`{ kind: "directory-error", relativePath, size: 0, error }` marker for a
|
|
106
|
+
directory that cannot be resolved or listed, then continues with its siblings.
|
|
107
|
+
Every examined directory entry consumes `maxEntries` before filtering, so
|
|
108
|
+
`"skip"` cannot turn the iterator into an unbounded traversal. Reporting and
|
|
109
|
+
`"truncated"` markers describe already-reached state and do not authorize
|
|
110
|
+
further descent.
|
|
111
|
+
|
|
112
|
+
The pure-Node path validates every directory canonically inside the root,
|
|
113
|
+
revalidates each listing through the normal `Root.list()` boundary, and tracks
|
|
114
|
+
canonical directories to stop symlink cycles. It does not hold a descriptor
|
|
115
|
+
for the entire tree, so it is not a process sandbox against a hostile peer that
|
|
116
|
+
can continuously swap and restore directories. Each individual lookup retains
|
|
117
|
+
the documented Node `Root` boundary checks.
|
|
118
|
+
|
|
119
|
+
Unlike `walkDirectory()` and `walkDirectorySync()`, `Root.walk()` is
|
|
120
|
+
root-bounded and reports failures inline because an async iterator has no final
|
|
121
|
+
result summary. Its default remains to throw on unreadable or invalid
|
|
122
|
+
directories.
|
|
123
|
+
|
|
70
124
|
## See also
|
|
71
125
|
|
|
72
126
|
- [`fileStore`](file-store.md) — managed stores use bounded walking for pruning.
|
|
73
127
|
- [Path scopes](path-scope.md) — boundary checks for known absolute paths.
|
|
128
|
+
- [Migrating to 0.5](migrating-to-0.5.md) — adopting bounded pruning and partial-result handling.
|
package/docs/writing.md
CHANGED
|
@@ -17,7 +17,7 @@ await fs.mkdir("snapshots/2026/05");
|
|
|
17
17
|
|
|
18
18
|
1. Resolve the relative target against the canonical root and reject anything that escapes (`outside-workspace`).
|
|
19
19
|
2. If `mkdir: true`, create missing parent directories with the parent fd pinned.
|
|
20
|
-
3.
|
|
20
|
+
3. Pin or guard the parent directory for the selected mechanism. Native operations use a parent fd; guarded JavaScript verifies directory identity before and after mutation. Linux beneath opens are kernel-atomic, while macOS, Windows, and JavaScript routes retain the best-effort race boundaries in the [security model](security-model.md#containment-guarantees-by-platform).
|
|
21
21
|
4. Write data to a sibling temp file in the same directory.
|
|
22
22
|
5. Atomically rename the temp file over the destination.
|
|
23
23
|
6. Stat the resulting fd and verify identity.
|
|
@@ -246,9 +246,9 @@ const fs = await root("/mnt/rclone-workspace", {
|
|
|
246
246
|
await fs.write("state.json", body); // succeeds on rclone FUSE
|
|
247
247
|
```
|
|
248
248
|
|
|
249
|
-
**How it works.** The full write runs under an exclusive per-target lock named `.fs-safe-write-<sha256>.lock` in the root. Keeping the lock in the already-canonical root avoids creating an unguarded lock path through a missing or raced target parent. The guarded Node fallback accepts the source-temp-to-destination inode mismatch only when the SHA-256 of the re-read bytes matches the SHA-256 of the bytes written. Subsequent path identity checks remain strict, so this mode requires an unchanged destination path to report stable identity. It deliberately
|
|
249
|
+
**How it works.** The full write runs under an exclusive per-target lock named `.fs-safe-write-<sha256>.lock` in the root. Keeping the lock in the already-canonical root avoids creating an unguarded lock path through a missing or raced target parent. The guarded Node fallback accepts the source-temp-to-destination inode mismatch only when the SHA-256 of the re-read bytes matches the SHA-256 of the bytes written. Subsequent path identity checks remain strict, so this mode requires an unchanged destination path to report stable identity. It deliberately stays on the guarded JavaScript path because content verification replaces the normal inode-preserving rename contract. The lock is released before the call returns.
|
|
250
250
|
|
|
251
|
-
**Security note.** `verify-content-with-lock` proves that the bytes observed after rename match the requested write and prevents *cooperating* writers from interleaving. It does **not** prove that the destination still names the temp-file object, retain
|
|
251
|
+
**Security note.** `verify-content-with-lock` proves that the bytes observed after rename match the requested write and prevents *cooperating* writers from interleaving. It does **not** prove that the destination still names the temp-file object, retain fd-relative parent pinning, or stop a same-UID process that ignores the advisory lock. Do not use this option on directories writable by untrusted same-UID processes. Strict identity verification remains the default.
|
|
252
252
|
|
|
253
253
|
Lock recovery is fail-closed. If a process crashes and leaves the root-level `.fs-safe-write-<sha256>.lock`, a later write reports the stale lock instead of deleting it based on a host-local PID. Recover only under external authority that excludes every competing writer; see [File lock](sidecar-lock.md#stale-recovery-guarded-remove-if-unchanged).
|
|
254
254
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/fs-safe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Capability-style filesystem roots for Node.js apps that handle untrusted relative paths.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"filesystem",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"dist/**/*.js",
|
|
28
28
|
"dist/**/*.d.ts",
|
|
29
29
|
"dist/**/*.d.ts.map",
|
|
30
|
+
"dist/native/**/*.node",
|
|
30
31
|
"docs/**/*.md",
|
|
31
32
|
"README.md",
|
|
32
33
|
"CHANGELOG.md",
|
|
@@ -96,6 +97,10 @@
|
|
|
96
97
|
"types": "./dist/atomic.d.ts",
|
|
97
98
|
"default": "./dist/atomic.js"
|
|
98
99
|
},
|
|
100
|
+
"./durability": {
|
|
101
|
+
"types": "./dist/durability.d.ts",
|
|
102
|
+
"default": "./dist/durability.js"
|
|
103
|
+
},
|
|
99
104
|
"./archive": {
|
|
100
105
|
"types": "./dist/archive.d.ts",
|
|
101
106
|
"default": "./dist/archive.js"
|
|
@@ -116,6 +121,7 @@
|
|
|
116
121
|
},
|
|
117
122
|
"scripts": {
|
|
118
123
|
"benchmark": "node scripts/benchmark.mjs",
|
|
124
|
+
"benchmark:publish": "pnpm build && node scripts/bench-publish.mjs",
|
|
119
125
|
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json",
|
|
120
126
|
"lint:file-size": "node scripts/check-file-size.mjs",
|
|
121
127
|
"lint:fs-boundary": "node scripts/check-fs-boundary-primitives.mjs",
|
|
@@ -125,7 +131,10 @@
|
|
|
125
131
|
"test:security": "vitest run test/fs-safe.test.ts test/read-boundary-bypass.test.ts test/write-boundary-bypass.test.ts test/additional-boundary-bypass.test.ts test/adversarial-boundary-payloads.test.ts",
|
|
126
132
|
"check": "pnpm lint:file-size && pnpm lint:fs-boundary && pnpm build && pnpm test && node scripts/check-pack.mjs",
|
|
127
133
|
"docs:site": "node scripts/build-docs-site.mjs",
|
|
134
|
+
"native:build": "pnpm --filter @openclaw/fs-safe-native-build build",
|
|
135
|
+
"native:test": "cargo test --manifest-path native/Cargo.toml",
|
|
128
136
|
"pack:check": "pnpm build && node scripts/check-pack.mjs",
|
|
137
|
+
"package:smoke": "node scripts/check-release-packages.mjs --allow-host-only --output release-artifacts",
|
|
129
138
|
"check:changed": "pnpm run check",
|
|
130
139
|
"release:notes": "node scripts/release-notes.mjs",
|
|
131
140
|
"test:changed": "pnpm run test",
|
|
@@ -136,9 +145,10 @@
|
|
|
136
145
|
},
|
|
137
146
|
"optionalDependencies": {
|
|
138
147
|
"jszip": "^3.10.1",
|
|
139
|
-
"tar": "7.5.
|
|
148
|
+
"tar": "7.5.21"
|
|
140
149
|
},
|
|
141
150
|
"devDependencies": {
|
|
151
|
+
"@napi-rs/cli": "3.7.4",
|
|
142
152
|
"@types/node": "^26.1.1",
|
|
143
153
|
"@vitest/coverage-v8": "4.1.10",
|
|
144
154
|
"typescript": "^7.0.2",
|
package/dist/pinned-helper.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { DirEntry, PathStat } from "./types.js";
|
|
2
|
-
import { isPinnedHelperUnavailable } from "./pinned-python.js";
|
|
3
|
-
type HelperOperation = "stat" | "readdir" | "mkdirp" | "remove" | "rename";
|
|
4
|
-
export { isPinnedHelperUnavailable };
|
|
5
|
-
export declare function runPinnedHelper<T>(operation: HelperOperation, rootDir: string, payload: Record<string, unknown>): Promise<T>;
|
|
6
|
-
export declare function helperStat(rootDir: string, relativePath: string): Promise<PathStat>;
|
|
7
|
-
export declare function helperReaddir(rootDir: string, relativePath: string, withFileTypes: false): Promise<string[]>;
|
|
8
|
-
export declare function helperReaddir(rootDir: string, relativePath: string, withFileTypes: true): Promise<DirEntry[]>;
|
|
9
|
-
//# sourceMappingURL=pinned-helper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pinned-helper.d.ts","sourceRoot":"","sources":["../src/pinned-helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EACL,yBAAyB,EAG1B,MAAM,oBAAoB,CAAC;AAE5B,KAAK,eAAe,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE3E,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAErC,wBAAsB,eAAe,CAAC,CAAC,EACrC,SAAS,EAAE,eAAe,EAC1B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,CAAC,CAAC,CAOZ;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEzF;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,KAAK,GACnB,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AACrB,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,IAAI,GAClB,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC"}
|
package/dist/pinned-helper.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { isPinnedHelperUnavailable, runPinnedPythonOperation, validatePinnedOperationPayload, } from "./pinned-python.js";
|
|
2
|
-
export { isPinnedHelperUnavailable };
|
|
3
|
-
export async function runPinnedHelper(operation, rootDir, payload) {
|
|
4
|
-
validatePinnedOperationPayload(payload);
|
|
5
|
-
return await runPinnedPythonOperation({
|
|
6
|
-
operation,
|
|
7
|
-
rootPath: rootDir,
|
|
8
|
-
payload,
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
export async function helperStat(rootDir, relativePath) {
|
|
12
|
-
return await runPinnedHelper("stat", rootDir, { relativePath });
|
|
13
|
-
}
|
|
14
|
-
export async function helperReaddir(rootDir, relativePath, withFileTypes) {
|
|
15
|
-
return await runPinnedHelper("readdir", rootDir, {
|
|
16
|
-
relativePath,
|
|
17
|
-
withFileTypes,
|
|
18
|
-
});
|
|
19
|
-
}
|
package/dist/pinned-path.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare function isPinnedPathHelperSpawnError(error: unknown): boolean;
|
|
2
|
-
export declare function runPinnedPathHelper(params: {
|
|
3
|
-
operation: "mkdirp" | "remove";
|
|
4
|
-
rootPath: string;
|
|
5
|
-
relativePath: string;
|
|
6
|
-
}): Promise<void>;
|
|
7
|
-
//# sourceMappingURL=pinned-path.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pinned-path.d.ts","sourceRoot":"","sources":["../src/pinned-path.ts"],"names":[],"mappings":"AAIA,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEpE;AAED,wBAAsB,mBAAmB,CAAC,MAAM,EAAE;IAChD,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,IAAI,CAAC,CAahB"}
|
package/dist/pinned-path.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { FsSafeError } from "./errors.js";
|
|
2
|
-
import { canFallbackFromPythonError } from "./pinned-python-config.js";
|
|
3
|
-
import { runPinnedHelper } from "./pinned-helper.js";
|
|
4
|
-
export function isPinnedPathHelperSpawnError(error) {
|
|
5
|
-
return canFallbackFromPythonError(error);
|
|
6
|
-
}
|
|
7
|
-
export async function runPinnedPathHelper(params) {
|
|
8
|
-
try {
|
|
9
|
-
await runPinnedHelper(params.operation, params.rootPath, {
|
|
10
|
-
relativePath: params.relativePath,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
catch (error) {
|
|
14
|
-
if (error instanceof FsSafeError) {
|
|
15
|
-
throw error;
|
|
16
|
-
}
|
|
17
|
-
throw new FsSafeError("helper-failed", "pinned path helper failed", {
|
|
18
|
-
cause: error instanceof Error ? error : undefined,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type FsSafePythonMode = "auto" | "off" | "require";
|
|
2
|
-
export type FsSafePythonConfig = {
|
|
3
|
-
mode: FsSafePythonMode;
|
|
4
|
-
pythonPath?: string;
|
|
5
|
-
};
|
|
6
|
-
export declare function configureFsSafePython(config: Partial<FsSafePythonConfig>): void;
|
|
7
|
-
export declare function getFsSafePythonConfig(): FsSafePythonConfig;
|
|
8
|
-
export declare function canFallbackFromPythonError(error: unknown): boolean;
|
|
9
|
-
//# sourceMappingURL=pinned-python-config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pinned-python-config.d.ts","sourceRoot":"","sources":["../src/pinned-python-config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC;AAE1D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,gBAAgB,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAqBF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAE/E;AAED,wBAAgB,qBAAqB,IAAI,kBAAkB,CAc1D;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMlE"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
let overrideConfig = {};
|
|
2
|
-
function parseMode(value) {
|
|
3
|
-
if (!value) {
|
|
4
|
-
return undefined;
|
|
5
|
-
}
|
|
6
|
-
const normalized = value.trim().toLowerCase();
|
|
7
|
-
if (normalized === "0" || normalized === "false" || normalized === "off" || normalized === "never") {
|
|
8
|
-
return "off";
|
|
9
|
-
}
|
|
10
|
-
if (normalized === "1" || normalized === "true" || normalized === "on" || normalized === "auto") {
|
|
11
|
-
return "auto";
|
|
12
|
-
}
|
|
13
|
-
if (normalized === "required" || normalized === "require") {
|
|
14
|
-
return "require";
|
|
15
|
-
}
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
export function configureFsSafePython(config) {
|
|
19
|
-
overrideConfig = { ...overrideConfig, ...config };
|
|
20
|
-
}
|
|
21
|
-
export function getFsSafePythonConfig() {
|
|
22
|
-
return {
|
|
23
|
-
mode: overrideConfig.mode ??
|
|
24
|
-
parseMode(process.env.FS_SAFE_PYTHON_MODE) ??
|
|
25
|
-
parseMode(process.env.OPENCLAW_FS_SAFE_PYTHON_MODE) ??
|
|
26
|
-
"auto",
|
|
27
|
-
pythonPath: overrideConfig.pythonPath ??
|
|
28
|
-
process.env.FS_SAFE_PYTHON ??
|
|
29
|
-
process.env.OPENCLAW_FS_SAFE_PYTHON ??
|
|
30
|
-
process.env.OPENCLAW_PINNED_PYTHON ??
|
|
31
|
-
process.env.OPENCLAW_PINNED_WRITE_PYTHON,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
export function canFallbackFromPythonError(error) {
|
|
35
|
-
const code = error instanceof Error && "code" in error ? error.code : undefined;
|
|
36
|
-
return (getFsSafePythonConfig().mode !== "require" &&
|
|
37
|
-
(code === "helper-unavailable" || code === "unsupported-platform"));
|
|
38
|
-
}
|
package/dist/pinned-python.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
type PinnedPythonOperation = "copy" | "stat" | "readdir" | "mkdirp" | "remove" | "rename" | "write";
|
|
2
|
-
export declare function __resetPinnedPythonWorkerForTest(): void;
|
|
3
|
-
export declare function runPinnedPythonOperation<T>(params: {
|
|
4
|
-
operation: PinnedPythonOperation;
|
|
5
|
-
rootPath: string;
|
|
6
|
-
payload: Record<string, unknown>;
|
|
7
|
-
}): Promise<T>;
|
|
8
|
-
export declare function assertPinnedPythonOperationAvailable(): void;
|
|
9
|
-
export declare function validatePinnedOperationPayload(payload: Record<string, unknown>): void;
|
|
10
|
-
export declare function isPinnedHelperUnavailable(error: unknown): boolean;
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=pinned-python.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pinned-python.d.ts","sourceRoot":"","sources":["../src/pinned-python.ts"],"names":[],"mappings":"AA2ZA,KAAK,qBAAqB,GACtB,MAAM,GACN,MAAM,GACN,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,OAAO,CAAC;AAiBZ,wBAAgB,gCAAgC,IAAI,IAAI,CAQvD;AAiOD,wBAAsB,wBAAwB,CAAC,CAAC,EAAE,MAAM,EAAE;IACxD,SAAS,EAAE,qBAAqB,CAAC;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,GAAG,OAAO,CAAC,CAAC,CAAC,CA4Bb;AAED,wBAAgB,oCAAoC,IAAI,IAAI,CAK3D;AAED,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAarF;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEjE"}
|