jsfe 1.7.7 → 1.7.9

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.
Files changed (49) hide show
  1. package/dist/forms/authoring.d.ts +10 -0
  2. package/dist/forms/authoring.d.ts.map +1 -0
  3. package/dist/forms/authoring.js +109 -0
  4. package/dist/forms/choice-flow.js +2 -2
  5. package/dist/forms/continuation-safety.d.ts +4 -0
  6. package/dist/forms/continuation-safety.d.ts.map +1 -0
  7. package/dist/forms/continuation-safety.js +14 -0
  8. package/dist/forms/contracts.d.ts +7 -3
  9. package/dist/forms/contracts.d.ts.map +1 -1
  10. package/dist/forms/contracts.js +37 -13
  11. package/dist/forms/flows.d.ts.map +1 -1
  12. package/dist/forms/flows.js +45 -10
  13. package/dist/forms/identity-flows.d.ts.map +1 -1
  14. package/dist/forms/identity-flows.js +10 -3
  15. package/dist/forms/index.d.ts +3 -0
  16. package/dist/forms/index.d.ts.map +1 -1
  17. package/dist/forms/index.js +5 -1
  18. package/dist/forms/inspection.d.ts +12 -0
  19. package/dist/forms/inspection.d.ts.map +1 -0
  20. package/dist/forms/inspection.js +120 -0
  21. package/dist/helpers/answer.d.ts.map +1 -1
  22. package/dist/helpers/answer.js +10 -2
  23. package/dist/helpers/contextual-response.d.ts +3 -0
  24. package/dist/helpers/contextual-response.d.ts.map +1 -1
  25. package/dist/helpers/contextual-response.js +7 -0
  26. package/dist/helpers/form-conversation.d.ts +22 -0
  27. package/dist/helpers/form-conversation.d.ts.map +1 -1
  28. package/dist/helpers/form-conversation.js +29 -1
  29. package/dist/helpers/form-state.d.ts +2 -1
  30. package/dist/helpers/form-state.d.ts.map +1 -1
  31. package/dist/helpers/form-state.js +95 -8
  32. package/dist/helpers/index.d.ts +13 -1
  33. package/dist/helpers/index.d.ts.map +1 -1
  34. package/dist/helpers/index.js +7 -6
  35. package/dist/helpers/match-inputs.d.ts.map +1 -1
  36. package/dist/helpers/match-inputs.js +9 -32
  37. package/dist/helpers/money.d.ts +8 -2
  38. package/dist/helpers/money.d.ts.map +1 -1
  39. package/dist/helpers/money.js +31 -7
  40. package/dist/host/capabilities.d.ts.map +1 -1
  41. package/dist/host/capabilities.js +4 -1
  42. package/dist/index.d.ts +10 -0
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +122 -0
  45. package/dist/runtime-identity.js +1 -1
  46. package/docs/copilot-reference.md +5 -0
  47. package/docs/development-release.md +20 -0
  48. package/docs/forms.md +82 -0
  49. package/package.json +1 -1
@@ -0,0 +1,120 @@
1
+ import { nextFormInput, formValuesEqual } from '../helpers/form-state.js';
2
+ import { actionConfirmationValid } from '../helpers/form-actions.js';
3
+ const components = { collector: 'Form', provider: 'Provider', performer: 'Performer', worker: 'Worker', gate: 'Worker', router: 'Worker' };
4
+ const object = value => value && typeof value === 'object' && !Array.isArray(value);
5
+ const framesOf = session => (Array.isArray(session?.flowStacks) ? session.flowStacks : []).flat().filter(object);
6
+ /** Explain existing state; this neither authorizes an action nor records an event history.
7
+ * Values, request bodies, caller words and rendered questions are intentionally omitted.
8
+ * `previous` adds only observable field changes and invalidated confirmations; it cannot
9
+ * reconstruct intermediate events between the two snapshots.
10
+ */
11
+ export function explainSession(session, { flows = [], previous } = {}) {
12
+ if (!object(session))
13
+ throw new TypeError('explainSession requires a session snapshot');
14
+ if (!Array.isArray(flows))
15
+ throw new TypeError('explainSession flows must be an array');
16
+ const registry = new Map(flows.filter(object).map(flow => [flow.id, flow]));
17
+ const cargo = object(session.cargo) ? session.cargo : {};
18
+ const forms = object(cargo.forms) ? cargo.forms : {};
19
+ const frames = framesOf(session), entries = [];
20
+ const activeIds = new Set(frames.flatMap(frame => [frame.variables?.form_instance, frame.variables?.form, frame.variables?.rf_form]).filter(id => typeof id === 'string'));
21
+ let held = !!session.continuationSafetyHold, uncertain = false, collecting = false, confirming = false;
22
+ const entry = (kind, message, source = {}) => entries.push({ kind, message, component: components[registry.get(source.flowId)?.variables?.contract?.value?.role] || 'Unknown', ...source });
23
+ const actions = new Map();
24
+ const action = (record, source) => {
25
+ if (!object(record))
26
+ return;
27
+ const identity = record.key || record;
28
+ const priority = ['attempted', 'unknown'].includes(record.status) || record.result?.status === 'unknown' ? 3 : record.status === 'completed' ? 2 : record.status === 'prepared' ? 1 : 0;
29
+ if (priority === 3)
30
+ held = true;
31
+ const previous = actions.get(identity);
32
+ // A duplicate key is not proof that both sources agree. Keep its most conservative
33
+ // evidence independently of traversal order, including journal/form contradictions.
34
+ if (priority && (!previous || priority > previous.priority))
35
+ actions.set(identity, { priority, source: source.flowId ? source : previous?.source || source });
36
+ };
37
+ if (session.continuationSafetyHold)
38
+ entry('continuation_held', 'An earlier action or incompatible continuation requires review before continuing.');
39
+ for (const [id, state] of Object.entries(forms)) {
40
+ if (!object(state)) {
41
+ uncertain = true;
42
+ entry('unavailable', 'This form state cannot be inspected.', { form: id });
43
+ continue;
44
+ }
45
+ const source = { flowId: state.definition, form: id }, active = activeIds.has(id), before = previous?.cargo?.forms?.[id];
46
+ if (object(before)) {
47
+ const names = new Set([...Object.keys(before.values || {}), ...Object.keys(state.values || {})]);
48
+ for (const input of names)
49
+ if (!formValuesEqual(before.values?.[input], state.values?.[input]))
50
+ entry('input_changed', 'The field changed; its current value is withheld from the explanation.', { ...source, input });
51
+ if (before.confirmation && !formValuesEqual(before.confirmation, state.confirmation))
52
+ entry(state.confirmation ? 'confirmation_changed' : 'confirmation_invalidated', state.confirmation ? 'A different confirmation is now recorded; it must match the current proposal.' : 'The earlier confirmation no longer applies. A fresh confirmation is required for the revised proposal.', source);
53
+ }
54
+ let next;
55
+ try {
56
+ if (!Array.isArray(state.specs) || !object(state.values))
57
+ throw new TypeError('Incomplete snapshot');
58
+ next = nextFormInput(state, cargo);
59
+ }
60
+ catch {
61
+ uncertain = true;
62
+ entry('unavailable', 'Required input state cannot be determined from this snapshot.', source);
63
+ }
64
+ if (next) {
65
+ const blocked = next === '__blocked__';
66
+ entry(blocked ? 'input_blocked' : 'input_missing', blocked ? 'Required inputs are waiting on their prerequisites.' : active ? 'Collecting this required input.' : 'This saved form still needs this input.', { ...source, ...(!blocked ? { input: next } : {}), active });
67
+ if (active)
68
+ collecting = true;
69
+ }
70
+ const proposal = state.proposal;
71
+ if (proposal?.status === 'prepared' && next === '') {
72
+ const valid = actionConfirmationValid(cargo, id, proposal);
73
+ entry(valid ? 'confirmation_recorded' : 'confirmation_needed', valid ? 'Confirmation matches the current proposal; other execution guards still apply.' : 'Waiting for confirmation of the current proposal.', { ...source, active });
74
+ if (active && !valid)
75
+ confirming = true;
76
+ }
77
+ else if (state.confirmation && next) {
78
+ entry('confirmation_stale', 'A recorded confirmation cannot authorize an incomplete form.', source);
79
+ }
80
+ action(state.proposal, source);
81
+ for (const record of Object.values(state.actions || {}))
82
+ action(record, source);
83
+ for (const [input, proposal] of Object.entries(state.inputProposals || {}))
84
+ if (proposal && !proposal.committed && proposal.status === 'pending') {
85
+ entry('input_confirmation_needed', 'A proposed field value is waiting for confirmation.', { ...source, input, active });
86
+ if (active)
87
+ confirming = true;
88
+ }
89
+ }
90
+ for (const record of Object.values(cargo.actionJournal || {}))
91
+ action(record, {});
92
+ for (const { priority, source } of actions.values()) {
93
+ if (priority === 3)
94
+ entry('action_held', 'An action has been attempted and its result is not confirmed. Automatic repetition is blocked.', source);
95
+ else if (priority === 2)
96
+ entry('action_completed', 'An action attempt has a recorded result. This does not authorize another attempt.', source);
97
+ else
98
+ entry('action_prepared', 'An action proposal is prepared; execution still requires its guards.', source);
99
+ }
100
+ // Completed forms may already be cleared. The generic last result remains evidence of
101
+ // its recorded outcome, but carries no authority or reliable component identity by itself.
102
+ const lastResult = cargo.actionResult;
103
+ const resultMessages = { ok: 'The most recent action result is recorded as successful.', failed: 'The most recent action result is recorded as failed.', unknown: 'The most recent action result is unconfirmed; consult the current action hold.', not_applicable: 'The most recent performer recorded that no action was applicable.' };
104
+ if (object(lastResult) && Object.hasOwn(resultMessages, lastResult.status))
105
+ entry('action_result', resultMessages[lastResult.status]);
106
+ const handoff = session.lastTurnDispatch;
107
+ const handedOff = handoff?.matchedFlow === null && frames.length === 0;
108
+ if (handedOff)
109
+ entry('handoff', 'DISPATCH yielded this turn to the host for contextual interpretation.', { flowId: registry.has(handoff.fromFlow) ? handoff.fromFlow : [...registry.values()].find(flow => flow.name === handoff.fromFlow)?.id });
110
+ const current = frames.at(-1);
111
+ if (current) {
112
+ const step = current.flowStepsStack?.at(-1);
113
+ const reversed = [...frames].reverse();
114
+ const author = reversed.find(frame => ['Form', 'Provider', 'Performer'].includes(registry.get(frame.flowId)?.metadata?.authoring?.component))
115
+ || reversed.find(frame => registry.get(frame.flowId)?.metadata?.authoring?.component)
116
+ || reversed.find(frame => { const definition = registry.get(frame.flowId); const role = definition?.variables?.contract?.value?.role; return ['provider', 'performer'].includes(role) || role === 'collector' && (definition?.primary || definition?.metadata?.formProtocol === 2); }) || current;
117
+ entry('current_step', 'Current execution location.', { flowId: author.flowId, ...(current.flowId !== author.flowId ? { workerFlowId: current.flowId } : {}), ...(step?.id ? { step: step.id } : {}) });
118
+ }
119
+ return { status: held ? 'held' : uncertain ? 'unknown' : handedOff ? 'handed_off' : confirming ? 'confirmation' : collecting ? 'collecting' : frames.length ? 'active' : 'idle', entries };
120
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"answer.d.ts","sourceRoot":"","sources":["../../src/helpers/answer.js"],"names":[],"mappings":"AAuLA;;;GAGG;AACH,wEAkBC;AAED,+HAA+H;AAC/H,oDAIC;AAcD,2GAA2G;AAC3G,uDAGC;AAOD;;;;;GAKG;AACH,+DAUC;AAKD;;;;GAIG;AACH,oDAEC;AAiBD;;;;;;GAMG;AACH,mDAAmF;AAEnF,kGAAkG;AAClG;;;EA6BC;AAUD;;;;;;;;;GASG;AACH,6EAyGC;;;;;;;;AApZD,qCAKiD"}
1
+ {"version":3,"file":"answer.d.ts","sourceRoot":"","sources":["../../src/helpers/answer.js"],"names":[],"mappings":"AAuLA;;;GAGG;AACH,wEAkBC;AAED,+HAA+H;AAC/H,oDAIC;AAcD,2GAA2G;AAC3G,uDAGC;AAOD;;;;;GAKG;AACH,+DAUC;AAKD;;;;GAIG;AACH,oDAEC;AAiBD;;;;;;GAMG;AACH,mDAAmF;AAEnF,kGAAkG;AAClG;;;EAmCC;AAUD;;;;;;;;;GASG;AACH,6EAyGC;;;;;;;;AA1ZD,qCAKiD"}
@@ -56,7 +56,7 @@ const NEGATIONS = ['no', 'not', 'nope', 'nah', 'never', 'dont', 'doesnt', 'didnt
56
56
  // Phrases that hold a negation word but agree ("no problem", "why not").
57
57
  const AGREEING = /\b(no problem|no worries|no hay problema|no te preocupes|why not|por que no|por qué no)\b/g;
58
58
  const DEFERRAL = /\b(later|tomorrow|next week|not now|not today|another time|mañana|manana|después|despues|luego|otro día|otro dia|ahora no|hoy no)\b/;
59
- const AGENT_ONLY = /^(?:(?:i want|i need|i would like|id like|can i|could i|let me|please|quiero|necesito|puedo|por favor)\s+)*(?:(?:to\s+)?(?:talk|speak|hablar|comunicarme)\s+(?:to|with|con)\s+)?(?:a|an|un|una|el|la)?\s*(?:live agent|agent|representative|rep|human|operator|real person|a person|person|someone|somebody|customer service|agente|representante|humano|operador|operadora|persona|alguien|servicio al cliente|gerente|manager|supervisor)(?:\s+(?:please|por favor))?$/;
59
+ const AGENT_ONLY = /^(?:(?:i want|i need|i would like|id like|can i|could i|let me|please|quiero|necesito|puedo|por favor)\s+)*(?:(?:to\s+)?(?:talk|speak|hablar|comunicarme)\s+(?:to|with|con)\s+)?(?:a|an|un|una|el|la)?\s*(?:live agent|agent|representative|rep|human|operator|real person|a person|person|someone|somebody|customer service|agente|representante|humano|operador|operadora|persona|alguien|servicio al cliente|agente en vivo|gerente|manager|supervisor)(?:\s+(?:please|por favor))?$/;
60
60
  // Accents are not meaning here (owner 2026-10-16): text callers type "direccion" for "dirección", "si" for "sí". Both
61
61
  // sides of every comparison pass through normalize, so a word list matches with or without them; ñ is kept.
62
62
  const plainVowels = (s) => s.replace(/[áàâä]/g, 'a').replace(/[éèêë]/g, 'e').replace(/[íìîï]/g, 'i').replace(/[óòôö]/g, 'o').replace(/[úùûü]/g, 'u');
@@ -273,7 +273,7 @@ export function isAmountAnswer(input) {
273
273
  return AMOUNT_ANSWER.test(String(input ?? '').replace(/\\(['"\\])/g, '$1'));
274
274
  }
275
275
  // A number that names something other than an amount: an account or sub-account, a card's last digits, a code, a ZIP.
276
- const IDENTIFIER_NUMBER = /\b(?:sub[\s-]?accounts?|accounts?|subcuentas?|cuentas?|cards?|tarjetas?|ending(?:\s+in)?|terminad[ao]s?\s+en|que\s+termina\s+en|termina\s+en|codes?|c[oó]digos?|zip(?:\s+code)?|postal|n[uú]mero|number)\s*(?:de\s+|is\s+|es\s+)?\d[\d\s-]*/gi;
276
+ const IDENTIFIER_NUMBER = /\b(?:sub[\s-]?accounts?|accounts?|subcuentas?|cuentas?|cards?|tarjetas?|ending(?:\s+in)?|terminad[ao]s?\s+en|que\s+termina(?:\s+en)?|termina(?:\s+en)?|codes?|c[oó]digos?|zip(?:\s+code)?|postal|n[uú]mero|number)\s*(?:de\s+|is\s+|es\s+)?\d[\d\s-]*/gi;
277
277
  // Digits spoken one at a time ("2 4 8 6"): a card ending or a code read back, never an amount.
278
278
  const SPELLED_DIGITS = /\b\d(?:\s+\d\b){2,}/g;
279
279
  // "10 con 18 centavos", "10 dollars and 18 cents", "$10 y 18 centavos"; speech-to-text also writes "76 con50 centavos", and
@@ -297,6 +297,14 @@ export function amountInAnswer(input) { return numericAmountReading(input).value
297
297
  /** Internal numeric evidence shared by the opt-in money reader; legacy results stay unchanged. */
298
298
  export function numericAmountReading(input) {
299
299
  const raw = String(input ?? '').replace(/\\(['"\\])/g, '$1');
300
+ // A connector plus cents is a fragment of another amount, not a new standalone payment.
301
+ // A caller can instead explicitly request "51 cents" or provide the complete dollars and cents.
302
+ if (/^\s*(?:and|con|y)\s*(?:un\s+)?\d{1,2}\s*(?:cents?|centavos?)\b/i.test(raw))
303
+ return { value: NaN, candidates: 0 };
304
+ // Last-four references (including a repeated unlabelled number) do not supply an amount.
305
+ // Mixed answers with an explicit monetary marker or payment verb still parse their independent amount.
306
+ if (/\b(?:cards?|tarjetas?|ending|termina(?:d[ao]s?)?|visa|mastercard|amex|discover)\b/i.test(raw) && !isAmountAnswer(raw) && !/\b(?:pay|paying|pagar|abonar)(?:\b|(?=\d))/i.test(raw))
307
+ return { value: NaN, candidates: 0 };
300
308
  // 1.234,56 (European) → 1234.56; 1,234.56 → 1234.56; 12,50 → 12.50
301
309
  let t = /\d{1,3}(\.\d{3})+,\d{1,2}\b/.test(raw) ? raw.replace(/\./g, '').replace(',', '.') : raw.replace(/,(?=\d{3}\b)/g, '').replace(/(\d),(\d{1,2})\b/g, '$1.$2');
302
310
  const dc = t.match(DOLLARS_AND_CENTS);
@@ -4,7 +4,10 @@ export function validateContextualResponseStep(step: any, flow: any): {
4
4
  variable: any;
5
5
  } | null | undefined;
6
6
  export function contextualResponseRuntimeSteps(id: any, steps: any, requirements?: any[]): any;
7
+ /** A normal extraction description for an open-ended FORM answer, using contextual DISPATCH. */
8
+ export function validateFormResponse(response: any): any;
7
9
  /** Explicit typed contextual responses. No engine state, transport, or host permissions. */
8
10
  export const CONTEXTUAL_RESPONSES_REQUIREMENT: "jsfe:contextual-responses:v1";
9
11
  export function contextualResponseProtocol(): number;
12
+ export function hasFormResponse(inputs: any): any;
10
13
  //# sourceMappingURL=contextual-response.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contextual-response.d.ts","sourceRoot":"","sources":["../../src/helpers/contextual-response.js"],"names":[],"mappings":"AAMA,2GAA2G;AAC3G;;;qBAiBC;AACD,+FAIC;AA7BD,4FAA4F;AAC5F,+CAAgD,8BAA8B,CAAC;AACxE,qDAA0C"}
1
+ {"version":3,"file":"contextual-response.d.ts","sourceRoot":"","sources":["../../src/helpers/contextual-response.js"],"names":[],"mappings":"AAMA,2GAA2G;AAC3G;;;qBAiBC;AACD,+FAIC;AAED,gGAAgG;AAChG,yDAGC;AAnCD,4FAA4F;AAC5F,+CAAgD,8BAA8B,CAAC;AACxE,qDAA0C;AAkC1C,kDAA8J"}
@@ -46,3 +46,10 @@ export function contextualResponseRuntimeSteps(id, steps, requirements = []) {
46
46
  const guard = { id: id + '_contextual_response_protocol', type: 'SET', variable: 'noop', value: 'contextualResponseProtocol() === 1', requireTrue: true };
47
47
  return steps[0]?.type === 'SET' && steps[0]?.value === guard.value && steps[0]?.requireTrue === true ? steps : [guard, ...steps];
48
48
  }
49
+ /** A normal extraction description for an open-ended FORM answer, using contextual DISPATCH. */
50
+ export function validateFormResponse(response) {
51
+ if (!response || typeof response !== 'object' || Array.isArray(response) || Object.keys(response).some(k => k !== 'description') || typeof response.description !== 'string' || !response.description.trim())
52
+ fail('FORM response requires a nonempty description only');
53
+ return structuredClone(response);
54
+ }
55
+ export const hasFormResponse = inputs => (inputs || []).some(input => input.response !== undefined || hasFormResponse(input.any_of) || hasFormResponse(input.schema?.inputs));
@@ -25,4 +25,26 @@ export function formConversationOutcome(cargo: any, id: any, reason: any, failur
25
25
  flow: any;
26
26
  };
27
27
  };
28
+ /** An explicit withdrawal retires the owning task; unknown actions remain held for reconciliation. */
29
+ export function cancelFormTask(cargo: any, id: any): {
30
+ outcome: any;
31
+ reason: any;
32
+ recovery: {
33
+ version: number;
34
+ mode: string;
35
+ reason: any;
36
+ form?: undefined;
37
+ flow?: undefined;
38
+ };
39
+ } | {
40
+ outcome: any;
41
+ reason: any;
42
+ recovery: {
43
+ version: number;
44
+ mode: string;
45
+ reason: any;
46
+ form: any;
47
+ flow: any;
48
+ };
49
+ };
28
50
  //# sourceMappingURL=form-conversation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"form-conversation.d.ts","sourceRoot":"","sources":["../../src/helpers/form-conversation.js"],"names":[],"mappings":"AAGA,0EAGC;AACD,oEAGC;AACD,sGAAsG;AACtG,+GAMC;AACD,8EAAwI;AAExI,yGAAyG;AACzG;;;;;;;;;;;;;;;;;;;;EAUC"}
1
+ {"version":3,"file":"form-conversation.d.ts","sourceRoot":"","sources":["../../src/helpers/form-conversation.js"],"names":[],"mappings":"AAGA,0EAGC;AACD,oEAGC;AACD,sGAAsG;AACtG,+GAMC;AACD,8EAAwI;AAExI,yGAAyG;AACzG;;;;;;;;;;;;;;;;;;;;EAUC;AAED,sGAAsG;AACtG;;;;;;;;;;;;;;;;;;;;EAeC"}
@@ -1,5 +1,5 @@
1
1
  /** Shared FORM retry, contextual yield and recovery policy; all state is conversation-owned. */
2
- import { formIncompleteOutcome } from './form-state.js';
2
+ import { formIncompleteOutcome, closeFormInstance } from './form-state.js';
3
3
  export function clearFormMisses(cargo, id, input) {
4
4
  const state = cargo.forms?.[id];
5
5
  if (!state)
@@ -55,3 +55,31 @@ export function formConversationOutcome(cargo, id, reason, failure = false, reco
55
55
  const mode = unknown ? 'hold' : recoveryMode, why = unknown ? 'action_result_unknown' : completed.owner ? completed.reason : reason;
56
56
  return { outcome: unknown ? 'unresolved' : completed.owner ? completed.outcome : failure ? 'unresolved' : 'pending', reason: why, recovery: { version: 1, mode, reason: why, form: root.id, flow: root.definition } };
57
57
  }
58
+ /** An explicit withdrawal retires the owning task; unknown actions remain held for reconciliation. */
59
+ export function cancelFormTask(cargo, id) {
60
+ // A completed primary may own an optional follow-up with an unknown send result.
61
+ // That completion does not permit withdrawing the unresolved action's evidence.
62
+ let root = cargo.forms?.[id];
63
+ const ancestors = new Set();
64
+ while (root?.parent && cargo.forms?.[root.parent] && !ancestors.has(root.id)) {
65
+ ancestors.add(root.id);
66
+ root = cargo.forms[root.parent];
67
+ }
68
+ if (root) {
69
+ const belongs = state => { const seen = new Set(); while (state && !seen.has(state.id)) {
70
+ if (state.id === root.id)
71
+ return true;
72
+ seen.add(state.id);
73
+ state = cargo.forms?.[state.parent];
74
+ } return false; };
75
+ const unknown = Object.values(cargo.forms || {}).filter(belongs).some(state => Object.values(state.actions || {}).some(record => ['attempted', 'unknown'].includes(record.status)));
76
+ if (unknown)
77
+ return { outcome: 'unresolved', reason: 'action_result_unknown', recovery: { version: 1, mode: 'hold', reason: 'action_result_unknown', form: root.id, flow: root.definition } };
78
+ }
79
+ const outcome = formConversationOutcome(cargo, id, 'request_cancelled', false, 'none');
80
+ if (outcome.recovery.mode === 'hold')
81
+ return outcome;
82
+ const owner = outcome.recovery.form || root?.id || id;
83
+ closeFormInstance(cargo, owner, false);
84
+ return { outcome: 'resolved', reason: 'request_cancelled', recovery: { version: 1, mode: 'none', reason: 'request_cancelled' } };
85
+ }
@@ -92,8 +92,9 @@ export function resetFormInputs(cargo: any, id: any, names?: any[]): boolean;
92
92
  export function acceptFormReadings(cargo: any, hits: any, additionalCandidates?: any[]): boolean;
93
93
  /** Resolve the outermost stale opted-in context through actual active ownership, without mutation.
94
94
  * An unflagged wrapper must not hide an ancestor whose owner accepted a different field value.
95
+ * Optional pure ownerWork schedules owned pending work (such as input consent) before the context re-asks.
95
96
  */
96
- export function formParentResume(cargo: any, id: any, explicit?: boolean): {
97
+ export function formParentResume(cargo: any, id: any, explicit?: boolean, ownerWork?: null): {
97
98
  owner: any;
98
99
  child: any;
99
100
  } | null;
@@ -1 +1 @@
1
- {"version":3,"file":"form-state.d.ts","sourceRoot":"","sources":["../../src/helpers/form-state.js"],"names":[],"mappings":"AAOA,qDAKC;AAED,oDAEC;AAED,qFAAqF;AACrF,oEA2BC;AAuCD,2FAEC;AACD,8FAcC;AACD,2DAOC;AACD,uEAuCC;AAED,kGAAkG;AAClG,2GAOC;AACD,0HAA0H;AAC1H,uEAwBC;AACD,8HAA8H;AAC9H;;;;;EAWC;AACD,uGAAuG;AACvG;;;;;;;;;;;QAgCC;AAED,0FAA0F;AAC1F;;;SAIC;AACD,gGAAgG;AAChG;;;;;;;;;;;EAQC;AAED,sGAAsG;AACtG,2DAIC;AACD;;;GAGG;AACH;;;;;;;SAkBC;AAED,2FAA2F;AAC3F,oGAIC;AACD,gFA4BC;AAED,2GAA2G;AAC3G;;;EASC;AACD,mEAoBC;AACD,mEAGC;AACD,sEAUC;AACD,+EAEC;AACD,qFASC;AACD,oGAoCC;AACD;;;SAKC;AACD,qEAGC;AACD,gEAgBC;AACD,2DAQC;AACD,oGAUC;AAED,uEAAuE;AACvE,wHA+BC;AAED,uHAAuH;AACvH,6EAaC;AACD,mHAAmH;AACnH,iGA4CC;AACD;;GAEG;AACH;;;SAcC;AACD,+EASC;AACD,8EAeC;AA5kBM,8CAAmE"}
1
+ {"version":3,"file":"form-state.d.ts","sourceRoot":"","sources":["../../src/helpers/form-state.js"],"names":[],"mappings":"AAQA,qDAKC;AAED,oDAEC;AAED,qFAAqF;AACrF,oEA6BC;AAuCD,2FAEC;AACD,8FAcC;AACD,2DAOC;AACD,uEAuCC;AAED,kGAAkG;AAClG,2GAOC;AACD,0HAA0H;AAC1H,uEAwBC;AACD,8HAA8H;AAC9H;;;;;EAWC;AACD,uGAAuG;AACvG;;;;;;;;;;;QAgCC;AAED,0FAA0F;AAC1F;;;SAIC;AACD,gGAAgG;AAChG;;;;;;;;;;;EAQC;AAED,sGAAsG;AACtG,2DAIC;AACD;;;GAGG;AACH;;;;;;;SAkBC;AAED,2FAA2F;AAC3F,oGAIC;AACD,gFA4BC;AAED,2GAA2G;AAC3G;;;EASC;AACD,mEAoBC;AACD,mEAGC;AACD,sEAUC;AACD,+EAEC;AAoCD,qFAYC;AACD,oGAqCC;AACD;;;SAKC;AACD,qEAGC;AACD,gEAgBC;AACD,2DAQC;AACD,oGAUC;AAED,uEAAuE;AACvE,wHA+BC;AAED,uHAAuH;AACvH,6EAaC;AACD,mHAAmH;AACnH,iGAsDC;AACD;;;GAGG;AACH;;;SAcC;AACD,+EASC;AACD,8EAeC;AAhoBM,8CAAmE"}
@@ -1,3 +1,4 @@
1
+ import { validateFormResponse } from './contextual-response.js';
1
2
  import { validateFormProposalPolicy } from './proposal-contract.js';
2
3
  /** Shared FORM semantics. Pure readers plus explicit mutations of the supplied session container; no host I/O. */
3
4
  import { readInputProfile } from './match-inputs.js';
@@ -36,6 +37,13 @@ export function resolveFormInputs(inputs, presets = {}) {
36
37
  validateMoneyOptions(input.profile.money);
37
38
  }
38
39
  validateFormExhaustion(input.on_exhausted);
40
+ if (input.meaning !== undefined)
41
+ throw new Error('FORM meaning is retired; use a contextual response description');
42
+ if (input.response !== undefined) {
43
+ if (!input.profile || input.form || input.any_of || input.bind)
44
+ throw new Error('FORM response requires a readable leaf input');
45
+ validateFormResponse(input.response);
46
+ }
39
47
  if (input.proposal !== undefined) {
40
48
  if (!input.profile || input.form || input.any_of || input.bind)
41
49
  throw new Error('FORM proposal requires a readable leaf input; declare it on each group member or inside the subform');
@@ -131,7 +139,7 @@ export function formInputFilled(input, state, cargo = {}, checking = new Set())
131
139
  const v = formPath({ cargo }, input.bind);
132
140
  return hasFormValue(v) && v !== false;
133
141
  }
134
- const filled = name => !state.errors?.[name] && !state.pending?.[name] && hasFormValue(state.values[name]);
142
+ const filled = name => !(state.inputProposals?.[name] && !state.inputProposals[name].committed && ['pending', 'confirmed'].includes(state.inputProposals[name].status)) && !state.errors?.[name] && !state.pending?.[name] && hasFormValue(state.values[name]);
135
143
  return input.any_of ? input.any_of.some(i => formInputApplies(i, state.values, cargo, state) && formInputFilled(i, state, cargo, checking)) : filled(input.name);
136
144
  }
137
145
  export function nextFormInput(state, cargo = {}) {
@@ -198,7 +206,7 @@ export function enrichFormMatches(matches, chain, form, names = [], asked = '')
198
206
  const enrich = h => {
199
207
  const spec = chain.find(c => c.form === h.form && c.name === h.name) || {};
200
208
  return { ...h, label: h.option_label || spec.label || h.name, label_es: h.option_label_es || spec.label_es || spec.label || h.name,
201
- validator: spec.validator || '', after: spec.after || '', validate_always: spec.validate_always === true, ...(spec.activation ? { activation: spec.activation } : {}), pii: spec.pii === true, current: h.form === form && names.includes(h.name), asked };
209
+ validator: spec.validator || '', ...(spec.response ? { response: spec.response } : {}), after: spec.after || '', validate_always: spec.validate_always === true, ...(spec.activation ? { activation: spec.activation } : {}), pii: spec.pii === true, current: h.form === form && names.includes(h.name), asked };
202
210
  };
203
211
  return { ...matches, hits: matches.hits.map(enrich), ambiguous: matches.ambiguous.map(enrich), remaining: (matches.remaining || []).map(group => group.map(enrich)) };
204
212
  }
@@ -492,7 +500,61 @@ export function rejectFormReadings(cargo, hits = []) {
492
500
  export function proposedFormValues(cargo, id, accepted = []) {
493
501
  return Object.assign({}, cargo.forms?.[id]?.values, ...accepted.filter(h => h.form === id).map(h => ({ [h.name]: h.value })));
494
502
  }
503
+ /** Bind deferred candidates to the exact controller proposal that made their context uncertain.
504
+ * A declined or replaced controller never reinterprets those words under the previous context. */
505
+ function readingProposalDependencies(cargo, hit) {
506
+ const found = [], visited = new Set();
507
+ const inspect = (owner, input) => {
508
+ if (!owner || !input)
509
+ return;
510
+ const key = owner.id + '/' + input.name;
511
+ if (visited.has(key))
512
+ return;
513
+ visited.add(key);
514
+ for (const name of [...(input.depends_on || []), ...(input.reset_on || []), ...Object.keys(input.when || {})]) {
515
+ if (name.startsWith('cargo.') || name.startsWith('form.'))
516
+ continue;
517
+ const dependency = owner.specs.find(s => s.name === name) || owner.specs.flatMap(s => s.any_of || [s]).find(s => s.name === name);
518
+ for (const member of dependency?.any_of || [dependency || { name }]) {
519
+ const proposal = owner.inputProposals?.[member.name];
520
+ if (proposal && !proposal.committed && ['pending', 'confirmed'].includes(proposal.status))
521
+ found.push({ form: owner.id, input: member.name, id: proposal.id, value: structuredClone(proposal.value) });
522
+ inspect(owner, member);
523
+ }
524
+ inspect(owner, dependency);
525
+ }
526
+ };
527
+ let owner = cargo.forms?.[hit.form];
528
+ inspect(owner, owner?.specs.flatMap(s => s.any_of || [s]).find(s => s.name === hit.name));
529
+ const seen = new Set();
530
+ while (owner?.parent && !seen.has(owner.parent)) {
531
+ seen.add(owner.parent);
532
+ const child = owner;
533
+ owner = cargo.forms[owner.parent];
534
+ if (!child.context_only)
535
+ inspect(owner, owner?.specs.find(s => s.name === child.result_input));
536
+ }
537
+ return found;
538
+ }
539
+ function proposalDependencyStatus(cargo, hit) {
540
+ let waiting = false;
541
+ for (const binding of hit.dependencyProposals || []) {
542
+ const owner = cargo.forms?.[binding.form], record = owner?.inputProposals?.[binding.input];
543
+ if (!record || record.id !== binding.id || !formValuesEqual(record.value, binding.value) || ['declined', 'superseded'].includes(record.status))
544
+ return 'obsolete';
545
+ if (record.committed && !formValuesEqual(owner.values[binding.input], binding.value))
546
+ return 'obsolete';
547
+ if (!record.committed)
548
+ waiting = true;
549
+ }
550
+ return waiting || readingProposalDependencies(cargo, hit).length ? 'waiting' : 'ready';
551
+ }
495
552
  export function formReadingRelevant(cargo, hit, accepted = []) {
553
+ const dependencyStatus = proposalDependencyStatus(cargo, hit);
554
+ if (dependencyStatus === 'obsolete')
555
+ return false;
556
+ if (dependencyStatus === 'waiting')
557
+ return true;
496
558
  let state = cargo.forms?.[hit.form];
497
559
  if (!state)
498
560
  return false;
@@ -517,6 +579,8 @@ export function formReadingRelevant(cargo, hit, accepted = []) {
517
579
  return true;
518
580
  }
519
581
  export function formReadingReady(cargo, hit, accepted = [], rejected = []) {
582
+ if (proposalDependencyStatus(cargo, hit) !== 'ready')
583
+ return false;
520
584
  const state = cargo.forms?.[hit.form];
521
585
  if (!state)
522
586
  return false;
@@ -591,7 +655,8 @@ export function queueFormReadings(cargo, hits = []) {
591
655
  const state = cargo.forms?.[hit.form];
592
656
  if (!state)
593
657
  throw new Error('Pending candidate has no owning form');
594
- state.pending[hit.name] = { ...hit, outcome: 'pending' };
658
+ const bindings = hit.dependencyProposals || readingProposalDependencies(cargo, hit);
659
+ state.pending[hit.name] = { ...hit, ...(bindings.length ? { dependencyProposals: bindings } : {}), outcome: 'pending' };
595
660
  }
596
661
  return true;
597
662
  }
@@ -612,9 +677,14 @@ export function pendingFormReadings(cargo, id) {
612
677
  }
613
678
  }
614
679
  }
615
- for (const h of Object.values(state.pending || {}))
680
+ for (const h of Object.values(state.pending || {})) {
681
+ if (proposalDependencyStatus(cargo, h) === 'obsolete') {
682
+ delete state.pending[h.name];
683
+ continue;
684
+ }
616
685
  if (!h.activation_group && formReadingReady(cargo, h))
617
686
  out.push({ ...h, fromPending: true });
687
+ }
618
688
  for (const child of Object.values(state.children || {}).concat(Object.values(state.contexts || {})))
619
689
  walk(child);
620
690
  };
@@ -777,6 +847,17 @@ export function resetFormInputs(cargo, id, names = []) {
777
847
  }
778
848
  /** Commit only validated readings. Callers batch dependency-related candidates before invoking this transition. */
779
849
  export function acceptFormReadings(cargo, hits, additionalCandidates = []) {
850
+ const deferred = [];
851
+ for (const state of Object.values(cargo.forms || {}))
852
+ for (const hit of Object.values(state.pending || {})) {
853
+ const bindings = hit.dependencyProposals || [];
854
+ if (bindings.length && bindings.some(binding => (hits || []).some(change => change.form === binding.form && change.name === binding.input && formValuesEqual(change.value, binding.value))) && bindings.every(binding => {
855
+ const record = cargo.forms[binding.form]?.inputProposals?.[binding.input];
856
+ return record?.id === binding.id && !['declined', 'superseded'].includes(record.status) && formValuesEqual(record.value, binding.value);
857
+ }))
858
+ deferred.push({ hit, task: state.task, definition: state.definition });
859
+ }
860
+ const preservedNodes = () => hits.concat(additionalCandidates, deferred.map(entry => entry.hit)).map(h => h.form);
780
861
  const groups = new Map();
781
862
  for (const hit of hits || []) {
782
863
  const state = cargo.forms?.[hit.form];
@@ -810,7 +891,7 @@ export function acceptFormReadings(cargo, hits, additionalCandidates = []) {
810
891
  }
811
892
  const changed = [...cleared, ...readings.filter(h => !formValuesEqual(state.values[h.name], h.value)).map(h => h.name)];
812
893
  const invalidating = changed.filter(name => cleared.includes(name) || hasFormValue(state.values[name]));
813
- invalidateFormInputs(cargo, id, invalidating, readings.map(h => h.name), hits.concat(additionalCandidates).map(h => h.form));
894
+ invalidateFormInputs(cargo, id, invalidating, readings.map(h => h.name), preservedNodes());
814
895
  if (changed.length && !invalidating.length) {
815
896
  state.revision++;
816
897
  state.confirmation = null;
@@ -835,17 +916,23 @@ export function acceptFormReadings(cargo, hits, additionalCandidates = []) {
835
916
  }
836
917
  delete parent.values[slot];
837
918
  delete parent.accepted[slot];
838
- invalidateFormInputs(cargo, parent.id, [slot], [], hits.concat(additionalCandidates).map(h => h.form));
919
+ invalidateFormInputs(cargo, parent.id, [slot], [], preservedNodes());
839
920
  child = parent;
840
921
  }
841
922
  }
842
923
  }
924
+ for (const { hit, task, definition } of deferred) {
925
+ const state = cargo.forms?.[hit.form];
926
+ if (state?.task === task && state.definition === definition && !own(state.values, hit.name))
927
+ state.pending[hit.name] = hit;
928
+ }
843
929
  return true;
844
930
  }
845
931
  /** Resolve the outermost stale opted-in context through actual active ownership, without mutation.
846
932
  * An unflagged wrapper must not hide an ancestor whose owner accepted a different field value.
933
+ * Optional pure ownerWork schedules owned pending work (such as input consent) before the context re-asks.
847
934
  */
848
- export function formParentResume(cargo, id, explicit = false) {
935
+ export function formParentResume(cargo, id, explicit = false, ownerWork = null) {
849
936
  const forms = cargo?.forms || {}, seen = new Set();
850
937
  let state = forms[id], selected = null;
851
938
  if (!state)
@@ -859,7 +946,7 @@ export function formParentResume(cargo, id, explicit = false) {
859
946
  const parent = forms[state.parent];
860
947
  if (!parent || parent.task !== state.task || (state.context_only ? parent.contexts?.[state.definition] !== state.id : parent.children?.[state.result_input] !== state.id))
861
948
  return null;
862
- if (state.context_only && (state.resume_on_parent_change === true || state.id === id && explicit === true) && parent.revision !== state.parent_revision)
949
+ if (state.context_only && (state.resume_on_parent_change === true || state.id === id && explicit === true) && (parent.revision !== state.parent_revision || typeof ownerWork === 'function' && ownerWork(cargo, parent.id)))
863
950
  selected = { owner: parent.id, child: state.id };
864
951
  state = parent;
865
952
  }
@@ -1,5 +1,9 @@
1
1
  export namespace STANDARD_FUNCTIONS {
2
+ export { continuationSafetyProtocol };
3
+ export { cancelFormTask };
2
4
  export { contextualResponseProtocol };
5
+ export { validateFormResponse };
6
+ export { hasFormResponse };
3
7
  export { formProposalPolicy };
4
8
  export { stageFormProposal };
5
9
  export { nextFormProposal };
@@ -20,6 +24,8 @@ export namespace STANDARD_FUNCTIONS {
20
24
  export { readMoneyAmount };
21
25
  export { isMoneyAmount };
22
26
  export { moneyIntentAllows };
27
+ export { isPastPaymentStatement };
28
+ export { isPartialMoneyAnswer };
23
29
  export { validateMoneyOptions };
24
30
  export { takeChoiceOffer };
25
31
  export { matchesChoice };
@@ -107,7 +113,11 @@ export namespace STANDARD_FUNCTIONS {
107
113
  export { urlToSpeech };
108
114
  export { textWithUrlToSpeech };
109
115
  }
116
+ import { continuationSafetyProtocol } from '../forms/continuation-safety.js';
117
+ import { cancelFormTask } from './form-conversation.js';
110
118
  import { contextualResponseProtocol } from './contextual-response.js';
119
+ import { validateFormResponse } from './contextual-response.js';
120
+ import { hasFormResponse } from './contextual-response.js';
111
121
  import { formProposalPolicy } from './form-proposals.js';
112
122
  import { stageFormProposal } from './form-proposals.js';
113
123
  import { nextFormProposal } from './form-proposals.js';
@@ -128,6 +138,8 @@ import { formConversationOutcome } from './form-conversation.js';
128
138
  import { readMoneyAmount } from './money.js';
129
139
  import { isMoneyAmount } from './money.js';
130
140
  import { moneyIntentAllows } from './money.js';
141
+ import { isPastPaymentStatement } from './money.js';
142
+ import { isPartialMoneyAnswer } from './money.js';
131
143
  import { validateMoneyOptions } from './money.js';
132
144
  import { takeChoiceOffer } from './choice-offer.js';
133
145
  import { matchesChoice } from './matches-choice.js';
@@ -219,5 +231,5 @@ import { validatePhone } from './validators.js';
219
231
  import { validateEmail } from './validators.js';
220
232
  import { urlToSpeech } from './url-speech.js';
221
233
  import { textWithUrlToSpeech } from './url-speech.js';
222
- export { contextualResponseProtocol, formProposalPolicy, stageFormProposal, nextFormProposal, formProposalReadings, bindFormProposal, decideFormProposal, commitFormProposals, settleFormProposalValidation, formProposalProtocol, validateFormProposalPolicy, validateFormProposalDescriptor, formProposalDescriptor, clearFormMisses, missFormInput, formInputPrompt, consumeFormFeedback, formConversationOutcome, readMoneyAmount, isMoneyAmount, moneyIntentAllows, validateMoneyOptions, takeChoiceOffer, matchesChoice, ANSWER_WORDS, CONFIRM_WORDS, isAnswer, isAgentRequest, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice, readEmail, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational, normalizeAndFindCapture, anythingElse, goodbye, sayName, dateToWords, amountToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readInputProfile, resolveFormInputs, formInputApplies, formInputFilled, nextFormInput, formInputChain, openFormInstance, validateFormIncompleteOutcome, formIncompleteOutcome, validateFormExhaustion, exhaustFormInput, formInitialReadings, orderFormReadings, proposedFormValues, applyFormValidation, formReadingDependencies, exclusiveFormReadings, enrichFormMatches, expandFormActivations, settleFormActivations, rememberFormArguments, resetFormInputs, hasFormValue, formPath, formValuesEqual, formReadingReady, formReadingRelevant, formPreparation, queueFormReadings, pendingFormReadings, formWorkLimit, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance, checkOtp, maskDestination, validateOTP, OTP_EXPIRY_MS, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech };
234
+ export { continuationSafetyProtocol, cancelFormTask, contextualResponseProtocol, validateFormResponse, hasFormResponse, formProposalPolicy, stageFormProposal, nextFormProposal, formProposalReadings, bindFormProposal, decideFormProposal, commitFormProposals, settleFormProposalValidation, formProposalProtocol, validateFormProposalPolicy, validateFormProposalDescriptor, formProposalDescriptor, clearFormMisses, missFormInput, formInputPrompt, consumeFormFeedback, formConversationOutcome, readMoneyAmount, isMoneyAmount, moneyIntentAllows, isPastPaymentStatement, isPartialMoneyAnswer, validateMoneyOptions, takeChoiceOffer, matchesChoice, ANSWER_WORDS, CONFIRM_WORDS, isAnswer, isAgentRequest, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice, readEmail, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational, normalizeAndFindCapture, anythingElse, goodbye, sayName, dateToWords, amountToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readInputProfile, resolveFormInputs, formInputApplies, formInputFilled, nextFormInput, formInputChain, openFormInstance, validateFormIncompleteOutcome, formIncompleteOutcome, validateFormExhaustion, exhaustFormInput, formInitialReadings, orderFormReadings, proposedFormValues, applyFormValidation, formReadingDependencies, exclusiveFormReadings, enrichFormMatches, expandFormActivations, settleFormActivations, rememberFormArguments, resetFormInputs, hasFormValue, formPath, formValuesEqual, formReadingReady, formReadingRelevant, formPreparation, queueFormReadings, pendingFormReadings, formWorkLimit, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance, checkOtp, maskDestination, validateOTP, OTP_EXPIRY_MS, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech };
223
235
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAAyC,0BAA0B;mCAC2G,qBAAqB;kCAArB,qBAAqB;iCAArB,qBAAqB;qCAArB,qBAAqB;iCAArB,qBAAqB;mCAArB,qBAAqB;oCAArB,qBAAqB;6CAArB,qBAAqB;qCAC/E,wBAAwB;2CAAxB,wBAAwB;+CAAxB,wBAAwB;uCAAxB,wBAAwB;gCACpC,w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Protocol } from './contextual-response.js';
1
+ import { continuationSafetyProtocol } from '../forms/continuation-safety.js';
2
+ import { contextualResponseProtocol, validateFormResponse, hasFormResponse } from './contextual-response.js';
2
3
  import { formProposalPolicy, stageFormProposal, nextFormProposal, formProposalReadings, bindFormProposal, decideFormProposal, commitFormProposals, settleFormProposalValidation } from './form-proposals.js';
3
4
  import { formProposalProtocol, validateFormProposalPolicy, validateFormProposalDescriptor, formProposalDescriptor } from './proposal-contract.js';
4
- import { clearFormMisses, missFormInput, formInputPrompt, consumeFormFeedback, formConversationOutcome } from './form-conversation.js';
5
+ import { cancelFormTask, clearFormMisses, missFormInput, formInputPrompt, consumeFormFeedback, formConversationOutcome } from './form-conversation.js';
5
6
  import { takeChoiceOffer } from './choice-offer.js';
6
7
  import { consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified } from './form-actions.js';
7
8
  /**
@@ -20,7 +21,7 @@ import { consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFo
20
21
  */
21
22
  import { sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion } from './form-sources.js';
22
23
  import { matchesChoice } from './matches-choice.js';
23
- import { readMoneyAmount, isMoneyAmount, moneyIntentAllows, validateMoneyOptions } from './money.js';
24
+ import { readMoneyAmount, isMoneyAmount, moneyIntentAllows, isPastPaymentStatement, isPartialMoneyAnswer, validateMoneyOptions } from './money.js';
24
25
  import { ANSWER_WORDS, CONFIRM_WORDS, isAnswer, isAgentRequest, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice } from './answer.js';
25
26
  import { readEmail, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational } from './contact.js';
26
27
  import { normalizeAndFindCapture } from './capture.js';
@@ -33,13 +34,13 @@ import { resolveFormInputs, formInputApplies, formInputFilled, nextFormInput, fo
33
34
  import { checkOtp, maskDestination, validateOTP, OTP_EXPIRY_MS } from './otp-check.js';
34
35
  import { validateDigits, validatePhone, validateEmail } from './validators.js';
35
36
  import { urlToSpeech, textWithUrlToSpeech } from './url-speech.js';
36
- export { contextualResponseProtocol, formProposalPolicy, stageFormProposal, nextFormProposal, formProposalReadings, bindFormProposal, decideFormProposal, commitFormProposals, settleFormProposalValidation, formProposalProtocol, validateFormProposalPolicy, validateFormProposalDescriptor, formProposalDescriptor, clearFormMisses, missFormInput, formInputPrompt, consumeFormFeedback, formConversationOutcome, readMoneyAmount, isMoneyAmount, moneyIntentAllows, validateMoneyOptions, takeChoiceOffer, matchesChoice, ANSWER_WORDS, CONFIRM_WORDS, isAnswer, isAgentRequest, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice, readEmail, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational, normalizeAndFindCapture, anythingElse, goodbye, sayName, dateToWords, amountToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readInputProfile, resolveFormInputs, formInputApplies, formInputFilled, nextFormInput, formInputChain, openFormInstance, validateFormIncompleteOutcome, formIncompleteOutcome, validateFormExhaustion, exhaustFormInput, formInitialReadings, orderFormReadings, proposedFormValues, applyFormValidation, formReadingDependencies, exclusiveFormReadings, enrichFormMatches, expandFormActivations, settleFormActivations, rememberFormArguments, resetFormInputs, hasFormValue, formPath, formValuesEqual, formReadingReady, formReadingRelevant, formPreparation, queueFormReadings, pendingFormReadings, formWorkLimit, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance, checkOtp, maskDestination, validateOTP, OTP_EXPIRY_MS, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech, };
37
+ export { continuationSafetyProtocol, cancelFormTask, contextualResponseProtocol, validateFormResponse, hasFormResponse, formProposalPolicy, stageFormProposal, nextFormProposal, formProposalReadings, bindFormProposal, decideFormProposal, commitFormProposals, settleFormProposalValidation, formProposalProtocol, validateFormProposalPolicy, validateFormProposalDescriptor, formProposalDescriptor, clearFormMisses, missFormInput, formInputPrompt, consumeFormFeedback, formConversationOutcome, readMoneyAmount, isMoneyAmount, moneyIntentAllows, isPastPaymentStatement, isPartialMoneyAnswer, validateMoneyOptions, takeChoiceOffer, matchesChoice, ANSWER_WORDS, CONFIRM_WORDS, isAnswer, isAgentRequest, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice, readEmail, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational, normalizeAndFindCapture, anythingElse, goodbye, sayName, dateToWords, amountToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readInputProfile, resolveFormInputs, formInputApplies, formInputFilled, nextFormInput, formInputChain, openFormInstance, validateFormIncompleteOutcome, formIncompleteOutcome, validateFormExhaustion, exhaustFormInput, formInitialReadings, orderFormReadings, proposedFormValues, applyFormValidation, formReadingDependencies, exclusiveFormReadings, enrichFormMatches, expandFormActivations, settleFormActivations, rememberFormArguments, resetFormInputs, hasFormValue, formPath, formValuesEqual, formReadingReady, formReadingRelevant, formPreparation, queueFormReadings, pendingFormReadings, formWorkLimit, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance, checkOtp, maskDestination, validateOTP, OTP_EXPIRY_MS, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech, };
37
38
  /** The functions flows call by name, ready to spread into a host's approved functions. */
38
39
  export const STANDARD_FUNCTIONS = {
39
- contextualResponseProtocol,
40
+ continuationSafetyProtocol, cancelFormTask, contextualResponseProtocol, validateFormResponse, hasFormResponse,
40
41
  formProposalPolicy, stageFormProposal, nextFormProposal, formProposalReadings, bindFormProposal, decideFormProposal, commitFormProposals, settleFormProposalValidation, formProposalProtocol, validateFormProposalPolicy, validateFormProposalDescriptor, formProposalDescriptor,
41
42
  clearFormMisses, missFormInput, formInputPrompt, consumeFormFeedback, formConversationOutcome,
42
- readMoneyAmount, isMoneyAmount, moneyIntentAllows, validateMoneyOptions, takeChoiceOffer, matchesChoice, isAnswer, isAgentRequest, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice,
43
+ readMoneyAmount, isMoneyAmount, moneyIntentAllows, isPastPaymentStatement, isPartialMoneyAnswer, validateMoneyOptions, takeChoiceOffer, matchesChoice, isAnswer, isAgentRequest, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice,
43
44
  readEmail, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational,
44
45
  normalizeAndFindCapture, anythingElse, goodbye, sayName, dateToWords, amountToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readInputProfile, resolveFormInputs, formInputApplies, formInputFilled, nextFormInput, formInputChain, openFormInstance, validateFormIncompleteOutcome, formIncompleteOutcome, validateFormExhaustion, exhaustFormInput, formInitialReadings, orderFormReadings, proposedFormValues, applyFormValidation, formReadingDependencies, exclusiveFormReadings, enrichFormMatches, expandFormActivations, settleFormActivations, rememberFormArguments, resetFormInputs, hasFormValue, formPath, formValuesEqual, formReadingReady, formReadingRelevant, formPreparation, queueFormReadings, pendingFormReadings, formWorkLimit, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance,
45
46
  validateOTP, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech,
@@ -1 +1 @@
1
- {"version":3,"file":"match-inputs.d.ts","sourceRoot":"","sources":["../../src/helpers/match-inputs.js"],"names":[],"mappings":"AAiGA;;;GAGG;AACH,sFAmGC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;mHACmH;AACnH;;;;;EAeC;AACD;;;;;;EAyHC"}
1
+ {"version":3,"file":"match-inputs.d.ts","sourceRoot":"","sources":["../../src/helpers/match-inputs.js"],"names":[],"mappings":"AAoFA;;;GAGG;AACH,sFAgGC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;mHACmH;AACnH;;;;;EAeC;AACD;;;;;;EAkHC"}