@peopl-health/nexus 4.5.23 → 4.5.25

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.
@@ -232,7 +232,6 @@ const submitForApproval = async (req, res) => {
232
232
  status: 'PENDING',
233
233
  approvalRequest: {
234
234
  sid: response.sid,
235
- status: response.status || 'PENDING',
236
235
  dateSubmitted: validSubmittedDate,
237
236
  dateUpdated: validUpdatedDate,
238
237
  rejectionReason: response.rejection_reason || ''
@@ -282,7 +281,6 @@ const checkApprovalStatus = async (req, res) => {
282
281
  );
283
282
  dbTemplate.approvalRequest = {
284
283
  sid: status.approvalRequest.sid,
285
- status: status.approvalRequest.status,
286
284
  dateSubmitted,
287
285
  dateUpdated: parseDate(
288
286
  status.approvalRequest.date_updated || status.approvalRequest.dateUpdated || status.content.dateUpdated,
@@ -20,9 +20,9 @@ class AssistantProcessor {
20
20
  return { thread, assistant };
21
21
  }
22
22
 
23
- async executeLLM(thread, assistant, runOptions = {}, messages = null) {
23
+ async executeLLM(thread, assistant, runOptions = {}, message = null) {
24
24
  const startTime = Date.now();
25
- const runResult = await runAssistantWithRetries(thread, assistant, { ...runOptions, phiProcessor: this.phiProcessor }, messages);
25
+ const runResult = await runAssistantWithRetries(thread, assistant, { ...runOptions, phiProcessor: this.phiProcessor }, message);
26
26
  const predictionTimeMs = Date.now() - startTime;
27
27
 
28
28
  const output = sanitizeOutput(runResult?.output);
@@ -41,19 +41,19 @@ class AssistantProcessor {
41
41
  };
42
42
  }
43
43
 
44
- async process({ code, runOptions = {}, messages = null }) {
44
+ async process({ code, runOptions = {}, message = null }) {
45
45
  if (!code) throw new Error('code is required for assistant processing');
46
46
 
47
47
  return (this.mode === 'queue')
48
48
  ? await this._executeViaQueue({ code, runOptions })
49
- : await this._executeLocal({ code, runOptions, messages });
49
+ : await this._executeLocal({ code, runOptions, message });
50
50
  }
51
51
 
52
- async _executeLocal({ code, runOptions = {}, messages = null }) {
52
+ async _executeLocal({ code, runOptions = {}, message = null }) {
53
53
  const resolved = await this.resolveThread(code);
54
54
  if (!resolved) return null;
55
55
 
56
- const result = await this.executeLLM(resolved.thread, resolved.assistant, runOptions, messages);
56
+ const result = await this.executeLLM(resolved.thread, resolved.assistant, runOptions, message);
57
57
  if (this.storeRunMetrics) await this.storeRunMetrics(code, resolved.thread, result);
58
58
  return result;
59
59
  }
@@ -507,7 +507,7 @@ class NexusMessaging {
507
507
  const result = await this.assistantProcessor.executeLLM(
508
508
  resolved.thread, resolved.assistant,
509
509
  { prePromptResult: preProcessResult },
510
- preProcessed.messages
510
+ preProcessed.messages[0]
511
511
  );
512
512
 
513
513
  if (storeRunMetrics) await storeRunMetrics(chatId, resolved.thread, result, preProcessed.timings);
@@ -22,14 +22,17 @@ const runAssistantAndWait = async ({ thread, assistant, message = null, runConfi
22
22
  throw new Error('runAssistantAndWait requires thread and assistant');
23
23
  }
24
24
 
25
+ if (Array.isArray(message)) {
26
+ throw new Error('runAssistantAndWait requires message to be a single element, not an array');
27
+ }
28
+
25
29
  const variant = getProviderVariant();
26
30
  const provider = createLLMProvider({ variant });
27
31
  const { polling, tools: configTools, ...config } = runConfig;
28
32
  const tools = assistant.getToolSchemas?.() || configTools || [];
29
- const messageForRun = Array.isArray(message) && message.length > 0 ? message[0] : message;
30
33
 
31
34
  return withThreadRecovery(
32
- (currentThread = thread) => provider.executeRun({ thread: currentThread, message: messageForRun, assistant, tools, config, polling }),
35
+ (currentThread = thread) => provider.executeRun({ thread: currentThread, message, assistant, tools, config, polling }),
33
36
  thread,
34
37
  variant
35
38
  );
package/lib/index.d.ts CHANGED
@@ -595,7 +595,7 @@ declare module '@peopl-health/nexus' {
595
595
  export interface ProcessInput {
596
596
  code: string;
597
597
  runOptions?: Record<string, any>;
598
- messages?: any[] | null;
598
+ message?: any | null;
599
599
  }
600
600
 
601
601
  export interface LLMResult {
@@ -614,7 +614,7 @@ declare module '@peopl-health/nexus' {
614
614
  constructor(config: AssistantProcessorConfig);
615
615
  setSendMessage(fn: AssistantProcessorConfig['sendMessage']): void;
616
616
  resolveThread(code: string): Promise<{ thread: any; assistant: any } | null>;
617
- executeLLM(thread: any, assistant: any, runOptions?: Record<string, any>, messages?: any[]): Promise<LLMResult>;
617
+ executeLLM(thread: any, assistant: any, runOptions?: Record<string, any>, message?: any): Promise<LLMResult>;
618
618
  process(input: ProcessInput): Promise<LLMResult | null>;
619
619
  sendResponse(code: string, result: any): Promise<string | null>;
620
620
  }
@@ -37,7 +37,6 @@ const TemplateSchema = new mongoose.Schema({
37
37
  ],
38
38
  approvalRequest: {
39
39
  sid: String,
40
- status: String,
41
40
  dateSubmitted: Date,
42
41
  dateUpdated: Date,
43
42
  rejectionReason: String
@@ -16,7 +16,6 @@ const refreshApprovalStatuses = async (templates) => {
16
16
  const updateFields = {
17
17
  approvalRequest: {
18
18
  sid: reqData.sid,
19
- status: reqData.status,
20
19
  dateSubmitted: reqData.dateCreated ? new Date(reqData.dateCreated) : new Date(),
21
20
  dateUpdated: reqData.dateUpdated ? new Date(reqData.dateUpdated) : new Date(),
22
21
  rejectionReason: reqData.rejectionReason || ''
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "4.5.23",
3
+ "version": "4.5.25",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",