opencode-landstrip 0.16.7 → 0.16.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/index.ts +15 -13
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -267,9 +267,10 @@ function extractBlockedPath(
267
267
  }
268
268
  }
269
269
 
270
- // If landstrip reported a trap but without a path, try to
271
- // extract the blocked path from the command itself
272
- if (landstripTraps.length > 0 && command) {
270
+ if (
271
+ landstripTraps.some((trap) => trap.kind === 'filesystem' || trap.kind === 'internal') &&
272
+ command
273
+ ) {
273
274
  for (const candidate of extractCandidatePaths(command)) {
274
275
  const resolved = canonicalizePath(candidate, baseDirectory);
275
276
  return resolved;
@@ -279,14 +280,6 @@ function extractBlockedPath(
279
280
  return null;
280
281
  }
281
282
 
282
- function extractBlockedWritePath(
283
- output: string,
284
- baseDirectory: string,
285
- command?: string,
286
- ): string | null {
287
- return extractBlockedPath(output, baseDirectory, command);
288
- }
289
-
290
283
  function evaluateReadPermission(
291
284
  path: string,
292
285
  config: SandboxConfig,
@@ -652,6 +645,15 @@ function socketQueryPort(baseDirectory: string): number | null {
652
645
  return readDiscoveryPort(baseDirectory);
653
646
  }
654
647
 
648
+ async function awaitQueryPort(baseDirectory: string): Promise<number | null> {
649
+ for (let attempt = 0; attempt < 5; attempt++) {
650
+ const port = socketQueryPort(baseDirectory);
651
+ if (port !== null) return port;
652
+ await new Promise((resolve) => setTimeout(resolve, 50));
653
+ }
654
+ return null;
655
+ }
656
+
655
657
  function buildWrappedCommand(
656
658
  policyPath: string,
657
659
  shell: string,
@@ -1062,7 +1064,7 @@ const plugin: Plugin = async ({ client, directory }: PluginInput, options?: Plug
1062
1064
  policy.path,
1063
1065
  configuredShell ?? process.env.SHELL ?? '/bin/sh',
1064
1066
  originalCommand,
1065
- socketQueryPort(directory),
1067
+ await awaitQueryPort(directory),
1066
1068
  );
1067
1069
 
1068
1070
  activeBash.set(callID, {
@@ -1239,7 +1241,7 @@ const plugin: Plugin = async ({ client, directory }: PluginInput, options?: Plug
1239
1241
  ?.catch?.(() => undefined);
1240
1242
  }
1241
1243
 
1242
- const blockedPath = extractBlockedWritePath(outputText, directory, state.originalCommand);
1244
+ const blockedPath = extractBlockedPath(outputText, directory, state.originalCommand);
1243
1245
  if (blockedPath) {
1244
1246
  await notifyOnce(
1245
1247
  `blocked:${blockedPath}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-landstrip",
3
- "version": "0.16.7",
3
+ "version": "0.16.8",
4
4
  "description": "Landlock-based sandboxing for opencode with landstrip",
5
5
  "keywords": [
6
6
  "landlock",