jsfe 1.56.0 → 1.57.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.
@@ -23,6 +23,12 @@ export function projectChoices(session: any): {
23
23
  say: string;
24
24
  }[];
25
25
  } | null;
26
+ /** The words the question asked now offers as its answers (each choice's phrases and labels), or [] when none is
27
+ * pending. Read-only. A host that answers some messages itself before the engine (a request to hear the last reply
28
+ * again, "again" / "otra vez") checks a message against these first, so an offered answer always reaches the flow:
29
+ * prod 2026-11-11, a payment-link failure menu offered AGAIN and the host replayed the menu instead. Covers an
30
+ * ask-choice question and a form's current choice input (its runtime choices, choices_from included). */
31
+ export function offeredReplies(session: any): any[];
26
32
  /** Host preflight: call before updateActivity. Unknown paths and malformed envelopes never enter execution. */
27
33
  /** The place a view's field suggests, or null: the host's suggestion endpoint answers only for a place field of the
28
34
  * form that is open now (`form` is the view's instance, `path` the field's), so it is never a general place service. */
@@ -1 +1 @@
1
- {"version":3,"file":"form-client.d.ts","sourceRoot":"","sources":["../../src/forms/form-client.js"],"names":[],"mappings":"AAiCA,iGAAiG;AACjG;;;;;SAwGC;AAMD;;;;;;;;GAQG;AACH;;;;;;;;SAoBC;AAED,+GAA+G;AAC/G;wHACwH;AACxH,qEAWC;AAED;;;;SA4CC;AAED;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BC;AA1QD,qCAAsC,eAAe,CAAC"}
1
+ {"version":3,"file":"form-client.d.ts","sourceRoot":"","sources":["../../src/forms/form-client.js"],"names":[],"mappings":"AAiCA,iGAAiG;AACjG;;;;;SAwGC;AAMD;;;;;;;;GAQG;AACH;;;;;;;;SAoBC;AAED;;;;yGAIyG;AACzG,oDAyBC;AACD,+GAA+G;AAC/G;wHACwH;AACxH,qEAWC;AAED;;;;SA4CC;AAED;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BC;AAzSD,qCAAsC,eAAe,CAAC"}
@@ -205,6 +205,43 @@ export function projectChoices(session) {
205
205
  }
206
206
  return { version: 1, language, options };
207
207
  }
208
+ /** The words the question asked now offers as its answers (each choice's phrases and labels), or [] when none is
209
+ * pending. Read-only. A host that answers some messages itself before the engine (a request to hear the last reply
210
+ * again, "again" / "otra vez") checks a message against these first, so an offered answer always reaches the flow:
211
+ * prod 2026-11-11, a payment-link failure menu offered AGAIN and the host replayed the menu instead. Covers an
212
+ * ask-choice question and a form's current choice input (its runtime choices, choices_from included). */
213
+ export function offeredReplies(session) {
214
+ if (!session || session.continuationSafetyHold)
215
+ return [];
216
+ const frame = (session.flowStacks || []).flat().at(-1);
217
+ if (!frame?.pendingVariable)
218
+ return [];
219
+ const out = new Set();
220
+ const take = choices => {
221
+ for (const choice of Array.isArray(choices) ? choices : []) {
222
+ if (!choice || String(choice.key ?? '').startsWith('event:'))
223
+ continue;
224
+ for (const word of [].concat(choice.phrases ?? choice.words ?? [], choice.label ?? [], choice.label_es ?? [])) {
225
+ if (typeof word === 'string' && word.trim())
226
+ out.add(word.trim());
227
+ }
228
+ }
229
+ };
230
+ if (frame.flowId === 'ask-choice') {
231
+ take(frame.variables?.choices);
232
+ }
233
+ else {
234
+ const context = frame.variables?.form_context;
235
+ const state = context?.form && context.current !== '__confirm' ? session.cargo?.forms?.[context.form] : null;
236
+ const names = new Set([].concat(context?.names || [], context?.current || []));
237
+ for (const input of state?.specs || []) {
238
+ if (!names.has(input.name) || input.profile?.kind !== 'choice')
239
+ continue;
240
+ take(input.choices_from ? state.data?.[input.choices_from] : input.profile.choices);
241
+ }
242
+ }
243
+ return [...out];
244
+ }
208
245
  /** Host preflight: call before updateActivity. Unknown paths and malformed envelopes never enter execution. */
209
246
  /** The place a view's field suggests, or null: the host's suggestion endpoint answers only for a place field of the
210
247
  * form that is open now (`form` is the view's instance, `path` the field's), so it is never a general place service. */
@@ -11,5 +11,5 @@ export { addressDraft, zipLocation, streetLocation, resolvedAddress } from "../h
11
11
  export { Form, Provider, Performer, Worker, compileExpression } from "./authoring.js";
12
12
  export { compileFlowDeclarations, serializeFlowDeclaration, captureOriginalDeclaration } from "./declarations.js";
13
13
  export { findFlowTraps, formatFlowTrap } from "./flow-traps.js";
14
- export { projectForm, projectChoices, parseFormSubmission, formSubmissionReaders, formPlaceField, FORM_SUBMISSION_PREFIX } from "./form-client.js";
14
+ export { projectForm, projectChoices, offeredReplies, parseFormSubmission, formSubmissionReaders, formPlaceField, FORM_SUBMISSION_PREFIX } from "./form-client.js";
15
15
  //# sourceMappingURL=index.d.ts.map
@@ -16,4 +16,4 @@ export { compileFlowDeclarations, serializeFlowDeclaration, captureOriginalDecla
16
16
  export { continuationBreaks } from './continuation-compat.js';
17
17
  export { inheritFlowDeclaration } from './declaration-capture.js';
18
18
  export { findFlowTraps, formatFlowTrap } from './flow-traps.js';
19
- export { projectForm, projectChoices, parseFormSubmission, formSubmissionReaders, formPlaceField, FORM_SUBMISSION_PREFIX } from './form-client.js';
19
+ export { projectForm, projectChoices, offeredReplies, parseFormSubmission, formSubmissionReaders, formPlaceField, FORM_SUBMISSION_PREFIX } from './form-client.js';
@@ -1 +1 @@
1
- export const JSFE_RUNTIME_FINGERPRINT = "sha256:e362d38ecb8fd3a4686fc68bebc9a27ad307e21d9e675230fcc35f7134c3cce3";
1
+ export const JSFE_RUNTIME_FINGERPRINT = "sha256:c29fa529bb5527d049229ecc264171f035aa5a275f1ac7900cf2fed042362f54";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsfe",
3
- "version": "1.56.0",
3
+ "version": "1.57.0",
4
4
  "description": "TypeScript workflow engine for conversational/automation apps: multi-flow orchestration, interrupt/resume, stack-based control, robust errors, and flexible tool/REST integration.",
5
5
  "license": "MIT",
6
6
  "author": "Ron Pinkas",