@dsh-plugin/dsh-synapse 0.1.0-dev.41044228975 → 0.1.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.
Files changed (74) hide show
  1. package/LICENSE +661 -661
  2. package/README.md +0 -14
  3. package/package.json +1 -1
  4. package/vendor/gugle-chat-bot/LICENSE +661 -661
  5. package/vendor/gugle-chat-bot/package.json +57 -57
  6. package/vendor/gugle-chat-bot/src/allow-rule.yml +9345 -9345
  7. package/vendor/gugle-chat-bot/src/api.json +4284 -4284
  8. package/vendor/gugle-chat-bot/src/command/index.ts +141 -141
  9. package/vendor/gugle-chat-bot/src/config/features.ts +547 -547
  10. package/vendor/gugle-chat-bot/src/config/index.ts +184 -184
  11. package/vendor/gugle-chat-bot/src/config/manager.ts +356 -356
  12. package/vendor/gugle-chat-bot/src/constants/index.ts +13 -13
  13. package/vendor/gugle-chat-bot/src/custom.ts +548 -548
  14. package/vendor/gugle-chat-bot/src/event/index.ts +118 -118
  15. package/vendor/gugle-chat-bot/src/features/admin/index.ts +414 -414
  16. package/vendor/gugle-chat-bot/src/features/bili/image/impl/video.ts +39 -39
  17. package/vendor/gugle-chat-bot/src/features/bili/image/index.ts +37 -37
  18. package/vendor/gugle-chat-bot/src/features/bili/index.ts +65 -65
  19. package/vendor/gugle-chat-bot/src/features/bili/template/style/video.css +97 -97
  20. package/vendor/gugle-chat-bot/src/features/bili/template/video.html +56 -56
  21. package/vendor/gugle-chat-bot/src/features/discord-bridge/index.ts +1128 -1128
  22. package/vendor/gugle-chat-bot/src/features/discord-bridge/markdown.ts +105 -105
  23. package/vendor/gugle-chat-bot/src/features/discord-bridge/slash.ts +355 -355
  24. package/vendor/gugle-chat-bot/src/features/discord-bridge/source.ts +96 -96
  25. package/vendor/gugle-chat-bot/src/features/discord-bridge/template/message.html +14 -14
  26. package/vendor/gugle-chat-bot/src/features/discord-bridge/template/style/message.css +144 -144
  27. package/vendor/gugle-chat-bot/src/features/github/api.ts +93 -93
  28. package/vendor/gugle-chat-bot/src/features/github/binding.ts +161 -161
  29. package/vendor/gugle-chat-bot/src/features/github/image/impl/issue.ts +132 -132
  30. package/vendor/gugle-chat-bot/src/features/github/image/impl/pr.ts +144 -144
  31. package/vendor/gugle-chat-bot/src/features/github/image/impl/release.ts +160 -160
  32. package/vendor/gugle-chat-bot/src/features/github/image/index.ts +310 -310
  33. package/vendor/gugle-chat-bot/src/features/github/index.ts +302 -302
  34. package/vendor/gugle-chat-bot/src/features/github/template/issue.html +118 -118
  35. package/vendor/gugle-chat-bot/src/features/github/template/pull_request.html +125 -125
  36. package/vendor/gugle-chat-bot/src/features/github/template/release.html +53 -53
  37. package/vendor/gugle-chat-bot/src/features/github/template/style/issue.css +468 -468
  38. package/vendor/gugle-chat-bot/src/features/github/template/style/pull_request.css +468 -468
  39. package/vendor/gugle-chat-bot/src/features/github/template/style/release.css +412 -412
  40. package/vendor/gugle-chat-bot/src/features/hermes/client.ts +184 -184
  41. package/vendor/gugle-chat-bot/src/features/hermes/config.ts +210 -210
  42. package/vendor/gugle-chat-bot/src/features/hermes/context.ts +67 -67
  43. package/vendor/gugle-chat-bot/src/features/hermes/history.ts +86 -86
  44. package/vendor/gugle-chat-bot/src/features/hermes/index.ts +1533 -1533
  45. package/vendor/gugle-chat-bot/src/features/hermes/message.ts +319 -319
  46. package/vendor/gugle-chat-bot/src/features/hermes/reaction.ts +181 -181
  47. package/vendor/gugle-chat-bot/src/features/hermes/render.ts +118 -118
  48. package/vendor/gugle-chat-bot/src/features/hermes/reply-units.ts +331 -331
  49. package/vendor/gugle-chat-bot/src/features/hermes/skills.ts +406 -406
  50. package/vendor/gugle-chat-bot/src/features/hermes/template/approval.html +30 -30
  51. package/vendor/gugle-chat-bot/src/features/hermes/template/progress.html +21 -21
  52. package/vendor/gugle-chat-bot/src/features/hermes/template/style/approval.css +81 -81
  53. package/vendor/gugle-chat-bot/src/features/hermes/template/style/progress.css +120 -120
  54. package/vendor/gugle-chat-bot/src/features/hermes/trigger.ts +86 -86
  55. package/vendor/gugle-chat-bot/src/features/hermes/types.ts +327 -327
  56. package/vendor/gugle-chat-bot/src/features/management/index.ts +156 -156
  57. package/vendor/gugle-chat-bot/src/features/minecraft/index.ts +127 -127
  58. package/vendor/gugle-chat-bot/src/features/modrinth/index.ts +71 -71
  59. package/vendor/gugle-chat-bot/src/features/parentheses/index.ts +117 -117
  60. package/vendor/gugle-chat-bot/src/features/peak-valley-timer/index.ts +451 -451
  61. package/vendor/gugle-chat-bot/src/features/poke/index.ts +24 -24
  62. package/vendor/gugle-chat-bot/src/features/version-tracker/index.ts +77 -77
  63. package/vendor/gugle-chat-bot/src/features/welcome/index.ts +57 -57
  64. package/vendor/gugle-chat-bot/src/github-ip.json +5814 -5814
  65. package/vendor/gugle-chat-bot/src/image/index.ts +278 -278
  66. package/vendor/gugle-chat-bot/src/index.ts +695 -695
  67. package/vendor/gugle-chat-bot/src/logger/index.ts +54 -54
  68. package/vendor/gugle-chat-bot/src/result.json +359 -359
  69. package/vendor/gugle-chat-bot/src/type/bili.d.ts +825 -825
  70. package/vendor/gugle-chat-bot/src/type/event.d.ts +146 -146
  71. package/vendor/gugle-chat-bot/src/type/github.d.ts +446 -446
  72. package/vendor/gugle-chat-bot/src/type/index.d.ts +254 -254
  73. package/vendor/gugle-chat-bot/tsconfig.json +46 -46
  74. package/scripts/dump-npm-latest.mjs +0 -30
@@ -1,86 +1,86 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { HistoryEntry } from '@/features/hermes/types';
4
-
5
- /**
6
- * 聊天记录持久化存储(移植自 qq-hermes-bridge src/history.ts,MIT 协议,原作者 Amorter)。
7
- * 每个会话以 JSON 文件形式存储在 data/hermes-history/,最多保留 N 条消息,
8
- * 进程重启后自动恢复。
9
- */
10
- export class ChatHistoryStore {
11
- private readonly dir: string;
12
- private readonly maxMessages: number;
13
- private readonly enabled: boolean;
14
-
15
- /** 内存缓存:key → 历史消息数组 */
16
- private readonly cache = new Map<string, HistoryEntry[]>();
17
-
18
- /**
19
- * @param maxMessages 每个会话最多保留的消息条数
20
- * @param enabled 是否启用持久化
21
- */
22
- public constructor(maxMessages: number, enabled: boolean) {
23
- this.dir = path.resolve(process.cwd(), 'data', 'hermes-history');
24
- this.maxMessages = maxMessages;
25
- this.enabled = enabled;
26
- if (enabled) {
27
- fs.mkdirSync(this.dir, { recursive: true });
28
- }
29
- }
30
-
31
- /**
32
- * 加载会话历史。
33
- * 优先从内存缓存读取,缓存未命中时从磁盘加载。
34
- */
35
- public load(key: string): HistoryEntry[] {
36
- if (!this.enabled) return [];
37
- if (this.cache.has(key)) return this.cache.get(key)!;
38
-
39
- try {
40
- const filePath = this.filePath(key);
41
- if (fs.existsSync(filePath)) {
42
- const data = JSON.parse(fs.readFileSync(filePath, 'utf-8')) as HistoryEntry[];
43
- if (Array.isArray(data)) {
44
- this.cache.set(key, data);
45
- return data;
46
- }
47
- }
48
- } catch {
49
- // 文件损坏或格式错误,忽略
50
- }
51
- return [];
52
- }
53
-
54
- /**
55
- * 保存会话历史。
56
- * 自动裁剪到 maxMessages 条,先写内存缓存再落盘。
57
- */
58
- public save(key: string, history: HistoryEntry[]): void {
59
- if (!this.enabled) return;
60
- const trimmed = history.slice(-this.maxMessages);
61
- this.cache.set(key, trimmed);
62
- try {
63
- fs.writeFileSync(this.filePath(key), JSON.stringify(trimmed, null, 2), 'utf-8');
64
- } catch {
65
- // 写入失败不阻塞主流程(磁盘满等极端情况)
66
- }
67
- }
68
-
69
- /** 清除会话的持久化历史 */
70
- public clear(key: string): void {
71
- if (!this.enabled) return;
72
- this.cache.delete(key);
73
- try {
74
- const filePath = this.filePath(key);
75
- if (fs.existsSync(filePath)) fs.unlinkSync(filePath);
76
- } catch {
77
- // 忽略
78
- }
79
- }
80
-
81
- /** 根据会话键生成安全的文件名(group:123456 → group_123456.json) */
82
- private filePath(key: string): string {
83
- const safe = key.replace(/[<>:"/\\|?*]/g, '_');
84
- return path.join(this.dir, `${safe}.json`);
85
- }
86
- }
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { HistoryEntry } from '@/features/hermes/types';
4
+
5
+ /**
6
+ * 聊天记录持久化存储(移植自 qq-hermes-bridge src/history.ts,MIT 协议,原作者 Amorter)。
7
+ * 每个会话以 JSON 文件形式存储在 data/hermes-history/,最多保留 N 条消息,
8
+ * 进程重启后自动恢复。
9
+ */
10
+ export class ChatHistoryStore {
11
+ private readonly dir: string;
12
+ private readonly maxMessages: number;
13
+ private readonly enabled: boolean;
14
+
15
+ /** 内存缓存:key → 历史消息数组 */
16
+ private readonly cache = new Map<string, HistoryEntry[]>();
17
+
18
+ /**
19
+ * @param maxMessages 每个会话最多保留的消息条数
20
+ * @param enabled 是否启用持久化
21
+ */
22
+ public constructor(maxMessages: number, enabled: boolean) {
23
+ this.dir = path.resolve(process.cwd(), 'data', 'hermes-history');
24
+ this.maxMessages = maxMessages;
25
+ this.enabled = enabled;
26
+ if (enabled) {
27
+ fs.mkdirSync(this.dir, { recursive: true });
28
+ }
29
+ }
30
+
31
+ /**
32
+ * 加载会话历史。
33
+ * 优先从内存缓存读取,缓存未命中时从磁盘加载。
34
+ */
35
+ public load(key: string): HistoryEntry[] {
36
+ if (!this.enabled) return [];
37
+ if (this.cache.has(key)) return this.cache.get(key)!;
38
+
39
+ try {
40
+ const filePath = this.filePath(key);
41
+ if (fs.existsSync(filePath)) {
42
+ const data = JSON.parse(fs.readFileSync(filePath, 'utf-8')) as HistoryEntry[];
43
+ if (Array.isArray(data)) {
44
+ this.cache.set(key, data);
45
+ return data;
46
+ }
47
+ }
48
+ } catch {
49
+ // 文件损坏或格式错误,忽略
50
+ }
51
+ return [];
52
+ }
53
+
54
+ /**
55
+ * 保存会话历史。
56
+ * 自动裁剪到 maxMessages 条,先写内存缓存再落盘。
57
+ */
58
+ public save(key: string, history: HistoryEntry[]): void {
59
+ if (!this.enabled) return;
60
+ const trimmed = history.slice(-this.maxMessages);
61
+ this.cache.set(key, trimmed);
62
+ try {
63
+ fs.writeFileSync(this.filePath(key), JSON.stringify(trimmed, null, 2), 'utf-8');
64
+ } catch {
65
+ // 写入失败不阻塞主流程(磁盘满等极端情况)
66
+ }
67
+ }
68
+
69
+ /** 清除会话的持久化历史 */
70
+ public clear(key: string): void {
71
+ if (!this.enabled) return;
72
+ this.cache.delete(key);
73
+ try {
74
+ const filePath = this.filePath(key);
75
+ if (fs.existsSync(filePath)) fs.unlinkSync(filePath);
76
+ } catch {
77
+ // 忽略
78
+ }
79
+ }
80
+
81
+ /** 根据会话键生成安全的文件名(group:123456 → group_123456.json) */
82
+ private filePath(key: string): string {
83
+ const safe = key.replace(/[<>:"/\\|?*]/g, '_');
84
+ return path.join(this.dir, `${safe}.json`);
85
+ }
86
+ }