hiloop-sdk 0.4.0 → 0.4.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.
- package/dist/ws.d.ts +1 -0
- package/dist/ws.js +10 -0
- package/package.json +1 -1
package/dist/ws.d.ts
CHANGED
package/dist/ws.js
CHANGED
|
@@ -15,6 +15,7 @@ import { CryptoContext, deriveKeyPairFromApiKey, computeFingerprint } from "./cr
|
|
|
15
15
|
export class HiloopWsClient {
|
|
16
16
|
constructor(options) {
|
|
17
17
|
this.ws = null;
|
|
18
|
+
this.agentId = null;
|
|
18
19
|
this.handlers = new Map();
|
|
19
20
|
this.anyHandlers = new Set();
|
|
20
21
|
this.reconnectAttempts = 0;
|
|
@@ -80,8 +81,17 @@ export class HiloopWsClient {
|
|
|
80
81
|
try {
|
|
81
82
|
const data = JSON.parse(event.data);
|
|
82
83
|
if (data.type === "connected") {
|
|
84
|
+
this.agentId = data.agentId;
|
|
83
85
|
resolve();
|
|
84
86
|
}
|
|
87
|
+
// Skip metadata-only message.new (agents get the richer session.message.new instead)
|
|
88
|
+
if (data.type === "message.new") {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
// Skip echoes: don't emit session messages sent by this agent
|
|
92
|
+
if (data.type === "session.message.new" && data.senderType === "agent" && data.senderId === this.agentId) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
85
95
|
this.emit(data.type, data);
|
|
86
96
|
}
|
|
87
97
|
catch { /* ignore malformed */ }
|