jsfe 1.42.2 → 1.43.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.
package/README.md CHANGED
@@ -400,6 +400,8 @@ An input with `profile.whole_phrases` (default off; `choice`, or a `pattern` tha
400
400
 
401
401
  **A number that must name itself.** `input.confirm_out_of_order: {word, word_es, message, message_es}` (default off): out of order a number fills this input only beside its word, in either language ("account 5373850"). Alone it may be something else, a code said with an extra digit, so nothing is filled: the caller hears `message` (`{value}` the number, digit by digit on a call; `{word}` the word) and the current question again, which counts as an attempt at that question. It works at `collect-input` and `confirm-form` questions. At its own question the number needs no word. `authenticate-user`'s `code_confirm` takes the same declaration for a `code_validator`, whose flow reads it with the helpers `saysConfirmWord(answer, spec)` and `confirmOutOfOrderLine(spec, value, language, voice)`.
402
402
 
403
+ **An amount-shaped number is no ZIP (jsfe 1.43.0, owner 2026-11-11).** `profile.refuse_amount_shape: true` on a `digits` profile (default off): out of order, three digits then two ("119 19") read as dollars and cents as readily as one number, so they are not this field's digits; at its own question the field was asked for, and it reads. The `zip` and `card_zip` presets declare it, and `card_zip` also declares `confirm_out_of_order` (word ZIP / CÓDIGO POSTAL): out of order a bare five-digit number fills the billing ZIP only beside the word (prod 2026-11-11: "119 19." at the save-card question replaced an answered billing ZIP and the charge failed AVS).
404
+
403
405
  **Declared choices (`responseChoices`, jsfe 1.14):** a step may name a flow variable of type array holding
404
406
  `[{ key, label, parameters? }]` (`parameters`: extracted on a pick, read as `{ key, arguments }`); the ranker is then also offered `choice:<key>` for each (before the fixed options), and `answers`
405
407
  means a reply that picks none of them. A picked choice sets `responseVariable` to `{ key }`, plus `arguments` when it declares `parameters` (the pick stands if extraction finds nothing or fails);
@@ -82,6 +82,7 @@ export function validateFlowContracts(flows: any, tools?: any[], { externalFlows
82
82
  kind: string;
83
83
  min: number;
84
84
  max: number;
85
+ refuse_amount_shape: boolean;
85
86
  };
86
87
  digits: {
87
88
  min: number;
@@ -239,11 +240,18 @@ export function validateFlowContracts(flows: any, tools?: any[], { externalFlows
239
240
  kind: string;
240
241
  min: number;
241
242
  max: number;
243
+ refuse_amount_shape: boolean;
242
244
  };
243
245
  digits: {
244
246
  min: number;
245
247
  max: number;
246
248
  };
249
+ confirm_out_of_order: {
250
+ word: string;
251
+ word_es: string;
252
+ message: string;
253
+ message_es: string;
254
+ };
247
255
  question: string;
248
256
  question_es: string;
249
257
  };
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/forms/contracts.js"],"names":[],"mappings":"AAgBA;;;IAGC;AACD;;;;;EAGC;AACD,qGAAqG;AACrG;;QAwCC;AAqBD;;;QAEC;AAgBD;;;;;;;;;QASC;AACD;;;;QAGC;AACD;;;;;;;;QA8BC;AAED,mHAAmH;AACnH,kDAgBC;AAED,+GAA+G;AAC/G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4EC"}
1
+ {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/forms/contracts.js"],"names":[],"mappings":"AAgBA;;;IAGC;AACD;;;;;EAGC;AACD,qGAAqG;AACrG;;QAwCC;AAqBD;;;QAEC;AAgBD;;;;;;;;;QASC;AACD;;;;QAGC;AACD;;;;;;;;QA8BC;AAED,mHAAmH;AACnH,kDAgBC;AAED,+GAA+G;AAC/G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4EC"}
@@ -144,6 +144,7 @@ export namespace FIELD_PRESETS {
144
144
  export { min_1 as min };
145
145
  let max_1: number;
146
146
  export { max_1 as max };
147
+ export let refuse_amount_shape: boolean;
147
148
  }
148
149
  export { profile_2 as profile };
149
150
  export namespace digits_1 {
@@ -410,6 +411,8 @@ export namespace FIELD_PRESETS {
410
411
  export { min_12 as min };
411
412
  let max_11: number;
412
413
  export { max_11 as max };
414
+ let refuse_amount_shape_1: boolean;
415
+ export { refuse_amount_shape_1 as refuse_amount_shape };
413
416
  }
414
417
  export { profile_12 as profile };
415
418
  export namespace digits_7 {
@@ -419,6 +422,12 @@ export namespace FIELD_PRESETS {
419
422
  export { max_12 as max };
420
423
  }
421
424
  export { digits_7 as digits };
425
+ export namespace confirm_out_of_order {
426
+ let word: string;
427
+ let word_es: string;
428
+ let message: string;
429
+ let message_es: string;
430
+ }
422
431
  let question_12: string;
423
432
  export { question_12 as question };
424
433
  let question_es_12: string;
@@ -1 +1 @@
1
- {"version":3,"file":"flows.d.ts","sourceRoot":"","sources":["../../src/forms/flows.js"],"names":[],"mappings":"AA6GA;;;;;;;GAOG;AACH;;;;GAIG;AACH,8HAA8H;AAC9H,uFAIC;AAiBD;;2EAE2E;AAC3E,qEAEC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqEC;AACD;;;GAGG;AACH;;;;;;EAGC;AA+lBD,wHAAwH;AACxH,wEAaC;AACD,4FAA4F;AAC5F;;;EAYC;AACD,sGAAsG;AACtG;;;EAOC;AA7zBM,6CAAuG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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const FIELD_PRESETS = {
57
57
  email: { label: 'email address', label_es: 'correo electrónico', profile: { kind: 'email' },
58
58
  question: 'What is your email address?', question_es: '¿Cuál es su correo electrónico?',
59
59
  retry: 'Please say your email address, for example juan at gmail dot com.', retry_es: 'Por favor diga su correo electrónico, por ejemplo juan arroba gmail punto com.' },
60
- zip: { label: 'ZIP code', label_es: 'código postal', profile: { kind: 'digits', min: 5, max: 5 }, digits: { min: 5, max: 5 },
60
+ zip: { label: 'ZIP code', label_es: 'código postal', profile: { kind: 'digits', min: 5, max: 5, refuse_amount_shape: true }, digits: { min: 5, max: 5 },
61
61
  question: 'What is your ZIP code?', question_es: '¿Cuál es su código postal?',
62
62
  retry: 'Please say or enter your 5-digit ZIP code.', retry_es: 'Por favor diga o ingrese su código postal de 5 dígitos.',
63
63
  retry_text: 'Please type your 5-digit ZIP code.', retry_text_es: 'Por favor escriba su código postal de 5 dígitos.' },
@@ -93,7 +93,10 @@ export const FIELD_PRESETS = {
93
93
  card_cvv: { label: 'security code', label_es: 'código de seguridad', profile: { kind: 'digits', min: 3, max: 4 }, digits: { min: 3, max: 4 }, pii: true,
94
94
  validator: 'validate-card-cvv',
95
95
  question: 'What is the security code on the back of the card?', question_es: '¿Cuál es el código de seguridad al reverso de la tarjeta?' },
96
- card_zip: { label: 'billing ZIP code', label_es: 'código postal de facturación', profile: { kind: 'digits', min: 5, max: 5 }, digits: { min: 5, max: 5 },
96
+ // A bare five-digit number out of order may be anything (prod 2026-11-11: it replaced an answered ZIP), so it fills the
97
+ // billing ZIP only beside the word (owner 2026-11-11).
98
+ card_zip: { label: 'billing ZIP code', label_es: 'código postal de facturación', profile: { kind: 'digits', min: 5, max: 5, refuse_amount_shape: true }, digits: { min: 5, max: 5 },
99
+ confirm_out_of_order: { word: 'ZIP', word_es: 'CÓDIGO POSTAL', message: 'If {value} is the billing ZIP code of the card, add the word {word}.', message_es: 'Si {value} es el código postal de facturación de la tarjeta, agregue las palabras {word}.' },
97
100
  question: 'What is the billing ZIP code for the card?', question_es: '¿Cuál es el código postal de facturación de la tarjeta?' },
98
101
  };
99
102
  // Field collectors: one-input forms over a preset, callable directly (result in cargo.formResults[<id>]).
@@ -1 +1 @@
1
- {"version":3,"file":"match-inputs.d.ts","sourceRoot":"","sources":["../../src/helpers/match-inputs.js"],"names":[],"mappings":"AAkBA;;;;GAIG;AACH,sEAQC;AAwFD;;;GAGG;AACH,sFAyHC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;mHACmH;AAEnH,iEAEC;AAGD,gGAKC;AAED;;;;;;;;;;;;;;;;;;;;;;EAeC;AACD;;;;;;;;;;;;;;;;;;;;;;;EA+SC"}
1
+ {"version":3,"file":"match-inputs.d.ts","sourceRoot":"","sources":["../../src/helpers/match-inputs.js"],"names":[],"mappings":"AAkBA;;;;GAIG;AACH,sEAQC;AAyFD;;;GAGG;AACH,sFA8HC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;mHACmH;AAEnH,iEAEC;AAGD,gGAKC;AAED;;;;;;;;;;;;;;;;;;;;;;EAeC;AACD;;;;;;;;;;;;;;;;;;;;;;;EA+SC"}
@@ -45,6 +45,7 @@ function digitRuns(raw) {
45
45
  // A choice reads its keys without the comma join: "1, 2" names two keys, not 12.
46
46
  const CHOICE_RUN = /\d(?:[\s.-]?\d)*/g;
47
47
  const DECIMAL_AMOUNT = /(?:[$€£]\s?)?\d+[.,]\d{2}(?!\d)/g; // a written decimal amount, with its currency mark
48
+ const AMOUNT_SHAPED = /(?<!\d[\s.,-]?)\d{3}\s+\d{2}(?![\s.,-]?\d)/g; // "119 19": dollars and cents as said (profile.refuse_amount_shape)
48
49
  /** Where the answer says amount n: a written decimal by itself ("51 72.45" is not one spoken run), else its number spans. */
49
50
  function amountSpans(raw, n) {
50
51
  const decimals = [...raw.matchAll(DECIMAL_AMOUNT)].filter((m) => Number(m[0].replace(/[^\d.,]/g, '').replace(',', '.')) === n).map((m) => [m.index, m.index + m[0].length]);
@@ -225,11 +226,19 @@ export function readInputProfile(profile, answer, isCurrent = true) {
225
226
  const min = Number(profile.min || 1);
226
227
  const max = Number(profile.max || min);
227
228
  // Out of order a decimal amount ("72.45", "287,15") is never this field's digits.
228
- let fits = [...new Set(digitRuns(isCurrent ? raw : raw.replace(DECIMAL_AMOUNT, (m) => ' '.repeat(m.length))).filter((d) => d.length >= min && d.length <= max))];
229
+ let source = isCurrent ? raw : raw.replace(DECIMAL_AMOUNT, (m) => ' '.repeat(m.length));
230
+ // profile.refuse_amount_shape: out of order, three digits then two ("119 19") read as dollars and cents as readily as
231
+ // one number, so they are not this field's digits (owner 2026-11-11: prod "119 19." at a save-card question replaced the
232
+ // billing ZIP with 11919 and the charge failed AVS). At its own question the field was asked for: it reads.
233
+ if (profile.refuse_amount_shape === true && !isCurrent) {
234
+ source = source.replace(AMOUNT_SHAPED, (m) => ' '.repeat(m.length));
235
+ }
236
+ else { /* every run reads */ }
237
+ let fits = [...new Set(digitRuns(source).filter((d) => d.length >= min && d.length <= max))];
229
238
  // At its own question, an answer of digits and separators alone is one number when its length fits ("4111, 1111,
230
239
  // 1111, 1111": a card read in groups of four).
231
- const whole = raw.replace(/\D/g, '');
232
- if (!fits.length && isCurrent && /^[\d\s.,-]+$/.test(raw.trim()) && whole.length >= min && whole.length <= max) {
240
+ const whole = source.replace(/\D/g, '');
241
+ if (!fits.length && isCurrent && /^[\d\s.,-]+$/.test(source.trim()) && whole.length >= min && whole.length <= max) {
233
242
  fits = [whole];
234
243
  }
235
244
  else { /* read by runs */ }
@@ -1 +1 @@
1
- export const JSFE_RUNTIME_FINGERPRINT = "sha256:9e8c3afaa822d4fa2657e72836fde0410fd30f7d265f2c0f6ad94e3abcc6efbc";
1
+ export const JSFE_RUNTIME_FINGERPRINT = "sha256:e948477ddf615570a3f1df9d8e65ea2c8d43bce904dd5b729d6f677d66a1cfb3";
@@ -360,6 +360,8 @@ it.
360
360
 
361
361
  **A number that must name itself.** `input.confirm_out_of_order: {word, word_es, message, message_es}` (default off): out of order a number fills this input only beside its word, in either language ("account 5373850"). Alone it may be something else, a code said with an extra digit, so nothing is filled: the caller hears `message` (`{value}` the number, digit by digit on a call; `{word}` the word) and the current question again, which counts as an attempt at that question. It works at `collect-input` and `confirm-form` questions. At its own question the number needs no word. `authenticate-user`'s `code_confirm` takes the same declaration for a `code_validator`, whose flow reads it with the helpers `saysConfirmWord(answer, spec)` and `confirmOutOfOrderLine(spec, value, language, voice)`.
362
362
 
363
+ **An amount-shaped number is no ZIP.** `profile.refuse_amount_shape: true` (digits profile, default off): "119 19" (three digits then two) is not the field's digits out of order; at its own question it reads. Declared by the `zip` and `card_zip` presets; `card_zip` also takes a bare number out of order only beside ZIP / CÓDIGO POSTAL (`confirm_out_of_order`).
364
+
363
365
  **A provider's menu.** `provides.menu.whole_phrases: true` (default off) applies the same rule to a menu: a fact's phrase answers only as the whole reply, and a phrase inside a longer sentence goes to the reply ranker, offered every fact with phrases, every action, `done` and a person. A fact pick is answered with every other fact that cleared `REPLY_ALSO_CUT` (0.6), so one sentence that asks two things hears both; an action pick runs alone. `answers` and `irrelevant` fall to the menu's plain DISPATCH, which hands the turn to the host without intent detection (a Guru answers from the user context the flow set); `new_request` runs intent detection. A reply with no phrase is unchanged. `menu.unanswered` handles a question the provider cannot answer: when a reply from its own menu comes back to it through intent detection with no fact to say, the caller hears the declared apology and offer (`provider-unanswered`) instead of the same facts again.
364
366
 
365
367
  Some options are **never offered**, so the ranker cannot pick them: the YES of a firm confirmation (an input's, or a form's
@@ -219,6 +219,7 @@ Declarations:
219
219
  | profile `out_of_order:{…}` | A narrower signature for out-of-order reading: the payment card takes a bare last four when asked, but out of order only a card word or "ending in 4242". |
220
220
  | `authenticate-user` `other_whole_answer:true` | At the code question "another account" switches only as the whole answer; inside a sentence the reply ranker decides, offered `another_account` and `no_other_account` ("I understand. We still need to secure access to your account.", then the question). Default off. |
221
221
  | input `confirm_out_of_order:{word,word_es,message,message_es}` | Out of order a number fills this input only beside its `word`, in either language. Alone, the caller hears `message` (`{value}` is the number, `{word}` the word) and the current question again, which counts as an attempt. `authenticate-user`'s `code_confirm` is the same declaration for a `code_validator`, whose flow reads it with `saysConfirmWord` and `confirmOutOfOrderLine`: an account number at the verification-code question, where it may be a code said with an extra digit. |
222
+ | profile `refuse_amount_shape:true` (digits) | Out of order, three digits then two ("119 19") fill nothing: they read as dollars and cents. At its own question they read as the field. The `zip` and `card_zip` presets declare it. |
222
223
  | input `choices_from` | The choice's values come from prepared data (the caller's saved cards), so its signature is those values. |
223
224
 
224
225
  Rules, in order:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsfe",
3
- "version": "1.42.2",
3
+ "version": "1.43.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",