@easbot/gateway 0.1.11
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 +21 -0
- package/README.en.md +186 -0
- package/README.md +186 -0
- package/dist/chunks/chunk-56QXYDMF.cjs +2 -0
- package/dist/chunks/chunk-7SIK6QBH.cjs +2 -0
- package/dist/chunks/chunk-JJLKV5TO.cjs +9 -0
- package/dist/chunks/chunk-QLUXSA3Q.cjs +1 -0
- package/dist/chunks/chunk-SIOB4FC7.cjs +1 -0
- package/dist/chunks/chunk-SJNPXLNN.mjs +1 -0
- package/dist/chunks/chunk-T4HRQGQB.mjs +2 -0
- package/dist/chunks/chunk-T7CC2647.mjs +1 -0
- package/dist/chunks/chunk-TY6W6O7O.mjs +1 -0
- package/dist/chunks/chunk-UMFMKA5B.mjs +9 -0
- package/dist/chunks/chunk-X7GOOL6H.mjs +2 -0
- package/dist/chunks/chunk-XQVVSJRM.cjs +1 -0
- package/dist/chunks/global-2V5GUUC4.cjs +1 -0
- package/dist/chunks/global-6SWXOXOD.mjs +1 -0
- package/dist/chunks/package-IPUQXPNH.mjs +1 -0
- package/dist/chunks/package-OFDLYJ3A.cjs +1 -0
- package/dist/chunks/server-RYQHSEAD.mjs +1 -0
- package/dist/chunks/server-TIKLUNVP.cjs +1 -0
- package/dist/cli.cjs +33 -0
- package/dist/cli.d.cts +6 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.mjs +33 -0
- package/dist/index.cjs +11 -0
- package/dist/index.d.cts +2238 -0
- package/dist/index.d.ts +2238 -0
- package/dist/index.mjs +11 -0
- package/package.json +101 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 houjallen
|
|
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.en.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# @easbot/gateway
|
|
2
|
+
|
|
3
|
+
EASBot Gateway - AI Agent Server and Multi-channel Integration Platform
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Multi-channel Integration**: WebSocket, HTTP, Discord, Telegram, Slack, Feishu, WeChat and more
|
|
8
|
+
- **Agent Core**: AI SDK-based Agent runtime
|
|
9
|
+
- **Session Management**: Multi-session and multi-agent concurrency support
|
|
10
|
+
- **Message Routing**: Intelligent message routing and format conversion
|
|
11
|
+
- **Event System**: Comprehensive event-driven architecture
|
|
12
|
+
- **Plugin System**: Extensible plugin mechanism
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @easbot/gateway
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
### Start Server
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { createGateway } from '@easbot/gateway';
|
|
26
|
+
|
|
27
|
+
const gateway = createGateway({
|
|
28
|
+
server: {
|
|
29
|
+
port: 4096,
|
|
30
|
+
websocket: true,
|
|
31
|
+
},
|
|
32
|
+
agents: [
|
|
33
|
+
{
|
|
34
|
+
id: 'main',
|
|
35
|
+
model: 'anthropic/claude-3-5-sonnet',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
await gateway.start();
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### WebSocket Client
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { GatewayClient } from '@easbot/gateway';
|
|
47
|
+
|
|
48
|
+
const client = new GatewayClient('ws://localhost:4096');
|
|
49
|
+
await client.connect();
|
|
50
|
+
|
|
51
|
+
await client.sendMessage({
|
|
52
|
+
agent: 'main',
|
|
53
|
+
message: 'Hello!',
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
client.on('message', (msg) => {
|
|
57
|
+
console.log('Received:', msg.content);
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Telegram Bot
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
const gateway = createGateway({
|
|
65
|
+
telegram: {
|
|
66
|
+
botToken: process.env.TELEGRAM_BOT_TOKEN,
|
|
67
|
+
},
|
|
68
|
+
agents: [{ id: 'main' }],
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
await gateway.start();
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Channel Configuration
|
|
75
|
+
|
|
76
|
+
### WebSocket
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
{
|
|
80
|
+
server: {
|
|
81
|
+
port: 4096,
|
|
82
|
+
path: '/ws',
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### HTTP
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
{
|
|
91
|
+
server: {
|
|
92
|
+
http: {
|
|
93
|
+
port: 4097,
|
|
94
|
+
path: '/api',
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Discord
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
{
|
|
104
|
+
discord: {
|
|
105
|
+
botToken: 'YOUR_BOT_TOKEN',
|
|
106
|
+
guildId: 'YOUR_GUILD_ID',
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Telegram
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
{
|
|
115
|
+
telegram: {
|
|
116
|
+
botToken: 'YOUR_BOT_TOKEN',
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Slack
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
{
|
|
125
|
+
slack: {
|
|
126
|
+
botToken: 'xoxb-...',
|
|
127
|
+
signingSecret: 'YOUR_SIGNING_SECRET',
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## API Documentation
|
|
133
|
+
|
|
134
|
+
### Gateway
|
|
135
|
+
|
|
136
|
+
Main gateway class managing all channels and Agents.
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
const gateway = createGateway(config);
|
|
140
|
+
await gateway.start();
|
|
141
|
+
await gateway.stop();
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### GatewayClient
|
|
145
|
+
|
|
146
|
+
WebSocket client for connecting to Gateway.
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
const client = new GatewayClient(url);
|
|
150
|
+
await client.connect();
|
|
151
|
+
await client.sendMessage(message);
|
|
152
|
+
client.disconnect();
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Agent
|
|
156
|
+
|
|
157
|
+
Agent instance configuration.
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
interface AgentConfig {
|
|
161
|
+
id: string;
|
|
162
|
+
model: string;
|
|
163
|
+
systemPrompt?: string;
|
|
164
|
+
tools?: Tool[];
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Development
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# Install dependencies
|
|
172
|
+
pnpm install
|
|
173
|
+
|
|
174
|
+
# Build
|
|
175
|
+
pnpm build
|
|
176
|
+
|
|
177
|
+
# Test
|
|
178
|
+
pnpm test
|
|
179
|
+
|
|
180
|
+
# Type check
|
|
181
|
+
pnpm type-check
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
|
|
186
|
+
MIT
|
package/README.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# @easbot/gateway
|
|
2
|
+
|
|
3
|
+
EASBot Gateway - AI Agent Server and Multi-channel Integration Platform
|
|
4
|
+
|
|
5
|
+
## 特性
|
|
6
|
+
|
|
7
|
+
- **多渠道集成**:支持 WebSocket、HTTP、Discord、Telegram、Slack、飞书、微信等
|
|
8
|
+
- **Agent 核心**:基于 AI SDK 的 Agent 运行时
|
|
9
|
+
- **会话管理**:支持多会话、多 Agent 并发
|
|
10
|
+
- **消息路由**:智能消息路由和格式转换
|
|
11
|
+
- **事件系统**:完善的事件驱动架构
|
|
12
|
+
- **插件系统**:可扩展的插件机制
|
|
13
|
+
|
|
14
|
+
## 安装
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @easbot/gateway
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 快速开始
|
|
21
|
+
|
|
22
|
+
### 启动服务器
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { createGateway } from '@easbot/gateway';
|
|
26
|
+
|
|
27
|
+
const gateway = createGateway({
|
|
28
|
+
server: {
|
|
29
|
+
port: 4096,
|
|
30
|
+
websocket: true,
|
|
31
|
+
},
|
|
32
|
+
agents: [
|
|
33
|
+
{
|
|
34
|
+
id: 'main',
|
|
35
|
+
model: 'anthropic/claude-3-5-sonnet',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
await gateway.start();
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### WebSocket 客户端
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { GatewayClient } from '@easbot/gateway';
|
|
47
|
+
|
|
48
|
+
const client = new GatewayClient('ws://localhost:4096');
|
|
49
|
+
await client.connect();
|
|
50
|
+
|
|
51
|
+
await client.sendMessage({
|
|
52
|
+
agent: 'main',
|
|
53
|
+
message: 'Hello!',
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
client.on('message', (msg) => {
|
|
57
|
+
console.log('Received:', msg.content);
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Telegram Bot
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
const gateway = createGateway({
|
|
65
|
+
telegram: {
|
|
66
|
+
botToken: process.env.TELEGRAM_BOT_TOKEN,
|
|
67
|
+
},
|
|
68
|
+
agents: [{ id: 'main' }],
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
await gateway.start();
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 渠道配置
|
|
75
|
+
|
|
76
|
+
### WebSocket
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
{
|
|
80
|
+
server: {
|
|
81
|
+
port: 4096,
|
|
82
|
+
path: '/ws',
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### HTTP
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
{
|
|
91
|
+
server: {
|
|
92
|
+
http: {
|
|
93
|
+
port: 4097,
|
|
94
|
+
path: '/api',
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Discord
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
{
|
|
104
|
+
discord: {
|
|
105
|
+
botToken: 'YOUR_BOT_TOKEN',
|
|
106
|
+
guildId: 'YOUR_GUILD_ID',
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Telegram
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
{
|
|
115
|
+
telegram: {
|
|
116
|
+
botToken: 'YOUR_BOT_TOKEN',
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Slack
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
{
|
|
125
|
+
slack: {
|
|
126
|
+
botToken: 'xoxb-...',
|
|
127
|
+
signingSecret: 'YOUR_SIGNING_SECRET',
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## API 文档
|
|
133
|
+
|
|
134
|
+
### Gateway
|
|
135
|
+
|
|
136
|
+
主网关类,管理所有渠道和 Agent。
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
const gateway = createGateway(config);
|
|
140
|
+
await gateway.start();
|
|
141
|
+
await gateway.stop();
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### GatewayClient
|
|
145
|
+
|
|
146
|
+
WebSocket 客户端,用于连接 Gateway。
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
const client = new GatewayClient(url);
|
|
150
|
+
await client.connect();
|
|
151
|
+
await client.sendMessage(message);
|
|
152
|
+
client.disconnect();
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Agent
|
|
156
|
+
|
|
157
|
+
Agent 实例配置。
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
interface AgentConfig {
|
|
161
|
+
id: string;
|
|
162
|
+
model: string;
|
|
163
|
+
systemPrompt?: string;
|
|
164
|
+
tools?: Tool[];
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## 开发
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# 安装依赖
|
|
172
|
+
pnpm install
|
|
173
|
+
|
|
174
|
+
# 构建
|
|
175
|
+
pnpm build
|
|
176
|
+
|
|
177
|
+
# 测试
|
|
178
|
+
pnpm test
|
|
179
|
+
|
|
180
|
+
# 类型检查
|
|
181
|
+
pnpm type-check
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## 许可证
|
|
185
|
+
|
|
186
|
+
MIT
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkJJLKV5TO_cjs=require('./chunk-JJLKV5TO.cjs'),chunkSIOB4FC7_cjs=require('./chunk-SIOB4FC7.cjs'),chunkXQVVSJRM_cjs=require('./chunk-XQVVSJRM.cjs'),f=require('fs'),W=require('path'),plugin=require('@easbot/plugin'),utils=require('@easbot/utils'),ws=require('ws'),Q=require('https'),V=require('http');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var f__namespace=/*#__PURE__*/_interopNamespace(f);var W__namespace=/*#__PURE__*/_interopNamespace(W);var Q__default=/*#__PURE__*/_interopDefault(Q);var V__default=/*#__PURE__*/_interopDefault(V);chunkSIOB4FC7_cjs.a();chunkSIOB4FC7_cjs.a();chunkSIOB4FC7_cjs.a();var I=class{constructor(e={}){chunkXQVVSJRM_cjs.e(this,"log",chunkJJLKV5TO_cjs.a.create({service:"gateway:lock"}));chunkXQVVSJRM_cjs.e(this,"config");chunkXQVVSJRM_cjs.e(this,"locks",new Map);chunkXQVVSJRM_cjs.e(this,"cleanupTimer",null);this.config={defaultTimeout:e.defaultTimeout??6e4,checkInterval:e.checkInterval??1e4};}tryAcquire(e,t,s,n){let r=this.locks.get(e);if(r)if(this.isLockExpired(r))this.log.warn("lock expired, releasing",{sessionId:e,oldHolder:r.holderId,newHolder:s}),this.locks.delete(e);else return this.log.debug("lock already held",{sessionId:e,holder:r.holderId,messageId:r.messageId}),false;let a={sessionId:e,messageId:t,holderId:s,acquiredAt:Date.now(),timeout:n??this.config.defaultTimeout};return this.locks.set(e,a),this.log.debug("lock acquired",{sessionId:e,messageId:t,subscriberId:s}),true}release(e,t){let s=this.locks.get(e);return s?s.holderId!==t?(this.log.warn("cannot release lock held by another",{sessionId:e,holder:s.holderId,requester:t}),false):(this.locks.delete(e),this.log.debug("lock released",{sessionId:e,subscriberId:t}),true):(this.log.debug("no lock to release",{sessionId:e}),false)}forceRelease(e){let t=this.locks.get(e);return t?(this.locks.delete(e),this.log.warn("lock force released",{sessionId:e,holder:t.holderId,messageId:t.messageId}),true):false}isLockExpired(e){return Date.now()-e.acquiredAt>e.timeout}getLock(e){return this.locks.get(e)}isLocked(e){let t=this.locks.get(e);return t?this.isLockExpired(t)?(this.locks.delete(e),false):true:false}getHolder(e){let t=this.locks.get(e);if(!(!t||this.isLockExpired(t)))return t.holderId}startCleanup(){this.cleanupTimer||(this.cleanupTimer=setInterval(()=>{this.cleanupExpired();},this.config.checkInterval),this.log.info("lock cleanup started",{interval:this.config.checkInterval}));}stopCleanup(){this.cleanupTimer&&(clearInterval(this.cleanupTimer),this.cleanupTimer=null,this.log.info("lock cleanup stopped"));}cleanupExpired(){let e=0;for(let[t,s]of this.locks)this.isLockExpired(s)&&(this.locks.delete(t),e++,this.log.warn("expired lock cleaned up",{sessionId:t,holder:s.holderId,messageId:s.messageId}));return e>0&&this.log.info("cleaned up expired locks",{count:e}),e}getAllLocks(){return [...this.locks.values()]}getLockCount(){return this.locks.size}};chunkSIOB4FC7_cjs.a();var x=class{constructor(e={}){chunkXQVVSJRM_cjs.e(this,"log",chunkJJLKV5TO_cjs.a.create({service:"gateway:retry"}));chunkXQVVSJRM_cjs.e(this,"policy");chunkXQVVSJRM_cjs.e(this,"retryQueue",new Map);chunkXQVVSJRM_cjs.e(this,"retryTimer",null);chunkXQVVSJRM_cjs.e(this,"handlers",new Map);this.policy={maxRetries:e.maxRetries??3,initialDelay:e.initialDelay??1e3,maxDelay:e.maxDelay??3e4,backoffMultiplier:e.backoffMultiplier??2};}registerHandler(e,t){this.handlers.set(e,t);}unregisterHandler(e){this.handlers.delete(e);}scheduleRetry(e,t){let s=e.id,n=this.retryQueue.get(s);if(n||(n={messageId:s,retryCount:0,nextRetryAt:0,errors:[]},this.retryQueue.set(s,n)),n.errors.push({error:t.message,timestamp:Date.now()}),n.retryCount>=this.policy.maxRetries)return this.log.error("max retries exceeded",{messageId:s,retryCount:n.retryCount,maxRetries:this.policy.maxRetries}),false;let r=Math.min(this.policy.initialDelay*this.policy.backoffMultiplier**n.retryCount,this.policy.maxDelay);return n.retryCount++,n.nextRetryAt=Date.now()+r,this.log.warn("retry scheduled",{messageId:s,retryCount:n.retryCount,delay:r,error:t.message}),true}getPendingRetries(){let e=Date.now(),t=[];for(let s of this.retryQueue.values())s.nextRetryAt<=e&&s.retryCount<=this.policy.maxRetries&&t.push(s);return t}async executeRetry(e){if(!this.handlers.get(e.messageId))return this.log.warn("no handler for retry",{messageId:e.messageId}),false;this.retryQueue.delete(e.messageId);try{return this.log.info("executing retry",{messageId:e.messageId,retryCount:e.retryCount}),!0}catch(s){return this.log.error("retry execution failed",{messageId:e.messageId,error:String(s)}),false}}clearRetry(e){this.retryQueue.delete(e),this.handlers.delete(e),this.log.debug("retry cleared",{messageId:e});}startProcessing(){this.retryTimer||(this.retryTimer=setInterval(async()=>{let e=this.getPendingRetries();for(let t of e)await this.executeRetry(t);},1e3),this.log.info("retry processing started"));}stopProcessing(){this.retryTimer&&(clearInterval(this.retryTimer),this.retryTimer=null,this.log.info("retry processing stopped"));}getStats(){let e=0;for(let t of this.retryQueue.values())e+=t.errors.length;return {pendingCount:this.retryQueue.size,totalErrors:e}}};chunkSIOB4FC7_cjs.a();chunkSIOB4FC7_cjs.a();function H(c,e,t,s){return {id:`msg_${Date.now()}_${Math.random().toString(36).slice(2,9)}`,sessionId:c,type:e,content:t,metadata:{channel:{platform:s?.channel?.platform??"api",channelId:s?.channel?.channelId??"default",userId:s?.channel?.userId,chatId:s?.channel?.chatId,...Object.fromEntries(Object.entries(s?.channel??{}).filter(([n])=>!["platform","channelId","userId","chatId"].includes(n)))},context:s?.context,agent:s?.agent},timestamp:Date.now()}}function B(c,e,t,s){return H(c,e,[{type:"text",text:t}],s)}chunkSIOB4FC7_cjs.a();function T(c){let e=[c.platform,c.channelId];return c.chatId&&e.push(c.chatId),c.userId&&e.push(c.userId),e.join("_")}function E(){return {status:"active",messageCount:0,lastMessageAt:null}}chunkSIOB4FC7_cjs.a();function k(c,e){return `sub_${c}_${e}`}chunkSIOB4FC7_cjs.a();var D=chunkJJLKV5TO_cjs.w,b={maxConnections:chunkJJLKV5TO_cjs.w.maxConnections??1e3,connectionTimeout:chunkJJLKV5TO_cjs.w.connectionTimeout??6e4,sessionExpireMs:chunkJJLKV5TO_cjs.w.sessionExpireMs??3e5,heartbeatInterval:chunkJJLKV5TO_cjs.w.heartbeatInterval??3e4};chunkSIOB4FC7_cjs.a();var q={type:"token",enabled:true,tokens:[],onInvalid:"reject",allowAnonymous:false,defaultPermissions:[]};chunkSIOB4FC7_cjs.a();var F={heartbeatInterval:3e4,heartbeatTimeout:9e4,heartbeatCheckInterval:1e4,autoDeregisterTimeout:3e5,maxAgents:100,maxRegistrations:1e3};chunkSIOB4FC7_cjs.a();var U={mode:"both",interval:3e4,pushEvents:["register","deregister","status_change"],conflictResolution:"latest",remoteNodes:[]};chunkSIOB4FC7_cjs.a();var $={maxConnectionsPerChannel:100,idleTimeout:3e5,reuseStrategy:"lru",healthCheckInterval:6e4,acquireTimeout:5e3,warmupCount:0};var A=class{constructor(){chunkXQVVSJRM_cjs.e(this,"log",chunkJJLKV5TO_cjs.a.create({service:"gateway:router"}));chunkXQVVSJRM_cjs.e(this,"subscribers",new Map);chunkXQVVSJRM_cjs.e(this,"subscriptions",new Map);chunkXQVVSJRM_cjs.e(this,"sessionSubscriptions",new Map);chunkXQVVSJRM_cjs.e(this,"channelPlugins",new Map);chunkXQVVSJRM_cjs.e(this,"lockManager");chunkXQVVSJRM_cjs.e(this,"retryManager");chunkXQVVSJRM_cjs.e(this,"cancelHandlers",new Set);this.lockManager=new I,this.retryManager=new x,this.lockManager.startCleanup();}onCancel(e){this.cancelHandlers.add(e);}offCancel(e){this.cancelHandlers.delete(e);}async emitCancel(e){for(let t of this.cancelHandlers)try{await t(e);}catch(s){this.log.error("cancel handler error",{error:String(s)});}}async route(e){this.log.debug("routing message",{id:e.id,sessionId:e.sessionId,type:e.type});let t=this.sessionSubscriptions.get(e.sessionId);if(!t||t.size===0)return this.log.debug("no subscribers for session",{sessionId:e.sessionId}),{success:true,broadcastCount:0,dispatchedToSubAgent:false};let s=0,n=null,r=[];for(let a of t){let g=this.subscriptions.get(a);if(!g)continue;let u=this.subscribers.get(g.subscriberId);if(u){if(e.type==="input"){if(!this.lockManager.tryAcquire(e.sessionId,e.id,u.id)){this.log.debug("skipping subscriber, lock held by another",{subscriberId:u.id,holder:this.lockManager.getHolder(e.sessionId)});continue}n=u.id;}try{await u.connection.send(e),s++,u.lastActiveAt=Date.now();}catch(p){this.log.warn("failed to send message to subscriber",{subscriberId:u.id,error:String(p)}),r.push(p instanceof Error?p:new Error(String(p))),n===u.id&&(this.lockManager.release(e.sessionId,u.id),n=null);}}}return this.log.debug("message routed",{id:e.id,broadcastCount:s,errorCount:r.length,processedBy:n}),{success:r.length===0,broadcastCount:s,dispatchedToSubAgent:false,error:r.length>0?r.map(a=>a.message).join("; "):void 0}}async completeMessage(e,t,s,n="completed"){this.lockManager.release(e,s),await this.emitCancel({sessionId:e,messageId:t,processedBy:s,reason:n,timestamp:Date.now()}),this.log.info("message completed",{sessionId:e,messageId:t,subscriberId:s,reason:n});}scheduleRetry(e,t){return this.retryManager.scheduleRetry(e,t)}async subscribe(e,t){let s=k(t.id,e);if(this.subscriptions.has(s))return this.log.debug("already subscribed",{subscriberId:t.id,sessionId:e}),this.subscriptions.get(s);let n={id:s,subscriberId:t.id,sessionId:e,createdAt:Date.now()};return this.subscribers.has(t.id)||this.subscribers.set(t.id,t),this.subscriptions.set(s,n),this.sessionSubscriptions.has(e)||this.sessionSubscriptions.set(e,new Set),this.sessionSubscriptions.get(e).add(s),t.sessions.add(e),this.log.info("subscribed to session",{subscriberId:t.id,sessionId:e,subscriptionId:s}),n}async unsubscribe(e){let t=this.subscriptions.get(e);if(!t){this.log.warn("subscription not found",{subscriptionId:e});return}this.subscriptions.delete(e);let s=this.sessionSubscriptions.get(t.sessionId);s&&(s.delete(e),s.size===0&&this.sessionSubscriptions.delete(t.sessionId));let n=this.subscribers.get(t.subscriberId);n&&n.sessions.delete(t.sessionId),this.log.info("unsubscribed from session",{subscriberId:t.subscriberId,sessionId:t.sessionId,subscriptionId:e});}async unsubscribeAll(e){let t=this.subscribers.get(e);if(!t)return;let s=[...t.sessions];for(let n of s){let r=k(e,n);await this.unsubscribe(r);}this.subscribers.delete(e),this.log.info("unsubscribed all sessions",{subscriberId:e});}async registerChannel(e){if(this.channelPlugins.has(e.id)){this.log.warn("channel plugin already registered",{id:e.id});return}this.channelPlugins.set(e.id,e),this.log.info("channel plugin registered",{id:e.id,platform:e.platform});}async unregisterChannel(e){let t=this.channelPlugins.get(e);if(!t){this.log.warn("channel plugin not found",{id:e});return}await t.stop(),this.channelPlugins.delete(e),this.log.info("channel plugin unregistered",{id:e});}getSubscriberCount(e){let t=this.sessionSubscriptions.get(e);return t?t.size:0}getAllSubscribers(){return [...this.subscribers.values()]}getChannelPlugin(e){return this.channelPlugins.get(e)}getAllChannelPlugins(){return [...this.channelPlugins.values()]}getLockManager(){return this.lockManager}getRetryManager(){return this.retryManager}async shutdown(){this.lockManager.stopCleanup(),this.retryManager.stopProcessing(),this.log.info("router shutdown");}};chunkSIOB4FC7_cjs.a();chunkSIOB4FC7_cjs.a();chunkSIOB4FC7_cjs.a();chunkSIOB4FC7_cjs.a();var v=class{constructor(e={}){chunkXQVVSJRM_cjs.e(this,"log",chunkJJLKV5TO_cjs.a.create({service:"gateway:message-store"}));chunkXQVVSJRM_cjs.e(this,"config");chunkXQVVSJRM_cjs.e(this,"messages",new Map);chunkXQVVSJRM_cjs.e(this,"sessionMessages",new Map);this.config={storagePath:e.storagePath??"./data/gateway-messages",maxRetentionDays:e.maxRetentionDays??30,maxRecords:e.maxRecords??1e5};}async store(e){let t={message:e,status:"pending",processedBy:null,processedAt:null,retryCount:0,error:null,createdAt:Date.now(),updatedAt:Date.now()};return this.messages.set(e.id,t),this.sessionMessages.has(e.sessionId)||this.sessionMessages.set(e.sessionId,new Set),this.sessionMessages.get(e.sessionId).add(e.id),this.log.debug("message stored",{id:e.id,sessionId:e.sessionId,type:e.type}),t}get(e){return this.messages.get(e)}async updateStatus(e,t,s={}){let n=this.messages.get(e);if(!n){this.log.warn("message not found for status update",{messageId:e});return}n.status=t,n.updatedAt=Date.now(),s.processedBy&&(n.processedBy=s.processedBy),(t==="completed"||t==="failed")&&(n.processedAt=Date.now()),s.error&&(n.error=s.error),this.log.debug("message status updated",{id:e,status:t,processedBy:s.processedBy});}incrementRetry(e){let t=this.messages.get(e);return t?(t.retryCount++,t.updatedAt=Date.now(),t.retryCount):0}isProcessed(e){let t=this.messages.get(e);return t?t.status==="completed"||t.status==="processing":false}getSessionHistory(e,t=100){let s=this.sessionMessages.get(e);if(!s)return [];let n=[];for(let r of s){let a=this.messages.get(r);a&&n.push(a);}return n.sort((r,a)=>r.createdAt-a.createdAt),n.slice(-t)}getPendingMessages(e){let t=[];for(let s of this.messages.values())s.status==="pending"&&(!e||s.message.sessionId===e)&&t.push(s);return t}getFailedMessages(e=3){let t=[];for(let s of this.messages.values())s.status==="failed"&&s.retryCount<e&&t.push(s);return t}async cleanup(){let e=Date.now(),t=this.config.maxRetentionDays*24*60*60*1e3,s=[];for(let[n,r]of this.messages)e-r.createdAt>t&&s.push(n);for(let n of s){let r=this.messages.get(n);if(r){let a=this.sessionMessages.get(r.message.sessionId);a&&a.delete(n),this.messages.delete(n);}}return s.length>0&&this.log.info("cleaned up expired messages",{count:s.length}),s.length}getStats(){let e={total:this.messages.size,pending:0,processing:0,completed:0,failed:0,cancelled:0};for(let t of this.messages.values())e[t.status]++;return e}};chunkSIOB4FC7_cjs.a();var C=class{constructor(e={}){chunkXQVVSJRM_cjs.e(this,"log",chunkJJLKV5TO_cjs.a.create({service:"gateway:session-store"}));chunkXQVVSJRM_cjs.e(this,"config");chunkXQVVSJRM_cjs.e(this,"sessions",new Map);chunkXQVVSJRM_cjs.e(this,"channelSessions",new Map);chunkXQVVSJRM_cjs.e(this,"autoSaveTimer",null);chunkXQVVSJRM_cjs.e(this,"isDirty",false);this.config={storagePath:e.storagePath??"./data/gateway-sessions",autoSaveInterval:e.autoSaveInterval??6e4,maxRetentionDays:e.maxRetentionDays??7,enablePersistence:e.enablePersistence??true};}async initialize(){if(!this.config.enablePersistence){this.log.info("session persistence disabled");return}await this.ensureStorageDir(),await this.load(),this.startAutoSave(),this.log.info("session store initialized",{sessionCount:this.sessions.size,storagePath:this.config.storagePath});}async close(){this.stopAutoSave(),this.isDirty&&await this.save(),this.log.info("session store closed");}async set(e){this.sessions.set(e.id,e),this.channelSessions.has(e.channel.channelId)||this.channelSessions.set(e.channel.channelId,new Set),this.channelSessions.get(e.channel.channelId).add(e.id),this.markDirty();}get(e){return this.sessions.get(e)}async delete(e){let t=this.sessions.get(e);if(!t)return;this.sessions.delete(e);let s=this.channelSessions.get(t.channel.channelId);s&&(s.delete(e),s.size===0&&this.channelSessions.delete(t.channel.channelId)),this.markDirty();}getAll(){return [...this.sessions.values()]}getByChannel(e){let t=this.channelSessions.get(e);return t?[...t].map(s=>this.sessions.get(s)).filter(s=>s!==void 0):[]}size(){return this.sessions.size}markDirty(){this.isDirty=true;}async save(){if(!this.config.enablePersistence)return;let e=this.getSessionFilePath(),t=this.serializeAll();try{await this.ensureStorageDir(),await f__namespace.promises.writeFile(e,JSON.stringify(t,null,2),"utf-8"),this.isDirty=!1,this.log.debug("sessions saved",{count:t.length});}catch(s){throw this.log.error("failed to save sessions",{error:s}),s}}async load(){if(!this.config.enablePersistence)return;let e=this.getSessionFilePath();try{if(!f__namespace.existsSync(e)){this.log.debug("no saved sessions found");return}let t=await f__namespace.promises.readFile(e,"utf-8"),s=JSON.parse(t);this.sessions.clear(),this.channelSessions.clear();let n=Date.now(),r=this.config.maxRetentionDays*24*60*60*1e3;for(let a of s){if(n-a.lastActiveAt>r)continue;let g={id:a.id,channel:a.channel,backendSessionId:a.backendSessionId,subscribers:new Set(a.subscribers),state:a.state,createdAt:a.createdAt,lastActiveAt:a.lastActiveAt};this.sessions.set(g.id,g),this.channelSessions.has(g.channel.channelId)||this.channelSessions.set(g.channel.channelId,new Set),this.channelSessions.get(g.channel.channelId).add(g.id);}this.log.info("sessions loaded",{loaded:this.sessions.size,skipped:s.length-this.sessions.size});}catch(t){this.log.error("failed to load sessions",{error:t});}}serializeAll(){let e=[];for(let t of this.sessions.values())e.push(this.serialize(t));return e}serialize(e){return {id:e.id,channel:e.channel,backendSessionId:e.backendSessionId,subscribers:[...e.subscribers],state:e.state,createdAt:e.createdAt,lastActiveAt:e.lastActiveAt}}getSessionFilePath(){return W__namespace.join(this.config.storagePath,"sessions.json")}async ensureStorageDir(){f__namespace.existsSync(this.config.storagePath)||await f__namespace.promises.mkdir(this.config.storagePath,{recursive:true});}startAutoSave(){this.autoSaveTimer||(this.autoSaveTimer=setInterval(async()=>{this.isDirty&&await this.save();},this.config.autoSaveInterval));}stopAutoSave(){this.autoSaveTimer&&(clearInterval(this.autoSaveTimer),this.autoSaveTimer=null);}async cleanup(){let e=Date.now(),t=this.config.maxRetentionDays*24*60*60*1e3,s=[];for(let n of this.sessions.values())e-n.lastActiveAt>t&&s.push(n.id);for(let n of s)await this.delete(n);return s.length>0&&(this.log.info("cleaned up expired sessions",{count:s.length}),await this.save()),s.length}getStats(){let e={total:this.sessions.size,byStatus:{active:0,idle:0,closed:0},byPlatform:{}};for(let t of this.sessions.values()){e.byStatus[t.state.status]++;let s=t.channel.platform;e.byPlatform[s]=(e.byPlatform[s]||0)+1;}return e}};var M=class{constructor(e={}){chunkXQVVSJRM_cjs.e(this,"log",chunkJJLKV5TO_cjs.a.create({service:"gateway:session"}));chunkXQVVSJRM_cjs.e(this,"sessionStore");chunkXQVVSJRM_cjs.e(this,"config");chunkXQVVSJRM_cjs.e(this,"initialized",false);this.config={enablePersistence:e.enablePersistence??true,storagePath:e.storagePath??"./data/gateway-sessions",autoSaveInterval:e.autoSaveInterval??6e4,maxRetentionDays:e.maxRetentionDays??7},this.sessionStore=new C({storagePath:this.config.storagePath,autoSaveInterval:this.config.autoSaveInterval,maxRetentionDays:this.config.maxRetentionDays,enablePersistence:this.config.enablePersistence});}async initialize(){this.initialized||(await this.sessionStore.initialize(),this.initialized=true,this.log.info("session manager initialized",{sessionCount:this.sessionStore.size(),persistenceEnabled:this.config.enablePersistence}));}async close(){await this.sessionStore.close(),this.log.info("session manager closed");}async getOrCreate(e,t={}){let s=T(e),n=this.sessionStore.get(s);return n?(n.lastActiveAt=Date.now(),this.log.debug("session found",{sessionId:s}),n):(n={id:s,channel:e,backendSessionId:null,subscribers:new Set,state:E(),createdAt:Date.now(),lastActiveAt:Date.now()},await this.sessionStore.set(n),this.log.info("session created",{sessionId:s,platform:e.platform,channelId:e.channelId,chatId:e.chatId,userId:e.userId}),n)}get(e){return this.sessionStore.get(e)}async closeSession(e){let t=this.sessionStore.get(e);if(!t){this.log.warn("session not found",{sessionId:e});return}t.state.status="closed",await this.sessionStore.delete(e),this.log.info("session closed",{sessionId:e});}async closeById(e){return this.closeSession(e)}async bindBackendSession(e,t){let s=this.sessionStore.get(e);if(!s)throw new Error(`Session not found: ${e}`);s.backendSessionId=t,await this.sessionStore.set(s),this.log.info("backend session bound",{gatewaySessionId:e,backendSessionId:t});}async unbindBackendSession(e){let t=this.sessionStore.get(e);if(!t){this.log.warn("session not found",{sessionId:e});return}t.backendSessionId=null,await this.sessionStore.set(t),this.log.info("backend session unbound",{gatewaySessionId:e});}getState(e){return this.sessionStore.get(e)?.state}async incrementMessageCountOrCreate(e,t){let s=this.sessionStore.get(e);if(!s){let n=t??{platform:"api",channelId:"default"};s=await this.getOrCreate(n);}return s.state.messageCount++,s.state.lastMessageAt=Date.now(),s.lastActiveAt=Date.now(),await this.sessionStore.set(s),s}async incrementMessageCount(e){let t=this.sessionStore.get(e);t&&(t.state.messageCount++,t.state.lastMessageAt=Date.now(),t.lastActiveAt=Date.now(),await this.sessionStore.set(t));}async addSubscriber(e,t){let s=this.sessionStore.get(e);if(!s){this.log.warn("session not found",{sessionId:e});return}s.subscribers.add(t),await this.sessionStore.set(s),this.log.debug("subscriber added to session",{sessionId:e,subscriberId:t});}async removeSubscriber(e,t){let s=this.sessionStore.get(e);s&&(s.subscribers.delete(t),await this.sessionStore.set(s),this.log.debug("subscriber removed from session",{sessionId:e,subscriberId:t}));}query(e){let t=this.sessionStore.getAll();return e.platform&&(t=t.filter(s=>s.channel.platform===e.platform)),e.channelId&&(t=t.filter(s=>s.channel.channelId===e.channelId)),e.userId&&(t=t.filter(s=>s.channel.userId===e.userId)),e.status&&(t=t.filter(s=>s.state.status===e.status)),t}getSessionsByChannel(e){return this.sessionStore.getByChannel(e)}getAllSessions(){return this.sessionStore.getAll()}getSessionCount(){return this.sessionStore.size()}async cleanupIdleSessions(e){let t=Date.now(),s=[];for(let n of this.sessionStore.getAll())n.state.status==="idle"&&t-n.lastActiveAt>e&&s.push(n.id);for(let n of s)await this.closeSession(n);return s.length>0&&this.log.info("cleaned up idle sessions",{count:s.length}),s.length}async save(){this.log.debug("session save triggered");}getStats(){return this.sessionStore.getStats()}};chunkSIOB4FC7_cjs.a();var w=class{constructor(e={}){chunkXQVVSJRM_cjs.e(this,"log",chunkJJLKV5TO_cjs.a.create({service:"gateway:plugin-loader"}));chunkXQVVSJRM_cjs.e(this,"plugins",new Map);chunkXQVVSJRM_cjs.e(this,"messageHandler",null);chunkXQVVSJRM_cjs.e(this,"healthCheckTimer",null);chunkXQVVSJRM_cjs.e(this,"config");this.config={pluginDir:e.pluginDir??"./plugins",autoDiscover:e.autoDiscover??false,healthCheckInterval:e.healthCheckInterval??6e4,healthCheckTimeout:e.healthCheckTimeout??5e3};}setMessageHandler(e){this.messageHandler=e;}async register(e,t){if(this.plugins.has(e.id)){this.log.warn("plugin already registered",{id:e.id});return}this.plugins.set(e.id,{plugin:e,config:t,started:false}),this.log.info("plugin registered",{id:e.id,platform:e.platform,name:e.name});}async unregister(e){let t=this.plugins.get(e);if(!t){this.log.warn("plugin not found",{id:e});return}t.started&&await this.stop(e),this.plugins.delete(e),this.log.info("plugin unregistered",{id:e});}async start(e){let t=this.plugins.get(e);if(!t)throw new Error(`Plugin not found: ${e}`);if(t.started){this.log.warn("plugin already started",{id:e});return}if(!this.messageHandler)throw new Error("Message handler not set");if(!t.config.enabled){this.log.warn("plugin is disabled",{id:e});return}this.log.info("starting plugin",{id:e});try{await t.plugin.start(t.config,this.messageHandler),t.started=!0,this.log.info("plugin started",{id:e});}catch(s){throw this.log.error("failed to start plugin",{id:e,error:String(s)}),s}}async stop(e){let t=this.plugins.get(e);if(!t){this.log.warn("plugin not found",{id:e});return}if(!t.started){this.log.warn("plugin not started",{id:e});return}this.log.info("stopping plugin",{id:e});try{await t.plugin.stop(),t.started=!1,this.log.info("plugin stopped",{id:e});}catch(s){throw this.log.error("failed to stop plugin",{id:e,error:String(s)}),s}}async startAll(){let e=[];for(let[t,s]of this.plugins){if(!s.config.enabled){this.log.debug("skipping disabled plugin",{id:t});continue}try{await this.start(t);}catch(n){e.push({id:t,error:n instanceof Error?n:new Error(String(n))});}}e.length>0&&this.log.warn("some plugins failed to start",{count:e.length,errors:e.map(t=>({id:t.id,error:t.error.message}))});}async stopAll(){let e=[];for(let[t,s]of this.plugins)if(s.started)try{await this.stop(t);}catch(n){e.push({id:t,error:n instanceof Error?n:new Error(String(n))});}e.length>0&&this.log.warn("some plugins failed to stop",{count:e.length,errors:e.map(t=>({id:t.id,error:t.error.message}))});}getPlugin(e){return this.plugins.get(e)?.plugin}getAllPlugins(){return [...this.plugins.values()].map(e=>e.plugin)}getRunningPlugins(){return [...this.plugins.values()].filter(e=>e.started).map(e=>e.plugin)}isRunning(e){return this.plugins.get(e)?.started??false}async healthCheck(e){let t=this.plugins.get(e);if(!t)return {healthy:false,lastCheck:Date.now(),error:"Plugin not found"};try{let s=await Promise.race([t.plugin.healthCheck(),new Promise((n,r)=>setTimeout(()=>r(new Error("Health check timeout")),this.config.healthCheckTimeout))]);return t.lastHealthCheck=s,s}catch(s){let n={healthy:false,lastCheck:Date.now(),error:s instanceof Error?s.message:String(s)};return t.lastHealthCheck=n,n}}async healthCheckAll(){let e=new Map;for(let[t]of this.plugins)e.set(t,await this.healthCheck(t));return e}startHealthCheckTimer(){if(this.healthCheckTimer){this.log.warn("health check timer already running");return}this.healthCheckTimer=setInterval(async()=>{let e=await this.healthCheckAll();for(let[t,s]of e)s.healthy||this.log.warn("plugin health check failed",{id:t,error:s.error});},this.config.healthCheckInterval),this.log.info("health check timer started",{interval:this.config.healthCheckInterval});}stopHealthCheckTimer(){this.healthCheckTimer&&(clearInterval(this.healthCheckTimer),this.healthCheckTimer=null,this.log.info("health check timer stopped"));}async sendToPlugin(e,t){let s=this.plugins.get(e);if(!s)throw new Error(`Plugin not found: ${e}`);if(!s.started)throw new Error(`Plugin not started: ${e}`);return s.plugin.send(t)}};chunkSIOB4FC7_cjs.a();var l=chunkJJLKV5TO_cjs.a.create({service:"gateway:websocket-server"});function K(){return `ws_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function P(c,e){for(let[t,s]of e.entries())if(s===c)return t;return null}var _=class{constructor(e={}){chunkXQVVSJRM_cjs.e(this,"config");chunkXQVVSJRM_cjs.e(this,"server",null);chunkXQVVSJRM_cjs.e(this,"wss",null);chunkXQVVSJRM_cjs.e(this,"httpsServer",null);chunkXQVVSJRM_cjs.e(this,"httpRedirectServer",null);chunkXQVVSJRM_cjs.e(this,"connections",new Map);chunkXQVVSJRM_cjs.e(this,"subscriptions",new Map);chunkXQVVSJRM_cjs.e(this,"sessionSubscriptions",new Map);chunkXQVVSJRM_cjs.e(this,"sessionLastActivity",new Map);chunkXQVVSJRM_cjs.e(this,"cleanupInterval",null);chunkXQVVSJRM_cjs.e(this,"heartbeatInterval",null);chunkXQVVSJRM_cjs.e(this,"startTime",0);chunkXQVVSJRM_cjs.e(this,"running",false);this.config={...D,...e};}async start(){if(this.running){l.warn("WebSocket server is already running");return}l.info("Starting WebSocket server",{port:this.config.port,hostname:this.config.hostname,path:this.config.path,https:this.config.https?.enabled??false}),this.startTime=Date.now();let e={onOpen:(s,n)=>{this.handleConnection(n);},onMessage:async(s,n)=>{try{let r=JSON.parse(s.data.toString());await this.handleMessage(n,r);}catch(r){l.error("Error processing WebSocket message",{error:r.message}),this.sendError(n,r.message);}},onClose:(s,n)=>{this.handleDisconnection(n);},onError:(s,n)=>{l.error("WebSocket error",{error:s.type});}};this.config.https?.enabled?await this.startHTTPSServer(e):await this.startHTTPServer(e),this.cleanupInterval=setInterval(()=>this.cleanupExpiredSessions(),3e4),this.heartbeatInterval=setInterval(()=>this.checkConnectionTimeout(),this.config.heartbeatInterval),this.running=true;let t=this.config.https?.enabled?"wss":"ws";l.info("WebSocket server started",{url:`${t}://${this.config.hostname}:${this.config.port}${this.config.path}`});}async startHTTPServer(e){this.server=utils.createServer({port:this.config.port,hostname:this.config.hostname,routes:this.createRoutes(),timeout:this.config.connectionTimeout,cors:true});let t=this.server.raw;t&&this.setupWebSocketUpgrade(t,e);}async startHTTPSServer(e){let t=this.config.https,s=this.loadSSLCertificates(t);if(!s){l.error("Failed to load SSL certificates, falling back to HTTP"),await this.startHTTPServer(e);return}this.server=utils.createServer({port:this.config.port,hostname:this.config.hostname,routes:this.createRoutes(),timeout:this.config.connectionTimeout,cors:true});let n=this.server.raw;this.httpsServer=Q__default.default.createServer(s,n.listeners("request")[0]),this.setupWebSocketUpgrade(this.httpsServer,e),await new Promise(r=>{this.httpsServer.listen(this.config.port,this.config.hostname,()=>{l.info("HTTPS server started",{port:this.config.port,hostname:this.config.hostname}),r();});}),t.forceRedirect&&t.httpPort&&this.startHTTPRedirectServer(t.httpPort);}loadSSLCertificates(e){try{return e.cert&&e.key?{cert:e.cert,key:e.key}:e.certPath&&e.keyPath?{cert:f__namespace.default.readFileSync(e.certPath),key:f__namespace.default.readFileSync(e.keyPath)}:null}catch(t){return l.error("Failed to load SSL certificates",{error:t.message}),null}}setupWebSocketUpgrade(e,t){this.wss=new ws.WebSocketServer({noServer:true}),e.on("upgrade",(s,n,r)=>{try{let g=new URL(s.url||"/",`http://${s.headers.host}`).pathname;(g===this.config.path||this.config.path==="/"&&(g==="/"||g===""))&&this.wss.handleUpgrade(s,n,r,u=>{t.onOpen?.({type:"open"},u),u.on("message",p=>{t.onMessage?.({data:p},u);}),u.on("close",(p,G)=>{t.onClose?.({code:p,reason:G},u);}),u.on("error",p=>{t.onError?.({type:"error",message:p.message},u);});});}catch{}});}startHTTPRedirectServer(e){this.httpRedirectServer=V__default.default.createServer((t,s)=>{let r=`https://${t.headers.host?.split(":")[0]||this.config.hostname}:${this.config.port}${t.url}`;l.debug("Redirecting HTTP to HTTPS",{from:t.url,to:r}),s.writeHead(301,{Location:r,"Content-Type":"text/plain"}),s.end(`Redirecting to ${r}`);}),this.httpRedirectServer.listen(e,this.config.hostname,()=>{l.info("HTTP redirect server started",{port:e,hostname:this.config.hostname});});}async stop(){if(!this.running){l.warn("WebSocket server is not running");return}l.info("Stopping WebSocket server"),this.cleanupInterval&&(clearInterval(this.cleanupInterval),this.cleanupInterval=null),this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null);for(let[e,t]of this.connections.entries())try{t.close(1e3,"Server shutting down");}catch(s){l.debug("Error closing connection",{clientId:e,error:String(s)});}this.connections.clear(),this.subscriptions.clear(),this.sessionSubscriptions.clear(),this.sessionLastActivity.clear(),this.wss&&(this.wss.close(),this.wss=null),this.httpsServer&&(await new Promise(e=>{this.httpsServer.close(()=>e());}),this.httpsServer=null),this.httpRedirectServer&&(await new Promise(e=>{this.httpRedirectServer.close(()=>e());}),this.httpRedirectServer=null),this.server&&(await this.server.stop(),this.server=null),this.running=false,l.info("WebSocket server stopped");}broadcastToSession(e,t){this.touchSession(e);let s=this.sessionSubscriptions.get(e);if(!s||s.size===0){l.debug("No clients subscribed to session",{sessionId:e});return}let n=t?.properties?.sessionID;if(typeof n=="string"&&n&&n!==e)return;let r=JSON.stringify({type:"event",sessionId:e,payload:t});for(let a of s){let g=this.subscriptions.get(a);if(g&&g.ws.readyState===g.ws.OPEN&&g.subscribedSessions.has(e)){if(g.subscribedEventTypes.size>0&&!g.subscribedEventTypes.has(t.type)){l.debug("Event type not subscribed, skipping",{clientId:a,sessionId:e,eventType:t.type,subscribedTypes:Array.from(g.subscribedEventTypes)});continue}g.ws.send(r),l.debug("Event pushed to client",{clientId:a,sessionId:e,eventType:t.type});}}}getConnectionCount(){return this.connections.size}getSubscriptionCount(){return this.sessionSubscriptions.size}getConnectionInfos(){let e=[];for(let[t,s]of this.subscriptions.entries())e.push({clientId:t,state:s.ws.readyState===s.ws.OPEN?"connected":"disconnected",connectedAt:s.connectedAt,lastActivityAt:s.lastActivityAt,authInfo:s.authInfo});return e}isRunning(){return this.running}handleConnection(e){if(this.connections.size>=(this.config.maxConnections??b.maxConnections)){l.warn("Maximum connections reached, rejecting new connection"),e.close(1013,"Maximum connections reached");return}let t=K();this.connections.set(t,e),this.subscriptions.set(t,{clientId:t,ws:e,subscribedSessions:new Set,subscribedEventTypes:new Set,connectedAt:Date.now(),lastActivityAt:Date.now()}),l.info("WebSocket client connected",{clientId:t,totalConnections:this.connections.size}),this.sendMessage(e,{type:"connected",clientId:t,payload:{version:"1.0.0",capabilities:["subscribe","message","interrupt","releaseSubscription"]}});}handleDisconnection(e){let t=P(e,this.connections);if(!t)return;this.connections.delete(t);let s=this.subscriptions.get(t);if(s){for(let n of s.subscribedSessions){let r=this.sessionSubscriptions.get(n);r&&(r.delete(t),r.size===0&&this.sessionSubscriptions.delete(n));}this.subscriptions.delete(t);}l.info("WebSocket client disconnected",{clientId:t,totalConnections:this.connections.size});}async handleMessage(e,t){let s=P(e,this.connections);if(!s){this.sendError(e,"Client not found");return}let n=this.subscriptions.get(s);switch(n&&(n.lastActivityAt=Date.now()),t.type){case "ping":this.sendMessage(e,{type:"pong"});break;case "initialize":await this.handleInitialize(e,t);break;case "subscribe":await this.handleSubscribe(e,t);break;case "unsubscribe":await this.handleUnsubscribe(e,t);break;case "message":await this.handleMessageRequest(e,t);break;case "interrupt":await this.handleInterrupt(e,t);break;case "releaseSubscription":await this.handleReleaseSubscription(e,t);break;default:this.sendError(e,`Unknown message type: ${t.type}`);}}async handleInitialize(e,t){this.sendMessage(e,{type:"initialize_response",success:true,result:{capabilities:["subscribe","message","interrupt","releaseSubscription"]}});}async handleSubscribe(e,t){if(t.type!=="subscribe"||!t.sessionId){this.sendError(e,"Invalid subscribe request");return}let s=P(e,this.connections);if(!s){this.sendError(e,"Client not found");return}let n=this.subscriptions.get(s);if(!n){this.sendError(e,"Subscription not found");return}if(n.subscribedSessions.add(t.sessionId),this.sessionSubscriptions.has(t.sessionId)||this.sessionSubscriptions.set(t.sessionId,new Set),this.sessionSubscriptions.get(t.sessionId).add(s),this.touchSession(t.sessionId),t.payload?.eventTypes)for(let r of t.payload.eventTypes)n.subscribedEventTypes.add(r);l.info("Client subscribed to session",{clientId:s,sessionId:t.sessionId}),this.sendMessage(e,{type:"subscribed",sessionId:t.sessionId});}async handleUnsubscribe(e,t){if(t.type!=="unsubscribe"||!t.sessionId){this.sendError(e,"Invalid unsubscribe request");return}let s=P(e,this.connections);if(!s)return;let n=this.subscriptions.get(s);if(!n)return;n.subscribedSessions.delete(t.sessionId);let r=this.sessionSubscriptions.get(t.sessionId);r&&(r.delete(s),r.size===0&&this.sessionSubscriptions.delete(t.sessionId)),l.info("Client unsubscribed from session",{clientId:s,sessionId:t.sessionId}),this.sendMessage(e,{type:"unsubscribed",sessionId:t.sessionId});}async handleMessageRequest(e,t){if(t.type!=="message"||!t.sessionId||!t.payload){this.sendError(e,"Invalid message request");return}l.debug("Message received",{sessionId:t.sessionId}),this.sendMessage(e,{type:"response",sessionId:t.sessionId,success:true,result:{received:true}});}async handleInterrupt(e,t){if(t.type!=="interrupt"||!t.sessionId){this.sendError(e,"Invalid interrupt request");return}l.info("Interrupt requested via WebSocket",{sessionId:t.sessionId}),this.sendMessage(e,{type:"interrupted",sessionId:t.sessionId,success:true});}async handleReleaseSubscription(e,t){if(t.type!=="releaseSubscription"||!t.sessionId){this.sendError(e,"Invalid releaseSubscription request");return}l.info("Release subscription requested via WebSocket",{sessionId:t.sessionId}),this.releaseSessionResources(t.sessionId),this.sendMessage(e,{type:"subscriptionReleased",sessionId:t.sessionId});}touchSession(e){this.sessionLastActivity.set(e,Date.now());}checkConnectionTimeout(){let e=Date.now(),t=this.config.connectionTimeout??b.connectionTimeout,s=[];for(let[n,r]of this.subscriptions.entries())e-r.lastActivityAt>t&&s.push(n);for(let n of s){let r=this.subscriptions.get(n);if(r){l.info("Closing inactive connection",{clientId:n,lastActivityAt:r.lastActivityAt,timeoutMs:t});try{r.ws.close(1001,"Connection timeout");}catch(a){l.debug("Error closing timed out connection",{clientId:n,error:String(a)});}}}s.length>0&&l.debug("Closed timed out connections",{count:s.length,remainingConnections:this.connections.size-s.length});}cleanupExpiredSessions(){let e=Date.now(),t=[],s=this.config.sessionExpireMs??b.sessionExpireMs;for(let[n,r]of this.sessionLastActivity.entries())e-r>s&&t.push(n);for(let n of t)l.info("Session expired due to inactivity, releasing resources",{sessionId:n,lastActivity:this.sessionLastActivity.get(n),expireMs:s}),this.releaseSessionResources(n),this.sessionLastActivity.delete(n);t.length>0&&l.debug("Cleaned up expired sessions",{count:t.length,remainingActive:this.sessionLastActivity.size});}releaseSessionResources(e){let t=this.sessionSubscriptions.get(e);if(t){for(let s of t){let n=this.subscriptions.get(s);n&&n.ws.readyState===n.ws.OPEN&&this.sendMessage(n.ws,{type:"session_closed",sessionId:e,payload:{reason:"Session resources released due to expiration or explicit release"}});}for(let s of t){let n=this.subscriptions.get(s);n&&n.subscribedSessions.delete(e);}this.sessionSubscriptions.delete(e),l.info("Session resources released",{sessionId:e,clientCount:t.size});}}sendMessage(e,t){e.readyState===e.OPEN&&e.send(JSON.stringify(t));}sendError(e,t,s){this.sendMessage(e,{type:"error",message:t,code:s});}createRoutes(){return [{method:"get",path:"/health",handler:e=>{let t={status:"healthy",timestamp:Date.now(),version:"1.0.0"};return e.json(t)}},{method:"get",path:"/status",handler:e=>{let t={status:this.running?"running":"stopped",connections:this.connections.size,sessions:this.sessionSubscriptions.size,subscriptions:this.subscriptions.size,uptime:this.running?Date.now()-this.startTime:0,version:"1.0.0"};return e.json(t)}},{method:"post",path:"/initialize",handler:async e=>{let t=await e.req.json().catch(()=>({}));return l.debug("ACP initialize request received",{body:t}),e.json({success:true,result:{capabilities:["subscribe","message","interrupt","releaseSubscription"],version:"1.0.0"}})}},{method:"post",path:"/session",handler:async e=>{await e.req.json().catch(()=>({}));let n={id:`session_${Date.now()}_${Math.random().toString(36).substring(2,9)}`,createdAt:Date.now()};return e.json(n)}},{method:"post",path:"/session/:sessionId/prompt",handler:async e=>{let t=e.req.param("sessionId");await e.req.json().catch(()=>({}));if(!t)return e.json({error:"No sessionId provided"},400);let r={messageId:`msg_${Date.now()}_${Math.random().toString(36).substring(2,9)}`,sessionId:t,createdAt:Date.now()};return e.status(202),e.json(r)}},{method:"get",path:"/subscriptions",handler:e=>{let t=Array.from(this.sessionSubscriptions.entries()).map(([n,r])=>({sessionId:n,subscriberCount:r.size,subscribers:Array.from(r)})),s={subscriptions:t,total:t.length};return e.json(s)}}]}};function J(c){let e={platform:c.channel?.platform??"api",channelId:c.channel?.channelId??"unknown",chatId:c.channel?.chatId,userId:c.channel?.userId};return {id:c.messageId??`msg_${Date.now()}_${Math.random().toString(36).slice(2,9)}`,sessionId:c.sessionId,type:c.type,content:Array.isArray(c.content)?c.content:[{type:"text",text:String(c.content??"")}],metadata:{channel:e,replyToMessageId:c.replyToMessageId},timestamp:c.timestamp??Date.now()}}var O=class{constructor(e){chunkXQVVSJRM_cjs.e(this,"log",chunkJJLKV5TO_cjs.a.create({service:"gateway:server"}));chunkXQVVSJRM_cjs.e(this,"config");chunkXQVVSJRM_cjs.e(this,"router");chunkXQVVSJRM_cjs.e(this,"sessionManager");chunkXQVVSJRM_cjs.e(this,"pluginLoader");chunkXQVVSJRM_cjs.e(this,"messageStore");chunkXQVVSJRM_cjs.e(this,"running",false);chunkXQVVSJRM_cjs.e(this,"connections",0);this.config=e,this.router=new A,this.sessionManager=new M,this.pluginLoader=new w({healthCheckInterval:6e4});let t=chunkJJLKV5TO_cjs.R(),s=chunkJJLKV5TO_cjs.O();this.messageStore=new v({storagePath:`${t.Path.data}/gateway-messages`}),s&&chunkJJLKV5TO_cjs.P().setMessageStorage({store:async r=>{let a=J(r);await this.messageStore.store(a);},updateStatus:async(r,a,g)=>{await this.messageStore.updateStatus(r,a,g);}}),this.pluginLoader.setMessageHandler({onMessage:n=>this.onMessage(n),onEvent:n=>this.onEvent(n)});}async start(){if(this.running){this.log.warn("gateway server is already running");return}this.log.info("starting gateway server",{port:this.config.port,hostname:this.config.hostname}),await this.sessionManager.initialize(),await this.pluginLoader.startAll(),this.pluginLoader.startHealthCheckTimer(),this.running=true,this.log.info("gateway server started");}async stop(){if(!this.running){this.log.warn("gateway server is not running");return}this.log.info("stopping gateway server"),this.pluginLoader.stopHealthCheckTimer(),await this.pluginLoader.stopAll(),await this.router.shutdown(),await this.sessionManager.close(),this.running=false,this.log.info("gateway server stopped");}getStatus(){return {running:this.running,port:this.config.port,hostname:this.config.hostname,connections:this.connections}}async onMessage(e){if(this.log.debug("message received",{id:e.id,sessionId:e.sessionId,type:e.type}),this.messageStore.isProcessed(e.id)){this.log.warn("message already processed, skipping",{id:e.id});return}await this.storeMessage(e),await this.sessionManager.incrementMessageCountOrCreate(e.sessionId,e.metadata.channel),(await this.router.route(e)).broadcastCount===0&&e.type==="input"&&this.log.debug("no subscribers, message pending",{id:e.id});}async storeMessage(e){if(await this.messageStore.store(e),chunkJJLKV5TO_cjs.O())try{let t=chunkJJLKV5TO_cjs.P(),s={name:plugin.HookEvent.GatewayMessageReceive,data:{messageId:e.id,sessionId:e.sessionId,type:e.type,content:e.content,channel:e.metadata.channel,replyToMessageId:e.metadata.replyToMessageId,timestamp:e.timestamp||Date.now()}};await t.hookRegistry.emit(s);}catch{this.log.debug("hook trigger skipped (no context)");}}async processMessage(e,t,s,n={}){if(await this.messageStore.updateStatus(t,"processing",{processedBy:s}),chunkJJLKV5TO_cjs.O())try{await chunkJJLKV5TO_cjs.P().hookRegistry.emit({name:plugin.HookEvent.GatewayMessageProcess,data:{messageId:t,sessionId:e,processorId:s,processType:n.processType||"direct",agent:n.agent,timestamp:Date.now()}});}catch{this.log.debug("hook trigger skipped (no context)");}}async completeMessage(e,t,s,n={}){let{success:r=true,error:a,responseMessageId:g,tokens:u,duration:p}=n;if(await this.messageStore.updateStatus(t,r?"completed":"failed",{processedBy:s,error:a}),chunkJJLKV5TO_cjs.O())try{await chunkJJLKV5TO_cjs.P().hookRegistry.emit({name:plugin.HookEvent.GatewayMessageComplete,data:{messageId:t,sessionId:e,processorId:s,status:r?"completed":"failed",error:a,responseMessageId:g,tokens:u,duration:p,timestamp:Date.now()}});}catch{this.log.debug("hook trigger skipped (no context)");}await this.router.completeMessage(e,t,s,r?"completed":"failed");}async onEvent(e){switch(this.log.debug("channel event",{type:e.type,channelId:e.channelId}),e.type){case "connected":this.connections++;break;case "disconnected":this.connections--;break;case "error":this.log.error("channel error",{channelId:e.channelId,data:e.data});break}}async registerChannel(e,t){let s=t??{enabled:true,platform:{},session:{autoCreate:true,resetPolicy:"onNewConversation"},routing:{broadcast:true,dispatchToSubAgent:false}};await this.pluginLoader.register(e,s),this.running&&await this.pluginLoader.start(e.id);}async unregisterChannel(e){await this.pluginLoader.unregister(e);}async subscribe(e,t){await this.router.subscribe(e,t),await this.sessionManager.addSubscriber(e,t.id);}async unsubscribe(e){await this.router.unsubscribe(e);}async send(e){await this.onMessage(e);}async sendToChannel(e,t,s={}){let{proactive:n=false,replyToMessageId:r}=s;if(chunkJJLKV5TO_cjs.O())try{await chunkJJLKV5TO_cjs.P().hookRegistry.emit({name:plugin.HookEvent.GatewayMessageSend,data:{messageId:t.id,sessionId:t.sessionId,type:t.type,channel:t.metadata.channel,proactive:n,replyToMessageId:r,timestamp:Date.now()}});}catch{this.log.debug("hook trigger skipped (no context)");}return this.pluginLoader.sendToPlugin(e,t)}async sendProactiveMessage(e,t,s,n){let r={id:`msg_${Date.now()}_${Math.random().toString(36).slice(2,9)}`,sessionId:t,type:"output",content:s,metadata:{channel:n},timestamp:Date.now()};return this.sendToChannel(e,r,{proactive:true})}getSessionManager(){return this.sessionManager}getRouter(){return this.router}getPluginLoader(){return this.pluginLoader}getMessageStore(){return this.messageStore}async getMessageHistory(e,t){return this.messageStore.getSessionHistory(e,t)}};
|
|
2
|
+
exports.a=I;exports.b=x;exports.c=H;exports.d=B;exports.e=T;exports.f=E;exports.g=k;exports.h=D;exports.i=q;exports.j=F;exports.k=U;exports.l=$;exports.m=A;exports.n=v;exports.o=C;exports.p=M;exports.q=w;exports.r=_;exports.s=O;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var s={name:"@easbot/gateway",version:"0.1.11",description:"EASBot Gateway - AI Agent Server and Multi-channel Integration Platform - \u652F\u6301 WebSocket\u3001HTTP\u3001Discord\u3001Telegram\u3001Slack \u7B49\u591A\u6E20\u9053\u96C6\u6210",type:"module",main:"dist/index.cjs",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.cjs"},"./package.json":"./package.json"},scripts:{dev:"cross-env NODE_ENV=development tsx src/cli.ts -- start",start:"cross-env NODE_ENV=production node dist/cli.mjs start",build:"tsup --env.NODE_ENV production",test:"vitest","test:run":"vitest run",lint:"biome check .","lint:fix":"biome check --write .","lint:report":"biome check --reporter=summary .",format:"biome format .","format:fix":"biome format --write .","type-check":"tsc --noEmit",clean:"npx rimraf dist node_modules",prepare:"echo norun",prepublishOnly:"pnpm build","publish:npm":"bash scripts/publish.sh","publish:npm:win":"powershell -ExecutionPolicy Bypass -File scripts/publish.ps1"},keywords:["easbot","gateway","server","websocket","http","agent","multi-channel","discord","telegram","slack","feishu","wechat","chat","integration"],author:"houjallen",license:"MIT",repository:{type:"git",url:"https://github.com/houjallen/easbot.git",directory:"packages/gateway"},homepage:"https://github.com/houjallen/easbot/tree/main/packages/gateway#readme",bugs:{url:"https://github.com/houjallen/easbot/issues"},files:["dist","README.md","README.en.md","LICENSE"],dependencies:{"@ai-sdk/provider":"^3.0.8","@ai-sdk/provider-utils":"^4.0.21","@ai-sdk/openai-compatible":"2.0.37","@ai-sdk/anthropic":"3.0.63","@easbot/plugin":"workspace:*","@easbot/sdk":"workspace:*","@easbot/types":"workspace:*","@easbot/utils":"workspace:*",zod:"^4.3.6",ws:"^8.20.0",ai:"^6.0.136","better-sqlite3":"^12.9.0","jieba-wasm":"^2.4.0","xdg-basedir":"^5.1.0"},devDependencies:{"@biomejs/biome":"^2.4.8","@types/better-sqlite3":"^7.6.13","@types/ws":"^8.18.1","@types/node":"^22.17.0","@vitest/coverage-v8":"^4.1.1",dotenv:"^17.3.1",tsup:"^8.5.1",typescript:"^6.0.2",vitest:"^4.1.1"},engines:{node:">=22.17.0"},publishConfig:{access:"public"}};
|
|
2
|
+
exports.a=s;
|