Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

551 B
Raw Blame
import type { Root } from 'chat';
import { BaseFormatConverter, parseMarkdown, stringifyMarkdown } from 'chat';

/**
 * iMessage ultimately receives plain text through BlueBubbles. Keeping the
 * markdown markers here preserves Chat SDK compatibility; the LobeHub platform
 * client strips markdown before final bot replies are sent.
 */
export class ImessageFormatConverter extends BaseFormatConverter {
  fromAst(ast: Root): string {
    return stringifyMarkdown(ast);
  }

  toAst(text: string): Root {
    return parseMarkdown(text.trim());
  }
}