retell-utils 0.3.3 → 0.4.1

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.
package/dist/agent.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { DataStorageSettingSchema } from "./enums.js";
2
+ import { AgentLanguageSchema, AmbientSoundSchema, DataStorageSettingSchema, DenoisingModeSchema, LlmModelSchema, PiiCategorySchema, PronunciationAlphabetSchema, SttModeSchema, VocabSpecializationSchema, VoiceEmotionSchema, VoicemailActionTypeSchema, VoiceModelSchema, WebhookEventSchema, } from "./enums.js";
3
3
  // ---------------------------------------------------------------------------
4
4
  // Response engine (shared by voice and chat agents)
5
5
  // ---------------------------------------------------------------------------
@@ -30,42 +30,197 @@ export const ResponseEngineSchema = z.discriminatedUnion("type", [
30
30
  ResponseEngineConversationFlowSchema,
31
31
  ]);
32
32
  // ---------------------------------------------------------------------------
33
+ // Shared sub-schemas
34
+ // ---------------------------------------------------------------------------
35
+ /** Pronunciation dictionary entry for guiding TTS. */
36
+ export const PronunciationEntrySchema = z.object({
37
+ word: z.string(),
38
+ alphabet: PronunciationAlphabetSchema,
39
+ phoneme: z.string(),
40
+ });
41
+ /** Post-call/chat analysis field definition (polymorphic on `type`). */
42
+ export const PostAnalysisFieldSchema = z.object({
43
+ type: z.enum(["string", "enum", "boolean", "number"]),
44
+ name: z.string(),
45
+ description: z.string().optional(),
46
+ examples: z.array(z.unknown()).optional(),
47
+ choices: z.array(z.string()).optional(),
48
+ });
49
+ /** PII scrubbing configuration. */
50
+ export const PiiConfigSchema = z.object({
51
+ mode: z.literal("post_call"),
52
+ categories: z.array(PiiCategorySchema),
53
+ });
54
+ /** Guardrail configuration for input/output topic filtering. */
55
+ export const GuardrailConfigSchema = z.object({
56
+ output_topics: z.array(z.string()).optional(),
57
+ input_topics: z.array(z.string()).optional(),
58
+ });
59
+ /** Knowledge base retrieval configuration. */
60
+ export const KbConfigSchema = z.object({
61
+ top_k: z.number().optional(),
62
+ filter_score: z.number().optional(),
63
+ });
64
+ /** MCP server configuration. */
65
+ export const McpConfigSchema = z.object({
66
+ name: z.string(),
67
+ url: z.string(),
68
+ headers: z.record(z.string(), z.string()).optional(),
69
+ query_params: z.record(z.string(), z.string()).optional(),
70
+ timeout_ms: z.number().optional(),
71
+ });
72
+ // ---------------------------------------------------------------------------
33
73
  // Voice agent response
34
74
  // ---------------------------------------------------------------------------
35
- /**
36
- * Zod schema for a voice agent response from the Retell API. Validates
37
- * structural fields (IDs, response engine, version) and passes through all
38
- * other fields for forward compatibility.
39
- */
40
- export const VoiceAgentResponseSchema = z
41
- .object({
75
+ /** Voicemail detection option with action. */
76
+ const VoicemailOptionSchema = z.object({
77
+ action: z.object({
78
+ type: VoicemailActionTypeSchema,
79
+ text: z.string().optional(),
80
+ }),
81
+ });
82
+ /** IVR detection option with action. */
83
+ const IvrOptionSchema = z.object({
84
+ action: z.object({
85
+ type: VoicemailActionTypeSchema,
86
+ }),
87
+ });
88
+ /** Custom STT provider configuration. */
89
+ const CustomSttConfigSchema = z.object({
90
+ provider: z.string().optional(),
91
+ endpointing_ms: z.number().optional(),
92
+ });
93
+ /** DTMF input options for callers. */
94
+ const UserDtmfOptionsSchema = z.object({
95
+ digit_limit: z.number().optional(),
96
+ termination_key: z.string().optional(),
97
+ timeout_ms: z.number().optional(),
98
+ });
99
+ /** Zod schema for a voice agent response from the Retell API. */
100
+ export const VoiceAgentResponseSchema = z.object({
101
+ // Required
42
102
  agent_id: z.string(),
43
- agent_name: z.string().nullable().optional(),
103
+ version: z.number(),
44
104
  response_engine: ResponseEngineSchema,
45
105
  voice_id: z.string(),
46
- version: z.number().optional(),
47
- is_published: z.boolean().optional(),
48
106
  last_modification_timestamp: z.number(),
49
- language: z.string().optional(),
107
+ channel: z.literal("voice").optional(),
108
+ // Identity
109
+ is_published: z.boolean().optional(),
110
+ agent_name: z.string().nullable().optional(),
111
+ version_description: z.string().nullable().optional(),
112
+ version_title: z.string().nullable().optional(),
113
+ // Voice
114
+ voice_model: VoiceModelSchema.nullable().optional(),
115
+ fallback_voice_ids: z.array(z.string()).nullable().optional(),
116
+ voice_temperature: z.number().optional(),
117
+ voice_speed: z.number().optional(),
118
+ enable_dynamic_voice_speed: z.boolean().optional(),
119
+ volume: z.number().optional(),
120
+ voice_emotion: VoiceEmotionSchema.nullable().optional(),
121
+ // Interaction
122
+ responsiveness: z.number().optional(),
123
+ interruption_sensitivity: z.number().optional(),
124
+ enable_backchannel: z.boolean().optional(),
125
+ backchannel_frequency: z.number().optional(),
126
+ backchannel_words: z.array(z.string()).nullable().optional(),
127
+ reminder_trigger_ms: z.number().optional(),
128
+ reminder_max_count: z.number().optional(),
129
+ // Ambience
130
+ ambient_sound: AmbientSoundSchema.nullable().optional(),
131
+ ambient_sound_volume: z.number().optional(),
132
+ // Language & STT
133
+ language: AgentLanguageSchema.optional(),
134
+ stt_mode: SttModeSchema.optional(),
135
+ custom_stt_config: CustomSttConfigSchema.optional(),
136
+ vocab_specialization: VocabSpecializationSchema.optional(),
137
+ normalize_for_speech: z.boolean().optional(),
138
+ boosted_keywords: z.array(z.string()).nullable().optional(),
139
+ pronunciation_dictionary: z
140
+ .array(PronunciationEntrySchema)
141
+ .nullable()
142
+ .optional(),
143
+ // Webhook
144
+ webhook_url: z.string().nullable().optional(),
145
+ webhook_events: z.array(WebhookEventSchema).nullable().optional(),
146
+ webhook_timeout_ms: z.number().optional(),
147
+ // Call limits
148
+ end_call_after_silence_ms: z.number().optional(),
149
+ max_call_duration_ms: z.number().optional(),
150
+ begin_message_delay_ms: z.number().optional(),
151
+ ring_duration_ms: z.number().optional(),
152
+ // Voicemail & IVR
153
+ enable_voicemail_detection: z.boolean().optional(),
154
+ voicemail_message: z.string().optional(),
155
+ voicemail_detection_timeout_ms: z.number().optional(),
156
+ voicemail_option: VoicemailOptionSchema.nullable().optional(),
157
+ ivr_option: IvrOptionSchema.nullable().optional(),
158
+ // DTMF
159
+ allow_user_dtmf: z.boolean().optional(),
160
+ user_dtmf_options: UserDtmfOptionsSchema.optional(),
161
+ // Post-call analysis
162
+ post_call_analysis_data: z
163
+ .array(PostAnalysisFieldSchema)
164
+ .nullable()
165
+ .optional(),
166
+ post_call_analysis_model: LlmModelSchema.nullable().optional(),
167
+ analysis_successful_prompt: z.string().nullable().optional(),
168
+ analysis_summary_prompt: z.string().nullable().optional(),
169
+ // Privacy & storage
50
170
  data_storage_setting: DataStorageSettingSchema.nullable().optional(),
51
- })
52
- .passthrough();
171
+ opt_in_signed_url: z.boolean().optional(),
172
+ signed_url_expiration_ms: z.number().nullable().optional(),
173
+ denoising_mode: DenoisingModeSchema.optional(),
174
+ pii_config: PiiConfigSchema.optional(),
175
+ guardrail_config: GuardrailConfigSchema.optional(),
176
+ // Visibility
177
+ is_public: z.boolean().nullable().optional(),
178
+ });
53
179
  // ---------------------------------------------------------------------------
54
180
  // Chat agent response
55
181
  // ---------------------------------------------------------------------------
56
- /**
57
- * Zod schema for a chat agent response from the Retell API. Same philosophy as
58
- * VoiceAgentResponseSchema: validate structural fields, passthrough the rest.
59
- */
60
- export const ChatAgentResponseSchema = z
61
- .object({
182
+ /** Zod schema for a chat agent response from the Retell API. */
183
+ export const ChatAgentResponseSchema = z.object({
184
+ // Required
62
185
  agent_id: z.string(),
63
- agent_name: z.string().nullable().optional(),
64
186
  response_engine: ResponseEngineSchema,
187
+ last_modification_timestamp: z.number(),
188
+ channel: z.literal("chat").optional(),
189
+ // Identity
65
190
  version: z.number().optional(),
66
191
  is_published: z.boolean().optional(),
67
- last_modification_timestamp: z.number(),
68
- language: z.string().optional(),
192
+ agent_name: z.string().nullable().optional(),
193
+ version_description: z.string().nullable().optional(),
194
+ version_title: z.string().nullable().optional(),
195
+ // Chat behavior
196
+ auto_close_message: z.string().nullable().optional(),
197
+ end_chat_after_silence_ms: z.number().optional(),
198
+ end_call_after_silence_ms: z.number().optional(),
199
+ language: AgentLanguageSchema.optional(),
200
+ // Webhook
201
+ webhook_url: z.string().nullable().optional(),
202
+ webhook_events: z.array(WebhookEventSchema).nullable().optional(),
203
+ webhook_timeout_ms: z.number().optional(),
204
+ // Post-call analysis (also present on chat agents)
205
+ post_call_analysis_data: z
206
+ .array(PostAnalysisFieldSchema)
207
+ .nullable()
208
+ .optional(),
209
+ post_call_analysis_model: LlmModelSchema.nullable().optional(),
210
+ // Post-chat analysis
211
+ post_chat_analysis_data: z
212
+ .array(PostAnalysisFieldSchema)
213
+ .nullable()
214
+ .optional(),
215
+ post_chat_analysis_model: LlmModelSchema.nullable().optional(),
216
+ analysis_successful_prompt: z.string().nullable().optional(),
217
+ analysis_summary_prompt: z.string().nullable().optional(),
218
+ // Privacy & storage
69
219
  data_storage_setting: DataStorageSettingSchema.nullable().optional(),
70
- })
71
- .passthrough();
220
+ opt_in_signed_url: z.boolean().optional(),
221
+ signed_url_expiration_ms: z.number().nullable().optional(),
222
+ pii_config: PiiConfigSchema.optional(),
223
+ guardrail_config: GuardrailConfigSchema.optional(),
224
+ // Visibility
225
+ is_public: z.boolean().nullable().optional(),
226
+ });
package/dist/call.d.ts CHANGED
@@ -59,14 +59,14 @@ export declare function createCallSchemas<TMeta extends z.ZodType, TDynVars exte
59
59
  call_id: z.ZodString;
60
60
  agent_id: z.ZodOptional<z.ZodString>;
61
61
  agent_name: z.ZodOptional<z.ZodString>;
62
- agent_version: z.ZodNumber;
63
- call_status: z.ZodEnum<{
62
+ agent_version: z.ZodOptional<z.ZodNumber>;
63
+ call_status: z.ZodCatch<z.ZodEnum<{
64
64
  registered: "registered";
65
65
  not_connected: "not_connected";
66
66
  ongoing: "ongoing";
67
67
  ended: "ended";
68
68
  error: "error";
69
- }>;
69
+ }>>;
70
70
  metadata: TMeta;
71
71
  retell_llm_dynamic_variables: TDynVars;
72
72
  collected_dynamic_variables: TCollected;
@@ -118,10 +118,10 @@ export declare function createCallSchemas<TMeta extends z.ZodType, TDynVars exte
118
118
  successful: z.ZodOptional<z.ZodBoolean>;
119
119
  }, z.core.$strip>, z.ZodObject<{
120
120
  role: z.ZodLiteral<"node_transition">;
121
- former_node_id: z.ZodString;
122
- former_node_name: z.ZodString;
123
- new_node_id: z.ZodString;
124
- new_node_name: z.ZodString;
121
+ former_node_id: z.ZodOptional<z.ZodString>;
122
+ former_node_name: z.ZodOptional<z.ZodString>;
123
+ new_node_id: z.ZodOptional<z.ZodString>;
124
+ new_node_name: z.ZodOptional<z.ZodString>;
125
125
  time_sec: z.ZodOptional<z.ZodNumber>;
126
126
  global_transition: z.ZodOptional<z.ZodBoolean>;
127
127
  }, z.core.$strip>, z.ZodObject<{
@@ -130,8 +130,8 @@ export declare function createCallSchemas<TMeta extends z.ZodType, TDynVars exte
130
130
  }, z.core.$strip>], "role">>>;
131
131
  }, z.core.$strip>, z.ZodDiscriminatedUnion<[z.ZodObject<{
132
132
  call_type: z.ZodLiteral<"phone_call">;
133
- from_number: z.ZodCatch<z.ZodNullable<z.ZodString>>;
134
- to_number: z.ZodString;
133
+ from_number: z.ZodCatch<z.ZodNullable<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string | undefined, string>>, z.ZodString>>>;
134
+ to_number: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string | undefined, string>>, z.ZodString>;
135
135
  direction: z.ZodEnum<{
136
136
  inbound: "inbound";
137
137
  outbound: "outbound";
@@ -147,14 +147,14 @@ export declare function createCallSchemas<TMeta extends z.ZodType, TDynVars exte
147
147
  call_id: z.ZodString;
148
148
  agent_id: z.ZodOptional<z.ZodString>;
149
149
  agent_name: z.ZodOptional<z.ZodString>;
150
- agent_version: z.ZodNumber;
151
- call_status: z.ZodEnum<{
150
+ agent_version: z.ZodOptional<z.ZodNumber>;
151
+ call_status: z.ZodCatch<z.ZodEnum<{
152
152
  registered: "registered";
153
153
  not_connected: "not_connected";
154
154
  ongoing: "ongoing";
155
155
  ended: "ended";
156
156
  error: "error";
157
- }>;
157
+ }>>;
158
158
  metadata: TMeta;
159
159
  retell_llm_dynamic_variables: TDynVars;
160
160
  collected_dynamic_variables: TCollected;
@@ -206,10 +206,10 @@ export declare function createCallSchemas<TMeta extends z.ZodType, TDynVars exte
206
206
  successful: z.ZodOptional<z.ZodBoolean>;
207
207
  }, z.core.$strip>, z.ZodObject<{
208
208
  role: z.ZodLiteral<"node_transition">;
209
- former_node_id: z.ZodString;
210
- former_node_name: z.ZodString;
211
- new_node_id: z.ZodString;
212
- new_node_name: z.ZodString;
209
+ former_node_id: z.ZodOptional<z.ZodString>;
210
+ former_node_name: z.ZodOptional<z.ZodString>;
211
+ new_node_id: z.ZodOptional<z.ZodString>;
212
+ new_node_name: z.ZodOptional<z.ZodString>;
213
213
  time_sec: z.ZodOptional<z.ZodNumber>;
214
214
  global_transition: z.ZodOptional<z.ZodBoolean>;
215
215
  }, z.core.$strip>, z.ZodObject<{
@@ -218,8 +218,8 @@ export declare function createCallSchemas<TMeta extends z.ZodType, TDynVars exte
218
218
  }, z.core.$strip>], "role">>>;
219
219
  }, z.core.$strip>, z.ZodDiscriminatedUnion<[z.ZodObject<{
220
220
  call_type: z.ZodLiteral<"phone_call">;
221
- from_number: z.ZodCatch<z.ZodNullable<z.ZodString>>;
222
- to_number: z.ZodString;
221
+ from_number: z.ZodCatch<z.ZodNullable<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string | undefined, string>>, z.ZodString>>>;
222
+ to_number: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string | undefined, string>>, z.ZodString>;
223
223
  direction: z.ZodEnum<{
224
224
  inbound: "inbound";
225
225
  outbound: "outbound";
@@ -266,8 +266,8 @@ export declare function createCallSchemas<TMeta extends z.ZodType, TDynVars exte
266
266
  transcript: z.ZodOptional<z.ZodString>;
267
267
  transcript_object: z.ZodOptional<z.ZodArray<z.ZodObject<{
268
268
  role: z.ZodEnum<{
269
- agent: "agent";
270
269
  user: "user";
270
+ agent: "agent";
271
271
  transfer_target: "transfer_target";
272
272
  }>;
273
273
  content: z.ZodString;
@@ -318,10 +318,10 @@ export declare function createCallSchemas<TMeta extends z.ZodType, TDynVars exte
318
318
  successful: z.ZodOptional<z.ZodBoolean>;
319
319
  }, z.core.$strip>, z.ZodObject<{
320
320
  role: z.ZodLiteral<"node_transition">;
321
- former_node_id: z.ZodString;
322
- former_node_name: z.ZodString;
323
- new_node_id: z.ZodString;
324
- new_node_name: z.ZodString;
321
+ former_node_id: z.ZodOptional<z.ZodString>;
322
+ former_node_name: z.ZodOptional<z.ZodString>;
323
+ new_node_id: z.ZodOptional<z.ZodString>;
324
+ new_node_name: z.ZodOptional<z.ZodString>;
325
325
  time_sec: z.ZodOptional<z.ZodNumber>;
326
326
  global_transition: z.ZodOptional<z.ZodBoolean>;
327
327
  }, z.core.$strip>, z.ZodObject<{
@@ -428,14 +428,14 @@ export declare function createCallSchemas<TMeta extends z.ZodType, TDynVars exte
428
428
  call_id: z.ZodString;
429
429
  agent_id: z.ZodOptional<z.ZodString>;
430
430
  agent_name: z.ZodOptional<z.ZodString>;
431
- agent_version: z.ZodNumber;
432
- call_status: z.ZodEnum<{
431
+ agent_version: z.ZodOptional<z.ZodNumber>;
432
+ call_status: z.ZodCatch<z.ZodEnum<{
433
433
  registered: "registered";
434
434
  not_connected: "not_connected";
435
435
  ongoing: "ongoing";
436
436
  ended: "ended";
437
437
  error: "error";
438
- }>;
438
+ }>>;
439
439
  metadata: TMeta;
440
440
  retell_llm_dynamic_variables: TDynVars;
441
441
  collected_dynamic_variables: TCollected;
@@ -487,10 +487,10 @@ export declare function createCallSchemas<TMeta extends z.ZodType, TDynVars exte
487
487
  successful: z.ZodOptional<z.ZodBoolean>;
488
488
  }, z.core.$strip>, z.ZodObject<{
489
489
  role: z.ZodLiteral<"node_transition">;
490
- former_node_id: z.ZodString;
491
- former_node_name: z.ZodString;
492
- new_node_id: z.ZodString;
493
- new_node_name: z.ZodString;
490
+ former_node_id: z.ZodOptional<z.ZodString>;
491
+ former_node_name: z.ZodOptional<z.ZodString>;
492
+ new_node_id: z.ZodOptional<z.ZodString>;
493
+ new_node_name: z.ZodOptional<z.ZodString>;
494
494
  time_sec: z.ZodOptional<z.ZodNumber>;
495
495
  global_transition: z.ZodOptional<z.ZodBoolean>;
496
496
  }, z.core.$strip>, z.ZodObject<{
@@ -499,8 +499,8 @@ export declare function createCallSchemas<TMeta extends z.ZodType, TDynVars exte
499
499
  }, z.core.$strip>], "role">>>;
500
500
  }, z.core.$strip>, z.ZodDiscriminatedUnion<[z.ZodObject<{
501
501
  call_type: z.ZodLiteral<"phone_call">;
502
- from_number: z.ZodCatch<z.ZodNullable<z.ZodString>>;
503
- to_number: z.ZodString;
502
+ from_number: z.ZodCatch<z.ZodNullable<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string | undefined, string>>, z.ZodString>>>;
503
+ to_number: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string | undefined, string>>, z.ZodString>;
504
504
  direction: z.ZodEnum<{
505
505
  inbound: "inbound";
506
506
  outbound: "outbound";
@@ -547,8 +547,8 @@ export declare function createCallSchemas<TMeta extends z.ZodType, TDynVars exte
547
547
  transcript: z.ZodOptional<z.ZodString>;
548
548
  transcript_object: z.ZodOptional<z.ZodArray<z.ZodObject<{
549
549
  role: z.ZodEnum<{
550
- agent: "agent";
551
550
  user: "user";
551
+ agent: "agent";
552
552
  transfer_target: "transfer_target";
553
553
  }>;
554
554
  content: z.ZodString;
@@ -599,10 +599,10 @@ export declare function createCallSchemas<TMeta extends z.ZodType, TDynVars exte
599
599
  successful: z.ZodOptional<z.ZodBoolean>;
600
600
  }, z.core.$strip>, z.ZodObject<{
601
601
  role: z.ZodLiteral<"node_transition">;
602
- former_node_id: z.ZodString;
603
- former_node_name: z.ZodString;
604
- new_node_id: z.ZodString;
605
- new_node_name: z.ZodString;
602
+ former_node_id: z.ZodOptional<z.ZodString>;
603
+ former_node_name: z.ZodOptional<z.ZodString>;
604
+ new_node_id: z.ZodOptional<z.ZodString>;
605
+ new_node_name: z.ZodOptional<z.ZodString>;
606
606
  time_sec: z.ZodOptional<z.ZodNumber>;
607
607
  global_transition: z.ZodOptional<z.ZodBoolean>;
608
608
  }, z.core.$strip>, z.ZodObject<{
@@ -725,14 +725,14 @@ export declare const CallSchemas: {
725
725
  call_id: z.ZodString;
726
726
  agent_id: z.ZodOptional<z.ZodString>;
727
727
  agent_name: z.ZodOptional<z.ZodString>;
728
- agent_version: z.ZodNumber;
729
- call_status: z.ZodEnum<{
728
+ agent_version: z.ZodOptional<z.ZodNumber>;
729
+ call_status: z.ZodCatch<z.ZodEnum<{
730
730
  registered: "registered";
731
731
  not_connected: "not_connected";
732
732
  ongoing: "ongoing";
733
733
  ended: "ended";
734
734
  error: "error";
735
- }>;
735
+ }>>;
736
736
  metadata: z.ZodPrefault<z.ZodObject<{}, z.core.$loose>>;
737
737
  retell_llm_dynamic_variables: z.ZodPrefault<z.ZodObject<{}, z.core.$loose>>;
738
738
  collected_dynamic_variables: z.ZodPrefault<z.ZodObject<{}, z.core.$loose>>;
@@ -784,10 +784,10 @@ export declare const CallSchemas: {
784
784
  successful: z.ZodOptional<z.ZodBoolean>;
785
785
  }, z.core.$strip>, z.ZodObject<{
786
786
  role: z.ZodLiteral<"node_transition">;
787
- former_node_id: z.ZodString;
788
- former_node_name: z.ZodString;
789
- new_node_id: z.ZodString;
790
- new_node_name: z.ZodString;
787
+ former_node_id: z.ZodOptional<z.ZodString>;
788
+ former_node_name: z.ZodOptional<z.ZodString>;
789
+ new_node_id: z.ZodOptional<z.ZodString>;
790
+ new_node_name: z.ZodOptional<z.ZodString>;
791
791
  time_sec: z.ZodOptional<z.ZodNumber>;
792
792
  global_transition: z.ZodOptional<z.ZodBoolean>;
793
793
  }, z.core.$strip>, z.ZodObject<{
@@ -796,8 +796,8 @@ export declare const CallSchemas: {
796
796
  }, z.core.$strip>], "role">>>;
797
797
  }, z.core.$strip>, z.ZodDiscriminatedUnion<[z.ZodObject<{
798
798
  call_type: z.ZodLiteral<"phone_call">;
799
- from_number: z.ZodCatch<z.ZodNullable<z.ZodString>>;
800
- to_number: z.ZodString;
799
+ from_number: z.ZodCatch<z.ZodNullable<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string | undefined, string>>, z.ZodString>>>;
800
+ to_number: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string | undefined, string>>, z.ZodString>;
801
801
  direction: z.ZodEnum<{
802
802
  inbound: "inbound";
803
803
  outbound: "outbound";
@@ -813,14 +813,14 @@ export declare const CallSchemas: {
813
813
  call_id: z.ZodString;
814
814
  agent_id: z.ZodOptional<z.ZodString>;
815
815
  agent_name: z.ZodOptional<z.ZodString>;
816
- agent_version: z.ZodNumber;
817
- call_status: z.ZodEnum<{
816
+ agent_version: z.ZodOptional<z.ZodNumber>;
817
+ call_status: z.ZodCatch<z.ZodEnum<{
818
818
  registered: "registered";
819
819
  not_connected: "not_connected";
820
820
  ongoing: "ongoing";
821
821
  ended: "ended";
822
822
  error: "error";
823
- }>;
823
+ }>>;
824
824
  metadata: z.ZodPrefault<z.ZodObject<{}, z.core.$loose>>;
825
825
  retell_llm_dynamic_variables: z.ZodPrefault<z.ZodObject<{}, z.core.$loose>>;
826
826
  collected_dynamic_variables: z.ZodPrefault<z.ZodObject<{}, z.core.$loose>>;
@@ -872,10 +872,10 @@ export declare const CallSchemas: {
872
872
  successful: z.ZodOptional<z.ZodBoolean>;
873
873
  }, z.core.$strip>, z.ZodObject<{
874
874
  role: z.ZodLiteral<"node_transition">;
875
- former_node_id: z.ZodString;
876
- former_node_name: z.ZodString;
877
- new_node_id: z.ZodString;
878
- new_node_name: z.ZodString;
875
+ former_node_id: z.ZodOptional<z.ZodString>;
876
+ former_node_name: z.ZodOptional<z.ZodString>;
877
+ new_node_id: z.ZodOptional<z.ZodString>;
878
+ new_node_name: z.ZodOptional<z.ZodString>;
879
879
  time_sec: z.ZodOptional<z.ZodNumber>;
880
880
  global_transition: z.ZodOptional<z.ZodBoolean>;
881
881
  }, z.core.$strip>, z.ZodObject<{
@@ -884,8 +884,8 @@ export declare const CallSchemas: {
884
884
  }, z.core.$strip>], "role">>>;
885
885
  }, z.core.$strip>, z.ZodDiscriminatedUnion<[z.ZodObject<{
886
886
  call_type: z.ZodLiteral<"phone_call">;
887
- from_number: z.ZodCatch<z.ZodNullable<z.ZodString>>;
888
- to_number: z.ZodString;
887
+ from_number: z.ZodCatch<z.ZodNullable<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string | undefined, string>>, z.ZodString>>>;
888
+ to_number: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string | undefined, string>>, z.ZodString>;
889
889
  direction: z.ZodEnum<{
890
890
  inbound: "inbound";
891
891
  outbound: "outbound";
@@ -932,8 +932,8 @@ export declare const CallSchemas: {
932
932
  transcript: z.ZodOptional<z.ZodString>;
933
933
  transcript_object: z.ZodOptional<z.ZodArray<z.ZodObject<{
934
934
  role: z.ZodEnum<{
935
- agent: "agent";
936
935
  user: "user";
936
+ agent: "agent";
937
937
  transfer_target: "transfer_target";
938
938
  }>;
939
939
  content: z.ZodString;
@@ -984,10 +984,10 @@ export declare const CallSchemas: {
984
984
  successful: z.ZodOptional<z.ZodBoolean>;
985
985
  }, z.core.$strip>, z.ZodObject<{
986
986
  role: z.ZodLiteral<"node_transition">;
987
- former_node_id: z.ZodString;
988
- former_node_name: z.ZodString;
989
- new_node_id: z.ZodString;
990
- new_node_name: z.ZodString;
987
+ former_node_id: z.ZodOptional<z.ZodString>;
988
+ former_node_name: z.ZodOptional<z.ZodString>;
989
+ new_node_id: z.ZodOptional<z.ZodString>;
990
+ new_node_name: z.ZodOptional<z.ZodString>;
991
991
  time_sec: z.ZodOptional<z.ZodNumber>;
992
992
  global_transition: z.ZodOptional<z.ZodBoolean>;
993
993
  }, z.core.$strip>, z.ZodObject<{
@@ -1094,14 +1094,14 @@ export declare const CallSchemas: {
1094
1094
  call_id: z.ZodString;
1095
1095
  agent_id: z.ZodOptional<z.ZodString>;
1096
1096
  agent_name: z.ZodOptional<z.ZodString>;
1097
- agent_version: z.ZodNumber;
1098
- call_status: z.ZodEnum<{
1097
+ agent_version: z.ZodOptional<z.ZodNumber>;
1098
+ call_status: z.ZodCatch<z.ZodEnum<{
1099
1099
  registered: "registered";
1100
1100
  not_connected: "not_connected";
1101
1101
  ongoing: "ongoing";
1102
1102
  ended: "ended";
1103
1103
  error: "error";
1104
- }>;
1104
+ }>>;
1105
1105
  metadata: z.ZodPrefault<z.ZodObject<{}, z.core.$loose>>;
1106
1106
  retell_llm_dynamic_variables: z.ZodPrefault<z.ZodObject<{}, z.core.$loose>>;
1107
1107
  collected_dynamic_variables: z.ZodPrefault<z.ZodObject<{}, z.core.$loose>>;
@@ -1153,10 +1153,10 @@ export declare const CallSchemas: {
1153
1153
  successful: z.ZodOptional<z.ZodBoolean>;
1154
1154
  }, z.core.$strip>, z.ZodObject<{
1155
1155
  role: z.ZodLiteral<"node_transition">;
1156
- former_node_id: z.ZodString;
1157
- former_node_name: z.ZodString;
1158
- new_node_id: z.ZodString;
1159
- new_node_name: z.ZodString;
1156
+ former_node_id: z.ZodOptional<z.ZodString>;
1157
+ former_node_name: z.ZodOptional<z.ZodString>;
1158
+ new_node_id: z.ZodOptional<z.ZodString>;
1159
+ new_node_name: z.ZodOptional<z.ZodString>;
1160
1160
  time_sec: z.ZodOptional<z.ZodNumber>;
1161
1161
  global_transition: z.ZodOptional<z.ZodBoolean>;
1162
1162
  }, z.core.$strip>, z.ZodObject<{
@@ -1165,8 +1165,8 @@ export declare const CallSchemas: {
1165
1165
  }, z.core.$strip>], "role">>>;
1166
1166
  }, z.core.$strip>, z.ZodDiscriminatedUnion<[z.ZodObject<{
1167
1167
  call_type: z.ZodLiteral<"phone_call">;
1168
- from_number: z.ZodCatch<z.ZodNullable<z.ZodString>>;
1169
- to_number: z.ZodString;
1168
+ from_number: z.ZodCatch<z.ZodNullable<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string | undefined, string>>, z.ZodString>>>;
1169
+ to_number: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string | undefined, string>>, z.ZodString>;
1170
1170
  direction: z.ZodEnum<{
1171
1171
  inbound: "inbound";
1172
1172
  outbound: "outbound";
@@ -1213,8 +1213,8 @@ export declare const CallSchemas: {
1213
1213
  transcript: z.ZodOptional<z.ZodString>;
1214
1214
  transcript_object: z.ZodOptional<z.ZodArray<z.ZodObject<{
1215
1215
  role: z.ZodEnum<{
1216
- agent: "agent";
1217
1216
  user: "user";
1217
+ agent: "agent";
1218
1218
  transfer_target: "transfer_target";
1219
1219
  }>;
1220
1220
  content: z.ZodString;
@@ -1265,10 +1265,10 @@ export declare const CallSchemas: {
1265
1265
  successful: z.ZodOptional<z.ZodBoolean>;
1266
1266
  }, z.core.$strip>, z.ZodObject<{
1267
1267
  role: z.ZodLiteral<"node_transition">;
1268
- former_node_id: z.ZodString;
1269
- former_node_name: z.ZodString;
1270
- new_node_id: z.ZodString;
1271
- new_node_name: z.ZodString;
1268
+ former_node_id: z.ZodOptional<z.ZodString>;
1269
+ former_node_name: z.ZodOptional<z.ZodString>;
1270
+ new_node_id: z.ZodOptional<z.ZodString>;
1271
+ new_node_name: z.ZodOptional<z.ZodString>;
1272
1272
  time_sec: z.ZodOptional<z.ZodNumber>;
1273
1273
  global_transition: z.ZodOptional<z.ZodBoolean>;
1274
1274
  }, z.core.$strip>, z.ZodObject<{
package/dist/call.js CHANGED
@@ -3,7 +3,7 @@ import { createCallAnalysisSchema } from "./analysis.js";
3
3
  import { CallCostSchema, LlmTokenUsageSchema } from "./cost.js";
4
4
  import { CallStatusSchema, DataStorageSettingSchema, DisconnectionReasonSchema, } from "./enums.js";
5
5
  import { CallLatencySchema } from "./latency.js";
6
- import { E164PhoneSchema, e164OrNullSchema } from "./phone.js";
6
+ import { e164PhoneSchema, e164OrNullSchema } from "./phone.js";
7
7
  import { TimestampedUtteranceSchema, TranscriptEntrySchema } from "./transcript.js";
8
8
  /**
9
9
  * Sensible defaults for all configurable fields. Object fields use
@@ -22,7 +22,7 @@ export const callSchemaDefaults = {
22
22
  const PhoneCallSchema = z.object({
23
23
  call_type: z.literal("phone_call"),
24
24
  from_number: e164OrNullSchema,
25
- to_number: E164PhoneSchema,
25
+ to_number: e164PhoneSchema,
26
26
  direction: z.enum(["inbound", "outbound"]),
27
27
  telephony_identifier: z
28
28
  .object({ twilio_call_sid: z.string().optional() })
@@ -68,8 +68,8 @@ export function createCallSchemas(config) {
68
68
  call_id: z.string(),
69
69
  agent_id: z.string().optional(),
70
70
  agent_name: z.string().optional(),
71
- agent_version: z.number(),
72
- call_status: CallStatusSchema,
71
+ agent_version: z.number().optional(),
72
+ call_status: CallStatusSchema.catch("ended"),
73
73
  metadata: config.metadata,
74
74
  retell_llm_dynamic_variables: config.dynamicVariables,
75
75
  collected_dynamic_variables: config.collectedDynamicVariables,
@@ -3,8 +3,8 @@ import { z } from "zod";
3
3
  export declare const ChatMessageSchema: z.ZodObject<{
4
4
  message_id: z.ZodString;
5
5
  role: z.ZodEnum<{
6
- agent: "agent";
7
6
  user: "user";
7
+ agent: "agent";
8
8
  }>;
9
9
  content: z.ZodString;
10
10
  created_timestamp: z.ZodNumber;