jsfe 1.89.0 → 1.91.0

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.
@@ -279,7 +279,7 @@ export const FLOWS = [
279
279
  "id": "ac_late_code_check",
280
280
  "type": "SET",
281
281
  "variable": "ac_late",
282
- "value": "(function(t, c) { if (typeof form_context !== 'undefined' && form_context && form_context.form) { var fc=form_context, chain=formInputChain(cargo.forms,fc.form,cargo), read=readFormAnswer(t,chain,Array.isArray(fc.names)&&fc.names.length>1?{form:fc.form,names:fc.names}:{form:fc.form,name:fc.current},'',fc.questions||[]); if(read.hits.length || read.ambiguous.length || read.questions.length || (read.clarify || []).length) return false; } t = String(t || '').trim(); c = String(c || ''); if (c.length !== 6) { return false; } var rest = t.replace(/^(?:(?:el|mi|the|my)\\s+)?(?:c[oó]digo|code)(?:\\s+(?:es|is|era|was))?\\s*[:,.-]?\\s*/i, ''); if (!/^[\\d\\s.,-]+$/.test(rest)) { return false; } var d = rest.replace(/\\D/g, ''); return d.length >= 2 && d.length <= 6 && c.indexOf(d) >= 0; })(ac_answer, ac_code)"
282
+ "value": "(function(t, c) { if (typeof form_context !== 'undefined' && form_context && form_context.form) { var fc=form_context, chain=formInputChain(cargo.forms,fc.form,cargo), read=readFormAnswer(t,chain,Array.isArray(fc.names)&&fc.names.length>1?{form:fc.form,names:fc.names}:{form:fc.form,name:fc.current},'',fc.questions||[]); if(read.hits.length || read.ambiguous.length || read.questions.length || (read.clarify || []).length) return false; } t = String(t || '').trim(); c = String(c || ''); if (c.length !== 6) { return false; } var rest = t.replace(/^(?:(?:el|mi|the|my)\\s+)?(?:c[oó]digo|code)(?:\\s+(?:es|is|era|was))?\\s*[:,.-]?\\s*/i, ''); if (!numberAlone(rest)) { return false; } var d = rest.replace(/\\D/g, ''); return d.length >= 2 && d.length <= 6 && c.indexOf(d) >= 0; })(ac_answer, ac_code)"
283
283
  },
284
284
  {
285
285
  "id": "ac_late_code_reask",
@@ -486,7 +486,7 @@ const collectInput = {
486
486
  // short of the input's minimum the next question is "Go on." Anything that is not digits drops the partial. A complete
487
487
  // first answer is not joined: the reader reads it as typed (a card in groups is one number; a card then its security
488
488
  // code is two, matchInputs numericSplit; owner 2026-11-20).
489
- SET('ci_partial_join', 'ci_partial', "(function () { var state = cargo.forms[form]; if (!ci_spec || ci_spec.accumulate !== true || !ci_spec.digits) return ''; var said = String(cargo.choiceText || '').trim(); var data = state.data = state.data || {}; var key = '__partial_' + current; if (!/^[0-9][0-9\\s.,-]*$/.test(said)) { delete data[key]; return ''; } var joined = String(data[key] || '') + said.replace(/[^0-9]/g, ''); var starts = ci_spec.accumulate_first ? new RegExp(ci_spec.accumulate_first) : null; if (!data[key] && starts && !starts.test(joined)) return ''; if (joined.length < Number(ci_spec.digits.min || 0)) { data[key] = joined; var fb = state.feedback || {}; fb[current] = 'partial'; state.feedback = fb; return 'hold'; } if (!data[key]) return ''; delete data[key]; cargo.choiceText = joined; cargo.choice = joined; return 'joined'; })()"),
489
+ SET('ci_partial_join', 'ci_partial', "(function () { var state = cargo.forms[form]; if (!ci_spec || ci_spec.accumulate !== true || !ci_spec.digits) return ''; var said = String(cargo.choiceText || '').trim(); var data = state.data = state.data || {}; var key = '__partial_' + current; var digits = numberAlone(said); if (!digits) { delete data[key]; return ''; } var joined = String(data[key] || '') + digits; var starts = ci_spec.accumulate_first ? new RegExp(ci_spec.accumulate_first) : null; if (!data[key] && starts && !starts.test(joined)) return ''; if (joined.length < Number(ci_spec.digits.min || 0)) { data[key] = joined; var fb = state.feedback || {}; fb[current] = 'partial'; state.feedback = fb; return 'hold'; } if (!data[key]) return ''; delete data[key]; cargo.choiceText = joined; cargo.choice = joined; return 'joined'; })()"),
490
490
  // An email at a known provider said without its ending ("Cecilia 41, at Yahoo."): it is kept and the caller is asked
491
491
  // only what comes after the provider; an ending alone on the next turn completes it, any other reply drops it
492
492
  // (owner 2026-11-18, prod 11-18 17:30). An unknown domain is never guessed: the address is asked again.
@@ -134,7 +134,7 @@ const contact = worker('get-cell-or-email', 'GetCellOrEmail', 'Identify a suppli
134
134
  set('identity_contact_options', 'contact_options', "contact_options || (retrying && cargo.contactOptions ? Object.assign({},cargo.contactOptions,{fromMenu:true,intro:'',intro_es:''}) : {retry_flow:retry_flow || 'authenticate-user',cancel_flow:cancel_flow || 'contact-support',account_pattern:account_pattern,account_name:account_name,account_name_es:account_name_es,account_shape:account_shape,intro:intro,intro_es:intro_es,caller_on_file:caller_on_file,retry_call_type:retry_call_type || 'reboot',validate_flow:validate_flow,merge_partials:merge_partials === true || merge_partials === 'true',parent_form:parent_form})"),
135
135
  // options carried from an earlier verification may name a task the caller has since closed; opening under it fails
136
136
  set('identity_contact_live_parent', 'contact_options', "contact_options.parent_form && !(cargo.forms && cargo.forms[contact_options.parent_form]) ? Object.assign({},contact_options,{parent_form:''}) : contact_options"),
137
- effect('identity_contact_remember', '(cargo.contactOptions=contact_options,cargo.authCapture=[{variable:"cell_number",reader:"phone"},{variable:"email",reader:"email"}].concat(contact_options.account_pattern?[{variable:"acct_number",regex:contact_options.account_pattern,normalizer:"[^0-9]"}]:[]),true)'),
137
+ effect('identity_contact_remember', '(cargo.contactOptions=contact_options,cargo.authCapture=[{variable:"cell_number",reader:"phone"},{variable:"email",reader:"email"}].concat(contact_options.account_pattern?[{variable:"acct_number",reader:"account",regex:contact_options.account_pattern}]:[]),true)'),
138
138
  when('identity_contact_new_rejection_series', '!gce_rejected', effect('identity_contact_rejections_reset', '(cargo.gceRejects=0,true)')),
139
139
  when('identity_contact_new_miss_series', '!gce_missed', effect('identity_contact_misses_reset', '(cargo.gceMisses=0,cargo.gceRanked=false,true)')),
140
140
  set('identity_contact_partial', 'contact_partial', "!!(contact_options.merge_partials && gce_partial && cargo.gcePartial)"),
@@ -1 +1 @@
1
- {"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../src/helpers/capture.js"],"names":[],"mappings":"AAeA;;;SA8BC"}
1
+ {"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../src/helpers/capture.js"],"names":[],"mappings":"AAoBA;;;SA8BC"}
@@ -6,12 +6,17 @@
6
6
  * through `warn`, so one bad tenant pattern cannot stop the others.
7
7
  *
8
8
  * A pattern may name a reader instead of a regex: { variable, reader: 'phone' | 'email' } reads the answer with
9
- * readPhone / readEmail (spoken and spelled forms included).
9
+ * readPhone / readEmail (spoken and spelled forms included); { variable, reader: 'account', regex } reads it with
10
+ * readIdentifier, an account whose digits match the tenant's regex (a number inside an email is the email's).
10
11
  *
11
12
  * Part of jsfe/helpers; imports only its sibling contact.js.
12
13
  */
13
- import { readEmail, readPhone } from './contact.js';
14
- const READERS = { phone: readPhone, email: readEmail };
14
+ import { readEmail, readPhone, readIdentifier } from './contact.js';
15
+ const READERS = {
16
+ phone: (input) => readPhone(input),
17
+ email: (input) => readEmail(input),
18
+ account: (input, pattern) => { const id = readIdentifier(input, pattern.regex || ''); return id && id.kind === 'account' ? id.value : ''; }
19
+ };
15
20
  export function normalizeAndFindCapture(userInput, patterns, warn = () => { }) {
16
21
  if (!Array.isArray(patterns)) {
17
22
  return null;
@@ -19,7 +24,7 @@ export function normalizeAndFindCapture(userInput, patterns, warn = () => { }) {
19
24
  else {
20
25
  for (const pattern of patterns) {
21
26
  if (pattern && READERS[pattern.reader]) {
22
- const value = READERS[pattern.reader](userInput);
27
+ const value = READERS[pattern.reader](userInput, pattern);
23
28
  if (value) {
24
29
  return { variable: pattern.variable, value };
25
30
  }
@@ -7,9 +7,7 @@
7
7
  * With `{literal:true}`, a complete visible address wins over surrounding prose; absent one,
8
8
  * the same spoken/spelled parsing applies. Distinct visible addresses are ambiguous and return empty.
9
9
  */
10
- export function readEmail(text: any, { literal }?: {
11
- literal?: boolean | undefined;
12
- }): string;
10
+ export function readEmail(text: any, options?: {}): string;
13
11
  /**
14
12
  * An address at a known provider said without its ending ("Cecilia 41, at Yahoo."): its name and provider
15
13
  * ("cecilia41@yahoo"), so the caller is asked only for what comes after the provider (owner 2026-11-18, prod 11-18 17:30:
@@ -29,6 +27,9 @@ export function emailSaid(address: any, voice: any, es?: boolean): string;
29
27
  * 2026-11-17: "Juana Perez 12 34 at gmail." heard "the phone number you provided isn't valid").
30
28
  */
31
29
  export function emailAttempt(text: any): boolean;
30
+ /** Where the address rawEmail read sits in the answer: [[start, end], ...]. Typed, the address itself; spoken (at / arroba /
31
+ * dot / punto), the shortest run of words that reads as it, with a spoken ending after it. */
32
+ export function emailSpans(raw: any, value: any): any[][];
32
33
  /**
33
34
  * The 10-digit North American number in the answer (a leading 1 dropped), or ''. A caller who restates the number
34
35
  * ("Area code 21. 213 555 0147.", "Area code, 213 555. Area code 213-555-0147.") is read by the last complete number
@@ -1 +1 @@
1
- {"version":3,"file":"contact.d.ts","sourceRoot":"","sources":["../../src/helpers/contact.js"],"names":[],"mappings":"AAiBA;;;;;;;;GAQG;AACH;;WAiDC;AAED;;;;GAIG;AACH,sDASC;AAED;;;GAGG;AACH,+CASC;AAED,+GAA+G;AAC/G,0EAGC;AAoBD;;;;GAIG;AACH,iDAEC;AAID;;;;;GAKG;AACH,0CAWC;AAED;;;;;GAKG;AACH,0DAgBC;AAED,qHAAqH;AACrH,2DAIC;AAED;;;;GAIG;AACH;;;SAmBC;AAED;;;GAGG;AACH,sDAOC;AAED;;;;;GAKG;AACH,yEAUC;AAQD;;;;;GAKG;AACH,qDAIC;AAED,mHAAmH;AACnH,oDAIC"}
1
+ {"version":3,"file":"contact.d.ts","sourceRoot":"","sources":["../../src/helpers/contact.js"],"names":[],"mappings":"AAwBA;;;;;;;;GAQG;AACH,2DAEC;AAsDD;;;;GAIG;AACH,sDASC;AAED;;;GAGG;AACH,+CASC;AAED,+GAA+G;AAC/G,0EAGC;AAoBD;;;;GAIG;AACH,iDAEC;AAID;8FAC8F;AAC9F,0DAsBC;AA+BD;;;;;GAKG;AACH,0CAWC;AAED;;;;;GAKG;AACH,0DAgBC;AAED,qHAAqH;AACrH,2DAIC;AAED;;;;GAIG;AACH;;;SAmBC;AAED;;;GAGG;AACH,sDAOC;AAED;;;;;GAKG;AACH,yEAUC;AAQD;;;;;GAKG;AACH,qDAIC;AAED,mHAAmH;AACnH,oDAIC"}
@@ -5,8 +5,15 @@
5
5
  * address ("juan at gmail dot com", "j u a n arroba gmail punto com"), so the same answer worked for a statement and
6
6
  * failed at the identity question (flow design review 2026-10-13).
7
7
  *
8
- * Part of jsfe/helpers; zero imports.
8
+ * An email and a phone claim the part of the answer they were read from, and a number inside the email is never read as
9
+ * another field (owner 2026-11-24: the longest match wins; a fragment of a match is never another field's). When the email
10
+ * and a complete phone overlap, the one that begins first keeps its part (a tie: the phone) and the other is read again on
11
+ * the rest. Prod 2026-11-23: the digits inside an address were read as an account number, an address's digits joined an
12
+ * account number into a phone, and a phone typed before an address became the start of the address.
13
+ *
14
+ * Part of jsfe/helpers; imports its sibling numbers.js.
9
15
  */
16
+ import { findNumbers } from './numbers.js';
10
17
  // Words that introduce an address and are never part of it ("my email is", "mi correo es", "send it to").
11
18
  const EMAIL_LEAD_IN = new Set(['my', 'mi', 'su', 'your', 'email', 'e-mail', 'mail', 'correo', 'electronico', 'electrónico',
12
19
  'address', 'dirección', 'direccion', 'de', 'is', 'es', "it's", 'its', 'it', 'the', 'el', 'la', 'to', 'para', 'send',
@@ -22,7 +29,11 @@ const EMAIL_LEAD_IN = new Set(['my', 'mi', 'su', 'your', 'email', 'e-mail', 'mai
22
29
  * With `{literal:true}`, a complete visible address wins over surrounding prose; absent one,
23
30
  * the same spoken/spelled parsing applies. Distinct visible addresses are ambiguous and return empty.
24
31
  */
25
- export function readEmail(text, { literal = false } = {}) {
32
+ export function readEmail(text, options = {}) {
33
+ return emailClaim(text, options).email;
34
+ }
35
+ /** readEmail's reading of the whole answer, before any phone claims its part. */
36
+ function rawEmail(text, { literal = false } = {}) {
26
37
  // Contextual prose must not become part of an already complete, visible address. This
27
38
  // explicit mode preserves the default spoken/spelled-name grammar for existing callers.
28
39
  if (literal) {
@@ -139,6 +150,64 @@ export function emailAttempt(text) {
139
150
  return /@|\barroba\b|\b(?:g\s?mail|gmai|hotmail|hot mail|yahoo|outlook|icloud|aol)\b/i.test(String(text ?? ''));
140
151
  }
141
152
  const northAmerican = (digits) => digits.length === 11 && digits.startsWith('1') ? digits.slice(1) : digits.length === 10 ? digits : '';
153
+ /** Where the address rawEmail read sits in the answer: [[start, end], ...]. Typed, the address itself; spoken (at / arroba /
154
+ * dot / punto), the shortest run of words that reads as it, with a spoken ending after it. */
155
+ export function emailSpans(raw, value) {
156
+ const literal = raw.toLowerCase().indexOf(value);
157
+ if (literal >= 0)
158
+ return [[literal, literal + value.length]];
159
+ // Spoken addresses may use at / arroba / dot / punto. Select the shortest source window yielding this address.
160
+ const tokens = [...raw.matchAll(/\S+/g)];
161
+ if (tokens.length > 128)
162
+ return [[0, raw.length]];
163
+ for (let size = 1; size <= tokens.length; size++) {
164
+ const spans = [];
165
+ for (let i = 0; i + size <= tokens.length; i++) {
166
+ const a = tokens[i].index, b = tokens[i + size - 1].index + tokens[i + size - 1][0].length;
167
+ if (rawEmail(raw.slice(a, b)) === value) {
168
+ // "juan at gmail" already reads as gmail.com: the spoken ending after it belongs to the same address
169
+ let j = i + size;
170
+ while (j < tokens.length && /^(?:dot|punto|punt|ponto|com|con|\.com)[.,;:!?]*$/i.test(tokens[j][0]))
171
+ j++;
172
+ spans.push([a, j > i + size ? tokens[j - 1].index + tokens[j - 1][0].length : b]);
173
+ }
174
+ else {
175
+ // this window is not the address
176
+ }
177
+ }
178
+ if (spans.length)
179
+ return spans;
180
+ }
181
+ return [[0, raw.length]];
182
+ }
183
+ const blank = (text, spans) => spans.reduce((out, [a, b]) => out.slice(0, a) + ' '.repeat(b - a) + out.slice(b), text);
184
+ /** The email in the answer and the part it claims: {email, spans}. A complete North American phone number overlapping it
185
+ * that begins no later than the email keeps its part, and the email is read again on the rest. */
186
+ function emailClaim(text, options = {}) {
187
+ const t = String(text ?? '');
188
+ const email = rawEmail(t, options);
189
+ if (!email) {
190
+ return { email: '', spans: [] };
191
+ }
192
+ else {
193
+ const spans = emailSpans(t, email);
194
+ const start = Math.min(...spans.map(([a]) => a));
195
+ const phone = findNumbers(t).find((n) => northAmerican(n.value) && spans.some(([a, b]) => n.start < b && n.end > a));
196
+ if (phone && phone.start <= start) {
197
+ const rest = blank(t, [[phone.start, phone.end]]);
198
+ const again = rawEmail(rest, options);
199
+ return again ? { email: again, spans: emailSpans(rest, again) } : { email: '', spans: [] };
200
+ }
201
+ else {
202
+ return { email, spans };
203
+ }
204
+ }
205
+ }
206
+ /** The answer with the email's part blanked, for the digit readers: its digits are the email's. */
207
+ function withoutEmail(text) {
208
+ const t = String(text ?? '');
209
+ return blank(t, emailClaim(t).spans);
210
+ }
142
211
  /**
143
212
  * The 10-digit North American number in the answer (a leading 1 dropped), or ''. A caller who restates the number
144
213
  * ("Area code 21. 213 555 0147.", "Area code, 213 555. Area code 213-555-0147.") is read by the last complete number
@@ -146,7 +215,7 @@ const northAmerican = (digits) => digits.length === 11 && digits.startsWith('1')
146
215
  * nothing. An answer with an international prefix (+, plus, más, 00) is never split, so it stays international.
147
216
  */
148
217
  export function readPhone(text) {
149
- const t = String(text ?? '');
218
+ const t = withoutEmail(text);
150
219
  const whole = northAmerican(t.replace(/[^0-9]/g, ''));
151
220
  if (whole) {
152
221
  return whole;
@@ -197,7 +266,7 @@ export function callerIsInternational(cargo) {
197
266
  * accountPattern (a regex source, e.g. '^5\\d{6,7}$') is the tenant's account-number shape; its digits win first.
198
267
  */
199
268
  export function readIdentifier(text, accountPattern = '') {
200
- const digits = String(text ?? '').replace(/[^0-9]/g, '');
269
+ const digits = withoutEmail(text).replace(/[^0-9]/g, '');
201
270
  let account = false;
202
271
  try {
203
272
  account = !!accountPattern && new RegExp(accountPattern).test(digits);
@@ -145,6 +145,7 @@ export namespace STANDARD_FUNCTIONS {
145
145
  export { textWithUrlToSpeech };
146
146
  export { joinSpokenDigits };
147
147
  export { wholeSpokenNumber };
148
+ export { numberAlone };
148
149
  export { registerSendable };
149
150
  export { sendables };
150
151
  export { chatTranscript };
@@ -303,10 +304,11 @@ import { textWithUrlToSpeech } from './url-speech.js';
303
304
  import { joinSpokenDigits } from './spoken-digits.js';
304
305
  import { spokenDigitsText } from './spoken-digits.js';
305
306
  import { wholeSpokenNumber } from './spoken-digits.js';
307
+ import { numberAlone } from './spoken-digits.js';
306
308
  import { registerSendable } from './sendables.js';
307
309
  import { sendables } from './sendables.js';
308
310
  import { chatTranscript } from './sendables.js';
309
311
  import { conversationCopy } from './sendables.js';
310
312
  import { CONVERSATION_KEY } from './sendables.js';
311
- export { continuationSafetyProtocol, cancelFormTask, contextualResponseProtocol, validateFormResponse, hasFormResponse, formProposalPolicy, stageFormProposal, nextFormProposal, formProposalReadings, bindFormProposal, retireStaleFormProposal, decideFormProposal, commitFormProposals, settleFormProposalValidation, formProposalProtocol, validateFormProposalPolicy, validateFormProposalDescriptor, formProposalDescriptor, clearFormMisses, formNoOwner, missFormInput, formMustComplete, formInputPrompt, formUserDescriptionSource, formConcernLine, formAcknowledges, consumeFormFeedback, keepFormLine, deferFormClarification, takeFormClarification, formClarificationKept, clearFormLines, formConversationOutcome, readMoneyAmount, isMoneyAmount, moneyIntentAllows, isPastPaymentStatement, isPartialMoneyAnswer, validateMoneyOptions, takeChoiceOffer, saysConfirmWord, saysNoValue, confirmOutOfOrderLine, matchesChoice, ANSWER_WORDS, CONFIRM_WORDS, isAnswer, isAgentRequest, isExitRequest, isGlobalExit, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice, withoutPromptEcho, readEmail, emailWithoutEnding, emailEnding, emailSaid, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational, normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, yesNoKeys, channelVerb, dateToWords, amountToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readArgument, groundAmount, joinSpokenNumbers, findNumbers, assignNumbers, addressDraft, readInputProfile, formAcceptanceTrace, resolveFormInputs, formInputApplies, formInputFilled, nextFormInput, formInputChain, openFormInstance, validateFormIncompleteOutcome, formIncompleteOutcome, validateFormExhaustion, exhaustFormInput, formInitialReadings, orderFormReadings, proposedFormValues, applyFormValidation, formReadingDependencies, exclusiveFormReadings, enrichFormMatches, expandFormActivations, settleFormActivations, rememberFormArguments, resetFormInputs, hasFormValue, formPath, formValuesEqual, formReadingReady, formReadingRelevant, formPreparation, queueFormReadings, pendingFormReadings, formWorkLimit, answerResetsFormReplays, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance, checkOtp, clearOtp, maskDestination, validateOTP, OTP_EXPIRY_MS, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech, joinSpokenDigits, spokenDigitsText, wholeSpokenNumber, registerSendable, sendables, chatTranscript, conversationCopy, CONVERSATION_KEY };
313
+ export { continuationSafetyProtocol, cancelFormTask, contextualResponseProtocol, validateFormResponse, hasFormResponse, formProposalPolicy, stageFormProposal, nextFormProposal, formProposalReadings, bindFormProposal, retireStaleFormProposal, decideFormProposal, commitFormProposals, settleFormProposalValidation, formProposalProtocol, validateFormProposalPolicy, validateFormProposalDescriptor, formProposalDescriptor, clearFormMisses, formNoOwner, missFormInput, formMustComplete, formInputPrompt, formUserDescriptionSource, formConcernLine, formAcknowledges, consumeFormFeedback, keepFormLine, deferFormClarification, takeFormClarification, formClarificationKept, clearFormLines, formConversationOutcome, readMoneyAmount, isMoneyAmount, moneyIntentAllows, isPastPaymentStatement, isPartialMoneyAnswer, validateMoneyOptions, takeChoiceOffer, saysConfirmWord, saysNoValue, confirmOutOfOrderLine, matchesChoice, ANSWER_WORDS, CONFIRM_WORDS, isAnswer, isAgentRequest, isExitRequest, isGlobalExit, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice, withoutPromptEcho, readEmail, emailWithoutEnding, emailEnding, emailSaid, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational, normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, yesNoKeys, channelVerb, dateToWords, amountToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readArgument, groundAmount, joinSpokenNumbers, findNumbers, assignNumbers, addressDraft, readInputProfile, formAcceptanceTrace, resolveFormInputs, formInputApplies, formInputFilled, nextFormInput, formInputChain, openFormInstance, validateFormIncompleteOutcome, formIncompleteOutcome, validateFormExhaustion, exhaustFormInput, formInitialReadings, orderFormReadings, proposedFormValues, applyFormValidation, formReadingDependencies, exclusiveFormReadings, enrichFormMatches, expandFormActivations, settleFormActivations, rememberFormArguments, resetFormInputs, hasFormValue, formPath, formValuesEqual, formReadingReady, formReadingRelevant, formPreparation, queueFormReadings, pendingFormReadings, formWorkLimit, answerResetsFormReplays, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance, checkOtp, clearOtp, maskDestination, validateOTP, OTP_EXPIRY_MS, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech, joinSpokenDigits, spokenDigitsText, wholeSpokenNumber, numberAlone, registerSendable, sendables, chatTranscript, conversationCopy, CONVERSATION_KEY };
312
314
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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oCAAjB,iBAAiB;8BAAjB,iBAAiB;wCAAjB,iBAAiB;mCAAjB,iBAAiB;qCAAjB,iBAAiB;mCAAjB,iBAAiB;oCAAjB,iBAAiB;iCAAjB,iBAAiB;kCAAjB,iBAAiB;yBACzqB,gBAAgB;yBAAhB,gBAAgB;gCAAhB,gBAAgB;4BAAhB,gBAAgB;8BAAhB,gBAAgB;+BACnC,iBAAiB;8BAAjB,iBAAiB;8BAAjB,iBAAiB;4BAI7B,iBAAiB;oCAAjB,iBAAiB;iCAHiB,oBAAoB;iCAApB,oBAAoB;kCAApB,oBAAoB;4BAApB,oBAAoB;iCA9BP,gBAAgB;0BAAhB,gBAAgB;+BAAhB,gBAAgB;iCAAhB,gBAAgB;iCAAhB,gBAAgB"}
@@ -35,11 +35,11 @@ import { matchInputs, readFormAnswer, readArgument, groundAmount, saysConfirmWor
35
35
  import { resolveFormInputs, formInputApplies, formInputFilled, nextFormInput, formInputChain, openFormInstance, validateFormIncompleteOutcome, formIncompleteOutcome, validateFormExhaustion, exhaustFormInput, formInitialReadings, orderFormReadings, proposedFormValues, applyFormValidation, formReadingDependencies, exclusiveFormReadings, enrichFormMatches, expandFormActivations, settleFormActivations, rememberFormArguments, resetFormInputs, hasFormValue, formPath, formValuesEqual, formReadingReady, formReadingRelevant, formPreparation, queueFormReadings, pendingFormReadings, formWorkLimit, answerResetsFormReplays, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance } from './form-state.js';
36
36
  import { checkOtp, clearOtp, maskDestination, validateOTP, OTP_EXPIRY_MS } from './otp-check.js';
37
37
  import { validateDigits, validatePhone, validateEmail } from './validators.js';
38
- import { joinSpokenDigits, spokenDigitsText, wholeSpokenNumber } from './spoken-digits.js';
38
+ import { joinSpokenDigits, spokenDigitsText, wholeSpokenNumber, numberAlone } from './spoken-digits.js';
39
39
  import { findNumbers, assignNumbers, joinSpokenNumbers } from './numbers.js';
40
40
  import { addressDraft } from './address.js';
41
41
  import { urlToSpeech, textWithUrlToSpeech } from './url-speech.js';
42
- export { continuationSafetyProtocol, cancelFormTask, contextualResponseProtocol, validateFormResponse, hasFormResponse, formProposalPolicy, stageFormProposal, nextFormProposal, formProposalReadings, bindFormProposal, retireStaleFormProposal, decideFormProposal, commitFormProposals, settleFormProposalValidation, formProposalProtocol, validateFormProposalPolicy, validateFormProposalDescriptor, formProposalDescriptor, clearFormMisses, formNoOwner, missFormInput, formMustComplete, formInputPrompt, formUserDescriptionSource, formConcernLine, formAcknowledges, consumeFormFeedback, keepFormLine, deferFormClarification, takeFormClarification, formClarificationKept, clearFormLines, formConversationOutcome, readMoneyAmount, isMoneyAmount, moneyIntentAllows, isPastPaymentStatement, isPartialMoneyAnswer, validateMoneyOptions, takeChoiceOffer, saysConfirmWord, saysNoValue, confirmOutOfOrderLine, matchesChoice, ANSWER_WORDS, CONFIRM_WORDS, isAnswer, isAgentRequest, isExitRequest, isGlobalExit, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice, withoutPromptEcho, readEmail, emailWithoutEnding, emailEnding, emailSaid, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational, normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, yesNoKeys, channelVerb, dateToWords, amountToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readArgument, groundAmount, joinSpokenNumbers, findNumbers, assignNumbers, addressDraft, readInputProfile, formAcceptanceTrace, resolveFormInputs, formInputApplies, formInputFilled, nextFormInput, formInputChain, openFormInstance, validateFormIncompleteOutcome, formIncompleteOutcome, validateFormExhaustion, exhaustFormInput, formInitialReadings, orderFormReadings, proposedFormValues, applyFormValidation, formReadingDependencies, exclusiveFormReadings, enrichFormMatches, expandFormActivations, settleFormActivations, rememberFormArguments, resetFormInputs, hasFormValue, formPath, formValuesEqual, formReadingReady, formReadingRelevant, formPreparation, queueFormReadings, pendingFormReadings, formWorkLimit, answerResetsFormReplays, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance, checkOtp, clearOtp, maskDestination, validateOTP, OTP_EXPIRY_MS, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech, joinSpokenDigits, spokenDigitsText, wholeSpokenNumber, registerSendable, sendables, chatTranscript, conversationCopy, CONVERSATION_KEY, };
42
+ export { continuationSafetyProtocol, cancelFormTask, contextualResponseProtocol, validateFormResponse, hasFormResponse, formProposalPolicy, stageFormProposal, nextFormProposal, formProposalReadings, bindFormProposal, retireStaleFormProposal, decideFormProposal, commitFormProposals, settleFormProposalValidation, formProposalProtocol, validateFormProposalPolicy, validateFormProposalDescriptor, formProposalDescriptor, clearFormMisses, formNoOwner, missFormInput, formMustComplete, formInputPrompt, formUserDescriptionSource, formConcernLine, formAcknowledges, consumeFormFeedback, keepFormLine, deferFormClarification, takeFormClarification, formClarificationKept, clearFormLines, formConversationOutcome, readMoneyAmount, isMoneyAmount, moneyIntentAllows, isPastPaymentStatement, isPartialMoneyAnswer, validateMoneyOptions, takeChoiceOffer, saysConfirmWord, saysNoValue, confirmOutOfOrderLine, matchesChoice, ANSWER_WORDS, CONFIRM_WORDS, isAnswer, isAgentRequest, isExitRequest, isGlobalExit, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice, withoutPromptEcho, readEmail, emailWithoutEnding, emailEnding, emailSaid, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational, normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, yesNoKeys, channelVerb, dateToWords, amountToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readArgument, groundAmount, joinSpokenNumbers, findNumbers, assignNumbers, addressDraft, readInputProfile, formAcceptanceTrace, resolveFormInputs, formInputApplies, formInputFilled, nextFormInput, formInputChain, openFormInstance, validateFormIncompleteOutcome, formIncompleteOutcome, validateFormExhaustion, exhaustFormInput, formInitialReadings, orderFormReadings, proposedFormValues, applyFormValidation, formReadingDependencies, exclusiveFormReadings, enrichFormMatches, expandFormActivations, settleFormActivations, rememberFormArguments, resetFormInputs, hasFormValue, formPath, formValuesEqual, formReadingReady, formReadingRelevant, formPreparation, queueFormReadings, pendingFormReadings, formWorkLimit, answerResetsFormReplays, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance, checkOtp, clearOtp, maskDestination, validateOTP, OTP_EXPIRY_MS, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech, joinSpokenDigits, spokenDigitsText, wholeSpokenNumber, numberAlone, registerSendable, sendables, chatTranscript, conversationCopy, CONVERSATION_KEY, };
43
43
  /** The functions flows call by name, ready to spread into a host's approved functions. */
44
44
  export const STANDARD_FUNCTIONS = {
45
45
  continuationSafetyProtocol, cancelFormTask, contextualResponseProtocol, validateFormResponse, hasFormResponse,
@@ -48,6 +48,6 @@ export const STANDARD_FUNCTIONS = {
48
48
  readMoneyAmount, isMoneyAmount, moneyIntentAllows, isPastPaymentStatement, isPartialMoneyAnswer, validateMoneyOptions, takeChoiceOffer, saysConfirmWord, confirmOutOfOrderLine, matchesChoice, isAnswer, isAgentRequest, isExitRequest, isGlobalExit, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice, withoutPromptEcho,
49
49
  readEmail, emailWithoutEnding, emailEnding, emailSaid, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational,
50
50
  normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, yesNoKeys, channelVerb, dateToWords, amountToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readArgument, groundAmount, joinSpokenNumbers, findNumbers, assignNumbers, addressDraft, readInputProfile, formAcceptanceTrace, resolveFormInputs, formInputApplies, formInputFilled, nextFormInput, formInputChain, openFormInstance, validateFormIncompleteOutcome, formIncompleteOutcome, validateFormExhaustion, exhaustFormInput, formInitialReadings, orderFormReadings, proposedFormValues, applyFormValidation, formReadingDependencies, exclusiveFormReadings, enrichFormMatches, expandFormActivations, settleFormActivations, rememberFormArguments, resetFormInputs, hasFormValue, formPath, formValuesEqual, formReadingReady, formReadingRelevant, formPreparation, queueFormReadings, pendingFormReadings, formWorkLimit, answerResetsFormReplays, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance,
51
- validateOTP, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech, joinSpokenDigits, wholeSpokenNumber,
51
+ validateOTP, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech, joinSpokenDigits, wholeSpokenNumber, numberAlone,
52
52
  registerSendable, sendables, chatTranscript, conversationCopy,
53
53
  };
@@ -1 +1 @@
1
- {"version":3,"file":"match-inputs.d.ts","sourceRoot":"","sources":["../../src/helpers/match-inputs.js"],"names":[],"mappings":"AAoBA;;;;GAIG;AACH,sEAQC;AAoGD;;;GAGG;AACH,sFAiIC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;mHACmH;AAEnH,iEAEC;AAID,gGAQC;AAYD,kDAGC;AAED;;;;;;;GAOG;AACH;;;;SAcC;AACD;;;;;GAKG;AACH;;;;;;;;;;;;;;;;;;;;;;EAaC;AACD;;;;;;;;;;;;;;;;;;;;;;EAeC;AAyDD;;;;;;;;;;;;;;;;;;;;;;;EAiZC"}
1
+ {"version":3,"file":"match-inputs.d.ts","sourceRoot":"","sources":["../../src/helpers/match-inputs.js"],"names":[],"mappings":"AAoBA;;;;GAIG;AACH,sEAQC;AA4ED;;;GAGG;AACH,sFAuIC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;mHACmH;AAEnH,iEAEC;AAID,gGAQC;AAYD,kDAGC;AAED;;;;;;;GAOG;AACH;;;;SAcC;AACD;;;;;GAKG;AACH;;;;;;;;;;;;;;;;;;;;;;EAaC;AACD;;;;;;;;;;;;;;;;;;;;;;EAeC;AAyDD;;;;;;;;;;;;;;;;;;;;;;;EAiZC"}
@@ -8,13 +8,13 @@
8
8
  * Tenant-agnostic shape reading only (the same class as pickChoice / readIdentifier). Conversation behaviour stays in
9
9
  * the flows. Part of jsfe/helpers; imports only siblings.
10
10
  */
11
- import { matchesChoice } from './matches-choice.js';
11
+ import { matchesChoice, answerCore } from './matches-choice.js';
12
12
  import { pickChoice, amountInAnswer, isAmountAnswer, isReaderFiller, ANSWER_WORDS, CONFIRM_WORDS } from './answer.js';
13
- import { readEmail, readPhone, readInternationalPhone, readIdentifier } from './contact.js';
13
+ import { readEmail, readPhone, readInternationalPhone, readIdentifier, emailSpans } from './contact.js';
14
14
  import { readSpokenMoney } from './spoken-money.js';
15
15
  import { readMoneyAmount, isPartialMoneyAnswer } from './money.js';
16
16
  import { pickProviderQuestion } from './form-sources.js';
17
- import { spokenDigitsText, wholeSpokenNumber } from './spoken-digits.js';
17
+ import { spokenDigitsText, wholeSpokenNumber, numberAlone } from './spoken-digits.js';
18
18
  import { DIGIT_RUN, findNumbers, assignNumbers, NUMBER_KINDS, presetValid } from './numbers.js';
19
19
  import { expirationDigits, validateExpiration } from './card-checks.js';
20
20
  /**
@@ -92,34 +92,6 @@ function choiceSpans(raw, words) {
92
92
  }
93
93
  return spans;
94
94
  }
95
- function emailSpans(raw, value) {
96
- const literal = raw.toLowerCase().indexOf(value);
97
- if (literal >= 0)
98
- return [[literal, literal + value.length]];
99
- // Spoken addresses may use at / arroba / dot / punto. Select the shortest source window yielding this address.
100
- const tokens = [...raw.matchAll(/\S+/g)];
101
- if (tokens.length > 128)
102
- return [[0, raw.length]];
103
- for (let size = 1; size <= tokens.length; size++) {
104
- const spans = [];
105
- for (let i = 0; i + size <= tokens.length; i++) {
106
- const a = tokens[i].index, b = tokens[i + size - 1].index + tokens[i + size - 1][0].length;
107
- if (readEmail(raw.slice(a, b)) === value) {
108
- // "juan at gmail" already reads as gmail.com: the spoken ending after it belongs to the same address
109
- let j = i + size;
110
- while (j < tokens.length && /^(?:dot|punto|punt|ponto|com|con|\.com)[.,;:!?]*$/i.test(tokens[j][0]))
111
- j++;
112
- spans.push([a, j > i + size ? tokens[j - 1].index + tokens[j - 1][0].length : b]);
113
- }
114
- else {
115
- // this window is not the address
116
- }
117
- }
118
- if (spans.length)
119
- return spans;
120
- }
121
- return [[0, raw.length]];
122
- }
123
95
  /** Remove independently spent evidence while leaving the original narrative value intact. */
124
96
  function unclaimedSpans(raw, readings) {
125
97
  let spans = [[0, raw.length]];
@@ -254,8 +226,8 @@ export function readInputProfile(profile, answer, isCurrent = true) {
254
226
  let fits = [...new Set(digitRuns(source).filter((d) => d.length >= min && d.length <= max))];
255
227
  // At its own question, an answer of digits and separators alone is one number when its length fits ("4111, 1111,
256
228
  // 1111, 1111": a card read in groups of four).
257
- const whole = source.replace(/\D/g, '');
258
- if (!fits.length && isCurrent && /^[\d\s.,-]+$/.test(source.trim()) && whole.length >= min && whole.length <= max) {
229
+ const whole = numberAlone(source);
230
+ if (!fits.length && isCurrent && whole && whole.length >= min && whole.length <= max) {
259
231
  fits = [whole];
260
232
  }
261
233
  else { /* read by runs */ }
@@ -267,8 +239,13 @@ export function readInputProfile(profile, answer, isCurrent = true) {
267
239
  }
268
240
  }
269
241
  else if (kind === 'pattern') {
242
+ // The pattern reads the answer without punctuation at its edges, as speech-to-text adds it ("3 noches.", "¿3 noches?");
243
+ // profile.raw_answer: true reads the answer as given (free text whose value is the caller's whole sentence).
270
244
  // spoken_digits: the pattern reads a number said in pieces as one number ("5 0 9 Lazy Lane", "apt 2 0 4").
271
- const said = profile.spoken_digits ? spokenDigitsText(raw, profile.spoken_digits) : { text: raw, at: (i) => i };
245
+ const core = profile.raw_answer === true ? { text: raw, start: 0 } : answerCore(raw);
246
+ const spoken = (text) => (profile.spoken_digits ? spokenDigitsText(text, profile.spoken_digits) : { text, at: (i) => i });
247
+ const inner = spoken(core.text);
248
+ const said = { text: inner.text, at: (i) => core.start + inner.at(i) };
272
249
  let m = null;
273
250
  try {
274
251
  m = new RegExp(profile.regex, profile.flags || 'i').exec(said.text);
@@ -282,7 +259,8 @@ export function readInputProfile(profile, answer, isCurrent = true) {
282
259
  return { value: v, spans: [[said.at(start), said.at(start + v.length - 1) + 1]], evidence: [`p:${String(v).toLowerCase()}`] };
283
260
  }
284
261
  else {
285
- return isCurrent && profile.accept_other === true && raw.trim() ? { value: said.text.trim(), fallback: true, spans: [[0, raw.length]] } : null;
262
+ // accept_other keeps the answer as given, as before
263
+ return isCurrent && profile.accept_other === true && raw.trim() ? { value: spoken(raw).text.trim(), fallback: true, spans: [[0, raw.length]] } : null;
286
264
  }
287
265
  }
288
266
  else if (kind === 'text') {
@@ -446,7 +424,7 @@ function digitsSpan(raw, value, from) {
446
424
  // asked input a complete value beside at least one other input and consumes every digit; otherwise null and the answer reads
447
425
  // as before (a card said in groups, a card spoken over two turns, a lone ZIP). → {name: {value, spans}} | null
448
426
  function numericSplit(raw, list, own) {
449
- if (!own || own.profile.kind !== 'digits' || !/^[\d\s.,-]+[.!]?$/.test(raw.trim()))
427
+ if (!own || own.profile.kind !== 'digits' || !numberAlone(raw))
450
428
  return null;
451
429
  const numeric = list.filter((c) => c.form === own.form && !c.confirmation && (NUMBER_KINDS.includes(c.field) || c.profile.kind === 'digits'));
452
430
  if (numeric.length < 2)
@@ -589,7 +567,7 @@ export function matchInputs(answer, candidates, current, choiceKey) {
589
567
  // A choice is excluded (a digit it does not offer reaches the invited amount, rule 4), and so is an amount.
590
568
  const bareDigits = raw.replace(/\D/g, '');
591
569
  const shapeOf = own && own.digits && !['choice', 'amount', 'text'].includes(own.profile.kind) ? own.digits : null;
592
- if (shapeOf && bareDigits && /^[\d\s.,/-]+$/.test(raw.trim()) && !isAmountAnswer(raw) && bareDigits.length >= Number(shapeOf.min || 1) && bareDigits.length <= Number(shapeOf.max || shapeOf.min || 1)
570
+ if (shapeOf && bareDigits && numberAlone(raw, { slash: true }) && !isAmountAnswer(raw) && bareDigits.length >= Number(shapeOf.min || 1) && bareDigits.length <= Number(shapeOf.max || shapeOf.min || 1)
593
571
  && !readings.some((reading) => reading.current || invited(reading))) {
594
572
  readings.push({ form: own.form, name: own.name, value: bareDigits, ...(own.validator ? {} : { invalid: true }), known: false, repeatedChoice: false, wholeChoice: false, choice: false, narrative: false, resetOn: [], spans: [[0, raw.length]], keypad: false, fallback: false,
595
573
  group: own.group, exclusive: own.exclusive === true, level: forms.indexOf(own.scope || own.form), current: true, confirm: Array.isArray(own.confirm_against) ? own.confirm_against : [] });
@@ -1,26 +1,12 @@
1
1
  /**
2
- * Strict word-aware option matching for flow CASE conditions (APPROVED_FUNCTIONS.matchesChoice) —
3
- * replaces the substring `.some(choice => input.includes(choice))` idiom, whose false positives broke
4
- * branch routing ('si' inside "imposible"/"así" matched YES, prod-observed 2026-08-09).
5
- *
6
- * Rules (deliberately NO fuzzy/prefix matching):
7
- * - single-word choice: exact word membership
8
- * - multi-word choice: exact word-sequence containment
9
- * - plurals/inflections: enumerate them explicitly in the choice list
10
- * - a keypad key (one digit, * or #) matches ONLY an answer that is exactly that key, never a key
11
- * inside a longer answer (owner rule): "I made payments by 1," at "press 1 to pay" charged the full
12
- * amount due on dev, 2026-10-14
13
- * - an ELONGATED word the user typed is forgiven (2026-10-01): a repeated vowel or any letter typed
14
- * 3+ times collapses — "Sii" matches 'si', "nadaaaa" 'nada', "yesss" 'yes'. A typed "Sii" at the
15
- * authentication retry menu ended the conversation in contact-support. Only the user's word is
16
- * collapsed, and only against an option word with no doubled letter of its own. Measured on a
17
- * week of prod prompts (scratch replay, 98 option lists × 23,692 prompts):
18
- * · collapsing BOTH sides: rejected — 'all' → 'al' made "servicio al cliente" (138 turns) pick
19
- * the "all" option, and 'mm' → 'm' made "I'm" a filler;
20
- * · collapsing every doubled letter of the user's word: rejected — "mess" matched Spanish
21
- * 'mes' and "Mall" 'mal'. A doubled consonant is real spelling, so "okk" stays unmatched.
22
- *
23
- * Zero imports, so scripts/tests/matches-choice.mjs runs the real implementation.
2
+ * The answer without punctuation at its edges, and where that core starts in the answer: {text, start}.
3
+ * questions: true also removes ? and ¿ (matchesChoice's keypad keys, as before: "1?" is the key 1).
24
4
  */
5
+ export function answerCore(input: any, { questions }?: {
6
+ questions?: boolean | undefined;
7
+ }): {
8
+ text: string;
9
+ start: number;
10
+ };
25
11
  export function matchesChoice(input: any, choices: any): boolean;
26
12
  //# sourceMappingURL=matches-choice.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"matches-choice.d.ts","sourceRoot":"","sources":["../../src/helpers/matches-choice.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,iEAiCC"}
1
+ {"version":3,"file":"matches-choice.d.ts","sourceRoot":"","sources":["../../src/helpers/matches-choice.js"],"names":[],"mappings":"AA8BA;;;GAGG;AACH;;;;;EAIC;AAED,iEAiCC"}
@@ -22,6 +22,20 @@
22
22
  *
23
23
  * Zero imports, so scripts/tests/matches-choice.mjs runs the real implementation.
24
24
  */
25
+ // Punctuation and spaces at an answer's edges, as speech-to-text adds them ("3 noches.", "California,"). A question mark
26
+ // stays: a question is not an answer ("¿No es en diciembre?" at the return date). Quotes stay: a quoted command is not
27
+ // the caller's own (speech-to-text adds none).
28
+ const ANSWER_EDGES = /^[\s.,;:!¡]+|[\s.,;:!¡]+$/g;
29
+ const ANSWER_EDGES_AND_QUESTION = /^[\s.,;:!?¿¡'"]+|[\s.,;:!?¿¡'"]+$/g;
30
+ /**
31
+ * The answer without punctuation at its edges, and where that core starts in the answer: {text, start}.
32
+ * questions: true also removes ? and ¿ (matchesChoice's keypad keys, as before: "1?" is the key 1).
33
+ */
34
+ export function answerCore(input, { questions = false } = {}) {
35
+ const raw = String(input ?? '');
36
+ const text = raw.replace(questions ? ANSWER_EDGES_AND_QUESTION : ANSWER_EDGES, '');
37
+ return { text, start: text ? raw.indexOf(text) : 0 };
38
+ }
25
39
  export function matchesChoice(input, choices) {
26
40
  if (!input || !Array.isArray(choices)) {
27
41
  return false;
@@ -40,7 +54,7 @@ export function matchesChoice(input, choices) {
40
54
  return choices.some(choice => {
41
55
  const choiceWords = tokenize(choice);
42
56
  if (/^[0-9*#]$/.test(String(choice).trim())) {
43
- return String(input).replace(/^[\s.,;:!?¿¡'"]+|[\s.,;:!?¿¡'"]+$/g, '') === String(choice).trim();
57
+ return answerCore(input, { questions: true }).text === String(choice).trim();
44
58
  }
45
59
  else if (choiceWords.length === 0) {
46
60
  return false;
@@ -6,7 +6,16 @@ export function spokenDigitsText(input: any, mode?: boolean): {
6
6
  export function joinSpokenDigits(input: any, mode?: boolean): string;
7
7
  /**
8
8
  * A whole answer that is one number said digit by digit reads as that number: "6 5 4 6", "6, 5, 4, 6.", "6-5-4-6", "6. 5. 4. 6.".
9
- * Anything else comes back as it was. A period with no space after it stays a decimal point ("4.5").
9
+ * Punctuation at its edges aside (answerCore). Anything else comes back as it was. A period with no space after it stays a
10
+ * decimal point ("4.5").
10
11
  */
11
12
  export function wholeSpokenNumber(input: any): string;
13
+ /**
14
+ * The one test of "this answer is a number alone" (owner 2026-11-24): digits and the separators speech-to-text puts between
15
+ * them (spaces, . , -; with slash: true also /, as in "07/29"), punctuation at the answer's edges aside (answerCore: "4111,
16
+ * 1111, 1111, 1111.", "799604!"). A question mark is not an edge: "1234?" is not a number alone. → its digits, or ''.
17
+ */
18
+ export function numberAlone(input: any, { slash }?: {
19
+ slash?: boolean | undefined;
20
+ }): string;
12
21
  //# sourceMappingURL=spoken-digits.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spoken-digits.d.ts","sourceRoot":"","sources":["../../src/helpers/spoken-digits.js"],"names":[],"mappings":"AAoBA,mHAAmH;AACnH;;;EAyBC;AAED,qEAEC;AAED;;;GAGG;AACH,sDAGC"}
1
+ {"version":3,"file":"spoken-digits.d.ts","sourceRoot":"","sources":["../../src/helpers/spoken-digits.js"],"names":[],"mappings":"AAsBA,mHAAmH;AACnH;;;EAyBC;AAED,qEAEC;AAED;;;;GAIG;AACH,sDAIC;AAED;;;;GAIG;AACH;;WAGC"}
@@ -4,8 +4,9 @@
4
4
  * A dash joins only single digits: "12-34 Main St" is a hyphenated house number, not a pause.
5
5
  *
6
6
  * mode true: any run of groups of up to three digits. mode 'house_number': the first group has at most two digits,
7
- * because "509 12 Ave" is a house number and a numbered street. Part of jsfe/helpers; zero imports.
7
+ * because "509 12 Ave" is a house number and a numbered street. Part of jsfe/helpers.
8
8
  */
9
+ import { answerCore } from './matches-choice.js';
9
10
  const RUN = /(?<![\w.,-])\d{1,3}(?:(?:[ \t]+|,\s*|\.\s+|-)\d{1,3})+(?![\w-])/g;
10
11
  const joins = (run, mode) => {
11
12
  const groups = run.split(/\D+/);
@@ -59,9 +60,20 @@ export function joinSpokenDigits(input, mode = true) {
59
60
  }
60
61
  /**
61
62
  * A whole answer that is one number said digit by digit reads as that number: "6 5 4 6", "6, 5, 4, 6.", "6-5-4-6", "6. 5. 4. 6.".
62
- * Anything else comes back as it was. A period with no space after it stays a decimal point ("4.5").
63
+ * Punctuation at its edges aside (answerCore). Anything else comes back as it was. A period with no space after it stays a
64
+ * decimal point ("4.5").
63
65
  */
64
66
  export function wholeSpokenNumber(input) {
65
67
  const text = String(input ?? '');
66
- return /^\s*\d(?:(?:\s+|,\s*|-|\.\s+)\d)+[\s.]*$/.test(text) ? text.replace(/\D/g, '') : text;
68
+ const core = answerCore(text).text;
69
+ return /^\d(?:(?:\s+|,\s*|-|\.\s+)\d)+$/.test(core) ? core.replace(/\D/g, '') : text;
70
+ }
71
+ /**
72
+ * The one test of "this answer is a number alone" (owner 2026-11-24): digits and the separators speech-to-text puts between
73
+ * them (spaces, . , -; with slash: true also /, as in "07/29"), punctuation at the answer's edges aside (answerCore: "4111,
74
+ * 1111, 1111, 1111.", "799604!"). A question mark is not an edge: "1234?" is not a number alone. → its digits, or ''.
75
+ */
76
+ export function numberAlone(input, { slash = false } = {}) {
77
+ const core = answerCore(input).text;
78
+ return (slash ? /^[\d\s.,\/-]*\d[\d\s.,\/-]*$/ : /^[\d\s.,-]*\d[\d\s.,-]*$/).test(core) ? core.replace(/\D/g, '') : '';
67
79
  }
@@ -1 +1 @@
1
- export const JSFE_RUNTIME_FINGERPRINT = "sha256:df2aef8397134376b8abc730555c4de6ba14116f1953c16067c0d88fc5423857";
1
+ export const JSFE_RUNTIME_FINGERPRINT = "sha256:12b7415283ddd8f6d0f359c9a16e568cdb7d0c22f756fb1d76963213d6eaa3c7";
@@ -199,7 +199,7 @@ Profiles:
199
199
  | `choice` | `choices:[{key,phrases,label?,label_es?,keys?,exact?,neutral?,negative?,current_only?}]`; optional `accept_other` (with `other_needs_letter`: other text only with a letter, such as a city; with `other_needs_digit`: only with a digit, such as an account number, so a word that is no choice goes to the reply ranker), `numeric_values`, `narrative`, `whole_phrases`, `template_words`. |
200
200
  | `digits` | `min`, `max`: one unambiguous digit run of that length. |
201
201
  | `identifier` | `pattern`: permitted account identifier shape. |
202
- | `pattern` | `regex`, optional `flags`, `group`; optional `accept_other` for the current field only, `whole_phrases`, `template_words`; `spoken_digits` (`true`, or `'house_number'` when a numbered street can follow) reads a number said in pieces as one number ("5 0 9 Lazy Lane", "apt 2 0 4"), required on any pattern that reads digits. |
202
+ | `pattern` | `regex`, optional `flags`, `group`; optional `accept_other` for the current field only, `whole_phrases`, `template_words`; `spoken_digits` (`true`, or `'house_number'` when a numbered street can follow) reads a number said in pieces as one number ("5 0 9 Lazy Lane", "apt 2 0 4"), required on any pattern that reads digits. The regex reads the answer without spaces and `. , ; : ! ¡` at its edges ("3 noches." reads as "3 noches"); `?`, `¿` and quotes stay: a question is not an answer, and a quoted command is not the caller's own. `raw_answer: true` reads the answer as given, for free text whose value is the caller's whole sentence. |
203
203
  | `phone`, `email` | Typed readers; email `literal:true` preserves an explicit visible address token in surrounding prose. An email at hotmail, yahoo, outlook, icloud or aol said without its ending is held and only the ending is asked ("What comes after yahoo? For example, dot com."); the ending alone completes it, any other reply drops it. gmail is completed as gmail.com; an unknown domain is never guessed. |
204
204
  | `amount` | `min`, `max`, optional `marked:true` or `marked:"out_of_order"`; optional `money:{currency:"USD",cardinals:true,intent:"payment"}`. |
205
205
  | `text` | Current-field text fallback; `narrative:true` retains a substantive answer alongside independent structured fields. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsfe",
3
- "version": "1.89.0",
3
+ "version": "1.91.0",
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",