mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 06:51:16 +08:00
feat: new tui based on ink
This commit is contained in:
36
tui_gateway/entry.py
Normal file
36
tui_gateway/entry.py
Normal file
@@ -0,0 +1,36 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user