Files
triggershell/src/lib/runner/events.ts
T
valknarandClaude Sonnet 5 c6337ea942 Run prettier across the repo, exclude the lockfile from it
Prettier had never been run in --check mode here before, so this had
drifted across most files (markdown tables, long option() chains,
line wrapping). Purely formatting, no logic changes - needed so a CI
format:check gate can actually pass. Adds .prettierignore for
pnpm-lock.yaml specifically: prettier's YAML formatter rewrites every
quoted key (single -> double quotes) producing an ~8700-line diff of
pure noise on a file pnpm itself owns the formatting of.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-16 13:55:25 +02:00

20 lines
819 B
TypeScript

import { EventEmitter } from "node:events";
import type { ServerMessage } from "../ws/protocol";
declare global {
var __triggershellRunEvents: EventEmitter | undefined;
}
/** Decouples the run engine from the WS transport: the engine emits, ws/server.ts broadcasts.
* Anchored on `globalThis` because Next compiles Route Handlers through its own module graph,
* separate from the modules `server.ts` requires directly via tsx - a plain module-level
* singleton would silently end up duplicated (one copy per graph) instead of shared. */
export const runEvents: EventEmitter =
globalThis.__triggershellRunEvents ?? new EventEmitter();
globalThis.__triggershellRunEvents = runEvents;
runEvents.setMaxListeners(0);
export function emitRunMessage(message: ServerMessage) {
runEvents.emit("message", message);
}