jsfe 1.61.0 → 1.63.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/form-client.d.ts.map +1 -1
- package/dist/forms/form-client.js +14 -1
- package/dist/forms/send-copy-flow.d.ts.map +1 -1
- package/dist/forms/send-copy-flow.js +11 -8
- package/dist/helpers/index.d.ts +4 -1
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +3 -3
- package/dist/helpers/sendables.d.ts +12 -3
- package/dist/helpers/sendables.d.ts.map +1 -1
- package/dist/helpers/sendables.js +33 -8
- package/dist/runtime-identity.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CC;AAjUD,qCAAsC,eAAe,CAAC"}
|
|
@@ -369,7 +369,20 @@ export function formSubmissionReaders(submission, getSession) {
|
|
|
369
369
|
const valid = read && Object.hasOwn(read, 'value') && read.value !== '' && read.refused !== true && !read.incompleteMoney;
|
|
370
370
|
return { ...hit, value: valid ? read.value : raw, invalid: !valid, origin: 'form_submission', current: false, utterance: '' };
|
|
371
371
|
});
|
|
372
|
-
|
|
372
|
+
// A card re-sends every field it shows. A field sent back with the value the form already holds is not an answer:
|
|
373
|
+
// it is neither acknowledged nor checked again (prod 2026-11-12: "Thank you, I already have your product number"
|
|
374
|
+
// on every store-card submission). A changed value is a correction, as before. When nothing at all changed, the
|
|
375
|
+
// readings stand, so the turn is never read as empty.
|
|
376
|
+
const unchanged = hit => {
|
|
377
|
+
const held = cargo.forms[hit.form]?.values;
|
|
378
|
+
if (!held || !Object.hasOwn(held, hit.name))
|
|
379
|
+
return false;
|
|
380
|
+
return hit.declined === true ? held[hit.name] === null : !hit.invalid && held[hit.name] !== null && held[hit.name] !== undefined
|
|
381
|
+
&& typeof held[hit.name] !== 'object' && String(held[hit.name]) === String(hit.value);
|
|
382
|
+
};
|
|
383
|
+
const changed = hits.filter(hit => !unchanged(hit));
|
|
384
|
+
const read = changed.length ? changed : hits;
|
|
385
|
+
return { hits: read, ambiguous: [], remaining: [], questions: [], refused: [], decisions: read.map(hit => ({ form: hit.form, name: hit.name, rule: 'form_submission' })) };
|
|
373
386
|
},
|
|
374
387
|
enrichFormMatches(matches, chain, form, names = [], asked = '') {
|
|
375
388
|
const result = enrichFormMatches(matches, chain, form, names, asked);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-copy-flow.d.ts","sourceRoot":"","sources":["../../src/forms/send-copy-flow.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"send-copy-flow.d.ts","sourceRoot":"","sources":["../../src/forms/send-copy-flow.js"],"names":[],"mappings":"AA+IA,0BAAgC"}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Intent detection picks the item, the medium and any destination in one stage-2 request: `item` is enum_from
|
|
6
6
|
* 'sendables' (jsfe 1.60.0), so its values are this session's sendables(cargo) keys with their labels.
|
|
7
|
+
* - The whole conversation (once the assistant has replied) goes by email only, as conversationCopy(cargo.chatTurns,
|
|
8
|
+
* language): the turns before this request, in the caller's language.
|
|
7
9
|
* - A content item (a reply, a text document) is sent as is: text through text-destination's number (or the one the
|
|
8
10
|
* caller gave) and send-text; email to the address given, else ask-email, and send-email-message.
|
|
9
11
|
* - A sender item runs its flow with {medium, destination, args} (destination: only what the caller gave): the sender
|
|
@@ -26,22 +28,22 @@ const ANYTHING_ELSE_ES = ' ¿Hay algo más en lo que le pueda ayudar?';
|
|
|
26
28
|
const TEXT_WORDS = ['1', 'text', 'texto', 'sms', 'message', 'text message', 'mensaje', 'mensaje de texto'];
|
|
27
29
|
const EMAIL_WORDS = ['2', 'email', 'e-mail', 'mail', 'correo', 'correo electrónico', 'correo electronico', 'email address'];
|
|
28
30
|
const sendCopy = defineWorker({
|
|
29
|
-
contract: { role: 'router', summary: 'Sends a reply
|
|
31
|
+
contract: { role: 'router', summary: 'Sends a reply, registered document or the whole conversation the caller picks, by text or email, through the system send workers or the document\'s sender flow' },
|
|
30
32
|
id: 'send-copy',
|
|
31
33
|
name: 'SendCopy',
|
|
32
|
-
version: '1.
|
|
34
|
+
version: '1.1.0',
|
|
33
35
|
primary: true,
|
|
34
36
|
prompt: 'Send a copy',
|
|
35
37
|
prompt_es: 'Enviar una copia',
|
|
36
|
-
description: "Asks to be sent, by text or email, something the assistant said in this conversation ('text me that', 'send me that by email', 'mándame eso por mensaje', 'envíeme
|
|
38
|
+
description: "Asks to be sent, by text or email, something the assistant said in this conversation, or a copy of the whole conversation ('text me that', 'send me that by email', 'email me a copy of this chat', 'mándame eso por mensaje', 'envíeme toda la conversación al correo'). Not: continuing the conversation by text (SwitchToText); a person (LiveAgentRequested).",
|
|
37
39
|
parameters: [
|
|
38
|
-
{ name: 'item', type: 'string', enum_from: 'sendables', description: "What the user asks to have sent: the reply or document they name or point to. 'That', 'it', 'this', 'eso' or 'lo que me dijo' is the latest reply." },
|
|
40
|
+
{ name: 'item', type: 'string', enum_from: 'sendables', description: "What the user asks to have sent: the reply or document they name or point to. 'That', 'it', 'this', 'eso' or 'lo que me dijo' is the latest reply; the whole chat, conversation or transcript ('toda la conversación') is the whole conversation." },
|
|
39
41
|
{ name: 'medium', type: 'string', enum: ['text', 'email'], description: "How the user asks to have it sent: text for a text message or SMS ('mensaje', 'texto'), email for an email ('correo')." },
|
|
40
42
|
{ name: 'destination', type: 'string', description: 'The phone number or email address the user gave to send it to, as given.' },
|
|
41
43
|
],
|
|
42
44
|
variables: vars({
|
|
43
45
|
noop: false, sc_items: [], sc_key: '', sc_item: null, sc_last: null, sc_last_head: '', sc_doc_list: '', sc_email: '', sc_phone: '',
|
|
44
|
-
sc_medium: '', sc_medium_q: '', sc_medium_q_es: '', sc_given: '', sc_media: [], sc_forced: '', sc_to: '', sc_subject: '', sc_sent: false,
|
|
46
|
+
sc_medium: '', sc_medium_q: '', sc_medium_q_es: '', sc_given: '', sc_media: [], sc_forced: '', sc_to: '', sc_subject: '', sc_content: '', sc_sent: false,
|
|
45
47
|
}),
|
|
46
48
|
steps: [
|
|
47
49
|
set('sc_items', 'sc_items', 'sendables(cargo)'),
|
|
@@ -118,9 +120,10 @@ const sendCopy = defineWorker({
|
|
|
118
120
|
when('sc_email_read', "sc_medium === 'email' && !sc_to", set('sc_email_pick', 'sc_to', "cargo.email && validateEmail(String(cargo.email)) ? String(cargo.email) : ''")),
|
|
119
121
|
when('sc_email_none_end', "sc_medium === 'email' && !sc_to", end('sc_email_none_done')),
|
|
120
122
|
// send: a sender item runs its flow (it tells the caller); content goes as is
|
|
121
|
-
set('sc_subject', 'sc_subject', "language === 'es' ? 'Su copia de nuestra conversación' : 'Your copy from our conversation'"),
|
|
122
|
-
|
|
123
|
-
when('
|
|
123
|
+
set('sc_subject', 'sc_subject', "language === 'es' ? 'Su copia de nuestra conversación' : sc_item.kind === 'conversation' ? 'Your copy of our conversation' : 'Your copy from our conversation'"),
|
|
124
|
+
set('sc_content', 'sc_content', "sc_item.kind === 'conversation' ? conversationCopy(cargo.chatTurns, language) : sc_item.content"),
|
|
125
|
+
when('sc_send_text', "sc_medium === 'text'", call('sc_send_text_call', 'send-text', { message: '{{sc_content}}' })),
|
|
126
|
+
when('sc_send_email', "sc_medium === 'email'", call('sc_send_email_call', 'send-email-message', { to: '{{sc_to}}', subject: '{{sc_subject}}', message: '{{sc_content}}', cc: '' })),
|
|
124
127
|
set('sc_sent', 'sc_sent', "sc_medium === 'text' ? cargo.textSent === true : cargo.emailSent === true"),
|
|
125
128
|
when('sc_done_text', "sc_sent && sc_medium === 'text'", say('sc_done_text_say', 'Done. I texted it to the number ending in {{cargo.textTo4}}.' + ANYTHING_ELSE, 'Listo. Se lo envié por mensaje de texto al número que termina en {{cargo.textTo4}}.' + ANYTHING_ELSE_ES)),
|
|
126
129
|
when('sc_done_email', "sc_sent && sc_medium === 'email'", say('sc_done_email_say', 'Done. I emailed it to {{sc_to}}.' + ANYTHING_ELSE, 'Listo. Se lo envié por correo a {{sc_to}}.' + ANYTHING_ELSE_ES)),
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -132,6 +132,7 @@ export namespace STANDARD_FUNCTIONS {
|
|
|
132
132
|
export { registerSendable };
|
|
133
133
|
export { sendables };
|
|
134
134
|
export { chatTranscript };
|
|
135
|
+
export { conversationCopy };
|
|
135
136
|
}
|
|
136
137
|
import { continuationSafetyProtocol } from '../forms/continuation-safety.js';
|
|
137
138
|
import { cancelFormTask } from './form-conversation.js';
|
|
@@ -273,5 +274,7 @@ import { wholeSpokenNumber } from './spoken-digits.js';
|
|
|
273
274
|
import { registerSendable } from './sendables.js';
|
|
274
275
|
import { sendables } from './sendables.js';
|
|
275
276
|
import { chatTranscript } from './sendables.js';
|
|
276
|
-
|
|
277
|
+
import { conversationCopy } from './sendables.js';
|
|
278
|
+
import { CONVERSATION_KEY } from './sendables.js';
|
|
279
|
+
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, conversationCopy, CONVERSATION_KEY };
|
|
277
280
|
//# 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":"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"}
|
package/dist/helpers/index.js
CHANGED
|
@@ -5,7 +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
|
+
import { registerSendable, sendables, chatTranscript, conversationCopy, CONVERSATION_KEY } from './sendables.js';
|
|
9
9
|
import { consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified } from './form-actions.js';
|
|
10
10
|
/**
|
|
11
11
|
* jsfe/helpers — the functions JSFE's system flows call from expressions, in ONE place for every host: reading an
|
|
@@ -37,7 +37,7 @@ import { checkOtp, clearOtp, maskDestination, validateOTP, OTP_EXPIRY_MS } from
|
|
|
37
37
|
import { validateDigits, validatePhone, validateEmail } from './validators.js';
|
|
38
38
|
import { joinSpokenDigits, spokenDigitsText, wholeSpokenNumber } from './spoken-digits.js';
|
|
39
39
|
import { urlToSpeech, textWithUrlToSpeech } from './url-speech.js';
|
|
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
|
+
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, conversationCopy, CONVERSATION_KEY, };
|
|
41
41
|
/** The functions flows call by name, ready to spread into a host's approved functions. */
|
|
42
42
|
export const STANDARD_FUNCTIONS = {
|
|
43
43
|
continuationSafetyProtocol, cancelFormTask, contextualResponseProtocol, validateFormResponse, hasFormResponse,
|
|
@@ -47,5 +47,5 @@ export const STANDARD_FUNCTIONS = {
|
|
|
47
47
|
readEmail, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational,
|
|
48
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,
|
|
49
49
|
validateOTP, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech, joinSpokenDigits, wholeSpokenNumber,
|
|
50
|
-
registerSendable, sendables, chatTranscript,
|
|
50
|
+
registerSendable, sendables, chatTranscript, conversationCopy,
|
|
51
51
|
};
|
|
@@ -5,11 +5,18 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export function registerSendable(cargo: any, entry: any): boolean;
|
|
7
7
|
/**
|
|
8
|
-
* Everything the caller may ask to be sent now: the registered documents,
|
|
9
|
-
* assistant turns of cargo.chatTurns, newest last. Each item is
|
|
10
|
-
*
|
|
8
|
+
* Everything the caller may ask to be sent now: the registered documents, the whole conversation (once the assistant has
|
|
9
|
+
* replied), then the last REPLY_COUNT non-empty assistant turns of cargo.chatTurns, newest last. Each item is
|
|
10
|
+
* {key, label, label_es?, kind, media?, content | sender+args}; the conversation is {key: CONVERSATION_KEY, kind:
|
|
11
|
+
* 'conversation', media: ['email']} with no content (conversationCopy makes it). A reply's key is "reply-<n>" (its turn
|
|
12
|
+
* number) and its label "Reply <n>: <first 120 characters>".
|
|
11
13
|
*/
|
|
12
14
|
export function sendables(cargo: any): any[];
|
|
15
|
+
/**
|
|
16
|
+
* The conversation as the caller receives a copy of it: "You: …" / "Assistant: …" ("Usted" / "Asistente" in Spanish),
|
|
17
|
+
* one paragraph per non-empty turn, in order. The turns are the host's masked text (cargo.chatTurns). → '' for none.
|
|
18
|
+
*/
|
|
19
|
+
export function conversationCopy(turns: any, language?: string): string;
|
|
13
20
|
/**
|
|
14
21
|
* The conversation as "role: text" lines, one per turn, in order: the same text the host's flat chat history has
|
|
15
22
|
* always carried (ChatContextManager.messagesWithRole), so a note built from it reads as before.
|
|
@@ -26,4 +33,6 @@ export function sendableDeclarationError(sendable: any): string;
|
|
|
26
33
|
* registered at run time (registerSendable) keeps its key. An invalid declaration is skipped (validation reports it).
|
|
27
34
|
*/
|
|
28
35
|
export function syncDeclaredSendables(cargo: any, flows: any): void;
|
|
36
|
+
/** The whole conversation's key in sendables(cargo); like "reply-<n>", no flow may register or declare it. */
|
|
37
|
+
export const CONVERSATION_KEY: "conversation";
|
|
29
38
|
//# sourceMappingURL=sendables.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendables.d.ts","sourceRoot":"","sources":["../../src/helpers/sendables.js"],"names":[],"mappings":"
|
|
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;AAED;;;GAGG;AACH,mDAMC;AAED;;;GAGG;AACH,gEAeC;AAED;;;;GAIG;AACH,oEAsBC;AAtJD,8GAA8G;AAC9G,+BAAgC,cAAc,CAAC"}
|
|
@@ -7,9 +7,16 @@
|
|
|
7
7
|
* - an entry with `sender` runs that flow with {medium, destination, ...args}; every sender flow takes those three.
|
|
8
8
|
* The host's replies are offered too, from cargo.chatTurns (the host's masked conversation, a list of
|
|
9
9
|
* {n, role, text, source?}); nothing registers them. chatTranscript(turns) formats that list as "role: text" lines.
|
|
10
|
+
* Once the assistant has replied, the whole conversation is offered too (key CONVERSATION_KEY, email only): it carries no
|
|
11
|
+
* content, because its text is the caller's language's copy, conversationCopy(cargo.chatTurns, language), made at send time.
|
|
10
12
|
*/
|
|
11
13
|
const REPLY_COUNT = 6;
|
|
12
14
|
const REPLY_LABEL_CHARS = 120;
|
|
15
|
+
/** The whole conversation's key in sendables(cargo); like "reply-<n>", no flow may register or declare it. */
|
|
16
|
+
export const CONVERSATION_KEY = 'conversation';
|
|
17
|
+
const RESERVED_KEYS = `a key starting with "reply-" or "${CONVERSATION_KEY}"`;
|
|
18
|
+
const reservedKey = (key) => key.startsWith('reply-') || key === CONVERSATION_KEY;
|
|
19
|
+
const SPEAKERS = { en: { user: 'You', assistant: 'Assistant' }, es: { user: 'Usted', assistant: 'Asistente' } };
|
|
13
20
|
const isText = (value) => typeof value === 'string' && value.trim() !== '';
|
|
14
21
|
const MEDIA = ['text', 'email'];
|
|
15
22
|
/** media, when given: a nonempty list of distinct 'text' / 'email' (what the sender can send by). */
|
|
@@ -27,8 +34,8 @@ export function registerSendable(cargo, entry) {
|
|
|
27
34
|
else if (!entry || typeof entry !== 'object') {
|
|
28
35
|
throw new Error('registerSendable: entry must be an object');
|
|
29
36
|
}
|
|
30
|
-
else if (!isText(entry.key) || entry.key
|
|
31
|
-
throw new Error(`registerSendable: key must be a nonempty string not
|
|
37
|
+
else if (!isText(entry.key) || reservedKey(entry.key)) {
|
|
38
|
+
throw new Error(`registerSendable: key must be a nonempty string, not ${RESERVED_KEYS} (got ${JSON.stringify(entry.key)})`);
|
|
32
39
|
}
|
|
33
40
|
else if (!isText(entry.label)) {
|
|
34
41
|
throw new Error(`registerSendable(${entry.key}): label must be a nonempty string`);
|
|
@@ -70,9 +77,11 @@ export function registerSendable(cargo, entry) {
|
|
|
70
77
|
}
|
|
71
78
|
}
|
|
72
79
|
/**
|
|
73
|
-
* Everything the caller may ask to be sent now: the registered documents,
|
|
74
|
-
* assistant turns of cargo.chatTurns, newest last. Each item is
|
|
75
|
-
*
|
|
80
|
+
* Everything the caller may ask to be sent now: the registered documents, the whole conversation (once the assistant has
|
|
81
|
+
* replied), then the last REPLY_COUNT non-empty assistant turns of cargo.chatTurns, newest last. Each item is
|
|
82
|
+
* {key, label, label_es?, kind, media?, content | sender+args}; the conversation is {key: CONVERSATION_KEY, kind:
|
|
83
|
+
* 'conversation', media: ['email']} with no content (conversationCopy makes it). A reply's key is "reply-<n>" (its turn
|
|
84
|
+
* number) and its label "Reply <n>: <first 120 characters>".
|
|
76
85
|
*/
|
|
77
86
|
export function sendables(cargo) {
|
|
78
87
|
const documents = Array.isArray(cargo?.sendables) ? cargo.sendables.filter((item) => isText(item?.key)).map((item) => (item.args ? { ...item, args: { ...item.args } } : { ...item })) : [];
|
|
@@ -82,7 +91,23 @@ export function sendables(cargo) {
|
|
|
82
91
|
const head = text.length > REPLY_LABEL_CHARS ? text.slice(0, REPLY_LABEL_CHARS) + '…' : text;
|
|
83
92
|
return { key: `reply-${turn.n}`, label: `Reply ${turn.n}: ${head}`, kind: 'reply', content: text };
|
|
84
93
|
});
|
|
85
|
-
|
|
94
|
+
const conversation = replies.length
|
|
95
|
+
? [{ key: CONVERSATION_KEY, label: 'The whole conversation', label_es: 'Toda nuestra conversación', kind: 'conversation', media: ['email'] }]
|
|
96
|
+
: [];
|
|
97
|
+
return [...documents, ...conversation, ...replies];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The conversation as the caller receives a copy of it: "You: …" / "Assistant: …" ("Usted" / "Asistente" in Spanish),
|
|
101
|
+
* one paragraph per non-empty turn, in order. The turns are the host's masked text (cargo.chatTurns). → '' for none.
|
|
102
|
+
*/
|
|
103
|
+
export function conversationCopy(turns, language = 'en') {
|
|
104
|
+
const speakers = SPEAKERS[language] || SPEAKERS.en;
|
|
105
|
+
if (Array.isArray(turns)) {
|
|
106
|
+
return turns.filter((turn) => turn && speakers[turn.role] && isText(turn.text)).map((turn) => `${speakers[turn.role]}: ${turn.text.trim()}`).join('\n\n');
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
return '';
|
|
110
|
+
}
|
|
86
111
|
}
|
|
87
112
|
/**
|
|
88
113
|
* The conversation as "role: text" lines, one per turn, in order: the same text the host's flat chat history has
|
|
@@ -104,8 +129,8 @@ export function sendableDeclarationError(sendable) {
|
|
|
104
129
|
if (!sendable || typeof sendable !== 'object' || Array.isArray(sendable)) {
|
|
105
130
|
return 'sendable must be an object {key, label, label_es?}';
|
|
106
131
|
}
|
|
107
|
-
else if (!isText(sendable.key) || sendable.key
|
|
108
|
-
return
|
|
132
|
+
else if (!isText(sendable.key) || reservedKey(sendable.key)) {
|
|
133
|
+
return `sendable.key must be a nonempty string, not ${RESERVED_KEYS}`;
|
|
109
134
|
}
|
|
110
135
|
else if (!isText(sendable.label)) {
|
|
111
136
|
return 'sendable.label must be a nonempty string';
|
package/dist/runtime-identity.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const JSFE_RUNTIME_FINGERPRINT = "sha256:
|
|
1
|
+
export const JSFE_RUNTIME_FINGERPRINT = "sha256:76aeadeef949e31a1f1d4ea04d2d6c94ac2840566d8f02c2d70a30e3b5e83c5b";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsfe",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.63.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",
|