mioku-plugin-agent 0.2.0 → 0.2.1
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/README.md +2 -0
- package/handlers/message.ts +10 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/handlers/message.ts
CHANGED
|
@@ -5,6 +5,9 @@ import { runAgentTurn } from "../core/loop";
|
|
|
5
5
|
import { genericPlatform } from "../platforms/generic";
|
|
6
6
|
import type { AgentPlatform } from "../platforms/types";
|
|
7
7
|
|
|
8
|
+
/** 私聊里以命令前缀开头的消息交给命令系统,agent 不处理 */
|
|
9
|
+
const COMMAND_PREFIX = /^[./~]/;
|
|
10
|
+
|
|
8
11
|
/** 各平台分支共用的入口:权限/自消息过滤后进入 agent 轮次 */
|
|
9
12
|
export async function handleAgentMessage(
|
|
10
13
|
host: AgentHost,
|
|
@@ -14,6 +17,13 @@ export async function handleAgentMessage(
|
|
|
14
17
|
if (event.message_type === "group") return;
|
|
15
18
|
const identity = identityOf(event);
|
|
16
19
|
if (!identity.userId || identity.userId === identity.botId) return;
|
|
20
|
+
const text = host.ctx.text(event);
|
|
21
|
+
if (COMMAND_PREFIX.test(text)) {
|
|
22
|
+
host.logger.debug(
|
|
23
|
+
`[agent] command ignored | user=${identity.userId} text=${text.slice(0, 60)}`,
|
|
24
|
+
);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
17
27
|
if (!(await host.isAllowed(identity.userId))) return;
|
|
18
28
|
await runAgentTurn(host, event, platform);
|
|
19
29
|
}
|