char-slop/berry

multipurpose self-modifiable agentic harness

git clone https://git.t4t.associates/char-slop/berry

Charlotte Sominitial commite6df845

main
629 B21 linesraw
1import { availableLanguages, highlight } from "@arborium/arborium";
2
3export interface HighlightRequest {
4  id: number;
5  language: string;
6  source: string;
7}
8
9export type HighlightReply = { id: number; html: string | null } | { id: number; error: string };
10
11const available = new Set<string>(availableLanguages);
12
13onmessage = async ({ data: { id, language, source } }: MessageEvent<HighlightRequest>) => {
14  let reply: HighlightReply;
15  try {
16    reply = { id, html: available.has(language) ? await highlight(language, source) : null };
17  } catch (error) {
18    reply = { id, error: String(error) };
19  }
20  postMessage(reply);
21};