@peopl-health/nexus 5.76.7 → 5.76.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.
@@ -3,6 +3,7 @@ const { escapeRegExp } = require('../../utils/textMatchUtils');
3
3
 
4
4
  const MAX_CARRIER_TEXT_LENGTH = 600;
5
5
  const MAX_HYDRATED_BODY_LENGTH = 1024;
6
+ const GRAPHEME_SEGMENTER = new Intl.Segmenter('es', { granularity: 'grapheme' });
6
7
  const FOLLOW_UP_TYPES = new Set(['seguimiento']);
7
8
  const CONTINGENCY_TYPES = new Set(['contingencia']);
8
9
  const REMINDER_TYPES = new Set(['cita', 'examen', 'medicamento', 'otros']);
@@ -50,7 +51,7 @@ function validateAgentText(messageText, firstName) {
50
51
  throw new Error('OUTREACH_CARRIER_TEXT_REPEATS_NAME');
51
52
  }
52
53
 
53
- const emojiCount = [...text.matchAll(/\p{Extended_Pictographic}/gu)].length;
54
+ const emojiCount = [...GRAPHEME_SEGMENTER.segment(text)].filter(({ segment }) => /\p{Extended_Pictographic}/u.test(segment)).length;
54
55
  if (emojiCount > 1) throw new Error('OUTREACH_CARRIER_TEXT_TOO_MANY_EMOJI');
55
56
  return { text, name };
56
57
  }
@@ -880,6 +880,13 @@ function issuePaths(issues) {
880
880
  return [...new Set(issues.map((issue) => String(issue.path || '').replace(/\[[^\]]*\]/g, '[]')).filter(Boolean))];
881
881
  }
882
882
 
883
+ // Zod issue paths in the validator's dotted form, so a DTO retry names its field like plan_invalid does.
884
+ function dtoIssues(err) {
885
+ const issues = Array.isArray(err?.issues) ? err.issues : [];
886
+ const paths = issues.map((issue) => ({ path: arr(issue.path).map((key) => (typeof key === 'number' ? '[]' : `.${String(key)}`)).join('').replace(/^\./, '') }));
887
+ return paths.some((issue) => issue.path) ? paths : null;
888
+ }
889
+
883
890
  function truncateToCardLimit(elements, repairs) {
884
891
  const excess = elements.length - MAX_TRIAGE_CARDS;
885
892
  if (excess <= 0) return 0;
@@ -992,7 +999,7 @@ async function runPlan({ provider, presetId, casoBase, gate, boundary = null, ra
992
999
  plan = buildPlan(takeaways, elements);
993
1000
  } catch (err) {
994
1001
  lastIssues = [{ path: 'plan', problem: err?.message || 'DTO inválido' }];
995
- if (attempt < PLAN_MAX_ATTEMPTS) { retried(attempt, 'plan_dto_invalid'); continue; }
1002
+ if (attempt < PLAN_MAX_ATTEMPTS) { retried(attempt, 'plan_dto_invalid', dtoIssues(err)); continue; }
996
1003
  return outcome({ attempts: attempt, repairs, failure: { status: 'failed', stage: 'validate', reason: 'plan_invalid', hardRejectIssues: lastIssues } });
997
1004
  }
998
1005
  return outcome({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "5.76.7",
3
+ "version": "5.76.9",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",