@teneo-protocol/sdk 2.2.1 → 3.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.
Files changed (228) hide show
  1. package/.github/ISSUE_TEMPLATE/config.yml +1 -1
  2. package/CHANGELOG.md +366 -15
  3. package/CONCEPTS.md +182 -44
  4. package/README.md +543 -104
  5. package/dist/constants.d.ts +3 -1
  6. package/dist/constants.d.ts.map +1 -1
  7. package/dist/constants.js +5 -3
  8. package/dist/constants.js.map +1 -1
  9. package/dist/core/websocket-client.d.ts.map +1 -1
  10. package/dist/core/websocket-client.js +9 -5
  11. package/dist/core/websocket-client.js.map +1 -1
  12. package/dist/formatters/response-formatter.d.ts +6 -6
  13. package/dist/handlers/message-handlers/agent-details-response-handler.d.ts +756 -756
  14. package/dist/handlers/message-handlers/agent-details-response-handler.js +2 -2
  15. package/dist/handlers/message-handlers/agent-details-response-handler.js.map +1 -1
  16. package/dist/handlers/message-handlers/agent-error-handler.d.ts +91 -0
  17. package/dist/handlers/message-handlers/agent-error-handler.d.ts.map +1 -0
  18. package/dist/handlers/message-handlers/agent-error-handler.js +44 -0
  19. package/dist/handlers/message-handlers/agent-error-handler.js.map +1 -0
  20. package/dist/handlers/message-handlers/agent-selected-handler.d.ts +6 -0
  21. package/dist/handlers/message-handlers/agent-selected-handler.d.ts.map +1 -1
  22. package/dist/handlers/message-handlers/agent-status-update-handler.d.ts +756 -756
  23. package/dist/handlers/message-handlers/agent-status-update-handler.d.ts.map +1 -1
  24. package/dist/handlers/message-handlers/agent-status-update-handler.js +2 -7
  25. package/dist/handlers/message-handlers/agent-status-update-handler.js.map +1 -1
  26. package/dist/handlers/message-handlers/all-agents-response-handler.js +2 -2
  27. package/dist/handlers/message-handlers/all-agents-response-handler.js.map +1 -1
  28. package/dist/handlers/message-handlers/auth-error-handler.d.ts +6 -0
  29. package/dist/handlers/message-handlers/auth-error-handler.d.ts.map +1 -1
  30. package/dist/handlers/message-handlers/auth-message-handler.d.ts.map +1 -1
  31. package/dist/handlers/message-handlers/auth-message-handler.js +6 -1
  32. package/dist/handlers/message-handlers/auth-message-handler.js.map +1 -1
  33. package/dist/handlers/message-handlers/auth-required-handler.d.ts +6 -0
  34. package/dist/handlers/message-handlers/auth-required-handler.d.ts.map +1 -1
  35. package/dist/handlers/message-handlers/auth-success-handler.d.ts.map +1 -1
  36. package/dist/handlers/message-handlers/auth-success-handler.js +6 -1
  37. package/dist/handlers/message-handlers/auth-success-handler.js.map +1 -1
  38. package/dist/handlers/message-handlers/base-handler.d.ts +2 -1
  39. package/dist/handlers/message-handlers/base-handler.d.ts.map +1 -1
  40. package/dist/handlers/message-handlers/base-handler.js +24 -4
  41. package/dist/handlers/message-handlers/base-handler.js.map +1 -1
  42. package/dist/handlers/message-handlers/challenge-handler.d.ts +6 -0
  43. package/dist/handlers/message-handlers/challenge-handler.d.ts.map +1 -1
  44. package/dist/handlers/message-handlers/error-message-handler.d.ts +6 -0
  45. package/dist/handlers/message-handlers/error-message-handler.d.ts.map +1 -1
  46. package/dist/handlers/message-handlers/index.d.ts +4 -0
  47. package/dist/handlers/message-handlers/index.d.ts.map +1 -1
  48. package/dist/handlers/message-handlers/index.js +23 -1
  49. package/dist/handlers/message-handlers/index.js.map +1 -1
  50. package/dist/handlers/message-handlers/list-available-agents-handler.d.ts +792 -756
  51. package/dist/handlers/message-handlers/list-available-agents-handler.d.ts.map +1 -1
  52. package/dist/handlers/message-handlers/list-available-agents-handler.js +23 -10
  53. package/dist/handlers/message-handlers/list-available-agents-handler.js.map +1 -1
  54. package/dist/handlers/message-handlers/list-room-agents-handler.d.ts +756 -756
  55. package/dist/handlers/message-handlers/list-room-agents-handler.d.ts.map +1 -1
  56. package/dist/handlers/message-handlers/list-room-agents-handler.js +2 -6
  57. package/dist/handlers/message-handlers/list-room-agents-handler.js.map +1 -1
  58. package/dist/handlers/message-handlers/list-rooms-response-handler.d.ts.map +1 -1
  59. package/dist/handlers/message-handlers/list-rooms-response-handler.js +2 -5
  60. package/dist/handlers/message-handlers/list-rooms-response-handler.js.map +1 -1
  61. package/dist/handlers/message-handlers/ping-pong-handler.d.ts +52 -4
  62. package/dist/handlers/message-handlers/ping-pong-handler.d.ts.map +1 -1
  63. package/dist/handlers/message-handlers/ping-pong-handler.js +23 -4
  64. package/dist/handlers/message-handlers/ping-pong-handler.js.map +1 -1
  65. package/dist/handlers/message-handlers/rate-limit-notification-handler.d.ts.map +1 -1
  66. package/dist/handlers/message-handlers/rate-limit-notification-handler.js +3 -2
  67. package/dist/handlers/message-handlers/rate-limit-notification-handler.js.map +1 -1
  68. package/dist/handlers/message-handlers/regular-message-handler.d.ts +6 -0
  69. package/dist/handlers/message-handlers/regular-message-handler.d.ts.map +1 -1
  70. package/dist/handlers/message-handlers/subscribe-response-handler.d.ts +12 -6
  71. package/dist/handlers/message-handlers/subscribe-response-handler.d.ts.map +1 -1
  72. package/dist/handlers/message-handlers/success-handler.d.ts +82 -0
  73. package/dist/handlers/message-handlers/success-handler.d.ts.map +1 -0
  74. package/dist/handlers/message-handlers/success-handler.js +24 -0
  75. package/dist/handlers/message-handlers/success-handler.js.map +1 -0
  76. package/dist/handlers/message-handlers/task-confirmed-handler.d.ts +110 -0
  77. package/dist/handlers/message-handlers/task-confirmed-handler.d.ts.map +1 -0
  78. package/dist/handlers/message-handlers/task-confirmed-handler.js +46 -0
  79. package/dist/handlers/message-handlers/task-confirmed-handler.js.map +1 -0
  80. package/dist/handlers/message-handlers/trigger-wallet-tx-handler.d.ts +244 -0
  81. package/dist/handlers/message-handlers/trigger-wallet-tx-handler.d.ts.map +1 -0
  82. package/dist/handlers/message-handlers/trigger-wallet-tx-handler.js +58 -0
  83. package/dist/handlers/message-handlers/trigger-wallet-tx-handler.js.map +1 -0
  84. package/dist/handlers/message-handlers/unsubscribe-response-handler.d.ts +12 -6
  85. package/dist/handlers/message-handlers/unsubscribe-response-handler.d.ts.map +1 -1
  86. package/dist/handlers/message-handlers/user-authenticated-handler.js +2 -2
  87. package/dist/handlers/message-handlers/user-authenticated-handler.js.map +1 -1
  88. package/dist/handlers/message-handlers/user-count-handler.js +2 -2
  89. package/dist/handlers/message-handlers/user-count-handler.js.map +1 -1
  90. package/dist/index.d.ts +3 -3
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +11 -4
  93. package/dist/index.js.map +1 -1
  94. package/dist/managers/admin-manager.d.ts +2 -0
  95. package/dist/managers/admin-manager.d.ts.map +1 -1
  96. package/dist/managers/admin-manager.js +3 -2
  97. package/dist/managers/admin-manager.js.map +1 -1
  98. package/dist/managers/agent-room-manager.d.ts +89 -11
  99. package/dist/managers/agent-room-manager.d.ts.map +1 -1
  100. package/dist/managers/agent-room-manager.js +99 -35
  101. package/dist/managers/agent-room-manager.js.map +1 -1
  102. package/dist/managers/index.d.ts +1 -1
  103. package/dist/managers/index.d.ts.map +1 -1
  104. package/dist/managers/index.js.map +1 -1
  105. package/dist/managers/message-router.d.ts +45 -5
  106. package/dist/managers/message-router.d.ts.map +1 -1
  107. package/dist/managers/message-router.js +96 -24
  108. package/dist/managers/message-router.js.map +1 -1
  109. package/dist/managers/room-manager.d.ts +29 -7
  110. package/dist/managers/room-manager.d.ts.map +1 -1
  111. package/dist/managers/room-manager.js +37 -11
  112. package/dist/managers/room-manager.js.map +1 -1
  113. package/dist/payments/index.d.ts +3 -1
  114. package/dist/payments/index.d.ts.map +1 -1
  115. package/dist/payments/index.js +17 -3
  116. package/dist/payments/index.js.map +1 -1
  117. package/dist/payments/networks.d.ts +59 -0
  118. package/dist/payments/networks.d.ts.map +1 -0
  119. package/dist/payments/networks.js +192 -0
  120. package/dist/payments/networks.js.map +1 -0
  121. package/dist/payments/payment-client.d.ts +55 -10
  122. package/dist/payments/payment-client.d.ts.map +1 -1
  123. package/dist/payments/payment-client.js +172 -51
  124. package/dist/payments/payment-client.js.map +1 -1
  125. package/dist/teneo-sdk.d.ts +214 -40
  126. package/dist/teneo-sdk.d.ts.map +1 -1
  127. package/dist/teneo-sdk.js +376 -85
  128. package/dist/teneo-sdk.js.map +1 -1
  129. package/dist/types/config.d.ts +335 -26
  130. package/dist/types/config.d.ts.map +1 -1
  131. package/dist/types/config.js +117 -22
  132. package/dist/types/config.js.map +1 -1
  133. package/dist/types/events.d.ts +60 -14
  134. package/dist/types/events.d.ts.map +1 -1
  135. package/dist/types/events.js.map +1 -1
  136. package/dist/types/index.d.ts +1 -1
  137. package/dist/types/index.d.ts.map +1 -1
  138. package/dist/types/index.js +11 -4
  139. package/dist/types/index.js.map +1 -1
  140. package/dist/types/messages.d.ts +9801 -7222
  141. package/dist/types/messages.d.ts.map +1 -1
  142. package/dist/types/messages.js +180 -40
  143. package/dist/types/messages.js.map +1 -1
  144. package/dist/utils/pricing-resolver.d.ts +1 -1
  145. package/dist/utils/pricing-resolver.d.ts.map +1 -1
  146. package/dist/utils/pricing-resolver.js +9 -1
  147. package/dist/utils/pricing-resolver.js.map +1 -1
  148. package/examples/agent-room-management-example.ts +5 -5
  149. package/examples/basic-usage.ts +26 -6
  150. package/examples/claude-agent-x-follower/index.ts +1 -1
  151. package/examples/minimal-chat.ts +115 -0
  152. package/examples/n8n-teneo/index.ts +2 -2
  153. package/examples/nestjs-dashboard/README.md +1 -1
  154. package/examples/nestjs-dashboard/src/teneo/agents.controller.ts +3 -3
  155. package/examples/nestjs-dashboard/src/teneo/rooms.controller.ts +5 -5
  156. package/examples/nestjs-dashboard/src/teneo/teneo.service.ts +8 -8
  157. package/examples/openai-teneo/index.ts +1 -1
  158. package/examples/payment-flow.ts +143 -0
  159. package/examples/production-dashboard/README.md +6 -8
  160. package/examples/production-dashboard/server.ts +22 -10
  161. package/examples/room-management-example.ts +2 -2
  162. package/examples/usage/01-connect.ts +0 -3
  163. package/examples/usage/02-list-agents.ts +0 -2
  164. package/examples/usage/03-pick-agent.ts +3 -4
  165. package/examples/usage/04-find-by-capability.ts +10 -12
  166. package/examples/usage/05-webhook-example.ts +2 -4
  167. package/examples/usage/06-simple-api-server.ts +13 -9
  168. package/examples/usage/07-event-listener.ts +1 -13
  169. package/examples/usage/README.md +33 -7
  170. package/examples/webhook-integration.ts +9 -9
  171. package/examples/x-influencer-battle-server.ts +1 -1
  172. package/package.json +3 -2
  173. package/scripts/diagnose-connection.ts +86 -0
  174. package/scripts/investigate-payload.ts +163 -0
  175. package/scripts/list-agents.ts +58 -0
  176. package/scripts/live-multi-network-test.ts +230 -0
  177. package/src/constants.ts +5 -3
  178. package/src/core/websocket-client.ts +10 -9
  179. package/src/handlers/message-handlers/agent-details-response-handler.ts +2 -2
  180. package/src/handlers/message-handlers/agent-error-handler.ts +47 -0
  181. package/src/handlers/message-handlers/agent-status-update-handler.ts +2 -7
  182. package/src/handlers/message-handlers/all-agents-response-handler.ts +2 -2
  183. package/src/handlers/message-handlers/auth-message-handler.ts +7 -1
  184. package/src/handlers/message-handlers/auth-success-handler.ts +7 -1
  185. package/src/handlers/message-handlers/base-handler.ts +24 -4
  186. package/src/handlers/message-handlers/index.ts +24 -0
  187. package/src/handlers/message-handlers/list-available-agents-handler.ts +24 -11
  188. package/src/handlers/message-handlers/list-room-agents-handler.ts +2 -6
  189. package/src/handlers/message-handlers/list-rooms-response-handler.ts +2 -5
  190. package/src/handlers/message-handlers/ping-pong-handler.ts +29 -4
  191. package/src/handlers/message-handlers/rate-limit-notification-handler.ts +3 -2
  192. package/src/handlers/message-handlers/success-handler.ts +26 -0
  193. package/src/handlers/message-handlers/task-confirmed-handler.ts +49 -0
  194. package/src/handlers/message-handlers/trigger-wallet-tx-handler.ts +62 -0
  195. package/src/handlers/message-handlers/user-authenticated-handler.ts +2 -2
  196. package/src/handlers/message-handlers/user-count-handler.ts +2 -2
  197. package/src/index.ts +12 -4
  198. package/src/managers/admin-manager.ts +5 -2
  199. package/src/managers/agent-room-manager.ts +155 -26
  200. package/src/managers/index.ts +6 -1
  201. package/src/managers/message-router.ts +122 -27
  202. package/src/managers/room-manager.ts +39 -11
  203. package/src/payments/index.ts +20 -5
  204. package/src/payments/networks.ts +208 -0
  205. package/src/payments/payment-client.ts +211 -56
  206. package/src/teneo-sdk.ts +417 -72
  207. package/src/types/config.test.ts +24 -4
  208. package/src/types/config.ts +127 -26
  209. package/src/types/events.ts +36 -2
  210. package/src/types/index.ts +16 -3
  211. package/src/types/messages.ts +221 -57
  212. package/src/utils/pricing-resolver.ts +10 -2
  213. package/tests/direct-agent-test.ts +1 -1
  214. package/tests/integration/real-server.test.ts +1 -1
  215. package/tests/integration/websocket.test.ts +3 -3
  216. package/tests/multi-network-payment.test.ts +309 -0
  217. package/tests/multi-network.test.ts +296 -0
  218. package/tests/payment-flow-test.ts +6 -4
  219. package/tests/unit/handlers/agent-error-handler.test.ts +388 -0
  220. package/tests/unit/handlers/agent-room-operation-response-handler.test.ts +9 -6
  221. package/tests/unit/handlers/agent-status-update-handler.test.ts +11 -16
  222. package/tests/unit/handlers/list-available-agents-handler.test.ts +11 -14
  223. package/tests/unit/handlers/list-room-agents-handler.test.ts +11 -15
  224. package/tests/unit/handlers/room-operation-response-handler.test.ts +9 -6
  225. package/tests/unit/handlers/trigger-wallet-tx-handler.test.ts +431 -0
  226. package/tests/unit/managers/admin-manager.test.ts +183 -0
  227. package/tests/unit/managers/agent-room-manager.test.ts +189 -33
  228. package/tests/unit/sdk-new-methods.test.ts +221 -0
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **Connect your app to the Teneo AI Agent Network**
4
4
 
5
- [![npm version](https://img.shields.io/badge/version-2.2.0-blue)](https://www.npmjs.com/package/@teneo-protocol/sdk)
5
+ [![npm version](https://img.shields.io/badge/version-3.0.0-blue)](https://www.npmjs.com/package/@teneo-protocol/sdk)
6
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.3-blue)](https://www.typescriptlang.org/)
7
7
  [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D18-green)](https://nodejs.org/)
8
8
  [![Tests](https://img.shields.io/badge/tests-671%20passing-success)](/)
@@ -15,6 +15,30 @@ The Teneo Protocol SDK lets you connect your application to a **decentralized ne
15
15
 
16
16
  ---
17
17
 
18
+ ## 🎉 What's New in v3.0
19
+
20
+ Version 3.0 introduces **API Naming Improvements** for better clarity and consistency:
21
+
22
+ ### 📝 Clearer Method Names
23
+
24
+ All method names have been improved to be more explicit and intuitive:
25
+
26
+ - **Room subscriptions** - `subscribeToPublicRoom()` makes it clear these only work for public rooms
27
+ - **Cache-only methods** - `getCached*()` prefix makes sync vs async operations obvious
28
+ - **Boolean semantics** - `checkAgentInRoom()` clearly indicates it may return `undefined`
29
+ - **Search scope** - `findAvailableAgentsBy*()` clarifies network-wide search
30
+
31
+ ### 🔄 Fully Backward Compatible
32
+
33
+ **All old method names still work!** They're deprecated with helpful aliases:
34
+ - Old names forward to new implementations
35
+ - TypeScript shows deprecation warnings
36
+ - Migrate at your convenience
37
+
38
+ [Jump to Migration Guide](#v300-migration-guide) | [See Full CHANGELOG](CHANGELOG.md#300---2026-01-28)
39
+
40
+ ---
41
+
18
42
  ## 🚀 Quickstart
19
43
 
20
44
  ### Installation
@@ -23,7 +47,7 @@ The Teneo Protocol SDK lets you connect your application to a **decentralized ne
23
47
  pnpm install @teneo-protocol/sdk
24
48
  ```
25
49
 
26
- ### Your First Connection (10 Lines)
50
+ ### Your First Connection
27
51
 
28
52
  ```typescript
29
53
  import { TeneoSDK } from "@teneo-protocol/sdk";
@@ -31,7 +55,7 @@ import { TeneoSDK } from "@teneo-protocol/sdk";
31
55
  // 1. Initialize with your Ethereum private key
32
56
  const sdk = new TeneoSDK({
33
57
  wsUrl: "wss://backend.developer.chatroom.teneo-protocol.ai/ws",
34
- privateKey: "your_private_key_here" // No 0x prefix
58
+ privateKey: "0x..." // Your private key with 0x prefix
35
59
  });
36
60
 
37
61
  // 2. Listen for responses
@@ -39,62 +63,62 @@ sdk.on("agent:response", (response) => {
39
63
  console.log(`${response.agentName}: ${response.humanized}`);
40
64
  });
41
65
 
42
- // 3. Connect and send a message
66
+ // 3. Connect (authenticates automatically)
43
67
  await sdk.connect();
44
- await sdk.sendMessage("Give me the last 5 tweets from @elonmusk");
45
-
46
- // The coordinator will select proper agent and return the results
47
- ```
48
-
49
- **That's it!** The coordinator automatically:
50
-
51
- 1. Routes your message to the right agent
52
- 2. Gets the response
53
- 3. Delivers it via the event you're listening to
54
-
55
- ---
56
-
57
- ## ✨ What's New in v2.2
58
-
59
- Version 2.2 introduces the **Quote-Approve Payment Flow** with x402 protocol support:
60
-
61
- ### 💰 Payment Flow (Quote-Approve)
62
-
63
- - **Automatic payment handling** - SDK handles the full quote → confirm → pay cycle
64
- - **x402 Protocol** - Industry-standard payment headers (Coinbase x402)
65
- - **USDC on PEAQ** - Payments settle on PEAQ network (Chain ID 3338)
66
- - **Price limits** - Set maximum price per request for safety
67
-
68
- [Jump to Payment Flow API](#-payment-flow-api)
69
-
70
- ---
71
-
72
- ## ✨ What's New in v2.0
73
-
74
- Version 2.0 introduces powerful **room management** and **agent customization** capabilities:
75
-
76
- ### 🏠 Multi-Room Management
77
68
 
78
- - **Create multiple rooms** for different contexts (crypto, gaming, research, etc.)
79
- - **Update and delete** your owned rooms
80
- - **Track room limits** based on your subscription tier
81
- - **Invite members** to your rooms (coming soon)
69
+ // 4. Get your private rooms (auto-available after auth)
70
+ const rooms = sdk.getRooms();
71
+ const roomId = rooms[0].id;
82
72
 
83
- ### 🤖 Agent Room Management
73
+ // 5. Send a message to a room
84
74
 
85
- - **Customize which agents** are available in each room
86
- - **Add/remove agents** from your owned rooms
87
- - **List room agents** with caching for performance
88
- - **Real-time agent status updates** for room availability
75
+ // WITH COORDINATOR (when available):
76
+ await sdk.sendMessage("Give me the last 5 tweets from @elonmusk", {
77
+ room: roomId
78
+ });
79
+ // → Coordinator selects best agent automatically
89
80
 
90
- ### 📊 Enhanced APIs
81
+ // WITHOUT COORDINATOR (direct command required):
82
+ await sdk.sendMessage("@X Platform Agent search bitcoin 5", {
83
+ room: roomId
84
+ });
85
+ // → Direct command to specific agent by name
86
+ ```
91
87
 
92
- - 8 new room management methods
93
- - 8 new agent-room management methods
94
- - 14 new events for room and agent operations
95
- - Intelligent caching with 5-minute TTL
88
+ **That's it!** After authentication:
89
+
90
+ 1. Your private rooms are automatically available
91
+ 2. Send messages to any room by ID
92
+ 3. **With coordinator**: Use natural language - coordinator routes to best agent
93
+ 4. **Without coordinator**: Use `@Agent Name command params` syntax to target specific agents
94
+ 5. Responses arrive via the event listener
95
+
96
+ ### Message Routing Flow
97
+
98
+ The SDK supports two routing approaches depending on your environment:
99
+
100
+ ```mermaid
101
+ graph TB
102
+ UserMessage[User Message]
103
+ CheckEnv{Environment Has<br/>Coordinator?}
104
+ CoordPath[Coordinator Routing]
105
+ DirectPath[Direct Routing]
106
+ CoordSelect[Coordinator Selects<br/>Best Agent]
107
+ DirectTarget[Direct to<br/>Named Agent]
108
+ Agent[Agent Processes<br/>Request]
109
+
110
+ UserMessage --> CheckEnv
111
+ CheckEnv -->|Yes| CoordPath
112
+ CheckEnv -->|No| DirectPath
113
+ CoordPath -->|"Natural language<br/>supported"| CoordSelect
114
+ DirectPath -->|"@Agent Name required"| DirectTarget
115
+ CoordSelect --> Agent
116
+ DirectTarget --> Agent
117
+ ```
96
118
 
97
- [Jump to Room Management API](#-room-management-api) | [Jump to Agent Room Management API](#-agent-room-management-api)
119
+ **Key Differences:**
120
+ - **Coordinator environments**: Both natural language and direct commands work
121
+ - **Non-coordinator environments**: Must use `@Agent Name command params` syntax
98
122
 
99
123
  ---
100
124
 
@@ -220,23 +244,33 @@ Organize agents by context using rooms:
220
244
  const sdk = new TeneoSDK({
221
245
  wsUrl: process.env.TENEO_WS_URL!,
222
246
  privateKey: process.env.PRIVATE_KEY!,
223
- autoJoinRooms: ["Crawler Room", "KOL tracker"]
247
+ autoJoinPublicRooms: ["crawler-room-id", "kol-tracker-room-id"] // public rooms only
224
248
  });
225
249
 
226
250
  // Each room may have different agents available
251
+ // Note: Private rooms are automatically available after auth
227
252
  await sdk.connect();
228
253
 
229
254
  // Send to specific room contexts
230
- await sdk.sendMessage("Get latest tweets from @elonmusk", { room: "KOL tracker" });
231
- // → Routed to X Agent in KOL tracker room
232
255
 
233
- await sdk.sendMessage("Crawl this website for data", { room: "Crawler Room" });
234
- // Routed to Crawler Agent in Crawler Room
256
+ // WITH COORDINATOR:
257
+ await sdk.sendMessage("Get latest tweets from @elonmusk", { room: "kol-tracker-room-id" });
258
+ // → Coordinator routes to best agent in room
259
+
260
+ await sdk.sendMessage("Crawl this website for data", { room: "crawler-room-id" });
261
+ // → Coordinator routes to best agent in room
262
+
263
+ // WITHOUT COORDINATOR (direct commands required):
264
+ await sdk.sendMessage("@X Platform Agent timeline @elonmusk 5", { room: "kol-tracker-room-id" });
265
+ // → Direct to X Platform Agent in room
266
+
267
+ await sdk.sendMessage("@Web Crawler Agent crawl https://example.com", { room: "crawler-room-id" });
268
+ // → Direct to Web Crawler Agent in room
235
269
 
236
270
  // Manage rooms dynamically
237
271
  const rooms = sdk.getSubscribedRooms();
238
272
  console.log("Active rooms:", rooms);
239
- // Output: Active rooms: ['Crawler Room', 'KOL tracker']
273
+ // Output: Active rooms: ['crawler-room-id', 'kol-tracker-room-id']
240
274
  ```
241
275
 
242
276
  ### Example 3: Webhook Integration
@@ -291,8 +325,8 @@ await sdk.connect();
291
325
 
292
326
  // Check webhook health
293
327
  const status = sdk.getWebhookStatus();
294
- console.log("Queue size:", status.queueSize);
295
- console.log("Circuit state:", status.circuitState); // OPEN/CLOSED/HALF_OPEN
328
+ console.log("Pending:", status.queue.pending);
329
+ console.log("Circuit state:", status.queue.circuitState); // OPEN/CLOSED/HALF_OPEN
296
330
  ```
297
331
 
298
332
  ---
@@ -318,7 +352,7 @@ TENEO_WS_URL=wss://backend.developer.chatroom.teneo-protocol.ai/ws
318
352
  - **URL**: `wss://backend.chatroom.teneo-protocol.ai/ws`
319
353
  - **Whitelist**: **Required** - you must be whitelisted to use this endpoint
320
354
  - **Use case**: Production applications and B2B integrations
321
- - **Get access**: Request whitelist access at [https://teneo-protocol.ai/chat-room](https://teneo-protocol.ai/chat-room)
355
+ - **Get access**: Request whitelist access at [https://teneo-protocol.ai/data-access](https://teneo-protocol.ai/data-access)
322
356
 
323
357
  **Configuration:**
324
358
  ```bash
@@ -371,7 +405,7 @@ const allRooms = sdk.getAllRooms();
371
405
  console.log(`Total rooms accessible: ${allRooms.length}`);
372
406
 
373
407
  // Get specific room by ID
374
- const room = sdk.getRoomById("room-123");
408
+ const room = sdk.getRoom("room-123");
375
409
  if (room) {
376
410
  console.log(`Room: ${room.name}`);
377
411
  console.log(`Created by: ${room.created_by}`);
@@ -504,23 +538,23 @@ available.forEach((agent) => {
504
538
 
505
539
  ```typescript
506
540
  // Check if specific agent is in room (instant, no network call)
507
- const isInRoom = sdk.isAgentInRoom("room-123", "agent-456");
508
- if (isInRoom === true) {
541
+ const inRoom = sdk.checkAgentInRoom("room-123", "agent-456");
542
+ if (inRoom === true) {
509
543
  console.log("Agent is in the room");
510
- } else if (isInRoom === false) {
544
+ } else if (inRoom === false) {
511
545
  console.log("Agent is NOT in the room");
512
546
  } else {
513
547
  console.log("Cache not available - call listRoomAgents() first");
514
548
  }
515
549
 
516
550
  // Get room agent count (instant)
517
- const count = sdk.getRoomAgentCount("room-123");
551
+ const count = sdk.getCachedRoomAgentCount("room-123");
518
552
  if (count !== undefined) {
519
553
  console.log(`Room has ${count} agents`);
520
554
  }
521
555
 
522
556
  // Get cached room agents (instant)
523
- const cached = sdk.getRoomAgents("room-123");
557
+ const cached = sdk.getCachedRoomAgents("room-123");
524
558
  if (cached) {
525
559
  console.log("Agents:", cached.map((a) => a.agent_name).join(", "));
526
560
  } else {
@@ -528,7 +562,7 @@ if (cached) {
528
562
  }
529
563
 
530
564
  // Get cached available agents (instant)
531
- const cachedAvailable = sdk.getAvailableAgents("room-123");
565
+ const cachedAvailable = sdk.getCachedAvailableAgents("room-123");
532
566
  ```
533
567
 
534
568
  ### Cache Management
@@ -584,8 +618,8 @@ sdk.on("agent_room:list_error", (error, roomId) => {
584
618
  console.error(`Failed to list agents in ${roomId}: ${error.message}`);
585
619
  });
586
620
 
587
- sdk.on("agent_room:list_available_error", (error, roomId) => {
588
- console.error(`Failed to list available agents for ${roomId}: ${error.message}`);
621
+ sdk.on("agent_room:list_available_error", (error) => {
622
+ console.error(`Failed to list available agents: ${error.message}`);
589
623
  });
590
624
  ```
591
625
 
@@ -646,7 +680,7 @@ import { TeneoSDK } from "@teneo-protocol/sdk";
646
680
  // Enable payments with auto-approve
647
681
  const sdk = new TeneoSDK(
648
682
  TeneoSDK.builder()
649
- .withWebSocketUrl("wss://backend.developer.chatroom.teneo-protocol.ai/ws")
683
+ .withWebSocketUrl(process.env.TENEO_WS_URL!)
650
684
  .withAuthentication(process.env.PRIVATE_KEY!)
651
685
  .withPayments({
652
686
  autoApprove: true, // Automatically approve quotes
@@ -658,7 +692,7 @@ const sdk = new TeneoSDK(
658
692
  await sdk.connect();
659
693
 
660
694
  // Send message - payment handled automatically
661
- const response = await sdk.sendMessage("@x-agent-enterprise-v2 user @elonmusk", {
695
+ const response = await sdk.sendMessage("@X Platform Agent user @elonmusk", {
662
696
  room: roomId,
663
697
  waitForResponse: true
664
698
  });
@@ -667,20 +701,367 @@ console.log(response.humanized);
667
701
  // Output: User profile for @elonmusk...
668
702
  ```
669
703
 
704
+ > **Note:** The builder uses `withPayments({ autoApprove: true })` while the plain config object uses `autoApproveQuotes: true`. Both control the same behavior. The builder also accepts `maxPricePerRequest` and `quoteTimeout`.
705
+
706
+ ### Multi-Network Support (v2.3)
707
+
708
+ The SDK supports USDC payments across multiple EVM networks with **dynamic configuration**. Network configurations are automatically fetched from the backend during `connect()`, enabling the protocol to add new networks without requiring SDK updates.
709
+
710
+ #### Dynamic Network Configuration
711
+
712
+ Networks are initialized automatically when you connect:
713
+
714
+ ```typescript
715
+ import { TeneoSDK, NETWORKS, getSupportedNetworks } from "@teneo-protocol/sdk";
716
+
717
+ const sdk = new TeneoSDK({
718
+ wsUrl: "wss://teneo.network/ws",
719
+ privateKey: "0x..."
720
+ });
721
+
722
+ // Before connect: NETWORKS is empty
723
+ console.log(NETWORKS); // {}
724
+
725
+ // Networks fetched during connect from backend /api/networks
726
+ await sdk.connect();
727
+
728
+ // After connect: NETWORKS populated with backend configuration
729
+ console.log(NETWORKS); // { peaq: {...}, base: {...}, avalanche: {...} }
730
+ const networks = getSupportedNetworks(); // ["peaq", "base", "avalanche"]
731
+ ```
732
+
733
+ **Key Features:**
734
+ - 🔄 **Automatic fetch** from backend `/api/networks` endpoint during `connect()`
735
+ - ⚡ **60-minute cache** with automatic refresh
736
+ - 🛡️ **Offline resilience** - falls back to cached configs if backend temporarily unavailable
737
+ - 🚀 **Future-proof** - new networks can be added server-side without SDK updates
738
+
739
+ #### Querying Network Information
740
+
741
+ ```typescript
742
+ import {
743
+ NETWORKS,
744
+ getNetwork,
745
+ getDefaultNetwork,
746
+ getSupportedNetworks,
747
+ isNetworkSupported,
748
+ createChainDefinition
749
+ } from "@teneo-protocol/sdk";
750
+
751
+ // Must be called after connect()
752
+ await sdk.connect();
753
+
754
+ // Get all supported networks (dynamically loaded from backend)
755
+ const networks = getSupportedNetworks();
756
+ console.log(networks); // e.g., ["peaq", "base", "avalanche"]
757
+
758
+ // Get network by name
759
+ const baseNetwork = getNetwork("base");
760
+
761
+ // Get network by chain ID
762
+ const peaqNetwork = getNetwork(3338);
763
+
764
+ // Get network by CAIP-2 identifier
765
+ const avaxNetwork = getNetwork("eip155:43114");
766
+
767
+ console.log(baseNetwork);
768
+ // {
769
+ // chainId: 8453,
770
+ // name: "Base Mainnet",
771
+ // caip2: "eip155:8453",
772
+ // rpcUrl: "https://mainnet.base.org",
773
+ // usdcContract: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
774
+ // settlementRouter: "0x73fc659Cd5494E69852bE8D9D23FE05Aab14b29B",
775
+ // transferHook: "0x081258287F692D61575387ee2a4075f34dd7Aef7",
776
+ // eip712: { name: "USD Coin", version: "2" }
777
+ // }
778
+
779
+ // Check if a network is supported
780
+ if (isNetworkSupported("base")) {
781
+ // Create a viem chain definition
782
+ const baseChain = createChainDefinition(baseNetwork);
783
+ // Use with PaymentClient or other viem-based operations
784
+ }
785
+
786
+ // Get default network (prefers PEAQ, falls back to first available)
787
+ const defaultNetwork = getDefaultNetwork();
788
+ ```
789
+
790
+ #### Current Networks
791
+
792
+ These networks are currently supported (fetched dynamically from backend):
793
+
794
+ **PEAQ Mainnet (chainId: 3338)**
795
+ - Original Teneo network
796
+ - USDC contract, settlement router, transfer hook configured via backend
797
+
798
+ **Base Mainnet (chainId: 8453)**
799
+ - Layer 2 scaling solution
800
+ - Lower gas fees, faster transactions
801
+
802
+ **Avalanche Mainnet (chainId: 43114)**
803
+ - High-throughput blockchain
804
+ - Sub-second finality
805
+
806
+ > **Note:** Network configurations are fetched from the backend and may change. Use `getSupportedNetworks()` to get the current list. The SDK automatically handles network selection based on agent requirements.
807
+
808
+ #### Settlement Router Integration (x402 v2.5)
809
+
810
+ Payment quotes now include settlement router information for enhanced payment routing:
811
+
812
+ ```typescript
813
+ // Request a quote
814
+ const quote = await sdk.requestQuote("Analyze this data", "room-id");
815
+
816
+ // Quote includes settlement router fields (x402 v2.5)
817
+ console.log(quote.data.settlement_router); // Router contract address
818
+ console.log(quote.data.salt); // Unique transaction salt
819
+ console.log(quote.data.facilitator_fee); // Facilitator fee amount
820
+ console.log(quote.data.hook); // Transfer hook address
821
+ console.log(quote.data.hook_data); // Optional hook data (default: "0x")
822
+ ```
823
+
824
+ > **Note:** The SDK automatically handles network selection. The payment server determines which network to use based on the agent's configuration. You don't need to manually configure networks unless you're using the `PaymentClient` directly for custom payment operations.
825
+
826
+ #### Configuring Default Payment Network
827
+
828
+ You can configure which network to use for all payments in three ways:
829
+
830
+ **Option 1: Using Environment Variable (Global Default)**
831
+
832
+ ```bash
833
+ # Set default network for all payments
834
+ export TENEO_NETWORK=base
835
+
836
+ # Or use chain ID
837
+ export TENEO_NETWORK=8453
838
+
839
+ # Or use CAIP-2 format
840
+ export TENEO_NETWORK=eip155:8453
841
+ ```
842
+
843
+ ```typescript
844
+ import { TeneoSDK } from "@teneo-protocol/sdk";
845
+
846
+ // SDK automatically uses TENEO_NETWORK env var
847
+ const sdk = new TeneoSDK(
848
+ TeneoSDK.builder()
849
+ .withWebSocketUrl(process.env.TENEO_WS_URL!)
850
+ .withAuthentication(process.env.PRIVATE_KEY!)
851
+ .withPayments({ autoApprove: true })
852
+ .build()
853
+ );
854
+
855
+ // All payments will use Base network (from TENEO_NETWORK)
856
+ ```
857
+
858
+ **Option 2: Using Config Builder (Per-SDK Instance)**
859
+
860
+ ```typescript
861
+ import { TeneoSDK } from "@teneo-protocol/sdk";
862
+
863
+ // Configure Base network for this SDK instance
864
+ const sdk = new TeneoSDK(
865
+ TeneoSDK.builder()
866
+ .withWebSocketUrl(process.env.TENEO_WS_URL!)
867
+ .withAuthentication(process.env.PRIVATE_KEY!)
868
+ .withPayments({ autoApprove: true })
869
+ .withNetwork("base") // Use Base Mainnet
870
+ .build()
871
+ );
872
+
873
+ // All payments from this SDK will use Base network
874
+ ```
875
+
876
+ Or using chain ID:
877
+
878
+ ```typescript
879
+ const sdk = new TeneoSDK(
880
+ TeneoSDK.builder()
881
+ .withWebSocketUrl(process.env.TENEO_WS_URL!)
882
+ .withAuthentication(process.env.PRIVATE_KEY!)
883
+ .withPayments({ autoApprove: true })
884
+ .withNetworkChainId(43114) // Use Avalanche (chain ID 43114)
885
+ .build()
886
+ );
887
+ ```
888
+
889
+ **Network Selection Priority:**
890
+
891
+ The SDK uses this priority order for network selection:
892
+ 1. **Per-request network override** via `sendDirectCommand({ network: "base" })` or `sendMessage({ network: "base" })`
893
+ 2. Builder `.withNetwork()` or `.withNetworkChainId()` setting
894
+ 3. `TENEO_NETWORK` environment variable
895
+ 4. Default: PEAQ network (eip155:3338)
896
+
897
+ **Example: Per-Request Network Override (Recommended)**
898
+
899
+ Send commands to different chains from a single SDK instance:
900
+
901
+ ```typescript
902
+ const sdk = new TeneoSDK(
903
+ TeneoSDK.builder()
904
+ .withWebSocketUrl(process.env.TENEO_WS_URL!)
905
+ .withAuthentication(process.env.PRIVATE_KEY!)
906
+ .withPayments({ autoApprove: true, maxPricePerRequest: 1000000 })
907
+ .build()
908
+ );
909
+
910
+ await sdk.connect();
911
+ const roomId = sdk.getRooms()[0].id;
912
+
913
+ // Pay on PEAQ
914
+ await sdk.sendDirectCommand({
915
+ agent: "x-agent-enterprise-v2",
916
+ command: "user @elonmusk",
917
+ room: roomId,
918
+ network: "peaq", // Per-request network override
919
+ }, true);
920
+
921
+ // Pay on Base
922
+ await sdk.sendDirectCommand({
923
+ agent: "x-agent-enterprise-v2",
924
+ command: "user @elonmusk",
925
+ room: roomId,
926
+ network: "base", // Per-request network override
927
+ }, true);
928
+
929
+ // Pay on Avalanche
930
+ await sdk.sendDirectCommand({
931
+ agent: "x-agent-enterprise-v2",
932
+ command: "user @elonmusk",
933
+ room: roomId,
934
+ network: "avalanche", // Per-request network override
935
+ }, true);
936
+ ```
937
+
938
+ You can also pass a chain ID instead of a name:
939
+
940
+ ```typescript
941
+ await sdk.sendDirectCommand({
942
+ agent: "x-agent-enterprise-v2",
943
+ command: "user @elonmusk",
944
+ room: roomId,
945
+ network: 8453, // Base by chain ID
946
+ }, true);
947
+ ```
948
+
949
+ The same works with `sendMessage`:
950
+
951
+ ```typescript
952
+ await sdk.sendMessage("@X Platform Agent user @elonmusk", {
953
+ room: roomId,
954
+ waitForResponse: true,
955
+ network: "avalanche", // Per-request network override
956
+ });
957
+ ```
958
+
959
+ **Example: Multiple SDK Instances with Different Networks**
960
+
961
+ For cases where you want a fixed default per SDK instance:
962
+
963
+ ```typescript
964
+ // Production bot uses PEAQ
965
+ const peaqBot = new TeneoSDK(
966
+ TeneoSDK.builder()
967
+ .withWebSocketUrl(process.env.TENEO_WS_URL!)
968
+ .withAuthentication(process.env.PEAQ_PRIVATE_KEY!)
969
+ .withPayments({ autoApprove: true })
970
+ .withNetwork("peaq")
971
+ .build()
972
+ );
973
+
974
+ // Experimental bot uses Base
975
+ const baseBot = new TeneoSDK(
976
+ TeneoSDK.builder()
977
+ .withWebSocketUrl(process.env.TENEO_WS_URL!)
978
+ .withAuthentication(process.env.BASE_PRIVATE_KEY!)
979
+ .withPayments({ autoApprove: true })
980
+ .withNetwork("base")
981
+ .build()
982
+ );
983
+
984
+ // High-throughput bot uses Avalanche
985
+ const avalancheBot = new TeneoSDK(
986
+ TeneoSDK.builder()
987
+ .withWebSocketUrl(process.env.TENEO_WS_URL!)
988
+ .withAuthentication(process.env.AVALANCHE_PRIVATE_KEY!)
989
+ .withPayments({ autoApprove: true })
990
+ .withNetwork("avalanche")
991
+ .build()
992
+ );
993
+ ```
994
+
670
995
  ### Direct Agent Commands
671
996
 
997
+ #### When to Use Direct Commands
998
+
999
+ Direct agent commands allow you to target a specific agent by name using the `@Agent Name command params` syntax:
1000
+
1001
+ - **Required** in non-coordinator environments (direct commands are the only way to communicate)
1002
+ - **Optional** in coordinator environments (gives you explicit control over which agent handles the request)
1003
+
1004
+ #### Syntax Options
1005
+
672
1006
  ```typescript
673
- // Target a specific agent directly
674
- await sdk.sendMessage("@x-agent-enterprise-v2 timeline @elonmusk 5", {
1007
+ // Option 1: Use @mention syntax via sendMessage (recommended)
1008
+ await sdk.sendMessage("@X Platform Agent search bitcoin 5", {
675
1009
  room: roomId,
676
1010
  waitForResponse: true
677
1011
  });
678
1012
 
679
- // Let the coordinator choose the best agent
1013
+ // Option 2: Use sendDirectCommand for programmatic control
1014
+ const response = await sdk.sendDirectCommand({
1015
+ agent: "X Platform Agent",
1016
+ command: "timeline @elonmusk 5",
1017
+ room: roomId
1018
+ }, true); // waitForResponse
1019
+
1020
+ console.log(response.humanized);
1021
+
1022
+ // Option 3: With per-request network override
1023
+ const response = await sdk.sendDirectCommand({
1024
+ agent: "X Platform Agent",
1025
+ command: "user @elonmusk",
1026
+ room: roomId,
1027
+ network: "base", // Per-request network override (peaq, base, avalanche, or chain ID)
1028
+ }, true);
1029
+
1030
+ // Option 4: Fire-and-forget (no wait for response)
1031
+ await sdk.sendDirectCommand({
1032
+ agent: "X Platform Agent",
1033
+ command: "user @elonmusk",
1034
+ room: roomId
1035
+ });
1036
+ ```
1037
+
1038
+ #### Environment-Specific Examples
1039
+
1040
+ ```typescript
1041
+ // IN COORDINATOR ENVIRONMENTS (both work):
1042
+
1043
+ // Natural language - coordinator selects best agent
680
1044
  await sdk.sendMessage("Get me the latest tweets from @elonmusk", {
681
1045
  room: roomId,
682
1046
  waitForResponse: true
683
1047
  });
1048
+
1049
+ // Direct command - explicit agent selection
1050
+ await sdk.sendMessage("@X Platform Agent timeline @elonmusk 5", {
1051
+ room: roomId,
1052
+ waitForResponse: true
1053
+ });
1054
+
1055
+ // IN NON-COORDINATOR ENVIRONMENTS (direct commands required):
1056
+
1057
+ // Direct command - MUST specify agent name
1058
+ await sdk.sendMessage("@X Platform Agent search bitcoin 5", {
1059
+ room: roomId,
1060
+ waitForResponse: true
1061
+ });
1062
+
1063
+ // This will NOT work without coordinator:
1064
+ // ❌ await sdk.sendMessage("Get bitcoin info", { room: roomId });
684
1065
  ```
685
1066
 
686
1067
  ### Payment Events
@@ -698,6 +1079,11 @@ sdk.on("payment:attached", (data) => {
698
1079
  console.log(`Paid ${data.amount / 1_000_000} USDC to ${data.agentId}`);
699
1080
  });
700
1081
 
1082
+ // Payment blocked (price exceeds maxPricePerRequest)
1083
+ sdk.on("payment:blocked", (data) => {
1084
+ console.warn(`Payment blocked: agent ${data.agentId} charges ${data.agentPrice} but max is ${data.maxPrice}`);
1085
+ });
1086
+
701
1087
  // Payment errors
702
1088
  sdk.on("payment:error", (error) => {
703
1089
  console.error(`Payment failed: ${error.message}`);
@@ -731,7 +1117,7 @@ sdk.on("quote:received", async (quote) => {
731
1117
  });
732
1118
 
733
1119
  // Request triggers quote
734
- await sdk.sendMessage("@x-agent user @elonmusk", { room: roomId });
1120
+ await sdk.sendMessage("@X Platform Agent user @elonmusk", { room: roomId });
735
1121
  ```
736
1122
 
737
1123
  ### Payment Flow Diagram
@@ -774,7 +1160,7 @@ sdk.on("auth:success", (state) => {
774
1160
  console.log(`✅ Authenticated as ${state.walletAddress}`);
775
1161
  console.log(`Whitelisted: ${state.isWhitelisted}`);
776
1162
  });
777
- sdk.on("auth:error", (error) => console.error("❌ Auth failed:", error.message));
1163
+ sdk.on("auth:error", (error) => console.error("❌ Auth failed:", error));
778
1164
  ```
779
1165
 
780
1166
  ### Agent Events
@@ -783,7 +1169,6 @@ sdk.on("auth:error", (error) => console.error("❌ Auth failed:", error.message)
783
1169
  sdk.on("agent:selected", (selection) => {
784
1170
  console.log(`🤖 ${selection.agentName} was selected by coordinator`);
785
1171
  console.log(`Reasoning: ${selection.reasoning}`);
786
- console.log(`Confidence: ${selection.confidence}`);
787
1172
  });
788
1173
 
789
1174
  sdk.on("agent:response", (response) => {
@@ -793,7 +1178,7 @@ sdk.on("agent:response", (response) => {
793
1178
  sdk.on("agent:list", (agents) => {
794
1179
  console.log(`📋 Agent list updated: ${agents.length} agents available`);
795
1180
  agents.forEach((agent) => {
796
- console.log(` - ${agent.name}: ${agent.capabilities?.join(", ")}`);
1181
+ console.log(` - ${agent.name}: ${agent.capabilities?.map(c => c.name).join(", ")}`);
797
1182
  });
798
1183
  });
799
1184
  ```
@@ -820,8 +1205,8 @@ sdk.on("room:unsubscribed", (data) => {
820
1205
  ```typescript
821
1206
  const sdk = new TeneoSDK({
822
1207
  wsUrl: "wss://backend.developer.chatroom.teneo-protocol.ai/ws",
823
- privateKey: "your_key", // No 0x prefix
824
- defaultRoom: "general",
1208
+ privateKey: "0x...", // Your private key
1209
+ autoJoinPublicRooms: ["room-id-1"],
825
1210
  reconnect: true,
826
1211
  logLevel: "info"
827
1212
  });
@@ -837,11 +1222,11 @@ const secureKey = new SecurePrivateKey(process.env.PRIVATE_KEY!);
837
1222
 
838
1223
  const config = new SDKConfigBuilder()
839
1224
  // Required
840
- .withWebSocketUrl("wss://backend.developer.chatroom.teneo-protocol.ai/ws")
1225
+ .withWebSocketUrl(process.env.TENEO_WS_URL!)
841
1226
  .withAuthentication(secureKey) // Encrypted key
842
1227
 
843
- // Rooms
844
- .withRoom("general", ["announcements", "support"]) // default + auto-join
1228
+ // Rooms - auto-join these public rooms on connect
1229
+ .withAutoJoinPublicRooms(["room-id-1", "room-id-2"]) // Public rooms only (private rooms auto-available)
845
1230
 
846
1231
  // Reconnection strategy
847
1232
  .withReconnectionStrategy({
@@ -877,7 +1262,6 @@ const config = new SDKConfigBuilder()
877
1262
  })
878
1263
 
879
1264
  // Performance
880
- .withRateLimit(10, 20) // 10 msg/sec, burst 20
881
1265
  .withMessageDeduplication(true, 60000, 10000)
882
1266
  .withLogging("debug")
883
1267
 
@@ -891,11 +1275,17 @@ const sdk = new TeneoSDK(config);
891
1275
  Create `.env`:
892
1276
 
893
1277
  ```bash
1278
+ # Required
894
1279
  TENEO_WS_URL=wss://backend.developer.chatroom.teneo-protocol.ai/ws
895
- PRIVATE_KEY=your_private_key_without_0x
896
- WALLET_ADDRESS=0xYourWalletAddress
897
- DEFAULT_ROOM=general
1280
+ PRIVATE_KEY=0xYourPrivateKey
1281
+
1282
+ # Optional
898
1283
  LOG_LEVEL=info
1284
+
1285
+ # Payment network (v2.3.0) - Optional, defaults to PEAQ
1286
+ TENEO_NETWORK=base # By name: peaq, base, avalanche
1287
+ # Or by chain ID: TENEO_NETWORK=8453
1288
+ # Or CAIP-2: TENEO_NETWORK=eip155:8453
899
1289
  ```
900
1290
 
901
1291
  Load them:
@@ -907,14 +1297,64 @@ dotenv.config();
907
1297
  const sdk = new TeneoSDK({
908
1298
  wsUrl: process.env.TENEO_WS_URL!,
909
1299
  privateKey: process.env.PRIVATE_KEY!,
910
- walletAddress: process.env.WALLET_ADDRESS,
911
- defaultRoom: process.env.DEFAULT_ROOM,
912
1300
  logLevel: (process.env.LOG_LEVEL as any) || "info"
1301
+ // TENEO_NETWORK is automatically used by SDK for payment network
913
1302
  });
914
1303
  ```
915
1304
 
916
1305
  ---
917
1306
 
1307
+ ## 🔄 v3.0.0 Migration Guide
1308
+
1309
+ All v3.0.0 changes are **backward compatible**. Old method names still work via deprecated aliases.
1310
+
1311
+ ### Quick Migration (Optional)
1312
+
1313
+ Search and replace across your codebase to use the new, clearer names:
1314
+
1315
+ ```bash
1316
+ # Config property
1317
+ autoJoinRooms: → autoJoinPublicRooms:
1318
+
1319
+ # Room subscription methods
1320
+ .subscribeToRoom( → .subscribeToPublicRoom(
1321
+ .unsubscribeFromRoom( → .unsubscribeFromPublicRoom(
1322
+
1323
+ # Cache-only methods (sync)
1324
+ .getRoomAgents( → .getCachedRoomAgents(
1325
+ .getAvailableAgents( → .getCachedAvailableAgents(
1326
+ .getRoomAgentCount( → .getCachedRoomAgentCount(
1327
+
1328
+ # Boolean check methods
1329
+ .isAgentInRoom( → .checkAgentInRoom(
1330
+
1331
+ # Network-wide search methods
1332
+ .findAgentsByCapability( → .findAvailableAgentsByCapability(
1333
+ .findAgentsByName( → .findAvailableAgentsByName(
1334
+ .findAgentsByStatus( → .findAvailableAgentsByStatus(
1335
+ ```
1336
+
1337
+ ### Why These Changes?
1338
+
1339
+ **Room Subscriptions**: `subscribeToPublicRoom()` clarifies that only public rooms need subscription. Private rooms are automatically available after authentication.
1340
+
1341
+ **Cache Methods**: The `getCached*` prefix makes it obvious these are synchronous, cache-only operations. Async methods like `listRoomAgents()` still fetch from server.
1342
+
1343
+ **Boolean Checks**: `checkAgentInRoom()` returns `boolean | undefined`, not just boolean. The name clarifies this uncertainty.
1344
+
1345
+ **Search Scope**: `findAvailableAgentsBy*()` methods search ALL available agents network-wide, not just room-specific agents.
1346
+
1347
+ ### No Rush!
1348
+
1349
+ - ✅ Old names work indefinitely
1350
+ - ✅ TypeScript/JSDoc shows deprecation hints
1351
+ - ✅ Migrate on your schedule
1352
+ - ✅ Zero functional changes
1353
+
1354
+ See [CHANGELOG.md](CHANGELOG.md#300---2026-01-28) for detailed explanations and examples.
1355
+
1356
+ ---
1357
+
918
1358
  ## 🛡️ Production Features
919
1359
 
920
1360
  ### 1. Secure Private Key Management
@@ -946,7 +1386,7 @@ Prevents cascading failures in webhook delivery:
946
1386
  ```typescript
947
1387
  const status = sdk.getWebhookStatus();
948
1388
 
949
- console.log("Circuit state:", status.circuitState);
1389
+ console.log("Circuit state:", status.queue.circuitState);
950
1390
  // CLOSED = Normal operation, webhooks being delivered
951
1391
  // OPEN = Too many failures, failing fast (60s timeout)
952
1392
  // HALF_OPEN = Testing recovery (2 successes → CLOSED)
@@ -1032,12 +1472,11 @@ sdk.on("signature:failed", (type, reason) => {
1032
1472
  const health = sdk.getHealth();
1033
1473
 
1034
1474
  console.log("Status:", health.status); // 'healthy' | 'degraded' | 'unhealthy'
1035
- console.log("Connected:", health.connection.connected);
1475
+ console.log("Connected:", health.connection.status);
1036
1476
  console.log("Authenticated:", health.connection.authenticated);
1037
- console.log("Uptime:", health.uptime);
1038
1477
 
1039
1478
  if (health.webhook) {
1040
- console.log("Webhook queue:", health.webhook.queueSize);
1479
+ console.log("Webhook pending:", health.webhook.pending);
1041
1480
  console.log("Circuit state:", health.webhook.circuitState);
1042
1481
  }
1043
1482
 
@@ -1060,12 +1499,12 @@ console.log("Reconnect attempts:", state.reconnectAttempts);
1060
1499
  ### Performance Metrics
1061
1500
 
1062
1501
  ```typescript
1063
- // Rate limiter status
1064
- const rateLimit = sdk.getRateLimiterStatus();
1065
- if (rateLimit) {
1066
- console.log("Available:", rateLimit.availableTokens);
1067
- console.log("Rate:", rateLimit.tokensPerSecond, "/sec");
1068
- console.log("Burst capacity:", rateLimit.maxBurst);
1502
+ // Rate limiter status (via health check)
1503
+ const health = sdk.getHealth();
1504
+ if (health.rateLimit) {
1505
+ console.log("Available:", health.rateLimit.availableTokens);
1506
+ console.log("Rate:", health.rateLimit.tokensPerSecond, "/sec");
1507
+ console.log("Burst capacity:", health.rateLimit.maxBurst);
1069
1508
  }
1070
1509
 
1071
1510
  // Deduplication cache
@@ -1123,8 +1562,8 @@ npm run build
1123
1562
  2. **Verify key length:**
1124
1563
 
1125
1564
  ```bash
1126
- echo -n "your_key" | wc -c
1127
- # Should output: 64 + 0x prefix
1565
+ echo -n "0x1234...your_key" | wc -c
1566
+ # Should output: 66 (0x prefix + 64 hex characters)
1128
1567
  ```
1129
1568
 
1130
1569
  3. **Enable debug logging:**
@@ -1150,7 +1589,7 @@ RateLimitError: Rate limit exceeded
1150
1589
  1. **Slow down requests:**
1151
1590
  ```typescript
1152
1591
  for (const message of messages) {
1153
- await sdk.sendMessage(message);
1592
+ await sdk.sendMessage(message, { room: roomId });
1154
1593
  await new Promise((r) => setTimeout(r, 200)); // 200ms delay
1155
1594
  }
1156
1595
  ```
@@ -1181,7 +1620,7 @@ RateLimitError: Rate limit exceeded
1181
1620
  3. **Check circuit breaker:**
1182
1621
  ```typescript
1183
1622
  const status = sdk.getWebhookStatus();
1184
- if (status.circuitState === "OPEN") {
1623
+ if (status.queue.circuitState === "OPEN") {
1185
1624
  console.log("Circuit open, will retry in 60s");
1186
1625
  }
1187
1626
  ```