* 从配置文件中创建上下文 * * 因为考虑serverless服务因此不能全局管理
(githubRaw: string)
| 178 | * 因为考虑serverless服务因此不能全局管理 |
| 179 | */ |
| 180 | function createTailchatContextWithConfig(githubRaw: string) { |
| 181 | const content = Buffer.from(githubRaw, 'base64').toString(); |
| 182 | const json = JSON.parse(content); |
| 183 | const tailchatHost = json['tailchatHost'] ?? defaultTailchatApiUrl; |
| 184 | const groupId = json['groupId']; |
| 185 | const panelId = json['panelId']; |
| 186 | |
| 187 | if (!groupId || !panelId) { |
| 188 | throw new Error('config format error'); |
| 189 | } |
| 190 | |
| 191 | const tailchatClient = createTailchatClient(tailchatHost); |
| 192 | |
| 193 | return { |
| 194 | tailchatClient, |
| 195 | groupId, |
| 196 | panelId, |
| 197 | }; |
| 198 | } |
| 199 | |
| 200 | function createTailchatClient(tailchatHost = defaultTailchatApiUrl) { |
| 201 | const tailchatClient = new TailchatClient( |
no test coverage detected