retell-utils 0.4.5 → 0.5.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/flow.d.ts +2259 -576
- package/dist/flow.js +110 -28
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
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,
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
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,82 @@ 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
|
+
/** Discriminated union of all conversation flow node types. */
|
|
148
|
+
export const FlowNodeSchema = z.discriminatedUnion("type", [
|
|
149
|
+
ConversationNodeSchema,
|
|
150
|
+
EndNodeSchema,
|
|
151
|
+
FunctionNodeSchema,
|
|
152
|
+
TransferCallNodeSchema,
|
|
153
|
+
BranchNodeSchema,
|
|
154
|
+
ComponentNodeSchema,
|
|
155
|
+
PressDigitNodeSchema,
|
|
156
|
+
SmsNodeSchema,
|
|
157
|
+
ExtractDynamicVariablesNodeSchema,
|
|
158
|
+
AgentSwapNodeSchema,
|
|
159
|
+
McpNodeSchema,
|
|
160
|
+
]);
|
|
94
161
|
// ---------------------------------------------------------------------------
|
|
95
162
|
// Flow components
|
|
96
163
|
// ---------------------------------------------------------------------------
|
|
@@ -105,6 +172,21 @@ export const FlowComponentSchema = z.object({
|
|
|
105
172
|
begin_tag_display_position: DisplayPositionSchema.nullable().optional(),
|
|
106
173
|
});
|
|
107
174
|
// ---------------------------------------------------------------------------
|
|
175
|
+
// Shared (account-level) flow component response
|
|
176
|
+
// ---------------------------------------------------------------------------
|
|
177
|
+
/** Zod schema for a shared conversation flow component response from the API. */
|
|
178
|
+
export const ConversationFlowComponentResponseSchema = z.object({
|
|
179
|
+
conversation_flow_component_id: z.string(),
|
|
180
|
+
user_modified_timestamp: z.number(),
|
|
181
|
+
linked_conversation_flow_ids: z.array(z.string()).optional(),
|
|
182
|
+
name: z.string().optional(),
|
|
183
|
+
nodes: z.array(FlowNodeSchema).optional(),
|
|
184
|
+
tools: z.array(LlmToolSchema).nullable().optional(),
|
|
185
|
+
mcps: z.array(McpConfigSchema).nullable().optional(),
|
|
186
|
+
start_node_id: z.string().nullable().optional(),
|
|
187
|
+
begin_tag_display_position: DisplayPositionSchema.nullable().optional(),
|
|
188
|
+
});
|
|
189
|
+
// ---------------------------------------------------------------------------
|
|
108
190
|
// Model choice
|
|
109
191
|
// ---------------------------------------------------------------------------
|
|
110
192
|
/** Model selection configuration for conversation flows. */
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { type ChatSchemaConfig, ChatSchemas, chatSchemaDefaults, createChatSchem
|
|
|
11
11
|
export { WebhookSchemas, createWebhookSchemas } from "./webhook.js";
|
|
12
12
|
export { ChatAgentResponseSchema, GuardrailConfigSchema, KbConfigSchema, McpConfigSchema, PiiConfigSchema, PostAnalysisFieldSchema, PronunciationEntrySchema, ResponseEngineConversationFlowSchema, ResponseEngineCustomLlmSchema, ResponseEngineRetellLlmSchema, ResponseEngineSchema, VoiceAgentResponseSchema, } from "./agent.js";
|
|
13
13
|
export { LlmResponseSchema, LlmStateEdgeSchema, LlmStateSchema, LlmToolSchema, TransferDestinationSchema, TransferOptionSchema, } from "./llm.js";
|
|
14
|
-
export { ConversationFlowResponseSchema, FlowComponentSchema, FlowEdgeSchema, FlowEquationSchema, FlowNodeSchema, FlowTransitionConditionSchema, } from "./flow.js";
|
|
14
|
+
export { ConversationFlowComponentResponseSchema, ConversationFlowResponseSchema, FlowComponentSchema, FlowEdgeSchema, FlowEquationSchema, FlowNodeSchema, FlowTransitionConditionSchema, } from "./flow.js";
|
|
15
15
|
export { InputMatchRuleSchema, TestCaseDefinitionSchema, TestCaseResponseEngineSchema, ToolMockSchema, } from "./test-case.js";
|
|
16
16
|
export { retellPagination } from "./pagination.js";
|
|
17
17
|
export { pluralize, resolveFilePlaceholders, toSnakeCase } from "./utils.js";
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,7 @@ export { ChatAgentResponseSchema, GuardrailConfigSchema, KbConfigSchema, McpConf
|
|
|
25
25
|
// LLM config schemas
|
|
26
26
|
export { LlmResponseSchema, LlmStateEdgeSchema, LlmStateSchema, LlmToolSchema, TransferDestinationSchema, TransferOptionSchema, } from "./llm.js";
|
|
27
27
|
// Conversation flow config schemas
|
|
28
|
-
export { ConversationFlowResponseSchema, FlowComponentSchema, FlowEdgeSchema, FlowEquationSchema, FlowNodeSchema, FlowTransitionConditionSchema, } from "./flow.js";
|
|
28
|
+
export { ConversationFlowComponentResponseSchema, ConversationFlowResponseSchema, FlowComponentSchema, FlowEdgeSchema, FlowEquationSchema, FlowNodeSchema, FlowTransitionConditionSchema, } from "./flow.js";
|
|
29
29
|
// Test case schemas
|
|
30
30
|
export { InputMatchRuleSchema, TestCaseDefinitionSchema, TestCaseResponseEngineSchema, ToolMockSchema, } from "./test-case.js";
|
|
31
31
|
// Pagination utility
|
package/package.json
CHANGED