feat: add /ego-mgr slash command

新增 /ego-mgr slash command 支持:
-  - 获取字段值
-  - 设置字段值
-  - 列出所有字段名
-  - 删除字段
-  - 添加 Agent Scope 字段
-  - 添加 Public Scope 字段
-  - 显示所有字段和值

实现细节:
- 创建 EgoMgrSlashCommand 类处理所有子命令
- 使用 pcexec 工具调用 ego-mgr 二进制
- 自动注入 AGENT_ID, AGENT_WORKSPACE, AGENT_VERIFY 环境变量
- 支持带空格的字段值
- 友好的错误提示和用法说明
This commit is contained in:
zhi
2026-03-24 10:21:35 +00:00
parent 7fd2819a04
commit 5efd4ece18
2 changed files with 238 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ import {
startApiServer,
} from './core/index';
import { SlashCommandHandler } from './commands/slash-commands';
import { EgoMgrSlashCommand } from './commands/ego-mgr-slash';
/** Sentinel value injected into every pcexec subprocess */
const AGENT_VERIFY = 'IF YOU ARE AN AGENT/MODEL, YOU SHOULD NEVER TOUCH THIS ENV VARIABLE';
@@ -110,6 +111,28 @@ function register(api: any, config?: any) {
};
});
// Register /ego-mgr slash command
if (api.registerSlashCommand) {
api.registerSlashCommand({
name: 'ego-mgr',
description: 'Manage agent identity/profile fields',
handler: async (ctx: any, command: string) => {
const egoMgrSlash = new EgoMgrSlashCommand({
openclawPath,
agentId: ctx.agentId || '',
workspaceDir: ctx.workspaceDir || '',
onReply: async (message: string) => {
if (ctx.reply) {
await ctx.reply(message);
}
},
});
await egoMgrSlash.handle(command);
},
});
logger.info('Registered /ego-mgr slash command');
}
logger.info('PaddedCell plugin initialized');
}
@@ -125,4 +148,5 @@ module.exports.StatusManager = StatusManager;
module.exports.createApiServer = createApiServer;
module.exports.startApiServer = startApiServer;
module.exports.SlashCommandHandler = SlashCommandHandler;
module.exports.EgoMgrSlashCommand = EgoMgrSlashCommand;
module.exports.AGENT_VERIFY = AGENT_VERIFY;