claude-bridge-cli 2.0.11 → 2.0.12
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.
- package/lib/bridge.js +20 -2
- package/package.json +1 -1
package/lib/bridge.js
CHANGED
|
@@ -675,11 +675,19 @@ function askClaude(config, { prompt, session_id, images, cwd, plan_mode, allow_t
|
|
|
675
675
|
fs.writeFileSync(tmpFile, finalPrompt, "utf8");
|
|
676
676
|
}
|
|
677
677
|
|
|
678
|
+
// Allow list — the caller (extension) can override via `allow_tools`, e.g.
|
|
679
|
+
// after the user clicks "Allow <tool>" on a permission denial, so an MCP
|
|
680
|
+
// tool (mcp__server__tool) or any other non-default tool can be granted for
|
|
681
|
+
// the session. Falls back to the default working set. Mirrors the Python
|
|
682
|
+
// bridge so both behave identically.
|
|
683
|
+
const defaultAllow = ["Read", "Write", "Edit", "Bash", "Grep", "Glob", "WebFetch", "WebSearch",
|
|
684
|
+
"Task", "TaskCreate", "TaskList", "TaskGet", "TaskUpdate", "NotebookEdit"];
|
|
685
|
+
const allow = (Array.isArray(allow_tools) && allow_tools.length &&
|
|
686
|
+
allow_tools.every(x => typeof x === "string")) ? allow_tools : defaultAllow;
|
|
678
687
|
const settings = JSON.stringify({
|
|
679
688
|
permissions: {
|
|
680
689
|
defaultMode: "acceptEdits",
|
|
681
|
-
allow
|
|
682
|
-
"Task", "TaskCreate", "TaskList", "TaskGet", "TaskUpdate", "NotebookEdit"],
|
|
690
|
+
allow,
|
|
683
691
|
deny: ["AskUserQuestion"],
|
|
684
692
|
}
|
|
685
693
|
});
|
|
@@ -751,12 +759,22 @@ function askClaude(config, { prompt, session_id, images, cwd, plan_mode, allow_t
|
|
|
751
759
|
const newDir = path.join(dataDir(), "images", sid);
|
|
752
760
|
try { fs.renameSync(oldDir, newDir); } catch {}
|
|
753
761
|
}
|
|
762
|
+
// Surface tool-permission denials so the extension can show an "Allow
|
|
763
|
+
// <tool>" button (then resend with allow_tools including it). Without
|
|
764
|
+
// this, a tool that needs approval — notably any MCP tool, which isn't
|
|
765
|
+
// in the default allow list — silently fails with no way to grant it in
|
|
766
|
+
// headless -p mode. Mirrors the Python bridge's shape.
|
|
767
|
+
const rawDenials = Array.isArray(result.permission_denials) ? result.permission_denials : [];
|
|
768
|
+
const permission_denials = rawDenials
|
|
769
|
+
.filter(x => x && typeof x === "object")
|
|
770
|
+
.map(x => ({ tool_name: x.tool_name || "?", tool_input: x.tool_input || {} }));
|
|
754
771
|
resolve({
|
|
755
772
|
response: result.result || result.assistantMessage || stdout.slice(0, 5000),
|
|
756
773
|
session_id: sid,
|
|
757
774
|
cost_usd: result.cost_usd || null,
|
|
758
775
|
duration_ms: result.duration_ms || null,
|
|
759
776
|
context: result.context || null,
|
|
777
|
+
permission_denials,
|
|
760
778
|
});
|
|
761
779
|
} catch {
|
|
762
780
|
if (stdout.trim()) {
|
package/package.json
CHANGED