M0: framing (ndjson + lsp-frame), ACPClient, mock agent fixture, probe script; real claude-code-acp handshake verified

This commit is contained in:
openbot committed 2026-10-06 11:05:40 +08:00
1 parent d96d4f73bb
commit 82c3763e5c
10 files changed
+967 -4

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
"""ndjson transport tests (the transport used by current ACP SDK agents)."""
import json
from agenthub.framing import decode_ndjson_lines, encode_ndjson
def test_ndjson_roundtrip():
msg = {"jsonrpc": "2.0", "id": 1, "result": {"ok": True}}
data = encode_ndjson(msg)
assert data.endswith(b"\n")
msgs, consumed = decode_ndjson_lines(data)
assert msgs == [msg]
assert consumed == len(data)
def test_ndjson_partial_tail():
a = {"id": 1}
b = {"id": 2}
buf = encode_ndjson(a) + encode_ndjson(b)[:10] # b is incomplete
msgs, consumed = decode_ndjson_lines(buf)
assert msgs == [a]
assert consumed == len(encode_ndjson(a))
def test_ndjson_unicode():
msg = {"text": "中文🎉"}
data = encode_ndjson(msg)
assert json.loads(data.decode("utf-8")) == msg