feat: add --schema, --max-turns and rpc --ask
- hx -p --schema <file> validates the final answer against a JSON schema, with one retry that includes the validation errors - max_turns config key and --max-turns cap the main agent's model calls - hx --mode rpc --ask sends permission requests to the client instead of auto-allowing bash/write/edit calls Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
13d914c8c0
commit
dfec176f43
11 files changed
+599
-14
No files matched your search
@@ -0,0 +1,27 @@
|
||||
"""RPC client for `hx --mode rpc --ask`: allows write, denies everything else.
|
||||
Usage: python3 tests/rpc_ask_client.py HX_BINARY
|
||||
"""
|
||||
import json, subprocess, sys
|
||||
|
||||
p = subprocess.Popen([sys.argv[1], "--mode", "rpc", "--ask"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True)
|
||||
|
||||
|
||||
def send(m):
|
||||
p.stdin.write(json.dumps({"jsonrpc": "2.0", **m}) + "\n")
|
||||
p.stdin.flush()
|
||||
|
||||
|
||||
send({"id": 1000, "method": "prompt", "params": {"text": "make hello.txt"}})
|
||||
asked = []
|
||||
while True:
|
||||
m = json.loads(p.stdout.readline())
|
||||
if m.get("method") == "permission":
|
||||
asked.append(m["params"]["tool"])
|
||||
send({"id": m["id"], "result": {"decision": "once" if m["params"]["tool"] == "write" else "deny"}})
|
||||
elif m.get("id") == 1000:
|
||||
assert "error" not in m, m
|
||||
break
|
||||
p.stdin.close()
|
||||
p.wait(timeout=30)
|
||||
assert asked and asked[0] == "write", asked
|
||||
print("asked", asked)
|
||||
Reference in new issue
Block a user