feat: make /transfer bidirectional across telegram and tui
This commit is contained in:
+40
-1
@@ -274,7 +274,7 @@ export function createMessageRouter(deps: {
|
||||
tier: effectiveTier,
|
||||
autonomyLevel: deps.config.agents.autonomy_level ?? 'standard',
|
||||
sensitiveMode: deps.config.agents.sensitive_mode,
|
||||
immutableDenylist: deps.config.agents.immutable_denylist.map((rule) => ({
|
||||
immutableDenylist: (deps.config.agents.immutable_denylist ?? []).map((rule) => ({
|
||||
tool: rule.tool,
|
||||
argsPattern: rule.args_pattern,
|
||||
reason: rule.reason,
|
||||
@@ -838,6 +838,45 @@ export function createMessageRouter(deps: {
|
||||
session.deleteConfig('queue.summarize_overflow');
|
||||
return 'Reset session queue overrides.';
|
||||
},
|
||||
|
||||
transferSession: (targetRaw: string) => {
|
||||
const target = targetRaw.trim().toLowerCase();
|
||||
if (!target) {
|
||||
return 'Usage: /transfer <tui|telegram>';
|
||||
}
|
||||
|
||||
let toFrontend: string;
|
||||
let toUserId: string;
|
||||
let destinationLabel: string;
|
||||
|
||||
if (target === 'tui') {
|
||||
toFrontend = 'tui';
|
||||
toUserId = 'local';
|
||||
destinationLabel = 'TUI (local)';
|
||||
} else if (target === 'telegram') {
|
||||
if (msg.channel === 'telegram') {
|
||||
toFrontend = 'telegram';
|
||||
toUserId = msg.senderId;
|
||||
} else {
|
||||
const chatId = deps.config.telegram?.allowed_chat_ids?.[0];
|
||||
if (chatId === undefined) {
|
||||
return 'Telegram not configured';
|
||||
}
|
||||
toFrontend = 'telegram';
|
||||
toUserId = String(chatId);
|
||||
}
|
||||
destinationLabel = `Telegram (${toUserId})`;
|
||||
} else {
|
||||
return `Unknown transfer target: ${target}. Supported targets: tui, telegram`;
|
||||
}
|
||||
|
||||
if (msg.channel === toFrontend && msg.senderId === toUserId) {
|
||||
return `Session is already active on ${destinationLabel}`;
|
||||
}
|
||||
|
||||
deps.sessionManager.transferSession(msg.channel, msg.senderId, toFrontend, toUserId);
|
||||
return `Session transferred to ${destinationLabel}`;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user