jsfe 1.102.0 → 1.103.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.
@@ -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,0CAYC;AACD,qHAQC;AASD,qHAAqH;AACrH,6FAKC;AACD,4EAYC;AAED;;kGAEkG;AAClG,0FASC;AAED;kIACkI;AAClI;;;;SAUC;AAiID,2DAOC;AACD,4DAOC;AACD,gHAAgH;AAChH,8DAGC;AAkKD,8EAGC;AAgCD,4FAA4F;AAC5F;;;;EAOC;AAYD,oGAOC;AAlRD,iCAAgC,wIAAwI,CAAC;AACzK,wCAAuC,CAAC,CAAC;AAqSzC,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,0CAYC;AACD,qHAQC;AASD,qHAAqH;AACrH,6FAKC;AACD,4EAYC;AAED;;kGAEkG;AAClG,0FASC;AAED;kIACkI;AAClI;;;;SAUC;AAiID,2DAOC;AACD,4DAOC;AACD,gHAAgH;AAChH,8DAGC;AAyKD,8EAGC;AAgCD,4FAA4F;AAC5F;;;;EAOC;AAYD,oGAOC;AAzRD,iCAAgC,wIAAwI,CAAC;AACzK,wCAAuC,CAAC,CAAC;AA4SzC,0BAAsK"}
@@ -378,17 +378,23 @@ function otpPhoneUnavailable(value) {
378
378
  // offered only where the step offers them (a code sent by text; a caller-ID preselection).
379
379
  const OTP_REPLY_CHOICES = [{ key: 'email', label: 'use the email on the account instead of the phone' }, { key: 'another_account', label: 'use another account' }, { key: 'no_other_account', label: 'says they have no other account, this is their only one' },
380
380
  { key: 'where', label: 'asks where the code was sent' }, { key: 'cannot_find', label: 'looked for the code and cannot find or see it' }, { key: 'another_way', label: 'asks for another way to get the code or to verify' }, { key: 'resend', label: 'says they have not received the code, or asks for it to be sent again' }, { key: 'has_code', label: 'has the code now or is getting it (here it is, one moment, let me look)' }, { key: 'no_phone', label: 'no longer has that phone or number' }, { key: '__agent', label: 'speak with a person (a live agent)' }];
381
- const validateCode = worker('validate-otp-code', 'ValidateOtpCode', 'Validate a challenge response with explicit bounded retries, alternate-contact handling and tenant callbacks.', { loopBound: '3 mismatches, 3 format misses, 2 resends, 3 sends per contact', variables: vars({ otp_phrases: OTP_WORDS, email_too: false, no_code_given: false, wants_other_account: false, other_account_given: false, otp_validation_result: false, whatsapp_invite_sent: false, invite_text: '', otp_cancel: 'contact-support', answer_key: '', answer_value: '', otp_reply_choices: OTP_REPLY_CHOICES, otp_offers: [], otp_reply: {}, otp_where: '', otp_where_es: '' }), contract: { role: 'gate', summary: 'Validate the active one-time challenge', tools: ['validate-otp', 'send-whatsapp-invite'], result: { path: 'cargo.otpVerified', type: 'boolean' } }, steps: [
381
+ const validateCode = worker('validate-otp-code', 'ValidateOtpCode', 'Validate a challenge response with explicit bounded retries, alternate-contact handling and tenant callbacks.', { loopBound: '3 mismatches, 3 format misses, 2 resends, 3 sends per contact', variables: vars({ otp_phrases: OTP_WORDS, email_too: false, no_code_given: false, wants_other_account: false, other_account_given: false, otp_validation_result: false, whatsapp_invite_sent: false, invite_text: '', otp_cancel: 'contact-support', answer_key: '', answer_value: '', otp_reply_choices: OTP_REPLY_CHOICES, otp_offers: [], otp_reply: {}, otp_where: '', otp_where_es: '', otp_last_six: '', otp_last_six_ok: false }), contract: { role: 'gate', summary: 'Validate the active one-time challenge', tools: ['validate-otp', 'send-whatsapp-invite'], result: { path: 'cargo.otpVerified', type: 'boolean' } }, steps: [
382
382
  set('otp_cancel', 'otp_cancel', "cargo.authCancelFlow || 'contact-support'"),
383
383
  set('otp_email_too_ready', 'email_too', "!!(cargo.otp_cell_number && cargo.otpAltSent !== true && cargo.otpAltSent !== 'failed' && validateEmail(String(cargo.otpAltEmail || '')))"),
384
384
  set('otp_reset_no_code', 'no_code_given', 'false'), set('otp_reset_invite', 'whatsapp_invite_sent', 'false'), set('otp_reset_callback', 'answer_key', "''"),
385
- when('otp_tenant_code', 'cargo.authOptions && cargo.authOptions.code_validator && String(user_choice).replace(/\\D/g,\'\').length !== 6 && /[0-9]/.test(user_choice)', call('otp_tenant_code_call', '{{cargo.authOptions.code_validator}}', { answer: '{{user_choice}}' })),
385
+ // Seven or eight digits: the last six are tried as the code before the tenant reads the digits (owner 2026-12-05; prod
386
+ // 12-04 'Código 5 5 3 2 4 2 4' was looked up as an account and a stranger got a code). A match verifies; a miss goes on as before.
387
+ set('otp_last_six', 'otp_last_six', "/^\\d{7,8}$/.test(normalized_otp_code) ? normalized_otp_code.slice(-6) : ''"), set('otp_last_six_reset', 'otp_last_six_ok', 'false'),
388
+ when('otp_last_six_try', '!!otp_last_six', { id: 'otp_last_six_tool', type: 'CALL-TOOL', tool: 'validate-otp', variable: 'otp_last_six_ok', args: { otp: '{{otp_last_six}}', container: '{{cargo}}' }, onFail: set('otp_last_six_failed', 'otp_last_six_ok', 'false') }),
389
+ set('otp_last_six_code', 'normalized_otp_code', "otp_last_six_ok === true ? otp_last_six : normalized_otp_code"),
390
+ when('otp_tenant_code', 'cargo.authOptions && cargo.authOptions.code_validator && String(user_choice).replace(/\\D/g,\'\').length !== 6 && /[0-9]/.test(user_choice) && otp_last_six_ok !== true', call('otp_tenant_code_call', '{{cargo.authOptions.code_validator}}', { answer: '{{user_choice}}' })),
386
391
  set('otp_other_given', 'other_account_given', "answer_key === 'another_account' ? (cargo.authOtherAccount=String(answer_value || ''),true) : false"),
387
392
  set('otp_other_requested', 'wants_other_account', 'other_account_given || !!(cargo.callerPreselected && normalized_otp_code.length !== 6 && ((cargo.authOptions && cargo.authOptions.other_whole_answer ? pickChoice(user_choice,[{key:\'other\',phrases:otp_phrases.other,exact:true}],false) === \'other\' : matchesChoice(user_choice,otp_phrases.other)) || otp_phrases.other_alone.includes(user_choice.replace(/[.,!?¡¿]/g,\'\').trim())))'),
388
393
  when('otp_tenant_answer', 'cargo.authOptions && cargo.authOptions.answer_handler && normalized_otp_code.length !== 6 && !wants_other_account && answer_key !== \'code_notice\'', call('otp_tenant_answer_call', '{{cargo.authOptions.answer_handler}}', { answer: '{{user_choice}}' })),
389
394
  set('otp_where_early', 'otp_where', expression(otpWhere, 'cargo')), set('otp_where_early_es', 'otp_where_es', expression(otpWhere, 'cargo', 'true')),
390
395
  cases('otp_response', {
391
396
  // The tenant's reading of the digits comes first (owner 2026-11-18: a real account number is taken before a code is tried).
397
+ "condition: otp_last_six_ok === true": effect('otp_last_six_verified', 'true'),
392
398
  "condition: normalized_otp_code.length === 6 && answer_key !== 'another_account' && answer_key !== 'code_notice'": { id: 'otp_check_tool', type: 'CALL-TOOL', tool: 'validate-otp', variable: 'otp_validation_result', args: { otp: '{{normalized_otp_code}}', container: '{{cargo}}' }, onFail: call('otp_check_failed', 'get-and-validate-otp-code', undefined, 'replace') },
393
399
  'condition: wants_other_account': toParent(call('otp_change_account', 'authenticate-user', { cell_number: '', email: '', retrying: true, declined_caller: true }, 'replace')),
394
400
  // Email asked for at a code sent by text: authentication is an input step, so the contact question is asked again
@@ -443,7 +449,8 @@ const validateCode = worker('validate-otp-code', 'ValidateOtpCode', 'Validate a
443
449
  default: effect('otp_reply_route_none', 'true')
444
450
  }),
445
451
  effect('otp_word_count', '(cargo.otpWordMisses=Number(cargo.otpWordMisses || 0)+(no_code_given?1:0),true)'),
446
- when('otp_word_cap', 'no_code_given && cargo.otpWordMisses >= 3', verificationEnd('otp_word_end')),
452
+ // Words alone end it at the sixth reply (owner 2026-12-04): at the third, callers still getting or saying the code lost it.
453
+ when('otp_word_cap', 'no_code_given && cargo.otpWordMisses >= 6', verificationEnd('otp_word_end')),
447
454
  // a reason for the call authentication serves is acknowledged: verification comes first
448
455
  when('otp_usecase_ack', "no_code_given && otp_reply && String(otp_reply.key || '').indexOf('usecase:') === 0", say('otp_usecase_explain', 'Understood. First we need to finish verifying your identity. I sent you a message with a six-digit code in it. Read those six digits back to me. You can also {{cargo.verb}} EXIT to cancel.', "Entendido. Primero necesitamos completar la verificación de su identidad. Le envié un mensaje con un código de seis dígitos. Dígame esos seis dígitos. También puede {{cargo.voice ? 'decir' : 'escribir'}} SALIR para cancelar.")),
449
456
  when('otp_explanation', "no_code_given && !(no_code_given && otp_reply && String(otp_reply.key || '').indexOf('usecase:') === 0)", say('otp_explain', 'Let me explain. I sent you a message with a six-digit code in it. Read those six digits back to me. You can also {{cargo.verb}} EXIT to cancel.', "Le explico. Le envié un mensaje con un código de seis dígitos. Dígame esos seis dígitos. También puede {{cargo.voice ? 'decir' : 'escribir'}} SALIR para cancelar.")),
@@ -1 +1 @@
1
- {"version":3,"file":"send-copy-flow.d.ts","sourceRoot":"","sources":["../../src/forms/send-copy-flow.js"],"names":[],"mappings":"AAwOA,0BAAmD"}
1
+ {"version":3,"file":"send-copy-flow.d.ts","sourceRoot":"","sources":["../../src/forms/send-copy-flow.js"],"names":[],"mappings":"AAqPA,0BAAmD"}
@@ -15,9 +15,12 @@
15
15
  * - The web chat link (WEB_LINK_KEY, owner 2026-11-26: "can I continue this on my computer?") is made at send time by the
16
16
  * host's get-web-chat-link tool. With no medium or destination named it is texted to the caller's number, else emailed to
17
17
  * the email on file, else the medium is asked; any number or email the caller names is used, as for any item.
18
- * - Any item to a target that is not the caller's own (their phone, the verified cell, the email on file) is read back and
19
- * sent only on YES, with a warning for the web link, the whole conversation, or a registered document that declares a
20
- * disclaimer (owner 2026-11-26: anything in the chat may be sensitive). A sender item's own flow gates its destination.
18
+ * - The email on file is a verified customer's only: cargo.accountEmail, which the tenant sets from the verified account, else
19
+ * the address the code went to. It is offered in full when no address was given (owner 2026-12-03).
20
+ * - Any item to a target that is not the caller's own (their phone, the verified cell, the email on file) is read back once and
21
+ * sent only on YES: ask-email's read-back is that question for an address it collected, and a second one is asked only when
22
+ * the item has a warning (owner 2026-12-03): the web link, the whole conversation, or a registered document that declares
23
+ * a disclaimer (owner 2026-11-26: anything in the chat may be sensitive). A sender item's own flow gates its destination.
21
24
  * No authentication gate here (owner rule: an authenticated caller's chat and documents are theirs to send anywhere;
22
25
  * before authentication no reply holds account data). A sender flow gates its own document.
23
26
  */
@@ -43,7 +46,7 @@ const sendCopy = defineWorker({
43
46
  contract: { role: 'router', summary: 'Sends a reply, registered document, the whole conversation or a link to continue it on the web, as the caller picks, by text or email, through the system send workers or the document\'s sender flow' },
44
47
  id: 'send-copy',
45
48
  name: 'SendCopy',
46
- version: '1.3.0',
49
+ version: '1.4.0',
47
50
  primary: true,
48
51
  prompt: 'Send a copy',
49
52
  prompt_es: 'Enviar una copia',
@@ -57,7 +60,7 @@ const sendCopy = defineWorker({
57
60
  ],
58
61
  variables: vars({
59
62
  noop: false, sc_items: [], sc_key: '', sc_item: null, sc_last: null, sc_last_head: '', sc_offer_q: '', sc_offer_q_es: '', sc_doc_list: '', sc_email: '', sc_phone: '',
60
- sc_medium: '', sc_medium_q: '', sc_medium_q_es: '', sc_given: '', sc_other: false, sc_too_long: false, sc_media: [], sc_forced: '', sc_to: '', sc_subject: '', sc_content: '', sc_sent: false, sc_link: '', sc_trusted: true, sc_warning: '', sc_warning_es: '', sc_target: '', sc_confirm_q: '', sc_confirm_q_es: '',
63
+ sc_medium: '', sc_medium_q: '', sc_medium_q_es: '', sc_given: '', sc_other: false, sc_too_long: false, sc_media: [], sc_forced: '', sc_to: '', sc_subject: '', sc_content: '', sc_sent: false, sc_link: '', sc_on_file: '', sc_account_email: false, sc_email_q: '', sc_email_q_es: '', sc_read_back: false, sc_ask: false, sc_warning: '', sc_warning_es: '', sc_target: '', sc_confirm_q: '', sc_confirm_q_es: '',
61
64
  }),
62
65
  steps: [
63
66
  set('sc_items', 'sc_items', 'sendables(cargo)'),
@@ -89,9 +92,12 @@ const sendCopy = defineWorker({
89
92
  set('sc_email', 'sc_email', `${EMAIL_IN_JS}(typeof destination === 'string' ? destination : '')`),
90
93
  set('sc_phone', 'sc_phone', "readPhone(typeof destination === 'string' ? destination : '')"),
91
94
  set('sc_medium', 'sc_medium', "typeof medium === 'string' && (medium === 'text' || medium === 'email') ? medium : sc_email ? 'email' : sc_phone ? 'text' : ''"),
95
+ // the email on file: the verified account's, else the address the verification code went to
96
+ set('sc_on_file', 'sc_on_file', "cargo.otpVerified === true ? [cargo.accountEmail, cargo.otp_email].map(function (e) { return String(e || '').trim(); }).find(function (e) { return validateEmail(e); }) || '' : ''"),
97
+ set('sc_account_email', 'sc_account_email', "!!sc_on_file && sc_on_file === String(cargo.accountEmail || '').trim()"),
92
98
  // the web chat link: texted to the caller's number when nothing was named, else emailed to the email on file
93
99
  when('sc_link_text', "sc_item.kind === 'web_link' && !sc_medium && !!cargo.twilioNumber && !!textDestination(cargo)", set('sc_link_text_set', 'sc_medium', "'text'")),
94
- when('sc_link_email', "sc_item.kind === 'web_link' && !sc_medium && validateEmail(String(cargo.otp_email || ''))", set('sc_link_email_set', 'sc_email', 'String(cargo.otp_email)')),
100
+ when('sc_link_email', "sc_item.kind === 'web_link' && !sc_medium && !!sc_on_file", set('sc_link_email_set', 'sc_email', 'sc_on_file')),
95
101
  when('sc_link_email_medium', "sc_item.kind === 'web_link' && !sc_medium && !!sc_email", set('sc_link_email_medium_set', 'sc_medium', "'email'")),
96
102
  when('sc_link', "sc_item.kind === 'web_link'", { id: 'sc_link_call', type: 'CALL-TOOL', tool: 'get-web-chat-link', variable: 'sc_link', args: {}, onFail: set('sc_link_failed', 'sc_link', "''") }),
97
103
  when('sc_link_none', "sc_item.kind === 'web_link' && !sc_link", say('sc_link_none_say', "Sorry, I couldn't make a link to continue on the web." + ANYTHING_ELSE, 'Lo siento, no pude crear un enlace para continuar en la web.' + ANYTHING_ELSE_ES)),
@@ -138,7 +144,9 @@ const sendCopy = defineWorker({
138
144
  question: 'What email address should I send it to?', question_es: '¿A qué correo electrónico se lo envío?', on_file: '',
139
145
  })),
140
146
  when('sc_other_email_read', "sc_other && sc_medium === 'email'", set('sc_other_email_set', 'sc_email', "cargo.email && validateEmail(String(cargo.email)) ? String(cargo.email) : ''")),
141
- when('sc_other_email_end', "sc_other && sc_medium === 'email' && !sc_email", end('sc_other_email_done')),
147
+ when('sc_other_email_heard', "sc_other && sc_medium === 'email'", set('sc_other_email_read_back', 'sc_read_back', 'true')),
148
+ when('sc_other_email_bad', "sc_other && sc_medium === 'email' && !sc_email", say('sc_other_email_bad_say', "Sorry, I couldn't read that email address, so I didn't send it." + ANYTHING_ELSE, 'Lo siento, no pude entender ese correo electrónico, así que no lo envié.' + ANYTHING_ELSE_ES)),
149
+ when('sc_other_email_end', "sc_other && sc_medium === 'email' && !sc_email", end('sc_other_email_done', { outcome: 'unresolved', reason: 'no_email' })),
142
150
  // a sender item: its flow collects what it needs (destination, identity) and tells the caller every outcome
143
151
  set('sc_given', 'sc_given', "sc_medium === 'email' ? sc_email : sc_phone"),
144
152
  when('sc_sender_reset', '!!sc_item.sender', effect('sc_sender_reset_set', 'cargo.copyHandled = false')),
@@ -160,25 +168,30 @@ const sendCopy = defineWorker({
160
168
  when('sc_number_bad', "sc_medium === 'text' && !cargo.textTo", say('sc_number_bad_say', "Sorry, I couldn't read that phone number." + ANYTHING_ELSE, 'Lo siento, no pude entender ese número de teléfono.' + ANYTHING_ELSE_ES)),
161
169
  when('sc_number_bad_end', "sc_medium === 'text' && !cargo.textTo", end('sc_number_bad_done', { outcome: 'unresolved', reason: 'no_phone_number' })),
162
170
  when('sc_text_four', "sc_medium === 'text'", effect('sc_text_four_set', 'cargo.textTo4 = last4(cargo.textTo, cargo.voice)')),
163
- // email: the address given, else asked (the verified email offered)
171
+ // email: the address given, else asked, offering the email on file
164
172
  set('sc_to', 'sc_to', "sc_medium === 'email' && sc_email && validateEmail(sc_email) ? sc_email : ''"),
165
173
  when('sc_email_clear', "sc_medium === 'email' && !sc_to", effect('sc_email_clear_set', "cargo.email = ''")),
174
+ set('sc_email_q', 'sc_email_q', "!sc_on_file ? 'What email address should I send it to?' : \"I'll email it to \" + emailSaid(sc_on_file, cargo.voice) + (sc_account_email ? ', the email on your account' : '') + (cargo.voice ? '. Press 1 or say OK to send it, or say a different email address.' : '. Type OK to send it, or type a different email address.')"),
175
+ set('sc_email_q_es', 'sc_email_q_es', "!sc_on_file ? '¿A qué correo electrónico se lo envío?' : 'Se lo enviaré a ' + emailSaid(sc_on_file, cargo.voice, true) + (sc_account_email ? ', el correo de su cuenta' : '') + (cargo.voice ? '. Presione 1 o diga OK para enviarlo, o diga otro correo electrónico.' : '. Escriba OK para enviarlo, o escriba otro correo electrónico.')"),
166
176
  when('sc_ask_email', "sc_medium === 'email' && !sc_to", call('sc_ask_email_call', 'ask-email', {
167
- question: 'What email address should I send it to?',
168
- question_es: '¿A qué correo electrónico se lo envío?',
169
- on_file: '{{cargo.otp_email}}',
177
+ question: '{{sc_email_q}}',
178
+ question_es: '{{sc_email_q_es}}',
179
+ on_file: '{{sc_on_file}}',
170
180
  })),
181
+ when('sc_email_heard', "sc_medium === 'email' && !sc_to", set('sc_email_read_back', 'sc_read_back', 'true')),
171
182
  when('sc_email_read', "sc_medium === 'email' && !sc_to", set('sc_email_pick', 'sc_to', "cargo.email && validateEmail(String(cargo.email)) ? String(cargo.email) : ''")),
172
- when('sc_email_none_end', "sc_medium === 'email' && !sc_to", end('sc_email_none_done')),
173
- // a target that is not the caller's own (their phone, the verified cell, the email on file): read back, with the item's
174
- // warning when it has one (the web link, the whole conversation, a registered document's disclaimer), sent only on YES
175
- set('sc_trusted', 'sc_trusted', "(sc_medium === 'email' ? sc_to.toLowerCase() === String(cargo.otp_email || '').trim().toLowerCase() : [cargo.callerId, cargo.otp_cell_number].map(function (n) { return String(n || '').replace(/\\D/g, '').slice(-10); }).filter(function (n) { return n.length === 10; }).indexOf(String(cargo.textTo || '').replace(/\\D/g, '').slice(-10)) >= 0)"),
176
- when('sc_warning', '!sc_trusted', set('sc_warning_set', 'sc_warning', "sc_item.kind === 'web_link' ? 'This link opens our conversation, including any account details, for whoever has it. ' : sc_item.kind === 'conversation' ? 'This is our whole conversation, including any account details. ' : sc_item.disclaimer ? String(sc_item.disclaimer) + ' ' : ''")),
177
- when('sc_warning_es', '!sc_trusted', set('sc_warning_es_set', 'sc_warning_es', "sc_item.kind === 'web_link' ? 'Este enlace abre nuestra conversación, incluidos los datos de su cuenta, para quien lo tenga. ' : sc_item.kind === 'conversation' ? 'Es toda nuestra conversación, incluidos los datos de su cuenta. ' : sc_item.disclaimer ? String(sc_item.disclaimer_es || sc_item.disclaimer) + ' ' : ''")),
178
- when('sc_target', '!sc_trusted', set('sc_target_set', 'sc_target', "sc_medium === 'email' ? sc_to : String(cargo.textTo || '').replace(/\\D/g, '').slice(-10).replace(/^(\\d{3})(\\d{3})(\\d{4})$/, '($1) $2-$3')")),
179
- when('sc_confirm_q', '!sc_trusted', set('sc_confirm_q_set', 'sc_confirm_q', "sc_warning + 'Should I send it to ' + sc_target + '? ' + yesNoKeys('en', cargo)")),
180
- when('sc_confirm_q_es', '!sc_trusted', set('sc_confirm_q_es_set', 'sc_confirm_q_es', "sc_warning_es + '¿Se lo envío a ' + sc_target + '? ' + yesNoKeys('es', cargo)")),
181
- when('sc_confirm', '!sc_trusted', call('sc_confirm_ask', 'ask-choice', {
183
+ when('sc_email_none', "sc_medium === 'email' && !sc_to", say('sc_email_none_say', "Sorry, I couldn't read that email address, so I didn't send it." + ANYTHING_ELSE, 'Lo siento, no pude entender ese correo electrónico, así que no lo envié.' + ANYTHING_ELSE_ES)),
184
+ when('sc_email_none_end', "sc_medium === 'email' && !sc_to", end('sc_email_none_done', { outcome: 'unresolved', reason: 'no_email' })),
185
+ // a target that is not the caller's own (their phone, the verified cell, the email on file): sent only on YES. An address
186
+ // ask-email just read back has had its YES: only an item with a warning (the web link, the whole conversation, a registered
187
+ // document's disclaimer) is asked about again, saying why
188
+ set('sc_warning', 'sc_warning', "sc_item.kind === 'web_link' ? 'This link opens our conversation, including any account details, for whoever has it. ' : sc_item.kind === 'conversation' ? 'This is our whole conversation, including any account details. ' : sc_item.disclaimer ? String(sc_item.disclaimer) + ' ' : ''"),
189
+ set('sc_warning_es', 'sc_warning_es', "sc_item.kind === 'web_link' ? 'Este enlace abre nuestra conversación, incluidos los datos de su cuenta, para quien lo tenga. ' : sc_item.kind === 'conversation' ? 'Es toda nuestra conversación, incluidos los datos de su cuenta. ' : sc_item.disclaimer ? String(sc_item.disclaimer_es || sc_item.disclaimer) + ' ' : ''"),
190
+ set('sc_ask', 'sc_ask', "!(sc_medium === 'email' ? !!sc_on_file && [sc_on_file, cargo.otp_email].some(function (e) { return String(e || '').trim().toLowerCase() === sc_to.toLowerCase(); }) : [cargo.callerId, cargo.otp_cell_number].map(function (n) { return String(n || '').replace(/\\D/g, '').slice(-10); }).filter(function (n) { return n.length === 10; }).indexOf(String(cargo.textTo || '').replace(/\\D/g, '').slice(-10)) >= 0) && (!sc_read_back || !!sc_warning)"),
191
+ when('sc_target', 'sc_ask', set('sc_target_set', 'sc_target', "sc_medium === 'email' ? sc_to : String(cargo.textTo || '').replace(/\\D/g, '').slice(-10).replace(/^(\\d{3})(\\d{3})(\\d{4})$/, '($1) $2-$3')")),
192
+ when('sc_confirm_q', 'sc_ask', set('sc_confirm_q_set', 'sc_confirm_q', "sc_warning + (sc_read_back ? (sc_account_email ? 'The address you gave is not the email on your account. ' : '') + 'Are you sure you want it sent there? ' : 'Should I send it to ' + sc_target + '? ') + yesNoKeys('en', cargo)")),
193
+ when('sc_confirm_q_es', 'sc_ask', set('sc_confirm_q_es_set', 'sc_confirm_q_es', "sc_warning_es + (sc_read_back ? (sc_account_email ? 'La dirección que me dio no es el correo de su cuenta. ' : '') + '¿Seguro que quiere que se lo envíe ahí? ' : '¿Se lo envío a ' + sc_target + '? ') + yesNoKeys('es', cargo)")),
194
+ when('sc_confirm', 'sc_ask', call('sc_confirm_ask', 'ask-choice', {
182
195
  question: '{{sc_confirm_q}}',
183
196
  question_es: '{{sc_confirm_q_es}}',
184
197
  choices: [{ key: 'yes', phrases: ['1'] }, { key: 'no', phrases: ['2'] }],
@@ -188,11 +201,11 @@ const sendCopy = defineWorker({
188
201
  answer_precheck: 'send-copy-destination-answer',
189
202
  })),
190
203
  // another email address or phone number: SendCopy again with it, so it is read back in its turn
191
- when('sc_corrected', "!sc_trusted && (cargo.choice === 'email' || cargo.choice === 'text')", set('sc_corrected_set', 'sc_given', `cargo.choice === 'email' ? ${EMAIL_IN_JS}(cargo.choiceText) : readPhone(String(cargo.choiceText || ''))`)),
192
- when('sc_corrected_medium', "!sc_trusted && (cargo.choice === 'email' || cargo.choice === 'text')", set('sc_corrected_medium_set', 'sc_medium', 'cargo.choice')),
193
- when('sc_corrected_again', "!sc_trusted && !!sc_given && (sc_medium === 'email' || sc_medium === 'text') && (cargo.choice === 'email' || cargo.choice === 'text')", { id: 'sc_corrected_again_flow', type: 'FLOW', value: 'send-copy', callType: 'replace', parameters: { item: '{{sc_item.key}}', medium: '{{sc_medium}}', destination: '{{sc_given}}', no_closing: '{{no_closing}}' } }),
194
- when('sc_confirm_no', "!sc_trusted && cargo.choice !== 'yes'", say('sc_confirm_no_say', "Okay, I didn't send it." + ANYTHING_ELSE, 'De acuerdo, no lo envié.' + ANYTHING_ELSE_ES)),
195
- when('sc_confirm_no_end', "!sc_trusted && cargo.choice !== 'yes'", end('sc_confirm_no_done', { outcome: 'unresolved', reason: 'declined' })),
204
+ when('sc_corrected', "sc_ask && (cargo.choice === 'email' || cargo.choice === 'text')", set('sc_corrected_set', 'sc_given', `cargo.choice === 'email' ? ${EMAIL_IN_JS}(cargo.choiceText) : readPhone(String(cargo.choiceText || ''))`)),
205
+ when('sc_corrected_medium', "sc_ask && (cargo.choice === 'email' || cargo.choice === 'text')", set('sc_corrected_medium_set', 'sc_medium', 'cargo.choice')),
206
+ when('sc_corrected_again', "sc_ask && !!sc_given && (sc_medium === 'email' || sc_medium === 'text') && (cargo.choice === 'email' || cargo.choice === 'text')", { id: 'sc_corrected_again_flow', type: 'FLOW', value: 'send-copy', callType: 'replace', parameters: { item: '{{sc_item.key}}', medium: '{{sc_medium}}', destination: '{{sc_given}}', no_closing: '{{no_closing}}' } }),
207
+ when('sc_confirm_no', "sc_ask && cargo.choice !== 'yes'", say('sc_confirm_no_say', "Okay, I didn't send it." + ANYTHING_ELSE, 'De acuerdo, no lo envié.' + ANYTHING_ELSE_ES)),
208
+ when('sc_confirm_no_end', "sc_ask && cargo.choice !== 'yes'", end('sc_confirm_no_done', { outcome: 'unresolved', reason: 'declined' })),
196
209
  // send: a sender item runs its flow (it tells the caller); content goes as is
197
210
  set('sc_subject', 'sc_subject', "sc_item.kind === 'web_link' ? (language === 'es' ? 'Continúe nuestra conversación en la web' : 'Continue our conversation on the web') : language === 'es' ? 'Su copia de nuestra conversación' : sc_item.kind === 'conversation' ? 'Your copy of our conversation' : 'Your copy from our conversation'"),
198
211
  when('sc_send_text', "sc_medium === 'text'", call('sc_send_text_call', 'send-text', { message: '{{sc_content}}' })),
@@ -34,6 +34,7 @@ export function isOtherRequest(input: any, kind: any): boolean;
34
34
  * the caller was offered $235.90 (2026-10-14).
35
35
  */
36
36
  export function isAmountAnswer(input: any): boolean;
37
+ export function joinDollarPieces(input: any): string;
37
38
  /**
38
39
  * The amount an answer names, or NaN when it names none or is ambiguous. Prod replay 2026-10-14: the first number in the
39
40
  * answer was taken, so "pagar cuenta 50, ciento treinta y cuatro…" paid $50, "$10 con 18 centavos" paid $10.00 and an
@@ -1 +1 @@
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;AAED;;;;;GAKG;AACH,uFAeC;;;;;;;;AAtiBD,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;AA2BD,qDAA0I;AAE1I;;;;;;GAMG;AACH,mDAAmF;AAEnF,kGAAkG;AAClG;;;EAqCC;AAqBD,oEAqBC;AASD,gJAAgJ;AAChJ,sEAGC;AAED;;;;;;;;;GASG;AACH,6EA4GC;AAED;;;;;GAKG;AACH,uFAeC;;;;;;;;AA5iBD,qCAKwE"}
@@ -355,6 +355,11 @@ const DOLLARS_JOINED_CENTS = /(\$\s*)?(\d+)(\s*(?:dollars?|d[oó]lar(?:es)?|buck
355
355
  // cinco": "157 95", "$157 95", "1 50" (owner 2026-10-29; prod 10-28 callers re-asked). Never after a decimal or before more
356
356
  // digits, and never two-digit dollars: "95 52" is four digits, a card's last four read in pairs.
357
357
  const DOLLARS_SPACE_CENTS = /(?<![\d.,])(\$\s*)?(\d|\d{3,})\s+(\d{2})(?![\d.,]|\s*(?:dollars?|d[oó]lar(?:es)?|bucks?|cents?|centavos?)\b)/gi;
358
+ // Dollars said in pieces, as speech-to-text writes "one sixty three" ("1 63") or "one six three" ("1 6 3"), are one number when
359
+ // a dollar word or "and NN cents" follows (prod 2026-12-04 CAb2b7f: "1 63 and 52 cents" was asked again twice). A first digit and
360
+ // then single digits or one pair: "50 100 dollars" stays two numbers (a sub account and an amount).
361
+ const DOLLARS_IN_PIECES = /(?<![\d$.,-]\s*)\d(?:(?:\s+\d)+|\s+\d{2})(?=\s*(?:(?:dollars?|d[oó]lar(?:es)?|bucks?)\b|(?:and|con|y)\s*(?:un\s+)?\d{1,2}\s*(?:cents?|centavos?)\b))/gi;
362
+ export function joinDollarPieces(input) { return String(input ?? '').replace(DOLLARS_IN_PIECES, (digits) => digits.replace(/\s+/g, '')); }
358
363
  /**
359
364
  * The amount an answer names, or NaN when it names none or is ambiguous. Prod replay 2026-10-14: the first number in the
360
365
  * answer was taken, so "pagar cuenta 50, ciento treinta y cuatro…" paid $50, "$10 con 18 centavos" paid $10.00 and an
@@ -365,7 +370,7 @@ const DOLLARS_SPACE_CENTS = /(?<![\d.,])(\$\s*)?(\d|\d{3,})\s+(\d{2})(?![\d.,]|\
365
370
  export function amountInAnswer(input) { return numericAmountReading(input).value; }
366
371
  /** Internal numeric evidence shared by the opt-in money reader; legacy results stay unchanged. */
367
372
  export function numericAmountReading(input) {
368
- const raw = String(input ?? '');
373
+ const raw = joinDollarPieces(input);
369
374
  // A connector plus cents is a fragment of another amount, not a new standalone payment.
370
375
  // A caller can instead explicitly request "51 cents" or provide the complete dollars and cents.
371
376
  if (/^\s*(?:and|con|y)\s*(?:un\s+)?\d{1,2}\s*(?:cents?|centavos?)\b/i.test(raw))
@@ -1,5 +1,5 @@
1
1
  /** Opt-in currency grammar. Existing amountInAnswer/isAmountAnswer retain their published 1.6 semantics. */
2
- import { numericAmountReading } from './answer.js';
2
+ import { joinDollarPieces, numericAmountReading } from './answer.js';
3
3
  import { scanSpokenMoney } from './spoken-money.js';
4
4
  /** A profile must declare its currency; currently only USD grammar is supported. No exchange-rate inference. */
5
5
  export function validateMoneyOptions(options) {
@@ -26,7 +26,7 @@ function completeMoneyAnswer(input) {
26
26
  let raw = String(input ?? '').trim().replace(/^[¡!]+|[.!]+$/g, '').trim();
27
27
  raw = raw.replace(/^(?:please|por favor)[, ]+/i, '').replace(/[, ]+(?:please|por favor)$/i, '').trim();
28
28
  raw = raw.replace(PAYMENT_PREFIX, '').replace(AMOUNT_LABEL_PREFIX, '').replace(AMOUNT_LABEL_SUFFIX, '').replace(ACCOUNT_PREFIX, '').replace(CARD_SUFFIX, '').replace(ACCOUNT_SUFFIX, '').trim();
29
- if (NUMERIC_MONEY.test(raw))
29
+ if (NUMERIC_MONEY.test(joinDollarPieces(raw)))
30
30
  return true;
31
31
  const { readings, invalid } = scanSpokenMoney(raw);
32
32
  return !invalid.length && readings.length === 1 && readings[0].start === 0 && readings[0].end === raw.length;
@@ -1 +1 @@
1
- export const JSFE_RUNTIME_FINGERPRINT = "sha256:f22f72d7d7656766155745899dc3b0d3ad38c4648b35d208b4400c65214b0d93";
1
+ export const JSFE_RUNTIME_FINGERPRINT = "sha256:c48b6579c62da0846a60ab512f7e21ee269604ca9ecc7582fd9380d5ae8af350";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsfe",
3
- "version": "1.102.0",
3
+ "version": "1.103.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",