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 CHANGED
@@ -34,6 +34,8 @@
34
34
 
35
35
  默认仅 bot 主人私聊可用;可在配置中允许管理员或指定用户。
36
36
 
37
+ 私聊中以 `.` / `/` / `~` 开头的消息视为命令,agent 直接忽略不处理
38
+
37
39
  ## 命令
38
40
 
39
41
  | 命令 | 说明 | 权限 |
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mioku-plugin-agent",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "超级用户 Agent 插件",
5
5
  "main": "index.ts",
6
6
  "type": "module",