opencode-landstrip 0.19.8 → 0.19.10

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 (3) hide show
  1. package/index.ts +31 -27
  2. package/package.json +3 -3
  3. package/shared.ts +3 -35
package/index.ts CHANGED
@@ -5,10 +5,9 @@ import type { Plugin } from '@opencode/plugin';
5
5
 
6
6
  import { randomBytes } from 'node:crypto';
7
7
  import { spawnSync } from 'node:child_process';
8
- import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
8
+ import { rmSync } from 'node:fs';
9
9
  import { type AddressInfo, connect as connectNet, createServer } from 'node:net';
10
- import { tmpdir } from 'node:os';
11
- import { basename, join } from 'node:path';
10
+ import { basename } from 'node:path';
12
11
 
13
12
  import {
14
13
  createProxyCredentials,
@@ -38,7 +37,7 @@ import {
38
37
  normalizeOptions,
39
38
  parseLandstripTraps,
40
39
  readDiscoveryPort,
41
- serializeLandstripPolicy,
40
+ writeLandstripPolicyFile,
42
41
  trapSessionHelloLine,
43
42
  } from './shared.js';
44
43
 
@@ -210,21 +209,15 @@ function writePolicyFile(
210
209
  baseDirectory: string,
211
210
  proxyPort: number | null,
212
211
  ): { dir: string; path: string } {
213
- const dir = mkdtempSync(join(tmpdir(), 'opencode-landstrip-'));
214
- const path = join(dir, 'policy.json');
215
- writeFileSync(
216
- path,
217
- serializeLandstripPolicy(
218
- buildLandstripPolicy({
219
- network: config.network,
220
- filesystem: config.filesystem,
221
- baseDirectory,
222
- httpProxyPort: proxyPort,
223
- }),
224
- ),
212
+ return writeLandstripPolicyFile(
213
+ buildLandstripPolicy({
214
+ network: config.network,
215
+ filesystem: config.filesystem,
216
+ baseDirectory,
217
+ httpProxyPort: proxyPort,
218
+ }),
219
+ 'opencode-landstrip-',
225
220
  );
226
-
227
- return { dir, path };
228
221
  }
229
222
 
230
223
  function proxyEnv(
@@ -491,7 +484,7 @@ function evaluateToolPermissions(
491
484
  );
492
485
  }
493
486
 
494
- if (tool === 'apply_patch' && typeof args.patchText === 'string') {
487
+ if ((tool === 'patch' || tool === 'apply_patch') && typeof args.patchText === 'string') {
495
488
  return extractPatchPaths(args.patchText).map((path) =>
496
489
  evaluateWritePermission(path, config, baseDirectory, effectiveAllowWrite),
497
490
  );
@@ -873,14 +866,25 @@ const plugin: Plugin.Plugin = {
873
866
  const state = activeBash.get(event.id);
874
867
  if (!state) return;
875
868
 
876
- const outputText =
877
- event.status === 'completed'
878
- ? typeof event.result.output === 'string'
879
- ? event.result.output
880
- : typeof event.result.content === 'string'
881
- ? event.result.content
882
- : ''
883
- : '';
869
+ let outputText = '';
870
+ if (event.status === 'completed') {
871
+ const { output, content } = event.result;
872
+ if (typeof output === 'string') {
873
+ outputText = output;
874
+ } else if (isRecord(output) && typeof output.output === 'string') {
875
+ outputText = output.output;
876
+ } else if (typeof content === 'string') {
877
+ outputText = content;
878
+ } else if (Array.isArray(content)) {
879
+ outputText = content
880
+ .flatMap((part) =>
881
+ isRecord(part) && part.type === 'text' && typeof part.text === 'string'
882
+ ? [part.text]
883
+ : [],
884
+ )
885
+ .join('\n');
886
+ }
887
+ }
884
888
  const serverTrapOutput = state.trapLines.join('\n');
885
889
  const combinedOutput = serverTrapOutput ? outputText + '\n' + serverTrapOutput : outputText;
886
890
  const traps = parseLandstripTraps(combinedOutput);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-landstrip",
3
- "version": "0.19.8",
3
+ "version": "0.19.10",
4
4
  "description": "OS-level AI command sandboxing for OpenCode with Landstrip",
5
5
  "keywords": [
6
6
  "landlock",
@@ -48,7 +48,7 @@
48
48
  "ci:test": "npm test"
49
49
  },
50
50
  "dependencies": {
51
- "@landstrip/landstrip-api": "^0.19.8",
51
+ "@landstrip/landstrip-api": "^0.19.10",
52
52
  "@opentui/core": ">=0.5.12",
53
53
  "@opentui/solid": ">=0.5.12",
54
54
  "solid-js": "1.9.12"
@@ -57,7 +57,7 @@
57
57
  "@opencode/plugin": "^2.0.18",
58
58
  "@opencode/theme": "^2.0.18",
59
59
  "@types/node": "^26.1.1",
60
- "oxfmt": "^0.71.0",
60
+ "oxfmt": "^0.72.0",
61
61
  "oxlint": "^1.68.0",
62
62
  "typescript": "^5.9.3"
63
63
  },
package/shared.ts CHANGED
@@ -41,6 +41,7 @@ export {
41
41
  sessionAllows,
42
42
  sessionScopeFor,
43
43
  serializeLandstripPolicy,
44
+ writeLandstripPolicyFile,
44
45
  deepMergeSandboxConfig,
45
46
  mergeArray,
46
47
  parseSandboxConfig,
@@ -79,16 +80,6 @@ import { dirname, isAbsolute, join } from 'node:path';
79
80
 
80
81
  const packageDir = dirname(fileURLToPath(import.meta.url));
81
82
 
82
- const LANDSTRIP_PACKAGE_NAMES = new Set([
83
- '@landstrip/landstrip-api',
84
- '@landstrip/landstrip-darwin-arm64',
85
- '@landstrip/landstrip-darwin-x64',
86
- '@landstrip/landstrip-linux-x64',
87
- '@landstrip/landstrip-linux-arm64',
88
- '@landstrip/landstrip-win32-x64',
89
- '@landstrip/landstrip-win32-arm64',
90
- ]);
91
-
92
83
  export function normalizeConfig(value: unknown): SandboxConfigOverrides {
93
84
  return parseSandboxConfig(value);
94
85
  }
@@ -179,31 +170,8 @@ export function landstripBinaryPath(): string {
179
170
  if (_landstripBinaryPathError !== undefined) throw _landstripBinaryPathError;
180
171
 
181
172
  try {
182
- const filePath = realpathSync.native(binaryPath());
183
- let probe = dirname(filePath);
184
-
185
- while (true) {
186
- const manifestPath = join(probe, 'package.json');
187
- if (existsSync(manifestPath)) {
188
- try {
189
- const manifest = JSON.parse(readFileSync(manifestPath, 'utf-8')) as unknown;
190
- if (isRecord(manifest) && LANDSTRIP_PACKAGE_NAMES.has(String(manifest.name))) {
191
- _landstripBinaryPath = filePath;
192
- return filePath;
193
- }
194
- } catch {
195
- // malformed package.json — continue walking to parent
196
- }
197
- }
198
-
199
- const parent = dirname(probe);
200
- if (parent === probe) break;
201
- probe = parent;
202
- }
203
-
204
- throw new Error(
205
- `Refusing to use landstrip binary outside official @landstrip/landstrip-api packages: ${filePath}`,
206
- );
173
+ _landstripBinaryPath = binaryPath();
174
+ return _landstripBinaryPath;
207
175
  } catch (error) {
208
176
  _landstripBinaryPathError = error;
209
177
  throw error;