@lousy-agents/agent-shell 5.22.18 → 5.22.20

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 +30 -10
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -129,6 +129,7 @@ const OPERATIONAL_CODE_VALUES = [
129
129
  "not-empty",
130
130
  "not-found",
131
131
  "not-removable",
132
+ "permission-denied",
132
133
  "permission-unverified",
133
134
  "read-failed",
134
135
  "timeout",
@@ -1681,6 +1682,15 @@ function fileNotFoundError(cause, details) {
1681
1682
  function root_errors_outsideWorkspaceError() {
1682
1683
  return new errors_FsSafeError("outside-workspace", "file is outside workspace root");
1683
1684
  }
1685
+ /** Classify raw traversal denials without disguising an established policy failure. */
1686
+ function pathTraversalPermissionError(error, targetPath) {
1687
+ if (error instanceof errors_FsSafeError)
1688
+ return error.code === "permission-denied" ? error : undefined;
1689
+ if (!hasNodeErrorCode(error, "EACCES") && !hasNodeErrorCode(error, "EPERM"))
1690
+ return;
1691
+ const deniedPath = path_isNodeError(error) && typeof error.path === "string" ? error.path : targetPath;
1692
+ return new errors_FsSafeError("permission-denied", `permission denied while resolving ${deniedPath}`, errorCauseOptions(error));
1693
+ }
1684
1694
  function rootPathChangedError(cause) {
1685
1695
  return new errors_FsSafeError("path-mismatch", "root path changed during operation", { cause });
1686
1696
  }
@@ -9605,6 +9615,9 @@ async function resolvePathInRoot(root, relativePath, options) {
9605
9615
  }
9606
9616
  }
9607
9617
  catch (error) {
9618
+ const permissionError = pathTraversalPermissionError(error, rawAbsolutePath);
9619
+ if (permissionError)
9620
+ throw permissionError;
9608
9621
  if (error instanceof errors_FsSafeError && error.code === "symlink") {
9609
9622
  throw error;
9610
9623
  }
@@ -12065,6 +12078,9 @@ async function resolveGuardedWritePathInRoot(root, params) {
12065
12078
  });
12066
12079
  }
12067
12080
  catch (error) {
12081
+ const permissionError = pathTraversalPermissionError(error, resolvedPath.resolved);
12082
+ if (permissionError)
12083
+ throw permissionError;
12068
12084
  throw new errors_FsSafeError("path-alias", "path alias escape blocked", errorCauseOptions(error));
12069
12085
  }
12070
12086
  }
@@ -14109,7 +14125,6 @@ async function removeStaleSidecarLockIfAllowed(params) {
14109
14125
  }
14110
14126
 
14111
14127
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/sidecar-lock-policy.js
14112
-
14113
14128
  const sidecar_lock_policy_MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
14114
14129
  function assertFiniteNonNegative(value, label) {
14115
14130
  if (!Number.isFinite(value) || value < 0) {
@@ -14211,16 +14226,16 @@ function sidecarLockPayloadCreatedAtMs(payload) {
14211
14226
  const createdAtMs = Date.parse(createdAt);
14212
14227
  return Number.isFinite(createdAtMs) ? createdAtMs : null;
14213
14228
  }
14214
- async function defaultSidecarLockShouldReclaim(params) {
14215
- const createdAtMs = sidecarLockPayloadCreatedAtMs(params.payload);
14229
+ function defaultSidecarLockShouldReclaim(snapshot, staleMs, nowMs) {
14230
+ const createdAtMs = sidecarLockPayloadCreatedAtMs(snapshot.payload);
14216
14231
  if (createdAtMs !== null)
14217
- return params.nowMs - createdAtMs > params.staleMs;
14218
- try {
14219
- return params.nowMs - external_node_fs_namespaceObject.statSync(params.lockPath).mtimeMs > params.staleMs;
14220
- }
14221
- catch {
14232
+ return nowMs - createdAtMs > staleMs;
14233
+ if (!snapshot.stat)
14222
14234
  return true;
14223
- }
14235
+ // A released pathname may already name another owner; age only the admitted record.
14236
+ const mtimeMs = "mtimeNs" in snapshot.stat
14237
+ ? Number(snapshot.stat.mtimeNs) / 1e6 : snapshot.stat.mtimeMs;
14238
+ return nowMs - mtimeMs > staleMs;
14224
14239
  }
14225
14240
 
14226
14241
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/sidecar-lock-admission-parser.js
@@ -14438,12 +14453,14 @@ async function handleStaleSidecarAdmission(params) {
14438
14453
  return;
14439
14454
  throw error;
14440
14455
  }
14441
- const shouldReclaim = staleOptions.shouldReclaim ?? defaultSidecarLockShouldReclaim;
14456
+ const shouldReclaim = staleOptions.shouldReclaim;
14442
14457
  let reclaim;
14443
14458
  try {
14444
14459
  reclaim = await admission.run(async () => {
14445
14460
  assertUnheld();
14446
14461
  try {
14462
+ if (!shouldReclaim)
14463
+ return defaultSidecarLockShouldReclaim(snapshot, params.staleMs, Date.now());
14447
14464
  return await Reflect.apply(shouldReclaim, undefined, [{
14448
14465
  lockPath,
14449
14466
  normalizedTargetPath,
@@ -21182,6 +21199,9 @@ async function resolvePinnedRootPathInRoot(root, params) {
21182
21199
  resolved = await (params.removalReceipts ? resolveRootPathForRemoval(resolution, params.removalReceipts) : root_path_resolveRootPath(resolution));
21183
21200
  }
21184
21201
  catch (err) {
21202
+ const permissionError = pathTraversalPermissionError(err, params.relativePath);
21203
+ if (permissionError)
21204
+ throw permissionError;
21185
21205
  if (err instanceof errors_FsSafeError && err.code === "symlink")
21186
21206
  throw err;
21187
21207
  throw new errors_FsSafeError("path-alias", "path alias escape blocked", { cause: err });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lousy-agents/agent-shell",
3
- "version": "5.22.18",
3
+ "version": "5.22.20",
4
4
  "description": "A flight recorder for npm script execution",
5
5
  "type": "module",
6
6
  "repository": {
@@ -37,11 +37,11 @@
37
37
  "typecheck": "tsc --noEmit"
38
38
  },
39
39
  "dependencies": {
40
- "@openclaw/fs-safe": "0.26.13",
40
+ "@openclaw/fs-safe": "0.26.14",
41
41
  "zod": "4.6.6"
42
42
  },
43
43
  "peerDependencies": {
44
- "@github/copilot-sdk": "1.0.26"
44
+ "@github/copilot-sdk": "1.0.28"
45
45
  },
46
46
  "peerDependenciesMeta": {
47
47
  "@github/copilot-sdk": {