claude_cli: tool calls on the event bus, extensions can block, permissions deny/extensions-only (#182)
This commit is contained in:
1 parent
6ebf1c3180
commit
6978aad27a
12 files changed
+297
-12
No files matched your search
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Test extension: subscribes to tool_call, blocks `read` of secrets and `bash` curl."""
|
||||
import json, sys
|
||||
for line in sys.stdin:
|
||||
m = json.loads(line)
|
||||
if m["method"] == "initialize":
|
||||
r = {"subscribe": ["tool_call"], "tools": []}
|
||||
else:
|
||||
e = m["params"]["event"]
|
||||
bad = (e["name"] == "read" and ".ssh" in e["args"]["path"]) or (e["name"] == "bash" and "curl" in e["args"]["command"])
|
||||
r = {"action": "block", "reason": "guard: " + e["name"]} if bad else {"action": "continue"}
|
||||
print(json.dumps({"jsonrpc": "2.0", "id": m["id"], "result": r}), flush=True)
|
||||
Reference in new issue
Block a user