jsfe 1.40.2 → 1.42.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
@@ -373,11 +373,27 @@ when it declares them. A confident `answers` (no `fallback`) is never lost: when
373
373
  the field is the reply as said. Unmarked fields (a product, a city) always need a real extraction. After a
374
374
  `fallback` answer extraction is the judge, and ReadFormResponse asks the question again when it finds nothing; `abort` is a RETURN: every flow ends and the reply is system message `cmd_request_aborted`
375
375
  ("The process has been cancelled at your request - how can I help you?"),
376
- outcome `user_aborted`, no recovery stamp;
376
+ outcome `user_aborted`, no recovery stamp (never the global exit flow below);
377
+ `concern` (jsfe 1.42.0, owner 2026-11-11; offered only when the step declares `responseConcern`, which form readers set from the nearest form
378
+ in the chain declaring `user_description` / `user_description_es`, `{{path}}` read from the form's values, then data, then cargo; never at
379
+ a reason question; cut 0.6, and the top score wins over a cleared choice): the caller objects to or misunderstands what the process does.
380
+ The reader says the description, how to cancel ("To cancel, press the asterisk key or say EXIT." / "To cancel, type EXIT."; Spanish
381
+ SALIR) and the question again; no attempt is counted;
377
382
  `irrelevant` (a stray word, an unfinished sentence, speech to someone else; cut 0.7, and 0.8 to outrank a cleared choice) extracts nothing and asks again: no flow moves. `new_request` ends the flows and routes the input through intent detection. Only a new request is routed: after
378
383
  `answers` a later ordinary DISPATCH in the same turn hands the host the turn without detection. A host that does not know the task answers the `llm`
379
384
  instructions with its text model.
380
385
 
386
+ **The global exit (jsfe 1.42.0, owner 2026-11-11):** a whole answer of `*`, EXIT, QUIT or SALIR (repeated, or with please / por
387
+ favor / now / ahora; CANCEL is not one) ends every flow at any question, before any reader, command or the reply ranker
388
+ (`isGlobalExit`), outcome `user_aborted`, reason `exit_requested`, unless the question declares a choice of its own for that
389
+ word (its key or a phrase is `*`, EXIT, QUIT or SALIR): that choice takes the answer. The engine then starts
390
+ the worker `global-exit` (default: a reboot to the set's `contact-support` with `exit_outcome`, the outcome in force before the
391
+ flows ended), or the tenant flow that `wraps: "global-exit"`. A set with neither a wrapper nor `contact-support` keeps the generic reply.
392
+
393
+ **Keypad 9 (jsfe 1.42.0, owner 2026-10-31):** on a call, a whole answer of `9` at any question ends every flow and starts
394
+ `switch-to-text`, when the caller's number can take texts (`callerTextNumber`) and the set has that flow. A question that declares a
395
+ choice for 9, or asks for an amount (ask-choice `amount`), keeps the answer. Keypad 8 (language) is the host's.
396
+
381
397
  An input with `profile.whole_phrases` (default off; `choice`, or a `pattern` that reads words) keeps its word reader only for a reply wholly made of its phrase, arguments, courtesy, connecting words and its `template_words`; any other reply goes to this ranker.
382
398
 
383
399
  **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)`.
@@ -983,9 +999,11 @@ await persist(session);
983
999
  ### Declared flow outcomes: `lastFlowOutcome`
984
1000
 
985
1001
  A flow can say how it ended, not just that it ended. An optional `outcome` (and `reason`) on a step
986
- is remembered on the flow and applied when the flow terminates. Put it on the step that ends the
987
- flow: a `RETURN`, an `END`, a `DISPATCH` or a final `SAY`. Both may use `{{…}}` interpolation with
988
- the flow's variables; an `outcome` that interpolates to empty declares nothing:
1002
+ is remembered on the flow and applied when the flow terminates. Any step may carry it, so a flow
1003
+ declares the outcome the moment it achieves (or fails) its objective, even when it goes on talking; a
1004
+ later declaration replaces it. On a `FLOW` step it is the calling flow's declaration. Both may use
1005
+ `{{…}}` interpolation with the flow's variables; an `outcome` that interpolates to empty declares
1006
+ nothing:
989
1007
 
990
1008
  ```json
991
1009
  { "id": "say_support_message", "type": "SAY", "value": "Sorry I couldn't help! ...",
@@ -1017,6 +1035,13 @@ declared an outcome terminated during that call. Hosts use it to run a recovery
1017
1035
  `"unresolved"` ending. When a `RETURN` terminates several flows, only the flow that executed it
1018
1036
  carries the RETURN's declaration; the others finalize with their own (usually none).
1019
1037
 
1038
+ **Flows read it as `$outcome` (jsfe 1.41.0):** `{ outcome, reason, flowName }` of the declaration in
1039
+ force for the running flow, its own, else the nearest among the flows that called it on this stack;
1040
+ `null` when none declared. A flow that starts declares nothing (a `replace` keeps the frame, and its
1041
+ declaration), and a called flow's declaration ends with it. A `reboot` ends every flow, so the flow
1042
+ that reboots hands the outcome over as a parameter, a path like any other: `{ "exit_outcome":
1043
+ "{{$outcome.outcome}}" }`. The outcome belongs to the flows; a host only reads `lastFlowOutcome`.
1044
+
1020
1045
  ## Architecture Overview
1021
1046
 
1022
1047
  ### Stack-of-Stacks Design
@@ -1270,7 +1295,7 @@ their original workflow seamlessly.
1270
1295
  - ✅ **END** - Return from the current flow only, resuming the parent flow — a functional `return` (no value; variables are shared with the parent)
1271
1296
  - ✅ **DISPATCH** - End all flows and route this turn's input through intent detection, as if no flow had been active (a matched flow starts in the same turn; no match → no response, the host answers). Resets everything; the ended flows' declared outcome is kept only when no flow matches. Takes `id`, `outcome`, `reason`. See the user guide's *DISPATCH Steps*
1272
1297
 
1273
- A terminal step (`RETURN`, `END`, `DISPATCH` or a final `SAY`) may also carry `outcome` / `reason`; see
1298
+ Any step may also carry `outcome` / `reason` (it applies when the flow terminates); see
1274
1299
  [Declared flow outcomes](#declared-flow-outcomes-lastflowoutcome).
1275
1300
 
1276
1301
  ### Step Reliability: Validation & Retry
@@ -1 +1 @@
1
- {"version":3,"file":"address-flows.d.ts","sourceRoot":"","sources":["../../src/forms/address-flows.js"],"names":[],"mappings":"AA6CA,0BAAmF"}
1
+ {"version":3,"file":"address-flows.d.ts","sourceRoot":"","sources":["../../src/forms/address-flows.js"],"names":[],"mappings":"AAgDA,0BAAmF"}
@@ -9,15 +9,18 @@ const E = (fn, ...args) => `(${fn.toString()})(${args.join(',')})`;
9
9
  const P = (name, type = 'string') => ({ name, type, description: name });
10
10
  const C = (id, summary, steps, extra = {}) => defineWorker({ id, name: id.split('-').map(w => w[0].toUpperCase() + w.slice(1)).join(''), description: summary, ...extra, contract: { role: 'worker', summary, ...extra.contract }, steps });
11
11
  const streetPattern = '\\b\\d{1,6}\\s+(?:[A-Za-z0-9.\\xC0-\\xFF-]+\\s+){1,8}(?:st(?:reet)?|ave(?:nue)?|blvd|boulevard|rd|road|ln|lane|dr(?:ive)?|way|ct|court|pl(?:ace)?|pkwy|parkway|cir(?:cle)?|ter(?:race)?)\\b';
12
- const address = defineForm({ id: 'collect-geocoded-address', name: 'CollectGeocodedAddress', version: '1.0.0', description: 'Collect a mailing address in any order, project geocoder evidence, and read the complete address back for confirmation.', contract: { summary: 'Collect and confirm a geocoded mailing address', result: { path: 'form result.resolved', type: 'object' } }, parameters: [P('given')], extraVars: { given: '', zip: '', street: '', unit: '', draft: null, address_result: null, exit_context: 'your address', exit_context_es: 'su dirección' },
13
- before: [S('address_given', 'given', "given || (cargo.forms[cargo.forms[form_instance].parent] || {}).context && (cargo.forms[cargo.forms[form_instance].parent].context.given || '') || ''"), S('address_draft', 'draft', E(addressDraft, "given || (cargo.forms[form_instance].seeds && cargo.forms[form_instance].seeds.given) || ''")), S('address_seed_zip', 'zip', "zip || draft.zip"), S('address_seed_street', 'street', "street || draft.street"), S('address_seed_unit', 'unit', "unit || draft.unit"), S('address_data', 'noop', "(cargo.forms[form_instance].data=Object.assign({need_city:false},cargo.forms[form_instance].data || {}), draft.street ? (cargo.addressDraft={said:draft.street}) : null, true)")],
12
+ const address = defineForm({ id: 'collect-geocoded-address', name: 'CollectGeocodedAddress', version: '1.0.0', description: 'Collect a mailing address in any order, project geocoder evidence, and read the complete address back for confirmation.', contract: { summary: 'Collect and confirm a geocoded mailing address', result: { path: 'form result.resolved', type: 'object' } }, parameters: [P('given')], extraVars: { given: '', zip: '', street: '', unit: '', draft: null, address_result: null, address_spec: null, address_label: 'new address', address_label_es: 'nueva dirección', exit_context: 'your address', exit_context_es: 'su dirección' },
13
+ before: [S('address_given', 'given', "given || (cargo.forms[cargo.forms[form_instance].parent] || {}).context && (cargo.forms[cargo.forms[form_instance].parent].context.given || '') || ''"), S('address_draft', 'draft', E(addressDraft, "given || (cargo.forms[form_instance].seeds && cargo.forms[form_instance].seeds.given) || ''")), S('address_seed_zip', 'zip', "zip || draft.zip"), S('address_seed_street', 'street', "street || draft.street"), S('address_seed_unit', 'unit', "unit || draft.unit"), S('address_data', 'noop', "(cargo.forms[form_instance].data=Object.assign({need_city:false},cargo.forms[form_instance].data || {}), draft.street ? (cargo.addressDraft={said:draft.street}) : null, true)"),
14
+ // The calling form's own label for this input names what is being changed ("new delivery address") in every question and the read-back;
15
+ // without one, today's wording.
16
+ S('address_spec', 'address_spec', "(function(f){var p=f&&f.parent?cargo.forms[f.parent]:null,s=p&&p.specs,n=f&&f.result_input,x=null;if(n&&Array.isArray(s)){for(var i=0;i<s.length;i++){if(s[i]&&s[i].name===n){x=s[i];break;}}}else if(n&&s&&typeof s==='object'){x=s[n]||null;}return x||{};})(cargo.forms[form_instance])"), S('address_label', 'address_label', "typeof address_spec.label==='string'&&address_spec.label.trim()?address_spec.label.trim():'new address'"), S('address_label_es', 'address_label_es', "typeof address_spec.label_es==='string'&&address_spec.label_es.trim()?address_spec.label_es.trim():'nueva dirección'"), S('address_label_data', 'noop', "(function(d,labelled){d.label=address_label;d.label_es=address_label_es;d.labelled=labelled;d.city_state_question=labelled?'What city and state is your '+address_label+' in?':'What city and state is that in?';d.city_state_question_es=labelled?'¿En qué ciudad y estado está su '+address_label_es+'?':'¿En qué ciudad y estado está?';d.unit_question=labelled?'Is there an apartment or unit number in your '+address_label+'? Type the number, or NONE.':'Is there an apartment or unit number? Type the number, or NONE.';d.unit_question_es=labelled?'¿Hay un número de apartamento o unidad en su '+address_label_es+'? Escriba el número, o NINGUNO.':'¿Hay un número de apartamento o unidad? Escriba el número, o NINGUNO.';return true;})(cargo.forms[form_instance].data,typeof address_spec.label==='string'&&!!address_spec.label.trim())")],
14
17
  inputs: [{ name: 'zip', field: 'zip', argument_description: '5-digit ZIP code', names: ['zip', 'zip code', 'postal code', 'código postal', 'codigo postal'], validator: 'address-zip-validate', prepare: 'address-zip-prompt', question_from: 'zip_question', question: 'What is the 5-digit zip code of your new address?', question_es: '¿Cuál es el código postal de 5 dígitos de su nueva dirección?' },
15
18
  { name: 'city', argument_description: 'city name alone', label: 'city', label_es: 'ciudad', names: ['city', 'ciudad'], profile: { kind: 'choice', choices: [], accept_other: true, other_needs_letter: true }, choices_from: 'city_choices', when: { 'form.data.city_known': true }, depends_on: ['zip'], reset_on: ['zip'], prepare: 'address-city-prompt', question_from: 'city_question', question: 'Which city is it?', question_es: '¿Qué ciudad es?' },
16
- { name: 'city_state', argument_description: 'city and state', label: 'city and state', label_es: 'ciudad y estado', names: ['city', 'ciudad'], profile: { kind: 'text' }, when: { 'form.data.need_city': true }, depends_on: ['zip'], question: 'What city and state is that in?', question_es: '¿En qué ciudad y estado está?' },
19
+ { name: 'city_state', argument_description: 'city and state', label: 'city and state', label_es: 'ciudad y estado', names: ['city', 'ciudad'], profile: { kind: 'text' }, when: { 'form.data.need_city': true }, depends_on: ['zip'], question_from: 'city_state_question', question: 'What city and state is that in?', question_es: '¿En qué ciudad y estado está?' },
17
20
  { name: 'street', argument_description: 'street number and street name, without the apartment', label: 'street address', label_es: 'dirección', names: ['street', 'calle'], profile: { kind: 'pattern', regex: streetPattern, spoken_digits: 'house_number', accept_other: true }, depends_on: ['zip'], validator: 'address-street-validate', prepare: 'address-street-prompt', question_from: 'street_question', question: 'What is the street address?', question_es: '¿Cuál es la dirección?' },
18
- { name: 'unit', argument_description: 'apartment or unit number alone, such as 4 or 12B', reset_on: ['street'], label: 'apartment or unit', label_es: 'apartamento o unidad', names: ['apartment', 'apt', 'unit', 'apartamento', 'unidad', 'departamento'], profile: { kind: 'pattern', regex: '(?:\\bapartment|\\bapartamento|\\bdepartamento|\\bapt\\.?|\\bunit|\\bunidad|#)\\s*([\\w-]+)', group: 1, spoken_digits: true, accept_other: true }, question: 'Is there an apartment or unit number? Type the number, or NONE.', question_es: '¿Hay un número de apartamento o unidad? Escriba el número, o NINGUNO.' }],
21
+ { name: 'unit', argument_description: 'apartment or unit number alone, such as 4 or 12B', reset_on: ['street'], label: 'apartment or unit', label_es: 'apartamento o unidad', names: ['apartment', 'apt', 'unit', 'apartamento', 'unidad', 'departamento'], profile: { kind: 'pattern', regex: '(?:\\bapartment|\\bapartamento|\\bdepartamento|\\bapt\\.?|\\bunit|\\bunidad|#)\\s*([\\w-]+)', group: 1, spoken_digits: true, accept_other: true }, question_from: 'unit_question', question: 'Is there an apartment or unit number? Type the number, or NONE.', question_es: '¿Hay un número de apartamento o unidad? Escriba el número, o NINGUNO.' }],
19
22
  before_confirm: [S('address_resolved', 'address_result', E(resolvedAddress, 'cargo.forms[form_instance].values', 'cargo.forms[form_instance].data'))],
20
- confirm: { named_fields: true, reply_context: 'This is a mailing address read back for confirmation. A reply may correct one part or several at once: the street number, street name or street type, the apartment or unit, the city, or the ZIP code.', no_keys: ['2', 'not right', 'not correct', 'incorrect', 'wrong', 'no es correcto', 'no es correcta', 'incorrecta'], question: 'Your new address is {{address_result.line}}. Is that correct?', question_es: 'Su nueva dirección es {{address_result.line}}. ¿Es correcta?' },
23
+ confirm: { named_fields: true, reply_context: 'This is a mailing address read back for confirmation. A reply may correct one part or several at once: the street number, street name or street type, the apartment or unit, the city, or the ZIP code.', no_keys: ['2', 'not right', 'not correct', 'incorrect', 'wrong', 'no es correcto', 'no es correcta', 'incorrecta'], question: 'Your {{address_label}} is {{address_result.line}}. Is that correct?', question_es: 'Su {{address_label_es}} es {{address_result.line}}. ¿Es correcta?' },
21
24
  after: [S('address_result_store', 'noop', '(cargo.forms[form_instance].values.resolved = address_result, cargo.address = address_result, cargo.addressDraft = null, true)')], declined: [S('address_retry_noop', 'noop', 'true')] });
22
25
  const zip = C('address-zip-validate', 'Read city and state from geocoder evidence for the proposed ZIP; missing geocoder data requires an explicit city.', [
23
26
  S('address_zip_components', 'components', "'postal_code:'+value+'|country:US'"), { id: 'address_zip_tool', type: 'CALL-TOOL', tool: 'geocode-zip', variable: 'result', args: { components: '{{components}}', address: '' }, onFail: S('address_zip_failed', 'result', 'null') },
@@ -31,9 +34,9 @@ const street = C('address-street-validate', 'Validate a proposed street against
31
34
  S('address_street_projection', 'location', E(streetLocation, 'result', 'value', 'values.zip')),
32
35
  S('address_street_result', 'noop', "(cargo.forms[form].data.street=location, location.city&&cargo.forms[form].accepted&&cargo.forms[form].accepted.city&&cargo.forms[form].accepted.city.origin==='derived'&&cargo.forms[form].values.city!==location.city?(cargo.forms[form].values.city=location.city):null, cargo.inputCheck={ok:true,value:String(value)}, true)")
33
36
  ], { parameters: [P('form'), P('value'), P('values', 'object')], variables: V({ components: '', result: null, location: null }), contract: { tools: ['geocode-street'], result: { path: 'cargo.inputCheck', type: 'object' } } });
34
- const zipPrompt = C('address-zip-prompt', 'Render the ZIP retry wording from the owned address instance.', [S('address_zip_prompt', 'noop', "(cargo.forms[form].data.zip_question=(cargo.forms[form].data.retry ? \"Let's try again. \" : '')+'What is the 5-digit zip code of your new address?',cargo.forms[form].data.zip_question_es=(cargo.forms[form].data.retry?'Intentémoslo otra vez. ':'')+'¿Cuál es el código postal de 5 dígitos de su nueva dirección?',true)")], { parameters: [P('form')], contract: { result: { path: 'cargo.forms[form].data', type: 'object' } } });
35
- const streetPrompt = C('address-street-prompt', 'Include the ZIP-derived location when asking for the street.', [S('address_street_prompt', 'noop', "(cargo.forms[form].data.street_question=(cargo.forms[form].data.location?'Got it, '+(cargo.forms[form].values.city?cargo.forms[form].values.city+', '+cargo.forms[form].data.location.state:cargo.forms[form].data.location.line)+'. ':'')+'What is the street address?',cargo.forms[form].data.street_question_es=(cargo.forms[form].data.location?'Entendido, '+(cargo.forms[form].values.city?cargo.forms[form].values.city+', '+cargo.forms[form].data.location.state:cargo.forms[form].data.location.line)+'. ':'')+'¿Cuál es la dirección?',true)")], { parameters: [P('form')], contract: { result: { path: 'cargo.forms[form].data', type: 'object' } } });
36
- const cityPrompt = C('address-city-prompt', 'Ask which of the ZIP code\'s place names the address carries.', [S('address_city_prompt', 'noop', "(function(data,voice){var names=(data.location&&data.location.cities)||[],n=names.length,list=function(and){return names.slice(0,-1).join(', ')+' '+and+' '+names[n-1];};if(n<2){data.city_question='What city is it?';data.city_question_es='¿Qué ciudad es?';return true;}data.city_question='Which city is it: '+list('or')+'? '+(voice?names.map(function(c,i){return (i?'':'Press ')+(i+1)+' for '+c;}).join(', ')+'.':'Type the city or its number, 1 to '+n+'.');data.city_question_es='¿Qué ciudad es: '+list('o')+'? '+(voice?names.map(function(c,i){return (i?'':'Presione ')+(i+1)+' para '+c;}).join(', ')+'.':'Escriba la ciudad o su número, del 1 al '+n+'.');return true;})(cargo.forms[form].data,cargo.voice===true)")], { parameters: [P('form')], contract: { result: { path: 'cargo.forms[form].data', type: 'object' } } });
37
+ const zipPrompt = C('address-zip-prompt', 'Render the ZIP question from the owned address instance, naming the calling form\'s label.', [S('address_zip_prompt', 'noop', "(cargo.forms[form].data.zip_question=(cargo.forms[form].data.retry ? \"Let's try again. \" : '')+'What is the 5-digit zip code of your '+(cargo.forms[form].data.label||'new address')+'?',cargo.forms[form].data.zip_question_es=(cargo.forms[form].data.retry?'Intentémoslo otra vez. ':'')+'¿Cuál es el código postal de 5 dígitos de su '+(cargo.forms[form].data.label_es||'nueva dirección')+'?',true)")], { parameters: [P('form')], contract: { result: { path: 'cargo.forms[form].data', type: 'object' } } });
38
+ const streetPrompt = C('address-street-prompt', 'Include the ZIP-derived location when asking for the street.', [S('address_street_prompt', 'noop', "(cargo.forms[form].data.street_question=(cargo.forms[form].data.location?'Got it, '+(cargo.forms[form].values.city?cargo.forms[form].values.city+', '+cargo.forms[form].data.location.state:cargo.forms[form].data.location.line)+'. ':'')+(cargo.forms[form].data.labelled?'What is the street of your '+cargo.forms[form].data.label+'?':'What is the street address?'),cargo.forms[form].data.street_question_es=(cargo.forms[form].data.location?'Entendido, '+(cargo.forms[form].values.city?cargo.forms[form].values.city+', '+cargo.forms[form].data.location.state:cargo.forms[form].data.location.line)+'. ':'')+(cargo.forms[form].data.labelled?'¿Cuál es la calle de su '+cargo.forms[form].data.label_es+'?':'¿Cuál es la dirección?'),true)")], { parameters: [P('form')], contract: { result: { path: 'cargo.forms[form].data', type: 'object' } } });
39
+ const cityPrompt = C('address-city-prompt', 'Ask which of the ZIP code\'s place names the address carries.', [S('address_city_prompt', 'noop', "(function(data,voice){var names=(data.location&&data.location.cities)||[],n=names.length,list=function(and){return names.slice(0,-1).join(', ')+' '+and+' '+names[n-1];};if(n<2){data.city_question=data.labelled?'What city is your '+data.label+' in?':'What city is it?';data.city_question_es=data.labelled?'¿En qué ciudad está su '+data.label_es+'?':'¿Qué ciudad es?';return true;}data.city_question=(data.labelled?'Which city is your '+data.label+' in: ':'Which city is it: ')+list('or')+'? '+(voice?names.map(function(c,i){return (i?'':'Press ')+(i+1)+' for '+c;}).join(', ')+'.':'Type the city or its number, 1 to '+n+'.');data.city_question_es=(data.labelled?'¿En qué ciudad está su '+data.label_es+': ':'¿Qué ciudad es: ')+list('o')+'? '+(voice?names.map(function(c,i){return (i?'':'Presione ')+(i+1)+' para '+c;}).join(', ')+'.':'Escriba la ciudad o su número, del 1 al '+n+'.');return true;})(cargo.forms[form].data,cargo.voice===true)")], { parameters: [P('form')], contract: { result: { path: 'cargo.forms[form].data', type: 'object' } } });
37
40
  // NO at the read-back asks which part is wrong and re-asks only that part; ALL starts over.
38
41
  const PARTS = [{ key: 'zip', phrases: ['1', 'zip', 'zip code', 'postal code', 'código postal', 'codigo postal'] }, { key: 'city', phrases: ['2', 'city', 'ciudad'] }, { key: 'street', phrases: ['3', 'street', 'calle'] }, { key: 'unit', phrases: ['4', 'apartment', 'apt', 'unit', 'apartamento', 'unidad', 'departamento'] }, { key: 'all', phrases: ['5', 'all', 'everything', 'all of it', 'todo', 'toda'] }];
39
42
  const declined = C('collect-geocoded-address-declined', 'Ask which part of the declined address is wrong, re-ask only that part, or start a fresh pass.', [
@@ -363,6 +363,7 @@ export const FLOWS: {
363
363
  parameters: {
364
364
  support_context: string;
365
365
  support_context_es: string;
366
+ exit_outcome: string;
366
367
  };
367
368
  };
368
369
  "condition: ac_key === '__text'": {
@@ -1 +1 @@
1
- {"version":3,"file":"choice-flow.d.ts","sourceRoot":"","sources":["../../src/forms/choice-flow.js"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAysBE"}
1
+ {"version":3,"file":"choice-flow.d.ts","sourceRoot":"","sources":["../../src/forms/choice-flow.js"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA0sBE"}
@@ -3,7 +3,7 @@ export const FLOWS = [
3
3
  {
4
4
  "id": "ask-choice",
5
5
  "name": "AskChoice",
6
- "version": "1.21.0",
6
+ "version": "1.22.0",
7
7
  "description": "Worker: ask one question and return cargo.choice plus the original cargo.choiceText. Declared choices, precheck keys and typed answer-validator keys keep priority across both read passes. Exact negative choices accept only their own declared words and keys. With amount, an unowned legacy payment question accepts a complete USD monetary answer or a simple payment instruction through readMoneyAmount; uncertain prose yields to DISPATCH without declaring an action failure. A lone digit keeps the question's keypad policy; amount:'marked' still requires marked money. An owning FORM supplies form_context and performs its own field, correction, provider-question and confirmation matching before deciding to retry or yield, retaining its draft and safety guards. Optional answer_precheck runs before choices; answer_validator runs only when no choice matched. AGENT/0 requests a person; EXIT/* leaves the request; a consumed switch offer routes its declared flow. Params include question(_es), choices [{key,phrases,exact?,negative?,neutral?}], retry(_es), accept_other, expect, amount, digits, exit_context(_es), pii and form_context.",
8
8
  "parameters": [
9
9
  { "name": "form_context", "type": "object", "description": "Optional declared FORM reader context {form,current,names,questions}; valid field readings take precedence over stale verification-code echoes." },
@@ -672,7 +672,8 @@ export const FLOWS = [
672
672
  "callType": "reboot",
673
673
  "parameters": {
674
674
  "support_context": "{{ac_exit_ctx}}",
675
- "support_context_es": "{{ac_exit_ctx_es}}"
675
+ "support_context_es": "{{ac_exit_ctx_es}}",
676
+ "exit_outcome": "{{$outcome.outcome}}"
676
677
  }
677
678
  },
678
679
  "condition: ac_key === '__text'": {
@@ -4,7 +4,7 @@ import { linkFormSchemas, validateFlowContracts } from './contracts.js';
4
4
  import { compileFormPrompts } from './prompt-compiler.js';
5
5
  import { withSafetyRevision } from './continuation-safety.js';
6
6
  import { capturedAuthorSpec, copyAuthorSpec, authoredExpressions } from './declaration-capture.js';
7
- const formKeys = new Set(['inputs', 'before', 'after', 'confirm', 'before_confirm', 'declined', 'stop', 'close_on_stop', 'resume_on_parent_change', 'done', 'validator', 'confirmation_condition', 'prompt', 'prompt_es', 'incomplete_outcome', 'on_exhausted', 'on_no', 'must_complete', 'first_task', 'first_task_es', 'acknowledge']);
7
+ const formKeys = new Set(['inputs', 'before', 'after', 'confirm', 'before_confirm', 'declined', 'stop', 'close_on_stop', 'resume_on_parent_change', 'done', 'validator', 'confirmation_condition', 'prompt', 'prompt_es', 'incomplete_outcome', 'on_exhausted', 'on_no', 'must_complete', 'first_task', 'first_task_es', 'user_description', 'user_description_es', 'acknowledge']);
8
8
  const sharedKeys = ['id', 'name', 'description', 'version', 'scope', 'primary', 'parameters', 'contract', 'parameterInstructions'];
9
9
  const safe = /^[A-Za-z_$][\w$]*$/;
10
10
  const fail = message => { throw new Error('Flow declaration: ' + message); };
@@ -17,7 +17,7 @@ export function validateRankParameters(id: any, name: any, what: any, list: any)
17
17
  * confirmation is soft, a plain form's (no action) included (owner 2026-11-09). confirm.exact is separate: it binds the
18
18
  * action to the confirmed values, whatever the confirmation's firmness. */
19
19
  export function confirmationFirmness(performs: any): "firm" | "soft";
20
- export function formFlow({ id, name, version, description, inputs, after, extraVars, parameters, confirm, confirm_soft, before_confirm, declined, stop, close_on_stop, on_no, resume_on_parent_change, before, done, primary, scope, validator, confirmation_condition, prompt, prompt_es, incomplete_outcome, on_exhausted, must_complete, first_task, first_task_es, acknowledge }: {
20
+ export function formFlow({ id, name, version, description, inputs, after, extraVars, parameters, confirm, confirm_soft, before_confirm, declined, stop, close_on_stop, on_no, resume_on_parent_change, before, done, primary, scope, validator, confirmation_condition, prompt, prompt_es, incomplete_outcome, on_exhausted, must_complete, first_task, first_task_es, user_description, user_description_es, acknowledge }: {
21
21
  id: any;
22
22
  name: any;
23
23
  version: any;
@@ -47,6 +47,8 @@ export function formFlow({ id, name, version, description, inputs, after, extraV
47
47
  must_complete?: boolean | undefined;
48
48
  first_task?: string | undefined;
49
49
  first_task_es?: string | undefined;
50
+ user_description?: string | undefined;
51
+ user_description_es?: string | undefined;
50
52
  acknowledge?: string | undefined;
51
53
  }): {
52
54
  variables: {
@@ -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;AAslBD,wHAAwH;AACxH,wEAaC;AACD,4FAA4F;AAC5F;;;EAYC;AACD,sGAAsG;AACtG;;;EAOC;AApzBM,6CAAuG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6gC9G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAOG"}
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;AAkmBD,wHAAwH;AACxH,wEAaC;AACD,4FAA4F;AAC5F;;;EAYC;AACD,sGAAsG;AACtG;;;EAOC;AAh0BM,6CAAuG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0hC9G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAOG"}
@@ -151,7 +151,7 @@ function validateAcceptanceDeclarations(id, inputs) {
151
151
  export function confirmationFirmness(performs) {
152
152
  return Array.isArray(performs) && performs.some((action) => action?.effect === 'charge') ? 'firm' : 'soft';
153
153
  }
154
- export function formFlow({ id, name, version, description, inputs, after = [], extraVars = {}, parameters = [], confirm = null, confirm_soft = confirmationFirmness([]) === 'soft', before_confirm = [], declined = [], stop = '', close_on_stop = false, on_no = '', resume_on_parent_change = false, before = [], done = true, primary = false, scope = 'isolated', validator = '', confirmation_condition = 'true', prompt = undefined, prompt_es = undefined, incomplete_outcome = null, on_exhausted = null, must_complete = false, first_task = '', first_task_es = '', acknowledge = 'all' }) {
154
+ export function formFlow({ id, name, version, description, inputs, after = [], extraVars = {}, parameters = [], confirm = null, confirm_soft = confirmationFirmness([]) === 'soft', before_confirm = [], declined = [], stop = '', close_on_stop = false, on_no = '', resume_on_parent_change = false, before = [], done = true, primary = false, scope = 'isolated', validator = '', confirmation_condition = 'true', prompt = undefined, prompt_es = undefined, incomplete_outcome = null, on_exhausted = null, must_complete = false, first_task = '', first_task_es = '', user_description = '', user_description_es = '', acknowledge = 'all' }) {
155
155
  validateFormExhaustion(on_exhausted);
156
156
  if (acknowledge !== 'all' && acknowledge !== 'data')
157
157
  throw new Error(`FORM ${id}: acknowledge must be 'all' or 'data'`);
@@ -192,13 +192,13 @@ export function formFlow({ id, name, version, description, inputs, after = [], e
192
192
  ] : [];
193
193
  return {
194
194
  id, name, version, description, scope, metadata: { formProtocol: 2 }, parameters: [...parameters, { name: 'form_instance', type: 'string', internal: true, description: 'Internal instance to resume' }], ...(primary ? { primary: true } : {}), ...(prompt ? { prompt, prompt_es } : {}),
195
- variables: vars({ form_on_exhausted: on_exhausted, form_on_no: on_no, form_must_complete: must_complete, form_incomplete_outcome: incompleteFrom ? null : incomplete_outcome, form_instance: '', form_internal_resume: false, form_resume_owner: '', form_arguments: {}, form_exhaustion: null, form_values: {}, form_validation: '', initial_readings: [], inputs: resolveFormInputs(inputs, FIELD_PRESETS), parent_form: '', result_input: '', questions: [], provides: null, exit_context: '', exit_context_es: '', form_confirm_q: '', form_confirm_q_es: '', form_confirm_firmness: '', form_confirmation: confirm || {}, form_should_confirm: false, ...extraVars }),
195
+ variables: vars({ form_on_exhausted: on_exhausted, form_on_no: on_no, form_must_complete: must_complete, form_incomplete_outcome: incompleteFrom ? null : incomplete_outcome, form_instance: '', form_internal_resume: false, form_resume_owner: '', form_arguments: {}, form_exhaustion: null, form_values: {}, form_validation: '', initial_readings: [], inputs: resolveFormInputs(inputs, FIELD_PRESETS), parent_form: '', result_input: '', questions: [], provides: null, exit_context: '', exit_context_es: '', form_confirm_q: '', form_confirm_q_es: '', form_confirm_firmness: '', form_confirmation: confirm || {}, form_should_confirm: false, ...(user_description ? { form_user_description: user_description } : {}), ...(user_description_es ? { form_user_description_es: user_description_es } : {}), ...extraVars }),
196
196
  steps: [
197
197
  ...contextualResponseRuntimeSteps(id, [], hasFormResponse(inputs) ? [CONTEXTUAL_RESPONSES_REQUIREMENT] : []),
198
198
  ...(hasFormResponse(inputs) ? [{ ...SET(`${id}_response_reader_required`, 'noop', "typeof validateFormResponse === 'function'"), requireTrue: true }] : []),
199
199
  ...proposalRuntimeSteps(id, [], hasInputProposals(inputs) ? [INPUT_PROPOSALS_REQUIREMENT] : []),
200
200
  SET(`${id}_resume_kind`, 'form_internal_resume', '!!form_instance'),
201
- SET(`${id}_open`, 'form_instance', `openFormInstance(cargo, ${JSON.stringify(id)}, inputs, { parent: parent_form || null, input: result_input || '', context:!!parent_form && !result_input, resume_on_parent_change: ${resume_on_parent_change === true}, resume: form_instance || (!parent_form ? (cargo.formTasks || {})[${JSON.stringify(id)}] || '' : ''), providers: provides, questions: questions, incomplete_outcome: ${incompleteExpression}, on_exhausted: form_on_exhausted, on_no: form_on_no, must_complete: form_must_complete${first_task ? `, first_task: ${JSON.stringify(first_task)}` : ''}${first_task_es ? `, first_task_es: ${JSON.stringify(first_task_es)}` : ''}${acknowledge === 'data' ? ", acknowledge: 'data'" : ''} })`),
201
+ SET(`${id}_open`, 'form_instance', `openFormInstance(cargo, ${JSON.stringify(id)}, inputs, { parent: parent_form || null, input: result_input || '', context:!!parent_form && !result_input, resume_on_parent_change: ${resume_on_parent_change === true}, resume: form_instance || (!parent_form ? (cargo.formTasks || {})[${JSON.stringify(id)}] || '' : ''), providers: provides, questions: questions, incomplete_outcome: ${incompleteExpression}, on_exhausted: form_on_exhausted, on_no: form_on_no, must_complete: form_must_complete${first_task ? `, first_task: ${JSON.stringify(first_task)}` : ''}${first_task_es ? `, first_task_es: ${JSON.stringify(first_task_es)}` : ''}${user_description ? ', user_description: form_user_description' : ''}${user_description_es ? ', user_description_es: form_user_description_es' : ''}${acknowledge === 'data' ? ", acknowledge: 'data'" : ''} })`),
202
202
  SIDE(`${id}_task`, `(!parent_form ? (cargo.formTasks = cargo.formTasks || {}, cargo.formTasks[${JSON.stringify(id)}] = form_instance) : true, true)`),
203
203
  SIDE(`${id}_provider_reset`, '(delete cargo.forms[form_instance].providerRequests, delete cargo.forms[form_instance].activeGates, delete cargo.forms[form_instance].afterRunning, delete cargo.forms[form_instance].providerGateActive, true)'),
204
204
  SIDE(`${id}_pass_reset`, '(cargo.forms[form_instance].replays = 0, form_internal_resume ? true : (cargo.forms[form_instance].attempts = {},cargo.forms[form_instance].misses={},cargo.forms[form_instance].feedback={}), true)'),
@@ -468,15 +468,21 @@ const RANK_LABEL_JS = "function(c){var said=(Array.isArray(c.phrases) ? c.phrase
468
468
  // already offered is not offered twice. Each carries its input, so a pick is read as that input's answer.
469
469
  const otherChoicesJS = (asked, taken, scope = `i.form===form && i.name!==${asked}`) => `(function(){var seen=(${taken}).map(function(c){return String(c.key);}).concat(['yes','no']);return (chain || []).filter(function(i){return ${scope} && !i.confirmation && i.profile && i.profile.kind==='choice' && Array.isArray(i.profile.choices);}).reduce(function(all,i){return all.concat(i.profile.choices.filter(function(c){var k=String(c.key);if(c.current_only===true||seen.indexOf(k)>=0)return false;seen.push(k);return true;}).map(function(c){return Object.assign({key:String(c.key),label:(${RANK_LABEL_JS})(c),owner:{form:i.form,name:i.name}},Array.isArray(c.parameters) && c.parameters.length ? {parameters:c.parameters} : {});}));},[]);})()`;
470
470
  const escapeRoutes = (id) => [WHEN(`${id}_agent`, "reply && reply.key === '__agent'", FLOW(`${id}_agent_flow`, 'live-agent-requested', 'reboot'))];
471
- const rankedDispatch = (id, reason, stay = false, parameters = '') => ({ ...yieldDispatch(id, 'form', `'${reason}'`), onResponse: 'continue', responseContext: 'Current question: {{asked}}', responseChoices: 'ranked', responseVariable: 'reply', ...(parameters ? { responseParameters: parameters } : {}), ...(stay ? { responseStay: 'stay' } : {}) });
471
+ const rankedDispatch = (id, reason, stay = false, parameters = '') => ({ ...yieldDispatch(id, 'form', `'${reason}'`), onResponse: 'continue', responseContext: 'Current question: {{asked}}', responseChoices: 'ranked', responseVariable: 'reply', responseConcern: '{{concern}}', ...(parameters ? { responseParameters: parameters } : {}), ...(stay ? { responseStay: 'stay' } : {}) });
472
+ // CONCERN (owner 2026-11-11): the nearest form in the chain that declares user_description says what its process does. The
473
+ // ranker is offered `concern` only then; a concern says the description, how to cancel, and the question again, with no attempt.
474
+ const concernText = (id) => SET(id, 'concern', "formUserDescription(cargo,form,language === 'es')");
475
+ const concernRoute = (id, input) => [WHEN(id, 'reply && reply.concern === true', SIDE(`${id}_line`, `(cargo.forms[form].feedback=cargo.forms[form].feedback || {},cargo.forms[form].feedback[${input}]='concern',true)`)), WHEN(`${id}_end`, 'reply && reply.concern === true', END(`${id}_done`))];
472
476
  const readFormReply = {
473
477
  id: 'read-form-reply', name: 'ReadFormReply', version: '1.1.0', scope: 'isolated', description: 'Rank an unreadable answer against its question: a request for a person or for text is taken; an answer is asked again; a withdrawal or a new request leaves with saved form progress.',
474
478
  parameters: [{ name: 'form', type: 'string' }, { name: 'input', type: 'string' }, { name: 'question', type: 'string' }, { name: 'question_es', type: 'string' }],
475
- variables: vars({ question: '', question_es: '', asked: '', ranked: [], reply: null }),
479
+ variables: vars({ question: '', question_es: '', asked: '', ranked: [], reply: null, concern: '' }),
476
480
  steps: [SET('reply_asked', 'asked', "language === 'es' && question_es ? question_es : question"),
481
+ concernText('reply_concern_text'),
477
482
  rankedChoices('reply_ranked', '[]'),
478
483
  rankedDispatch('reply_dispatch', 'input_not_matched'),
479
484
  ...escapeRoutes('reply_escape'),
485
+ ...concernRoute('reply_concern', 'input'),
480
486
  rankedMiss('reply_miss')]
481
487
  };
482
488
  // A provider menu's fact named inside a longer sentence (provides.menu.whole_phrases): the phrase does not decide, the ranker
@@ -518,7 +524,7 @@ const RANK_ARGUMENTS_JS = `(function(){
518
524
  const readFormChoice = {
519
525
  id: 'read-form-choice', name: 'ReadFormChoice', version: '1.4.0', scope: 'isolated', description: 'Rank an unreadable answer to a choice question and take the offered option it picks, or a request for a person or for text; otherwise ask again. A withdrawal or a new request leaves with saved form progress.',
520
526
  parameters: [{ name: 'form', type: 'string' }, { name: 'input', type: 'string' }, { name: 'question', type: 'string' }, { name: 'question_es', type: 'string' }, { name: 'choices', type: 'array' }, { name: 'firm', type: 'string' }],
521
- variables: vars({ question: '', question_es: '', choices: [], firm: '', asked: '', ranked: [], reply: null, picked: '', chain: null, reading: null, others: [], owner: null, stay: false, params: [], rank_params: [], args: null }),
527
+ variables: vars({ question: '', question_es: '', choices: [], firm: '', asked: '', ranked: [], reply: null, picked: '', chain: null, reading: null, others: [], owner: null, stay: false, params: [], rank_params: [], args: null, concern: '' }),
522
528
  steps: [SET('choice_asked', 'asked', "language === 'es' && question_es ? question_es : question"),
523
529
  SET('choice_params', 'params', "(function(){var spec=((cargo.forms[form] || {}).specs || []).filter(function(i){return i.name===input;})[0];return spec && Array.isArray(spec.rank_parameters) ? spec.rank_parameters : [];})()"),
524
530
  SET('choice_rank_params', 'rank_params', "params.map(function(p){return {name:p.name,type:p.type || 'string',description:p.description};})"),
@@ -526,8 +532,10 @@ const readFormChoice = {
526
532
  SET('choice_stay', 'stay', 'formMustComplete(cargo,form,input)'),
527
533
  SET('choice_others', 'others', otherChoicesJS('input', 'choices || []', "!(i.form===form && i.name===input)")),
528
534
  rankedChoices('choice_ranked', `(choices || []).filter(function(c,i,all){return !(firm==='firm' && String(c.key)==='yes') && all.findIndex(function(o){return String(o.key)===String(c.key);})===i;}).map(function(c){return Object.assign({key:String(c.key),label:(${RANK_LABEL_JS})(c)},Array.isArray(c.parameters) && c.parameters.length ? {parameters:c.parameters.map(function(p){return {name:p.name,type:p.type || 'string',description:p.description};})} : {});}).concat(others.map(function(c){return Object.assign({key:c.key,label:c.label},c.parameters ? {parameters:c.parameters.map(function(p){return {name:p.name,type:p.type || 'string',description:p.description};})} : {});}))`),
535
+ concernText('choice_concern_text'),
529
536
  rankedDispatch('choice_dispatch', 'input_not_matched', true, 'rank_params'),
530
537
  ...escapeRoutes('choice_escape'),
538
+ ...concernRoute('choice_concern', 'input'),
531
539
  SET('choice_picked', 'picked', "(function(){var k=String(reply && reply.key || '');var c=(choices || []).filter(function(c){return String(c.key)===k;})[0] || others.filter(function(c){return c.key===k;})[0];return c ? String(c.key) : '';})()"),
532
540
  // A question over any_of asks one name and its choices belong to a member ('selection' asks, 'option' holds PAST DUE): the pick is read as the member's answer.
533
541
  SET('choice_owner', 'owner', "(others.filter(function(c){return c.key===picked && !(choices || []).some(function(own){return String(own.key)===picked;});})[0] || {}).owner || (function(){var asked=(chain || []).filter(function(i){return i.form===form && i.name===input;})[0];if(asked || !picked)return null;var spec=((cargo.forms[form] || {}).specs || []).filter(function(i){return i.name===input;})[0];var names=((spec || {}).any_of || []).map(function(i){return i.name;});var member=(chain || []).filter(function(i){return i.form===form && names.indexOf(i.name)>=0 && i.profile && (i.profile.choices || []).some(function(c){return String(c.key)===picked;});})[0];return member ? {form:member.form,name:member.name} : null;})()"),
@@ -552,12 +560,12 @@ const readFormChoice = {
552
560
  // A confirmation's unread answer goes to the reply ranker with the confirmation question (owner 2026-10-27), never
553
561
  // straight to the host. A firm confirmation authorizes the form's action, so the ranker is offered NO, the form's other
554
562
  // choices (a correction) and a person, never YES; a soft one (no exact action) is offered YES too (owner 2026-11-08:
555
- // prod 11:07 "Sí, para enviar." at a ticket's confirmation). Result: cargo.confirmRanked = 'yes' | 'no' | 'changed' | 'none'
563
+ // prod 11:07 "Sí, para enviar." at a ticket's confirmation). Result: cargo.confirmRanked = 'yes' | 'no' | 'changed' | 'none' | 'concern'
556
564
  // (ConfirmForm reads it); `abort` ends every flow; `new_request` goes to intent detection.
557
565
  const readConfirmReply = {
558
566
  id: 'read-confirm-reply', name: 'ReadConfirmReply', version: '1.4.0', scope: 'isolated', description: 'Rank an unreadable answer to a confirmation: it declines (NO), picks another of the form\'s choices (a correction, read as that input\'s answer), says a named field read back is wrong (confirm.named_fields: that input is asked again), asks for a person, or is asked again; a withdrawal or a new request leaves with saved form progress. Never confirms.',
559
567
  parameters: [{ name: 'form', type: 'string' }, { name: 'confirmation', type: 'string' }, { name: 'question', type: 'string' }, { name: 'question_es', type: 'string' }, { name: 'named_fields', type: 'boolean' }, { name: 'reply_context', type: 'string' }, { name: 'rank_parameters', type: 'array' }, { name: 'invites', type: 'array' }],
560
- variables: vars({ confirmation: '', question: '', question_es: '', asked: '', ranked: [], reply: null, chain: null, others: [], fields: [], field: null, picked: null, reading: null, named_fields: false, prompt: null, field_arguments: [], corrections: [], reply_context: '', stay: false, rank_parameters: [], invites: [], rank_params: [], args: null }),
568
+ variables: vars({ confirmation: '', question: '', question_es: '', asked: '', ranked: [], reply: null, chain: null, others: [], fields: [], field: null, picked: null, reading: null, named_fields: false, prompt: null, field_arguments: [], corrections: [], reply_context: '', stay: false, rank_parameters: [], invites: [], rank_params: [], args: null, concern: '' }),
561
569
  steps: [
562
570
  SET('confirm_asked', 'asked', "(language === 'es' && question_es ? question_es : question)+(reply_context ? ' '+reply_context : '')"),
563
571
  SET('confirm_stay', 'stay', "formMustComplete(cargo,form,'__confirm')"),
@@ -574,8 +582,11 @@ const readConfirmReply = {
574
582
  rankedChoices('confirm_ranked_choices', "(confirmation==='soft' ? [{key:'yes',label:'yes: agrees to what the question asks to confirm'}] : []).concat([{key:'no',label:'no: declines or refuses what the question asks to confirm'}]).concat(others.map(function(c){return Object.assign({key:c.key,label:c.label},c.parameters ? {parameters:c.parameters.map(function(p){return {name:p.name,type:p.type || 'string',description:p.description};})} : {});})).concat(fields.map(function(c){return {key:c.key,label:c.label,parameters:field_arguments};}))"),
575
583
  // confirm.rank_parameters: values extracted when the ranker says the reply answers (owner 2026-11-06), read as RANK_ARGUMENTS_JS says
576
584
  SET('confirm_rank_params', 'rank_params', "(Array.isArray(rank_parameters) ? rank_parameters : []).map(function(p){return {name:p.name,type:p.type || 'string',description:p.description};})"),
585
+ concernText('confirm_concern_text'),
577
586
  rankedDispatch('confirm_dispatch', 'confirmation_not_matched', true, 'rank_params'),
578
587
  ...escapeRoutes('confirm_escape'),
588
+ WHEN('confirm_concern', 'reply && reply.concern === true', SIDE('confirm_concern_line', "(cargo.forms[form].feedback=cargo.forms[form].feedback || {},cargo.forms[form].feedback['__confirm']='concern',cargo.confirmRanked='concern',true)")),
589
+ WHEN('confirm_concern_end', 'reply && reply.concern === true', END('confirm_concern_done')),
579
590
  // a correction picked by the ranker is read as its input's answer: the form changes and is confirmed again, never confirmed
580
591
  SET('confirm_picked', 'picked', "others.filter(function(c){return reply && c.key===reply.key;})[0] || null"),
581
592
  SET('confirm_read', 'reading', "picked ? enrichFormMatches(readFormAnswer(picked.key, chain, picked.owner, picked.key, []), chain, form, [picked.owner.name], picked.owner.name) : null"),
@@ -737,10 +748,11 @@ const confirmForm = {
737
748
  default: SET('cf_unclear', 'cf_result', "'unclear'")
738
749
  } },
739
750
  // the ranker's reading of an unread answer: a decline is the NO; an answer that declines nothing is asked again
740
- SET('cf_ranked', 'cf_result', "cf_result ? cf_result : cargo.confirmRanked === 'yes' ? 'yes' : cargo.confirmRanked === 'no' ? 'no' : cargo.confirmRanked === 'none' ? 'unclear' : ''"),
751
+ SET('cf_ranked', 'cf_result', "cf_result ? cf_result : cargo.confirmRanked === 'yes' ? 'yes' : cargo.confirmRanked === 'no' ? 'no' : cargo.confirmRanked === 'none' ? 'unclear' : cargo.confirmRanked === 'concern' ? 'concern' : ''"),
741
752
  SET('cf_changed', 'cf_result', "cf_result ? cf_result : 'changed'"),
742
753
  // an unclear answer is asked again (the form runs again and reaches this question), at most twice
743
- SET('cf_tries_count', 'cf_tries', "cf_result === 'unclear' ? missFormInput(cargo,form,'__confirm') : (clearFormMisses(cargo,form,'__confirm'),0)"),
754
+ // a concern is answered and asked again: no attempt, and the misses so far stand
755
+ SET('cf_tries_count', 'cf_tries', "cf_result === 'unclear' ? missFormInput(cargo,form,'__confirm') : cf_result === 'concern' ? 0 : (clearFormMisses(cargo,form,'__confirm'),0)"),
744
756
  WHEN('cf_first', 'cf_must && cf_result === \'unclear\' && cf_words > 0', SIDE('cf_first_line', "(cargo.forms[form].feedback['__confirm']='first',true)")),
745
757
  // out of attempts: the give-up worker (a person), never a silent DISPATCH that ends the request unanswered
746
758
  optionalIncomplete('cf_optional_exhausted', 'cf_tries >= 2 && !cf_must', 'form', "'confirmation_misses_exhausted'"),
@@ -748,7 +760,7 @@ const confirmForm = {
748
760
  WHEN('cf_misses_exhausted', 'cf_tries >= 2 && !cf_must', FLOW('cf_give_up', 'give-up', 'reboot', { context: '{{exit_context}}', context_es: '{{exit_context_es}}' })),
749
761
  WHEN('cf_clarified_no_sorry', 'cf_clarify', SIDE('cf_clarified_feedback', "consumeFormFeedback(cargo,form,'__confirm')")),
750
762
  WHEN('cf_bind_revision', "cf_result === 'yes'", SIDE('cf_bind', 'confirmFormRevision(cargo, form)')),
751
- SIDE('cf_store', "(cargo.formConfirm[form] = cf_result === 'unclear' || cf_result === 'clarification' ? 'changed' : cf_result, true)"),
763
+ SIDE('cf_store', "(cargo.formConfirm[form] = cf_result === 'unclear' || cf_result === 'clarification' || cf_result === 'concern' ? 'changed' : cf_result, true)"),
752
764
  ],
753
765
  };
754
766
  // ── proposed input: owned confirmation before canonical acceptance or callbacks ────────────────────────────
@@ -881,7 +893,7 @@ export function finishProviderRequest(cargo, owner, provides, keys) {
881
893
  return { keys: own ? own.keys : keys, remaining: queue.filter(entry => entry.catalog !== catalog) };
882
894
  }
883
895
  const provideData = {
884
- id: 'provide-data', name: 'ProvideData', version: '1.0.0', scope: 'isolated',
896
+ id: 'provide-data', name: 'ProvideData', version: '1.1.0', scope: 'isolated',
885
897
  description: "Worker: answer a question about a provider catalog. Resolves `asked` (a fact or set key; empty = ask which), passes the catalog's gate for non-public facts (gate.flow, called with gate_params; then every path in gate.verified must be truthy), loads the source (load-source), says the facts (answer-facts). Params: provides, asked.",
886
898
  parameters: [{ name: 'form', type: 'string', description: 'Originating FORM instance for task-owned deferred questions' }, { name: 'provides', type: 'object', description: 'The provider catalog' }, { name: 'asked', type: 'string', description: 'Fact or set key' }, { name: 'reply', type: 'string', description: 'The words that started the provider, this turn: tells a question back from its own menu from a later one' }, { name: 'asked_keys', type: 'array', description: 'Independent requested facts or sets' }, { name: 'no_menu', type: 'string', description: "'true': answer only (a question asked inside a form)" }, { name: 'gate_params', type: 'object', description: 'Identifiers the caller already gave, passed to the gate flow as gate_params' }, { name: 'no_gate', type: 'string', description: "'true': the caller is inside a task on the verified account; the gate flow is not run (the verified paths are still checked)" }],
887
899
  variables: vars({ reply: '', pd_unanswered: false, form: '', pd_request: null, pd_deferred: null, pd_ready: [], asked_keys: [], no_gate: '', pd_close: false, pd_who: '', no_menu: '', gate_params: null, pd_keys: [], pd_menu: [], pd_mkeys: [], pd_q: '', pd_q_es: '', pd_gated: false, pd_ok: false }),
@@ -909,7 +921,8 @@ const provideData = {
909
921
  SET('pd_gate_check', 'pd_ok', `!pd_gated || [].concat(provides.gate.verified).every(function (p) { return !!${PATH_JS}(p); })`),
910
922
  WHEN('pd_not_verified', '!pd_ok', END('pd_not_verified_end', { outcome: 'unresolved', reason: 'provide_data_not_verified', recovery: { version: 1, mode: 'none', reason: 'provide_data_not_verified' } })),
911
923
  WHEN('pd_load', 'provides.source && provides.source.flow', FLOW('pd_load_flow', 'load-source', 'call', { source: '{{provides.source}}' })),
912
- FLOW('pd_answer', 'answer-facts', 'call', { provides: '{{provides}}', keys: '{{pd_keys}}' }),
924
+ // the asked facts answered: this flow achieved its objective (flows read it as $outcome; a later step may replace it)
925
+ { ...FLOW('pd_answer', 'answer-facts', 'call', { provides: '{{provides}}', keys: '{{pd_keys}}' }), outcome: "{{pd_keys.length > 0 ? 'resolved' : ''}}", reason: 'fact_answered' },
913
926
  WHEN('pd_deferred_more', 'pd_deferred.remaining.length > 0', FLOW('pd_answer_deferred', 'provide-queued-data', 'call', { form: '{{form}}', requests: '{{pd_deferred.remaining}}' })),
914
927
  SET('pd_ready', 'pd_ready', `(${takeReadyProviderRequests.toString()})(cargo,form)`),
915
928
  WHEN('pd_ready_more', 'pd_ready.length > 0', FLOW('pd_answer_ready', 'provide-queued-data', 'call', { form: '{{form}}', requests: '{{pd_ready}}' })),
@@ -956,7 +969,7 @@ const providerUnanswered = {
956
969
  ],
957
970
  };
958
971
  const providerMenu = {
959
- id: 'provider-menu', name: 'ProviderMenu', version: '1.1.0', scope: 'isolated',
972
+ id: 'provider-menu', name: 'ProviderMenu', version: '1.2.0', scope: 'isolated',
960
973
  description: "Worker: after a provider answered, offer its menu (provides.menu: question(_voice)(_es) with {verb} / {name}; choices [{ key, phrases, flow, exact, set }]; done { phrases, say(_es) }). A fact or set named by its words is answered and the menu comes back (menu.whole_phrases: only when the phrase is the whole reply; a phrase inside a sentence goes to the reply ranker, whose no-pick is the host's); an action runs its flow (replace) after setting its `set` cargo fields; done says goodbye. Other phrases: DISPATCH. No phrases: asked once more, then 'anything else?'. Params: provides, retry.",
961
974
  parameters: [{ name: 'provides', type: 'object', description: 'The provider catalog' }, { name: 'retry', type: 'string', description: "'1' on the re-ask" }],
962
975
  variables: vars({ retry: '', pm_q: '', pm_q_es: '', pm_choices: [], pm_key: '', pm_keys: [], pm_contained: false, pm_also: [], pm_close: false, pm_flow: '', pm_bye: '', pm_bye_es: '', pm_who: '', pm_sorry: '', pm_sorry_es: '' }),
@@ -986,7 +999,7 @@ const providerMenu = {
986
999
  SET('pm_sorry_en', 'pm_sorry', "\"Sorry, I didn't catch that. \" + anythingElse('en', pm_who)"),
987
1000
  SET('pm_sorry_es_text', 'pm_sorry_es', "'Disculpe, no le entendí. ' + anythingElse('es', pm_who)"),
988
1001
  { id: 'pm_route', type: 'CASE', branches: {
989
- 'condition: pm_keys.length > 0': FLOW('pm_answer', 'answer-facts', 'call', { provides: '{{provides}}', keys: '{{pm_keys}}' }),
1002
+ 'condition: pm_keys.length > 0': { ...FLOW('pm_answer', 'answer-facts', 'call', { provides: '{{provides}}', keys: '{{pm_keys}}' }), outcome: 'resolved', reason: 'fact_answered' },
990
1003
  'condition: pm_flow': FLOW('pm_act', '{{pm_flow}}', 'replace'),
991
1004
  "condition: pm_key === 'done'": { id: 'pm_done', type: 'SAY', value: '{{pm_bye}}', value_es: '{{pm_bye_es}}', outcome: 'resolved' },
992
1005
  "condition: /[a-záéíóúüñ]/i.test(String(cargo.choiceText || ''))": { id: 'pm_elsewhere', type: 'DISPATCH' },
@@ -1 +1 @@
1
- {"version":3,"file":"identity-flows.d.ts","sourceRoot":"","sources":["../../src/forms/identity-flows.js"],"names":[],"mappings":"AA8CA,+GAA+G;AAC/G,oFAOC;AAQD,wFAAwF;AACxF,iDAGC;AACD,6CAMC;AACD,qHAQC;AAMD,4EAKC;AA6FD,2DAOC;AACD,4DAOC;AACD,gHAAgH;AAChH,8DAGC;AAqJD,8EAGC;AA4BD,4FAA4F;AAC5F;;;;EAOC;AAWD,oGAOC;AAhQD,iCAAgC,wIAAwI,CAAC;AACzK,wCAAuC,CAAC,CAAC;AA4QzC,0BAAmJ"}
1
+ {"version":3,"file":"identity-flows.d.ts","sourceRoot":"","sources":["../../src/forms/identity-flows.js"],"names":[],"mappings":"AA8CA,+GAA+G;AAC/G,oFAOC;AAQD,wFAAwF;AACxF,iDAGC;AACD,6CAMC;AACD,qHAQC;AAMD,4EAKC;AA6FD,2DAOC;AACD,4DAOC;AACD,gHAAgH;AAChH,8DAGC;AAqJD,8EAGC;AA4BD,4FAA4F;AAC5F;;;;EAOC;AAWD,oGAOC;AAhQD,iCAAgC,wIAAwI,CAAC;AACzK,wCAAuC,CAAC,CAAC;AAiRzC,0BAA8J"}
@@ -456,4 +456,10 @@ const failed = worker('verification-failed', 'VerificationFailed', 'End a verifi
456
456
  { id: 'vf_offer_agent', type: 'CASE', branches: { 'condition: !!vf_agent': { id: 'vf_agent_say', type: 'SAY', value: '{{vf_agent}}', value_es: '{{vf_agent_es}}' }, default: set('vf_agent_skip', 'noop', 'true') } },
457
457
  end('vf_end')]
458
458
  });
459
- export const FLOWS = [taskGate, resume, service, rawTransport, contact, declined, splitFailed, rejected, auth, code, validateCode, emailToo, retry, email, failed];
459
+ // The global exit (owner 2026-11-11): the engine starts this flow when the whole answer is *, EXIT, QUIT or SALIR (and the
460
+ // question declares no choice of its own for it), after every flow has ended. Default: the tenant's support closing with the outcome in force. A tenant
461
+ // gives the global exit its own path with a flow that `wraps` this one; the engine then starts that wrapper.
462
+ const globalExit = worker('global-exit', 'GlobalExit', 'Worker (started by the engine): the caller exited; give the support closing with the outcome in force.', { scope: 'isolated', parameters: [param('exit_outcome', 'The declared outcome in force when the caller exited (resolved: thanks)')], steps: [
463
+ call('global_exit_support', 'contact-support', { exit_outcome: '{{exit_outcome}}' }, 'reboot')
464
+ ] });
465
+ export const FLOWS = [taskGate, resume, service, rawTransport, contact, declined, splitFailed, rejected, auth, code, validateCode, emailToo, retry, email, failed, globalExit];
@@ -11,6 +11,12 @@ export function isWholeNo(input: any): boolean;
11
11
  * The word may be repeated ("Salir salir."), echo the prompt ("Salir para cancelar") or end in "now" (prod 2026-10-28).
12
12
  */
13
13
  export function isExitRequest(input: any): boolean;
14
+ /**
15
+ * Whether the WHOLE answer is the global exit (owner 2026-11-11): "*", EXIT, QUIT or SALIR, maybe repeated or with please /
16
+ * por favor / now. The engine ends every flow on it, at any question, before any reader or the reply ranker. "Cancel" and
17
+ * "cancelar" are not in it: they can be an answer (a menu's CANCEL choice), so they stay with the question.
18
+ */
19
+ export function isGlobalExit(input: any): boolean;
14
20
  /** Whether the WHOLE answer asks for a person ("agent", "I want to talk to a representative", "0") — for free-text prompts. */
15
21
  export function isAgentRequest(input: any): boolean;
16
22
  /** Whether the answer is (part of) a spelled address — letters said one at a time, or a spelled symbol. */
@@ -1 +1 @@
1
- {"version":3,"file":"answer.d.ts","sourceRoot":"","sources":["../../src/helpers/answer.js"],"names":[],"mappings":"AAsNA;;;GAGG;AACH,wEAkBC;AAED,qHAAqH;AACrH,+CAGC;AAED;;;;GAIG;AACH,mDAIC;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;;;;;;;;AAhgBD,qCAKwE"}
1
+ {"version":3,"file":"answer.d.ts","sourceRoot":"","sources":["../../src/helpers/answer.js"],"names":[],"mappings":"AAsNA;;;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;;;;;;;;AA3gBD,qCAKwE"}
@@ -265,6 +265,16 @@ export function isExitRequest(input) {
265
265
  const word = '(?:exit|quit|salir|abort|cancel|cancelar)';
266
266
  return b === '*' || new RegExp(`^${word}(?:[ .]+${word})*(?: para cancelar| to cancel)?(?: please| por favor| ahora| now)?$`).test(b);
267
267
  }
268
+ /**
269
+ * Whether the WHOLE answer is the global exit (owner 2026-11-11): "*", EXIT, QUIT or SALIR, maybe repeated or with please /
270
+ * por favor / now. The engine ends every flow on it, at any question, before any reader or the reply ranker. "Cancel" and
271
+ * "cancelar" are not in it: they can be an answer (a menu's CANCEL choice), so they stay with the question.
272
+ */
273
+ export function isGlobalExit(input) {
274
+ const b = normalize(input).replace(/^[.\s!]+|[.\s!]+$/g, '');
275
+ const word = '(?:exit|quit|salir)';
276
+ return /^\*(?:\s*\*)*$/.test(b) || new RegExp(`^${word}(?:[ .!]+${word})*(?: please| por favor| ahora| now)?$`).test(b);
277
+ }
268
278
  /** Whether the WHOLE answer asks for a person ("agent", "I want to talk to a representative", "0") — for free-text prompts. */
269
279
  export function isAgentRequest(input) {
270
280
  // the period normalize() keeps for emails is not part of the answer at its ends ("Operator." on a call, 2026-10-17)
@@ -1,5 +1,6 @@
1
1
  /** Return an isolated declaration copy; unknown response fields cannot silently become legacy dispatch. */
2
2
  export function validateContextualResponseStep(step: any, flow: any): {
3
+ concern?: any;
3
4
  reasonFor?: any;
4
5
  choices?: any;
5
6
  variable: any;
@@ -1 +1 @@
1
- {"version":3,"file":"contextual-response.d.ts","sourceRoot":"","sources":["../../src/helpers/contextual-response.js"],"names":[],"mappings":"AAMA,2GAA2G;AAC3G;;;;;;qBAoBC;AACD,oHAAoH;AACpH,2DAcC;AACD,+FAIC;AAED;;;GAGG;AACH,yDAMC;AA5DD,4FAA4F;AAC5F,+CAAgD,8BAA8B,CAAC;AACxE,qDAA0C;AA2D1C,kDAA8J"}
1
+ {"version":3,"file":"contextual-response.d.ts","sourceRoot":"","sources":["../../src/helpers/contextual-response.js"],"names":[],"mappings":"AAMA,2GAA2G;AAC3G;;;;;;;qBAsBC;AACD,oHAAoH;AACpH,2DAcC;AACD,+FAIC;AAED;;;GAGG;AACH,yDAMC;AA9DD,4FAA4F;AAC5F,+CAAgD,8BAA8B,CAAC;AACxE,qDAA0C;AA6D1C,kDAA8J"}
@@ -33,8 +33,11 @@ export function validateContextualResponseStep(step, flow) {
33
33
  // responseReasonFor: what the caller does not want; the reply is ranked as the reason for not wanting it (owner 2026-10-31).
34
34
  if (own(step, 'responseReasonFor') && (typeof step.responseReasonFor !== 'string' || choices))
35
35
  fail('responseReasonFor is a string, on a question without responseChoices');
36
+ // responseConcern: what the process does (a form's user_description); the ranker may read the reply as a concern about it.
37
+ if (own(step, 'responseConcern') && typeof step.responseConcern !== 'string')
38
+ fail('responseConcern is a string');
36
39
  try {
37
- return structuredClone({ parameters: dynamic ? [] : step.responseParameters || [], ...(dynamic ? { parametersFrom: step.responseParameters } : {}), variable: step.responseVariable, ...(choices ? { choices: step.responseChoices } : {}), ...(own(step, 'responseReasonFor') ? { reasonFor: step.responseReasonFor } : {}) });
40
+ return structuredClone({ parameters: dynamic ? [] : step.responseParameters || [], ...(dynamic ? { parametersFrom: step.responseParameters } : {}), variable: step.responseVariable, ...(choices ? { choices: step.responseChoices } : {}), ...(own(step, 'responseReasonFor') ? { reasonFor: step.responseReasonFor } : {}), ...(own(step, 'responseConcern') ? { concern: step.responseConcern } : {}) });
38
41
  }
39
42
  catch {
40
43
  fail('response parameters must be cloneable declaration data');
@@ -7,6 +7,14 @@ export function formMustComplete(cargo: any, id: any, input: any): boolean;
7
7
  /** A must_complete question's reply that picks nothing the ranker was offered is acknowledged, then the question again (owner
8
8
  * 2026-11-02): "I understand, first let's record your new card." The task is the nearest enclosing form's first_task. */
9
9
  export function formFirstLine(cargo: any, id: any, input: any, es: any): string;
10
+ /**
11
+ * A form's user_description (owner 2026-11-11): what the process does, for a caller who objects to or misunderstands it. The
12
+ * nearest form in the chain that declares one, from the asking form outward, so a shared sub-form (an address) speaks for the
13
+ * task that opened it. {{path}} reads that form's values, then its data, then cargo ('' when missing). '' when none declares one.
14
+ */
15
+ export function formUserDescription(cargo: any, id: any, es: any): string;
16
+ /** CONCERN: the description, how to cancel (the global exit: *, EXIT, SALIR), then the question again. */
17
+ export function formConcernLine(cargo: any, id: any, es: any): string;
10
18
  /**
11
19
  * Explicit retry wins. Otherwise acknowledge only an actual unrecognized answer, once per re-ask.
12
20
  * question_text / retry_text (and _es): the written-channel wording, used only when the conversation is not a call.
@@ -1 +1 @@
1
- {"version":3,"file":"form-conversation.d.ts","sourceRoot":"","sources":["../../src/helpers/form-conversation.js"],"names":[],"mappings":"AAMA,0EAGC;AACD,oEAGC;AACD;;qGAEqG;AACrG,2EAWC;AACD;yHACyH;AACzH,gFAIC;AACD;;;GAGG;AACH,+GASC;AAMD,oEAOC;AACD,8EAAwI;AAExI,yGAAyG;AACzG;;;;;;;;;;;;;;;;;;;;EAUC;AAED,sGAAsG;AACtG;;;;;;;;;;;;;;;;;;;;EAeC;AAED;2HAC2H;AAC3H,8EAOC"}
1
+ {"version":3,"file":"form-conversation.d.ts","sourceRoot":"","sources":["../../src/helpers/form-conversation.js"],"names":[],"mappings":"AAMA,0EAGC;AACD,oEAGC;AACD;;qGAEqG;AACrG,2EAWC;AACD;yHACyH;AACzH,gFAIC;AACD;;;;GAIG;AACH,0EAWC;AACD,0GAA0G;AAC1G,sEAIC;AACD;;;GAGG;AACH,+GAUC;AAMD,oEAOC;AACD,8EAAwI;AAExI,yGAAyG;AACzG;;;;;;;;;;;;;;;;;;;;EAUC;AAED,sGAAsG;AACtG;;;;;;;;;;;;;;;;;;;;EAeC;AAED;2HAC2H;AAC3H,8EAOC"}
@@ -57,6 +57,38 @@ export function formFirstLine(cargo, id, input, es) {
57
57
  }
58
58
  return es ? `Entiendo, primero vamos a ${task || 'terminar esto'}. ` : `I understand, first let's ${task || 'finish this'}. `;
59
59
  }
60
+ /**
61
+ * A form's user_description (owner 2026-11-11): what the process does, for a caller who objects to or misunderstands it. The
62
+ * nearest form in the chain that declares one, from the asking form outward, so a shared sub-form (an address) speaks for the
63
+ * task that opened it. {{path}} reads that form's values, then its data, then cargo ('' when missing). '' when none declares one.
64
+ */
65
+ export function formUserDescription(cargo, id, es) {
66
+ const seen = new Set();
67
+ while (id && cargo?.forms?.[id] && !seen.has(id)) {
68
+ seen.add(id);
69
+ const state = cargo.forms[id];
70
+ const text = es ? state.user_description_es || state.user_description : state.user_description;
71
+ if (typeof text === 'string' && text.trim()) {
72
+ const read = path => { const parts = path.split('.'); for (const root of [state.values, state.data, { cargo }]) {
73
+ let v = root;
74
+ for (const p of parts) {
75
+ v = v == null ? undefined : v[p];
76
+ }
77
+ if (v !== undefined && v !== null && v !== '')
78
+ return String(v);
79
+ } return ''; };
80
+ return text.replace(/\{\{\s*([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}/g, (m, path) => read(path)).replace(/\s+/g, ' ').trim();
81
+ }
82
+ id = state.parent;
83
+ }
84
+ return '';
85
+ }
86
+ /** CONCERN: the description, how to cancel (the global exit: *, EXIT, SALIR), then the question again. */
87
+ export function formConcernLine(cargo, id, es) {
88
+ const said = formUserDescription(cargo, id, es), end = /[.!?]$/.test(said) ? '' : '.';
89
+ const cancel = es ? (cargo?.voice ? 'Para cancelar, presione la tecla de asterisco o diga SALIR.' : 'Para cancelar, escriba SALIR.') : (cargo?.voice ? 'To cancel, press the asterisk key or say EXIT.' : 'To cancel, type EXIT.');
90
+ return (said ? said + end + ' ' : '') + cancel + ' ';
91
+ }
60
92
  /**
61
93
  * Explicit retry wins. Otherwise acknowledge only an actual unrecognized answer, once per re-ask.
62
94
  * question_text / retry_text (and _es): the written-channel wording, used only when the conversation is not a call.
@@ -70,6 +102,8 @@ export function formInputPrompt(cargo, id, input, spec, data = {}, language = 'e
70
102
  return es ? 'Continúe.' : 'Go on.';
71
103
  if (feedback === 'first')
72
104
  return formFirstLine(cargo, id, input, es) + (retry || question);
105
+ if (feedback === 'concern')
106
+ return formConcernLine(cargo, id, es) + question;
73
107
  if (feedback && retry)
74
108
  return retry;
75
109
  return (feedback === 'miss' ? sorryNotCaught(es ? 'es' : 'en', cargo) : '') + question;