jsfe 1.57.0 → 1.59.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/dist/forms/flows.d.ts.map +1 -1
- package/dist/forms/flows.js +9 -3
- package/dist/forms/form-client.d.ts.map +1 -1
- package/dist/forms/form-client.js +14 -0
- package/dist/helpers/index.d.ts +7 -1
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +3 -1
- package/dist/helpers/sendables.d.ts +18 -0
- package/dist/helpers/sendables.d.ts.map +1 -0
- package/dist/helpers/sendables.js +91 -0
- 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":"AA4GA;;;;;;;GAOG;AACH;;;;GAIG;AACH,8HAA8H;AAC9H,uFAIC;
|
|
1
|
+
{"version":3,"file":"flows.d.ts","sourceRoot":"","sources":["../../src/forms/flows.js"],"names":[],"mappings":"AA4GA;;;;;;;GAOG;AACH;;;;GAIG;AACH,8HAA8H;AAC9H,uFAIC;AAsGD;;2EAE2E;AAC3E,qEAEC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyEC;AACD;;;GAGG;AACH;;;;;;EAGC;AAmlBD,wHAAwH;AACxH,wEAaC;AACD,4FAA4F;AAC5F;;;EAYC;AACD,sGAAsG;AACtG;;;EAOC;AAz4BM,6CAAuG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkI9G,4CAEqI;AA49BrI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAOG"}
|
package/dist/forms/flows.js
CHANGED
|
@@ -157,13 +157,17 @@ function validateAcceptanceDeclarations(id, inputs) {
|
|
|
157
157
|
* names, and fills {input: part} fills inputs of this form with its locality (and, for a combobox, the code's other
|
|
158
158
|
* localities as its options) or admin_area.
|
|
159
159
|
* - control 'combobox': a choice that also takes other text (accept_other), drawn as a text box offering its choices.
|
|
160
|
+
* - control 'options' {options_from}: a text box with ready replies the card offers beside it (buttons, or a list when there
|
|
161
|
+
* are many). options_from names the form data holding them, [{key, label, label_es?}]; a pick submits its key as the
|
|
162
|
+
* typed reply would be, so the profile reads it unchanged and no channel without a card is affected.
|
|
160
163
|
* - autofill: the HTML autocomplete token the browser may fill the box from (a saved address, name, email or phone).
|
|
161
164
|
* Checked at definition time; malformed fails.
|
|
162
165
|
*/
|
|
163
166
|
const FORM_CLIENT_KEYS = { date: ['control', 'range_from', 'min', 'max', 'timezone', 'autofill'], number: ['control', 'min', 'max', 'autofill'],
|
|
164
|
-
place: ['control', 'types', 'regions', 'fills', 'autofill'], postal: ['control', 'regions', 'fills', 'autofill'], combobox: ['control', 'autofill'],
|
|
167
|
+
place: ['control', 'types', 'regions', 'fills', 'autofill'], postal: ['control', 'regions', 'fills', 'autofill'], combobox: ['control', 'autofill'],
|
|
168
|
+
options: ['control', 'options_from', 'autofill'], none: ['autofill'] };
|
|
165
169
|
const FORM_CLIENT_KINDS = ['pattern', 'text', 'digits', 'amount', 'identifier'];
|
|
166
|
-
const FORM_CONTROL_KINDS = { place: ['pattern', 'text'], postal: ['digits', 'pattern', 'text', 'identifier'], combobox: ['choice'],
|
|
170
|
+
const FORM_CONTROL_KINDS = { place: ['pattern', 'text'], postal: ['digits', 'pattern', 'text', 'identifier'], combobox: ['choice'], options: ['pattern', 'text'],
|
|
167
171
|
none: ['pattern', 'text', 'digits', 'amount', 'identifier', 'email', 'phone', 'choice'] };
|
|
168
172
|
const FORM_PLACE_TYPES = ['cities', 'address'];
|
|
169
173
|
const FORM_FILL_PARTS = { place: ['postal_code', 'locality', 'admin_area', 'country'], postal: ['locality', 'admin_area'] };
|
|
@@ -182,7 +186,7 @@ function validateFormClientControls(id, inputs) {
|
|
|
182
186
|
else if (!declared || typeof declared !== 'object' || Array.isArray(declared))
|
|
183
187
|
fail(input, 'must be false or {control?, autofill?, ...}');
|
|
184
188
|
else if (declared.control !== undefined && (declared.control === 'none' || !Object.hasOwn(FORM_CLIENT_KEYS, declared.control)))
|
|
185
|
-
fail(input, 'control must be "date", "number", "place", "postal" or "
|
|
189
|
+
fail(input, 'control must be "date", "number", "place", "postal", "combobox" or "options"');
|
|
186
190
|
else { /* a control object, or autofill alone; checked below */ }
|
|
187
191
|
const control = declared.control ?? 'none';
|
|
188
192
|
const extra = Object.keys(declared).filter((key) => !FORM_CLIENT_KEYS[control].includes(key));
|
|
@@ -198,6 +202,8 @@ function validateFormClientControls(id, inputs) {
|
|
|
198
202
|
fail(input, `autofill ${JSON.stringify(declared.autofill)} is not one of ${FORM_AUTOFILL_TOKENS.join(', ')}`);
|
|
199
203
|
if (control === 'combobox' && (input.profile || {}).accept_other !== true)
|
|
200
204
|
fail(input, 'combobox needs a choice that accepts other text (accept_other)');
|
|
205
|
+
if (control === 'options' && (typeof declared.options_from !== 'string' || !/^[A-Za-z_]\w{0,63}$/.test(declared.options_from)))
|
|
206
|
+
fail(input, 'options needs options_from: the name of the form data holding the replies');
|
|
201
207
|
for (const key of ['min', 'max'])
|
|
202
208
|
if (declared[key] !== undefined && !Number.isInteger(declared[key]))
|
|
203
209
|
fail(input, `${key} must be a whole number`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-client.d.ts","sourceRoot":"","sources":["../../src/forms/form-client.js"],"names":[],"mappings":"AAiCA,iGAAiG;AACjG;;;;;
|
|
1
|
+
{"version":3,"file":"form-client.d.ts","sourceRoot":"","sources":["../../src/forms/form-client.js"],"names":[],"mappings":"AAiCA,iGAAiG;AACjG;;;;;SAoHC;AAMD;;;;;;;;GAQG;AACH;;;;;;;;SAoBC;AAED;;;;yGAIyG;AACzG,oDAyBC;AACD,+GAA+G;AAC/G;wHACwH;AACxH,qEAWC;AAED;;;;SA4CC;AAED;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BC;AArTD,qCAAsC,eAAe,CAAC"}
|
|
@@ -132,6 +132,20 @@ export function projectForm(session, flows) {
|
|
|
132
132
|
else if (control === 'combobox') {
|
|
133
133
|
field.control = control;
|
|
134
134
|
}
|
|
135
|
+
else if (control === 'options') {
|
|
136
|
+
// Ready replies beside the box: a pick is submitted as its key, read by the profile like typed text.
|
|
137
|
+
field.control = control;
|
|
138
|
+
const offered = state.data?.[input.form_client.options_from];
|
|
139
|
+
const options = new Map();
|
|
140
|
+
for (const option of Array.isArray(offered) ? offered : []) {
|
|
141
|
+
const key = option && (typeof option.key === 'string' || typeof option.key === 'number') ? String(option.key) : '';
|
|
142
|
+
const optionLabel = option ? (language === 'es' ? option.label_es || option.label : option.label) : '';
|
|
143
|
+
if (key && !options.has(key))
|
|
144
|
+
options.set(key, { key, label: typeof optionLabel === 'string' && optionLabel ? optionLabel : key });
|
|
145
|
+
else { /* no key, or a key already offered */ }
|
|
146
|
+
}
|
|
147
|
+
field.options = [...options.values()];
|
|
148
|
+
}
|
|
135
149
|
else { /* the profile's own box */ }
|
|
136
150
|
// The browser may fill the box from its saved data (an address, a name).
|
|
137
151
|
if (input.form_client?.autofill && !field.sensitive)
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -129,6 +129,9 @@ export namespace STANDARD_FUNCTIONS {
|
|
|
129
129
|
export { textWithUrlToSpeech };
|
|
130
130
|
export { joinSpokenDigits };
|
|
131
131
|
export { wholeSpokenNumber };
|
|
132
|
+
export { registerSendable };
|
|
133
|
+
export { sendables };
|
|
134
|
+
export { chatTranscript };
|
|
132
135
|
}
|
|
133
136
|
import { continuationSafetyProtocol } from '../forms/continuation-safety.js';
|
|
134
137
|
import { cancelFormTask } from './form-conversation.js';
|
|
@@ -267,5 +270,8 @@ import { textWithUrlToSpeech } from './url-speech.js';
|
|
|
267
270
|
import { joinSpokenDigits } from './spoken-digits.js';
|
|
268
271
|
import { spokenDigitsText } from './spoken-digits.js';
|
|
269
272
|
import { wholeSpokenNumber } from './spoken-digits.js';
|
|
270
|
-
|
|
273
|
+
import { registerSendable } from './sendables.js';
|
|
274
|
+
import { sendables } from './sendables.js';
|
|
275
|
+
import { chatTranscript } from './sendables.js';
|
|
276
|
+
export { continuationSafetyProtocol, cancelFormTask, contextualResponseProtocol, validateFormResponse, hasFormResponse, formProposalPolicy, stageFormProposal, nextFormProposal, formProposalReadings, bindFormProposal, retireStaleFormProposal, decideFormProposal, commitFormProposals, settleFormProposalValidation, formProposalProtocol, validateFormProposalPolicy, validateFormProposalDescriptor, formProposalDescriptor, clearFormMisses, formNoOwner, missFormInput, formMustComplete, formInputPrompt, formUserDescriptionSource, formConcernLine, formAcknowledges, consumeFormFeedback, formConversationOutcome, readMoneyAmount, isMoneyAmount, moneyIntentAllows, isPastPaymentStatement, isPartialMoneyAnswer, validateMoneyOptions, takeChoiceOffer, saysConfirmWord, saysNoValue, confirmOutOfOrderLine, matchesChoice, ANSWER_WORDS, CONFIRM_WORDS, isAnswer, isAgentRequest, isExitRequest, isGlobalExit, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice, withoutPromptEcho, readEmail, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational, normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, dateToWords, amountToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readInputProfile, formAcceptanceTrace, 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, answerResetsFormReplays, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance, checkOtp, clearOtp, maskDestination, validateOTP, OTP_EXPIRY_MS, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech, joinSpokenDigits, spokenDigitsText, wholeSpokenNumber, registerSendable, sendables, chatTranscript };
|
|
271
277
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CACyC,iCAAiC;+BAIqI,wBAAwB;2CAHzJ,0BAA0B;qCAA1B,0BAA0B;gCAA1B,0BAA0B;mCAC8F,qBAAqB;kCAArB,qBAAqB;iCAArB,qBAAqB;qCAArB,qBAAqB;iCAArB,qBAAqB;wCAArB,qBAAqB;mCAArB,qBAAqB;oCAArB,qBAAqB;6CAArB,qBAAqB;qCACvG,wBAAwB;2CAAxB,wBAAwB;+CAAxB,wBAAwB;uCAAxB,wBAAwB;gCACmE,wBAAwB;4BAAxB,wBAAwB;8BAAxB,wBAAwB;iCAAxB,wBAAwB;gCAAxB,wBAAwB;0CAAxB,wBAAwB;gCAAxB,wBAAwB;iCAAxB,wBAAwB;oCAAxB,wBAAwB;wCAAxB,wBAAwB;gCAoBxG,YAAY;8BAAZ,YAAY;kCAAZ,YAAY;uCAAZ,YAAY;qCAAZ,YAAY;qCAAZ,YAAY;gCAnB3G,mBAAmB;gCA2BqF,mBAAmB;4BAAnB,mBAAmB;sCAAnB,mBAAmB;8BAT7H,qBAAqB;6BAEkJ,aAAa;8BAAb,aAAa;yBAAb,aAAa;+BAAb,aAAa;8BAAb,aAAa;6BAAb,aAAa;+BAAb,aAAa;kCAAb,aAAa;+BAAb,aAAa;+BAAb,aAAa;2BAAb,aAAa;kCAAb,aAAa;0BACzD,cAAc;0BAAd,cAAc;uCAAd,cAAc;+BAAd,cAAc;sBAAd,cAAc;0BAAd,cAAc;iCAAd,cAAc;gCAAd,cAAc;sCAAd,cAAc;wCAC/H,cAAc;6BACS,cAAc;wBAAd,cAAc;wBAAd,cAAc;+BAAd,cAAc;4BACjD,iBAAiB;+BACd,uBAAuB;mCACC,kBAAkB;mCAAlB,kBAAkB;qCAxB+I,mBAAmB;yCAAnB,mBAAmB;8BAAnB,mBAAmB;iCAAnB,mBAAmB;oCAAnB,mBAAmB;kCAAnB,mBAAmB;wCAAnB,mBAAmB;gCAAnB,mBAAmB;iCAAnB,mBAAmB;mCAAnB,mBAAmB;gCAe1I,mBAAmB;mCAAnB,mBAAmB;sCAAnB,mBAAmB;qCAAnB,mBAAmB;4BAUoB,mBAAmB;+BAAnB,mBAAmB;iCAAnB,mBAAmB;oCAAnB,mBAAmB;kCAC6kB,iBAAiB;iCAAjB,iBAAiB;gCAAjB,iBAAiB;8BAAjB,iBAAiB;+BAAjB,iBAAiB;iCAAjB,iBAAiB;8CAAjB,iBAAiB;sCAAjB,iBAAiB;uCAAjB,iBAAiB;iCAAjB,iBAAiB;oCAAjB,iBAAiB;kCAAjB,iBAAiB;mCAAjB,iBAAiB;oCAAjB,iBAAiB;wCAAjB,iBAAiB;sCAAjB,iBAAiB;kCAAjB,iBAAiB;sCAAjB,iBAAiB;sCAAjB,iBAAiB;sCAAjB,iBAAiB;gCAAjB,iBAAiB;6BAAjB,iBAAiB;yBAAjB,iBAAiB;gCAAjB,iBAAiB;iCAAjB,iBAAiB;oCAAjB,iBAAiB;gCAAjB,iBAAiB;kCAAjB,iBAAiB;oCAAjB,iBAAiB;8BAAjB,iBAAiB;wCAAjB,iBAAiB;mCAAjB,iBAAiB;qCAAjB,iBAAiB;mCAAjB,iBAAiB;oCAAjB,iBAAiB;iCAAjB,iBAAiB;kCAAjB,iBAAiB;yBACzqB,gBAAgB;yBAAhB,gBAAgB;gCAAhB,gBAAgB;4BAAhB,gBAAgB;8BAAhB,gBAAgB;+BACnC,iBAAiB;8BAAjB,iBAAiB;8BAAjB,iBAAiB;4BAE7B,iBAAiB;oCAAjB,iBAAiB;iCADI,oBAAoB;iCAApB,oBAAoB;kCAApB,oBAAoB;iCA9B9B,gBAAgB;0BAAhB,gBAAgB;+BAAhB,gBAAgB"}
|
package/dist/helpers/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { formProposalPolicy, stageFormProposal, nextFormProposal, formProposalRe
|
|
|
5
5
|
import { formProposalProtocol, validateFormProposalPolicy, validateFormProposalDescriptor, formProposalDescriptor } from './proposal-contract.js';
|
|
6
6
|
import { cancelFormTask, clearFormMisses, formNoOwner, missFormInput, formMustComplete, formInputPrompt, formUserDescriptionSource, formConcernLine, formAcknowledges, consumeFormFeedback, formConversationOutcome } from './form-conversation.js';
|
|
7
7
|
import { takeChoiceOffer } from './choice-offer.js';
|
|
8
|
+
import { registerSendable, sendables, chatTranscript } from './sendables.js';
|
|
8
9
|
import { consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified } from './form-actions.js';
|
|
9
10
|
/**
|
|
10
11
|
* jsfe/helpers — the functions JSFE's system flows call from expressions, in ONE place for every host: reading an
|
|
@@ -36,7 +37,7 @@ import { checkOtp, clearOtp, maskDestination, validateOTP, OTP_EXPIRY_MS } from
|
|
|
36
37
|
import { validateDigits, validatePhone, validateEmail } from './validators.js';
|
|
37
38
|
import { joinSpokenDigits, spokenDigitsText, wholeSpokenNumber } from './spoken-digits.js';
|
|
38
39
|
import { urlToSpeech, textWithUrlToSpeech } from './url-speech.js';
|
|
39
|
-
export { continuationSafetyProtocol, cancelFormTask, contextualResponseProtocol, validateFormResponse, hasFormResponse, formProposalPolicy, stageFormProposal, nextFormProposal, formProposalReadings, bindFormProposal, retireStaleFormProposal, decideFormProposal, commitFormProposals, settleFormProposalValidation, formProposalProtocol, validateFormProposalPolicy, validateFormProposalDescriptor, formProposalDescriptor, clearFormMisses, formNoOwner, missFormInput, formMustComplete, formInputPrompt, formUserDescriptionSource, formConcernLine, formAcknowledges, consumeFormFeedback, formConversationOutcome, readMoneyAmount, isMoneyAmount, moneyIntentAllows, isPastPaymentStatement, isPartialMoneyAnswer, validateMoneyOptions, takeChoiceOffer, saysConfirmWord, saysNoValue, confirmOutOfOrderLine, matchesChoice, ANSWER_WORDS, CONFIRM_WORDS, isAnswer, isAgentRequest, isExitRequest, isGlobalExit, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice, withoutPromptEcho, readEmail, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational, normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, dateToWords, amountToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readInputProfile, formAcceptanceTrace, 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, answerResetsFormReplays, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance, checkOtp, clearOtp, maskDestination, validateOTP, OTP_EXPIRY_MS, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech, joinSpokenDigits, spokenDigitsText, wholeSpokenNumber, };
|
|
40
|
+
export { continuationSafetyProtocol, cancelFormTask, contextualResponseProtocol, validateFormResponse, hasFormResponse, formProposalPolicy, stageFormProposal, nextFormProposal, formProposalReadings, bindFormProposal, retireStaleFormProposal, decideFormProposal, commitFormProposals, settleFormProposalValidation, formProposalProtocol, validateFormProposalPolicy, validateFormProposalDescriptor, formProposalDescriptor, clearFormMisses, formNoOwner, missFormInput, formMustComplete, formInputPrompt, formUserDescriptionSource, formConcernLine, formAcknowledges, consumeFormFeedback, formConversationOutcome, readMoneyAmount, isMoneyAmount, moneyIntentAllows, isPastPaymentStatement, isPartialMoneyAnswer, validateMoneyOptions, takeChoiceOffer, saysConfirmWord, saysNoValue, confirmOutOfOrderLine, matchesChoice, ANSWER_WORDS, CONFIRM_WORDS, isAnswer, isAgentRequest, isExitRequest, isGlobalExit, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice, withoutPromptEcho, readEmail, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational, normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, dateToWords, amountToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readInputProfile, formAcceptanceTrace, 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, answerResetsFormReplays, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance, checkOtp, clearOtp, maskDestination, validateOTP, OTP_EXPIRY_MS, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech, joinSpokenDigits, spokenDigitsText, wholeSpokenNumber, registerSendable, sendables, chatTranscript, };
|
|
40
41
|
/** The functions flows call by name, ready to spread into a host's approved functions. */
|
|
41
42
|
export const STANDARD_FUNCTIONS = {
|
|
42
43
|
continuationSafetyProtocol, cancelFormTask, contextualResponseProtocol, validateFormResponse, hasFormResponse,
|
|
@@ -46,4 +47,5 @@ export const STANDARD_FUNCTIONS = {
|
|
|
46
47
|
readEmail, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational,
|
|
47
48
|
normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, dateToWords, amountToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readInputProfile, formAcceptanceTrace, 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, answerResetsFormReplays, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance,
|
|
48
49
|
validateOTP, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech, joinSpokenDigits, wholeSpokenNumber,
|
|
50
|
+
registerSendable, sendables, chatTranscript,
|
|
49
51
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Register (or replace, by key) a document the caller may ask to be sent. Throws on a malformed entry: a flow that
|
|
3
|
+
* registers something unsendable is a flow bug and must fail where it is written, not when a caller asks for it.
|
|
4
|
+
* → true, so it can stand in a SET expression.
|
|
5
|
+
*/
|
|
6
|
+
export function registerSendable(cargo: any, entry: any): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Everything the caller may ask to be sent now: the registered documents, then the last REPLY_COUNT non-empty
|
|
9
|
+
* assistant turns of cargo.chatTurns, newest last. Each item is {key, label, label_es?, kind, content | sender+args}.
|
|
10
|
+
* A reply's key is "reply-<n>" (its turn number) and its label "Reply <n>: <first 120 characters>".
|
|
11
|
+
*/
|
|
12
|
+
export function sendables(cargo: any): any[];
|
|
13
|
+
/**
|
|
14
|
+
* The conversation as "role: text" lines, one per turn, in order: the same text the host's flat chat history has
|
|
15
|
+
* always carried (ChatContextManager.messagesWithRole), so a note built from it reads as before.
|
|
16
|
+
*/
|
|
17
|
+
export function chatTranscript(turns: any): string;
|
|
18
|
+
//# sourceMappingURL=sendables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendables.d.ts","sourceRoot":"","sources":["../../src/helpers/sendables.js"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,kEAmCC;AAED;;;;GAIG;AACH,6CASC;AAED;;;GAGG;AACH,mDAMC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sendables: what a caller may ask to be sent ("send me that by text", "email me my statement").
|
|
3
|
+
*
|
|
4
|
+
* A flow that produces a document registers it on the session with registerSendable(cargo, entry); a generic sender
|
|
5
|
+
* (the SendCopy flow) offers sendables(cargo) to the ranker and sends the pick without knowing what it is:
|
|
6
|
+
* - an entry with `content` is sent as is (text or email);
|
|
7
|
+
* - an entry with `sender` runs that flow with {medium, destination, ...args}; every sender flow takes those three.
|
|
8
|
+
* The host's replies are offered too, from cargo.chatTurns (the host's masked conversation, a list of
|
|
9
|
+
* {n, role, text, source?}); nothing registers them. chatTranscript(turns) formats that list as "role: text" lines.
|
|
10
|
+
*/
|
|
11
|
+
const REPLY_COUNT = 6;
|
|
12
|
+
const REPLY_LABEL_CHARS = 120;
|
|
13
|
+
const isText = (value) => typeof value === 'string' && value.trim() !== '';
|
|
14
|
+
/**
|
|
15
|
+
* Register (or replace, by key) a document the caller may ask to be sent. Throws on a malformed entry: a flow that
|
|
16
|
+
* registers something unsendable is a flow bug and must fail where it is written, not when a caller asks for it.
|
|
17
|
+
* → true, so it can stand in a SET expression.
|
|
18
|
+
*/
|
|
19
|
+
export function registerSendable(cargo, entry) {
|
|
20
|
+
if (!cargo || typeof cargo !== 'object') {
|
|
21
|
+
throw new Error('registerSendable: cargo is required');
|
|
22
|
+
}
|
|
23
|
+
else if (!entry || typeof entry !== 'object') {
|
|
24
|
+
throw new Error('registerSendable: entry must be an object');
|
|
25
|
+
}
|
|
26
|
+
else if (!isText(entry.key) || entry.key.startsWith('reply-')) {
|
|
27
|
+
throw new Error(`registerSendable: key must be a nonempty string not starting with "reply-" (got ${JSON.stringify(entry.key)})`);
|
|
28
|
+
}
|
|
29
|
+
else if (!isText(entry.label)) {
|
|
30
|
+
throw new Error(`registerSendable(${entry.key}): label must be a nonempty string`);
|
|
31
|
+
}
|
|
32
|
+
else if (entry.label_es !== undefined && !isText(entry.label_es)) {
|
|
33
|
+
throw new Error(`registerSendable(${entry.key}): label_es, when given, must be a nonempty string`);
|
|
34
|
+
}
|
|
35
|
+
else if (isText(entry.content) === isText(entry.sender)) {
|
|
36
|
+
throw new Error(`registerSendable(${entry.key}): exactly one of content (the text to send) or sender (a flow id) is required`);
|
|
37
|
+
}
|
|
38
|
+
else if (entry.args !== undefined && (entry.args === null || typeof entry.args !== 'object' || Array.isArray(entry.args))) {
|
|
39
|
+
throw new Error(`registerSendable(${entry.key}): args, when given, must be an object`);
|
|
40
|
+
}
|
|
41
|
+
else if (entry.args !== undefined && !isText(entry.sender)) {
|
|
42
|
+
throw new Error(`registerSendable(${entry.key}): args belong to a sender entry`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const stored = { key: entry.key, label: entry.label, kind: 'document' };
|
|
46
|
+
if (entry.label_es !== undefined) {
|
|
47
|
+
stored.label_es = entry.label_es;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
// English label only: the ranker reads the label in either language.
|
|
51
|
+
}
|
|
52
|
+
if (isText(entry.content)) {
|
|
53
|
+
stored.content = entry.content;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
stored.sender = entry.sender;
|
|
57
|
+
stored.args = { ...(entry.args || {}) };
|
|
58
|
+
}
|
|
59
|
+
const list = Array.isArray(cargo.sendables) ? cargo.sendables.filter((item) => item?.key !== entry.key) : [];
|
|
60
|
+
list.push(stored);
|
|
61
|
+
cargo.sendables = list;
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Everything the caller may ask to be sent now: the registered documents, then the last REPLY_COUNT non-empty
|
|
67
|
+
* assistant turns of cargo.chatTurns, newest last. Each item is {key, label, label_es?, kind, content | sender+args}.
|
|
68
|
+
* A reply's key is "reply-<n>" (its turn number) and its label "Reply <n>: <first 120 characters>".
|
|
69
|
+
*/
|
|
70
|
+
export function sendables(cargo) {
|
|
71
|
+
const documents = Array.isArray(cargo?.sendables) ? cargo.sendables.filter((item) => isText(item?.key)).map((item) => (item.args ? { ...item, args: { ...item.args } } : { ...item })) : [];
|
|
72
|
+
const turns = Array.isArray(cargo?.chatTurns) ? cargo.chatTurns : [];
|
|
73
|
+
const replies = turns.filter((turn) => turn?.role === 'assistant' && isText(turn.text)).slice(-REPLY_COUNT).map((turn) => {
|
|
74
|
+
const text = turn.text.trim();
|
|
75
|
+
const head = text.length > REPLY_LABEL_CHARS ? text.slice(0, REPLY_LABEL_CHARS) + '…' : text;
|
|
76
|
+
return { key: `reply-${turn.n}`, label: `Reply ${turn.n}: ${head}`, kind: 'reply', content: text };
|
|
77
|
+
});
|
|
78
|
+
return [...documents, ...replies];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The conversation as "role: text" lines, one per turn, in order: the same text the host's flat chat history has
|
|
82
|
+
* always carried (ChatContextManager.messagesWithRole), so a note built from it reads as before.
|
|
83
|
+
*/
|
|
84
|
+
export function chatTranscript(turns) {
|
|
85
|
+
if (Array.isArray(turns)) {
|
|
86
|
+
return turns.filter((turn) => turn && typeof turn.role === 'string').map((turn) => `${turn.role}: ${turn.text ?? ''}`).join('\n');
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
return '';
|
|
90
|
+
}
|
|
91
|
+
}
|
package/dist/runtime-identity.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const JSFE_RUNTIME_FINGERPRINT = "sha256:
|
|
1
|
+
export const JSFE_RUNTIME_FINGERPRINT = "sha256:c2fbd22a8c456db8293ab4fa66498ebe40400d08cbcb9e0706d8416c338f4a0c";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsfe",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.59.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",
|