@brightlee7788/test-echo-mode 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.
- package/dist/index.js +42 -0
- package/package.json +31 -0
- package/src/index.ts +59 -0
- package/tsconfig.json +15 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { FIFOQueue } from 'evolclaw/response-modes';
|
|
2
|
+
export const responseModeMeta = {
|
|
3
|
+
id: 'test-echo-mode',
|
|
4
|
+
displayName: 'Test Echo Mode',
|
|
5
|
+
description: '回显模式:直接返回用户发送的消息,不调用 AI',
|
|
6
|
+
applicableScenes: ['private', 'group'],
|
|
7
|
+
};
|
|
8
|
+
export default class TestEchoModeMode {
|
|
9
|
+
id = responseModeMeta.id;
|
|
10
|
+
displayName = responseModeMeta.displayName;
|
|
11
|
+
description = responseModeMeta.description;
|
|
12
|
+
type = 'extension';
|
|
13
|
+
applicableScenes = [...responseModeMeta.applicableScenes];
|
|
14
|
+
queue = new FIFOQueue();
|
|
15
|
+
async initialize(_context) { }
|
|
16
|
+
async cleanup() {
|
|
17
|
+
await this.queue.clear();
|
|
18
|
+
}
|
|
19
|
+
async handleInbound(message) {
|
|
20
|
+
// 使用 customHandler 直接发送 echo,不调用 AI
|
|
21
|
+
return {
|
|
22
|
+
action: 'drop', // drop 表示不进入 AI 处理流程
|
|
23
|
+
customHandler: async (msg, context) => {
|
|
24
|
+
try {
|
|
25
|
+
// 直接发送 echo 消息
|
|
26
|
+
await context.channel.send(`Echo: ${msg.content}`);
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
context.logger.error(`[test-echo-mode] Failed to send echo: ${err}`);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
reason: 'Echo mode - bypass AI',
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
async handleOutbound(_payload) {
|
|
36
|
+
// echo 模式不会走到这里,因为 handleInbound 返回了 drop + customHandler
|
|
37
|
+
return { method: 'direct', type: 'message' };
|
|
38
|
+
}
|
|
39
|
+
getQueue() {
|
|
40
|
+
return this.queue;
|
|
41
|
+
}
|
|
42
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@brightlee7788/test-echo-mode",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc",
|
|
8
|
+
"dev": "tsc --watch"
|
|
9
|
+
},
|
|
10
|
+
"evolclaw": {
|
|
11
|
+
"responseMode": {
|
|
12
|
+
"id": "test-echo-mode",
|
|
13
|
+
"displayName": "Test Echo Mode",
|
|
14
|
+
"description": "自定义响应模式",
|
|
15
|
+
"applicableScenes": [
|
|
16
|
+
"private",
|
|
17
|
+
"group"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"evolclaw": "file:../../../../../dev-lih/evolclaw/evolclaw-3.6.0.tgz",
|
|
23
|
+
"typescript": "^5.6.0"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"evolclaw-response-mode"
|
|
27
|
+
],
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
}
|
|
31
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InboundMessage,
|
|
3
|
+
InboundDecision,
|
|
4
|
+
OutboundPayload,
|
|
5
|
+
OutboundDecision,
|
|
6
|
+
ResponseMode,
|
|
7
|
+
ResponseModeContext,
|
|
8
|
+
MessageQueueInterface,
|
|
9
|
+
} from 'evolclaw/response-modes';
|
|
10
|
+
import { FIFOQueue } from 'evolclaw/response-modes';
|
|
11
|
+
|
|
12
|
+
export const responseModeMeta = {
|
|
13
|
+
id: 'test-echo-mode',
|
|
14
|
+
displayName: 'Test Echo Mode',
|
|
15
|
+
description: '回显模式:直接返回用户发送的消息,不调用 AI',
|
|
16
|
+
applicableScenes: ['private', 'group'] as const,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default class TestEchoModeMode implements ResponseMode {
|
|
20
|
+
readonly id = responseModeMeta.id;
|
|
21
|
+
readonly displayName = responseModeMeta.displayName;
|
|
22
|
+
readonly description = responseModeMeta.description;
|
|
23
|
+
readonly type = 'extension' as const;
|
|
24
|
+
readonly applicableScenes = [...responseModeMeta.applicableScenes];
|
|
25
|
+
|
|
26
|
+
private readonly queue = new FIFOQueue();
|
|
27
|
+
|
|
28
|
+
async initialize(_context: ResponseModeContext): Promise<void> {}
|
|
29
|
+
|
|
30
|
+
async cleanup(): Promise<void> {
|
|
31
|
+
await this.queue.clear();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async handleInbound(message: InboundMessage): Promise<InboundDecision> {
|
|
35
|
+
// 使用 customHandler 直接发送 echo,不调用 AI
|
|
36
|
+
return {
|
|
37
|
+
action: 'drop', // drop 表示不进入 AI 处理流程
|
|
38
|
+
customHandler: async (msg: InboundMessage, context: ResponseModeContext) => {
|
|
39
|
+
try {
|
|
40
|
+
// 直接发送 echo 消息
|
|
41
|
+
await context.channel.send(`Echo: ${msg.content}`);
|
|
42
|
+
} catch (err) {
|
|
43
|
+
context.logger.error(`[test-echo-mode] Failed to send echo: ${err}`);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
reason: 'Echo mode - bypass AI',
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async handleOutbound(_payload: OutboundPayload): Promise<OutboundDecision> {
|
|
51
|
+
// echo 模式不会走到这里,因为 handleInbound 返回了 drop + customHandler
|
|
52
|
+
return { method: 'direct', type: 'message' };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
getQueue(): MessageQueueInterface {
|
|
56
|
+
return this.queue;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"outDir": "dist",
|
|
7
|
+
"rootDir": "src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true
|
|
11
|
+
},
|
|
12
|
+
"include": [
|
|
13
|
+
"src/**/*"
|
|
14
|
+
]
|
|
15
|
+
}
|