pi-landstrip 0.20.11 → 0.20.13

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.ts +26 -10
  2. package/package.json +2 -2
package/dist/index.ts CHANGED
@@ -40,6 +40,7 @@ import {
40
40
  isRecord as isRecord3,
41
41
  isQueryTrap,
42
42
  matchesPathPattern,
43
+ matchesWriteDenyPattern,
43
44
  mergeArray,
44
45
  parseLandstripTraps,
45
46
  parseSandboxConfig,
@@ -6947,7 +6948,8 @@ function createLandstripIntegrationWithPrompts(options, permissionPrompts) {
6947
6948
  if (!config.enabled)
6948
6949
  return { allowed: true, prompted: false };
6949
6950
  for (const access of normalized) {
6950
- if (matchesPattern(access.path, access.operation === "read" ? config.filesystem.denyReadAlways : mergeArray(config.filesystem.denyWriteAlways, config.filesystem.denyWrite), ctx.cwd)) {
6951
+ const denied = access.operation === "read" ? matchesPattern(access.path, config.filesystem.denyReadAlways, ctx.cwd) : matchesWriteDenyPattern(access.path, mergeArray(config.filesystem.denyWriteAlways, config.filesystem.denyWrite), ctx.cwd, getEffectiveAllowWrite(config));
6952
+ if (denied) {
6951
6953
  return {
6952
6954
  allowed: false,
6953
6955
  prompted: false,
@@ -7101,7 +7103,7 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
7101
7103
  ...[...allowances.explicitDenyRead.globRoots.values()].flat()
7102
7104
  ]), cwd, { requireAllowMatch: true }) ? { action: "allow" } : undefined;
7103
7105
  }
7104
- if (trap.operation === "write" && (matchesPattern(path, config.filesystem.denyWriteAlways, cwd) || matchesPattern(path, config.filesystem.denyWrite, cwd))) {
7106
+ if (trap.operation === "write" && (matchesWriteDenyPattern(path, config.filesystem.denyWriteAlways, cwd, getEffectiveAllowWrite(config, allowances)) || matchesWriteDenyPattern(path, config.filesystem.denyWrite, cwd, getEffectiveAllowWrite(config, allowances)))) {
7105
7107
  return { action: "deny", reason: "hard-deny" };
7106
7108
  }
7107
7109
  const allowed = trap.operation === "read" ? readAllowed(path, getEffectiveAllowRead(config, cwd, allowances), getEffectiveDenyRead(config, cwd), cwd) : !shouldPromptForWrite(path, getEffectiveAllowWrite(config, allowances), cwd);
@@ -7764,9 +7766,19 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
7764
7766
  if (!ctx.hasUI)
7765
7767
  return null;
7766
7768
  const { globalPath, projectPath } = getPiConfigPaths(ctx.cwd, "sandbox.json");
7769
+ const writeDeniedBy = (config) => {
7770
+ const writeRoots = getEffectiveAllowWrite(config, allowances);
7771
+ if (matchesWriteDenyPattern(blockedPath, config.filesystem.denyWriteAlways, ctx.cwd, writeRoots)) {
7772
+ return "denyWriteAlways";
7773
+ }
7774
+ if (matchesWriteDenyPattern(blockedPath, config.filesystem.denyWrite, ctx.cwd, writeRoots)) {
7775
+ return "denyWrite";
7776
+ }
7777
+ return null;
7778
+ };
7767
7779
  const current = () => {
7768
7780
  const config = loadConfig(ctx.cwd);
7769
- if (matchesPattern(blockedPath, operation === "read" ? config.filesystem.denyReadAlways : mergeArray(config.filesystem.denyWriteAlways, config.filesystem.denyWrite), ctx.cwd)) {
7781
+ if (operation === "read" ? matchesPattern(blockedPath, config.filesystem.denyReadAlways, ctx.cwd) : writeDeniedBy(config) !== null) {
7770
7782
  return false;
7771
7783
  }
7772
7784
  const needsPrompt = operation === "read" ? !readAllowed(blockedPath, getEffectiveAllowRead(config, ctx.cwd, allowances), getEffectiveDenyRead(config, ctx.cwd), ctx.cwd) : shouldPromptForWrite(blockedPath, getEffectiveAllowWrite(config, allowances), ctx.cwd);
@@ -7786,21 +7798,25 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
7786
7798
  }, signal);
7787
7799
  if (!access) {
7788
7800
  const config = loadConfig(ctx.cwd);
7789
- if (operation === "write" && (matchesPattern(blockedPath, config.filesystem.denyWriteAlways, ctx.cwd) || matchesPattern(blockedPath, config.filesystem.denyWrite, ctx.cwd))) {
7790
- const tier = matchesPattern(blockedPath, config.filesystem.denyWriteAlways, ctx.cwd) ? "denyWriteAlways" : "denyWrite";
7791
- notify(ctx, `"${blockedPath}" is blocked by ${tier}. Check:
7801
+ if (operation === "write") {
7802
+ const tier = writeDeniedBy(config);
7803
+ if (tier) {
7804
+ notify(ctx, `"${blockedPath}" is blocked by ${tier}. Check:
7792
7805
  ${projectPath}
7793
7806
  ${globalPath}`, "warning");
7807
+ }
7794
7808
  }
7795
7809
  return null;
7796
7810
  }
7797
7811
  let config = loadConfig(ctx.cwd);
7798
- if (operation === "write" && (matchesPattern(blockedPath, config.filesystem.denyWriteAlways, ctx.cwd) || matchesPattern(blockedPath, config.filesystem.denyWrite, ctx.cwd))) {
7799
- const tier = matchesPattern(blockedPath, config.filesystem.denyWriteAlways, ctx.cwd) ? "denyWriteAlways" : "denyWrite";
7800
- notify(ctx, `"${blockedPath}" was added to allowWrite, but ${tier} still blocks it. Check:
7812
+ if (operation === "write") {
7813
+ const tier = writeDeniedBy(config);
7814
+ if (tier) {
7815
+ notify(ctx, `"${blockedPath}" was added to allowWrite, but ${tier} still blocks it. Check:
7801
7816
  ${projectPath}
7802
7817
  ${globalPath}`, "warning");
7803
- return null;
7818
+ return null;
7819
+ }
7804
7820
  }
7805
7821
  onUpdate?.({
7806
7822
  content: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-landstrip",
3
- "version": "0.20.11",
3
+ "version": "0.20.13",
4
4
  "description": "Sandboxed Bash and process-backed agents for Pi",
5
5
  "keywords": [
6
6
  "landstrip",
@@ -39,7 +39,7 @@
39
39
  "ci:test": "npm run test"
40
40
  },
41
41
  "dependencies": {
42
- "@landstrip/landstrip-api": "^0.20.11",
42
+ "@landstrip/landstrip-api": "^0.20.13",
43
43
  "jsonc-parser": "^3.3.1",
44
44
  "minimatch": "^10.2.5",
45
45
  "undici": "^8.9.0",