@pinecall/protocol 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,386 @@
1
+ import { z } from "zod";
2
+ /** Which model and provider produced a block. livekit's Metadata, nested exactly as it nests it. */
3
+ export declare const MetadataSchema: z.ZodObject<{
4
+ model_name: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
5
+ model_provider: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
6
+ }, z.core.$strict>;
7
+ export type Metadata = z.infer<typeof MetadataSchema>;
8
+ /**
9
+ * One LLM request, measured by the session's llm node. Two arrive for one reply when a tool ran in
10
+ * between; they share the speech_id.
11
+ */
12
+ export declare const LLMMetricsSchema: z.ZodObject<{
13
+ type: z.ZodLiteral<"llm_metrics">;
14
+ label: z.ZodString;
15
+ request_id: z.ZodString;
16
+ timestamp: z.ZodNumber;
17
+ duration: z.ZodNumber;
18
+ ttft: z.ZodNumber;
19
+ cancelled: z.ZodBoolean;
20
+ completion_tokens: z.ZodInt;
21
+ prompt_tokens: z.ZodInt;
22
+ prompt_cached_tokens: z.ZodInt;
23
+ cache_creation_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
24
+ reasoning_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
25
+ total_tokens: z.ZodInt;
26
+ tokens_per_second: z.ZodNumber;
27
+ speech_id: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
28
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodObject<{
29
+ model_name: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
30
+ model_provider: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
31
+ }, z.core.$strict>>>>;
32
+ }, z.core.$strict>;
33
+ export type LLMMetrics = z.infer<typeof LLMMetricsSchema>;
34
+ /**
35
+ * One speech-to-text request, measured by the session's stt node. A streaming STT reports one per
36
+ * connection segment, with duration 0.
37
+ */
38
+ export declare const STTMetricsSchema: z.ZodObject<{
39
+ type: z.ZodLiteral<"stt_metrics">;
40
+ label: z.ZodString;
41
+ request_id: z.ZodString;
42
+ timestamp: z.ZodNumber;
43
+ duration: z.ZodNumber;
44
+ audio_duration: z.ZodNumber;
45
+ input_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
46
+ output_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
47
+ streamed: z.ZodBoolean;
48
+ acquire_time: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
49
+ connection_reused: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
50
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodObject<{
51
+ model_name: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
52
+ model_provider: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
53
+ }, z.core.$strict>>>>;
54
+ }, z.core.$strict>;
55
+ export type STTMetrics = z.infer<typeof STTMetricsSchema>;
56
+ /**
57
+ * One text-to-speech request, measured by the session's tts node. One reply may produce several,
58
+ * one per sentence segment.
59
+ */
60
+ export declare const TTSMetricsSchema: z.ZodObject<{
61
+ type: z.ZodLiteral<"tts_metrics">;
62
+ label: z.ZodString;
63
+ request_id: z.ZodString;
64
+ timestamp: z.ZodNumber;
65
+ ttfb: z.ZodNumber;
66
+ duration: z.ZodNumber;
67
+ audio_duration: z.ZodNumber;
68
+ cancelled: z.ZodBoolean;
69
+ characters_count: z.ZodInt;
70
+ input_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
71
+ output_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
72
+ streamed: z.ZodBoolean;
73
+ acquire_time: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
74
+ connection_reused: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
75
+ segment_id: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
76
+ speech_id: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
77
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodObject<{
78
+ model_name: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
79
+ model_provider: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
80
+ }, z.core.$strict>>>>;
81
+ }, z.core.$strict>;
82
+ export type TTSMetrics = z.infer<typeof TTSMetricsSchema>;
83
+ /**
84
+ * The voice activity detector's health, reported about once a second while it runs. Not a per-turn
85
+ * measure.
86
+ */
87
+ export declare const VADMetricsSchema: z.ZodObject<{
88
+ type: z.ZodLiteral<"vad_metrics">;
89
+ label: z.ZodString;
90
+ timestamp: z.ZodNumber;
91
+ idle_time: z.ZodNumber;
92
+ inference_duration_total: z.ZodNumber;
93
+ inference_count: z.ZodInt;
94
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodObject<{
95
+ model_name: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
96
+ model_provider: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
97
+ }, z.core.$strict>>>>;
98
+ }, z.core.$strict>;
99
+ export type VADMetrics = z.infer<typeof VADMetricsSchema>;
100
+ /** How long the session took to decide that the caller had finished. One per user turn. */
101
+ export declare const EOUMetricsSchema: z.ZodObject<{
102
+ type: z.ZodLiteral<"eou_metrics">;
103
+ timestamp: z.ZodNumber;
104
+ end_of_utterance_delay: z.ZodNumber;
105
+ transcription_delay: z.ZodNumber;
106
+ on_user_turn_completed_delay: z.ZodNumber;
107
+ speech_id: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
108
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodObject<{
109
+ model_name: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
110
+ model_provider: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
111
+ }, z.core.$strict>>>>;
112
+ }, z.core.$strict>;
113
+ export type EOUMetrics = z.infer<typeof EOUMetricsSchema>;
114
+ /**
115
+ * One prediction by the end-of-turn model. It listens to the audio and says whether the caller is
116
+ * done.
117
+ */
118
+ export declare const EOTInferenceMetricsSchema: z.ZodObject<{
119
+ type: z.ZodLiteral<"eot_inference_metrics">;
120
+ timestamp: z.ZodNumber;
121
+ total_duration: z.ZodNumber;
122
+ detection_delay: z.ZodNumber;
123
+ prediction_duration: z.ZodNumber;
124
+ num_requests: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
125
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodObject<{
126
+ model_name: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
127
+ model_provider: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
128
+ }, z.core.$strict>>>>;
129
+ }, z.core.$strict>;
130
+ export type EOTInferenceMetrics = z.infer<typeof EOTInferenceMetricsSchema>;
131
+ /**
132
+ * The interruption detector's latest inference and its running counts. Reported when the detector
133
+ * runs, not per turn.
134
+ */
135
+ export declare const InterruptionMetricsSchema: z.ZodObject<{
136
+ type: z.ZodLiteral<"interruption_metrics">;
137
+ timestamp: z.ZodNumber;
138
+ total_duration: z.ZodNumber;
139
+ prediction_duration: z.ZodNumber;
140
+ detection_delay: z.ZodNumber;
141
+ num_interruptions: z.ZodInt;
142
+ num_backchannels: z.ZodInt;
143
+ num_requests: z.ZodInt;
144
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodObject<{
145
+ model_name: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
146
+ model_provider: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
147
+ }, z.core.$strict>>>>;
148
+ }, z.core.$strict>;
149
+ export type InterruptionMetrics = z.infer<typeof InterruptionMetricsSchema>;
150
+ /** Of a realtime model's cached input, how much was audio, text or image. */
151
+ export declare const RealtimeCachedTokenDetailsSchema: z.ZodObject<{
152
+ audio_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
153
+ text_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
154
+ image_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
155
+ }, z.core.$strict>;
156
+ export type RealtimeCachedTokenDetails = z.infer<typeof RealtimeCachedTokenDetailsSchema>;
157
+ /** What a realtime model read, by kind, with the cached part broken out. */
158
+ export declare const RealtimeInputTokenDetailsSchema: z.ZodObject<{
159
+ audio_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
160
+ text_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
161
+ image_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
162
+ cached_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
163
+ cached_tokens_details: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodObject<{
164
+ audio_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
165
+ text_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
166
+ image_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
167
+ }, z.core.$strict>>>>;
168
+ }, z.core.$strict>;
169
+ export type RealtimeInputTokenDetails = z.infer<typeof RealtimeInputTokenDetailsSchema>;
170
+ /** What a realtime model produced, by kind. */
171
+ export declare const RealtimeOutputTokenDetailsSchema: z.ZodObject<{
172
+ text_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
173
+ audio_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
174
+ image_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
175
+ }, z.core.$strict>;
176
+ export type RealtimeOutputTokenDetails = z.infer<typeof RealtimeOutputTokenDetailsSchema>;
177
+ /**
178
+ * One response from a speech-to-speech model, which replaces STT, LLM and TTS at once. Pinecall's
179
+ * default pipeline never emits it; a realtime provider would.
180
+ */
181
+ export declare const RealtimeModelMetricsSchema: z.ZodObject<{
182
+ type: z.ZodLiteral<"realtime_model_metrics">;
183
+ label: z.ZodOptional<z.ZodNullable<z.ZodString>>;
184
+ request_id: z.ZodString;
185
+ timestamp: z.ZodNumber;
186
+ duration: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
187
+ session_duration: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
188
+ ttft: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
189
+ cancelled: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
190
+ input_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
191
+ output_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
192
+ total_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
193
+ tokens_per_second: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
194
+ input_token_details: z.ZodObject<{
195
+ audio_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
196
+ text_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
197
+ image_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
198
+ cached_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
199
+ cached_tokens_details: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodObject<{
200
+ audio_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
201
+ text_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
202
+ image_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
203
+ }, z.core.$strict>>>>;
204
+ }, z.core.$strict>;
205
+ output_token_details: z.ZodObject<{
206
+ text_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
207
+ audio_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
208
+ image_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
209
+ }, z.core.$strict>;
210
+ acquire_time: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
211
+ connection_reused: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
212
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodObject<{
213
+ model_name: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
214
+ model_provider: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
215
+ }, z.core.$strict>>>>;
216
+ }, z.core.$strict>;
217
+ export type RealtimeModelMetrics = z.infer<typeof RealtimeModelMetricsSchema>;
218
+ /**
219
+ * Timing of a video avatar worker, when one is in the chain. No Pinecall channel has one today;
220
+ * carried because the library measures it.
221
+ */
222
+ export declare const AvatarMetricsSchema: z.ZodObject<{
223
+ type: z.ZodLiteral<"avatar_metrics">;
224
+ timestamp: z.ZodNumber;
225
+ playback_latency: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
226
+ session_started_time: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodNumber>>>;
227
+ avatar_joined_time: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodNumber>>>;
228
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodObject<{
229
+ model_name: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
230
+ model_provider: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
231
+ }, z.core.$strict>>>>;
232
+ }, z.core.$strict>;
233
+ export type AvatarMetrics = z.infer<typeof AvatarMetricsSchema>;
234
+ /** Which model handled one leg of a turn. livekit's MetricsMetadata, as it sits on the ChatMessage. */
235
+ export declare const TurnMetadataSchema: z.ZodObject<{
236
+ model_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
237
+ model_provider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
238
+ }, z.core.$strict>;
239
+ export type TurnMetadata = z.infer<typeof TurnMetadataSchema>;
240
+ /**
241
+ * What the session measured about the caller's turn. livekit stamps it on the user ChatMessage;
242
+ * every field is optional, since a text session has no speech to time.
243
+ */
244
+ export declare const UserTurnMetricsSchema: z.ZodObject<{
245
+ started_speaking_at: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
246
+ stopped_speaking_at: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
247
+ transcription_delay: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
248
+ end_of_turn_delay: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
249
+ on_user_turn_completed_delay: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
250
+ stt_metadata: z.ZodOptional<z.ZodNullable<z.ZodObject<{
251
+ model_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
252
+ model_provider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
253
+ }, z.core.$strict>>>;
254
+ }, z.core.$strict>;
255
+ export type UserTurnMetrics = z.infer<typeof UserTurnMetricsSchema>;
256
+ /**
257
+ * What the session measured about the agent's reply. livekit stamps it on the assistant
258
+ * ChatMessage; every field is optional, since a text session has no audio to time.
259
+ */
260
+ export declare const AgentTurnMetricsSchema: z.ZodObject<{
261
+ started_speaking_at: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
262
+ stopped_speaking_at: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
263
+ llm_node_ttft: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
264
+ llm_node_tps: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
265
+ llm_node_ttfs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
266
+ tts_node_ttfb: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
267
+ playback_latency: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
268
+ e2e_latency: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
269
+ provider_request_ids: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
270
+ llm_metadata: z.ZodOptional<z.ZodNullable<z.ZodObject<{
271
+ model_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
272
+ model_provider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
273
+ }, z.core.$strict>>>;
274
+ tts_metadata: z.ZodOptional<z.ZodNullable<z.ZodObject<{
275
+ model_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
276
+ model_provider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
277
+ }, z.core.$strict>>>;
278
+ }, z.core.$strict>;
279
+ export type AgentTurnMetrics = z.infer<typeof AgentTurnMetricsSchema>;
280
+ /**
281
+ * Everything one LLM consumed over the call. One row per provider and model, as livekit's usage
282
+ * collector sums it.
283
+ */
284
+ export declare const LLMModelUsageSchema: z.ZodObject<{
285
+ type: z.ZodLiteral<"llm_usage">;
286
+ provider: z.ZodString;
287
+ model: z.ZodString;
288
+ input_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
289
+ input_cached_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
290
+ input_cache_creation_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
291
+ input_audio_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
292
+ input_cached_audio_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
293
+ input_text_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
294
+ input_cached_text_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
295
+ input_image_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
296
+ input_cached_image_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
297
+ output_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
298
+ output_audio_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
299
+ output_text_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
300
+ output_reasoning_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
301
+ session_duration: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
302
+ }, z.core.$strict>;
303
+ export type LLMModelUsage = z.infer<typeof LLMModelUsageSchema>;
304
+ /** Everything one TTS consumed over the call. */
305
+ export declare const TTSModelUsageSchema: z.ZodObject<{
306
+ type: z.ZodLiteral<"tts_usage">;
307
+ provider: z.ZodString;
308
+ model: z.ZodString;
309
+ input_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
310
+ output_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
311
+ characters_count: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
312
+ audio_duration: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
313
+ }, z.core.$strict>;
314
+ export type TTSModelUsage = z.infer<typeof TTSModelUsageSchema>;
315
+ /** Everything one STT consumed over the call. */
316
+ export declare const STTModelUsageSchema: z.ZodObject<{
317
+ type: z.ZodLiteral<"stt_usage">;
318
+ provider: z.ZodString;
319
+ model: z.ZodString;
320
+ input_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
321
+ output_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
322
+ audio_duration: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
323
+ }, z.core.$strict>;
324
+ export type STTModelUsage = z.infer<typeof STTModelUsageSchema>;
325
+ /** How often the interruption detector was asked over the call. */
326
+ export declare const InterruptionModelUsageSchema: z.ZodObject<{
327
+ type: z.ZodLiteral<"interruption_usage">;
328
+ provider: z.ZodString;
329
+ model: z.ZodString;
330
+ total_requests: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
331
+ }, z.core.$strict>;
332
+ export type InterruptionModelUsage = z.infer<typeof InterruptionModelUsageSchema>;
333
+ /** How often the end-of-turn model was asked over the call. */
334
+ export declare const EOTModelUsageSchema: z.ZodObject<{
335
+ type: z.ZodLiteral<"eot_usage">;
336
+ provider: z.ZodString;
337
+ model: z.ZodString;
338
+ total_requests: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
339
+ }, z.core.$strict>;
340
+ export type EOTModelUsage = z.infer<typeof EOTModelUsageSchema>;
341
+ /** One usage row, told apart by its type tag. */
342
+ export declare const ModelUsageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
343
+ type: z.ZodLiteral<"llm_usage">;
344
+ provider: z.ZodString;
345
+ model: z.ZodString;
346
+ input_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
347
+ input_cached_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
348
+ input_cache_creation_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
349
+ input_audio_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
350
+ input_cached_audio_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
351
+ input_text_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
352
+ input_cached_text_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
353
+ input_image_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
354
+ input_cached_image_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
355
+ output_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
356
+ output_audio_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
357
+ output_text_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
358
+ output_reasoning_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
359
+ session_duration: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
360
+ }, z.core.$strict>, z.ZodObject<{
361
+ type: z.ZodLiteral<"tts_usage">;
362
+ provider: z.ZodString;
363
+ model: z.ZodString;
364
+ input_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
365
+ output_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
366
+ characters_count: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
367
+ audio_duration: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
368
+ }, z.core.$strict>, z.ZodObject<{
369
+ type: z.ZodLiteral<"stt_usage">;
370
+ provider: z.ZodString;
371
+ model: z.ZodString;
372
+ input_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
373
+ output_tokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
374
+ audio_duration: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
375
+ }, z.core.$strict>, z.ZodObject<{
376
+ type: z.ZodLiteral<"interruption_usage">;
377
+ provider: z.ZodString;
378
+ model: z.ZodString;
379
+ total_requests: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
380
+ }, z.core.$strict>, z.ZodObject<{
381
+ type: z.ZodLiteral<"eot_usage">;
382
+ provider: z.ZodString;
383
+ model: z.ZodString;
384
+ total_requests: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
385
+ }, z.core.$strict>], "type">;
386
+ export type ModelUsage = z.infer<typeof ModelUsageSchema>;
@@ -0,0 +1,268 @@
1
+ // Generated from schema/metrics.json: every livekit-agents 1.8 metric, verbatim. Never edited by hand.
2
+ import { z } from "zod";
3
+ /** Which model and provider produced a block. livekit's Metadata, nested exactly as it nests it. */
4
+ export const MetadataSchema = z.strictObject({
5
+ model_name: z.string().nullable().nullish(),
6
+ model_provider: z.string().nullable().nullish(),
7
+ });
8
+ /**
9
+ * One LLM request, measured by the session's llm node. Two arrive for one reply when a tool ran in
10
+ * between; they share the speech_id.
11
+ */
12
+ export const LLMMetricsSchema = z.strictObject({
13
+ type: z.literal("llm_metrics"),
14
+ label: z.string(),
15
+ request_id: z.string(),
16
+ timestamp: z.number(),
17
+ duration: z.number(),
18
+ ttft: z.number(),
19
+ cancelled: z.boolean(),
20
+ completion_tokens: z.int(),
21
+ prompt_tokens: z.int(),
22
+ prompt_cached_tokens: z.int(),
23
+ cache_creation_tokens: z.int().nullish(),
24
+ reasoning_tokens: z.int().nullish(),
25
+ total_tokens: z.int(),
26
+ tokens_per_second: z.number(),
27
+ speech_id: z.string().nullable().nullish(),
28
+ metadata: MetadataSchema.nullable().nullish(),
29
+ });
30
+ /**
31
+ * One speech-to-text request, measured by the session's stt node. A streaming STT reports one per
32
+ * connection segment, with duration 0.
33
+ */
34
+ export const STTMetricsSchema = z.strictObject({
35
+ type: z.literal("stt_metrics"),
36
+ label: z.string(),
37
+ request_id: z.string(),
38
+ timestamp: z.number(),
39
+ duration: z.number(),
40
+ audio_duration: z.number(),
41
+ input_tokens: z.int().nullish(),
42
+ output_tokens: z.int().nullish(),
43
+ streamed: z.boolean(),
44
+ acquire_time: z.number().nullish(),
45
+ connection_reused: z.boolean().nullish(),
46
+ metadata: MetadataSchema.nullable().nullish(),
47
+ });
48
+ /**
49
+ * One text-to-speech request, measured by the session's tts node. One reply may produce several,
50
+ * one per sentence segment.
51
+ */
52
+ export const TTSMetricsSchema = z.strictObject({
53
+ type: z.literal("tts_metrics"),
54
+ label: z.string(),
55
+ request_id: z.string(),
56
+ timestamp: z.number(),
57
+ ttfb: z.number(),
58
+ duration: z.number(),
59
+ audio_duration: z.number(),
60
+ cancelled: z.boolean(),
61
+ characters_count: z.int(),
62
+ input_tokens: z.int().nullish(),
63
+ output_tokens: z.int().nullish(),
64
+ streamed: z.boolean(),
65
+ acquire_time: z.number().nullish(),
66
+ connection_reused: z.boolean().nullish(),
67
+ segment_id: z.string().nullable().nullish(),
68
+ speech_id: z.string().nullable().nullish(),
69
+ metadata: MetadataSchema.nullable().nullish(),
70
+ });
71
+ /**
72
+ * The voice activity detector's health, reported about once a second while it runs. Not a per-turn
73
+ * measure.
74
+ */
75
+ export const VADMetricsSchema = z.strictObject({
76
+ type: z.literal("vad_metrics"),
77
+ label: z.string(),
78
+ timestamp: z.number(),
79
+ idle_time: z.number(),
80
+ inference_duration_total: z.number(),
81
+ inference_count: z.int(),
82
+ metadata: MetadataSchema.nullable().nullish(),
83
+ });
84
+ /** How long the session took to decide that the caller had finished. One per user turn. */
85
+ export const EOUMetricsSchema = z.strictObject({
86
+ type: z.literal("eou_metrics"),
87
+ timestamp: z.number(),
88
+ end_of_utterance_delay: z.number(),
89
+ transcription_delay: z.number(),
90
+ on_user_turn_completed_delay: z.number(),
91
+ speech_id: z.string().nullable().nullish(),
92
+ metadata: MetadataSchema.nullable().nullish(),
93
+ });
94
+ /**
95
+ * One prediction by the end-of-turn model. It listens to the audio and says whether the caller is
96
+ * done.
97
+ */
98
+ export const EOTInferenceMetricsSchema = z.strictObject({
99
+ type: z.literal("eot_inference_metrics"),
100
+ timestamp: z.number(),
101
+ total_duration: z.number(),
102
+ detection_delay: z.number(),
103
+ prediction_duration: z.number(),
104
+ num_requests: z.int().nullish(),
105
+ metadata: MetadataSchema.nullable().nullish(),
106
+ });
107
+ /**
108
+ * The interruption detector's latest inference and its running counts. Reported when the detector
109
+ * runs, not per turn.
110
+ */
111
+ export const InterruptionMetricsSchema = z.strictObject({
112
+ type: z.literal("interruption_metrics"),
113
+ timestamp: z.number(),
114
+ total_duration: z.number(),
115
+ prediction_duration: z.number(),
116
+ detection_delay: z.number(),
117
+ num_interruptions: z.int(),
118
+ num_backchannels: z.int(),
119
+ num_requests: z.int(),
120
+ metadata: MetadataSchema.nullable().nullish(),
121
+ });
122
+ /** Of a realtime model's cached input, how much was audio, text or image. */
123
+ export const RealtimeCachedTokenDetailsSchema = z.strictObject({
124
+ audio_tokens: z.int().nullish(),
125
+ text_tokens: z.int().nullish(),
126
+ image_tokens: z.int().nullish(),
127
+ });
128
+ /** What a realtime model read, by kind, with the cached part broken out. */
129
+ export const RealtimeInputTokenDetailsSchema = z.strictObject({
130
+ audio_tokens: z.int().nullish(),
131
+ text_tokens: z.int().nullish(),
132
+ image_tokens: z.int().nullish(),
133
+ cached_tokens: z.int().nullish(),
134
+ cached_tokens_details: RealtimeCachedTokenDetailsSchema.nullable().nullish(),
135
+ });
136
+ /** What a realtime model produced, by kind. */
137
+ export const RealtimeOutputTokenDetailsSchema = z.strictObject({
138
+ text_tokens: z.int().nullish(),
139
+ audio_tokens: z.int().nullish(),
140
+ image_tokens: z.int().nullish(),
141
+ });
142
+ /**
143
+ * One response from a speech-to-speech model, which replaces STT, LLM and TTS at once. Pinecall's
144
+ * default pipeline never emits it; a realtime provider would.
145
+ */
146
+ export const RealtimeModelMetricsSchema = z.strictObject({
147
+ type: z.literal("realtime_model_metrics"),
148
+ label: z.string().nullish(),
149
+ request_id: z.string(),
150
+ timestamp: z.number(),
151
+ duration: z.number().nullish(),
152
+ session_duration: z.number().nullish(),
153
+ ttft: z.number().nullish(),
154
+ cancelled: z.boolean().nullish(),
155
+ input_tokens: z.int().nullish(),
156
+ output_tokens: z.int().nullish(),
157
+ total_tokens: z.int().nullish(),
158
+ tokens_per_second: z.number().nullish(),
159
+ input_token_details: RealtimeInputTokenDetailsSchema,
160
+ output_token_details: RealtimeOutputTokenDetailsSchema,
161
+ acquire_time: z.number().nullish(),
162
+ connection_reused: z.boolean().nullish(),
163
+ metadata: MetadataSchema.nullable().nullish(),
164
+ });
165
+ /**
166
+ * Timing of a video avatar worker, when one is in the chain. No Pinecall channel has one today;
167
+ * carried because the library measures it.
168
+ */
169
+ export const AvatarMetricsSchema = z.strictObject({
170
+ type: z.literal("avatar_metrics"),
171
+ timestamp: z.number(),
172
+ playback_latency: z.number().nullish(),
173
+ session_started_time: z.number().nullable().nullish(),
174
+ avatar_joined_time: z.number().nullable().nullish(),
175
+ metadata: MetadataSchema.nullable().nullish(),
176
+ });
177
+ /** Which model handled one leg of a turn. livekit's MetricsMetadata, as it sits on the ChatMessage. */
178
+ export const TurnMetadataSchema = z.strictObject({
179
+ model_name: z.string().nullish(),
180
+ model_provider: z.string().nullish(),
181
+ });
182
+ /**
183
+ * What the session measured about the caller's turn. livekit stamps it on the user ChatMessage;
184
+ * every field is optional, since a text session has no speech to time.
185
+ */
186
+ export const UserTurnMetricsSchema = z.strictObject({
187
+ started_speaking_at: z.number().nullish(),
188
+ stopped_speaking_at: z.number().nullish(),
189
+ transcription_delay: z.number().nullish(),
190
+ end_of_turn_delay: z.number().nullish(),
191
+ on_user_turn_completed_delay: z.number().nullish(),
192
+ stt_metadata: TurnMetadataSchema.nullish(),
193
+ });
194
+ /**
195
+ * What the session measured about the agent's reply. livekit stamps it on the assistant
196
+ * ChatMessage; every field is optional, since a text session has no audio to time.
197
+ */
198
+ export const AgentTurnMetricsSchema = z.strictObject({
199
+ started_speaking_at: z.number().nullish(),
200
+ stopped_speaking_at: z.number().nullish(),
201
+ llm_node_ttft: z.number().nullish(),
202
+ llm_node_tps: z.number().nullish(),
203
+ llm_node_ttfs: z.number().nullish(),
204
+ tts_node_ttfb: z.number().nullish(),
205
+ playback_latency: z.number().nullish(),
206
+ e2e_latency: z.number().nullish(),
207
+ provider_request_ids: z.array(z.string()).nullish(),
208
+ llm_metadata: TurnMetadataSchema.nullish(),
209
+ tts_metadata: TurnMetadataSchema.nullish(),
210
+ });
211
+ /**
212
+ * Everything one LLM consumed over the call. One row per provider and model, as livekit's usage
213
+ * collector sums it.
214
+ */
215
+ export const LLMModelUsageSchema = z.strictObject({
216
+ type: z.literal("llm_usage"),
217
+ provider: z.string(),
218
+ model: z.string(),
219
+ input_tokens: z.int().nullish(),
220
+ input_cached_tokens: z.int().nullish(),
221
+ input_cache_creation_tokens: z.int().nullish(),
222
+ input_audio_tokens: z.int().nullish(),
223
+ input_cached_audio_tokens: z.int().nullish(),
224
+ input_text_tokens: z.int().nullish(),
225
+ input_cached_text_tokens: z.int().nullish(),
226
+ input_image_tokens: z.int().nullish(),
227
+ input_cached_image_tokens: z.int().nullish(),
228
+ output_tokens: z.int().nullish(),
229
+ output_audio_tokens: z.int().nullish(),
230
+ output_text_tokens: z.int().nullish(),
231
+ output_reasoning_tokens: z.int().nullish(),
232
+ session_duration: z.number().nullish(),
233
+ });
234
+ /** Everything one TTS consumed over the call. */
235
+ export const TTSModelUsageSchema = z.strictObject({
236
+ type: z.literal("tts_usage"),
237
+ provider: z.string(),
238
+ model: z.string(),
239
+ input_tokens: z.int().nullish(),
240
+ output_tokens: z.int().nullish(),
241
+ characters_count: z.int().nullish(),
242
+ audio_duration: z.number().nullish(),
243
+ });
244
+ /** Everything one STT consumed over the call. */
245
+ export const STTModelUsageSchema = z.strictObject({
246
+ type: z.literal("stt_usage"),
247
+ provider: z.string(),
248
+ model: z.string(),
249
+ input_tokens: z.int().nullish(),
250
+ output_tokens: z.int().nullish(),
251
+ audio_duration: z.number().nullish(),
252
+ });
253
+ /** How often the interruption detector was asked over the call. */
254
+ export const InterruptionModelUsageSchema = z.strictObject({
255
+ type: z.literal("interruption_usage"),
256
+ provider: z.string(),
257
+ model: z.string(),
258
+ total_requests: z.int().nullish(),
259
+ });
260
+ /** How often the end-of-turn model was asked over the call. */
261
+ export const EOTModelUsageSchema = z.strictObject({
262
+ type: z.literal("eot_usage"),
263
+ provider: z.string(),
264
+ model: z.string(),
265
+ total_requests: z.int().nullish(),
266
+ });
267
+ /** One usage row, told apart by its type tag. */
268
+ export const ModelUsageSchema = z.discriminatedUnion("type", [LLMModelUsageSchema, TTSModelUsageSchema, STTModelUsageSchema, InterruptionModelUsageSchema, EOTModelUsageSchema]);