jsfe 1.85.0 → 1.86.1
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/dist/forms/flows.d.ts.map +1 -1
- package/dist/forms/flows.js +4 -2
- package/dist/helpers/match-inputs.d.ts.map +1 -1
- package/dist/helpers/match-inputs.js +58 -3
- package/dist/helpers/sendables.d.ts +4 -1
- package/dist/helpers/sendables.d.ts.map +1 -1
- package/dist/helpers/sendables.js +27 -2
- package/dist/runtime-identity.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flows.d.ts","sourceRoot":"","sources":["../../src/forms/flows.js"],"names":[],"mappings":"AAkIA;;;;;;;GAOG;AACH;;;;GAIG;AACH,8HAA8H;AAC9H,uFAIC;AAsGD;;2EAE2E;AAC3E,qEAEC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2EC;AACD;;;GAGG;AACH;;;;;;EAGC;
|
|
1
|
+
{"version":3,"file":"flows.d.ts","sourceRoot":"","sources":["../../src/forms/flows.js"],"names":[],"mappings":"AAkIA;;;;;;;GAOG;AACH;;;;GAIG;AACH,8HAA8H;AAC9H,uFAIC;AAsGD;;2EAE2E;AAC3E,qEAEC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2EC;AACD;;;GAGG;AACH;;;;;;EAGC;AAynBD,wHAAwH;AACxH,wEAaC;AACD,4FAA4F;AAC5F;;;EAYC;AACD,sGAAsG;AACtG;;;EAOC;AAv8BM,6CAAuG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwJ9G,4CAEqI;AA0gCrI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAOG"}
|
package/dist/forms/flows.js
CHANGED
|
@@ -481,8 +481,10 @@ const collectInput = {
|
|
|
481
481
|
WHEN('ci_route_key', 'ci_routed', FLOW('ci_route_key_flow', '{{ci_routed}}', 'call', { form: '{{form}}', input: '{{current}}' })),
|
|
482
482
|
WHEN('ci_routed_end', 'ci_routed', END('ci_routed_done')),
|
|
483
483
|
// `accumulate` (opt-in, digit inputs): a number said in groups across turns ("4347", "6971 2210"…) is kept and joined;
|
|
484
|
-
// short of the input's minimum the next question is "Go on." Anything that is not digits drops the partial.
|
|
485
|
-
|
|
484
|
+
// short of the input's minimum the next question is "Go on." Anything that is not digits drops the partial. A complete
|
|
485
|
+
// first answer is not joined: the reader reads it as typed (a card in groups is one number; a card then its security
|
|
486
|
+
// code is two, matchInputs numericSplit; owner 2026-11-20).
|
|
487
|
+
SET('ci_partial_join', 'ci_partial', "(function () { var state = cargo.forms[form]; if (!ci_spec || ci_spec.accumulate !== true || !ci_spec.digits) return ''; var said = String(cargo.choiceText || '').trim(); var data = state.data = state.data || {}; var key = '__partial_' + current; if (!/^[0-9][0-9\\s.,-]*$/.test(said)) { delete data[key]; return ''; } var joined = String(data[key] || '') + said.replace(/[^0-9]/g, ''); var starts = ci_spec.accumulate_first ? new RegExp(ci_spec.accumulate_first) : null; if (!data[key] && starts && !starts.test(joined)) return ''; if (joined.length < Number(ci_spec.digits.min || 0)) { data[key] = joined; var fb = state.feedback || {}; fb[current] = 'partial'; state.feedback = fb; return 'hold'; } if (!data[key]) return ''; delete data[key]; cargo.choiceText = joined; cargo.choice = joined; return 'joined'; })()"),
|
|
486
488
|
// An email at a known provider said without its ending ("Cecilia 41, at Yahoo."): it is kept and the caller is asked
|
|
487
489
|
// only what comes after the provider; an ending alone on the next turn completes it, any other reply drops it
|
|
488
490
|
// (owner 2026-11-18, prod 11-18 17:30). An unknown domain is never guessed: the address is asked again.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match-inputs.d.ts","sourceRoot":"","sources":["../../src/helpers/match-inputs.js"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH,sEAQC;AAoGD;;;GAGG;AACH,sFAiIC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;mHACmH;AAEnH,iEAEC;AAGD,gGAOC;AAYD,kDAGC;AAED;;;;;;;GAOG;AACH;;;;SAcC;AACD;;;;;GAKG;AACH;;;;;;;;;;;;;;;;;;;;;;EAaC;AACD;;;;;;;;;;;;;;;;;;;;;;EAeC;
|
|
1
|
+
{"version":3,"file":"match-inputs.d.ts","sourceRoot":"","sources":["../../src/helpers/match-inputs.js"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH,sEAQC;AAoGD;;;GAGG;AACH,sFAiIC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;mHACmH;AAEnH,iEAEC;AAGD,gGAOC;AAYD,kDAGC;AAED;;;;;;;GAOG;AACH;;;;SAcC;AACD;;;;;GAKG;AACH;;;;;;;;;;;;;;;;;;;;;;EAaC;AACD;;;;;;;;;;;;;;;;;;;;;;EAeC;AAqCD;;;;;;;;;;;;;;;;;;;;;;;EAsYC"}
|
|
@@ -15,7 +15,7 @@ import { readSpokenMoney } from './spoken-money.js';
|
|
|
15
15
|
import { readMoneyAmount, isPartialMoneyAnswer } from './money.js';
|
|
16
16
|
import { pickProviderQuestion } from './form-sources.js';
|
|
17
17
|
import { spokenDigitsText, wholeSpokenNumber } from './spoken-digits.js';
|
|
18
|
-
import { DIGIT_RUN } from './numbers.js';
|
|
18
|
+
import { DIGIT_RUN, findNumbers, assignNumbers, NUMBER_KINDS } from './numbers.js';
|
|
19
19
|
/**
|
|
20
20
|
* This turn's acceptance decisions for the host to log, appended per match: fields filled out of order, in a compound
|
|
21
21
|
* answer or as an invited input, and every refused reading, by form, field and rule. Field names and rules only, never
|
|
@@ -421,6 +421,57 @@ export function readFormAnswer(answer, candidates, current, choiceKey, questions
|
|
|
421
421
|
const provenance = h => ({ ...h, raw, utterance: raw });
|
|
422
422
|
return { ...matches, hits: matches.hits.map(provenance), ambiguous: matches.ambiguous.map(provenance), remaining: (matches.remaining || []).map(group => group.map(provenance)), questions: [...new Set(asked)] };
|
|
423
423
|
}
|
|
424
|
+
// The span of `value`'s digits in raw, starting at the first digit at or after `from` (separators between them allowed). → null
|
|
425
|
+
function digitsSpan(raw, value, from) {
|
|
426
|
+
let i = from;
|
|
427
|
+
while (i < raw.length && !/\d/.test(raw[i]))
|
|
428
|
+
i++;
|
|
429
|
+
const start = i;
|
|
430
|
+
let got = '';
|
|
431
|
+
while (i < raw.length && got.length < value.length) {
|
|
432
|
+
if (/\d/.test(raw[i]))
|
|
433
|
+
got += raw[i];
|
|
434
|
+
else { /* a separator inside the value */ }
|
|
435
|
+
i++;
|
|
436
|
+
}
|
|
437
|
+
return got === value ? [start, i] : null;
|
|
438
|
+
}
|
|
439
|
+
// One numeric answer that fills several of the form's numeric inputs (owner 2026-11-20): at a digits question, an answer of
|
|
440
|
+
// digits and separators alone ("4111 1111 1111 1111 123" at the card number) is read with jsfe assignNumbers, each numeric
|
|
441
|
+
// input of the asked input's form a spec (a preset field by its kind: the card number with its check digit, the expiration a
|
|
442
|
+
// valid unexpired date; any other digits input by its length), multiple: true. Used only when exactly one reading gives the
|
|
443
|
+
// asked input a complete value beside at least one other input and consumes every digit; otherwise null and the answer reads
|
|
444
|
+
// as before (a card said in groups, a card spoken over two turns, a lone ZIP). → {name: {value, spans}} | null
|
|
445
|
+
function numericSplit(raw, list, own) {
|
|
446
|
+
if (!own || own.profile.kind !== 'digits' || !/^[\d\s.,-]+[.!]?$/.test(raw.trim()))
|
|
447
|
+
return null;
|
|
448
|
+
const numeric = list.filter((c) => c.form === own.form && !c.confirmation && (NUMBER_KINDS.includes(c.field) || c.profile.kind === 'digits'));
|
|
449
|
+
if (numeric.length < 2)
|
|
450
|
+
return null;
|
|
451
|
+
const specs = numeric.map((c) => (NUMBER_KINDS.includes(c.field) ? { name: c.name, kind: c.field } : { name: c.name, kind: 'digits', min: Number(c.profile.min || 1), max: Number(c.profile.max || c.profile.min || 1) }));
|
|
452
|
+
let read = null;
|
|
453
|
+
try {
|
|
454
|
+
read = assignNumbers(findNumbers(raw), specs, { multiple: true });
|
|
455
|
+
}
|
|
456
|
+
catch {
|
|
457
|
+
read = null;
|
|
458
|
+
}
|
|
459
|
+
const names = read ? Object.keys(read.values) : [];
|
|
460
|
+
if (!read || read.ambiguous.length || read.unread.length || names.length < 2 || !names.includes(own.name))
|
|
461
|
+
return null;
|
|
462
|
+
const out = {};
|
|
463
|
+
let at = 0;
|
|
464
|
+
for (let left = [...names]; left.length;) {
|
|
465
|
+
const next = left.find((name) => digitsSpan(raw, read.values[name], at));
|
|
466
|
+
if (!next)
|
|
467
|
+
return null;
|
|
468
|
+
const span = digitsSpan(raw, read.values[next], at);
|
|
469
|
+
out[next] = { value: read.values[next], spans: [span] };
|
|
470
|
+
at = span[1];
|
|
471
|
+
left = left.filter((name) => name !== next);
|
|
472
|
+
}
|
|
473
|
+
return out;
|
|
474
|
+
}
|
|
424
475
|
export function matchInputs(answer, candidates, current, choiceKey) {
|
|
425
476
|
const raw = unescape(answer);
|
|
426
477
|
const list = Array.isArray(candidates) ? candidates.filter((c) => c && c.name && c.profile) : [];
|
|
@@ -450,6 +501,7 @@ export function matchInputs(answer, candidates, current, choiceKey) {
|
|
|
450
501
|
// An invited input is read as in order while it is asked (docs/copilot-reference.md §5): its asked signature, not
|
|
451
502
|
// its narrower out-of-order one ("40" at "NEW CARD, LINK, or a different amount" is the amount).
|
|
452
503
|
const invitedInput = new Set([...list.filter(isCur).flatMap((c) => Array.isArray(c.invites) ? c.invites : []), ...(Array.isArray(cur.invites) ? cur.invites : [])]);
|
|
504
|
+
const split = numericSplit(raw, list, own);
|
|
453
505
|
for (const c of list) {
|
|
454
506
|
// Rule 2: a confirmation is answered only when asked, firm by CONFIRM_WORDS, soft by the wider YES vocabulary.
|
|
455
507
|
const confirmation = ['firm', 'soft'].includes(c.confirmation) ? c.confirmation : '';
|
|
@@ -464,7 +516,9 @@ export function matchInputs(answer, candidates, current, choiceKey) {
|
|
|
464
516
|
}
|
|
465
517
|
const vocabulary = confirmation ? { ...c.profile, choices: (c.profile.choices || []).map((x) => x.key === 'yes' ? { ...x, phrases: [...(x.phrases ?? x.words ?? []), ...(confirmation === 'firm' ? CONFIRM_WORDS : ANSWER_WORDS.yes)], exact: confirmation === 'firm' || x.exact === true } : x.key === 'no' ? { ...x, phrases: [...(x.phrases ?? x.words ?? []), ...ANSWER_WORDS.no] } : x) } : c.profile;
|
|
466
518
|
const profile = narrativeCurrent && vocabulary.kind === 'email' ? { ...vocabulary, literal: true } : vocabulary;
|
|
467
|
-
|
|
519
|
+
// A split answer's numeric inputs take its parts (or nothing); the rules below judge each part as they judge any reading.
|
|
520
|
+
const splitInput = split && c.form === own.form && !c.confirmation && (NUMBER_KINDS.includes(c.field) || c.profile.kind === 'digits');
|
|
521
|
+
let r = splitInput ? (split[c.name] ? { value: split[c.name].value, spans: split[c.name].spans, evidence: [`split:${c.field || c.profile.kind}`] } : null) : readInputProfile(profile, raw, isCur(c) || invitedInput.has(c.name) && c.confirmation === undefined);
|
|
468
522
|
// A semantic choice supplied by ask-choice (e.g. spoken keypad keys) is a reading, not an early return.
|
|
469
523
|
if (!r && c === own && choiceKey && c.profile.kind === 'choice' && (c.profile.choices || []).some(x => x.key === choiceKey)) {
|
|
470
524
|
r = { ...(r || {}), value: choiceKey, spans: r?.spans?.length ? r.spans : [[0, raw.length]] };
|
|
@@ -531,7 +585,8 @@ export function matchInputs(answer, candidates, current, choiceKey) {
|
|
|
531
585
|
refused.push({ form: reading.form, name: reading.name, value: reading.value, rule: 'bare_amount_out_of_order', spans: reading.spans });
|
|
532
586
|
return false;
|
|
533
587
|
}
|
|
534
|
-
else if (/\d/.test(spanText(reading)) && !wholeRuns(reading)) {
|
|
588
|
+
else if (/\d/.test(spanText(reading)) && !wholeRuns(reading) && !(split && reading.form === own.form && split[reading.name]?.value === reading.value)) {
|
|
589
|
+
// (a part of a numeric split is whole by construction: every digit of the answer is assigned to one of the parts)
|
|
535
590
|
refused.push({ form: reading.form, name: reading.name, value: reading.value, rule: 'fragment', spans: reading.spans });
|
|
536
591
|
return false;
|
|
537
592
|
}
|
|
@@ -20,8 +20,11 @@ export function conversationCopy(turns: any, language?: string): string;
|
|
|
20
20
|
/**
|
|
21
21
|
* The conversation as "role: text" lines, one per turn, in order: the same text the host's flat chat history has
|
|
22
22
|
* always carried (ChatContextManager.messagesWithRole), so a note built from it reads as before.
|
|
23
|
+
* `maxLength` (optional, for a field with a length limit: a CRM description takes 2,000 characters, prod 2026-11-20): the
|
|
24
|
+
* latest whole turns that fit, after a line saying earlier turns were left out; a last turn longer than the room keeps its
|
|
25
|
+
* end. Without it the whole conversation, as before.
|
|
23
26
|
*/
|
|
24
|
-
export function chatTranscript(turns: any): string;
|
|
27
|
+
export function chatTranscript(turns: any, maxLength: any): string;
|
|
25
28
|
/**
|
|
26
29
|
* A flow's declared sendable: `sendable: {key, label, label_es?, media?}` on its definition means the caller may ask for it at
|
|
27
30
|
* any time (a statement nobody has produced yet), and that flow is its sender. → the problem with it, or '' when valid.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendables.d.ts","sourceRoot":"","sources":["../../src/helpers/sendables.js"],"names":[],"mappings":"AA2BA;;;;GAIG;AACH,kEAqCC;AAED;;;;;;GAMG;AACH,6CAYC;AAED;;;GAGG;AACH,wEAOC;
|
|
1
|
+
{"version":3,"file":"sendables.d.ts","sourceRoot":"","sources":["../../src/helpers/sendables.js"],"names":[],"mappings":"AA2BA;;;;GAIG;AACH,kEAqCC;AAED;;;;;;GAMG;AACH,6CAYC;AAED;;;GAGG;AACH,wEAOC;AAGD;;;;;;GAMG;AACH,mEAwBC;AAED;;;GAGG;AACH,gEAeC;AAED;;;;GAIG;AACH,oEAsBC;AA5KD,8GAA8G;AAC9G,+BAAgC,cAAc,CAAC"}
|
|
@@ -109,13 +109,38 @@ export function conversationCopy(turns, language = 'en') {
|
|
|
109
109
|
return '';
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
+
const OMITTED = '[earlier turns omitted]';
|
|
112
113
|
/**
|
|
113
114
|
* The conversation as "role: text" lines, one per turn, in order: the same text the host's flat chat history has
|
|
114
115
|
* always carried (ChatContextManager.messagesWithRole), so a note built from it reads as before.
|
|
116
|
+
* `maxLength` (optional, for a field with a length limit: a CRM description takes 2,000 characters, prod 2026-11-20): the
|
|
117
|
+
* latest whole turns that fit, after a line saying earlier turns were left out; a last turn longer than the room keeps its
|
|
118
|
+
* end. Without it the whole conversation, as before.
|
|
115
119
|
*/
|
|
116
|
-
export function chatTranscript(turns) {
|
|
120
|
+
export function chatTranscript(turns, maxLength) {
|
|
117
121
|
if (Array.isArray(turns)) {
|
|
118
|
-
|
|
122
|
+
const lines = turns.filter((turn) => turn && typeof turn.role === 'string').map((turn) => `${turn.role}: ${turn.text ?? ''}`);
|
|
123
|
+
const whole = lines.join('\n');
|
|
124
|
+
const max = Number(maxLength);
|
|
125
|
+
if (maxLength === undefined || maxLength === null || !Number.isFinite(max) || whole.length <= max) {
|
|
126
|
+
return whole;
|
|
127
|
+
}
|
|
128
|
+
else if (max <= OMITTED.length + 1) {
|
|
129
|
+
return whole.slice(whole.length - Math.max(0, Math.floor(max)));
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
const room = Math.floor(max) - OMITTED.length - 1;
|
|
133
|
+
const kept = [];
|
|
134
|
+
let used = 0;
|
|
135
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
136
|
+
const cost = lines[i].length + (kept.length ? 1 : 0);
|
|
137
|
+
if (used + cost > room)
|
|
138
|
+
break;
|
|
139
|
+
kept.unshift(lines[i]);
|
|
140
|
+
used += cost;
|
|
141
|
+
}
|
|
142
|
+
return `${OMITTED}\n${kept.length ? kept.join('\n') : lines[lines.length - 1].slice(lines[lines.length - 1].length - room)}`;
|
|
143
|
+
}
|
|
119
144
|
}
|
|
120
145
|
else {
|
|
121
146
|
return '';
|
package/dist/runtime-identity.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const JSFE_RUNTIME_FINGERPRINT = "sha256:
|
|
1
|
+
export const JSFE_RUNTIME_FINGERPRINT = "sha256:6b12bdc47c99a1718052fbc4918dc8b7762c433141e00d68ff187a55087a4eff";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsfe",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.86.1",
|
|
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",
|