acp-ts 1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 yangzhiqiang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,374 @@
1
+ # ACP-WS 使用指南
2
+
3
+ ## 简介
4
+
5
+ ACP-WS 是一个基于 WebSocket 的智能体通信库,提供了智能体身份管理(AgentCP)和 WebSocket 通信(AgentWS)功能。通过 AgentManager 统一管理这些功能,使用更加便捷。
6
+
7
+ ## 快速开始
8
+
9
+ ### 1. 初始化 AgentManager
10
+
11
+ ```typescript
12
+ // 获取 AgentManager 单例
13
+ const manager = AgentManager.getInstance();
14
+
15
+ // 初始化 AgentCP(身份管理)
16
+ const apiUrl = "https://your-api-url";
17
+ const seedPassword = "your-seed-password"; // 可选
18
+ const acp = await manager.initACP(apiUrl, seedPassword);
19
+ ```
20
+
21
+ ### 2. 身份管理
22
+
23
+ ```typescript
24
+ // 创建新的智能体身份
25
+ const aid = await acp.createAid("your-aid");
26
+
27
+ // 如果本地只有一个账户,可以直接加载当前账户
28
+ const currentAid = await acp.loadCurrentAid();
29
+ if (!currentAid) {
30
+ throw new Error("没有可用的身份");
31
+ }
32
+
33
+ // 或者加载指定的身份
34
+ const loaded = await acp.loadAid(aid);
35
+ if (!loaded) {
36
+ throw new Error("加载身份失败");
37
+ }
38
+
39
+ // 或者导入已有的身份
40
+ const identity = {
41
+ aid: "your-aid",
42
+ privateKey: "your-private-key",
43
+ certPem: "your-cert-pem"
44
+ };
45
+ await acp.importAid(identity, seedPassword);
46
+
47
+ // 如果没有身份,可以加载访客身份
48
+ const guestAid = await acp.loadGuestAid();
49
+
50
+ // 获取当前可用的身份列表
51
+ const aidList = await acp.loadAidList();
52
+
53
+ // 获取当前身份的证书信息
54
+ const certInfo = await acp.getCertInfo(aid);
55
+ ```
56
+
57
+ ### 3. 上线并建立连接
58
+
59
+ ```typescript
60
+ // 获取连接配置
61
+ const config = await acp.online();
62
+
63
+ // 初始化 WebSocket 连接
64
+ const aws = await manager.initAWS(aid, config);
65
+
66
+ // 启动 WebSocket 连接
67
+ await aws.startWebSocket();
68
+
69
+ // 快速连接到指定智能体(推荐方式)
70
+ aws.connectTo("target-aid",
71
+ (sessionInfo) => {
72
+ console.log("会话创建成功:", sessionInfo.sessionId);
73
+ console.log("邀请码:", sessionInfo.identifyingCode);
74
+ },
75
+ (inviteStatus) => {
76
+ console.log("邀请状态:", inviteStatus);
77
+ }
78
+ );
79
+ ```
80
+
81
+ ### 4. 消息通信
82
+
83
+ ```typescript
84
+ // 注册状态变更监听
85
+ aws.onStatusChange((status) => {
86
+ console.log(`连接状态: ${status}`);
87
+ // status: 'connecting' | 'connected' | 'disconnected' | 'reconnecting' | 'error'
88
+ });
89
+
90
+ // 注册消息接收监听
91
+ aws.onMessage((message) => {
92
+ console.log(`收到消息类型: ${message.type}`); // 'success' | 'error'
93
+ console.log(`消息内容: ${message.content}`);
94
+ });
95
+
96
+ // 发送消息到当前会话
97
+ aws.send("Hello, Agent!");
98
+
99
+ // 发送消息到指定智能体
100
+ aws.sendTo("specific-agent-id", "Hello, specific agent!");
101
+
102
+ // 断开连接
103
+ aws.disconnect();
104
+ ```
105
+
106
+ ## 高级用法
107
+
108
+ ### 手动会话管理
109
+
110
+ 如果需要更精细的控制,可以手动管理会话和邀请:
111
+
112
+ ```typescript
113
+ // 手动创建会话
114
+ aws.createSession((sessionRes) => {
115
+ console.log("会话ID:", sessionRes.sessionId);
116
+ console.log("邀请码:", sessionRes.identifyingCode);
117
+
118
+ // 手动邀请智能体
119
+ aws.invite(
120
+ "target-agent-id",
121
+ sessionRes.sessionId,
122
+ sessionRes.identifyingCode,
123
+ (inviteStatus) => {
124
+ if (inviteStatus === 'success') {
125
+ console.log("邀请成功,可以开始通信");
126
+ } else {
127
+ console.log("邀请失败");
128
+ }
129
+ }
130
+ );
131
+ });
132
+ ```
133
+
134
+ ### React 组件中使用
135
+
136
+ ```typescript
137
+ import React, { useEffect, useState } from 'react';
138
+ import { AgentManager } from './agent-manager';
139
+
140
+ const ChatComponent: React.FC = () => {
141
+ const [aws, setAws] = useState<any>(null);
142
+ const [messages, setMessages] = useState<string[]>([]);
143
+ const [connectionStatus, setConnectionStatus] = useState<string>('disconnected');
144
+
145
+ useEffect(() => {
146
+ const initAgent = async () => {
147
+ try {
148
+ const manager = AgentManager.getInstance();
149
+ const acp = await manager.initACP("https://api.example.com");
150
+
151
+ // 加载或创建身份
152
+ let aid = await acp.loadCurrentAid();
153
+ if (!aid) {
154
+ aid = await acp.loadGuestAid();
155
+ }
156
+
157
+ // 获取连接配置并初始化WebSocket
158
+ const config = await acp.online();
159
+ const agentWS = await manager.initAWS(aid, config);
160
+
161
+ // 注册事件监听器
162
+ agentWS.onStatusChange((status) => {
163
+ setConnectionStatus(status);
164
+ });
165
+
166
+ agentWS.onMessage((message) => {
167
+ setMessages(prev => [...prev, message.content]);
168
+ });
169
+
170
+ // 启动连接
171
+ await agentWS.startWebSocket();
172
+ setAws(agentWS);
173
+
174
+ } catch (error) {
175
+ console.error("初始化失败:", error);
176
+ }
177
+ };
178
+
179
+ initAgent();
180
+
181
+ // 清理函数
182
+ return () => {
183
+ if (aws) {
184
+ aws.disconnect();
185
+ }
186
+ };
187
+ }, []);
188
+
189
+ const sendMessage = (text: string) => {
190
+ if (aws && connectionStatus === 'connected') {
191
+ aws.send(text);
192
+ }
193
+ };
194
+
195
+ const connectToAgent = (targetAid: string) => {
196
+ if (aws) {
197
+ aws.connectTo(targetAid);
198
+ }
199
+ };
200
+
201
+ return (
202
+ <div>
203
+ <div>状态: {connectionStatus}</div>
204
+ <div>
205
+ {messages.map((msg, index) => (
206
+ <div key={index}>{msg}</div>
207
+ ))}
208
+ </div>
209
+ {/* 发送消息和连接的UI组件 */}
210
+ </div>
211
+ );
212
+ };
213
+ ```
214
+
215
+ ## API 参考
216
+
217
+ ### AgentWS 类
218
+
219
+ #### 方法
220
+
221
+ - `startWebSocket(): Promise<void>` - 启动WebSocket连接
222
+ - `connectTo(receiver, onSessionCreated?, onInviteStatus?): void` - 快捷连接到指定智能体
223
+ - `createSession(callback): void` - 创建会话
224
+ - `invite(receiver, sessionId, identifyingCode, callback?): void` - 邀请智能体加入会话
225
+ - `send(message): void` - 发送消息到当前会话
226
+ - `sendTo(receiver, message): void` - 发送消息到指定智能体
227
+ - `onStatusChange(callback): void` - 注册状态变更监听器
228
+ - `onMessage(callback): void` - 注册消息接收监听器
229
+ - `disconnect(): void` - 断开连接
230
+
231
+ #### 状态类型
232
+
233
+ ```typescript
234
+ type ConnectionStatus = 'connecting' | 'connected' | 'disconnected' | 'reconnecting' | 'error';
235
+ type InviteStatus = 'success' | 'error';
236
+ ```
237
+
238
+ #### 消息类型
239
+
240
+ ```typescript
241
+ type ACPMessageResponse = {
242
+ type: 'success' | 'error';
243
+ content: string;
244
+ }
245
+
246
+ type ACPMessageSessionResponse = {
247
+ identifyingCode: string;
248
+ sessionId: string;
249
+ }
250
+ ```
251
+
252
+ ### WSClient 类
253
+
254
+ 底层WebSocket客户端,提供更精细的控制:
255
+
256
+ - `connectToServer(wsServer, aid, signature): Promise<void>` - 连接到WebSocket服务器
257
+ - `createSession(callback): void` - 创建会话(自动清理监听器)
258
+ - `invite(receiver, sessionId, identifyingCode, callback?): void` - 发送邀请
259
+ - `onStatusChange(callback): () => void` - 注册状态监听器,返回清理函数
260
+ - `onMessage(callback): () => void` - 注册消息监听器,返回清理函数
261
+ - `send(message): void` - 发送消息
262
+ - `sendTo(receiver, message): void` - 发送消息到指定接收者
263
+ - `disconnect(): void` - 断开连接并清理所有监听器
264
+
265
+ ## 错误处理
266
+
267
+ 所有关键操作都有适当的错误处理:
268
+
269
+ - 身份验证失败
270
+ - 连接超时
271
+ - 消息发送失败
272
+ - WebSocket 连接断开
273
+ - 参数验证错误
274
+
275
+ 建议使用 try-catch 包装关键操作:
276
+
277
+ ```typescript
278
+ try {
279
+ await aws.startWebSocket();
280
+ } catch (error) {
281
+ console.error(`WebSocket 连接失败: ${error.message}`);
282
+ // 实现重连逻辑
283
+ }
284
+ ```
285
+
286
+ ### 常见错误处理
287
+
288
+ ```typescript
289
+ // 连接错误处理
290
+ aws.onStatusChange((status) => {
291
+ switch (status) {
292
+ case 'error':
293
+ console.error("连接出错,尝试重连...");
294
+ // 实现重连逻辑
295
+ break;
296
+ case 'disconnected':
297
+ console.warn("连接断开");
298
+ break;
299
+ case 'connected':
300
+ console.log("连接成功");
301
+ break;
302
+ }
303
+ });
304
+
305
+ // 消息错误处理
306
+ aws.onMessage((message) => {
307
+ if (message.type === 'error') {
308
+ console.error("收到错误消息:", message.content);
309
+ // 处理错误情况
310
+ } else {
311
+ // 处理正常消息
312
+ console.log("收到消息:", message.content);
313
+ }
314
+ });
315
+ ```
316
+
317
+ ## 最佳实践
318
+
319
+ ### 1. 资源管理
320
+ - 始终使用 AgentManager 来管理实例,避免直接创建 AgentCP 或 AgentWS 实例
321
+ - 在应用退出时调用 `disconnect()` 清理资源
322
+ - 在React组件中使用useEffect的清理函数来清理WebSocket连接
323
+
324
+ ### 2. 事件处理
325
+ - 在初始化 WebSocket 连接后再注册事件监听器
326
+ - 使用 WSClient 时记得调用返回的清理函数防止内存泄漏
327
+ - 避免在回调函数中执行耗时操作,以免阻塞消息处理
328
+
329
+ ### 3. 异步操作
330
+ - 使用 async/await 处理异步操作
331
+ - 实现适当的重连机制和错误恢复策略
332
+ - 对关键操作添加超时控制
333
+
334
+ ### 4. 安全性
335
+ - 妥善保管 seedPassword 和私钥信息
336
+ - 验证消息来源和内容的合法性
337
+ - 使用HTTPS/WSS协议进行通信
338
+
339
+ ### 5. 性能优化
340
+ - 合理使用 `connectTo` 而不是手动管理会话
341
+ - 避免频繁创建和销毁连接
342
+ - 对大量消息的场景考虑消息批处理
343
+
344
+ ### 6. 调试和监控
345
+ - 启用适当的日志记录
346
+ - 监控连接状态和消息传输
347
+ - 实现健康检查机制
348
+
349
+ ## 故障排除
350
+
351
+ ### 常见问题
352
+
353
+ 1. **连接失败**: 检查网络连接、服务器地址和身份验证信息
354
+ 2. **消息发送失败**: 确认WebSocket连接状态和会话状态
355
+ 3. **监听器未清理**: 使用WSClient时记得调用返回的清理函数
356
+ 4. **重复监听器**: createSession和invite方法已自动处理重复注册问题
357
+
358
+ ### 调试技巧
359
+
360
+ ```typescript
361
+ // 启用详细日志
362
+ aws.onStatusChange((status) => {
363
+ console.log(`[${new Date().toISOString()}] 状态变更: ${status}`);
364
+ });
365
+
366
+ // 监控消息传输
367
+ aws.onMessage((message) => {
368
+ console.log(`[${new Date().toISOString()}] 收到消息:`, message);
369
+ });
370
+
371
+ // 检查当前连接状态
372
+ const currentStatus = aws.msgClient.getCurrentStatus();
373
+ console.log("当前连接状态:", currentStatus);
374
+ ```
@@ -0,0 +1,31 @@
1
+ import { IAgentCP, IAgentIdentity } from "./interfaces";
2
+ declare class AgentCP implements IAgentCP {
3
+ private seedPassword;
4
+ private apUrl;
5
+ private msgUrl;
6
+ private activeAid;
7
+ constructor(apiUrl: string, seedPassword?: string);
8
+ /**
9
+ * 初始化并预热加密模块
10
+ */
11
+ private initializeCrypto;
12
+ importAid(identity: IAgentIdentity, seedPassword?: string): Promise<boolean>;
13
+ loadAid(aid: string): Promise<string | null>;
14
+ createAid(aid: string): Promise<string>;
15
+ loadCurrentAid(): Promise<string | null>;
16
+ loadGuestAid(): Promise<string>;
17
+ loadAidList(): Promise<string[] | null>;
18
+ online(): Promise<{
19
+ messageSignature: string;
20
+ messageServer: string;
21
+ heartbeatServer: string;
22
+ }>;
23
+ getCertInfo(aid: string): Promise<{
24
+ privateKey: string;
25
+ publicKey: string;
26
+ csr: string;
27
+ cert: string;
28
+ } | null>;
29
+ private handleError;
30
+ }
31
+ export { AgentCP };
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgentCP = void 0;
4
+ const cert_1 = require("./cert");
5
+ const datamanager_1 = require("./datamanager");
6
+ const api_1 = require("./api");
7
+ const utils_1 = require("./utils");
8
+ class AgentCP {
9
+ constructor(apiUrl, seedPassword = "") {
10
+ this.activeAid = '';
11
+ if (!apiUrl) {
12
+ this.handleError("参数缺失:apiUrl不应为空");
13
+ }
14
+ if (apiUrl.startsWith('http://')) {
15
+ this.handleError("apiUrl不需要http://开头");
16
+ }
17
+ const baseUrl = `https://acp3.${apiUrl}`;
18
+ this.seedPassword = seedPassword;
19
+ this.apUrl = `${baseUrl}/api/accesspoint`;
20
+ this.msgUrl = `${baseUrl}/api/message`;
21
+ // 预热加密模块
22
+ this.initializeCrypto();
23
+ }
24
+ /**
25
+ * 初始化并预热加密模块
26
+ */
27
+ async initializeCrypto() {
28
+ try {
29
+ await (0, cert_1.preloadCrypto)();
30
+ }
31
+ catch (error) {
32
+ console.warn('AgentCP 加密模块预热失败:', error);
33
+ }
34
+ }
35
+ /// 导入本地用户信息
36
+ async importAid(identity, seedPassword = "") {
37
+ this.seedPassword = seedPassword;
38
+ const { aid, privateKey, certPem } = identity;
39
+ try {
40
+ if (!aid || !privateKey || !certPem) {
41
+ this.handleError("参数缺失:aid、privateKey 或 certPem 不应为空");
42
+ }
43
+ const isValid = (0, cert_1.isPemValid)(certPem);
44
+ if (!isValid) {
45
+ this.handleError("证书已过期");
46
+ }
47
+ await datamanager_1.CertAndKeyStore.saveAid(aid);
48
+ await datamanager_1.CertAndKeyStore.saveCertificate(aid, certPem);
49
+ await datamanager_1.CertAndKeyStore.savePrivateKey(aid, privateKey);
50
+ this.activeAid = aid;
51
+ return true;
52
+ }
53
+ catch (err) {
54
+ this.handleError(`错误: ${err instanceof Error ? err.message : String(err)}`);
55
+ }
56
+ }
57
+ async loadAid(aid) {
58
+ const aids = await datamanager_1.CertAndKeyStore.getAids();
59
+ if (aids && aids.length > 0) {
60
+ if (aids.includes(aid)) {
61
+ this.activeAid = aid;
62
+ return aid;
63
+ }
64
+ }
65
+ return null;
66
+ }
67
+ async createAid(aid) {
68
+ const loaded = await this.loadAid(aid);
69
+ if (loaded) {
70
+ this.activeAid = loaded;
71
+ return loaded;
72
+ }
73
+ const created = await (0, utils_1.createAid)(aid, this.apUrl, this.seedPassword);
74
+ if (!created) {
75
+ this.handleError(`当前aid: ${aid}创建失败`);
76
+ }
77
+ this.activeAid = aid;
78
+ return aid;
79
+ }
80
+ async loadCurrentAid() {
81
+ const aids = await datamanager_1.CertAndKeyStore.getAids();
82
+ if (aids && aids.length > 0) {
83
+ let currentAid = aids[0];
84
+ const firstNonGuestAid = aids.find((aid) => !aid.startsWith('guest'));
85
+ if (firstNonGuestAid) {
86
+ currentAid = firstNonGuestAid;
87
+ }
88
+ return this.loadAid(currentAid);
89
+ }
90
+ else {
91
+ return null;
92
+ }
93
+ }
94
+ async loadGuestAid() {
95
+ const loaded = await (0, api_1.getGuestAid)(this.apUrl, this.seedPassword);
96
+ if (!loaded) {
97
+ this.handleError('加载aid失败');
98
+ }
99
+ this.activeAid = loaded;
100
+ return loaded;
101
+ }
102
+ async loadAidList() {
103
+ const aids = await datamanager_1.CertAndKeyStore.getAids();
104
+ if (aids) {
105
+ return aids;
106
+ }
107
+ else {
108
+ return null;
109
+ }
110
+ }
111
+ async online() {
112
+ var _a;
113
+ let messageSignature = '';
114
+ let messageServer = '';
115
+ let heartbeatServer = '';
116
+ const aid = this.activeAid;
117
+ if (!aid) {
118
+ this.handleError('请先加载或创建 AID');
119
+ }
120
+ const privateKey = await (0, utils_1.getDecryptKey)(aid, this.seedPassword);
121
+ if (!privateKey) {
122
+ this.handleError('私钥不存在或无效,请检查 AID 是否正确创建');
123
+ }
124
+ const { publicKeyPem, certPem } = await (0, cert_1.getPublicKeyPem)(aid);
125
+ if (!certPem) {
126
+ this.handleError('证书不存在,请重新创建 AID');
127
+ }
128
+ const apData = await (0, api_1.signIn)(aid, this.apUrl, privateKey, publicKeyPem, certPem);
129
+ if (!apData) {
130
+ this.handleError(`${this.apUrl}接口signIn失败`);
131
+ }
132
+ const epData = await (0, api_1.getEntryPointConfig)(aid, this.apUrl);
133
+ if (!epData) {
134
+ this.handleError("接入点服务器get_accesspoint_config获取数据失败");
135
+ }
136
+ else {
137
+ if (epData) {
138
+ messageServer = epData.messageServer;
139
+ heartbeatServer = epData.heartbeatServer;
140
+ }
141
+ }
142
+ const msgData = await (0, api_1.signIn)(aid, this.msgUrl, privateKey, publicKeyPem, certPem);
143
+ if (!msgData) {
144
+ this.handleError(`${this.msgUrl}接口signIn失败`);
145
+ }
146
+ else {
147
+ messageSignature = (_a = msgData.signature) !== null && _a !== void 0 ? _a : '';
148
+ }
149
+ return {
150
+ messageSignature,
151
+ messageServer,
152
+ heartbeatServer
153
+ };
154
+ }
155
+ async getCertInfo(aid) {
156
+ const csr = await datamanager_1.CertAndKeyStore.getCsr(aid);
157
+ const privateKey = await datamanager_1.CertAndKeyStore.getPrivateKey(aid);
158
+ const { publicKeyPem, certPem } = await (0, cert_1.getPublicKeyPem)(aid);
159
+ if (!certPem || !csr || !privateKey || !publicKeyPem) {
160
+ return null;
161
+ }
162
+ return {
163
+ privateKey,
164
+ publicKey: publicKeyPem,
165
+ csr,
166
+ cert: certPem
167
+ };
168
+ }
169
+ handleError(error, customMessage) {
170
+ const errorMessage = error instanceof Error ? error.message : String(error);
171
+ throw new Error(`${customMessage || '操作失败'}: ${errorMessage}`);
172
+ }
173
+ }
174
+ exports.AgentCP = AgentCP;
@@ -0,0 +1,13 @@
1
+ import { IAgentCP, IAgentWS, IConnectionConfig } from './interfaces';
2
+ declare class AgentManager {
3
+ private static instance;
4
+ private agentCP;
5
+ private agentWS;
6
+ private constructor();
7
+ static getInstance(): AgentManager;
8
+ initACP(apiUrl: string, seedPassword?: string): IAgentCP;
9
+ initAWS(aid: string, config: IConnectionConfig): IAgentWS;
10
+ acp(): IAgentCP;
11
+ aws(): IAgentWS;
12
+ }
13
+ export { AgentManager };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgentManager = void 0;
4
+ const agentcp_1 = require("./agentcp");
5
+ const agentws_1 = require("./agentws");
6
+ class AgentManager {
7
+ constructor() {
8
+ this.agentCP = null;
9
+ this.agentWS = null;
10
+ }
11
+ static getInstance() {
12
+ if (!AgentManager.instance) {
13
+ AgentManager.instance = new AgentManager();
14
+ }
15
+ return AgentManager.instance;
16
+ }
17
+ initACP(apiUrl, seedPassword = "") {
18
+ this.agentCP = new agentcp_1.AgentCP(apiUrl, seedPassword);
19
+ return this.agentCP;
20
+ }
21
+ initAWS(aid, config) {
22
+ const { messageServer, messageSignature } = config;
23
+ this.agentWS = new agentws_1.AgentWS(aid, messageServer, messageSignature);
24
+ return this.agentWS;
25
+ }
26
+ acp() {
27
+ if (!this.agentCP) {
28
+ throw new Error("AgentCP未初始化");
29
+ }
30
+ return this.agentCP;
31
+ }
32
+ aws() {
33
+ if (!this.agentWS) {
34
+ throw new Error("AgentWS未初始化");
35
+ }
36
+ return this.agentWS;
37
+ }
38
+ }
39
+ exports.AgentManager = AgentManager;