Files
Moltbot/src/sessions/transcript-events.ts
2026-01-17 18:53:52 +00:00

24 lines
691 B
TypeScript

type SessionTranscriptUpdate = {
sessionFile: string;
};
type SessionTranscriptListener = (update: SessionTranscriptUpdate) => void;
const SESSION_TRANSCRIPT_LISTENERS = new Set<SessionTranscriptListener>();
export function onSessionTranscriptUpdate(listener: SessionTranscriptListener): () => void {
SESSION_TRANSCRIPT_LISTENERS.add(listener);
return () => {
SESSION_TRANSCRIPT_LISTENERS.delete(listener);
};
}
export function emitSessionTranscriptUpdate(sessionFile: string): void {
const trimmed = sessionFile.trim();
if (!trimmed) return;
const update = { sessionFile: trimmed };
for (const listener of SESSION_TRANSCRIPT_LISTENERS) {
listener(update);
}
}