|
1 | | -import fs from "node:fs"; |
2 | | -import path from "node:path"; |
3 | 1 | import { describe, expect, it } from "vitest"; |
| 2 | +import { discordSessionBindingAdapterChannels } from "../../../../extensions/discord/runtime-api.js"; |
| 3 | +import { feishuSessionBindingAdapterChannels } from "../../../../extensions/feishu/api.js"; |
| 4 | +import { matrixSessionBindingAdapterChannels } from "../../../../extensions/matrix/api.js"; |
| 5 | +import { telegramSessionBindingAdapterChannels } from "../../../../extensions/telegram/runtime-api.js"; |
4 | 6 | import { sessionBindingContractChannelIds } from "./manifest.js"; |
5 | 7 |
|
6 | | -const sessionBindingAdapterFiles = [ |
7 | | - "../../../../extensions/discord/src/monitor/thread-bindings.manager.ts", |
8 | | - "../../../../extensions/feishu/src/thread-bindings.ts", |
9 | | - "../../../../extensions/matrix/src/matrix/thread-bindings.ts", |
10 | | - "../../../../extensions/telegram/src/thread-bindings.ts", |
11 | | -] as const; |
12 | | - |
13 | 8 | function discoverSessionBindingChannels() { |
14 | | - const channels = new Set<string>(); |
15 | | - for (const relativePath of sessionBindingAdapterFiles) { |
16 | | - const filePath = path.resolve(import.meta.dirname, relativePath); |
17 | | - const source = fs.readFileSync(filePath, "utf8"); |
18 | | - for (const match of source.matchAll( |
19 | | - /registerSessionBindingAdapter\(\{[\s\S]*?channel:\s*"([^"]+)"/g, |
20 | | - )) { |
21 | | - channels.add(match[1]); |
22 | | - } |
23 | | - } |
24 | | - return [...channels].toSorted(); |
| 9 | + return [ |
| 10 | + ...new Set([ |
| 11 | + ...discordSessionBindingAdapterChannels, |
| 12 | + ...feishuSessionBindingAdapterChannels, |
| 13 | + ...matrixSessionBindingAdapterChannels, |
| 14 | + ...telegramSessionBindingAdapterChannels, |
| 15 | + ]), |
| 16 | + ].toSorted(); |
25 | 17 | } |
26 | 18 |
|
27 | 19 | describe("channel contract registry", () => { |
|
0 commit comments