forked from openclaw/openclaw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiagnostics.ts
More file actions
30 lines (27 loc) · 1.06 KB
/
Copy pathdiagnostics.ts
File metadata and controls
30 lines (27 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import {
emitTrustedDiagnosticEvent,
type DiagnosticEventInput,
} from "../infra/diagnostic-events.js";
import { firstFiniteTalkEventNumber, talkEventPayloadRecord } from "./event-metrics.js";
import type { TalkEvent } from "./talk-events.js";
type TalkDiagnosticEventInput = Extract<DiagnosticEventInput, { type: "talk.event" }>;
export function createTalkDiagnosticEvent(event: TalkEvent): TalkDiagnosticEventInput {
const payload = talkEventPayloadRecord(event.payload);
return {
type: "talk.event",
sessionId: event.sessionId,
turnId: event.turnId,
captureId: event.captureId,
talkEventType: event.type,
mode: event.mode,
transport: event.transport,
brain: event.brain,
provider: event.provider,
final: event.final,
durationMs: firstFiniteTalkEventNumber(payload, ["durationMs", "latencyMs", "elapsedMs"]),
byteLength: firstFiniteTalkEventNumber(payload, ["byteLength", "audioBytes"]),
};
}
export function recordTalkDiagnosticEvent(event: TalkEvent): void {
emitTrustedDiagnosticEvent(createTalkDiagnosticEvent(event));
}