@onereach/step-voice 7.0.21-voiceagent.2 → 7.0.21-voiceagent.20

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.
@@ -5,19 +5,21 @@ const step_1 = tslib_1.__importDefault(require("@onereach/flow-sdk/dst/step"));
5
5
  class VoiceAgentFunctionResponse extends step_1.default {
6
6
  async runStep() {
7
7
  const ctx = await this.thread.get('__voiceAgentContext') ?? {};
8
- const { callId, callCallback, name: functionName } = ctx;
8
+ const { callId, callCallback, name: functionName, functionId } = ctx;
9
9
  const result = this.data.result ?? '';
10
10
  if (!callId) {
11
11
  throw new Error('Voice Agent Function Response: missing call context (must be placed on a Voice Agent function exit)');
12
12
  }
13
+ this.log.error("Voice Agent Function Response Params", ctx);
13
14
  const event = {
14
15
  target: this.helpers.providersAccountId,
15
16
  name: 'out/voice/function-result',
16
17
  params: {
17
18
  id: callId,
18
- commands: [{ name: 'function_result', params: { name: functionName, result } }]
19
+ commands: [{ name: 'function_result', params: { name: functionName, functionId, result } }]
19
20
  }
20
21
  };
22
+ this.log.error("Voice Agent Function Response", event);
21
23
  await this.thread.eventManager.emit(event, {
22
24
  target: callCallback,
23
25
  invocationType: 'async',
@@ -7,6 +7,8 @@ interface Handler {
7
7
  interface INPUT {
8
8
  url: string;
9
9
  handlers: Handler[];
10
+ system_instruction: string;
11
+ developer_messages: string[];
10
12
  }
11
13
  export default class VoiceAgent extends VoiceStep<Partial<INPUT>> {
12
14
  runStep(): Promise<void>;
@@ -5,7 +5,7 @@ const lodash_1 = tslib_1.__importDefault(require("lodash"));
5
5
  const voice_1 = tslib_1.__importDefault(require("./voice"));
6
6
  class VoiceAgent extends voice_1.default {
7
7
  async runStep() {
8
- const { url = 'wss://bot.svc.devvoice-voiceone.api.onereach.ai/ws', handlers = [] } = this.data;
8
+ const { url = 'wss://bot.svc.devvoice-voiceone.api.onereach.ai/ws', handlers = [], system_instruction = '', developer_messages = [] } = this.data;
9
9
  const call = await this.fetchData();
10
10
  const tools = handlers.map(h => ({
11
11
  type: 'function',
@@ -13,17 +13,23 @@ class VoiceAgent extends voice_1.default {
13
13
  description: h.description,
14
14
  parameters: typeof h.parameters === 'string' ? JSON.parse(h.parameters) : h.parameters
15
15
  }));
16
+ const config = {
17
+ system_instruction,
18
+ developer_messages,
19
+ tools
20
+ };
16
21
  this.triggers.local(`in/voice/${call.id}`, async (event) => {
17
22
  switch (event.params.type) {
18
- case 'recognition': {
19
- if (event.params.event !== 'function_call')
23
+ case 'function_call': {
24
+ if (event.params.type !== 'function_call')
20
25
  return;
21
26
  const cb = this.thread.takeCallback();
22
27
  const name = event.params.name ?? 'function_call';
23
- const params = event.params.params ?? {};
28
+ const params = event.params.arguments ?? {};
29
+ const functionId = event.params.functionId ?? '';
24
30
  const exitId = this.findExitByLabel(name) ?? this.getExitStepId('function_call');
25
31
  if (exitId) {
26
- this.exitStep(exitId, { name, params, __voicecb: cb, callId: call.id, callType: call.type, callCallback: call.callback }, true);
32
+ this.exitStep(exitId, { name, functionId, params, __voicecb: cb, callId: call.id, callType: call.type, callCallback: call.callback }, true);
27
33
  }
28
34
  else {
29
35
  this.log.warn('no exit for function_call', { name });
@@ -40,7 +46,7 @@ class VoiceAgent extends voice_1.default {
40
46
  }
41
47
  });
42
48
  this.triggers.otherwise(async () => {
43
- await this.sendCommands(call, [{ name: 'ws_pipe', params: { url, tools } }]);
49
+ await this.sendCommands(call, [{ name: 'ws_pipe', params: { url, config } }]);
44
50
  return this.exitFlow();
45
51
  });
46
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "7.0.21-voiceagent.2",
3
+ "version": "7.0.21-voiceagent.20",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",