jsfe 1.81.1 → 1.81.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"identity-flows.d.ts","sourceRoot":"","sources":["../../src/forms/identity-flows.js"],"names":[],"mappings":"AAkDA,+GAA+G;AAC/G,oFAOC;AAQD,wFAAwF;AACxF,iDAGC;AACD,0CAMC;AACD,qHAQC;AASD,qHAAqH;AACrH,6FAKC;AACD,4EAMC;AAkHD,2DAOC;AACD,4DAOC;AACD,gHAAgH;AAChH,8DAGC;AA0JD,8EAGC;AAgCD,4FAA4F;AAC5F;;;;EAOC;AAWD,oGAOC;AAzQD,iCAAgC,wIAAwI,CAAC;AACzK,wCAAuC,CAAC,CAAC;AA4RzC,0BAAsK"}
1
+ {"version":3,"file":"identity-flows.d.ts","sourceRoot":"","sources":["../../src/forms/identity-flows.js"],"names":[],"mappings":"AAkDA,+GAA+G;AAC/G,oFAOC;AAQD,wFAAwF;AACxF,iDAGC;AACD,0CAWC;AACD,qHAQC;AASD,qHAAqH;AACrH,6FAKC;AACD,4EAMC;AAkHD,2DAOC;AACD,4DAOC;AACD,gHAAgH;AAChH,8DAGC;AA0JD,8EAGC;AAgCD,4FAA4F;AAC5F;;;;EAOC;AAWD,oGAOC;AAzQD,iCAAgC,wIAAwI,CAAC;AACzK,wCAAuC,CAAC,CAAC;AA4RzC,0BAAsK"}
@@ -80,10 +80,16 @@ export function serviceDigits(text) {
80
80
  }
81
81
  export function otpDigits(text) {
82
82
  // The code is ONE complete six-digit number, or the caller's restart of it ("57. 57, 21, 80.", or said twice), read by the
83
- // number finder (owner 2026-11-19). Anything else is no code ('') and the question is asked again: pieces separated by
84
- // words are never glued into a code. Runs inside a flow expression, so findNumbers/assignNumbers are the standard functions.
85
- const read = assignNumbers(findNumbers(String(text || '')), { code: v => v.length === 6 });
86
- return read.values.code || '';
83
+ // number finder (owner 2026-11-19). The OTP form reads the result three ways: six characters verify; any other non-empty
84
+ // result says "I was expecting a 6-digit code" and counts a format miss (ended at 3); '' is an answer without digits. So any
85
+ // other answer returns the digits it holds, as before, except pieces separated by words that glue to six: they are never a
86
+ // code ("572 and then 180" is "572180?", a format miss). Runs inside a flow expression, so findNumbers/assignNumbers are the
87
+ // standard functions.
88
+ const numbers = findNumbers(String(text || '')), read = assignNumbers(numbers, { code: v => v.length === 6 });
89
+ if (read.values.code)
90
+ return read.values.code;
91
+ const digits = numbers.map(n => n.value).join('');
92
+ return digits.length === 6 ? digits + '?' : digits;
87
93
  }
88
94
  export function contactPrompt(cargo, options, callerAllowed, partial = false, es = false) {
89
95
  if (partial)
@@ -1 +1 @@
1
- {"version":3,"file":"answer.d.ts","sourceRoot":"","sources":["../../src/helpers/answer.js"],"names":[],"mappings":"AA4NA;;;GAGG;AACH,wEAkBC;AAED,qHAAqH;AACrH,+CAGC;AAED;;;;GAIG;AACH,mDAIC;AAED;;;;GAIG;AACH,kDAIC;AAED,+HAA+H;AAC/H,oDAIC;AAcD,2GAA2G;AAC3G,uDAGC;AAOD;;;;;GAKG;AACH,+DAUC;AAKD;;;;GAIG;AACH,oDAEC;AAuBD;;;;;;GAMG;AACH,mDAAmF;AAEnF,kGAAkG;AAClG;;;EAqCC;AAqBD,oEAqBC;AASD,gJAAgJ;AAChJ,sEAGC;AAED;;;;;;;;;GASG;AACH,6EA4GC;;;;;;;;AAjhBD,qCAKwE"}
1
+ {"version":3,"file":"answer.d.ts","sourceRoot":"","sources":["../../src/helpers/answer.js"],"names":[],"mappings":"AA0NA;;;GAGG;AACH,wEAkBC;AAED,qHAAqH;AACrH,+CAGC;AAED;;;;GAIG;AACH,mDAIC;AAED;;;;GAIG;AACH,kDAIC;AAED,+HAA+H;AAC/H,oDAIC;AAcD,2GAA2G;AAC3G,uDAGC;AAOD;;;;;GAKG;AACH,+DAUC;AAKD;;;;GAIG;AACH,oDAEC;AAuBD;;;;;;GAMG;AACH,mDAAmF;AAEnF,kGAAkG;AAClG;;;EAqCC;AAqBD,oEAqBC;AASD,gJAAgJ;AAChJ,sEAGC;AAED;;;;;;;;;GASG;AACH,6EA4GC;;;;;;;;AA/gBD,qCAKwE"}
@@ -64,14 +64,13 @@ const AGENT_ONLY = /^(?:(?:i want|i need|i would like|id like|can i|could i|let
64
64
  // Accents are not meaning here (owner 2026-10-16): text callers type "direccion" for "dirección", "si" for "sí". Both
65
65
  // sides of every comparison pass through normalize, so a word list matches with or without them; ñ is kept.
66
66
  const plainVowels = (s) => s.replace(/[áàâä]/g, 'a').replace(/[éèêë]/g, 'e').replace(/[íìîï]/g, 'i').replace(/[óòôö]/g, 'o').replace(/[úùûü]/g, 'u');
67
- // A whole answer that is one digit's word, with or without a closing period, IS that digit (owner 2026-11-19): speech-to-text
68
- // writes a pressed or spoken "0" as "Zero." as often as "0", and "0" is the agent key.
69
- const DIGIT_WORD = { zero: '0', one: '1', two: '2', three: '3', four: '4', five: '5', six: '6', seven: '7', eight: '8', nine: '9',
70
- cero: '0', uno: '1', dos: '2', tres: '3', cuatro: '4', cinco: '5', seis: '6', siete: '7', ocho: '8', nueve: '9' };
71
- const digitAnswer = (s) => { const w = s.replace(/\.$/, ''); return Object.hasOwn(DIGIT_WORD, w) ? DIGIT_WORD[w] : s; };
72
67
  /** Unescapes what the engine escaped, lowercases, drops punctuation but keeps * @ ., and drops accents (not ñ). */
73
- const normalize = (s) => digitAnswer(plainVowels(String(s ?? '').replace(/\\(['"\\])/g, '$1').toLowerCase().replace(/[^\w\s*@.áéíóúüñàâäèêëìîïòôöùû]+/g, ''))
74
- .replace(AGREEING, ' ').replace(/\s+/g, ' ').trim());
68
+ const normalize = (s) => plainVowels(String(s ?? '').replace(/\\(['"\\])/g, '$1').toLowerCase().replace(/[^\w\s*@.áéíóúüñàâäèêëìîïòôöùû]+/g, ''))
69
+ .replace(AGREEING, ' ').replace(/\s+/g, ' ').trim();
70
+ // The agent key 0, pressed or spoken: a whole answer that is one digit's word, with or without a closing period, is that digit
71
+ // (owner 2026-11-19; speech-to-text writes "Zero." as often as "0"). Every other digit word already reads as its digit where
72
+ // digits are read (choice keys, the number finder); only these literal "0" comparisons missed it.
73
+ const isZeroKey = (b) => b === '0' || /^(?:zero|cero)\.?$/.test(b);
75
74
  const NEGATION_SET = new Set(NEGATIONS.map(plainVowels));
76
75
  const hasNegation = (s) => String(s).split(' ').some((t) => NEGATION_SET.has(t));
77
76
  // Said around an answer without changing it: politeness, filler, a form of address.
@@ -236,7 +235,7 @@ export function isAnswer(input, kind, extra = []) {
236
235
  if (!b) {
237
236
  return false;
238
237
  }
239
- else if (kind === 'agent' && b === '0') {
238
+ else if (kind === 'agent' && isZeroKey(b)) {
240
239
  return true;
241
240
  }
242
241
  else if (kind === 'exit' && b === '*') {
@@ -284,7 +283,7 @@ export function isGlobalExit(input) {
284
283
  export function isAgentRequest(input) {
285
284
  // the period normalize() keeps for emails is not part of the answer at its ends ("Operator." on a call, 2026-10-17)
286
285
  const b = normalize(input).replace(/^[.\s]+|[.\s]+$/g, '');
287
- return b === '0' || (!hasNegation(b) && AGENT_ONLY.test(b));
286
+ return isZeroKey(b) || (!hasNegation(b) && AGENT_ONLY.test(b));
288
287
  }
289
288
  // A spoken or typed number: a digit, or a number word (ASR usually writes digits, not always).
290
289
  const NUMBER_WORD = /\b(zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|thirty|forty|fifty|sixty|seventy|eighty|ninety|hundred|thousand|cero|uno|una|dos|tres|cuatro|cinco|seis|siete|ocho|nueve|diez|once|doce|trece|catorce|quince|dieciséis|dieciseis|diecisiete|dieciocho|diecinueve|veinte|veinti\w+|treinta|cuarenta|cincuenta|sesenta|setenta|ochenta|noventa|cien|ciento|cientos|mil)\b/;
@@ -590,7 +589,7 @@ export function pickChoice(answer, choices, acceptOther) {
590
589
  else if (blocked && noChoice) {
591
590
  return noChoice;
592
591
  }
593
- else if ((b === '0' && !amount) || (!hasNegation(b) && !b.includes('@') && (AGENT_ONLY.test(b) || (!acceptOther && matchesChoice(b, ANSWER_WORDS.agent.filter((w) => !AGENT_AMBIGUOUS.has(w))))))) {
592
+ else if ((isZeroKey(b) && !amount) || (!hasNegation(b) && !b.includes('@') && (AGENT_ONLY.test(b) || (!acceptOther && matchesChoice(b, ANSWER_WORDS.agent.filter((w) => !AGENT_AMBIGUOUS.has(w))))))) {
594
593
  return '__agent';
595
594
  }
596
595
  else if (b === '*' || (acceptOther ? /^(exit|quit|salir|abort)( please| por favor)?$/ : /^(exit|quit|salir|abort|cancel|cancelar)( please| por favor)?$/).test(b)) {
@@ -1 +1 @@
1
- {"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../src/helpers/numbers.js"],"names":[],"mappings":"AAoFA;;;;;GAKG;AACH;;;;;;IAqBC;AAED;;;;;;;GAOG;AACH;;;;EA0BC;AAED;mFACmF;AACnF,qEASC;AArJD;;;4EAG4E;AAC5E,+BAAqF"}
1
+ {"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../src/helpers/numbers.js"],"names":[],"mappings":"AAmGA;;;;;GAKG;AACH;;;;;;IAqBC;AAED;;;;;;;GAOG;AACH;;;;EA0BC;AAED;mFACmF;AACnF,qEASC;AApKD;;;4EAG4E;AAC5E,+BAAqF"}
@@ -26,6 +26,23 @@ function wordNumbers(raw) {
26
26
  const found = [];
27
27
  for (let i = 0; i < tokens.length; i++) {
28
28
  const first = tokens[i].word;
29
+ // Spanish says "y" inside a number, and speech-to-text keeps it between the digits (owner 2026-11-19; prod 11-19 17:10
30
+ // "9 y 5, 55, 31" was the code 955531): tens and a digit add up ("40 y 3" → 43, "cuarenta y tres"); two single digits
31
+ // join ("9 y 5" → 95) unless the first ends a number already being said digit by digit ("1 2 3 4 y 0 5 1 2 1 9 8 0" is two
32
+ // numbers). "y" between longer groups still separates two numbers ("1382 y 5603").
33
+ const and = tokens[i + 1], unit = tokens[i + 2];
34
+ if (/^\d{1,2}$/.test(first) && and?.word === 'y' && unit && /^\d$/.test(unit.word) && gapOk(tokens[i], and) && gapOk(and, unit)
35
+ && !/\d/.test(raw[unit.end] || '')) {
36
+ const tensAndUnit = /^[2-9]0$/.test(first) && unit.word !== '0';
37
+ const digitPair = /^\d$/.test(first) && !/\d[\s.,-]*$/.test(raw.slice(0, tokens[i].start));
38
+ if (tensAndUnit || digitPair) {
39
+ found.push({ start: tokens[i].start, end: unit.end, digits: tensAndUnit ? String(Number(first) + Number(unit.word)) : first + unit.word });
40
+ i += 2;
41
+ continue;
42
+ }
43
+ else { /* "15 y 3": two numbers */ }
44
+ }
45
+ else { /* no "y" inside a number here */ }
29
46
  if (!isNumberWord(first) || CONNECTORS.has(first)) {
30
47
  continue;
31
48
  }
@@ -1 +1 @@
1
- export const JSFE_RUNTIME_FINGERPRINT = "sha256:fc22f499a14db5291a60b88052ce3fd09775fb9bd83d42a0ceebc834ad9e9541";
1
+ export const JSFE_RUNTIME_FINGERPRINT = "sha256:3d731a036910c77393b8dc78e4ea00412c176a335b235bf420480f466cc7a191";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsfe",
3
- "version": "1.81.1",
3
+ "version": "1.81.3",
4
4
  "description": "TypeScript workflow engine for conversational/automation apps: multi-flow orchestration, interrupt/resume, stack-based control, robust errors, and flexible tool/REST integration.",
5
5
  "license": "MIT",
6
6
  "author": "Ron Pinkas",