mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
36 lines
783 B
Python
36 lines
783 B
Python
import json
|
|
import sys
|
|
|
|
from tui_gateway.server import handle_request, resolve_skin
|
|
|
|
|
|
def _write(obj: dict):
|
|
sys.stdout.write(json.dumps(obj) + "\n")
|
|
sys.stdout.flush()
|
|
|
|
|
|
def main():
|
|
_write({
|
|
"jsonrpc": "2.0",
|
|
"method": "event",
|
|
"params": {"type": "gateway.ready", "payload": {"skin": resolve_skin()}},
|
|
})
|
|
|
|
for raw in sys.stdin:
|
|
line = raw.strip()
|
|
if not line:
|
|
continue
|
|
|
|
try:
|
|
req = json.loads(line)
|
|
except json.JSONDecodeError:
|
|
_write({"jsonrpc": "2.0", "error": {"code": -32700, "message": "parse error"}, "id": None})
|
|
continue
|
|
|
|
resp = handle_request(req)
|
|
if resp is not None:
|
|
_write(resp)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|