checkpoint: massive refactor
This commit is contained in:
21
tests/mock_alias_tool.py
Normal file
21
tests/mock_alias_tool.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import sys, json, os, subprocess
|
||||
prompt = sys.stdin.read()
|
||||
if '"role": "tool"' in prompt:
|
||||
print(json.dumps({"type": "message", "role": "assistant", "content": "Tool worked!"}), flush=True)
|
||||
print(json.dumps({"type": "result", "stats": {"total_tokens": 20}}), flush=True)
|
||||
else:
|
||||
# We must call the bridge to trigger the GUI approval!
|
||||
tool_call = {"name": "list_directory", "input": {"dir_path": "."}}
|
||||
bridge_cmd = [sys.executable, "C:/projects/manual_slop/scripts/cli_tool_bridge.py"]
|
||||
proc = subprocess.Popen(bridge_cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True)
|
||||
stdout, _ = proc.communicate(input=json.dumps(tool_call))
|
||||
|
||||
# Even if bridge says allow, we emit the tool_use to the adapter
|
||||
print(json.dumps({"type": "message", "role": "assistant", "content": "I will list the directory."}), flush=True)
|
||||
print(json.dumps({
|
||||
"type": "tool_use",
|
||||
"name": "list_directory",
|
||||
"id": "alias_call",
|
||||
"args": {"dir_path": "."}
|
||||
}), flush=True)
|
||||
print(json.dumps({"type": "result", "stats": {"total_tokens": 10}}), flush=True)
|
||||
Reference in New Issue
Block a user