fix: MockChannelAdapter handles commands like real channels (#150)
The e2e test for /help failed because MockChannelAdapter was passing commands to the agent instead of handling them locally. Real channels (Telegram, Signal, etc.) intercept /help and return HELP_TEXT directly. Now MockChannelAdapter does the same, making tests consistent. Written by Cameron ◯ Letta Code
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
import type { ChannelAdapter } from '../channels/types.js';
|
||||
import type { InboundMessage, OutboundMessage } from '../core/types.js';
|
||||
import { parseCommand, HELP_TEXT } from '../core/commands.js';
|
||||
|
||||
export class MockChannelAdapter implements ChannelAdapter {
|
||||
readonly id = 'mock' as const;
|
||||
@@ -72,6 +73,18 @@ export class MockChannelAdapter implements ChannelAdapter {
|
||||
|
||||
const chatId = options.chatId || 'test-chat-123';
|
||||
|
||||
// Handle slash commands locally (like real channels do)
|
||||
const command = parseCommand(text);
|
||||
if (command) {
|
||||
if (command === 'help' || command === 'start') {
|
||||
return HELP_TEXT;
|
||||
} else if (this.onCommand) {
|
||||
const result = await this.onCommand(command);
|
||||
return result || '(No response)';
|
||||
}
|
||||
return '(Command not handled)';
|
||||
}
|
||||
|
||||
// Create promise that resolves when bot sends response
|
||||
const responsePromise = new Promise<OutboundMessage>((resolve) => {
|
||||
this.responseResolvers.push(resolve);
|
||||
|
||||
Reference in New Issue
Block a user