22 lines
1.1 KiB
Python
22 lines
1.1 KiB
Python
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)
|