feat: add /ego-mgr slash command

Add /ego-mgr slash command with subcommands:
- get, set, list, delete, add-column, add-public-column, show
- Uses pcexec to call ego-mgr binary with proper env vars

Translate all Chinese text to English in responses.

Note: pcexec tool name and function names remain unchanged.
This commit is contained in:
zhi
2026-03-24 10:21:35 +00:00
parent 7fd2819a04
commit 7346c80c88
5 changed files with 259 additions and 21 deletions

View File

@@ -48,7 +48,7 @@ export class SlashCommandHandler {
async handle(command: string, userId: string): Promise<void> {
// Check authorization
if (!this.authorizedUsers.includes(userId)) {
await this.onReply('❌ 无权执行此命令');
await this.onReply('Unauthorized');
return;
}
@@ -68,10 +68,10 @@ export class SlashCommandHandler {
break;
default:
await this.onReply(
'用法:\n' +
'`/padded-cell-ctrl status` - 查看状态\n' +
'`/padded-cell-ctrl enable pass-mgr|safe-restart` - 启用功能\n' +
'`/padded-cell-ctrl disable pass-mgr|safe-restart` - 禁用功能'
'Usage:\n' +
'`/padded-cell-ctrl status` - Show status\n' +
'`/padded-cell-ctrl enable pass-mgr|safe-restart` - Enable feature\n' +
'`/padded-cell-ctrl disable pass-mgr|safe-restart` - Disable feature'
);
}
}
@@ -81,12 +81,12 @@ export class SlashCommandHandler {
const agents = this.statusManager.getAllAgents();
const lines = [
'**PaddedCell 状态**',
'**PaddedCell Status**',
'',
`🔐 密码管理: ${this.state.passMgrEnabled ? '✅ 启用' : '❌ 禁用'}`,
`🔄 安全重启: ${this.state.safeRestartEnabled ? '✅ 启用' : '❌ 禁用'}`,
`Secret Manager: ${this.state.passMgrEnabled ? 'Enabled' : 'Disabled'}`,
`Safe Restart: ${this.state.safeRestartEnabled ? 'Enabled' : 'Disabled'}`,
'',
'**Agent 状态:**',
'**Agent Status:**',
];
for (const agent of agents) {
@@ -95,14 +95,14 @@ export class SlashCommandHandler {
}
if (agents.length === 0) {
lines.push('(暂无 agent 注册)');
lines.push('(No agents registered)');
}
if (global.restartStatus !== 'idle') {
lines.push('');
lines.push(`⚠️ 重启状态: ${global.restartStatus}`);
lines.push(`Restart Status: ${global.restartStatus}`);
if (global.restartScheduledBy) {
lines.push(` ${global.restartScheduledBy} 发起`);
lines.push(` Initiated by ${global.restartScheduledBy}`);
}
}
@@ -111,12 +111,12 @@ export class SlashCommandHandler {
private async handleEnable(feature: 'pass-mgr' | 'safe-restart'): Promise<void> {
if (!this.isValidFeature(feature)) {
await this.onReply('❌ 未知功能。可用选项: pass-mgr, safe-restart');
await this.onReply('Unknown feature. Available: pass-mgr, safe-restart');
return;
}
if (this.isOnCooldown(feature)) {
await this.onReply('⏳ 该功能最近刚被修改过,请稍后再试');
await this.onReply('This feature was recently modified. Please try again later.');
return;
}
@@ -127,17 +127,17 @@ export class SlashCommandHandler {
}
this.state.lastToggle[feature] = Date.now();
await this.onReply(`✅ 已启用 ${feature}`);
await this.onReply(`Enabled ${feature}`);
}
private async handleDisable(feature: 'pass-mgr' | 'safe-restart'): Promise<void> {
if (!this.isValidFeature(feature)) {
await this.onReply('❌ 未知功能。可用选项: pass-mgr, safe-restart');
await this.onReply('Unknown feature. Available: pass-mgr, safe-restart');
return;
}
if (this.isOnCooldown(feature)) {
await this.onReply('⏳ 该功能最近刚被修改过,请稍后再试');
await this.onReply('This feature was recently modified. Please try again later.');
return;
}
@@ -148,7 +148,7 @@ export class SlashCommandHandler {
}
this.state.lastToggle[feature] = Date.now();
await this.onReply(`✅ 已禁用 ${feature}`);
await this.onReply(`Disabled ${feature}`);
}
private isValidFeature(feature: string): feature is 'pass-mgr' | 'safe-restart' {