@teneo-protocol/sdk 3.0.0 → 3.1.1

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 (54) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +106 -1
  3. package/dist/handlers/message-handlers/agent-details-response-handler.d.ts +378 -54
  4. package/dist/handlers/message-handlers/agent-details-response-handler.d.ts.map +1 -1
  5. package/dist/handlers/message-handlers/agent-status-update-handler.d.ts +378 -54
  6. package/dist/handlers/message-handlers/agent-status-update-handler.d.ts.map +1 -1
  7. package/dist/handlers/message-handlers/all-agents-response-handler.d.ts +135 -54
  8. package/dist/handlers/message-handlers/all-agents-response-handler.d.ts.map +1 -1
  9. package/dist/handlers/message-handlers/list-available-agents-handler.d.ts +378 -54
  10. package/dist/handlers/message-handlers/list-available-agents-handler.d.ts.map +1 -1
  11. package/dist/handlers/message-handlers/list-room-agents-handler.d.ts +378 -54
  12. package/dist/handlers/message-handlers/list-room-agents-handler.d.ts.map +1 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +1 -1
  15. package/dist/managers/admin-manager.d.ts +1 -1
  16. package/dist/managers/admin-manager.js +1 -1
  17. package/dist/managers/message-router.d.ts +35 -0
  18. package/dist/managers/message-router.d.ts.map +1 -1
  19. package/dist/managers/message-router.js +143 -2
  20. package/dist/managers/message-router.js.map +1 -1
  21. package/dist/payments/payment-client.d.ts.map +1 -1
  22. package/dist/payments/payment-client.js +5 -3
  23. package/dist/payments/payment-client.js.map +1 -1
  24. package/dist/teneo-sdk.d.ts +2 -2
  25. package/dist/teneo-sdk.d.ts.map +1 -1
  26. package/dist/teneo-sdk.js +21 -3
  27. package/dist/teneo-sdk.js.map +1 -1
  28. package/dist/types/config.d.ts +29 -3
  29. package/dist/types/config.d.ts.map +1 -1
  30. package/dist/types/config.js +21 -2
  31. package/dist/types/config.js.map +1 -1
  32. package/dist/types/error-codes.d.ts +3 -0
  33. package/dist/types/error-codes.d.ts.map +1 -1
  34. package/dist/types/error-codes.js +4 -0
  35. package/dist/types/error-codes.js.map +1 -1
  36. package/dist/types/events.d.ts +3 -0
  37. package/dist/types/events.d.ts.map +1 -1
  38. package/dist/types/events.js.map +1 -1
  39. package/dist/types/messages.d.ts +3632 -552
  40. package/dist/types/messages.d.ts.map +1 -1
  41. package/dist/types/messages.js +18 -7
  42. package/dist/types/messages.js.map +1 -1
  43. package/package.json +1 -1
  44. package/src/index.ts +1 -1
  45. package/src/managers/admin-manager.ts +1 -1
  46. package/src/managers/message-router.ts +183 -3
  47. package/src/payments/payment-client.ts +6 -3
  48. package/src/teneo-sdk.ts +22 -3
  49. package/src/types/config.ts +23 -2
  50. package/src/types/error-codes.ts +5 -0
  51. package/src/types/events.ts +5 -0
  52. package/src/types/messages.ts +18 -7
  53. package/tests/unit/managers/admin-manager.test.ts +2 -2
  54. package/tests/unit/managers/message-router-autosummon.test.ts +338 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,27 @@ All notable changes to the Teneo Protocol SDK will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.1.1] - 2026-02-19
9
+
10
+ ### ✨ Pre-Flight Auto-Summon
11
+
12
+ The SDK now automatically adds missing agents to your room before sending commands, eliminating coordinator reject→retry cycles.
13
+
14
+ - **Pre-flight cache check**: Before sending a command, the SDK checks if the target agent is already in the room
15
+ - **Automatic addition**: If the agent is missing, it's added to the room before the command is sent
16
+ - **Lifecycle events**: `autosummon:start`, `autosummon:success`, `autosummon:failed` for full observability
17
+ - **Fallback path**: If pre-flight fails or cache is empty, falls back to coordinator-triggered auto-summon
18
+ - **Configuration**: Enable with `autoSummon: true` or `.withAutoSummon(true)` in the builder
19
+
20
+ ### 🔐 Private Key Validation
21
+
22
+ - Constructor now validates private key format (64 hex characters / 32 bytes)
23
+ - Catches empty strings, malformed keys, and too-short keys immediately
24
+ - Prevents cryptic signing errors downstream
25
+
26
+
27
+ ---
28
+
8
29
  ## [3.0.0] - 2026-01-28
9
30
 
10
31
  *Built on top of v2.3.0 multi-network support*
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-3.0.0-blue)](https://www.npmjs.com/package/@teneo-protocol/sdk)
5
+ [![npm version](https://img.shields.io/badge/version-3.1.1-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,46 @@ 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.1.1
19
+
20
+ ### 🤖 Pre-Flight Auto-Summon
21
+
22
+ The SDK now automatically detects when an agent is missing from your room and adds it **before** sending your command — no more failed requests or retry cycles:
23
+
24
+ ```typescript
25
+ const sdk = new TeneoSDK({
26
+ wsUrl: process.env.WS_URL,
27
+ privateKey: process.env.PRIVATE_KEY,
28
+ autoSummon: true // Enable auto-summon
29
+ });
30
+
31
+ // Agent not in room? SDK handles it automatically:
32
+ // 1. Checks local cache → agent missing
33
+ // 2. Fires autosummon:start
34
+ // 3. Adds agent to room
35
+ // 4. Fires autosummon:success
36
+ // 5. Sends your command
37
+ await sdk.sendDirectCommand({
38
+ agent: "example-agent",
39
+ command: "latest 2h",
40
+ room: roomId
41
+ }, true);
42
+ ```
43
+
44
+ **Lifecycle events** for full visibility:
45
+
46
+ - `autosummon:start` — agent addition initiated
47
+ - `autosummon:success` — agent added, command proceeding
48
+ - `autosummon:failed` — agent not found or addition failed, falls back to coordinator
49
+
50
+ ### 🔐 Private Key Validation
51
+
52
+ Constructor now validates private key format immediately, catching empty or malformed keys before they cause cryptic signing errors downstream.
53
+
54
+ [See Full CHANGELOG](CHANGELOG.md#311---2026-02-19)
55
+
56
+ ---
57
+
18
58
  ## 🎉 What's New in v3.0
19
59
 
20
60
  Version 3.0 introduces **API Naming Improvements** for better clarity and consistency:
@@ -623,6 +663,71 @@ sdk.on("agent_room:list_available_error", (error) => {
623
663
  });
624
664
  ```
625
665
 
666
+ ### Auto-Summon
667
+
668
+ When you send a command to an agent that isn't in your room yet, the SDK can automatically add it for you. No manual `addAgentToRoom()` call needed — just send your command and the SDK handles the rest.
669
+
670
+ #### Setup
671
+
672
+ ```typescript
673
+ const sdk = new TeneoSDK(
674
+ TeneoSDK.builder()
675
+ .withWebSocketUrl(process.env.TENEO_WS_URL!)
676
+ .withAuthentication(process.env.PRIVATE_KEY!)
677
+ .withAutoSummon(true) // Enable auto-summon
678
+ .withNetwork("base")
679
+ .build()
680
+ );
681
+
682
+ await sdk.connect();
683
+ ```
684
+
685
+ #### How It Works
686
+
687
+ ```typescript
688
+ // Just send a command — the agent doesn't need to be in your room
689
+ const response = await sdk.sendDirectCommand({
690
+ agent: "example-agent",
691
+ command: "latest 2h",
692
+ room: roomId
693
+ }, true);
694
+
695
+ // Behind the scenes:
696
+ // 1. SDK checks if agent is in the room (instant cache lookup)
697
+ // 2. If not -> automatically adds the agent to your room
698
+ // 3. Sends your command to the agent
699
+ // 4. Returns the response
700
+ console.log(response.humanized);
701
+ ```
702
+
703
+ #### Auto-Summon Events
704
+
705
+ Track the auto-summon lifecycle to show loading states in your UI:
706
+
707
+ ```typescript
708
+ // Agent is being added to the room
709
+ sdk.on("autosummon:start", (agentName, roomId) => {
710
+ showLoadingState(`Adding ${agentName} to your room...`);
711
+ });
712
+
713
+ // Agent was successfully added — command is now being processed
714
+ sdk.on("autosummon:success", (agentName, agentId, roomId) => {
715
+ showNotification(`${agentName} joined your room`);
716
+ });
717
+
718
+ // Agent could not be added (doesn't exist, is offline, etc.)
719
+ sdk.on("autosummon:failed", (agentName, roomId, reason) => {
720
+ showError(`Could not add ${agentName}: ${reason}`);
721
+ });
722
+ ```
723
+
724
+ #### Behavior Notes
725
+
726
+ - **No duplicates**: If the agent is already in the room, the SDK skips the summon and sends your command directly.
727
+ - **Works with any message method**: Auto-summon triggers from both `sendDirectCommand()` and `sendMessage()` when the message targets an `@agent`.
728
+ - **Graceful fallback**: If the local cache is empty (e.g., first connection), the SDK falls back to server-side detection — your command still works, just with a small extra round trip.
729
+ - **Room ownership required**: Auto-summon only works in rooms you own, since adding agents requires owner permissions.
730
+
626
731
  ### Complete Example: Room Setup
627
732
 
628
733
  ```typescript