openclaw-channel-dmwork 0.2.16 → 0.2.17

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 (196) hide show
  1. package/openclaw.plugin.json +1 -1
  2. package/package.json +2 -2
  3. package/src/accounts.ts +2 -0
  4. package/src/api-fetch.ts +46 -0
  5. package/src/config-schema.ts +4 -0
  6. package/src/inbound.ts +55 -18
  7. package/node_modules/@types/bignumber.js/LICENSE +0 -21
  8. package/node_modules/@types/bignumber.js/README.md +0 -3
  9. package/node_modules/@types/bignumber.js/package.json +0 -12
  10. package/node_modules/@types/crypto-js/LICENSE +0 -21
  11. package/node_modules/@types/crypto-js/README.md +0 -15
  12. package/node_modules/@types/crypto-js/aes.d.ts +0 -3
  13. package/node_modules/@types/crypto-js/blowfish.d.ts +0 -3
  14. package/node_modules/@types/crypto-js/core.d.ts +0 -3
  15. package/node_modules/@types/crypto-js/enc-base64.d.ts +0 -3
  16. package/node_modules/@types/crypto-js/enc-base64url.d.ts +0 -3
  17. package/node_modules/@types/crypto-js/enc-hex.d.ts +0 -3
  18. package/node_modules/@types/crypto-js/enc-latin1.d.ts +0 -3
  19. package/node_modules/@types/crypto-js/enc-utf16.d.ts +0 -3
  20. package/node_modules/@types/crypto-js/enc-utf8.d.ts +0 -3
  21. package/node_modules/@types/crypto-js/evpkdf.d.ts +0 -3
  22. package/node_modules/@types/crypto-js/format-hex.d.ts +0 -3
  23. package/node_modules/@types/crypto-js/format-openssl.d.ts +0 -3
  24. package/node_modules/@types/crypto-js/hmac-md5.d.ts +0 -3
  25. package/node_modules/@types/crypto-js/hmac-ripemd160.d.ts +0 -3
  26. package/node_modules/@types/crypto-js/hmac-sha1.d.ts +0 -3
  27. package/node_modules/@types/crypto-js/hmac-sha224.d.ts +0 -3
  28. package/node_modules/@types/crypto-js/hmac-sha256.d.ts +0 -3
  29. package/node_modules/@types/crypto-js/hmac-sha3.d.ts +0 -3
  30. package/node_modules/@types/crypto-js/hmac-sha384.d.ts +0 -3
  31. package/node_modules/@types/crypto-js/hmac-sha512.d.ts +0 -3
  32. package/node_modules/@types/crypto-js/index.d.ts +0 -1757
  33. package/node_modules/@types/crypto-js/lib-typedarrays.d.ts +0 -3
  34. package/node_modules/@types/crypto-js/md5.d.ts +0 -3
  35. package/node_modules/@types/crypto-js/mode-cfb.d.ts +0 -3
  36. package/node_modules/@types/crypto-js/mode-ctr-gladman.d.ts +0 -3
  37. package/node_modules/@types/crypto-js/mode-ctr.d.ts +0 -3
  38. package/node_modules/@types/crypto-js/mode-ecb.d.ts +0 -3
  39. package/node_modules/@types/crypto-js/mode-ofb.d.ts +0 -3
  40. package/node_modules/@types/crypto-js/package.json +0 -40
  41. package/node_modules/@types/crypto-js/pad-ansix923.d.ts +0 -3
  42. package/node_modules/@types/crypto-js/pad-iso10126.d.ts +0 -3
  43. package/node_modules/@types/crypto-js/pad-iso97971.d.ts +0 -3
  44. package/node_modules/@types/crypto-js/pad-nopadding.d.ts +0 -3
  45. package/node_modules/@types/crypto-js/pad-pkcs7.d.ts +0 -3
  46. package/node_modules/@types/crypto-js/pad-zeropadding.d.ts +0 -3
  47. package/node_modules/@types/crypto-js/pbkdf2.d.ts +0 -3
  48. package/node_modules/@types/crypto-js/rabbit-legacy.d.ts +0 -3
  49. package/node_modules/@types/crypto-js/rabbit.d.ts +0 -3
  50. package/node_modules/@types/crypto-js/rc4.d.ts +0 -3
  51. package/node_modules/@types/crypto-js/ripemd160.d.ts +0 -3
  52. package/node_modules/@types/crypto-js/sha1.d.ts +0 -3
  53. package/node_modules/@types/crypto-js/sha224.d.ts +0 -3
  54. package/node_modules/@types/crypto-js/sha256.d.ts +0 -3
  55. package/node_modules/@types/crypto-js/sha3.d.ts +0 -3
  56. package/node_modules/@types/crypto-js/sha384.d.ts +0 -3
  57. package/node_modules/@types/crypto-js/sha512.d.ts +0 -3
  58. package/node_modules/@types/crypto-js/tripledes.d.ts +0 -3
  59. package/node_modules/@types/crypto-js/x64-core.d.ts +0 -3
  60. package/node_modules/base64-js/LICENSE +0 -21
  61. package/node_modules/base64-js/README.md +0 -34
  62. package/node_modules/base64-js/base64js.min.js +0 -1
  63. package/node_modules/base64-js/index.d.ts +0 -3
  64. package/node_modules/base64-js/index.js +0 -150
  65. package/node_modules/base64-js/package.json +0 -47
  66. package/node_modules/bignumber.js/CHANGELOG.md +0 -381
  67. package/node_modules/bignumber.js/LICENCE.md +0 -26
  68. package/node_modules/bignumber.js/README.md +0 -289
  69. package/node_modules/bignumber.js/bignumber.d.mts +0 -6
  70. package/node_modules/bignumber.js/bignumber.d.ts +0 -5
  71. package/node_modules/bignumber.js/bignumber.js +0 -2922
  72. package/node_modules/bignumber.js/bignumber.mjs +0 -2907
  73. package/node_modules/bignumber.js/doc/API.html +0 -2249
  74. package/node_modules/bignumber.js/package.json +0 -60
  75. package/node_modules/bignumber.js/types.d.ts +0 -1821
  76. package/node_modules/buffer/AUTHORS.md +0 -73
  77. package/node_modules/buffer/LICENSE +0 -21
  78. package/node_modules/buffer/README.md +0 -410
  79. package/node_modules/buffer/index.d.ts +0 -194
  80. package/node_modules/buffer/index.js +0 -2106
  81. package/node_modules/buffer/package.json +0 -93
  82. package/node_modules/crypto-js/CONTRIBUTING.md +0 -28
  83. package/node_modules/crypto-js/LICENSE +0 -24
  84. package/node_modules/crypto-js/README.md +0 -275
  85. package/node_modules/crypto-js/aes.js +0 -234
  86. package/node_modules/crypto-js/blowfish.js +0 -471
  87. package/node_modules/crypto-js/bower.json +0 -39
  88. package/node_modules/crypto-js/cipher-core.js +0 -895
  89. package/node_modules/crypto-js/core.js +0 -807
  90. package/node_modules/crypto-js/crypto-js.js +0 -6657
  91. package/node_modules/crypto-js/docs/QuickStartGuide.wiki +0 -470
  92. package/node_modules/crypto-js/enc-base64.js +0 -136
  93. package/node_modules/crypto-js/enc-base64url.js +0 -148
  94. package/node_modules/crypto-js/enc-hex.js +0 -18
  95. package/node_modules/crypto-js/enc-latin1.js +0 -18
  96. package/node_modules/crypto-js/enc-utf16.js +0 -149
  97. package/node_modules/crypto-js/enc-utf8.js +0 -18
  98. package/node_modules/crypto-js/evpkdf.js +0 -134
  99. package/node_modules/crypto-js/format-hex.js +0 -66
  100. package/node_modules/crypto-js/format-openssl.js +0 -18
  101. package/node_modules/crypto-js/hmac-md5.js +0 -18
  102. package/node_modules/crypto-js/hmac-ripemd160.js +0 -18
  103. package/node_modules/crypto-js/hmac-sha1.js +0 -18
  104. package/node_modules/crypto-js/hmac-sha224.js +0 -18
  105. package/node_modules/crypto-js/hmac-sha256.js +0 -18
  106. package/node_modules/crypto-js/hmac-sha3.js +0 -18
  107. package/node_modules/crypto-js/hmac-sha384.js +0 -18
  108. package/node_modules/crypto-js/hmac-sha512.js +0 -18
  109. package/node_modules/crypto-js/hmac.js +0 -143
  110. package/node_modules/crypto-js/index.js +0 -18
  111. package/node_modules/crypto-js/lib-typedarrays.js +0 -76
  112. package/node_modules/crypto-js/md5.js +0 -268
  113. package/node_modules/crypto-js/mode-cfb.js +0 -80
  114. package/node_modules/crypto-js/mode-ctr-gladman.js +0 -116
  115. package/node_modules/crypto-js/mode-ctr.js +0 -58
  116. package/node_modules/crypto-js/mode-ecb.js +0 -40
  117. package/node_modules/crypto-js/mode-ofb.js +0 -54
  118. package/node_modules/crypto-js/package.json +0 -42
  119. package/node_modules/crypto-js/pad-ansix923.js +0 -49
  120. package/node_modules/crypto-js/pad-iso10126.js +0 -44
  121. package/node_modules/crypto-js/pad-iso97971.js +0 -40
  122. package/node_modules/crypto-js/pad-nopadding.js +0 -30
  123. package/node_modules/crypto-js/pad-pkcs7.js +0 -18
  124. package/node_modules/crypto-js/pad-zeropadding.js +0 -47
  125. package/node_modules/crypto-js/pbkdf2.js +0 -145
  126. package/node_modules/crypto-js/rabbit-legacy.js +0 -190
  127. package/node_modules/crypto-js/rabbit.js +0 -192
  128. package/node_modules/crypto-js/rc4.js +0 -139
  129. package/node_modules/crypto-js/ripemd160.js +0 -267
  130. package/node_modules/crypto-js/sha1.js +0 -150
  131. package/node_modules/crypto-js/sha224.js +0 -80
  132. package/node_modules/crypto-js/sha256.js +0 -199
  133. package/node_modules/crypto-js/sha3.js +0 -326
  134. package/node_modules/crypto-js/sha384.js +0 -83
  135. package/node_modules/crypto-js/sha512.js +0 -326
  136. package/node_modules/crypto-js/tripledes.js +0 -779
  137. package/node_modules/crypto-js/x64-core.js +0 -304
  138. package/node_modules/curve25519-js/.prettierrc +0 -6
  139. package/node_modules/curve25519-js/LICENSE +0 -19
  140. package/node_modules/curve25519-js/README.md +0 -111
  141. package/node_modules/curve25519-js/lib/index.d.ts +0 -69
  142. package/node_modules/curve25519-js/lib/index.js +0 -1669
  143. package/node_modules/curve25519-js/package.json +0 -34
  144. package/node_modules/curve25519-js/tsconfig.json +0 -20
  145. package/node_modules/curve25519-js/tslint.json +0 -10
  146. package/node_modules/ieee754/LICENSE +0 -11
  147. package/node_modules/ieee754/README.md +0 -51
  148. package/node_modules/ieee754/index.d.ts +0 -10
  149. package/node_modules/ieee754/index.js +0 -85
  150. package/node_modules/ieee754/package.json +0 -52
  151. package/node_modules/md5-typescript/.idea/Md5-typescript.iml +0 -13
  152. package/node_modules/md5-typescript/.idea/jsLibraryMappings.xml +0 -6
  153. package/node_modules/md5-typescript/.idea/libraries/tsconfig_roots.xml +0 -13
  154. package/node_modules/md5-typescript/.idea/modules.xml +0 -8
  155. package/node_modules/md5-typescript/.idea/vcs.xml +0 -6
  156. package/node_modules/md5-typescript/.idea/workspace.xml +0 -345
  157. package/node_modules/md5-typescript/LICENSE +0 -21
  158. package/node_modules/md5-typescript/README.md +0 -13
  159. package/node_modules/md5-typescript/dist/bundles/bundle.umd.js +0 -208
  160. package/node_modules/md5-typescript/dist/bundles/bundle.umd.min.js +0 -1
  161. package/node_modules/md5-typescript/dist/index.d.ts +0 -43
  162. package/node_modules/md5-typescript/dist/index.js +0 -198
  163. package/node_modules/md5-typescript/dist/index.js.map +0 -1
  164. package/node_modules/md5-typescript/dist/index.metadata.json +0 -1
  165. package/node_modules/md5-typescript/package.json +0 -31
  166. package/node_modules/md5-typescript/rollup.config.js +0 -7
  167. package/node_modules/md5-typescript/tsconfig.json +0 -28
  168. package/node_modules/wukongimjssdk/README.md +0 -42
  169. package/node_modules/wukongimjssdk/lib/agent.d.ts +0 -17
  170. package/node_modules/wukongimjssdk/lib/agent_manager.d.ts +0 -16
  171. package/node_modules/wukongimjssdk/lib/channel_manager.d.ts +0 -45
  172. package/node_modules/wukongimjssdk/lib/chat_manager.d.ts +0 -49
  173. package/node_modules/wukongimjssdk/lib/config.d.ts +0 -20
  174. package/node_modules/wukongimjssdk/lib/connect_manager.d.ts +0 -63
  175. package/node_modules/wukongimjssdk/lib/const.d.ts +0 -13
  176. package/node_modules/wukongimjssdk/lib/conversation_manager.d.ts +0 -30
  177. package/node_modules/wukongimjssdk/lib/decoder.d.ts +0 -15
  178. package/node_modules/wukongimjssdk/lib/encoder.d.ts +0 -14
  179. package/node_modules/wukongimjssdk/lib/event_manager.d.ts +0 -14
  180. package/node_modules/wukongimjssdk/lib/guid.d.ts +0 -16
  181. package/node_modules/wukongimjssdk/lib/index.d.ts +0 -54
  182. package/node_modules/wukongimjssdk/lib/model.d.ts +0 -320
  183. package/node_modules/wukongimjssdk/lib/proto.d.ts +0 -166
  184. package/node_modules/wukongimjssdk/lib/provider.d.ts +0 -29
  185. package/node_modules/wukongimjssdk/lib/receipt_manager.d.ts +0 -17
  186. package/node_modules/wukongimjssdk/lib/reminder_manager.d.ts +0 -14
  187. package/node_modules/wukongimjssdk/lib/sdk.d.ts +0 -5
  188. package/node_modules/wukongimjssdk/lib/security.d.ts +0 -17
  189. package/node_modules/wukongimjssdk/lib/stream_manager.d.ts +0 -15
  190. package/node_modules/wukongimjssdk/lib/task.d.ts +0 -51
  191. package/node_modules/wukongimjssdk/lib/version.d.ts +0 -1
  192. package/node_modules/wukongimjssdk/lib/websocket.d.ts +0 -13
  193. package/node_modules/wukongimjssdk/lib/wukongimjssdk.cjs.js +0 -3896
  194. package/node_modules/wukongimjssdk/lib/wukongimjssdk.esm.js +0 -3806
  195. package/node_modules/wukongimjssdk/lib/wukongimjssdk.umd.js +0 -18043
  196. package/node_modules/wukongimjssdk/package.json +0 -72
@@ -1,5 +1,5 @@
1
1
  {
2
- "id": "dmwork",
2
+ "id": "openclaw-channel-dmwork",
3
3
  "channels": [
4
4
  "dmwork"
5
5
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-channel-dmwork",
3
- "version": "0.2.16",
3
+ "version": "0.2.17",
4
4
  "description": "DMWork channel plugin for OpenClaw via WuKongIM WebSocket",
5
5
  "main": "index.ts",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "typescript": "^5.9.3"
28
28
  },
29
29
  "openclaw": {
30
- "id": "dmwork",
30
+ "id": "openclaw-channel-dmwork",
31
31
  "type": "channel",
32
32
  "extensions": [
33
33
  "index.ts"
package/src/accounts.ts CHANGED
@@ -18,6 +18,7 @@ export type ResolvedDmworkAccount = {
18
18
  pollIntervalMs: number;
19
19
  heartbeatIntervalMs: number;
20
20
  requireMention?: boolean;
21
+ historyLimit?: number; // 群聊历史消息条数限制
21
22
  };
22
23
  };
23
24
 
@@ -73,6 +74,7 @@ export function resolveDmworkAccount(params: {
73
74
  pollIntervalMs,
74
75
  heartbeatIntervalMs,
75
76
  requireMention: accountConfig.requireMention ?? channel.requireMention,
77
+ historyLimit: accountConfig.historyLimit ?? channel.historyLimit ?? 20,
76
78
  },
77
79
  };
78
80
  }
package/src/api-fetch.ts CHANGED
@@ -146,3 +146,49 @@ export async function fetchBotGroups(params: {
146
146
  }
147
147
  return resp.json();
148
148
  }
149
+
150
+ /**
151
+ * 获取频道历史消息(用于注入上下文)
152
+ * @param params.log - Optional logger for consistent logging with OpenClaw log system
153
+ */
154
+ export async function getChannelMessages(params: {
155
+ apiUrl: string;
156
+ botToken: string;
157
+ channelId: string;
158
+ channelType: ChannelType;
159
+ limit?: number;
160
+ signal?: AbortSignal;
161
+ log?: { info?: (...args: any[]) => void; error?: (...args: any[]) => void };
162
+ }): Promise<Array<{ from_uid: string; content: string; timestamp: number }>> {
163
+ try {
164
+ const url = `${params.apiUrl.replace(/\/+$/, "")}/v1/bot/channel/messages`;
165
+ const response = await fetch(url, {
166
+ method: "POST",
167
+ headers: {
168
+ "Content-Type": "application/json",
169
+ Authorization: `Bearer ${params.botToken}`,
170
+ },
171
+ body: JSON.stringify({
172
+ channel_id: params.channelId,
173
+ channel_type: params.channelType,
174
+ limit: params.limit ?? 20,
175
+ }),
176
+ signal: params.signal,
177
+ });
178
+
179
+ if (!response.ok) {
180
+ params.log?.info?.(`dmwork: getChannelMessages failed: ${response.status}`);
181
+ return [];
182
+ }
183
+
184
+ const data = await response.json();
185
+ return (data.messages ?? data ?? []).map((m: any) => ({
186
+ from_uid: m.from_uid ?? m.sender_id ?? "unknown",
187
+ content: m.payload?.content ?? m.content ?? "",
188
+ timestamp: m.timestamp ?? Math.floor(Date.now() / 1000), // API timestamps are in seconds
189
+ }));
190
+ } catch (err) {
191
+ params.log?.error?.(`dmwork: getChannelMessages error: ${err}`);
192
+ return [];
193
+ }
194
+ }
@@ -10,6 +10,7 @@ export interface DmworkAccountConfig {
10
10
  heartbeatIntervalMs?: number;
11
11
  requireMention?: boolean;
12
12
  botUid?: string;
13
+ historyLimit?: number; // 群聊历史消息条数限制(默认20)
13
14
  }
14
15
 
15
16
  export interface DmworkConfig {
@@ -22,6 +23,7 @@ export interface DmworkConfig {
22
23
  heartbeatIntervalMs?: number;
23
24
  requireMention?: boolean;
24
25
  botUid?: string;
26
+ historyLimit?: number; // 群聊历史消息条数限制(默认20)
25
27
  accounts?: Record<string, DmworkAccountConfig | undefined>;
26
28
  }
27
29
 
@@ -38,6 +40,7 @@ export const DmworkConfigJsonSchema = {
38
40
  heartbeatIntervalMs: { type: "number", minimum: 5000 },
39
41
  requireMention: { type: "boolean" },
40
42
  botUid: { type: "string" },
43
+ historyLimit: { type: "number", minimum: 1, maximum: 100 },
41
44
  accounts: {
42
45
  type: "object",
43
46
  additionalProperties: {
@@ -50,6 +53,7 @@ export const DmworkConfigJsonSchema = {
50
53
  wsUrl: { type: "string" },
51
54
  requireMention: { type: "boolean" },
52
55
  botUid: { type: "string" },
56
+ historyLimit: { type: "number", minimum: 1, maximum: 100 },
53
57
  },
54
58
  },
55
59
  },
package/src/inbound.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ChannelLogSink, OpenClawConfig } from "openclaw/plugin-sdk";
2
- import { sendMessage, sendReadReceipt, sendTyping } from "./api-fetch.js";
2
+ import { sendMessage, sendReadReceipt, sendTyping, getChannelMessages } from "./api-fetch.js";
3
3
  import type { ResolvedDmworkAccount } from "./accounts.js";
4
4
  import type { BotMessage } from "./types.js";
5
5
  import { ChannelType, MessageType } from "./types.js";
@@ -113,36 +113,72 @@ export async function handleInboundMessage(params: {
113
113
  body: rawBody,
114
114
  timestamp: message.timestamp ? message.timestamp * 1000 : Date.now(),
115
115
  });
116
- while (entries.length > DEFAULT_GROUP_HISTORY_LIMIT) {
116
+ const historyLimit = account.config.historyLimit ?? DEFAULT_GROUP_HISTORY_LIMIT;
117
+ while (entries.length > historyLimit) {
117
118
  entries.shift();
118
119
  }
119
120
  log?.info?.(
120
- `dmwork: group message not mentioning bot, recorded as history context`,
121
+ `dmwork: [HISTORY] 非@消息已缓存 | from=${message.from_uid} | session=${sessionId} | 当前缓存=${entries.length}条`,
121
122
  );
122
123
  return;
123
124
  }
124
125
 
125
126
  // Bot IS mentioned — prepend history context (manual — avoids SDK format incompatibility)
126
- {
127
- const entries = groupHistories.get(sessionId) ?? [];
128
- if (entries.length > 0) {
129
- historyPrefix = entries
130
- .map((e: any) => `[${e.sender}]: ${e.body}`)
131
- .join("\n") + "\n---\n";
132
- log?.info?.(`dmwork: prepending history context (${historyPrefix.length} chars)`);
127
+ // Sliding window: always include the most recent historyLimit messages
128
+ const historyLimit = account.config.historyLimit ?? DEFAULT_GROUP_HISTORY_LIMIT;
129
+ let entries = groupHistories.get(sessionId) ?? [];
130
+ // Take last N entries (sliding window)
131
+ if (entries.length > historyLimit) {
132
+ entries = entries.slice(-historyLimit);
133
+ groupHistories.set(sessionId, entries); // Persist trimmed entries
134
+ }
135
+ const historyCountBefore = entries.length;
136
+ log?.info?.(`dmwork: [MENTION] 收到@消息 | from=${message.from_uid} | 缓存=${historyCountBefore}条 | historyLimit=${historyLimit} | session=${sessionId}`);
137
+
138
+ // If memory cache is empty, try fetching from API
139
+ if (entries.length === 0 && account.config.botToken) {
140
+ log?.info?.(`dmwork: [MENTION] 内存缓存为空,尝试从API获取历史...`);
141
+ try {
142
+ const fetchLimit = Math.min(historyLimit, 100); // Cap at 100
143
+ const apiMessages = await getChannelMessages({
144
+ apiUrl: account.config.apiUrl,
145
+ botToken: account.config.botToken,
146
+ channelId: message.channel_id!,
147
+ channelType: ChannelType.Group,
148
+ limit: fetchLimit,
149
+ log,
150
+ });
151
+ entries = apiMessages
152
+ .filter((m: any) => m.from_uid !== botUid && m.content && !m.content.includes(`@${botUid}`))
153
+ .slice(-historyLimit)
154
+ .map((m: any) => ({
155
+ sender: m.from_uid,
156
+ body: m.content,
157
+ timestamp: m.timestamp * 1000,
158
+ }));
159
+ groupHistories.set(sessionId, entries); // Persist API-fetched entries
160
+ log?.info?.(`dmwork: [MENTION] 从API获取到 ${entries.length} 条历史消息`);
161
+ } catch (err) {
162
+ log?.error?.(`dmwork: [MENTION] 从API获取历史失败: ${err}`);
133
163
  }
134
164
  }
135
165
 
136
- // Clear history after consuming
137
- if (typeof clearHistoryEntriesIfEnabled === "function") {
138
- clearHistoryEntriesIfEnabled({
139
- historyMap: groupHistories,
140
- historyKey: sessionId,
141
- limit: DEFAULT_GROUP_HISTORY_LIMIT,
142
- });
166
+ // Build history context manually (JSON format)
167
+ if (entries.length > 0) {
168
+ historyPrefix = "【群聊历史记录】以下是你上次回复后群里其他人说的话(sender 是用户ID,body 是消息内容):\n```json\n" +
169
+ JSON.stringify(entries.map((e: any) => ({
170
+ sender: e.sender,
171
+ body: e.body,
172
+ })), null, 2) +
173
+ "\n```\n请根据这些历史上下文来回复当前的@消息。\n\n";
174
+ log?.info?.(`dmwork: [MENTION] 已注入历史上下文 | ${historyPrefix.length} chars | ${entries.length}条消息`);
143
175
  } else {
144
- groupHistories.delete(sessionId);
176
+ log?.info?.(`dmwork: [MENTION] 无历史上下文可注入`);
145
177
  }
178
+
179
+ // Sliding window: keep history, don't clear
180
+ // (entries stay in queue, limited by historyLimit in the caching logic)
181
+ log?.info?.(`dmwork: [MENTION] 历史滑动窗口 | session=${sessionId} | 队列保留`);
146
182
  }
147
183
 
148
184
  const core = getDmworkRuntime();
@@ -200,6 +236,7 @@ export async function handleInboundMessage(params: {
200
236
 
201
237
  const ctxPayload = core.channel.reply.finalizeInboundContext({
202
238
  Body: body,
239
+ BodyForAgent: body, // ← 关键!AI 实际读取的是这个字段!
203
240
  RawBody: rawBody,
204
241
  CommandBody: rawBody,
205
242
  From: `dmwork:${message.from_uid}`,
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) Microsoft Corporation.
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
@@ -1,3 +0,0 @@
1
- This is a stub types definition for @types/bignumber.js (https://github.com/MikeMcl/bignumber.js#readme).
2
-
3
- bignumber.js provides its own type definitions, so you don't need @types/bignumber.js installed!
@@ -1,12 +0,0 @@
1
- {
2
- "name": "@types/bignumber.js",
3
- "version": "5.0.4",
4
- "description": "Stub TypeScript definitions entry for bignumber.js, which provides its own types definitions",
5
- "main": "",
6
- "scripts": {},
7
- "license": "MIT",
8
- "dependencies": {
9
- "bignumber.js": "*"
10
- },
11
- "deprecated": "This is a stub types definition. bignumber.js provides its own type definitions, so you do not need this installed."
12
- }
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) Microsoft Corporation.
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
@@ -1,15 +0,0 @@
1
- # Installation
2
- > `npm install --save @types/crypto-js`
3
-
4
- # Summary
5
- This package contains type definitions for crypto-js (https://github.com/brix/crypto-js).
6
-
7
- # Details
8
- Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/crypto-js.
9
-
10
- ### Additional Details
11
- * Last updated: Mon, 22 Jan 2024 06:37:11 GMT
12
- * Dependencies: none
13
-
14
- # Credits
15
- These definitions were written by [Michael Zabka](https://github.com/misak113), [Max Lysenko](https://github.com/maximlysenko), [Brendan Early](https://github.com/mymindstorm), and [Doma](https://github.com/SevenOutman).
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS.AES;
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS.Blowfish;
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS;
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS.enc.Base64;
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS.enc.Base64url;
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS.enc.Hex;
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS.enc.Latin1;
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS.enc.Utf16;
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS.enc.Utf8;
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS.EvpKDF;
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS.format.Hex;
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS.format.OpenSSL;
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS.HmacMD5;
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS.HmacRIPEMD160;
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS.HmacSHA1;
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS.HmacSHA224;
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS.HmacSHA256;
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS.HmacSHA3;
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS.HmacSHA384;
@@ -1,3 +0,0 @@
1
- import CryptoJS = require("./index");
2
-
3
- export = CryptoJS.HmacSHA512;