retell-utils 0.5.0 → 0.5.2

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/flow.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { KbConfigSchema, McpConfigSchema } from "./agent.js";
3
- import { EquationCombinatorSchema, EquationOperatorSchema, FlowInstructionTypeSchema, FlowNodeTypeSchema, FlowTransitionConditionTypeSchema, LlmModelSchema, StartSpeakerSchema, } from "./enums.js";
3
+ import { EquationCombinatorSchema, EquationOperatorSchema, FlowInstructionTypeSchema, FlowTransitionConditionTypeSchema, LlmModelSchema, StartSpeakerSchema, } from "./enums.js";
4
4
  import { LlmToolSchema, TransferDestinationSchema, TransferOptionSchema, } from "./llm.js";
5
5
  // ---------------------------------------------------------------------------
6
6
  // Shared sub-schemas
@@ -51,26 +51,26 @@ const GlobalNodeSettingSchema = z.object({
51
51
  negative_finetune_examples: z.array(FinetuneExampleSchema).optional(),
52
52
  cool_down: z.number().optional(),
53
53
  });
54
- /** Schema for a conversation flow node with all known fields explicit. */
55
- export const FlowNodeSchema = z.object({
56
- // Common
57
- id: z.string().optional(),
58
- name: z.string().optional(),
59
- type: FlowNodeTypeSchema.optional(),
60
- instruction: z
61
- .object({
62
- type: FlowInstructionTypeSchema.optional(),
63
- text: z.string().optional(),
64
- })
65
- .optional(),
66
- display_position: DisplayPositionSchema.nullable().optional(),
67
- // Edges
68
- edges: z.array(FlowEdgeSchema).optional(),
69
- edge: FlowEdgeSchema.optional(),
70
- else_edge: FlowEdgeSchema.optional(),
71
- skip_response_edge: FlowEdgeSchema.optional(),
54
+ // ---------------------------------------------------------------------------
55
+ // Per-type node schemas (discriminated union on `type`)
56
+ // ---------------------------------------------------------------------------
57
+ const InstructionSchema = z.object({
58
+ type: FlowInstructionTypeSchema,
59
+ text: z.string(),
60
+ });
61
+ /** Fields shared by every node type. */
62
+ const baseNodeFields = {
63
+ id: z.string(),
64
+ name: z.string(),
65
+ display_position: DisplayPositionSchema.default({ x: 0, y: 0 }),
66
+ };
67
+ const ConversationNodeSchema = z.object({
68
+ ...baseNodeFields,
69
+ type: z.literal("conversation"),
70
+ instruction: InstructionSchema,
71
+ edges: z.array(FlowEdgeSchema),
72
72
  always_edge: FlowEdgeSchema.optional(),
73
- // Conversation node fields
73
+ skip_response_edge: FlowEdgeSchema.optional(),
74
74
  start_speaker: StartSpeakerSchema.optional(),
75
75
  interruption_sensitivity: z.number().optional(),
76
76
  global_node_setting: GlobalNodeSettingSchema.optional(),
@@ -82,15 +82,92 @@ export const FlowNodeSchema = z.object({
82
82
  .array(FinetuneExampleSchema)
83
83
  .nullable()
84
84
  .optional(),
85
- // Function node fields
86
- tool_id: z.string().optional(),
87
- tool_type: z.string().optional(),
88
- speak_during_execution: z.boolean().optional(),
89
- wait_for_result: z.boolean().optional(),
90
- // Transfer node fields
91
- transfer_destination: TransferDestinationSchema.optional(),
92
- transfer_option: TransferOptionSchema.optional(),
93
85
  });
86
+ const EndNodeSchema = z.object({
87
+ ...baseNodeFields,
88
+ type: z.literal("end"),
89
+ instruction: InstructionSchema.optional(),
90
+ speak_during_execution: z.boolean().default(false),
91
+ });
92
+ const FunctionNodeSchema = z.object({
93
+ ...baseNodeFields,
94
+ type: z.literal("function"),
95
+ instruction: InstructionSchema.optional(),
96
+ tool_id: z.string(),
97
+ tool_type: z.string(),
98
+ speak_during_execution: z.boolean().default(false),
99
+ wait_for_result: z.boolean(),
100
+ edges: z.array(FlowEdgeSchema),
101
+ else_edge: FlowEdgeSchema.optional(),
102
+ global_node_setting: GlobalNodeSettingSchema.optional(),
103
+ });
104
+ const TransferCallNodeSchema = z.object({
105
+ ...baseNodeFields,
106
+ type: z.literal("transfer_call"),
107
+ instruction: InstructionSchema,
108
+ transfer_destination: TransferDestinationSchema,
109
+ transfer_option: TransferOptionSchema,
110
+ speak_during_execution: z.boolean().default(false),
111
+ edge: FlowEdgeSchema,
112
+ });
113
+ const BranchNodeSchema = z.object({
114
+ ...baseNodeFields,
115
+ type: z.literal("branch"),
116
+ edges: z.array(FlowEdgeSchema),
117
+ else_edge: FlowEdgeSchema,
118
+ });
119
+ const ComponentNodeSchema = z.object({
120
+ ...baseNodeFields,
121
+ type: z.literal("component"),
122
+ component_id: z.string(),
123
+ component_type: z.string(),
124
+ edges: z.array(FlowEdgeSchema),
125
+ else_edge: FlowEdgeSchema.optional(),
126
+ });
127
+ const PressDigitNodeSchema = z.looseObject({
128
+ ...baseNodeFields,
129
+ type: z.literal("press_digit"),
130
+ });
131
+ const SmsNodeSchema = z.looseObject({
132
+ ...baseNodeFields,
133
+ type: z.literal("sms"),
134
+ });
135
+ const ExtractDynamicVariablesNodeSchema = z.looseObject({
136
+ ...baseNodeFields,
137
+ type: z.literal("extract_dynamic_variables"),
138
+ });
139
+ const AgentSwapNodeSchema = z.looseObject({
140
+ ...baseNodeFields,
141
+ type: z.literal("agent_swap"),
142
+ });
143
+ const McpNodeSchema = z.looseObject({
144
+ ...baseNodeFields,
145
+ type: z.literal("mcp"),
146
+ });
147
+ const BridgeTransferNodeSchema = z.looseObject({
148
+ ...baseNodeFields,
149
+ type: z.literal("bridge_transfer"),
150
+ });
151
+ const CancelTransferNodeSchema = z.looseObject({
152
+ ...baseNodeFields,
153
+ type: z.literal("cancel_transfer"),
154
+ });
155
+ /** Discriminated union of all conversation flow node types. */
156
+ export const FlowNodeSchema = z.discriminatedUnion("type", [
157
+ ConversationNodeSchema,
158
+ EndNodeSchema,
159
+ FunctionNodeSchema,
160
+ TransferCallNodeSchema,
161
+ BranchNodeSchema,
162
+ ComponentNodeSchema,
163
+ PressDigitNodeSchema,
164
+ SmsNodeSchema,
165
+ ExtractDynamicVariablesNodeSchema,
166
+ AgentSwapNodeSchema,
167
+ McpNodeSchema,
168
+ BridgeTransferNodeSchema,
169
+ CancelTransferNodeSchema,
170
+ ]);
94
171
  // ---------------------------------------------------------------------------
95
172
  // Flow components
96
173
  // ---------------------------------------------------------------------------
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { AgentLanguageSchema, AmbientSoundSchema, CallStatusSchema, ChatStatusSchema, ChatTypeSchema, DataStorageSettingSchema, DenoisingModeSchema, DisconnectionReasonSchema, EquationCombinatorSchema, EquationOperatorSchema, FlowInstructionTypeSchema, FlowNodeTypeSchema, FlowTransitionConditionTypeSchema, LlmModelSchema, LlmToolTypeSchema, ToolHttpMethodSchema, ToolParameterTypeSchema, PiiCategorySchema, PronunciationAlphabetSchema, S2sModelSchema, StartSpeakerSchema, SttModeSchema, UserSentimentSchema, VocabSpecializationSchema, VoiceEmotionSchema, VoicemailActionTypeSchema, VoiceModelSchema, WebhookEventSchema, } from "./enums.js";
1
+ export { AgentLanguageSchema, AmbientSoundSchema, CallStatusSchema, ChatStatusSchema, ChatTypeSchema, DataStorageSettingSchema, DenoisingModeSchema, DisconnectionReasonSchema, EquationCombinatorSchema, EquationOperatorSchema, FlowInstructionTypeSchema, FlowTransitionConditionTypeSchema, LlmModelSchema, LlmToolTypeSchema, ToolHttpMethodSchema, ToolParameterTypeSchema, PiiCategorySchema, PronunciationAlphabetSchema, S2sModelSchema, StartSpeakerSchema, SttModeSchema, UserSentimentSchema, VocabSpecializationSchema, VoiceEmotionSchema, VoicemailActionTypeSchema, VoiceModelSchema, WebhookEventSchema, } from "./enums.js";
2
2
  export { CallLatencySchema, LatencyMetricSchema } from "./latency.js";
3
3
  export { CallCostSchema, ChatCostSchema, LlmTokenUsageSchema, ProductCostSchema, } from "./cost.js";
4
4
  export { DTMFSchema, NodeTransitionSchema, TimestampedUtteranceSchema, ToolCallInvocationSchema, ToolCallResultSchema, TranscriptEntrySchema, UtteranceSchema, WordTimestampSchema, } from "./transcript.js";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Enums
2
- export { AgentLanguageSchema, AmbientSoundSchema, CallStatusSchema, ChatStatusSchema, ChatTypeSchema, DataStorageSettingSchema, DenoisingModeSchema, DisconnectionReasonSchema, EquationCombinatorSchema, EquationOperatorSchema, FlowInstructionTypeSchema, FlowNodeTypeSchema, FlowTransitionConditionTypeSchema, LlmModelSchema, LlmToolTypeSchema, ToolHttpMethodSchema, ToolParameterTypeSchema, PiiCategorySchema, PronunciationAlphabetSchema, S2sModelSchema, StartSpeakerSchema, SttModeSchema, UserSentimentSchema, VocabSpecializationSchema, VoiceEmotionSchema, VoicemailActionTypeSchema, VoiceModelSchema, WebhookEventSchema, } from "./enums.js";
2
+ export { AgentLanguageSchema, AmbientSoundSchema, CallStatusSchema, ChatStatusSchema, ChatTypeSchema, DataStorageSettingSchema, DenoisingModeSchema, DisconnectionReasonSchema, EquationCombinatorSchema, EquationOperatorSchema, FlowInstructionTypeSchema, FlowTransitionConditionTypeSchema, LlmModelSchema, LlmToolTypeSchema, ToolHttpMethodSchema, ToolParameterTypeSchema, PiiCategorySchema, PronunciationAlphabetSchema, S2sModelSchema, StartSpeakerSchema, SttModeSchema, UserSentimentSchema, VocabSpecializationSchema, VoiceEmotionSchema, VoicemailActionTypeSchema, VoiceModelSchema, WebhookEventSchema, } from "./enums.js";
3
3
  // Latency
4
4
  export { CallLatencySchema, LatencyMetricSchema } from "./latency.js";
5
5
  // Cost
package/dist/llm.d.ts CHANGED
@@ -9,10 +9,6 @@ export declare const TransferDestinationSchema: z.ZodObject<{
9
9
  /** Transfer option configuration (warm/cold transfer behavior). */
10
10
  export declare const TransferOptionSchema: z.ZodObject<{
11
11
  type: z.ZodOptional<z.ZodString>;
12
- option: z.ZodOptional<z.ZodObject<{
13
- type: z.ZodOptional<z.ZodString>;
14
- prompt: z.ZodOptional<z.ZodString>;
15
- }, z.core.$strip>>;
16
12
  public_handoff_option: z.ZodOptional<z.ZodObject<{
17
13
  type: z.ZodOptional<z.ZodString>;
18
14
  prompt: z.ZodOptional<z.ZodString>;
@@ -27,6 +23,11 @@ export declare const TransferOptionSchema: z.ZodObject<{
27
23
  agent_detection_timeout_ms: z.ZodOptional<z.ZodNumber>;
28
24
  show_transferee_as_caller: z.ZodOptional<z.ZodBoolean>;
29
25
  enable_bridge_audio_cue: z.ZodOptional<z.ZodBoolean>;
26
+ transfer_ring_duration_ms: z.ZodOptional<z.ZodNumber>;
27
+ cold_transfer_mode: z.ZodOptional<z.ZodEnum<{
28
+ sip_refer: "sip_refer";
29
+ sip_invite: "sip_invite";
30
+ }>>;
30
31
  }, z.core.$strip>;
31
32
  /**
32
33
  * Schema for an LLM tool. Tools are highly polymorphic (end_call,
@@ -35,15 +36,15 @@ export declare const TransferOptionSchema: z.ZodObject<{
35
36
  */
36
37
  export declare const LlmToolSchema: z.ZodObject<{
37
38
  type: z.ZodEnum<{
38
- transfer_call: "transfer_call";
39
- press_digit: "press_digit";
40
- agent_swap: "agent_swap";
41
- mcp: "mcp";
39
+ custom: "custom";
42
40
  end_call: "end_call";
41
+ transfer_call: "transfer_call";
43
42
  check_availability_cal: "check_availability_cal";
44
43
  book_appointment_cal: "book_appointment_cal";
45
- custom: "custom";
44
+ press_digit: "press_digit";
46
45
  extract_dynamic_variable: "extract_dynamic_variable";
46
+ agent_swap: "agent_swap";
47
+ mcp: "mcp";
47
48
  send_sms: "send_sms";
48
49
  }>;
49
50
  name: z.ZodOptional<z.ZodString>;
@@ -78,10 +79,6 @@ export declare const LlmToolSchema: z.ZodObject<{
78
79
  }, z.core.$strip>>;
79
80
  transfer_option: z.ZodOptional<z.ZodObject<{
80
81
  type: z.ZodOptional<z.ZodString>;
81
- option: z.ZodOptional<z.ZodObject<{
82
- type: z.ZodOptional<z.ZodString>;
83
- prompt: z.ZodOptional<z.ZodString>;
84
- }, z.core.$strip>>;
85
82
  public_handoff_option: z.ZodOptional<z.ZodObject<{
86
83
  type: z.ZodOptional<z.ZodString>;
87
84
  prompt: z.ZodOptional<z.ZodString>;
@@ -96,6 +93,11 @@ export declare const LlmToolSchema: z.ZodObject<{
96
93
  agent_detection_timeout_ms: z.ZodOptional<z.ZodNumber>;
97
94
  show_transferee_as_caller: z.ZodOptional<z.ZodBoolean>;
98
95
  enable_bridge_audio_cue: z.ZodOptional<z.ZodBoolean>;
96
+ transfer_ring_duration_ms: z.ZodOptional<z.ZodNumber>;
97
+ cold_transfer_mode: z.ZodOptional<z.ZodEnum<{
98
+ sip_refer: "sip_refer";
99
+ sip_invite: "sip_invite";
100
+ }>>;
99
101
  }, z.core.$strip>>;
100
102
  custom_sip_headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
101
103
  cal_api_key: z.ZodOptional<z.ZodString>;
@@ -119,15 +121,15 @@ export declare const LlmStateSchema: z.ZodObject<{
119
121
  }, z.core.$strip>>>;
120
122
  tools: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
121
123
  type: z.ZodEnum<{
122
- transfer_call: "transfer_call";
123
- press_digit: "press_digit";
124
- agent_swap: "agent_swap";
125
- mcp: "mcp";
124
+ custom: "custom";
126
125
  end_call: "end_call";
126
+ transfer_call: "transfer_call";
127
127
  check_availability_cal: "check_availability_cal";
128
128
  book_appointment_cal: "book_appointment_cal";
129
- custom: "custom";
129
+ press_digit: "press_digit";
130
130
  extract_dynamic_variable: "extract_dynamic_variable";
131
+ agent_swap: "agent_swap";
132
+ mcp: "mcp";
131
133
  send_sms: "send_sms";
132
134
  }>;
133
135
  name: z.ZodOptional<z.ZodString>;
@@ -162,10 +164,6 @@ export declare const LlmStateSchema: z.ZodObject<{
162
164
  }, z.core.$strip>>;
163
165
  transfer_option: z.ZodOptional<z.ZodObject<{
164
166
  type: z.ZodOptional<z.ZodString>;
165
- option: z.ZodOptional<z.ZodObject<{
166
- type: z.ZodOptional<z.ZodString>;
167
- prompt: z.ZodOptional<z.ZodString>;
168
- }, z.core.$strip>>;
169
167
  public_handoff_option: z.ZodOptional<z.ZodObject<{
170
168
  type: z.ZodOptional<z.ZodString>;
171
169
  prompt: z.ZodOptional<z.ZodString>;
@@ -180,6 +178,11 @@ export declare const LlmStateSchema: z.ZodObject<{
180
178
  agent_detection_timeout_ms: z.ZodOptional<z.ZodNumber>;
181
179
  show_transferee_as_caller: z.ZodOptional<z.ZodBoolean>;
182
180
  enable_bridge_audio_cue: z.ZodOptional<z.ZodBoolean>;
181
+ transfer_ring_duration_ms: z.ZodOptional<z.ZodNumber>;
182
+ cold_transfer_mode: z.ZodOptional<z.ZodEnum<{
183
+ sip_refer: "sip_refer";
184
+ sip_invite: "sip_invite";
185
+ }>>;
183
186
  }, z.core.$strip>>;
184
187
  custom_sip_headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
185
188
  cal_api_key: z.ZodOptional<z.ZodString>;
@@ -231,15 +234,15 @@ export declare const LlmResponseSchema: z.ZodObject<{
231
234
  general_prompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
232
235
  general_tools: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
233
236
  type: z.ZodEnum<{
234
- transfer_call: "transfer_call";
235
- press_digit: "press_digit";
236
- agent_swap: "agent_swap";
237
- mcp: "mcp";
237
+ custom: "custom";
238
238
  end_call: "end_call";
239
+ transfer_call: "transfer_call";
239
240
  check_availability_cal: "check_availability_cal";
240
241
  book_appointment_cal: "book_appointment_cal";
241
- custom: "custom";
242
+ press_digit: "press_digit";
242
243
  extract_dynamic_variable: "extract_dynamic_variable";
244
+ agent_swap: "agent_swap";
245
+ mcp: "mcp";
243
246
  send_sms: "send_sms";
244
247
  }>;
245
248
  name: z.ZodOptional<z.ZodString>;
@@ -274,10 +277,6 @@ export declare const LlmResponseSchema: z.ZodObject<{
274
277
  }, z.core.$strip>>;
275
278
  transfer_option: z.ZodOptional<z.ZodObject<{
276
279
  type: z.ZodOptional<z.ZodString>;
277
- option: z.ZodOptional<z.ZodObject<{
278
- type: z.ZodOptional<z.ZodString>;
279
- prompt: z.ZodOptional<z.ZodString>;
280
- }, z.core.$strip>>;
281
280
  public_handoff_option: z.ZodOptional<z.ZodObject<{
282
281
  type: z.ZodOptional<z.ZodString>;
283
282
  prompt: z.ZodOptional<z.ZodString>;
@@ -292,6 +291,11 @@ export declare const LlmResponseSchema: z.ZodObject<{
292
291
  agent_detection_timeout_ms: z.ZodOptional<z.ZodNumber>;
293
292
  show_transferee_as_caller: z.ZodOptional<z.ZodBoolean>;
294
293
  enable_bridge_audio_cue: z.ZodOptional<z.ZodBoolean>;
294
+ transfer_ring_duration_ms: z.ZodOptional<z.ZodNumber>;
295
+ cold_transfer_mode: z.ZodOptional<z.ZodEnum<{
296
+ sip_refer: "sip_refer";
297
+ sip_invite: "sip_invite";
298
+ }>>;
295
299
  }, z.core.$strip>>;
296
300
  custom_sip_headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
297
301
  cal_api_key: z.ZodOptional<z.ZodString>;
@@ -308,15 +312,15 @@ export declare const LlmResponseSchema: z.ZodObject<{
308
312
  }, z.core.$strip>>>;
309
313
  tools: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
310
314
  type: z.ZodEnum<{
311
- transfer_call: "transfer_call";
312
- press_digit: "press_digit";
313
- agent_swap: "agent_swap";
314
- mcp: "mcp";
315
+ custom: "custom";
315
316
  end_call: "end_call";
317
+ transfer_call: "transfer_call";
316
318
  check_availability_cal: "check_availability_cal";
317
319
  book_appointment_cal: "book_appointment_cal";
318
- custom: "custom";
320
+ press_digit: "press_digit";
319
321
  extract_dynamic_variable: "extract_dynamic_variable";
322
+ agent_swap: "agent_swap";
323
+ mcp: "mcp";
320
324
  send_sms: "send_sms";
321
325
  }>;
322
326
  name: z.ZodOptional<z.ZodString>;
@@ -351,10 +355,6 @@ export declare const LlmResponseSchema: z.ZodObject<{
351
355
  }, z.core.$strip>>;
352
356
  transfer_option: z.ZodOptional<z.ZodObject<{
353
357
  type: z.ZodOptional<z.ZodString>;
354
- option: z.ZodOptional<z.ZodObject<{
355
- type: z.ZodOptional<z.ZodString>;
356
- prompt: z.ZodOptional<z.ZodString>;
357
- }, z.core.$strip>>;
358
358
  public_handoff_option: z.ZodOptional<z.ZodObject<{
359
359
  type: z.ZodOptional<z.ZodString>;
360
360
  prompt: z.ZodOptional<z.ZodString>;
@@ -369,6 +369,11 @@ export declare const LlmResponseSchema: z.ZodObject<{
369
369
  agent_detection_timeout_ms: z.ZodOptional<z.ZodNumber>;
370
370
  show_transferee_as_caller: z.ZodOptional<z.ZodBoolean>;
371
371
  enable_bridge_audio_cue: z.ZodOptional<z.ZodBoolean>;
372
+ transfer_ring_duration_ms: z.ZodOptional<z.ZodNumber>;
373
+ cold_transfer_mode: z.ZodOptional<z.ZodEnum<{
374
+ sip_refer: "sip_refer";
375
+ sip_invite: "sip_invite";
376
+ }>>;
372
377
  }, z.core.$strip>>;
373
378
  custom_sip_headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
374
379
  cal_api_key: z.ZodOptional<z.ZodString>;
package/dist/llm.js CHANGED
@@ -19,7 +19,6 @@ export const TransferDestinationSchema = z.object({
19
19
  /** Transfer option configuration (warm/cold transfer behavior). */
20
20
  export const TransferOptionSchema = z.object({
21
21
  type: z.string().optional(),
22
- option: HandoffOptionSchema.optional(),
23
22
  public_handoff_option: HandoffOptionSchema.optional(),
24
23
  private_handoff_option: HandoffOptionSchema.optional(),
25
24
  on_hold_music: z.string().optional(),
@@ -28,6 +27,8 @@ export const TransferOptionSchema = z.object({
28
27
  agent_detection_timeout_ms: z.number().optional(),
29
28
  show_transferee_as_caller: z.boolean().optional(),
30
29
  enable_bridge_audio_cue: z.boolean().optional(),
30
+ transfer_ring_duration_ms: z.number().optional(),
31
+ cold_transfer_mode: z.enum(["sip_refer", "sip_invite"]).optional(),
31
32
  });
32
33
  // ---------------------------------------------------------------------------
33
34
  // Tools & states
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "retell-utils",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Type-safe Zod schemas for Retell AI API resources with lifecycle-aware discriminated unions and generic customization",
5
5
  "type": "module",
6
6
  "zshy": {