MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / safeEmitLive

Function safeEmitLive

packages/agent-core/src/loop/events.ts:181–199  ·  view source on GitHub ↗
(emit: LoopLiveEventEmitter | undefined, event: LoopEvent)

Source from the content-addressed store, hash-verified

179}
180
181function safeEmitLive(emit: LoopLiveEventEmitter | undefined, event: LoopEvent): void {
182 if (emit === undefined) return;
183 let maybePromise: unknown;
184 try {
185 maybePromise = (emit as (event: LoopEvent) => unknown)(event);
186 } catch {
187 return;
188 }
189 if (
190 maybePromise !== undefined &&
191 maybePromise !== null &&
192 typeof (maybePromise as { then?: unknown }).then === 'function' &&
193 typeof (maybePromise as { catch?: unknown }).catch === 'function'
194 ) {
195 (maybePromise as Promise<unknown>).catch(() => {
196 // Live listeners are best-effort; their failures must not affect the turn.
197 });
198 }
199}

Callers 2

dispatchEventFunction · 0.85
recordEventFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected