@onereach/step-voice 7.0.24 → 7.0.25-VOIC1709useridledetection.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.
@@ -16,6 +16,13 @@ interface INPUT {
16
16
  developer_messages: string[];
17
17
  greeting_message: string;
18
18
  prevent_greeting_interruption: boolean;
19
+ idle_detection_enabled: boolean;
20
+ idle_timeout_secs: number | string;
21
+ idle_max_retries: number | string;
22
+ idle_prompts: Array<string | {
23
+ prompt?: string;
24
+ }>;
25
+ idle_goodbye_message: string;
19
26
  custom_config_enabled: boolean;
20
27
  agent_url_overwritten: boolean;
21
28
  agent_url: string;
@@ -27,6 +34,7 @@ interface INPUT {
27
34
  }
28
35
  export default class VoiceAgent extends VoiceStep<Partial<INPUT>> {
29
36
  runStep(): Promise<void>;
37
+ private normalizeIdlePrompts;
30
38
  private findExitByLabel;
31
39
  private isValidAgentUrl;
32
40
  private buildAgentServiceConfig;
@@ -34,7 +34,7 @@ class VoiceAgent extends voice_1.default {
34
34
  }
35
35
  });
36
36
  this.triggers.otherwise(async () => {
37
- const { handlers = [], system_instruction = '', developer_messages = [], greeting_message = '', prevent_greeting_interruption = false, custom_config_enabled = false, agent_url_overwritten = false, agent_url = '', mode = '', stt = {}, llm = {}, tts = {}, realtime = {} } = this.data;
37
+ const { handlers = [], system_instruction = '', developer_messages = [], greeting_message = '', prevent_greeting_interruption = false, idle_detection_enabled = false, idle_timeout_secs = 8, idle_max_retries = 3, idle_prompts = [], idle_goodbye_message = '', custom_config_enabled = false, agent_url_overwritten = false, agent_url = '', mode = '', stt = {}, llm = {}, tts = {}, realtime = {} } = this.data;
38
38
  if (lodash_1.default.isEmpty(system_instruction)) {
39
39
  this.throwError(new Error('Voice Agent: system instruction is required'));
40
40
  }
@@ -57,6 +57,18 @@ class VoiceAgent extends voice_1.default {
57
57
  prevent_greeting_interruption,
58
58
  tools
59
59
  };
60
+ if (idle_detection_enabled) {
61
+ const timeoutSecs = Number(idle_timeout_secs);
62
+ const maxRetries = Number(idle_max_retries);
63
+ const prompts = this.normalizeIdlePrompts(idle_prompts);
64
+ config.idle_detection = {
65
+ enabled: true,
66
+ timeout_secs: timeoutSecs,
67
+ max_retries: maxRetries,
68
+ prompts,
69
+ goodbye_message: lodash_1.default.isEmpty(lodash_1.default.trim(idle_goodbye_message)) ? undefined : idle_goodbye_message
70
+ };
71
+ }
60
72
  let agentCustomUrl = '';
61
73
  if (custom_config_enabled) {
62
74
  config.mode = mode;
@@ -87,6 +99,11 @@ class VoiceAgent extends voice_1.default {
87
99
  return this.exitFlow();
88
100
  });
89
101
  }
102
+ normalizeIdlePrompts(idlePrompts) {
103
+ return (idlePrompts || [])
104
+ .map(item => typeof item === 'string' ? item : item?.prompt ?? '')
105
+ .filter(prompt => !lodash_1.default.isEmpty(lodash_1.default.trim(String(prompt))));
106
+ }
90
107
  findExitByLabel(label) {
91
108
  const exit = lodash_1.default.find(this.step.exits, (e) => e.label === label);
92
109
  return exit?.id;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "7.0.24",
3
+ "version": "7.0.25-VOIC1709useridledetection.1",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",