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.
- package/openclaw.plugin.json +1 -1
- package/package.json +2 -2
- package/src/accounts.ts +2 -0
- package/src/api-fetch.ts +46 -0
- package/src/config-schema.ts +4 -0
- package/src/inbound.ts +55 -18
- package/node_modules/@types/bignumber.js/LICENSE +0 -21
- package/node_modules/@types/bignumber.js/README.md +0 -3
- package/node_modules/@types/bignumber.js/package.json +0 -12
- package/node_modules/@types/crypto-js/LICENSE +0 -21
- package/node_modules/@types/crypto-js/README.md +0 -15
- package/node_modules/@types/crypto-js/aes.d.ts +0 -3
- package/node_modules/@types/crypto-js/blowfish.d.ts +0 -3
- package/node_modules/@types/crypto-js/core.d.ts +0 -3
- package/node_modules/@types/crypto-js/enc-base64.d.ts +0 -3
- package/node_modules/@types/crypto-js/enc-base64url.d.ts +0 -3
- package/node_modules/@types/crypto-js/enc-hex.d.ts +0 -3
- package/node_modules/@types/crypto-js/enc-latin1.d.ts +0 -3
- package/node_modules/@types/crypto-js/enc-utf16.d.ts +0 -3
- package/node_modules/@types/crypto-js/enc-utf8.d.ts +0 -3
- package/node_modules/@types/crypto-js/evpkdf.d.ts +0 -3
- package/node_modules/@types/crypto-js/format-hex.d.ts +0 -3
- package/node_modules/@types/crypto-js/format-openssl.d.ts +0 -3
- package/node_modules/@types/crypto-js/hmac-md5.d.ts +0 -3
- package/node_modules/@types/crypto-js/hmac-ripemd160.d.ts +0 -3
- package/node_modules/@types/crypto-js/hmac-sha1.d.ts +0 -3
- package/node_modules/@types/crypto-js/hmac-sha224.d.ts +0 -3
- package/node_modules/@types/crypto-js/hmac-sha256.d.ts +0 -3
- package/node_modules/@types/crypto-js/hmac-sha3.d.ts +0 -3
- package/node_modules/@types/crypto-js/hmac-sha384.d.ts +0 -3
- package/node_modules/@types/crypto-js/hmac-sha512.d.ts +0 -3
- package/node_modules/@types/crypto-js/index.d.ts +0 -1757
- package/node_modules/@types/crypto-js/lib-typedarrays.d.ts +0 -3
- package/node_modules/@types/crypto-js/md5.d.ts +0 -3
- package/node_modules/@types/crypto-js/mode-cfb.d.ts +0 -3
- package/node_modules/@types/crypto-js/mode-ctr-gladman.d.ts +0 -3
- package/node_modules/@types/crypto-js/mode-ctr.d.ts +0 -3
- package/node_modules/@types/crypto-js/mode-ecb.d.ts +0 -3
- package/node_modules/@types/crypto-js/mode-ofb.d.ts +0 -3
- package/node_modules/@types/crypto-js/package.json +0 -40
- package/node_modules/@types/crypto-js/pad-ansix923.d.ts +0 -3
- package/node_modules/@types/crypto-js/pad-iso10126.d.ts +0 -3
- package/node_modules/@types/crypto-js/pad-iso97971.d.ts +0 -3
- package/node_modules/@types/crypto-js/pad-nopadding.d.ts +0 -3
- package/node_modules/@types/crypto-js/pad-pkcs7.d.ts +0 -3
- package/node_modules/@types/crypto-js/pad-zeropadding.d.ts +0 -3
- package/node_modules/@types/crypto-js/pbkdf2.d.ts +0 -3
- package/node_modules/@types/crypto-js/rabbit-legacy.d.ts +0 -3
- package/node_modules/@types/crypto-js/rabbit.d.ts +0 -3
- package/node_modules/@types/crypto-js/rc4.d.ts +0 -3
- package/node_modules/@types/crypto-js/ripemd160.d.ts +0 -3
- package/node_modules/@types/crypto-js/sha1.d.ts +0 -3
- package/node_modules/@types/crypto-js/sha224.d.ts +0 -3
- package/node_modules/@types/crypto-js/sha256.d.ts +0 -3
- package/node_modules/@types/crypto-js/sha3.d.ts +0 -3
- package/node_modules/@types/crypto-js/sha384.d.ts +0 -3
- package/node_modules/@types/crypto-js/sha512.d.ts +0 -3
- package/node_modules/@types/crypto-js/tripledes.d.ts +0 -3
- package/node_modules/@types/crypto-js/x64-core.d.ts +0 -3
- package/node_modules/base64-js/LICENSE +0 -21
- package/node_modules/base64-js/README.md +0 -34
- package/node_modules/base64-js/base64js.min.js +0 -1
- package/node_modules/base64-js/index.d.ts +0 -3
- package/node_modules/base64-js/index.js +0 -150
- package/node_modules/base64-js/package.json +0 -47
- package/node_modules/bignumber.js/CHANGELOG.md +0 -381
- package/node_modules/bignumber.js/LICENCE.md +0 -26
- package/node_modules/bignumber.js/README.md +0 -289
- package/node_modules/bignumber.js/bignumber.d.mts +0 -6
- package/node_modules/bignumber.js/bignumber.d.ts +0 -5
- package/node_modules/bignumber.js/bignumber.js +0 -2922
- package/node_modules/bignumber.js/bignumber.mjs +0 -2907
- package/node_modules/bignumber.js/doc/API.html +0 -2249
- package/node_modules/bignumber.js/package.json +0 -60
- package/node_modules/bignumber.js/types.d.ts +0 -1821
- package/node_modules/buffer/AUTHORS.md +0 -73
- package/node_modules/buffer/LICENSE +0 -21
- package/node_modules/buffer/README.md +0 -410
- package/node_modules/buffer/index.d.ts +0 -194
- package/node_modules/buffer/index.js +0 -2106
- package/node_modules/buffer/package.json +0 -93
- package/node_modules/crypto-js/CONTRIBUTING.md +0 -28
- package/node_modules/crypto-js/LICENSE +0 -24
- package/node_modules/crypto-js/README.md +0 -275
- package/node_modules/crypto-js/aes.js +0 -234
- package/node_modules/crypto-js/blowfish.js +0 -471
- package/node_modules/crypto-js/bower.json +0 -39
- package/node_modules/crypto-js/cipher-core.js +0 -895
- package/node_modules/crypto-js/core.js +0 -807
- package/node_modules/crypto-js/crypto-js.js +0 -6657
- package/node_modules/crypto-js/docs/QuickStartGuide.wiki +0 -470
- package/node_modules/crypto-js/enc-base64.js +0 -136
- package/node_modules/crypto-js/enc-base64url.js +0 -148
- package/node_modules/crypto-js/enc-hex.js +0 -18
- package/node_modules/crypto-js/enc-latin1.js +0 -18
- package/node_modules/crypto-js/enc-utf16.js +0 -149
- package/node_modules/crypto-js/enc-utf8.js +0 -18
- package/node_modules/crypto-js/evpkdf.js +0 -134
- package/node_modules/crypto-js/format-hex.js +0 -66
- package/node_modules/crypto-js/format-openssl.js +0 -18
- package/node_modules/crypto-js/hmac-md5.js +0 -18
- package/node_modules/crypto-js/hmac-ripemd160.js +0 -18
- package/node_modules/crypto-js/hmac-sha1.js +0 -18
- package/node_modules/crypto-js/hmac-sha224.js +0 -18
- package/node_modules/crypto-js/hmac-sha256.js +0 -18
- package/node_modules/crypto-js/hmac-sha3.js +0 -18
- package/node_modules/crypto-js/hmac-sha384.js +0 -18
- package/node_modules/crypto-js/hmac-sha512.js +0 -18
- package/node_modules/crypto-js/hmac.js +0 -143
- package/node_modules/crypto-js/index.js +0 -18
- package/node_modules/crypto-js/lib-typedarrays.js +0 -76
- package/node_modules/crypto-js/md5.js +0 -268
- package/node_modules/crypto-js/mode-cfb.js +0 -80
- package/node_modules/crypto-js/mode-ctr-gladman.js +0 -116
- package/node_modules/crypto-js/mode-ctr.js +0 -58
- package/node_modules/crypto-js/mode-ecb.js +0 -40
- package/node_modules/crypto-js/mode-ofb.js +0 -54
- package/node_modules/crypto-js/package.json +0 -42
- package/node_modules/crypto-js/pad-ansix923.js +0 -49
- package/node_modules/crypto-js/pad-iso10126.js +0 -44
- package/node_modules/crypto-js/pad-iso97971.js +0 -40
- package/node_modules/crypto-js/pad-nopadding.js +0 -30
- package/node_modules/crypto-js/pad-pkcs7.js +0 -18
- package/node_modules/crypto-js/pad-zeropadding.js +0 -47
- package/node_modules/crypto-js/pbkdf2.js +0 -145
- package/node_modules/crypto-js/rabbit-legacy.js +0 -190
- package/node_modules/crypto-js/rabbit.js +0 -192
- package/node_modules/crypto-js/rc4.js +0 -139
- package/node_modules/crypto-js/ripemd160.js +0 -267
- package/node_modules/crypto-js/sha1.js +0 -150
- package/node_modules/crypto-js/sha224.js +0 -80
- package/node_modules/crypto-js/sha256.js +0 -199
- package/node_modules/crypto-js/sha3.js +0 -326
- package/node_modules/crypto-js/sha384.js +0 -83
- package/node_modules/crypto-js/sha512.js +0 -326
- package/node_modules/crypto-js/tripledes.js +0 -779
- package/node_modules/crypto-js/x64-core.js +0 -304
- package/node_modules/curve25519-js/.prettierrc +0 -6
- package/node_modules/curve25519-js/LICENSE +0 -19
- package/node_modules/curve25519-js/README.md +0 -111
- package/node_modules/curve25519-js/lib/index.d.ts +0 -69
- package/node_modules/curve25519-js/lib/index.js +0 -1669
- package/node_modules/curve25519-js/package.json +0 -34
- package/node_modules/curve25519-js/tsconfig.json +0 -20
- package/node_modules/curve25519-js/tslint.json +0 -10
- package/node_modules/ieee754/LICENSE +0 -11
- package/node_modules/ieee754/README.md +0 -51
- package/node_modules/ieee754/index.d.ts +0 -10
- package/node_modules/ieee754/index.js +0 -85
- package/node_modules/ieee754/package.json +0 -52
- package/node_modules/md5-typescript/.idea/Md5-typescript.iml +0 -13
- package/node_modules/md5-typescript/.idea/jsLibraryMappings.xml +0 -6
- package/node_modules/md5-typescript/.idea/libraries/tsconfig_roots.xml +0 -13
- package/node_modules/md5-typescript/.idea/modules.xml +0 -8
- package/node_modules/md5-typescript/.idea/vcs.xml +0 -6
- package/node_modules/md5-typescript/.idea/workspace.xml +0 -345
- package/node_modules/md5-typescript/LICENSE +0 -21
- package/node_modules/md5-typescript/README.md +0 -13
- package/node_modules/md5-typescript/dist/bundles/bundle.umd.js +0 -208
- package/node_modules/md5-typescript/dist/bundles/bundle.umd.min.js +0 -1
- package/node_modules/md5-typescript/dist/index.d.ts +0 -43
- package/node_modules/md5-typescript/dist/index.js +0 -198
- package/node_modules/md5-typescript/dist/index.js.map +0 -1
- package/node_modules/md5-typescript/dist/index.metadata.json +0 -1
- package/node_modules/md5-typescript/package.json +0 -31
- package/node_modules/md5-typescript/rollup.config.js +0 -7
- package/node_modules/md5-typescript/tsconfig.json +0 -28
- package/node_modules/wukongimjssdk/README.md +0 -42
- package/node_modules/wukongimjssdk/lib/agent.d.ts +0 -17
- package/node_modules/wukongimjssdk/lib/agent_manager.d.ts +0 -16
- package/node_modules/wukongimjssdk/lib/channel_manager.d.ts +0 -45
- package/node_modules/wukongimjssdk/lib/chat_manager.d.ts +0 -49
- package/node_modules/wukongimjssdk/lib/config.d.ts +0 -20
- package/node_modules/wukongimjssdk/lib/connect_manager.d.ts +0 -63
- package/node_modules/wukongimjssdk/lib/const.d.ts +0 -13
- package/node_modules/wukongimjssdk/lib/conversation_manager.d.ts +0 -30
- package/node_modules/wukongimjssdk/lib/decoder.d.ts +0 -15
- package/node_modules/wukongimjssdk/lib/encoder.d.ts +0 -14
- package/node_modules/wukongimjssdk/lib/event_manager.d.ts +0 -14
- package/node_modules/wukongimjssdk/lib/guid.d.ts +0 -16
- package/node_modules/wukongimjssdk/lib/index.d.ts +0 -54
- package/node_modules/wukongimjssdk/lib/model.d.ts +0 -320
- package/node_modules/wukongimjssdk/lib/proto.d.ts +0 -166
- package/node_modules/wukongimjssdk/lib/provider.d.ts +0 -29
- package/node_modules/wukongimjssdk/lib/receipt_manager.d.ts +0 -17
- package/node_modules/wukongimjssdk/lib/reminder_manager.d.ts +0 -14
- package/node_modules/wukongimjssdk/lib/sdk.d.ts +0 -5
- package/node_modules/wukongimjssdk/lib/security.d.ts +0 -17
- package/node_modules/wukongimjssdk/lib/stream_manager.d.ts +0 -15
- package/node_modules/wukongimjssdk/lib/task.d.ts +0 -51
- package/node_modules/wukongimjssdk/lib/version.d.ts +0 -1
- package/node_modules/wukongimjssdk/lib/websocket.d.ts +0 -13
- package/node_modules/wukongimjssdk/lib/wukongimjssdk.cjs.js +0 -3896
- package/node_modules/wukongimjssdk/lib/wukongimjssdk.esm.js +0 -3806
- package/node_modules/wukongimjssdk/lib/wukongimjssdk.umd.js +0 -18043
- package/node_modules/wukongimjssdk/package.json +0 -72
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openclaw-channel-dmwork",
|
|
3
|
-
"version": "0.2.
|
|
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
|
+
}
|
package/src/config-schema.ts
CHANGED
|
@@ -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
|
-
|
|
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:
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
//
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
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,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).
|