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:
Cameron
2026-02-04 17:54:28 -08:00
committed by GitHub
parent fe233b2f8f
commit 3d1f536c93

View File

@@ -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);