┌──────────────────────────────────────────────────────────────────────────┐
│ 메시징 채널 계층 │
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │WhatsApp │ │Telegram │ │ Slack │ │ Discord │ │
│ │ Baileys │ │ grammY │ │ Bolt │ │discord.js│ │
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
└───────┼────────────┼────────────┼────────────┼────────────┘ │
│ │ │ │ │
▼ ▼ ▼ ▼ │
┌───────────────────────────────────────────────────────────────────┐│
│ 제어 평면 계층 ││
│ Gateway Daemon ││
│ WebSocket Server (18789) ││
└────────────┬───────────────────────────┬───────────────────┘│
│ │ │
┌────┴────┐ └──────┐ │
│ │ │ │
▼ ▼ ▼ ▼
┌───────────┐ ┌───────────┐ ┌───────────────────┐
│ macOS App │ │ CLI │ │ 디바이스 노드 │
│ Web UI │ │ TUI │ │ iOS/Android │
└──────┬────┘ └──────┬────┘ └────────┬────────┘
│ │ │
└──────────────┬─────────────────────┘
▼
┌─────────────────────┐
│ 에이전트 계층 │
│ Pi Agent Runtime │
│ (RPC Mode) │
└─────────┬─────────┘
│
┌───────────┼───────────┐
▼ ▼ ▼
┌─────────┐ ┌─────────┐ ┌─────────┐
│ 브라우저 │ │ Canvas │ │ 크론 │
│ 자동화 │ │ A2UI │ │ 웹훅 │
└─────────┘ └─────────┘ └─────────┘// 연결 수명 주기
Client Gateway
| |
|---- req:connect -------->|
|<------ res (ok) ---------| (또는 res error + close)
| (payload=hello-ok carries snapshot: presence + health)
| |
|<------ event:tick -------|
|<------ event:presence ---|
| |
|------- req:agent ------->|
|<------ res:agent --------| (ack: {runId,status:"accepted"})
|<------ event:agent ------| (streaming)
|<------ res:agent --------| (final: {runId,status,summary})
| |// RPC 요청 포맷
interface RPCRequest {
method: string;
params: Record<string, unknown>;
id: string;
}
// RPC 응답 포맷
interface RPCResponse {
result: unknown;
error?: string;
id: string;
}
// 스트리밍 포맷
interface RPCStream {
type: 'content' | 'tool_output' | 'tool_call';
data: unknown;
id: string;
}{
agents: {
bindings: {
// 채널:계정:피어 → 워크스페이스
"whatsapp:+1234567890": "main",
"whatsapp:+9876543210": "personal",
"telegram:@clawdbot_bot": "main",
"discord:server:123456789": "work",
"slack:workspace:U1234567890": "main"
},
// 다중 워크스페이스
workspaces: {
"main": "~/clawd",
"personal": "~/clawd-personal",
"work": "~/clawd-work"
}
}
}// 노드 연결
{
"type": "req",
"method": "connect",
"params": {
"role": "node",
"deviceId": "device-uuid",
"caps": [
"camera.snap",
"screen.record",
"location.get"
],
"permissions": {
"camera": true,
"screen": false
}
}
}interface ChannelAdapter {
connect(): Promise<void>;
send(recipient: string, message: Message): Promise<void>;
onMessage(handler: (msg: Message) => void): void;
onPresence(handler: (presence: Presence) => void): void;
disconnect(): Promise<void>;
}외부 메신저
│
│ 1. 사용자 메시지 수신
▼
메시징 채널 (WhatsApp, Telegram, ...)
│
│ 2. 메시지 정규화
▼
Gateway (메시지 라우팅)
│
│ 3. 세션 결정
│ - 채널/계정/피어 검색
│ - 바인딩 확인
│ - 세션 생성/검색
▼
Pi Agent (실행)
│
│ 4. 도구 실행 (필요시)
│ - 브라우저 자동화
│ - 파일 조작
│ - 크론 작업 등
▼
응답 생성
│
│ 5. 응답 생성
▼
Gateway (아웃바운드 라우팅)
│
│ 6. 채널로 전송
▼
메시징 채널
│
│ 7. 응답 전송
▼
외부 메신저클라이언트 (macOS App, CLI, Web UI)
│
│ 1. 요청 생성
▼
Gateway
│
│ 2. 인증 및 권한 확인
▼
Pi Agent
│
│ 3. 도구 실행
▼
응답 스트리밍
│
│ 4. 실시간 결과 반환
▼
클라이언트