@lousy-agents/agent-shell 5.22.6 → 5.22.8

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.
Files changed (2) hide show
  1. package/dist/index.js +54 -22
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -259,12 +259,23 @@ function parseMode(value) {
259
259
  function configureFsSafeNative(config) {
260
260
  overrideConfig = { ...overrideConfig, ...config };
261
261
  }
262
+ function rejectLegacyMode() {
263
+ for (const source of ["FS_SAFE_PYTHON_MODE", "OPENCLAW_FS_SAFE_PYTHON_MODE"]) {
264
+ if (process.env[source] === undefined)
265
+ continue;
266
+ const mode = parseMode(process.env[source]) ?? "auto";
267
+ throw new Error(`${source} has been removed. Set FS_SAFE_NATIVE_MODE=${mode} or ` +
268
+ `configureFsSafeNative({ mode: "${mode}" }) before using fs-safe, then remove ${source}. ` +
269
+ "Legacy mode settings no longer select native policy.");
270
+ }
271
+ return "auto";
272
+ }
262
273
  function getFsSafeNativeConfig() {
263
274
  return {
264
275
  mode: overrideConfig.mode ??
265
276
  parseMode(process.env.FS_SAFE_NATIVE_MODE) ??
266
277
  parseMode(process.env.OPENCLAW_FS_SAFE_NATIVE_MODE) ??
267
- "auto",
278
+ rejectLegacyMode(),
268
279
  };
269
280
  }
270
281
  /** Internal provenance; keep the public configuration shape unchanged. */
@@ -276,13 +287,13 @@ function getNativeModeSetting() {
276
287
  if (mode !== undefined)
277
288
  return { mode, source };
278
289
  }
279
- return { mode: "auto", source: "default" };
290
+ return { mode: rejectLegacyMode(), source: "default" };
280
291
  }
281
292
  function isFsSafeNativeRequired() {
282
293
  return (overrideConfig.mode ??
283
294
  parseMode(process.env.FS_SAFE_NATIVE_MODE) ??
284
295
  parseMode(process.env.OPENCLAW_FS_SAFE_NATIVE_MODE) ??
285
- "auto") === "require";
296
+ rejectLegacyMode()) === "require";
286
297
  }
287
298
  function __resetFsSafeNativeConfigForTest() {
288
299
  overrideConfig = {};
@@ -5120,14 +5131,15 @@ function pathExistsSync(targetPath) {
5120
5131
  function resolvePathViaExistingAncestorSync(targetPath) {
5121
5132
  return resolveExistingAncestor(targetPath, "ordinary");
5122
5133
  }
5123
- function resolveExistingAncestor(targetPath, mode) {
5124
- const exists = mode === "native" ? root_path_existing_pathExists : pathExistsSync;
5125
- const canonicalize = mode === "native" ? realpath_realpathSync.native : realpath_realpathSync;
5134
+ function resolveExistingAncestor(targetPath, mode, preserveRawSegments = false, remainingHops = 64) {
5135
+ const exists = mode === "native" || preserveRawSegments ? root_path_existing_pathExists : pathExistsSync;
5136
+ const canonicalize = realpath_realpathSync.native;
5126
5137
  windows_path_alias_assertNoWindowsPathAlias(targetPath);
5127
5138
  const normalized = windows_path_alias_resolvePathPreservingWindowsRoot(targetPath);
5128
5139
  windows_path_alias_assertNoWindowsPathAlias(normalized);
5129
- let cursor = normalized;
5130
- const filesystemRoot = external_node_path_namespaceObject.parse(normalized).root;
5140
+ const candidate = preserveRawSegments ? absolutePathWithRawSegments(targetPath) : normalized;
5141
+ let cursor = candidate;
5142
+ const filesystemRoot = external_node_path_namespaceObject.parse(candidate).root;
5131
5143
  while (cursor !== filesystemRoot &&
5132
5144
  !exists(cursor)) {
5133
5145
  cursor = external_node_path_namespaceObject.dirname(cursor);
@@ -5139,22 +5151,30 @@ function resolveExistingAncestor(targetPath, mode) {
5139
5151
  try {
5140
5152
  rawResolvedAncestor = canonicalize(windows_path_alias_pathForWindowsFilesystem(cursor));
5141
5153
  }
5142
- catch {
5143
- return normalized;
5154
+ catch (error) {
5155
+ if (!preserveRawSegments)
5156
+ return normalized;
5157
+ if (!path_isNotFoundPathError(error))
5158
+ throw error;
5159
+ rawResolvedAncestor = resolveSymlinkHopPath(cursor, mode, false, remainingHops);
5144
5160
  }
5145
5161
  windows_path_alias_assertNoWindowsPathAlias(rawResolvedAncestor);
5146
5162
  const resolvedAncestor = windows_path_alias_resolvePathPreservingWindowsRoot(rawResolvedAncestor);
5147
5163
  windows_path_alias_assertNoWindowsPathAlias(resolvedAncestor);
5148
5164
  // Keep a leading suffix separator relative to the canonical ancestor.
5149
- const resolved = cursor === normalized
5165
+ const suffix = candidate.slice(cursor.length);
5166
+ if (preserveRawSegments && suffix.split(external_node_path_namespaceObject.sep).includes("..")) {
5167
+ throw new errors_FsSafeError("symlink", "symlink target has an unresolved parent component");
5168
+ }
5169
+ const resolved = cursor === candidate
5150
5170
  ? resolvedAncestor
5151
- : external_node_path_namespaceObject.resolve(resolvedAncestor, `.${external_node_path_namespaceObject.sep}${normalized.slice(cursor.length)}`);
5171
+ : external_node_path_namespaceObject.resolve(resolvedAncestor, `.${external_node_path_namespaceObject.sep}${suffix}`);
5152
5172
  windows_path_alias_assertNoWindowsPathAlias(resolved);
5153
5173
  return resolved;
5154
5174
  }
5155
- function resolveSymlinkHopPath(symlinkPath, mode, rejectUnresolved) {
5175
+ function resolveSymlinkHopPath(symlinkPath, mode, rejectUnresolved, remainingHops = 64) {
5156
5176
  try {
5157
- const canonicalize = mode === "native" ? realpath_realpathSync.native : realpath_realpathSync;
5177
+ const canonicalize = realpath_realpathSync.native;
5158
5178
  const rawRealPath = canonicalize(symlinkPath);
5159
5179
  windows_path_alias_assertNoWindowsPathAlias(rawRealPath, "filesystem", "resolved symlink path uses a Windows filesystem namespace alias");
5160
5180
  const realPath = windows_path_alias_resolvePathPreservingWindowsRoot(rawRealPath);
@@ -5167,11 +5187,16 @@ function resolveSymlinkHopPath(symlinkPath, mode, rejectUnresolved) {
5167
5187
  }
5168
5188
  if (!path_isNotFoundPathError(error))
5169
5189
  throw error;
5190
+ if (remainingHops <= 0)
5191
+ throw new errors_FsSafeError("symlink", "too many unresolved symlink hops");
5170
5192
  const linkTarget = external_node_fs_namespaceObject.readlinkSync(symlinkPath);
5171
5193
  windows_path_alias_assertNoWindowsPathAlias(linkTarget, "filesystem", "symlink target uses a Windows filesystem namespace alias");
5172
5194
  const linkDir = windows_path_alias_resolvePathPreservingWindowsRoot(external_node_path_namespaceObject.dirname(symlinkPath));
5173
- const targetPath = windows_path_alias_resolvePathFromBasePreservingWindowsRoot(linkDir, linkTarget);
5174
- const resolved = resolveExistingAncestor(targetPath, mode);
5195
+ // Keep parent segments until the kernel has resolved the existing prefix.
5196
+ const targetPath = external_node_path_namespaceObject.isAbsolute(linkTarget) ? linkTarget
5197
+ : external_node_path_namespaceObject.parse(linkTarget).root ? windows_path_alias_resolvePathFromBasePreservingWindowsRoot(linkDir, linkTarget)
5198
+ : `${linkDir}${external_node_path_namespaceObject.sep}${linkTarget}`;
5199
+ const resolved = resolveExistingAncestor(targetPath, mode, true, remainingHops - 1);
5175
5200
  windows_path_alias_assertNoWindowsPathAlias(resolved, "filesystem", "resolved symlink path uses a Windows filesystem namespace alias");
5176
5201
  return resolved;
5177
5202
  }
@@ -9160,8 +9185,8 @@ function assertResolvedLinkDirectory(pathname, isLast) {
9160
9185
  const stat = external_node_fs_namespaceObject.statSync(windows_path_alias_pathForWindowsFilesystem(pathname));
9161
9186
  assertDirectoryBeforeMoreSegments(stat, pathname, isLast);
9162
9187
  }
9163
- // Both public APIs use synchronous metadata; only canonicalization and ancestor
9164
- // existence differ. Promise wrappers preserve the asynchronous rejection API.
9188
+ // Both public APIs use kernel canonicalization and synchronous metadata; only
9189
+ // ancestor existence differs. Promise wrappers preserve asynchronous rejection.
9165
9190
  function traverseRootPath(params, { mode = "native", observation: observationOutput, observeRoot, removalReceipts }) {
9166
9191
  const input = captureValidRootPathInputs(params);
9167
9192
  const rawAbsolutePath = absolutePathWithRawSegments(input.absolutePath);
@@ -17151,7 +17176,7 @@ function directoryChangedError(error) {
17151
17176
  return error;
17152
17177
  return new errors_FsSafeError("path-mismatch", "directory changed during operation", errorCauseOptions(error));
17153
17178
  }
17154
- async function assertRootDirectoryObservationGuard(root, guard) {
17179
+ async function assertRootDirectoryObservationGuard(root, guard, backend) {
17155
17180
  if (isNativeDirectoryObservationGuard(guard)) {
17156
17181
  throw new errors_FsSafeError("path-mismatch", "native directory observation cannot be revalidated");
17157
17182
  }
@@ -17160,7 +17185,9 @@ async function assertRootDirectoryObservationGuard(root, guard) {
17160
17185
  identity.dev === root.rootIdentity.dev && identity.ino === root.rootIdentity.ino;
17161
17186
  if (guardPinsRoot) {
17162
17187
  try {
17163
- if ("identity" in guard)
17188
+ if (backend && "identity" in guard)
17189
+ assertReceiptDirectoryGuardSync(root, guard, backend);
17190
+ else if ("identity" in guard)
17164
17191
  assertDirectoryObservationGuardSync(guard);
17165
17192
  else
17166
17193
  await assertAsyncDirectoryGuard(guard);
@@ -17183,7 +17210,9 @@ async function assertRootDirectoryObservationGuard(root, guard) {
17183
17210
  await assertRootIdentityCurrent(root);
17184
17211
  }
17185
17212
  try {
17186
- if ("identity" in guard)
17213
+ if (backend && "identity" in guard)
17214
+ assertReceiptDirectoryGuardSync(root, guard, backend);
17215
+ else if ("identity" in guard)
17187
17216
  assertDirectoryObservationGuardSync(guard);
17188
17217
  else
17189
17218
  await assertAsyncDirectoryGuard(guard);
@@ -17337,12 +17366,15 @@ async function openRootDirectoryListing(root, directory, options, receipt) {
17337
17366
  identity: { dev: admitted.stat.dev, ino: admitted.stat.ino },
17338
17367
  }, admitted.dir, admitted.realPath);
17339
17368
  }
17369
+ // Windows watch listings keep every fence while sharing one handle for its
17370
+ // identity/path queries. POSIX pathname checks are cheaper than this helper.
17371
+ const backend = getNativeDirectoryObservationBackend(options.exactIdentity === true && process.platform === "win32");
17340
17372
  const assertCurrent = async () => {
17341
17373
  options.signal?.throwIfAborted();
17342
17374
  if (receipt)
17343
17375
  assertRootPathObservationReceiptCurrent(root, receipt);
17344
17376
  else
17345
- await assertRootDirectoryObservationGuard(root, guard);
17377
+ await assertRootDirectoryObservationGuard(root, guard, backend);
17346
17378
  options.signal?.throwIfAborted();
17347
17379
  };
17348
17380
  const paths = { directory: guard.realPath, names: new Map() };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lousy-agents/agent-shell",
3
- "version": "5.22.6",
3
+ "version": "5.22.8",
4
4
  "description": "A flight recorder for npm script execution",
5
5
  "type": "module",
6
6
  "repository": {
@@ -37,7 +37,7 @@
37
37
  "typecheck": "tsc --noEmit"
38
38
  },
39
39
  "dependencies": {
40
- "@openclaw/fs-safe": "0.26.6",
40
+ "@openclaw/fs-safe": "0.26.7",
41
41
  "zod": "4.5.2"
42
42
  },
43
43
  "peerDependencies": {