@teneo-protocol/sdk 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish-npm.yml +8 -6
- package/CHANGELOG.md +265 -0
- package/README.md +406 -53
- package/dist/core/websocket-client.d.ts +13 -0
- package/dist/core/websocket-client.d.ts.map +1 -1
- package/dist/core/websocket-client.js +34 -3
- package/dist/core/websocket-client.js.map +1 -1
- package/dist/handlers/message-handlers/agent-room-operation-response-handler.d.ts +76 -0
- package/dist/handlers/message-handlers/agent-room-operation-response-handler.d.ts.map +1 -0
- package/dist/handlers/message-handlers/agent-room-operation-response-handler.js +70 -0
- package/dist/handlers/message-handlers/agent-room-operation-response-handler.js.map +1 -0
- package/dist/handlers/message-handlers/agent-selected-handler.d.ts +92 -38
- package/dist/handlers/message-handlers/agent-selected-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/agent-status-update-handler.d.ts +904 -0
- package/dist/handlers/message-handlers/agent-status-update-handler.d.ts.map +1 -0
- package/dist/handlers/message-handlers/agent-status-update-handler.js +51 -0
- package/dist/handlers/message-handlers/agent-status-update-handler.js.map +1 -0
- package/dist/handlers/message-handlers/auth-error-handler.d.ts +45 -31
- package/dist/handlers/message-handlers/auth-error-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/auth-message-handler.d.ts +6 -0
- package/dist/handlers/message-handlers/auth-message-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/auth-message-handler.js +65 -5
- package/dist/handlers/message-handlers/auth-message-handler.js.map +1 -1
- package/dist/handlers/message-handlers/auth-required-handler.d.ts +49 -31
- package/dist/handlers/message-handlers/auth-required-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/auth-success-handler.d.ts +6 -0
- package/dist/handlers/message-handlers/auth-success-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/auth-success-handler.js +46 -4
- package/dist/handlers/message-handlers/auth-success-handler.js.map +1 -1
- package/dist/handlers/message-handlers/challenge-handler.d.ts +45 -31
- package/dist/handlers/message-handlers/challenge-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/error-message-handler.d.ts +49 -31
- package/dist/handlers/message-handlers/error-message-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/index.d.ts +5 -0
- package/dist/handlers/message-handlers/index.d.ts.map +1 -1
- package/dist/handlers/message-handlers/index.js +23 -1
- package/dist/handlers/message-handlers/index.js.map +1 -1
- package/dist/handlers/message-handlers/list-available-agents-handler.d.ts +877 -0
- package/dist/handlers/message-handlers/list-available-agents-handler.d.ts.map +1 -0
- package/dist/handlers/message-handlers/list-available-agents-handler.js +38 -0
- package/dist/handlers/message-handlers/list-available-agents-handler.js.map +1 -0
- package/dist/handlers/message-handlers/list-room-agents-handler.d.ts +886 -0
- package/dist/handlers/message-handlers/list-room-agents-handler.d.ts.map +1 -0
- package/dist/handlers/message-handlers/list-room-agents-handler.js +51 -0
- package/dist/handlers/message-handlers/list-room-agents-handler.js.map +1 -0
- package/dist/handlers/message-handlers/list-rooms-response-handler.d.ts +178 -89
- package/dist/handlers/message-handlers/list-rooms-response-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/ping-pong-handler.d.ts +62 -58
- package/dist/handlers/message-handlers/ping-pong-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/regular-message-handler.d.ts +31 -29
- package/dist/handlers/message-handlers/regular-message-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/regular-message-handler.js +1 -0
- package/dist/handlers/message-handlers/regular-message-handler.js.map +1 -1
- package/dist/handlers/message-handlers/room-operation-response-handler.d.ts +328 -0
- package/dist/handlers/message-handlers/room-operation-response-handler.d.ts.map +1 -0
- package/dist/handlers/message-handlers/room-operation-response-handler.js +92 -0
- package/dist/handlers/message-handlers/room-operation-response-handler.js.map +1 -0
- package/dist/handlers/message-handlers/subscribe-response-handler.d.ts +53 -31
- package/dist/handlers/message-handlers/subscribe-response-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/types.d.ts +2 -0
- package/dist/handlers/message-handlers/types.d.ts.map +1 -1
- package/dist/handlers/message-handlers/unsubscribe-response-handler.d.ts +53 -31
- package/dist/handlers/message-handlers/unsubscribe-response-handler.d.ts.map +1 -1
- package/dist/managers/agent-room-manager.d.ts +222 -0
- package/dist/managers/agent-room-manager.d.ts.map +1 -0
- package/dist/managers/agent-room-manager.js +508 -0
- package/dist/managers/agent-room-manager.js.map +1 -0
- package/dist/managers/index.d.ts +2 -0
- package/dist/managers/index.d.ts.map +1 -1
- package/dist/managers/index.js +5 -1
- package/dist/managers/index.js.map +1 -1
- package/dist/managers/message-router.d.ts +1 -1
- package/dist/managers/message-router.d.ts.map +1 -1
- package/dist/managers/message-router.js +41 -4
- package/dist/managers/message-router.js.map +1 -1
- package/dist/managers/room-management-manager.d.ts +213 -0
- package/dist/managers/room-management-manager.d.ts.map +1 -0
- package/dist/managers/room-management-manager.js +440 -0
- package/dist/managers/room-management-manager.js.map +1 -0
- package/dist/managers/room-manager.d.ts +4 -4
- package/dist/managers/room-manager.d.ts.map +1 -1
- package/dist/managers/room-manager.js +1 -1
- package/dist/managers/room-manager.js.map +1 -1
- package/dist/teneo-sdk.d.ts +362 -14
- package/dist/teneo-sdk.d.ts.map +1 -1
- package/dist/teneo-sdk.js +497 -7
- package/dist/teneo-sdk.js.map +1 -1
- package/dist/types/config.d.ts +63 -54
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +9 -5
- package/dist/types/config.js.map +1 -1
- package/dist/types/error-codes.d.ts +2 -0
- package/dist/types/error-codes.d.ts.map +1 -1
- package/dist/types/error-codes.js +3 -0
- package/dist/types/error-codes.js.map +1 -1
- package/dist/types/events.d.ts +132 -68
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/events.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +27 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/messages.d.ts +11396 -2559
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/messages.js +294 -27
- package/dist/types/messages.js.map +1 -1
- package/dist/types/validation.d.ts.map +1 -1
- package/dist/types/validation.js +1 -1
- package/dist/types/validation.js.map +1 -1
- package/dist/utils/bounded-queue.d.ts +1 -1
- package/dist/utils/bounded-queue.js +6 -6
- package/dist/utils/circuit-breaker.d.ts.map +1 -1
- package/dist/utils/circuit-breaker.js.map +1 -1
- package/dist/utils/event-waiter.d.ts.map +1 -1
- package/dist/utils/event-waiter.js +2 -1
- package/dist/utils/event-waiter.js.map +1 -1
- package/dist/utils/rate-limiter.d.ts.map +1 -1
- package/dist/utils/rate-limiter.js +4 -6
- package/dist/utils/rate-limiter.js.map +1 -1
- package/dist/utils/secure-private-key.d.ts.map +1 -1
- package/dist/utils/secure-private-key.js +9 -15
- package/dist/utils/secure-private-key.js.map +1 -1
- package/dist/utils/signature-verifier.d.ts +2 -2
- package/dist/utils/signature-verifier.d.ts.map +1 -1
- package/dist/utils/signature-verifier.js +5 -5
- package/dist/utils/signature-verifier.js.map +1 -1
- package/examples/.env.example +1 -1
- package/examples/agent-room-management-example.ts +334 -0
- package/examples/claude-agent-x-follower/.env.example +117 -0
- package/examples/claude-agent-x-follower/QUICKSTART.md +243 -0
- package/examples/claude-agent-x-follower/README.md +540 -0
- package/examples/claude-agent-x-follower/index.ts +248 -0
- package/examples/claude-agent-x-follower/package.json +37 -0
- package/examples/claude-agent-x-follower/tsconfig.json +20 -0
- package/examples/n8n-teneo/.env.example +127 -0
- package/examples/n8n-teneo/Dockerfile +42 -0
- package/examples/n8n-teneo/README.md +564 -0
- package/examples/n8n-teneo/docker-compose.yml +71 -0
- package/examples/n8n-teneo/index.ts +177 -0
- package/examples/n8n-teneo/package.json +22 -0
- package/examples/n8n-teneo/tsconfig.json +12 -0
- package/examples/n8n-teneo/workflows/x-timeline.json +66 -0
- package/examples/openai-teneo/.env.example +130 -0
- package/examples/openai-teneo/README.md +635 -0
- package/examples/openai-teneo/index.ts +280 -0
- package/examples/openai-teneo/package.json +24 -0
- package/examples/openai-teneo/tsconfig.json +16 -0
- package/examples/production-dashboard/.env.example +5 -3
- package/examples/production-dashboard/README.md +839 -0
- package/examples/production-dashboard/pnpm-lock.yaml +92 -0
- package/examples/production-dashboard/public/dashboard.html +1150 -504
- package/examples/production-dashboard/server.ts +428 -12
- package/examples/room-management-example.ts +285 -0
- package/examples/usage/.env.example +17 -0
- package/examples/usage/01-connect.ts +116 -0
- package/examples/usage/02-list-agents.ts +153 -0
- package/examples/usage/03-pick-agent.ts +201 -0
- package/examples/usage/04-find-by-capability.ts +237 -0
- package/examples/usage/05-webhook-example.ts +319 -0
- package/examples/usage/06-simple-api-server.ts +396 -0
- package/examples/usage/07-event-listener.ts +402 -0
- package/examples/usage/README.md +383 -0
- package/examples/usage/package.json +42 -0
- package/package.json +13 -3
- package/src/core/websocket-client.ts +43 -9
- package/src/formatters/response-formatter.test.ts +8 -2
- package/src/handlers/message-handlers/agent-room-operation-response-handler.ts +83 -0
- package/src/handlers/message-handlers/agent-status-update-handler.ts +58 -0
- package/src/handlers/message-handlers/auth-message-handler.ts +73 -5
- package/src/handlers/message-handlers/auth-success-handler.ts +58 -6
- package/src/handlers/message-handlers/index.ts +19 -0
- package/src/handlers/message-handlers/list-available-agents-handler.ts +41 -0
- package/src/handlers/message-handlers/list-room-agents-handler.ts +61 -0
- package/src/handlers/message-handlers/regular-message-handler.ts +1 -0
- package/src/handlers/message-handlers/room-operation-response-handler.ts +105 -0
- package/src/handlers/message-handlers/types.ts +6 -0
- package/src/handlers/webhook-handler.test.ts +13 -10
- package/src/managers/agent-room-manager.ts +609 -0
- package/src/managers/index.ts +2 -0
- package/src/managers/message-router.ts +48 -6
- package/src/managers/room-management-manager.ts +523 -0
- package/src/managers/room-manager.ts +12 -6
- package/src/teneo-sdk.ts +543 -10
- package/src/types/config.ts +13 -6
- package/src/types/error-codes.ts +4 -0
- package/src/types/events.ts +24 -0
- package/src/types/index.ts +55 -0
- package/src/types/messages.ts +374 -41
- package/src/types/validation.ts +4 -1
- package/src/utils/bounded-queue.ts +9 -9
- package/src/utils/circuit-breaker.ts +4 -1
- package/src/utils/deduplication-cache.test.ts +2 -6
- package/src/utils/event-waiter.test.ts +4 -1
- package/src/utils/event-waiter.ts +5 -7
- package/src/utils/rate-limiter.test.ts +5 -17
- package/src/utils/rate-limiter.ts +6 -9
- package/src/utils/secure-private-key.test.ts +66 -59
- package/src/utils/secure-private-key.ts +10 -16
- package/src/utils/signature-verifier.test.ts +75 -70
- package/src/utils/signature-verifier.ts +7 -8
- package/src/utils/ssrf-validator.test.ts +3 -3
- package/tests/integration/room-management.test.ts +514 -0
- package/tests/integration/websocket.test.ts +1 -1
- package/tests/unit/handlers/agent-room-operation-response-handler.test.ts +394 -0
- package/tests/unit/handlers/agent-status-update-handler.test.ts +407 -0
- package/tests/unit/handlers/auth-success-handler-rooms.test.ts +699 -0
- package/tests/unit/handlers/list-available-agents-handler.test.ts +256 -0
- package/tests/unit/handlers/list-room-agents-handler.test.ts +294 -0
- package/tests/unit/handlers/room-operation-response-handler.test.ts +527 -0
- package/tests/unit/managers/agent-room-manager.test.ts +534 -0
- package/tests/unit/managers/room-management-manager.test.ts +438 -0
|
@@ -0,0 +1,839 @@
|
|
|
1
|
+
# Production Dashboard Example
|
|
2
|
+
|
|
3
|
+
A comprehensive, production-ready example demonstrating **ALL features** of the Teneo Protocol SDK using modern technologies: **Hono** (fast web framework) and **Bun** (fast JavaScript runtime).
|
|
4
|
+
|
|
5
|
+
## 🎯 What This Example Demonstrates
|
|
6
|
+
|
|
7
|
+
This is the **ultimate reference implementation** showcasing every SDK capability in a real-world application.
|
|
8
|
+
|
|
9
|
+
### Core Features
|
|
10
|
+
|
|
11
|
+
✅ **WebSocket Connection** - Auto-reconnection with exponential backoff
|
|
12
|
+
✅ **Ethereum Authentication** - Wallet-based authentication
|
|
13
|
+
✅ **Message Sending** - Coordinator-based and direct agent commands
|
|
14
|
+
✅ **Room Management (v1)** - Subscribe, unsubscribe, and list rooms
|
|
15
|
+
✅ **Room Management (v2.0)** - Create, update, delete rooms with ownership tracking
|
|
16
|
+
✅ **Agent-Room Management (v2.0)** - Add/remove agents per room, list room agents
|
|
17
|
+
✅ **Agent Discovery** - List agents with capabilities
|
|
18
|
+
✅ **Response Formatting** - Raw JSON, humanized text, or both
|
|
19
|
+
|
|
20
|
+
### Advanced Features
|
|
21
|
+
|
|
22
|
+
✅ **Private Key Encryption** (SEC-3) - Encrypted private key storage in memory
|
|
23
|
+
✅ **Message Signature Verification** (SEC-2) - Cryptographic message validation
|
|
24
|
+
✅ **Indexed Agent Lookups** (PERF-3) - O(1) agent search by capability/status
|
|
25
|
+
✅ **Configurable Retry Strategies** (REL-3) - Custom backoff for reconnection/webhooks
|
|
26
|
+
✅ **Message Deduplication** (CB-4) - TTL-based duplicate message prevention
|
|
27
|
+
✅ **Webhook Integration** - Real-time event streaming with circuit breaker
|
|
28
|
+
✅ **Rate Limiting** - Configurable rate limiting with status monitoring
|
|
29
|
+
✅ **Health Monitoring** - Comprehensive health checks for all components
|
|
30
|
+
✅ **SSRF Protection** - Webhook URL validation
|
|
31
|
+
✅ **Error Handling** - Custom error classes with recovery strategies
|
|
32
|
+
✅ **Event System** - Complete event-driven architecture
|
|
33
|
+
|
|
34
|
+
### v2.0 Features (New!)
|
|
35
|
+
|
|
36
|
+
✅ **Multi-Room Management** - Create, update, and delete your own rooms
|
|
37
|
+
✅ **Room Ownership Tracking** - Distinguish between owned and shared rooms
|
|
38
|
+
✅ **Room Limits** - Track and display room creation quotas
|
|
39
|
+
✅ **Agent-Room Customization** - Add/remove agents per room (owner only)
|
|
40
|
+
✅ **Room Agent Listing** - List agents in specific rooms with caching
|
|
41
|
+
✅ **Available Agents** - See which agents can be added to a room
|
|
42
|
+
✅ **Real-time Room Events** - Live updates for room creation/updates/deletions
|
|
43
|
+
✅ **Real-time Agent-Room Events** - Live updates when agents are added/removed
|
|
44
|
+
|
|
45
|
+
### Production Features
|
|
46
|
+
|
|
47
|
+
✅ **Health Check Endpoint** - `/health` for Kubernetes/Docker monitoring
|
|
48
|
+
✅ **Metrics Endpoint** - `/metrics` for observability
|
|
49
|
+
✅ **Graceful Shutdown** - Proper cleanup on SIGINT/SIGTERM
|
|
50
|
+
✅ **Structured Logging** - Debug logging for troubleshooting
|
|
51
|
+
✅ **Environment Configuration** - 12-factor app principles
|
|
52
|
+
✅ **Real-time Updates** - Server-Sent Events (SSE) for live dashboard
|
|
53
|
+
|
|
54
|
+
## 🚀 Quick Start
|
|
55
|
+
|
|
56
|
+
### Prerequisites
|
|
57
|
+
|
|
58
|
+
- **Bun** (v1.0.0 or higher) - [Install Bun](https://bun.sh)
|
|
59
|
+
- **Teneo Account** - WebSocket URL and private key
|
|
60
|
+
- **Node.js** (v18+) if not using Bun
|
|
61
|
+
|
|
62
|
+
### Installation
|
|
63
|
+
|
|
64
|
+
1. **Clone the repository** (if not already):
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
git clone https://github.com/TeneoProtocolAI/sdk.git
|
|
68
|
+
cd sdk
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
2. **Install dependencies**:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
cd examples/production-dashboard
|
|
75
|
+
bun install
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
3. **Configure environment**:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
cp .env.example .env
|
|
82
|
+
# Edit .env with your credentials
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
4. **Run the dashboard**:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
bun run server.ts
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
5. **Open the dashboard**:
|
|
92
|
+
```
|
|
93
|
+
http://localhost:3000
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Using npm/pnpm Instead of Bun
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
npm install hono @hono/node-server
|
|
100
|
+
npm run dev # or: node --loader ts-node/esm server.ts
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## 📁 Project Structure
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
production-dashboard/
|
|
107
|
+
├── server.ts # Hono server with SDK integration
|
|
108
|
+
├── public/
|
|
109
|
+
│ └── dashboard.html # Beautiful responsive dashboard UI
|
|
110
|
+
├── package.json # Bun-specific configuration
|
|
111
|
+
├── .env.example # Environment template
|
|
112
|
+
└── README.md # This file
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## 🔧 Configuration
|
|
116
|
+
|
|
117
|
+
### Environment Variables
|
|
118
|
+
|
|
119
|
+
Create a `.env` file with the following variables:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Required
|
|
123
|
+
WS_URL=wss://your-teneo-server.com/ws
|
|
124
|
+
PRIVATE_KEY=0x...your-private-key
|
|
125
|
+
WALLET_ADDRESS=0x...your-wallet-address
|
|
126
|
+
|
|
127
|
+
# Optional
|
|
128
|
+
DEFAULT_ROOM=general
|
|
129
|
+
PORT=3000
|
|
130
|
+
|
|
131
|
+
# Security Features
|
|
132
|
+
ENABLE_SIGNATURE_VERIFICATION=true
|
|
133
|
+
TRUSTED_ADDRESSES=0xAgent1...,0xAgent2...
|
|
134
|
+
|
|
135
|
+
# Webhook (auto-configured to localhost)
|
|
136
|
+
WEBHOOK_URL=http://localhost:3000/webhook
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### SDK Configuration
|
|
140
|
+
|
|
141
|
+
The example initializes the SDK with all features enabled:
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
// SEC-3: Encrypt private key in memory
|
|
145
|
+
const secureKey = new SecurePrivateKey(PRIVATE_KEY);
|
|
146
|
+
|
|
147
|
+
const config = new SDKConfigBuilder()
|
|
148
|
+
.withWebSocketUrl(WS_URL)
|
|
149
|
+
.withAuthentication(secureKey, WALLET_ADDRESS) // Use encrypted key
|
|
150
|
+
.withAutoJoinRooms([DEFAULT_ROOM])
|
|
151
|
+
.withReconnection({ enabled: true, delay: 5000, maxAttempts: 10 })
|
|
152
|
+
// REL-3: Custom retry strategies for production
|
|
153
|
+
.withReconnectionStrategy({
|
|
154
|
+
type: "exponential",
|
|
155
|
+
baseDelay: 3000,
|
|
156
|
+
maxDelay: 120000,
|
|
157
|
+
maxAttempts: 15,
|
|
158
|
+
jitter: true,
|
|
159
|
+
backoffMultiplier: 2.5
|
|
160
|
+
})
|
|
161
|
+
.withWebhookRetryStrategy({
|
|
162
|
+
type: "exponential",
|
|
163
|
+
baseDelay: 1000,
|
|
164
|
+
maxDelay: 30000,
|
|
165
|
+
maxAttempts: 5,
|
|
166
|
+
jitter: false
|
|
167
|
+
})
|
|
168
|
+
.withResponseFormat({ format: "both", includeMetadata: true })
|
|
169
|
+
.withLogging("debug")
|
|
170
|
+
.withCache(true, 300000, 100)
|
|
171
|
+
.withSignatureVerification({
|
|
172
|
+
enabled: ENABLE_SIG_VERIFICATION,
|
|
173
|
+
trustedAddresses: TRUSTED_ADDRESSES,
|
|
174
|
+
requireFor: ["task_response", "agent_selected"],
|
|
175
|
+
strictMode: false
|
|
176
|
+
})
|
|
177
|
+
.build();
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## 📡 API Endpoints
|
|
181
|
+
|
|
182
|
+
### Dashboard & UI
|
|
183
|
+
|
|
184
|
+
- `GET /` - Main dashboard interface
|
|
185
|
+
|
|
186
|
+
### Monitoring
|
|
187
|
+
|
|
188
|
+
- `GET /health` - Health check (connection, auth, webhooks, circuit breaker)
|
|
189
|
+
- `GET /metrics` - SDK metrics (agents, rooms, messages, errors)
|
|
190
|
+
|
|
191
|
+
### Webhooks
|
|
192
|
+
|
|
193
|
+
- `POST /webhook` - Webhook receiver endpoint
|
|
194
|
+
|
|
195
|
+
### Messages
|
|
196
|
+
|
|
197
|
+
- `POST /api/message` - Send message to coordinator
|
|
198
|
+
|
|
199
|
+
```json
|
|
200
|
+
{
|
|
201
|
+
"content": "What is blockchain?",
|
|
202
|
+
"waitForResponse": true
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
- `POST /api/direct-command` - Send direct agent command
|
|
207
|
+
```json
|
|
208
|
+
{
|
|
209
|
+
"agent": "weather-agent",
|
|
210
|
+
"command": "weather New York",
|
|
211
|
+
"room": "general"
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Agent & Room Management
|
|
216
|
+
|
|
217
|
+
- `GET /api/agents` - List all available agents
|
|
218
|
+
- `GET /api/agents/search/capability/:capability` - **PERF-3**: Search by capability (O(1))
|
|
219
|
+
- `GET /api/agents/search/name/:name` - **PERF-3**: Search by name (O(k))
|
|
220
|
+
- `GET /api/agents/search/status/:status` - **PERF-3**: Search by status (O(1))
|
|
221
|
+
- `GET /api/rooms` - List all available rooms (v1)
|
|
222
|
+
- `GET /api/deduplication` - **CB-4**: Get message deduplication status
|
|
223
|
+
- `POST /api/room/subscribe` - Subscribe to a room (v1)
|
|
224
|
+
```json
|
|
225
|
+
{
|
|
226
|
+
"roomId": "tech-support"
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
- `POST /api/room/unsubscribe` - Unsubscribe from a room (v1)
|
|
230
|
+
|
|
231
|
+
### Room Management v2.0 API
|
|
232
|
+
|
|
233
|
+
- `GET /api/v2/rooms/owned` - Get all rooms you own
|
|
234
|
+
- `GET /api/v2/rooms/shared` - Get all rooms you're a member of
|
|
235
|
+
- `GET /api/v2/rooms/limit` - Get your room creation limit
|
|
236
|
+
- `POST /api/v2/rooms` - Create a new room
|
|
237
|
+
```json
|
|
238
|
+
{
|
|
239
|
+
"name": "My Room",
|
|
240
|
+
"description": "Optional description"
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
- `PUT /api/v2/rooms/:id` - Update room (owner only)
|
|
244
|
+
```json
|
|
245
|
+
{
|
|
246
|
+
"name": "Updated Name",
|
|
247
|
+
"description": "New description"
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
- `DELETE /api/v2/rooms/:id` - Delete room (owner only)
|
|
251
|
+
|
|
252
|
+
### Agent-Room Management v2.0 API
|
|
253
|
+
|
|
254
|
+
- `GET /api/v2/rooms/:id/agents` - List agents in room (with 5-min cache)
|
|
255
|
+
- `GET /api/v2/rooms/:id/available-agents` - List agents available to add
|
|
256
|
+
- `GET /api/v2/rooms/:id/agents/count` - Get agent count (instant, from cache)
|
|
257
|
+
- `GET /api/v2/rooms/:roomId/agents/:agentId/check` - Check if agent is in room
|
|
258
|
+
- `POST /api/v2/rooms/:roomId/agents/:agentId` - Add agent to room (owner only)
|
|
259
|
+
- `DELETE /api/v2/rooms/:roomId/agents/:agentId` - Remove agent from room (owner only)
|
|
260
|
+
- `POST /api/v2/rooms/:id/cache/invalidate` - Manually invalidate agent-room cache
|
|
261
|
+
|
|
262
|
+
### Real-time Data
|
|
263
|
+
|
|
264
|
+
- `GET /api/events` - Get recent events (JSON)
|
|
265
|
+
- `GET /api/messages` - Get recent messages (JSON)
|
|
266
|
+
- `GET /api/webhooks` - Get received webhooks (JSON)
|
|
267
|
+
- `GET /api/sse` - Server-Sent Events stream
|
|
268
|
+
|
|
269
|
+
## 🎨 Dashboard Features
|
|
270
|
+
|
|
271
|
+
### Status Panel
|
|
272
|
+
|
|
273
|
+
- **Connection Status**: Real-time WebSocket connection state
|
|
274
|
+
- **Authentication**: Authentication status and wallet address
|
|
275
|
+
- **Agent Count**: Number of available agents
|
|
276
|
+
- **Message Count**: Total messages sent
|
|
277
|
+
|
|
278
|
+
### Message Interface
|
|
279
|
+
|
|
280
|
+
- **Send Message**: Send to coordinator (automatic agent selection)
|
|
281
|
+
- **Send & Wait**: Send and wait for response (synchronous)
|
|
282
|
+
- **Message History**: View all messages and responses
|
|
283
|
+
|
|
284
|
+
### Tabs
|
|
285
|
+
|
|
286
|
+
1. **Agents Tab**: List all agents with capabilities and status
|
|
287
|
+
2. **Rooms Tab**: Manage room subscriptions (subscribe/unsubscribe) - v1
|
|
288
|
+
3. **Room Mgmt Tab** 🆕: Create, update, delete rooms - View owned/shared rooms with room limits (v2.0)
|
|
289
|
+
4. **Agent-Room Tab** 🆕: Add/remove agents to rooms - List room agents and available agents (v2.0)
|
|
290
|
+
5. **Messages Tab**: View message history with responses
|
|
291
|
+
6. **Webhooks Tab**: Monitor received webhooks
|
|
292
|
+
7. **Events Tab**: Real-time event stream (includes v2.0 room and agent-room events)
|
|
293
|
+
|
|
294
|
+
### Health Monitor
|
|
295
|
+
|
|
296
|
+
- Overall system health status
|
|
297
|
+
- Webhook circuit breaker state
|
|
298
|
+
- Rate limiter status
|
|
299
|
+
- System uptime
|
|
300
|
+
|
|
301
|
+
## 🔍 Feature Deep Dive
|
|
302
|
+
|
|
303
|
+
### Private Key Encryption (SEC-3)
|
|
304
|
+
|
|
305
|
+
The dashboard protects your private key in memory using encryption:
|
|
306
|
+
|
|
307
|
+
```typescript
|
|
308
|
+
import { SecurePrivateKey } from "@teneo-protocol/sdk";
|
|
309
|
+
|
|
310
|
+
// Encrypt private key in memory
|
|
311
|
+
const secureKey = new SecurePrivateKey(process.env.PRIVATE_KEY);
|
|
312
|
+
|
|
313
|
+
// Use with SDK - automatically decrypted when needed
|
|
314
|
+
const config = new SDKConfigBuilder().withAuthentication(secureKey, WALLET_ADDRESS).build();
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
**Security Benefits:**
|
|
318
|
+
|
|
319
|
+
- Private key is encrypted in memory using AES-256-GCM
|
|
320
|
+
- Protected from memory dumps and debugging tools
|
|
321
|
+
- Automatic secure cleanup when no longer needed
|
|
322
|
+
- Minimal performance overhead
|
|
323
|
+
|
|
324
|
+
**Example Test:**
|
|
325
|
+
|
|
326
|
+
```bash
|
|
327
|
+
# Without encryption: private key visible in memory dump
|
|
328
|
+
# With encryption: only encrypted bytes visible
|
|
329
|
+
curl http://localhost:3000/metrics
|
|
330
|
+
# Your private key is never exposed in logs or responses
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Message Deduplication (CB-4)
|
|
334
|
+
|
|
335
|
+
Prevent duplicate message processing using a TTL-based cache:
|
|
336
|
+
|
|
337
|
+
```typescript
|
|
338
|
+
// CB-4: Message deduplication to prevent duplicate processing
|
|
339
|
+
.withMessageDeduplication(
|
|
340
|
+
true, // Enabled by default
|
|
341
|
+
120000, // 2 minute TTL (increased from default 60s for production)
|
|
342
|
+
50000 // 50k message cache (increased from default 10k for high volume)
|
|
343
|
+
)
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
**How It Works:**
|
|
347
|
+
|
|
348
|
+
- Maintains an in-memory cache of processed message IDs
|
|
349
|
+
- Automatically expires entries after TTL (Time To Live)
|
|
350
|
+
- Bounded size prevents unbounded memory growth
|
|
351
|
+
- Messages without IDs are allowed through (graceful degradation)
|
|
352
|
+
|
|
353
|
+
**Configuration Options:**
|
|
354
|
+
|
|
355
|
+
- `enabled`: Enable/disable deduplication (default: true)
|
|
356
|
+
- `ttl`: How long to remember message IDs in milliseconds (default: 60000ms = 1 minute)
|
|
357
|
+
- `maxSize`: Maximum number of message IDs to cache (default: 10000)
|
|
358
|
+
|
|
359
|
+
**Monitoring:**
|
|
360
|
+
|
|
361
|
+
```bash
|
|
362
|
+
# Check deduplication status
|
|
363
|
+
curl http://localhost:3000/api/deduplication
|
|
364
|
+
|
|
365
|
+
# Response:
|
|
366
|
+
{
|
|
367
|
+
"enabled": true,
|
|
368
|
+
"cacheSize": 1234, // Current number of cached IDs
|
|
369
|
+
"ttl": 120000, // TTL in milliseconds
|
|
370
|
+
"maxSize": 50000, // Maximum cache size
|
|
371
|
+
"utilization": "2.47%" // Cache utilization percentage
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
**Events:**
|
|
376
|
+
|
|
377
|
+
- `message:duplicate` - Emitted when a duplicate message is detected and skipped
|
|
378
|
+
|
|
379
|
+
**Testing:**
|
|
380
|
+
|
|
381
|
+
1. Send the same message multiple times rapidly
|
|
382
|
+
2. Watch Events tab for `message:duplicate` events
|
|
383
|
+
3. Verify duplicates are not processed
|
|
384
|
+
4. Monitor `/api/deduplication` to see cache size increase
|
|
385
|
+
|
|
386
|
+
**Production Benefits:**
|
|
387
|
+
|
|
388
|
+
- Prevents duplicate task execution if messages are retransmitted
|
|
389
|
+
- Protects against network-level duplicates during reconnections
|
|
390
|
+
- Configurable TTL balances memory usage vs duplicate window
|
|
391
|
+
- Zero-cost when messages lack IDs (backwards compatible)
|
|
392
|
+
|
|
393
|
+
### Indexed Agent Lookups (PERF-3)
|
|
394
|
+
|
|
395
|
+
Fast agent searches using O(1) or O(k) indexed lookups instead of O(n) filtering:
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
# Find agents with specific capability (O(1) lookup)
|
|
399
|
+
curl http://localhost:3000/api/agents/search/capability/weather-forecast
|
|
400
|
+
|
|
401
|
+
# Find agents by name (O(k) token-based search)
|
|
402
|
+
curl http://localhost:3000/api/agents/search/name/weather
|
|
403
|
+
|
|
404
|
+
# Find all online agents (O(1) lookup)
|
|
405
|
+
curl http://localhost:3000/api/agents/search/status/online
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
**Performance Comparison:**
|
|
409
|
+
|
|
410
|
+
- Traditional: O(n) - iterate through all agents
|
|
411
|
+
- Indexed: O(1) - direct map lookup for capability/status
|
|
412
|
+
- Indexed: O(k) - token-based search for names (k = tokens)
|
|
413
|
+
|
|
414
|
+
**SDK Usage:**
|
|
415
|
+
|
|
416
|
+
```typescript
|
|
417
|
+
// Fast capability search
|
|
418
|
+
const weatherAgents = sdk.findAgentsByCapability("weather-forecast");
|
|
419
|
+
|
|
420
|
+
// Fast partial name search
|
|
421
|
+
const agentsWithWeather = sdk.findAgentsByName("weather");
|
|
422
|
+
|
|
423
|
+
// Fast status filtering
|
|
424
|
+
const onlineAgents = sdk.findAgentsByStatus("online");
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### Configurable Retry Strategies (REL-3)
|
|
428
|
+
|
|
429
|
+
Customize retry behavior for both WebSocket reconnection and webhook delivery:
|
|
430
|
+
|
|
431
|
+
```typescript
|
|
432
|
+
// Aggressive reconnection for production uptime
|
|
433
|
+
.withReconnectionStrategy({
|
|
434
|
+
type: "exponential", // exponential | linear | constant
|
|
435
|
+
baseDelay: 3000, // First retry after 3s
|
|
436
|
+
maxDelay: 120000, // Cap at 2 minutes
|
|
437
|
+
maxAttempts: 15, // Try up to 15 times
|
|
438
|
+
jitter: true, // Prevent thundering herd
|
|
439
|
+
backoffMultiplier: 2.5 // Faster escalation
|
|
440
|
+
})
|
|
441
|
+
|
|
442
|
+
// Predictable webhook retries
|
|
443
|
+
.withWebhookRetryStrategy({
|
|
444
|
+
type: "exponential",
|
|
445
|
+
baseDelay: 1000,
|
|
446
|
+
maxDelay: 30000,
|
|
447
|
+
maxAttempts: 5,
|
|
448
|
+
jitter: false // Predictable for debugging
|
|
449
|
+
})
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
**Strategy Types:**
|
|
453
|
+
|
|
454
|
+
1. **Exponential** (recommended for production):
|
|
455
|
+
- Delay: `baseDelay * multiplier^(attempt-1)`
|
|
456
|
+
- Example: 1s, 2s, 4s, 8s, 16s...
|
|
457
|
+
- Best for: Network failures, server overload
|
|
458
|
+
|
|
459
|
+
2. **Linear** (predictable delays):
|
|
460
|
+
- Delay: `baseDelay * attempt`
|
|
461
|
+
- Example: 2s, 4s, 6s, 8s, 10s...
|
|
462
|
+
- Best for: Rate-limited APIs
|
|
463
|
+
|
|
464
|
+
3. **Constant** (testing/debugging):
|
|
465
|
+
- Delay: `baseDelay`
|
|
466
|
+
- Example: 5s, 5s, 5s, 5s, 5s...
|
|
467
|
+
- Best for: Testing, fixed intervals
|
|
468
|
+
|
|
469
|
+
**Jitter** adds 0-1000ms random delay to prevent synchronized retries.
|
|
470
|
+
|
|
471
|
+
### Message Signature Verification (SEC-2)
|
|
472
|
+
|
|
473
|
+
When enabled, the SDK verifies Ethereum signatures on incoming messages:
|
|
474
|
+
|
|
475
|
+
```typescript
|
|
476
|
+
.withSignatureVerification({
|
|
477
|
+
enabled: true,
|
|
478
|
+
trustedAddresses: ['0x123...', '0x456...'], // Whitelist
|
|
479
|
+
requireFor: ['task_response', 'agent_selected'], // Required message types
|
|
480
|
+
strictMode: false // Warn vs reject unsigned messages
|
|
481
|
+
})
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
**Events emitted:**
|
|
485
|
+
|
|
486
|
+
- `signature:verified` - Signature validated successfully
|
|
487
|
+
- `signature:failed` - Signature validation failed
|
|
488
|
+
- `signature:missing` - Signature missing but optional
|
|
489
|
+
|
|
490
|
+
### Webhook Integration with Circuit Breaker
|
|
491
|
+
|
|
492
|
+
Webhooks are sent to your endpoint with automatic retry and circuit breaker:
|
|
493
|
+
|
|
494
|
+
```typescript
|
|
495
|
+
sdk.configureWebhook("https://your-server.com/webhook", {
|
|
496
|
+
Authorization: "Bearer token",
|
|
497
|
+
"X-API-Key": "secret"
|
|
498
|
+
});
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
**Circuit Breaker States:**
|
|
502
|
+
|
|
503
|
+
- `CLOSED` - Normal operation
|
|
504
|
+
- `OPEN` - Too many failures, webhooks paused
|
|
505
|
+
- `HALF_OPEN` - Testing if service recovered
|
|
506
|
+
|
|
507
|
+
**Webhook Events:**
|
|
508
|
+
|
|
509
|
+
- `webhook:sent` - Webhook sent to endpoint
|
|
510
|
+
- `webhook:success` - Endpoint acknowledged
|
|
511
|
+
- `webhook:error` - Delivery failed
|
|
512
|
+
- `webhook:retry` - Retry attempt
|
|
513
|
+
|
|
514
|
+
### Health Monitoring
|
|
515
|
+
|
|
516
|
+
The `/health` endpoint returns comprehensive status:
|
|
517
|
+
|
|
518
|
+
```json
|
|
519
|
+
{
|
|
520
|
+
"status": "healthy",
|
|
521
|
+
"timestamp": "2024-10-14T00:00:00.000Z",
|
|
522
|
+
"connection": {
|
|
523
|
+
"status": "connected",
|
|
524
|
+
"authenticated": true,
|
|
525
|
+
"reconnectAttempts": 0
|
|
526
|
+
},
|
|
527
|
+
"webhook": {
|
|
528
|
+
"configured": true,
|
|
529
|
+
"status": "healthy",
|
|
530
|
+
"pending": 0,
|
|
531
|
+
"failed": 0,
|
|
532
|
+
"circuitState": "CLOSED"
|
|
533
|
+
},
|
|
534
|
+
"agents": {
|
|
535
|
+
"count": 5
|
|
536
|
+
},
|
|
537
|
+
"rooms": {
|
|
538
|
+
"count": 3,
|
|
539
|
+
"subscribedRooms": ["general", "announcements"]
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
### Rate Limiting
|
|
545
|
+
|
|
546
|
+
The SDK includes built-in rate limiting to prevent overwhelming the server:
|
|
547
|
+
|
|
548
|
+
```typescript
|
|
549
|
+
.withCache(true, 300000, 100)
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
Monitor rate limit status via `/metrics` endpoint.
|
|
553
|
+
|
|
554
|
+
## 🧪 Testing the Features
|
|
555
|
+
|
|
556
|
+
### 1. Test Connection & Authentication
|
|
557
|
+
|
|
558
|
+
- Open dashboard
|
|
559
|
+
- Watch connection status turn green
|
|
560
|
+
- See authentication complete with wallet address
|
|
561
|
+
|
|
562
|
+
### 2. Test Message Sending
|
|
563
|
+
|
|
564
|
+
- Type a message in the input box
|
|
565
|
+
- Click "Send Message" (fire and forget)
|
|
566
|
+
- Click "Send & Wait" (wait for response)
|
|
567
|
+
- View response in Messages tab
|
|
568
|
+
|
|
569
|
+
### 3. Test Agent Selection
|
|
570
|
+
|
|
571
|
+
- Send: "What is blockchain?"
|
|
572
|
+
- Watch Events tab for `agent:selected` event
|
|
573
|
+
- See coordinator's reasoning for agent selection
|
|
574
|
+
|
|
575
|
+
### 4. Test Webhooks
|
|
576
|
+
|
|
577
|
+
- Send a message
|
|
578
|
+
- Watch Webhooks tab for incoming webhook events
|
|
579
|
+
- See event types: `task`, `agent_selected`, `task_response`
|
|
580
|
+
|
|
581
|
+
### 5. Test Room Management (v1)
|
|
582
|
+
|
|
583
|
+
- Go to Rooms tab
|
|
584
|
+
- Enter a room ID
|
|
585
|
+
- Click "Subscribe to Room"
|
|
586
|
+
- See room appear in subscribed list
|
|
587
|
+
- Click "Unsubscribe" to unsubscribe from room
|
|
588
|
+
|
|
589
|
+
### 5b. Test Room Management v2.0
|
|
590
|
+
|
|
591
|
+
- Go to **Room Mgmt** tab
|
|
592
|
+
- See your owned and shared rooms
|
|
593
|
+
- Check your room limit (e.g., "2/50 rooms")
|
|
594
|
+
- **Create a room**: Enter name and description, click "Create Room"
|
|
595
|
+
- See room appear in "Private Rooms" list with owner badge
|
|
596
|
+
- **Update room**: Click "Update" on an owned room, modify name/description
|
|
597
|
+
- **Delete room**: Click "Delete" on an owned room
|
|
598
|
+
- Watch Events tab for `room:created`, `room:updated`, `room:deleted` events
|
|
599
|
+
|
|
600
|
+
### 5c. Test Agent-Room Management v2.0
|
|
601
|
+
|
|
602
|
+
- Go to **Agent-Room** tab
|
|
603
|
+
- Select a room you own from the dropdown
|
|
604
|
+
- See "Agents in Room" list (may be empty for new rooms)
|
|
605
|
+
- See "Available Agents" list (agents you can add)
|
|
606
|
+
- **Add an agent**: Click "Add" next to an available agent
|
|
607
|
+
- Watch agent move from "Available" to "Agents in Room"
|
|
608
|
+
- See agent count update in real-time
|
|
609
|
+
- **Remove an agent**: Click "Remove" next to an agent in room
|
|
610
|
+
- Watch Events tab for `agent_room:agent_added`, `agent_room:agent_removed` events
|
|
611
|
+
|
|
612
|
+
### 6. Test Signature Verification
|
|
613
|
+
|
|
614
|
+
- Enable in `.env`: `ENABLE_SIGNATURE_VERIFICATION=true`
|
|
615
|
+
- Add trusted addresses
|
|
616
|
+
- Watch Events tab for `signature:verified` events
|
|
617
|
+
- See failed verifications for untrusted addresses
|
|
618
|
+
|
|
619
|
+
### 7. Test Health Monitoring
|
|
620
|
+
|
|
621
|
+
- Open: `http://localhost:3000/health`
|
|
622
|
+
- See comprehensive health status
|
|
623
|
+
- Monitor circuit breaker state
|
|
624
|
+
- Check metrics: `http://localhost:3000/metrics`
|
|
625
|
+
|
|
626
|
+
### 8. Test Message Deduplication (CB-4)
|
|
627
|
+
|
|
628
|
+
- Send a message and note the response
|
|
629
|
+
- Simulate network issues by sending the same message multiple times
|
|
630
|
+
- Watch Events tab for `message:duplicate` events
|
|
631
|
+
- Verify only the first message is processed
|
|
632
|
+
- Check deduplication status:
|
|
633
|
+
```bash
|
|
634
|
+
curl http://localhost:3000/api/deduplication
|
|
635
|
+
```
|
|
636
|
+
- See cache size increase with each unique message
|
|
637
|
+
- Wait for TTL to expire and verify cache cleanup
|
|
638
|
+
|
|
639
|
+
### 9. Test Indexed Agent Lookups (PERF-3)
|
|
640
|
+
|
|
641
|
+
- Search by capability:
|
|
642
|
+
```bash
|
|
643
|
+
curl http://localhost:3000/api/agents/search/capability/weather
|
|
644
|
+
```
|
|
645
|
+
- Search by name:
|
|
646
|
+
```bash
|
|
647
|
+
curl http://localhost:3000/api/agents/search/name/weather
|
|
648
|
+
```
|
|
649
|
+
- Search by status:
|
|
650
|
+
```bash
|
|
651
|
+
curl http://localhost:3000/api/agents/search/status/online
|
|
652
|
+
```
|
|
653
|
+
- Compare response times with large agent lists
|
|
654
|
+
|
|
655
|
+
### 10. Test Retry Strategies (REL-3)
|
|
656
|
+
|
|
657
|
+
- Disconnect from network
|
|
658
|
+
- Watch Events tab for reconnection attempts
|
|
659
|
+
- Observe exponential backoff with jitter: 3s, ~7.5s, ~18.75s...
|
|
660
|
+
- See max 15 attempts before giving up
|
|
661
|
+
- Reconnect network and see instant recovery
|
|
662
|
+
|
|
663
|
+
### 11. Verify Private Key Encryption (SEC-3)
|
|
664
|
+
|
|
665
|
+
- Check server logs for "Private key encrypted in memory" message
|
|
666
|
+
- Confirm no private key appears in any logs or API responses
|
|
667
|
+
- Private key is only decrypted when signing messages
|
|
668
|
+
|
|
669
|
+
## 🏗️ Architecture
|
|
670
|
+
|
|
671
|
+
```
|
|
672
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
673
|
+
│ Dashboard UI (Browser) │
|
|
674
|
+
│ ┌────────┬─────────┬──────────┬───────────┬────────────┐ │
|
|
675
|
+
│ │ Status │ Agents │ Rooms │ Messages │ Webhooks │ │
|
|
676
|
+
│ └────────┴─────────┴──────────┴───────────┴────────────┘ │
|
|
677
|
+
└─────────────────────┬───────────────────────────────────────┘
|
|
678
|
+
│ HTTP + SSE
|
|
679
|
+
┌─────────────────────▼───────────────────────────────────────┐
|
|
680
|
+
│ Hono Server (Bun) │
|
|
681
|
+
│ ┌──────────────┐ ┌─────────────┐ ┌──────────────────┐ │
|
|
682
|
+
│ │ API Routes │ │ SSE Stream │ │ Webhook Receiver │ │
|
|
683
|
+
│ └──────────────┘ └─────────────┘ └──────────────────┘ │
|
|
684
|
+
└─────────────────────┬───────────────────────────────────────┘
|
|
685
|
+
│
|
|
686
|
+
┌─────────────────────▼───────────────────────────────────────┐
|
|
687
|
+
│ Teneo SDK │
|
|
688
|
+
│ ┌──────────┬──────────┬──────────┬──────────┬──────────┐ │
|
|
689
|
+
│ │WebSocket │ Auth │ Messages │ Rooms │ Webhooks │ │
|
|
690
|
+
│ │ Client │ Manager │ Router │ Manager │ Handler │ │
|
|
691
|
+
│ └──────────┴──────────┴──────────┴──────────┴──────────┘ │
|
|
692
|
+
│ ┌──────────────────────────────────────────────────────┐ │
|
|
693
|
+
│ │ Signature Verifier │ Rate Limiter │ Circuit Breaker │ │
|
|
694
|
+
│ └──────────────────────────────────────────────────────┘ │
|
|
695
|
+
└─────────────────────┬───────────────────────────────────────┘
|
|
696
|
+
│ WebSocket
|
|
697
|
+
┌─────────────────────▼───────────────────────────────────────┐
|
|
698
|
+
│ Teneo AI Network │
|
|
699
|
+
│ ┌──────────┬──────────┬──────────┬──────────┐ │
|
|
700
|
+
│ │ Agent 1 │ Agent 2 │ Agent 3 │ Agent N │ │
|
|
701
|
+
│ └──────────┴──────────┴──────────┴──────────┘ │
|
|
702
|
+
└──────────────────────────────────────────────────────────────┘
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
## 🐛 Troubleshooting
|
|
706
|
+
|
|
707
|
+
### Connection Issues
|
|
708
|
+
|
|
709
|
+
- **Problem**: Dashboard shows "Disconnected"
|
|
710
|
+
- **Solution**: Check `.env` file has correct `WS_URL` and credentials
|
|
711
|
+
- **Check**: Look at server console for error messages
|
|
712
|
+
|
|
713
|
+
### Authentication Failures
|
|
714
|
+
|
|
715
|
+
- **Problem**: "Authentication Pending" never completes
|
|
716
|
+
- **Solution**: Verify `PRIVATE_KEY` and `WALLET_ADDRESS` are correct
|
|
717
|
+
- **Check**: Ensure wallet has access to the Teneo network
|
|
718
|
+
|
|
719
|
+
### Webhook Not Receiving
|
|
720
|
+
|
|
721
|
+
- **Problem**: Webhooks tab is empty
|
|
722
|
+
- **Solution**: Webhooks are configured to `localhost` by default
|
|
723
|
+
- **Note**: For production, use a publicly accessible URL
|
|
724
|
+
|
|
725
|
+
### Signature Verification Errors
|
|
726
|
+
|
|
727
|
+
- **Problem**: All messages fail verification
|
|
728
|
+
- **Solution**: Check `TRUSTED_ADDRESSES` includes agent addresses
|
|
729
|
+
- **Tip**: Set `strictMode: false` to allow unsigned messages
|
|
730
|
+
|
|
731
|
+
### Port Already in Use
|
|
732
|
+
|
|
733
|
+
- **Problem**: `EADDRINUSE: address already in use`
|
|
734
|
+
- **Solution**: Change `PORT` in `.env` or kill existing process
|
|
735
|
+
- **Command**: `lsof -ti:3000 | xargs kill -9` (Mac/Linux)
|
|
736
|
+
|
|
737
|
+
## 📚 Learn More
|
|
738
|
+
|
|
739
|
+
### Related Documentation
|
|
740
|
+
|
|
741
|
+
- [Teneo SDK Documentation](../../README.md)
|
|
742
|
+
- [Hono Framework](https://hono.dev)
|
|
743
|
+
- [Bun Runtime](https://bun.sh)
|
|
744
|
+
|
|
745
|
+
### Other Examples
|
|
746
|
+
|
|
747
|
+
- [Basic Usage](../basic-usage.ts) - Simple CLI example
|
|
748
|
+
- [Webhook Integration](../webhook-integration.ts) - Webhook focus
|
|
749
|
+
- [Battle App](../x-influencer-battle-server.ts) - Specific use case
|
|
750
|
+
|
|
751
|
+
## 🚢 Deployment
|
|
752
|
+
|
|
753
|
+
### Docker
|
|
754
|
+
|
|
755
|
+
```dockerfile
|
|
756
|
+
FROM oven/bun:1
|
|
757
|
+
|
|
758
|
+
WORKDIR /app
|
|
759
|
+
COPY package.json bun.lockb ./
|
|
760
|
+
RUN bun install
|
|
761
|
+
|
|
762
|
+
COPY . .
|
|
763
|
+
|
|
764
|
+
ENV PORT=3000
|
|
765
|
+
EXPOSE 3000
|
|
766
|
+
|
|
767
|
+
CMD ["bun", "run", "server.ts"]
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
### Kubernetes
|
|
771
|
+
|
|
772
|
+
```yaml
|
|
773
|
+
apiVersion: v1
|
|
774
|
+
kind: Service
|
|
775
|
+
metadata:
|
|
776
|
+
name: teneo-dashboard
|
|
777
|
+
spec:
|
|
778
|
+
type: LoadBalancer
|
|
779
|
+
ports:
|
|
780
|
+
- port: 80
|
|
781
|
+
targetPort: 3000
|
|
782
|
+
selector:
|
|
783
|
+
app: teneo-dashboard
|
|
784
|
+
|
|
785
|
+
---
|
|
786
|
+
apiVersion: apps/v1
|
|
787
|
+
kind: Deployment
|
|
788
|
+
metadata:
|
|
789
|
+
name: teneo-dashboard
|
|
790
|
+
spec:
|
|
791
|
+
replicas: 2
|
|
792
|
+
selector:
|
|
793
|
+
matchLabels:
|
|
794
|
+
app: teneo-dashboard
|
|
795
|
+
template:
|
|
796
|
+
metadata:
|
|
797
|
+
labels:
|
|
798
|
+
app: teneo-dashboard
|
|
799
|
+
spec:
|
|
800
|
+
containers:
|
|
801
|
+
- name: dashboard
|
|
802
|
+
image: your-registry/teneo-dashboard:latest
|
|
803
|
+
ports:
|
|
804
|
+
- containerPort: 3000
|
|
805
|
+
env:
|
|
806
|
+
- name: WS_URL
|
|
807
|
+
valueFrom:
|
|
808
|
+
secretKeyRef:
|
|
809
|
+
name: teneo-secrets
|
|
810
|
+
key: ws-url
|
|
811
|
+
livenessProbe:
|
|
812
|
+
httpGet:
|
|
813
|
+
path: /health
|
|
814
|
+
port: 3000
|
|
815
|
+
initialDelaySeconds: 30
|
|
816
|
+
periodSeconds: 10
|
|
817
|
+
```
|
|
818
|
+
|
|
819
|
+
## 📝 License
|
|
820
|
+
|
|
821
|
+
MIT - See [LICENSE](../../LICENSE) for details
|
|
822
|
+
|
|
823
|
+
## 🤝 Contributing
|
|
824
|
+
|
|
825
|
+
This example is part of the Teneo Protocol SDK. For contributions, please see the main [CONTRIBUTING.md](../../CONTRIBUTING.md).
|
|
826
|
+
|
|
827
|
+
## 💡 Tips
|
|
828
|
+
|
|
829
|
+
- **Development**: Use `bun --watch server.ts` for auto-reload
|
|
830
|
+
- **Production**: Set `logLevel: 'info'` and enable all security features
|
|
831
|
+
- **Monitoring**: Integrate `/health` endpoint with your monitoring stack
|
|
832
|
+
- **Scaling**: Dashboard is stateless and can be horizontally scaled
|
|
833
|
+
- **Security**: Always use HTTPS webhooks in production
|
|
834
|
+
|
|
835
|
+
---
|
|
836
|
+
|
|
837
|
+
**🎉 Enjoy exploring the Teneo SDK!**
|
|
838
|
+
|
|
839
|
+
For questions or issues, visit our [GitHub repository](https://github.com/TeneoProtocolAI/sdk).
|