opencode-sandbox 0.1.2 → 0.1.4

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 +10 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -91,6 +91,7 @@ var SandboxPlugin = async ({ directory, worktree }) => {
91
91
  }
92
92
  if (!sandboxReady)
93
93
  return {};
94
+ let lastOriginalCommand;
94
95
  return {
95
96
  "tool.execute.before": async (input, output) => {
96
97
  if (input.tool !== "bash")
@@ -98,6 +99,7 @@ var SandboxPlugin = async ({ directory, worktree }) => {
98
99
  const command = output.args?.command;
99
100
  if (typeof command !== "string" || !command)
100
101
  return;
102
+ lastOriginalCommand = command;
101
103
  try {
102
104
  output.args.command = await SandboxManager.wrapWithSandbox(command);
103
105
  } catch (err) {
@@ -109,14 +111,18 @@ var SandboxPlugin = async ({ directory, worktree }) => {
109
111
  return;
110
112
  const text = output.output ?? "";
111
113
  if (text.includes("Operation not permitted") || text.includes("Connection blocked by network allowlist")) {
112
- const annotation = text + `
114
+ const message = "⚠️ [opencode-sandbox] Command blocked or partially blocked by sandbox restrictions. " + "Adjust config in .opencode/sandbox.json or OPENCODE_SANDBOX_CONFIG.";
115
+ output.output = text + `
113
116
 
114
- ⚠️ [opencode-sandbox] Command blocked or partially blocked by sandbox restrictions. ` + "Adjust config in .opencode/sandbox.json or OPENCODE_SANDBOX_CONFIG.";
115
- output.output = annotation;
117
+ ` + message;
116
118
  if (output.metadata && typeof output.metadata.output === "string") {
117
- output.metadata.output = annotation;
119
+ output.metadata.output = message;
118
120
  }
119
121
  }
122
+ if (lastOriginalCommand && input.args && typeof input.args.command === "string") {
123
+ input.args.command = lastOriginalCommand;
124
+ lastOriginalCommand = undefined;
125
+ }
120
126
  }
121
127
  };
122
128
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-sandbox",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "OpenCode plugin that sandboxes agent commands using @anthropic-ai/sandbox-runtime (seatbelt on macOS, bubblewrap on Linux)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",