feat: add hostname to hello + local/remote peer locality detection
Peers report os.hostname() in the hello handshake. list_peers shows [local] or [remote] tag per peer. MCP instructions teach AI to read local peers' files directly via filesystem instead of relay. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -101,6 +101,7 @@ interface PeerConn {
|
||||
sessionPubkey: string | null;
|
||||
displayName: string;
|
||||
cwd: string;
|
||||
hostname?: string;
|
||||
peerType?: "ai" | "human" | "connector";
|
||||
channel?: string;
|
||||
model?: string;
|
||||
@@ -920,6 +921,7 @@ async function handleHello(
|
||||
sessionPubkey: hello.sessionPubkey ?? null,
|
||||
displayName: effectiveDisplayName,
|
||||
cwd: hello.cwd,
|
||||
hostname: hello.hostname,
|
||||
peerType: hello.peerType,
|
||||
channel: hello.channel,
|
||||
model: hello.model,
|
||||
@@ -1138,6 +1140,7 @@ function handleConnection(ws: WebSocket): void {
|
||||
sessionId: p.sessionId,
|
||||
connectedAt: p.connectedAt.toISOString(),
|
||||
cwd: pc?.cwd ?? p.cwd,
|
||||
...(pc?.hostname ? { hostname: pc.hostname } : {}),
|
||||
...(pc?.peerType ? { peerType: pc.peerType } : {}),
|
||||
...(pc?.channel ? { channel: pc.channel } : {}),
|
||||
...(pc?.model ? { model: pc.model } : {}),
|
||||
|
||||
@@ -57,6 +57,8 @@ export interface WSHelloMessage {
|
||||
sessionId: string;
|
||||
pid: number;
|
||||
cwd: string;
|
||||
/** OS hostname — used to detect same-machine peers for direct file access. */
|
||||
hostname?: string;
|
||||
/** Peer type: ai session, human user, or external connector. */
|
||||
peerType?: "ai" | "human" | "connector";
|
||||
/** Channel the peer connected from (e.g. "claude-code", "telegram", "slack", "web"). */
|
||||
@@ -226,6 +228,7 @@ export interface WSPeersListMessage {
|
||||
sessionId: string;
|
||||
connectedAt: string;
|
||||
cwd?: string;
|
||||
hostname?: string;
|
||||
peerType?: "ai" | "human" | "connector";
|
||||
channel?: string;
|
||||
model?: string;
|
||||
|
||||
Reference in New Issue
Block a user