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

Function traceWsIn

apps/kimi-web/src/debug/trace.ts:268–296  ·  view source on GitHub ↗
(frame: unknown)

Source from the content-addressed store, hash-verified

266
267/** Inbound server frame — control frames and event frames alike. */
268export function traceWsIn(frame: unknown): void {
269 if (!isTraceEnabled()) return;
270 const f = (frame ?? {}) as Record<string, unknown>;
271 const type = typeof f['type'] === 'string' ? (f['type'] as string) : '(unknown)';
272 const sessionId =
273 typeof f['session_id'] === 'string'
274 ? (f['session_id'] as string)
275 : typeof (f['payload'] as Record<string, unknown> | undefined)?.['session_id'] === 'string'
276 ? ((f['payload'] as Record<string, unknown>)['session_id'] as string)
277 : undefined;
278 const seq = typeof f['seq'] === 'number' ? (f['seq'] as number) : undefined;
279 const offset = typeof f['offset'] === 'number' ? (f['offset'] as number) : undefined;
280 const bits = [
281 sessionId,
282 seq !== undefined ? `seq=${seq}` : undefined,
283 offset !== undefined ? `offset=${offset}` : undefined,
284 f['volatile'] === true ? 'volatile' : undefined,
285 ].filter(Boolean);
286 push({
287 source: 'ws',
288 kind: 'ws:in',
289 eventType: type,
290 sessionId,
291 seq,
292 offset,
293 label: `← ${type}${bits.length > 0 ? ` (${bits.join(' ')})` : ''}`,
294 detail: detailOf(f['payload']),
295 });
296}
297
298// ---------------------------------------------------------------------------
299// Client-side log capture — so the exported troubleshooting log includes the

Callers 1

connectMethod · 0.90

Calls 3

isTraceEnabledFunction · 0.85
detailOfFunction · 0.85
pushFunction · 0.70

Tested by

no test coverage detected