retell-utils 0.5.0 → 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 +2213 -873
- package/dist/flow.js +95 -28
- 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
|
// ---------------------------------------------------------------------------
|
package/package.json
CHANGED