@onereach/step-voice 7.0.51 → 7.0.52-VOIC1768serviceswitcher.0
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/Update Voice Agent.d.ts +9 -0
- package/dst/Update Voice Agent.js +32 -2
- package/dst/Voice Agent.d.ts +10 -0
- package/dst/Voice Agent.js +24 -1
- package/package.json +1 -1
|
@@ -15,6 +15,11 @@ interface AgentServiceConfig {
|
|
|
15
15
|
api_key?: string;
|
|
16
16
|
options?: Record<string, unknown>;
|
|
17
17
|
}
|
|
18
|
+
interface AgentBackupInput {
|
|
19
|
+
mode?: string;
|
|
20
|
+
order?: Array<Partial<AgentServiceConfig>>;
|
|
21
|
+
timeout?: number | string;
|
|
22
|
+
}
|
|
18
23
|
interface INPUT {
|
|
19
24
|
system_instruction_mode: SystemInstructionMode;
|
|
20
25
|
system_instruction: string;
|
|
@@ -31,6 +36,9 @@ interface INPUT {
|
|
|
31
36
|
llm: Partial<AgentServiceConfig>;
|
|
32
37
|
tts: Partial<AgentServiceConfig>;
|
|
33
38
|
realtime: Partial<AgentServiceConfig>;
|
|
39
|
+
stt_backup?: AgentBackupInput;
|
|
40
|
+
llm_backup?: AgentBackupInput;
|
|
41
|
+
tts_backup?: AgentBackupInput;
|
|
34
42
|
}
|
|
35
43
|
export default class UpdateVoiceAgent extends VoiceStep<Partial<INPUT>> {
|
|
36
44
|
runStep(): Promise<void>;
|
|
@@ -39,6 +47,7 @@ export default class UpdateVoiceAgent extends VoiceStep<Partial<INPUT>> {
|
|
|
39
47
|
private normalizeMessages;
|
|
40
48
|
private buildTools;
|
|
41
49
|
private buildOptionalServiceOverride;
|
|
50
|
+
private buildBackupUpdate;
|
|
42
51
|
private parseAgentServiceOptions;
|
|
43
52
|
private isStepFlagEnabled;
|
|
44
53
|
}
|
|
@@ -50,7 +50,7 @@ class UpdateVoiceAgent extends voice_1.default {
|
|
|
50
50
|
if (this.isStepFlagEnabled(this.data.realtime_unsupported)) {
|
|
51
51
|
this.throwError(new Error('Update Voice Agent does not support Realtime (Gemini Live) pipelines. Switch Voice Agent to Waterfall.'));
|
|
52
52
|
}
|
|
53
|
-
const { system_instruction_mode = 'append', system_instruction = '', developer_messages_mode = 'append', developer_messages = [], tools_update_mode = 'append', tools: toolDefs = [], custom_config_enabled = false, mode = '', stt = {}, llm = {}, tts = {}, realtime = {}, } = this.data;
|
|
53
|
+
const { system_instruction_mode = 'append', system_instruction = '', developer_messages_mode = 'append', developer_messages = [], tools_update_mode = 'append', tools: toolDefs = [], custom_config_enabled = false, mode = '', stt = {}, llm = {}, tts = {}, realtime = {}, stt_backup, llm_backup, tts_backup, } = this.data;
|
|
54
54
|
const params = {};
|
|
55
55
|
if (system_instruction_mode !== 'off'
|
|
56
56
|
&& !lodash_1.default.isEmpty(lodash_1.default.trim(String(system_instruction)))) {
|
|
@@ -87,7 +87,10 @@ class UpdateVoiceAgent extends voice_1.default {
|
|
|
87
87
|
const sttOverride = this.buildOptionalServiceOverride('stt', stt);
|
|
88
88
|
const llmOverride = this.buildOptionalServiceOverride('llm', llm);
|
|
89
89
|
const ttsOverride = this.buildOptionalServiceOverride('tts', tts);
|
|
90
|
-
|
|
90
|
+
const sttBackup = this.buildBackupUpdate('stt', stt_backup);
|
|
91
|
+
const llmBackup = this.buildBackupUpdate('llm', llm_backup);
|
|
92
|
+
const ttsBackup = this.buildBackupUpdate('tts', tts_backup);
|
|
93
|
+
if (!sttOverride && !llmOverride && !ttsOverride && !sttBackup && !llmBackup && !ttsBackup) {
|
|
91
94
|
this.throwError(new Error('Update Voice Agent: set at least one model or options when pipeline override is enabled'));
|
|
92
95
|
}
|
|
93
96
|
if (sttOverride)
|
|
@@ -96,6 +99,12 @@ class UpdateVoiceAgent extends voice_1.default {
|
|
|
96
99
|
params.llm = llmOverride;
|
|
97
100
|
if (ttsOverride)
|
|
98
101
|
params.tts = ttsOverride;
|
|
102
|
+
if (sttBackup)
|
|
103
|
+
params.stt_backup = sttBackup;
|
|
104
|
+
if (llmBackup)
|
|
105
|
+
params.llm_backup = llmBackup;
|
|
106
|
+
if (ttsBackup)
|
|
107
|
+
params.tts_backup = ttsBackup;
|
|
99
108
|
}
|
|
100
109
|
}
|
|
101
110
|
if (!params.system_instruction
|
|
@@ -170,6 +179,27 @@ class UpdateVoiceAgent extends voice_1.default {
|
|
|
170
179
|
options,
|
|
171
180
|
};
|
|
172
181
|
}
|
|
182
|
+
buildBackupUpdate(label, backup) {
|
|
183
|
+
if (backup?.mode !== 'override' || lodash_1.default.isEmpty(backup.order))
|
|
184
|
+
return undefined;
|
|
185
|
+
const order = (backup.order || []).map((entry, index) => {
|
|
186
|
+
const model = lodash_1.default.trim(String(entry?.model ?? ''));
|
|
187
|
+
if (lodash_1.default.isEmpty(entry?.provider) || lodash_1.default.isEmpty(model)) {
|
|
188
|
+
this.throwError(new Error(`Update Voice Agent: model is required for ${label} backup ${index + 1}`));
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
provider: entry.provider ?? '',
|
|
192
|
+
model,
|
|
193
|
+
options: this.parseAgentServiceOptions(`${label} backup ${index + 1}`, entry.options),
|
|
194
|
+
};
|
|
195
|
+
});
|
|
196
|
+
const timeout = Number(backup.timeout);
|
|
197
|
+
return {
|
|
198
|
+
mode: 'override',
|
|
199
|
+
order,
|
|
200
|
+
...(backup.timeout != null && backup.timeout !== '' && Number.isFinite(timeout) ? { timeout } : {}),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
173
203
|
parseAgentServiceOptions(label, options) {
|
|
174
204
|
if (options == null || options === '')
|
|
175
205
|
return undefined;
|
package/dst/Voice Agent.d.ts
CHANGED
|
@@ -47,6 +47,11 @@ interface AgentServiceConfig {
|
|
|
47
47
|
api_key?: string;
|
|
48
48
|
options?: Record<string, unknown>;
|
|
49
49
|
}
|
|
50
|
+
interface AgentBackupInput {
|
|
51
|
+
mode?: string;
|
|
52
|
+
order?: Array<Partial<AgentServiceConfig>>;
|
|
53
|
+
timeout?: number | string;
|
|
54
|
+
}
|
|
50
55
|
type SubagentContextMode = 'own' | 'shared';
|
|
51
56
|
interface Subagent {
|
|
52
57
|
id: string;
|
|
@@ -123,6 +128,10 @@ interface INPUT {
|
|
|
123
128
|
llm: Partial<AgentServiceConfig>;
|
|
124
129
|
tts: Partial<AgentServiceConfig>;
|
|
125
130
|
realtime: Partial<AgentServiceConfig>;
|
|
131
|
+
stt_backup?: AgentBackupInput;
|
|
132
|
+
llm_backup?: AgentBackupInput;
|
|
133
|
+
tts_backup?: AgentBackupInput;
|
|
134
|
+
realtime_backup?: AgentBackupInput;
|
|
126
135
|
tool_feedback?: ToolCallFeedbackConfig;
|
|
127
136
|
soft_timeout?: SoftTimeoutConfig;
|
|
128
137
|
system_tools?: AgentSystemToolConfig[];
|
|
@@ -147,6 +156,7 @@ export default class VoiceAgent extends VoiceStep<Partial<INPUT>> {
|
|
|
147
156
|
private buildWorkingHoursSchedules;
|
|
148
157
|
private isValidAgentUrl;
|
|
149
158
|
private buildAgentServiceConfig;
|
|
159
|
+
private buildAgentBackupConfig;
|
|
150
160
|
private validatePerToolFeedback;
|
|
151
161
|
private validateSoftTimeout;
|
|
152
162
|
private validateSystemTools;
|
package/dst/Voice Agent.js
CHANGED
|
@@ -82,7 +82,7 @@ class VoiceAgent extends voice_1.default {
|
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
84
|
this.triggers.otherwise(async () => {
|
|
85
|
-
const { handlers = [], subagents = [], system_instruction = '', developer_messages = [], custom_config_enabled = false, agent_url_overwritten = false, system_tools, knowledge = [], mcp_servers = [], agent_url = '', mode = '', stt = {}, llm = {}, tts = {}, realtime = {} } = this.data;
|
|
85
|
+
const { handlers = [], subagents = [], system_instruction = '', developer_messages = [], custom_config_enabled = false, agent_url_overwritten = false, system_tools, knowledge = [], mcp_servers = [], agent_url = '', mode = '', stt = {}, llm = {}, tts = {}, realtime = {}, stt_backup, llm_backup, tts_backup, realtime_backup } = this.data;
|
|
86
86
|
if (lodash_1.default.isEmpty(system_instruction)) {
|
|
87
87
|
this.throwError(new Error('Voice Agent: system instruction is required'));
|
|
88
88
|
}
|
|
@@ -113,9 +113,13 @@ class VoiceAgent extends voice_1.default {
|
|
|
113
113
|
config.stt = this.buildAgentServiceConfig('stt', stt);
|
|
114
114
|
config.llm = this.buildAgentServiceConfig('llm', llm);
|
|
115
115
|
config.tts = this.buildAgentServiceConfig('tts', tts);
|
|
116
|
+
config.stt_backup = this.buildAgentBackupConfig('stt', stt_backup);
|
|
117
|
+
config.llm_backup = this.buildAgentBackupConfig('llm', llm_backup);
|
|
118
|
+
config.tts_backup = this.buildAgentBackupConfig('tts', tts_backup);
|
|
116
119
|
break;
|
|
117
120
|
case "realtime" /* AgentPipelineMode.REALTIME */:
|
|
118
121
|
config.realtime = this.buildAgentServiceConfig('realtime', realtime);
|
|
122
|
+
config.realtime_backup = this.buildAgentBackupConfig('realtime', realtime_backup);
|
|
119
123
|
break;
|
|
120
124
|
default:
|
|
121
125
|
this.throwError(new Error(`Voice Agent: unknown mode "${mode}"`));
|
|
@@ -376,6 +380,25 @@ class VoiceAgent extends voice_1.default {
|
|
|
376
380
|
options: this.parseAgentServiceOptions(label, service.options)
|
|
377
381
|
};
|
|
378
382
|
}
|
|
383
|
+
buildAgentBackupConfig(label, backup) {
|
|
384
|
+
if (backup?.mode === 'disabled')
|
|
385
|
+
return { mode: 'disabled' };
|
|
386
|
+
if (backup?.mode !== 'override')
|
|
387
|
+
return;
|
|
388
|
+
const order = (backup.order || [])
|
|
389
|
+
.map((entry, index) => this.buildAgentServiceConfig(`${label} backup ${index + 1}`, entry || {}))
|
|
390
|
+
.filter((entry) => entry != null);
|
|
391
|
+
if (order.length === 0) {
|
|
392
|
+
this.log.warn(`Voice Agent: ${label} backup is custom but has no backups, the default is used`);
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
const timeout = Number(backup.timeout);
|
|
396
|
+
return {
|
|
397
|
+
mode: 'override',
|
|
398
|
+
order,
|
|
399
|
+
...(backup.timeout != null && backup.timeout !== '' && Number.isFinite(timeout) ? { timeout } : {})
|
|
400
|
+
};
|
|
401
|
+
}
|
|
379
402
|
validatePerToolFeedback(config, toolName) {
|
|
380
403
|
if (config == null || typeof config !== 'object' || Array.isArray(config)) {
|
|
381
404
|
return null;
|