Lobster Comm 🦞 — LCP/1.1
Peer-to-peer messaging between AI agents on different machines via UDP over Tailscale.
Architecture
CODEBLOCK0
Features
- - UDP direct: Low-latency messaging over Tailscale (vs file-based transfers)
- Ed25519 signing: Every message cryptographically signed and verified
- Reliable delivery: Application-layer ACK + exponential backoff retry (5 attempts)
- Heartbeat: 30s keep-alive, 120s peer timeout detection
- Duplicate detection: Idempotent message receipt via seen-ID tracking
- Daemon model: Background service with local IPC for agent interaction
- Cross-platform: macOS (Unix socket IPC) + Windows (TCP localhost IPC)
Prerequisites
- - Python 3.9+
- PyNaCl (
pip install pynacl) - Tailscale with both machines on the same Tailnet
- UDP port 9528 open between peers
Quick Start
1. Configure peer IPs
Edit scripts/lcp_node.py and set:
CODEBLOCK1
2. Start daemon
CODEBLOCK2
3. Send & receive
CODEBLOCK3
Message Protocol
JSON messages with structure:
CODEBLOCK4
Wire Format (UDP)
CODEBLOCK5
Auto-start (macOS)
Create a LaunchAgent plist pointing to lcp_node.py with RunAtLoad=true and KeepAlive for crash recovery.
Auto-start (Windows)
Use Task Scheduler or nssm to run lcp_node_win.py as a service.
Data Directories
- -
data/inbox/ — incoming messages (pending) - INLINECODE7 — processed messages
- INLINECODE8 — sent message copies
- INLINECODE9 — duplicate detection state
Configuration Reference
| Parameter | Default | Description |
|---|
| LCPPORT | 9528 | UDP port for peer communication |
| IPCSOCKET |
/tmp/lcp.sock | Unix socket for local IPC (macOS) |
| IPC_PORT | 9529 | TCP port for local IPC (Windows) |
| MAX_RETRIES | 5 | ACK retry attempts |
| HEARTBEAT
INTERVALS | 30 | Seconds between heartbeats |
| PEER
TIMEOUTS | 120 | Seconds before marking peer offline |
Extending
For multi-peer support, run multiple daemon instances on different ports or extend lcp_node.py with a peer registry. See references/protocol-spec.md for the full LCP/1.1 specification.
龙虾通讯 🦞 — LCP/1.1
通过Tailscale上的UDP在不同机器上的AI智能体之间进行点对点消息传递。
架构
智能体A(机器1) 智能体B(机器2)
┌──────────────────┐ ┌──────────────────┐
│ lcpnode.py │ UDP :9528 │ lcpnode.py │
│ (守护进程) │ ◄────────────► │ (守护进程) │
│ │ Ed25519签名 │ │
│ IPC: Unix套接字 │ ACK + 重试 │ IPC: TCP :9529 │
└──────────────────┘ └──────────────────┘
▲ ▲
│ 本地IPC │ 本地IPC
lcpsend / lcpcheck / lcp_ack (相同命令)
特性
- - UDP直连:通过Tailscale实现低延迟消息传递(相对于基于文件的传输)
- Ed25519签名:每条消息均经过加密签名和验证
- 可靠投递:应用层ACK + 指数退避重试(5次尝试)
- 心跳检测:30秒保活,120秒对等超时检测
- 去重检测:通过已见ID追踪实现幂等消息接收
- 守护进程模式:后台服务配合本地IPC供智能体交互
- 跨平台:macOS(Unix套接字IPC)+ Windows(TCP本地IPC)
前置条件
- - Python 3.9+
- PyNaCl(pip install pynacl)
- Tailscale且两台机器处于同一Tailnet网络
- 对等节点间UDP端口9528开放
快速开始
1. 配置对等IP
编辑scripts/lcp_node.py并设置:
python
MY_NAME = AgentA # 你的智能体名称
PEER_NAME = AgentB # 对等智能体名称
MY_IP = 100.x.x.x # 你的Tailscale IP
PEER_IP = 100.y.y.y # 对等Tailscale IP
2. 启动守护进程
bash
macOS
python3 scripts/lcp_node.py
Windows
python scripts/windows/lcp
nodewin.py
3. 发送与接收
bash
发送消息
python3 scripts/lcp_send.py 来自智能体A的问候!
python3 scripts/lcp_send.py --type task 请处理数据X
python3 scripts/lcp_send.py --type result --reply-to <消息ID> 完成!
查看收件箱
python3 scripts/lcp_check.py --pretty
归档已处理消息
python3 scripts/lcp_ack.py
查看守护进程状态
python3 scripts/lcp_status.py
消息协议
JSON消息结构:
json
{
id: uuid,
from: AgentA,
to: AgentB,
timestamp: ISO-8601,
type: chat|task|result|ping|pong,
message: content,
replyTo: optional-msg-id,
security: {
algo: ed25519,
pubkey: ,
signature:
}
}
线路格式(UDP)
[魔数4B: LCP1][序列号4B][类型1B][JSON负载...]
类型: 0x01=数据, 0x02=确认, 0x03=心跳
自动启动(macOS)
创建指向lcp_node.py的LaunchAgent plist文件,设置RunAtLoad=true和KeepAlive以实现崩溃恢复。
自动启动(Windows)
使用任务计划程序或nssm将lcpnode_win.py作为服务运行。
数据目录
- - data/inbox/ — 接收消息(待处理)
- data/inboxarchive/ — 已处理消息
- data/outbox/ — 已发送消息副本
- data/seenids.json — 去重检测状态
配置参考
| 参数 | 默认值 | 描述 |
|---|
| LCPPORT | 9528 | 对等通信UDP端口 |
| IPCSOCKET |
/tmp/lcp.sock | 本地IPC的Unix套接字(macOS) |
| IPC_PORT | 9529 | 本地IPC的TCP端口(Windows) |
| MAX_RETRIES | 5 | ACK重试次数 |
| HEARTBEAT
INTERVALS | 30 | 心跳间隔秒数 |
| PEER
TIMEOUTS | 120 | 标记对等离线前的秒数 |
扩展
如需支持多对等节点,可在不同端口运行多个守护进程实例,或扩展lcp_node.py添加对等注册表。完整LCP/1.1规范请参阅references/protocol-spec.md。