jsfe 1.62.0 → 1.64.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.js +2 -2
- 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/docs/copilot-reference.md +1 -1
- package/package.json +1 -1
package/dist/forms/flows.js
CHANGED
|
@@ -407,7 +407,7 @@ const collectInput = {
|
|
|
407
407
|
id: 'collect-input', name: 'CollectInput', version: '1.0.0', scope: 'isolated',
|
|
408
408
|
description: "Worker: ask the form's current input once and file the answer wherever it belongs in the form chain (matchInputs, decided by scope; a declared confirm_against pair is asked). One reading → collect-input-accept; ambiguous → disambiguate-input; a question about the form's data → provide-data; a short miss → counted, the loop re-asks; 3+ words that fit nothing → DISPATCH. Params: form, current, questions, provides, exit_context(_es).",
|
|
409
409
|
parameters: ['form', 'current', 'questions', 'provides', 'exit_context', 'exit_context_es'].map((n) => ({ name: n, type: ['questions'].includes(n) ? 'array' : n === 'provides' ? 'object' : 'string', description: n })),
|
|
410
|
-
variables: vars({ ci_clarify: null, ci_partial: '', ci_no_owner: '', ci_no_flow: '', ci_no_up: false, ci_reply_reader: '', ci_exhaustion: null, ci_d: {}, ci_pre: '', ci_val: '', ci_routed: '', ci_names: [], ci_chain: [], ci_spec: null, ci_choices: [], ci_q: '', ci_q_es: '', ci_missed: 0, ci_max: 3, ci_misses: 0, ci_miss_limit:
|
|
410
|
+
variables: vars({ ci_clarify: null, ci_partial: '', ci_no_owner: '', ci_no_flow: '', ci_no_up: false, ci_reply_reader: '', ci_exhaustion: null, ci_d: {}, ci_pre: '', ci_val: '', ci_routed: '', ci_names: [], ci_chain: [], ci_spec: null, ci_choices: [], ci_q: '', ci_q_es: '', ci_missed: 0, ci_max: 3, ci_misses: 0, ci_miss_limit: 4, ci_must: false, ci_m: null, ci_qkey: '', ci_skip_gate: '', ci_words: 0, ci_digits: null, ci_amount: false, ci_as_spoken: false, ci_reader: {}, ci_pii: false, ci_ctx: '', ci_ctx_es: '' }),
|
|
411
411
|
steps: [
|
|
412
412
|
SET('ci_find_spec', 'ci_spec', "(function () { var s = ((cargo.forms[form] || {}).specs || []).filter(function (s) { return s.name === current; })[0]; return s ? (Array.isArray(s.any_of) ? Object.assign({}, s, { profile: { kind: 'group' } }) : s) : null; })()"),
|
|
413
413
|
SET('ci_current_names', 'ci_names', "Array.isArray(ci_spec && ci_spec.any_of) ? ci_spec.any_of.map(function (m) { return m.name; }) : [current]"),
|
|
@@ -415,7 +415,7 @@ const collectInput = {
|
|
|
415
415
|
SET('ci_count_missed', 'ci_missed', "Number(((cargo.forms[form] || {}).attempts || {})[current] || 0)"),
|
|
416
416
|
SET('ci_max_attempts', 'ci_max', 'Number(ci_spec.max_attempts || 3)'),
|
|
417
417
|
SET('ci_context_misses', 'ci_misses', 'Number(((cargo.forms[form] || {}).misses || {})[current] || 0)'),
|
|
418
|
-
SET('ci_context_limit', 'ci_miss_limit', 'Number(ci_spec.max_misses ||
|
|
418
|
+
SET('ci_context_limit', 'ci_miss_limit', 'Number(ci_spec.max_misses || 4)'),
|
|
419
419
|
// must_complete (the field's, else the nearest form's): an unreadable answer is never handed away; it is asked again
|
|
420
420
|
SET('ci_must_complete', 'ci_must', 'formMustComplete(cargo,form,current)'),
|
|
421
421
|
WHEN('ci_context_yield', 'ci_misses >= ci_miss_limit && !ci_must', yieldDispatch('ci_misses_dispatch', 'form', "'input_misses_exhausted'")),
|
|
@@ -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:64b2e7ca250843a61ff538116240912866c88675ccb7c7c4ced73d247e4acc4b";
|
|
@@ -267,7 +267,7 @@ The loop skips accepted data and asks the first ready missing required field. Co
|
|
|
267
267
|
|
|
268
268
|
### Retry, yield and recovery
|
|
269
269
|
|
|
270
|
-
An unreadable answer with any words goes to the reply ranker, offered the question's choices (`exact` ones too, since `exact` is how words match a choice; never the YES of a firm confirmation; a NO always) and a person (`__agent`), never text (the words and keypad key for text are read before it): a picked choice is the answer, a person is taken, a reply that picks none is asked again (counted against `max_attempts`); only `abort` or `new_request` leaves the form. `max_misses` (default
|
|
270
|
+
An unreadable answer with any words goes to the reply ranker, offered the question's choices (`exact` ones too, since `exact` is how words match a choice; never the YES of a firm confirmation; a NO always) and a person (`__agent`), never text (the words and keypad key for text are read before it): a picked choice is the answer, a person is taken, a reply that picks none is asked again (counted against `max_attempts`); only `abort` or `new_request` leaves the form. `max_misses` (default four) bounds unreadable answers without words (symbols, an unexpected keypad entry): clarify each with explicit retry text or a localized “Sorry, I didn't catch that.” prefix; yield the fourth utterance to DISPATCH while preserving the draft. A form confirmation's unread answers are ranked the same way (offered NO, never YES); after four, the `give-up` worker takes over. Validator failures use a separate `max_attempts` budget. An out-of-order accepted answer is not a miss. On exhaustion the nearest declared `on_exhausted` receives `{form,input,failed_form,failed_input,reason:"attempts_exhausted"}` and must deliberately recover that branch; it does not receive consent.
|
|
271
271
|
|
|
272
272
|
`user_description` / `user_description_es` on a form (jsfe 1.42.0): one sentence saying what the process does, written with the engine's own `{{...}}` expressions, every input of the form in scope ('' until answered) and its data ("This process allows you to change the delivery address or delivery date for your order.{{change === 'address' ? ' You chose to change the delivery address.' : change === 'date' ? ' You chose to change the delivery date.' : ''}}"). The nearest form in the chain declaring one is used. The form's readers then offer the reply ranker `concern`; a caller who expresses doubt that the process is what they need hears the sentence, "To cancel, press the asterisk key or say EXIT." (text: "To cancel, type EXIT."; Spanish SALIR) and the question again, with no attempt counted. Declare it where a caller may mistake what the flow is doing; it applies to every question of the form and its sub-forms, so word it for all of them.
|
|
273
273
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsfe",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.64.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",
|