core: lan_peer example — verify agent serverless sync without clipboard contention

A controllable LAN peer (dead server, doesn't touch the OS clipboard) used to
prove the desktop agent syncs over LAN alone. Confirmed both directions on macOS
with the server unreachable: pbcopy → agent → peer, and peer → agent → pasteboard.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-21 00:20:45 -05:00
parent 09d63651ab
commit f9a7f38bb7

32
core/examples/lan_peer.rs Normal file
View File

@@ -0,0 +1,32 @@
//! A controllable LAN peer for verifying the agent's serverless sync, without a
//! second clipboard-touching process. Dead server → only the LAN transport can
//! move data.
//! cargo run --example lan_peer -- <room> <text-to-send>
//! Prints `RECV <text>` for anything received; sends <text-to-send> once after
//! discovery settles.
use std::time::Duration;
use tethercore::{Engine, Message, MessageHandler};
struct Printer;
impl MessageHandler for Printer {
fn on_message(&self, msg: Message) {
println!("RECV {}", msg.text);
}
fn on_status(&self, _connected: bool) {}
}
fn main() {
let room = std::env::args().nth(1).unwrap_or_else(|| "lan-verify".into());
let send = std::env::args().nth(2);
// High `from` so it accepts the agent's dial (lower id dials).
let e = Engine::new("http://127.0.0.1:1".into(), room, "zzz-peer".into(), "peer".into());
e.start(Box::new(Printer));
std::thread::sleep(Duration::from_secs(6)); // let mDNS discover + TCP connect
if let Some(s) = send {
e.send(s);
}
std::thread::sleep(Duration::from_secs(8));
}