@onereach/step-voice 7.0.48-VOIC1810.0 → 7.0.48
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/dst/Voice Agent.d.ts +1 -1
- package/dst/Voice Agent.js +42 -54
- package/package.json +1 -1
package/dst/Voice Agent.d.ts
CHANGED
|
@@ -111,7 +111,7 @@ export default class VoiceAgent extends VoiceStep<Partial<INPUT>> {
|
|
|
111
111
|
private validateToolFeedback;
|
|
112
112
|
private isStepFlagEnabled;
|
|
113
113
|
private isRealtimePipeline;
|
|
114
|
-
private
|
|
114
|
+
private buildGreetingAndCallBehavior;
|
|
115
115
|
private isValidAgentUrl;
|
|
116
116
|
private buildAgentServiceConfig;
|
|
117
117
|
private validatePerToolFeedback;
|
package/dst/Voice Agent.js
CHANGED
|
@@ -79,45 +79,22 @@ class VoiceAgent extends voice_1.default {
|
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
81
|
this.triggers.otherwise(async () => {
|
|
82
|
-
const { handlers = [], subagents = [], system_instruction = '', developer_messages = [],
|
|
82
|
+
const { handlers = [], subagents = [], system_instruction = '', developer_messages = [], custom_config_enabled = false, agent_url_overwritten = false, system_tools, knowledge = [], agent_url = '', mode = '', stt = {}, llm = {}, tts = {}, realtime = {} } = this.data;
|
|
83
83
|
if (lodash_1.default.isEmpty(system_instruction)) {
|
|
84
84
|
this.throwError(new Error('Voice Agent: system instruction is required'));
|
|
85
85
|
}
|
|
86
|
-
const
|
|
86
|
+
const realtimePipeline = this.isRealtimePipeline();
|
|
87
|
+
const tools = handlers.map(handler => this.serializeTool(realtimePipeline ? lodash_1.default.omit(handler, 'feedback') : handler));
|
|
87
88
|
const config = {
|
|
88
89
|
system_instruction,
|
|
89
90
|
developer_messages,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
tools
|
|
91
|
+
tools,
|
|
92
|
+
...(realtimePipeline ? {} : this.buildGreetingAndCallBehavior())
|
|
93
93
|
};
|
|
94
94
|
const serializedSubagents = this.serializeSubagents(subagents) || [];
|
|
95
95
|
if (serializedSubagents.length > 0) {
|
|
96
96
|
config.subagents = serializedSubagents;
|
|
97
97
|
}
|
|
98
|
-
if (this.isStepFlagEnabled(idle_detection_enabled)) {
|
|
99
|
-
const timeoutSecs = Number(idle_timeout_secs);
|
|
100
|
-
const maxRetries = Number(idle_max_retries);
|
|
101
|
-
const prompts = this.normalizeIdlePrompts(idle_prompts);
|
|
102
|
-
config.idle_detection = {
|
|
103
|
-
enabled: true,
|
|
104
|
-
timeout_secs: timeoutSecs,
|
|
105
|
-
max_retries: maxRetries,
|
|
106
|
-
prompts,
|
|
107
|
-
goodbye_message: lodash_1.default.isEmpty(lodash_1.default.trim(idle_goodbye_message)) ? undefined : idle_goodbye_message
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
if (this.isStepFlagEnabled(dtmf_enabled)) {
|
|
111
|
-
const timeout = Number(dtmf_timeout);
|
|
112
|
-
const terminationDigit = String(dtmf_termination_digit || '#');
|
|
113
|
-
const prefix = dtmf_prefix == null || dtmf_prefix === '' ? 'DTMF: ' : String(dtmf_prefix);
|
|
114
|
-
config.dtmf = {
|
|
115
|
-
enabled: true,
|
|
116
|
-
timeout: Number.isFinite(timeout) ? timeout : 2,
|
|
117
|
-
termination_digit: terminationDigit,
|
|
118
|
-
prefix
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
98
|
let agentCustomUrl = '';
|
|
122
99
|
if (this.isStepFlagEnabled(agent_url_overwritten)) {
|
|
123
100
|
if (!this.isValidAgentUrl(agent_url)) {
|
|
@@ -140,27 +117,12 @@ class VoiceAgent extends voice_1.default {
|
|
|
140
117
|
this.throwError(new Error(`Voice Agent: unknown mode "${mode}"`));
|
|
141
118
|
}
|
|
142
119
|
}
|
|
143
|
-
if (this.isStepFlagEnabled(tool_feedback?.enabled) && tools.length > 0) {
|
|
144
|
-
const validatedFeedback = this.validateToolFeedback(tool_feedback);
|
|
145
|
-
if (validatedFeedback) {
|
|
146
|
-
config.tool_feedback = validatedFeedback;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
if (soft_timeout != null) {
|
|
150
|
-
const validatedSoftTimeout = this.validateSoftTimeout(soft_timeout);
|
|
151
|
-
if (validatedSoftTimeout) {
|
|
152
|
-
config.soft_timeout = validatedSoftTimeout;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
120
|
if (system_tools != null) {
|
|
156
121
|
config.system_tools = this.validateSystemTools(system_tools);
|
|
157
122
|
}
|
|
158
123
|
if (!lodash_1.default.isEmpty(knowledge)) {
|
|
159
124
|
config.knowledge = this.validateKnowledge(knowledge);
|
|
160
125
|
}
|
|
161
|
-
if (this.isRealtimePipeline(custom_config_enabled, mode)) {
|
|
162
|
-
this.omitRealtimeUnsupportedSettings(config);
|
|
163
|
-
}
|
|
164
126
|
const params = { config };
|
|
165
127
|
if (agentCustomUrl) {
|
|
166
128
|
params.url = agentCustomUrl;
|
|
@@ -307,19 +269,45 @@ class VoiceAgent extends voice_1.default {
|
|
|
307
269
|
isStepFlagEnabled(value) {
|
|
308
270
|
return value === true || value === 'true';
|
|
309
271
|
}
|
|
310
|
-
isRealtimePipeline(
|
|
311
|
-
return this.isStepFlagEnabled(
|
|
272
|
+
isRealtimePipeline() {
|
|
273
|
+
return this.isStepFlagEnabled(this.data.custom_config_enabled)
|
|
274
|
+
&& this.data.mode === "realtime" /* AgentPipelineMode.REALTIME */;
|
|
312
275
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
276
|
+
buildGreetingAndCallBehavior() {
|
|
277
|
+
const { greeting_message = '', prevent_greeting_interruption = false, idle_detection_enabled = false, idle_timeout_secs = 8, idle_max_retries = 3, idle_prompts = [], idle_goodbye_message = '', dtmf_enabled = false, dtmf_timeout = 2, dtmf_termination_digit = '#', dtmf_prefix = 'DTMF: ', tool_feedback, soft_timeout } = this.data;
|
|
278
|
+
const settings = {
|
|
279
|
+
greeting_message,
|
|
280
|
+
prevent_greeting_interruption
|
|
281
|
+
};
|
|
282
|
+
if (this.isStepFlagEnabled(idle_detection_enabled)) {
|
|
283
|
+
settings.idle_detection = {
|
|
284
|
+
enabled: true,
|
|
285
|
+
timeout_secs: Number(idle_timeout_secs),
|
|
286
|
+
max_retries: Number(idle_max_retries),
|
|
287
|
+
prompts: this.normalizeIdlePrompts(idle_prompts),
|
|
288
|
+
goodbye_message: lodash_1.default.isEmpty(lodash_1.default.trim(idle_goodbye_message)) ? undefined : idle_goodbye_message
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
if (this.isStepFlagEnabled(dtmf_enabled)) {
|
|
292
|
+
const timeout = Number(dtmf_timeout);
|
|
293
|
+
settings.dtmf = {
|
|
294
|
+
enabled: true,
|
|
295
|
+
timeout: Number.isFinite(timeout) ? timeout : 2,
|
|
296
|
+
termination_digit: String(dtmf_termination_digit || '#'),
|
|
297
|
+
prefix: dtmf_prefix == null || dtmf_prefix === '' ? 'DTMF: ' : String(dtmf_prefix)
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
if (this.isStepFlagEnabled(tool_feedback?.enabled) && !lodash_1.default.isEmpty(this.data.handlers)) {
|
|
301
|
+
const validatedFeedback = this.validateToolFeedback(tool_feedback);
|
|
302
|
+
if (validatedFeedback)
|
|
303
|
+
settings.tool_feedback = validatedFeedback;
|
|
304
|
+
}
|
|
305
|
+
if (soft_timeout != null) {
|
|
306
|
+
const validatedSoftTimeout = this.validateSoftTimeout(soft_timeout);
|
|
307
|
+
if (validatedSoftTimeout)
|
|
308
|
+
settings.soft_timeout = validatedSoftTimeout;
|
|
322
309
|
}
|
|
310
|
+
return settings;
|
|
323
311
|
}
|
|
324
312
|
isValidAgentUrl(value) {
|
|
325
313
|
return /^wss?:\/\/([a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+|\[[a-fA-F0-9:]+\])(:\d+)?(\/\S*)?$/.test(value);
|