@onereach/step-voice 7.0.26-agenttimeout.8 → 7.0.26-agenttimeout.9

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.
@@ -2,6 +2,7 @@ import VoiceStep from './voice';
2
2
  interface INPUT {
3
3
  result: string;
4
4
  stopAgent: boolean;
5
+ functionId?: string;
5
6
  }
6
7
  export default class VoiceAgentFunctionResult extends VoiceStep<INPUT> {
7
8
  runStep(): Promise<void>;
@@ -4,11 +4,18 @@ const tslib_1 = require("tslib");
4
4
  const voice_1 = tslib_1.__importDefault(require("./voice"));
5
5
  class VoiceAgentFunctionResult extends voice_1.default {
6
6
  async runStep() {
7
- const { result, stopAgent } = this.data;
7
+ const { result, stopAgent, functionId: inputFunctionId } = this.data;
8
8
  let ctx = await this.thread.get(`__voiceAgentContext_${this.thread.id}`);
9
9
  if (!ctx) {
10
10
  ctx = await this.thread.get('__voiceAgentContext') ?? {};
11
11
  }
12
+ const lookupFunctionId = inputFunctionId || ctx?.functionId;
13
+ if (lookupFunctionId) {
14
+ const fnCtx = await this.thread.get(`__voiceAgentContext_fn_${lookupFunctionId}`);
15
+ if (fnCtx) {
16
+ ctx = fnCtx;
17
+ }
18
+ }
12
19
  const { callId, callCallback, name: functionName, functionId } = ctx;
13
20
  if (!callId) {
14
21
  throw new Error('Voice Agent Function Result: missing call context (must be placed on a Voice Agent function exit)');
@@ -299,6 +299,9 @@ class VoiceAgent extends voice_1.default {
299
299
  const result = this.state.result;
300
300
  await this.thread.set(`__voiceAgentContext_${this.thread.id}`, result);
301
301
  await this.thread.set('__voiceAgentContext', result);
302
+ if (result?.functionId) {
303
+ await this.thread.set(`__voiceAgentContext_fn_${result.functionId}`, result);
304
+ }
302
305
  this.thread.exitStep(this.state.exitStep, result);
303
306
  }
304
307
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "7.0.26-agenttimeout.8",
3
+ "version": "7.0.26-agenttimeout.9",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",