claude_cli: offer codemode to claude (codemode = true), hx tools inside it ask via the permission bridge
This commit is contained in:
1 parent
785effef11
commit
fdeaaf5cf2
4 files changed
+111
-27
No files matched your search
@@ -15,9 +15,15 @@ if "--permission-prompt-tool" in sys.argv: # act like claude: ask hx whether `r
|
||||
{"tool_name": "Bash", "input": {"command": "rm -rf x"}}}}
|
||||
p.stdin.write(json.dumps({"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {}}) + "\n" + json.dumps(call) + "\n")
|
||||
p.stdin.flush()
|
||||
lines = [json.loads(p.stdout.readline()) for _ in range(2)]
|
||||
cm = {"jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": {"name": "codemode", "arguments":
|
||||
{"script": "return await tools.bash({command: 'echo cm-' + 'ok > cm.txt; cat cm.txt'})"}}}
|
||||
if "HX_CODEMODE" in cfg["env"]:
|
||||
p.stdin.write(json.dumps(cm) + "\n"); p.stdin.flush()
|
||||
lines = [json.loads(p.stdout.readline()) for _ in range(2 + ("HX_CODEMODE" in cfg["env"]))]
|
||||
p.stdin.close()
|
||||
reply = "approve: " + json.loads(lines[1]["result"]["content"][0]["text"])["behavior"]
|
||||
if len(lines) == 3:
|
||||
reply += " " + lines[2]["result"]["content"][0]["text"]
|
||||
out({"type": "system", "subtype": "init", "session_id": "S1"})
|
||||
ev = lambda e: out({"type": "stream_event", "session_id": "S1", "event": e})
|
||||
ev({"type": "content_block_start", "content_block": {"type": "tool_use", "name": "Read"}})
|
||||
|
||||
Reference in new issue
Block a user