@agentxjs/network 0.2.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/dist/browser-qLiqDF2b.d.cts +56 -0
- package/dist/browser-qLiqDF2b.d.ts +56 -0
- package/dist/browser.cjs +308 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +2 -0
- package/dist/browser.d.ts +2 -0
- package/dist/browser.js +9 -0
- package/dist/browser.js.map +1 -0
- package/dist/chunk-63P5VUHB.js +275 -0
- package/dist/chunk-63P5VUHB.js.map +1 -0
- package/dist/index.cjs +491 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +28 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +192 -0
- package/dist/index.js.map +1 -0
- package/package.json +60 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WebSocketClient,
|
|
3
|
+
__publicField,
|
|
4
|
+
createWebSocketClient
|
|
5
|
+
} from "./chunk-63P5VUHB.js";
|
|
6
|
+
|
|
7
|
+
// src/WebSocketServer.ts
|
|
8
|
+
import { createLogger } from "@agentxjs/common";
|
|
9
|
+
var logger = createLogger("network/WebSocketServer");
|
|
10
|
+
var WebSocketConnection = class {
|
|
11
|
+
constructor(ws, options) {
|
|
12
|
+
__publicField(this, "id");
|
|
13
|
+
__publicField(this, "ws");
|
|
14
|
+
__publicField(this, "messageHandlers", /* @__PURE__ */ new Set());
|
|
15
|
+
__publicField(this, "closeHandlers", /* @__PURE__ */ new Set());
|
|
16
|
+
__publicField(this, "errorHandlers", /* @__PURE__ */ new Set());
|
|
17
|
+
__publicField(this, "heartbeatInterval");
|
|
18
|
+
__publicField(this, "isAlive", true);
|
|
19
|
+
this.ws = ws;
|
|
20
|
+
this.id = `conn_${Date.now()}_${Math.random().toString(36).substring(2, 8)}`;
|
|
21
|
+
if (options.heartbeat !== false) {
|
|
22
|
+
const interval = options.heartbeatInterval || 3e4;
|
|
23
|
+
ws.on("pong", () => {
|
|
24
|
+
this.isAlive = true;
|
|
25
|
+
logger.debug("Heartbeat pong received", { id: this.id });
|
|
26
|
+
});
|
|
27
|
+
this.heartbeatInterval = setInterval(() => {
|
|
28
|
+
if (!this.isAlive) {
|
|
29
|
+
logger.warn("Client heartbeat timeout, terminating connection", { id: this.id });
|
|
30
|
+
clearInterval(this.heartbeatInterval);
|
|
31
|
+
ws.terminate();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
this.isAlive = false;
|
|
35
|
+
ws.ping();
|
|
36
|
+
logger.debug("Heartbeat ping sent", { id: this.id });
|
|
37
|
+
}, interval);
|
|
38
|
+
}
|
|
39
|
+
ws.on("message", (data) => {
|
|
40
|
+
const message = data.toString();
|
|
41
|
+
for (const handler of this.messageHandlers) {
|
|
42
|
+
handler(message);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
ws.on("close", () => {
|
|
46
|
+
if (this.heartbeatInterval) {
|
|
47
|
+
clearInterval(this.heartbeatInterval);
|
|
48
|
+
}
|
|
49
|
+
for (const handler of this.closeHandlers) {
|
|
50
|
+
handler();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
ws.on("error", (err) => {
|
|
54
|
+
if (this.heartbeatInterval) {
|
|
55
|
+
clearInterval(this.heartbeatInterval);
|
|
56
|
+
}
|
|
57
|
+
for (const handler of this.errorHandlers) {
|
|
58
|
+
handler(err);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
send(message) {
|
|
63
|
+
if (this.ws.readyState === 1) {
|
|
64
|
+
this.ws.send(message);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
onMessage(handler) {
|
|
68
|
+
this.messageHandlers.add(handler);
|
|
69
|
+
return () => {
|
|
70
|
+
this.messageHandlers.delete(handler);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
onClose(handler) {
|
|
74
|
+
this.closeHandlers.add(handler);
|
|
75
|
+
return () => {
|
|
76
|
+
this.closeHandlers.delete(handler);
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
onError(handler) {
|
|
80
|
+
this.errorHandlers.add(handler);
|
|
81
|
+
return () => {
|
|
82
|
+
this.errorHandlers.delete(handler);
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
close() {
|
|
86
|
+
if (this.heartbeatInterval) {
|
|
87
|
+
clearInterval(this.heartbeatInterval);
|
|
88
|
+
}
|
|
89
|
+
this.ws.close();
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
var WebSocketServer = class {
|
|
93
|
+
constructor(options = {}) {
|
|
94
|
+
__publicField(this, "wss", null);
|
|
95
|
+
__publicField(this, "connections", /* @__PURE__ */ new Set());
|
|
96
|
+
__publicField(this, "connectionHandlers", /* @__PURE__ */ new Set());
|
|
97
|
+
__publicField(this, "options");
|
|
98
|
+
__publicField(this, "attachedToServer", false);
|
|
99
|
+
this.options = options;
|
|
100
|
+
}
|
|
101
|
+
async listen(port, host = "0.0.0.0") {
|
|
102
|
+
if (this.wss) {
|
|
103
|
+
throw new Error("Server already listening");
|
|
104
|
+
}
|
|
105
|
+
if (this.attachedToServer) {
|
|
106
|
+
throw new Error(
|
|
107
|
+
"Cannot listen when attached to existing server. The server should call listen() instead."
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
const { WebSocketServer: WSS } = await import("ws");
|
|
111
|
+
this.wss = new WSS({ port, host });
|
|
112
|
+
this.wss.on("connection", (ws) => {
|
|
113
|
+
this.handleConnection(ws);
|
|
114
|
+
});
|
|
115
|
+
logger.info("WebSocket server listening", { port, host });
|
|
116
|
+
}
|
|
117
|
+
attach(server, path = "/ws") {
|
|
118
|
+
if (this.wss) {
|
|
119
|
+
throw new Error("Server already initialized");
|
|
120
|
+
}
|
|
121
|
+
import("ws").then(({ WebSocketServer: WSS }) => {
|
|
122
|
+
this.wss = new WSS({ noServer: true });
|
|
123
|
+
server.on("upgrade", (request, socket, head) => {
|
|
124
|
+
const url = new URL(request.url || "", `http://${request.headers.host}`);
|
|
125
|
+
if (url.pathname === path) {
|
|
126
|
+
this.wss.handleUpgrade(request, socket, head, (ws) => {
|
|
127
|
+
this.wss.emit("connection", ws, request);
|
|
128
|
+
});
|
|
129
|
+
} else {
|
|
130
|
+
socket.destroy();
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
this.wss.on("connection", (ws) => {
|
|
134
|
+
this.handleConnection(ws);
|
|
135
|
+
});
|
|
136
|
+
this.attachedToServer = true;
|
|
137
|
+
logger.info("WebSocket attached to existing HTTP server", { path });
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
handleConnection(ws) {
|
|
141
|
+
const connection = new WebSocketConnection(ws, this.options);
|
|
142
|
+
this.connections.add(connection);
|
|
143
|
+
logger.info("Client connected", {
|
|
144
|
+
connectionId: connection.id,
|
|
145
|
+
totalConnections: this.connections.size
|
|
146
|
+
});
|
|
147
|
+
connection.onClose(() => {
|
|
148
|
+
this.connections.delete(connection);
|
|
149
|
+
logger.info("Client disconnected", {
|
|
150
|
+
connectionId: connection.id,
|
|
151
|
+
totalConnections: this.connections.size
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
for (const handler of this.connectionHandlers) {
|
|
155
|
+
handler(connection);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
onConnection(handler) {
|
|
159
|
+
this.connectionHandlers.add(handler);
|
|
160
|
+
return () => {
|
|
161
|
+
this.connectionHandlers.delete(handler);
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
broadcast(message) {
|
|
165
|
+
for (const connection of this.connections) {
|
|
166
|
+
connection.send(message);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
async close() {
|
|
170
|
+
if (!this.wss) return;
|
|
171
|
+
for (const connection of this.connections) {
|
|
172
|
+
connection.close();
|
|
173
|
+
}
|
|
174
|
+
this.connections.clear();
|
|
175
|
+
if (!this.attachedToServer) {
|
|
176
|
+
await new Promise((resolve) => {
|
|
177
|
+
this.wss.close(() => resolve());
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
this.wss = null;
|
|
181
|
+
}
|
|
182
|
+
async dispose() {
|
|
183
|
+
await this.close();
|
|
184
|
+
this.connectionHandlers.clear();
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
export {
|
|
188
|
+
WebSocketClient,
|
|
189
|
+
WebSocketServer,
|
|
190
|
+
createWebSocketClient
|
|
191
|
+
};
|
|
192
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/WebSocketServer.ts"],"sourcesContent":["/**\n * WebSocket Server implementation of ChannelServer\n */\n\nimport type { WebSocket as WS, WebSocketServer as WSS } from \"ws\";\nimport type {\n ChannelServer,\n ChannelConnection,\n ChannelServerOptions,\n MinimalHTTPServer,\n Unsubscribe,\n} from \"@agentxjs/types/network\";\nimport { createLogger } from \"@agentxjs/common\";\n\nconst logger = createLogger(\"network/WebSocketServer\");\n\n/**\n * WebSocket connection implementation\n */\nclass WebSocketConnection implements ChannelConnection {\n public readonly id: string;\n private ws: WS;\n private messageHandlers = new Set<(message: string) => void>();\n private closeHandlers = new Set<() => void>();\n private errorHandlers = new Set<(error: Error) => void>();\n private heartbeatInterval?: ReturnType<typeof setInterval>;\n private isAlive = true;\n\n constructor(ws: WS, options: ChannelServerOptions) {\n this.ws = ws;\n this.id = `conn_${Date.now()}_${Math.random().toString(36).substring(2, 8)}`;\n\n // Setup heartbeat if enabled\n if (options.heartbeat !== false) {\n const interval = options.heartbeatInterval || 30000;\n\n ws.on(\"pong\", () => {\n this.isAlive = true;\n logger.debug(\"Heartbeat pong received\", { id: this.id });\n });\n\n this.heartbeatInterval = setInterval(() => {\n if (!this.isAlive) {\n logger.warn(\"Client heartbeat timeout, terminating connection\", { id: this.id });\n clearInterval(this.heartbeatInterval);\n ws.terminate();\n return;\n }\n this.isAlive = false;\n ws.ping();\n logger.debug(\"Heartbeat ping sent\", { id: this.id });\n }, interval);\n }\n\n // Setup message handler\n ws.on(\"message\", (data: Buffer) => {\n const message = data.toString();\n for (const handler of this.messageHandlers) {\n handler(message);\n }\n });\n\n // Setup close handler\n ws.on(\"close\", () => {\n if (this.heartbeatInterval) {\n clearInterval(this.heartbeatInterval);\n }\n for (const handler of this.closeHandlers) {\n handler();\n }\n });\n\n // Setup error handler\n ws.on(\"error\", (err: Error) => {\n if (this.heartbeatInterval) {\n clearInterval(this.heartbeatInterval);\n }\n for (const handler of this.errorHandlers) {\n handler(err);\n }\n });\n }\n\n send(message: string): void {\n if (this.ws.readyState === 1) {\n // WebSocket.OPEN\n this.ws.send(message);\n }\n }\n\n onMessage(handler: (message: string) => void): Unsubscribe {\n this.messageHandlers.add(handler);\n return () => {\n this.messageHandlers.delete(handler);\n };\n }\n\n onClose(handler: () => void): Unsubscribe {\n this.closeHandlers.add(handler);\n return () => {\n this.closeHandlers.delete(handler);\n };\n }\n\n onError(handler: (error: Error) => void): Unsubscribe {\n this.errorHandlers.add(handler);\n return () => {\n this.errorHandlers.delete(handler);\n };\n }\n\n close(): void {\n if (this.heartbeatInterval) {\n clearInterval(this.heartbeatInterval);\n }\n this.ws.close();\n }\n}\n\n/**\n * WebSocket Server\n */\nexport class WebSocketServer implements ChannelServer {\n private wss: WSS | null = null;\n private connections = new Set<WebSocketConnection>();\n private connectionHandlers = new Set<(connection: ChannelConnection) => void>();\n private options: ChannelServerOptions;\n private attachedToServer = false;\n\n constructor(options: ChannelServerOptions = {}) {\n this.options = options;\n }\n\n async listen(port: number, host: string = \"0.0.0.0\"): Promise<void> {\n if (this.wss) {\n throw new Error(\"Server already listening\");\n }\n if (this.attachedToServer) {\n throw new Error(\n \"Cannot listen when attached to existing server. The server should call listen() instead.\"\n );\n }\n\n const { WebSocketServer: WSS } = await import(\"ws\");\n this.wss = new WSS({ port, host });\n\n this.wss.on(\"connection\", (ws: WS) => {\n this.handleConnection(ws);\n });\n\n logger.info(\"WebSocket server listening\", { port, host });\n }\n\n attach(server: MinimalHTTPServer, path: string = \"/ws\"): void {\n if (this.wss) {\n throw new Error(\"Server already initialized\");\n }\n\n import(\"ws\").then(({ WebSocketServer: WSS }) => {\n this.wss = new WSS({ noServer: true });\n\n // Handle WebSocket upgrade on the HTTP server\n server.on(\"upgrade\", (request, socket, head) => {\n const url = new URL(request.url || \"\", `http://${request.headers.host}`);\n if (url.pathname === path) {\n this.wss!.handleUpgrade(request as any, socket as any, head as any, (ws: WS) => {\n this.wss!.emit(\"connection\", ws, request);\n });\n } else {\n (socket as any).destroy();\n }\n });\n\n this.wss.on(\"connection\", (ws: WS) => {\n this.handleConnection(ws);\n });\n\n this.attachedToServer = true;\n logger.info(\"WebSocket attached to existing HTTP server\", { path });\n });\n }\n\n private handleConnection(ws: WS): void {\n const connection = new WebSocketConnection(ws, this.options);\n this.connections.add(connection);\n\n logger.info(\"Client connected\", {\n connectionId: connection.id,\n totalConnections: this.connections.size,\n });\n\n connection.onClose(() => {\n this.connections.delete(connection);\n logger.info(\"Client disconnected\", {\n connectionId: connection.id,\n totalConnections: this.connections.size,\n });\n });\n\n // Notify handlers\n for (const handler of this.connectionHandlers) {\n handler(connection);\n }\n }\n\n onConnection(handler: (connection: ChannelConnection) => void): Unsubscribe {\n this.connectionHandlers.add(handler);\n return () => {\n this.connectionHandlers.delete(handler);\n };\n }\n\n broadcast(message: string): void {\n for (const connection of this.connections) {\n connection.send(message);\n }\n }\n\n async close(): Promise<void> {\n if (!this.wss) return;\n\n for (const connection of this.connections) {\n connection.close();\n }\n this.connections.clear();\n\n // Don't close the server if attached to existing HTTP server\n if (!this.attachedToServer) {\n await new Promise<void>((resolve) => {\n this.wss!.close(() => resolve());\n });\n }\n this.wss = null;\n }\n\n async dispose(): Promise<void> {\n await this.close();\n this.connectionHandlers.clear();\n }\n}\n"],"mappings":";;;;;;;AAYA,SAAS,oBAAoB;AAE7B,IAAM,SAAS,aAAa,yBAAyB;AAK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AAO,UAAU;AAClC,aAAO,KAAK,uBAAuB;AAAA,QACjC,cAAc,WAAW;AAAA,QACzB,kBAAkB,KAAK,YAAY;AAAA,MACrC,CAAC;AAAA,IACH,CAAC;AAGD,eAAW,WAAW,KAAK,oBAAoB;AAC7C,cAAQ,UAAU;AAAA,IACpB;AAAA,EACF;AAAA,EAEA,aAAa,SAA+D;AAC1E,SAAK,mBAAmB,IAAI,OAAO;AACnC,WAAO,MAAM;AACX,WAAK,mBAAmB,OAAO,OAAO;AAAA,IACxC;AAAA,EACF;AAAA,EAEA,UAAU,SAAuB;AAC/B,eAAW,cAAc,KAAK,aAAa;AACzC,iBAAW,KAAK,OAAO;AAAA,IACzB;AAAA,EACF;AAAA,EAEA,MAAM,QAAuB;AAC3B,QAAI,CAAC,KAAK,IAAK;AAEf,eAAW,cAAc,KAAK,aAAa;AACzC,iBAAW,MAAM;AAAA,IACnB;AACA,SAAK,YAAY,MAAM;AAGvB,QAAI,CAAC,KAAK,kBAAkB;AAC1B,YAAM,IAAI,QAAc,CAAC,YAAY;AACnC,aAAK,IAAK,MAAM,MAAM,QAAQ,CAAC;AAAA,MACjC,CAAC;AAAA,IACH;AACA,SAAK,MAAM;AAAA,EACb;AAAA,EAEA,MAAM,UAAyB;AAC7B,UAAM,KAAK,MAAM;AACjB,SAAK,mBAAmB,MAAM;AAAA,EAChC;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentxjs/network",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Network layer abstraction for AgentX platform - WebSocket client/server with heartbeat and auto-reconnect",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"agentx",
|
|
7
|
+
"network",
|
|
8
|
+
"websocket",
|
|
9
|
+
"channel",
|
|
10
|
+
"internal"
|
|
11
|
+
],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/deepractice/Agent",
|
|
15
|
+
"directory": "packages/network"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"type": "module",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js",
|
|
23
|
+
"require": "./dist/index.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./browser": {
|
|
26
|
+
"types": "./dist/browser.d.ts",
|
|
27
|
+
"import": "./dist/browser.js",
|
|
28
|
+
"require": "./dist/browser.cjs"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"main": "./dist/index.cjs",
|
|
32
|
+
"module": "./dist/index.js",
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"README.md"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsup",
|
|
40
|
+
"dev": "tsup --watch",
|
|
41
|
+
"lint": "eslint .",
|
|
42
|
+
"typecheck": "tsc --noEmit",
|
|
43
|
+
"clean": "rm -rf dist"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@agentxjs/common": "workspace:*",
|
|
47
|
+
"@agentxjs/types": "workspace:*",
|
|
48
|
+
"reconnecting-websocket": "^4.4.0",
|
|
49
|
+
"ws": "^8.18.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/node": "^22.19.1",
|
|
53
|
+
"@types/ws": "^8.5.13",
|
|
54
|
+
"tsup": "^8.5.0",
|
|
55
|
+
"typescript": "^5.9.3"
|
|
56
|
+
},
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public"
|
|
59
|
+
}
|
|
60
|
+
}
|