@peopl-health/nexus 2.0.10 → 2.0.12

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,7 +16,7 @@ const moment = require('moment-timezone');
16
16
  const mode = process.env.NODE_ENV || 'dev';
17
17
 
18
18
 
19
- async function checkRunStatus(assistant, thread_id, run_id, retryCount = 0, maxRetries = 100) {
19
+ async function checkRunStatus(assistant, thread_id, run_id, retryCount = 0, maxRetries = 100, actionHandled = false) {
20
20
  try {
21
21
  const provider = createProvider({ variant: process.env.VARIANT || 'assistants' });
22
22
  const run = await provider.getRun({ threadId: thread_id, runId: run_id });
@@ -36,15 +36,20 @@ async function checkRunStatus(assistant, thread_id, run_id, retryCount = 0, maxR
36
36
  if (retryCount >= maxRetries) {
37
37
  return false;
38
38
  }
39
- await assistant.handleRequiresAction(run);
40
- await new Promise(resolve => setTimeout(resolve, 5000));
41
- return checkRunStatus(assistant, thread_id, run_id, retryCount + 1, maxRetries);
39
+ if (!actionHandled) {
40
+ await assistant.handleRequiresAction(run);
41
+ await new Promise(resolve => setTimeout(resolve, 5000));
42
+ return checkRunStatus(assistant, thread_id, run_id, retryCount + 1, maxRetries, true);
43
+ } else {
44
+ await new Promise(resolve => setTimeout(resolve, 1000));
45
+ return checkRunStatus(assistant, thread_id, run_id, retryCount + 1, maxRetries, actionHandled);
46
+ }
42
47
  } else if (!['completed', 'succeeded'].includes(run.status)) {
43
48
  if (retryCount >= maxRetries) {
44
49
  return false;
45
50
  }
46
51
  await new Promise(resolve => setTimeout(resolve, 1000));
47
- return checkRunStatus(assistant, thread_id, run_id, retryCount + 1, maxRetries);
52
+ return checkRunStatus(assistant, thread_id, run_id, retryCount + 1, maxRetries, actionHandled);
48
53
  } else {
49
54
  console.log('Run completed.');
50
55
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "2.0.10",
3
+ "version": "2.0.12",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",