30 lines
813 B
Python
30 lines
813 B
Python
"""Quick test: call Claude Code plugin's chat export."""
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent.parent / "_sdk"))
|
|
|
|
import grpc
|
|
import agentsd_pb2 as pb
|
|
import agentsd_pb2_grpc as rpc
|
|
|
|
|
|
def main():
|
|
# Connect to claudecode plugin's callback server
|
|
channel = grpc.insecure_channel("localhost:50053")
|
|
bridge = rpc.PluginBridgeStub(channel)
|
|
|
|
# Call "chat"
|
|
args = json.dumps({"prompt": "What is 2+2? Reply with just the number."}).encode()
|
|
resp = bridge.Call(pb.CallRequest(target="claudecode", fn="chat", args=args))
|
|
print(f"ok={resp.ok}")
|
|
if resp.result:
|
|
result = json.loads(resp.result)
|
|
print(f"result: {result.get('result', result.get('error', ''))}")
|
|
channel.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|