jsfe 1.84.0 → 1.85.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.
|
@@ -85,7 +85,7 @@ export function otpDigits(text) {
|
|
|
85
85
|
// other answer returns the digits it holds, as before, except pieces separated by words that glue to six: they are never a
|
|
86
86
|
// code ("572 and then 180" is "572180?", a format miss). Runs inside a flow expression, so findNumbers/assignNumbers are the
|
|
87
87
|
// standard functions.
|
|
88
|
-
const numbers = findNumbers(String(text || '')), read = assignNumbers(numbers, {
|
|
88
|
+
const numbers = findNumbers(String(text || '')), read = assignNumbers(numbers, [{ name: 'code', kind: 'digits', min: 6 }]);
|
|
89
89
|
if (read.values.code)
|
|
90
90
|
return read.values.code;
|
|
91
91
|
const digits = numbers.map(n => n.value).join('');
|
|
@@ -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":"AA0KA,0BAAgC"}
|
|
@@ -4,10 +4,11 @@
|
|
|
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)
|
|
8
|
-
*
|
|
9
|
-
* - A content item (a reply, a text document) is sent as is: text through text-destination's number
|
|
10
|
-
* caller gave) and send-text
|
|
7
|
+
* - The whole conversation (once the assistant has replied) is conversationCopy(cargo.chatTurns, language): the turns
|
|
8
|
+
* before this request, in the caller's language.
|
|
9
|
+
* - A content item (a reply, a text document, the conversation) is sent as is: text through text-destination's number
|
|
10
|
+
* (or the one the caller gave) and send-text when it fits one text message (TEXT_MAX), else by email; email to the
|
|
11
|
+
* address given, else ask-email, and send-email-message.
|
|
11
12
|
* - A sender item runs its flow with {medium, destination, args} (destination: only what the caller gave): the sender
|
|
12
13
|
* collects the rest, sets cargo.copyHandled = true as it takes over and tells the caller every outcome. Without it (a
|
|
13
14
|
* missing sender) SendCopy says it could not send. A sender's declared media limit the medium (statement: email).
|
|
@@ -26,6 +27,8 @@ const call = (id, value, parameters) => ({ id, type: 'FLOW', value, callType: 'c
|
|
|
26
27
|
const ANYTHING_ELSE = ' Is there anything else I can help you with?';
|
|
27
28
|
const ANYTHING_ELSE_ES = ' ¿Hay algo más en lo que le pueda ayudar?';
|
|
28
29
|
const TEXT_WORDS = ['1', 'text', 'texto', 'sms', 'message', 'text message', 'mensaje', 'mensaje de texto'];
|
|
30
|
+
// A text message is one message: Twilio rejects a body over 1,600 characters (error 21617), so longer content goes by email.
|
|
31
|
+
const TEXT_MAX = 1600;
|
|
29
32
|
const EMAIL_WORDS = ['2', 'email', 'e-mail', 'mail', 'correo', 'correo electrónico', 'correo electronico', 'email address'];
|
|
30
33
|
const sendCopy = defineWorker({
|
|
31
34
|
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' },
|
|
@@ -35,7 +38,7 @@ const sendCopy = defineWorker({
|
|
|
35
38
|
primary: true,
|
|
36
39
|
prompt: 'Send a copy',
|
|
37
40
|
prompt_es: 'Enviar una copia',
|
|
38
|
-
description: "Asks to be sent something by text or email, whatever it is ('email me that', 'text me the case number', 'can I have that emailed to me', 'send me a copy of this chat', 'mándame eso por mensaje', 'me lo puede mandar por correo'). Not: continuing the conversation by text (SwitchToText)
|
|
41
|
+
description: "Asks to be sent something by text or email, whatever it is ('email me that', 'text me the case number', 'send me the receipt', 'can I have that emailed to me', 'send me a copy of this chat', 'mándame eso por mensaje', 'me lo puede mandar por correo'). Not: continuing the conversation by text (SwitchToText).",
|
|
39
42
|
parameters: [
|
|
40
43
|
{ 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." },
|
|
41
44
|
{ 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')." },
|
|
@@ -44,7 +47,7 @@ const sendCopy = defineWorker({
|
|
|
44
47
|
],
|
|
45
48
|
variables: vars({
|
|
46
49
|
noop: false, sc_items: [], sc_key: '', sc_item: null, sc_last: null, sc_last_head: '', sc_offer_q: '', sc_offer_q_es: '', sc_doc_list: '', sc_email: '', sc_phone: '',
|
|
47
|
-
sc_medium: '', sc_medium_q: '', sc_medium_q_es: '', sc_given: '', sc_other: false, sc_media: [], sc_forced: '', sc_to: '', sc_subject: '', sc_content: '', sc_sent: false,
|
|
50
|
+
sc_medium: '', sc_medium_q: '', sc_medium_q_es: '', sc_given: '', sc_other: false, sc_too_long: false, sc_media: [], sc_forced: '', sc_to: '', sc_subject: '', sc_content: '', sc_sent: false,
|
|
48
51
|
}),
|
|
49
52
|
steps: [
|
|
50
53
|
set('sc_items', 'sc_items', 'sendables(cargo)'),
|
|
@@ -75,10 +78,14 @@ const sendCopy = defineWorker({
|
|
|
75
78
|
set('sc_email', 'sc_email', "(String(typeof destination === 'string' ? destination : '').match(/[^\\s@]+@[^\\s@]+\\.[^\\s@]+/) || [''])[0].replace(/[.,;:]+$/, '')"),
|
|
76
79
|
set('sc_phone', 'sc_phone', "readPhone(typeof destination === 'string' ? destination : '')"),
|
|
77
80
|
set('sc_medium', 'sc_medium', "typeof medium === 'string' && (medium === 'text' || medium === 'email') ? medium : sc_email ? 'email' : sc_phone ? 'text' : ''"),
|
|
78
|
-
// the media this item can go by: a sender's declared media; content by text only where the line has a sender
|
|
79
|
-
|
|
81
|
+
// the media this item can go by: a sender's declared media; content by text only where the line has a sender and it
|
|
82
|
+
// fits one text message (TEXT_MAX), else by email
|
|
83
|
+
set('sc_content', 'sc_content', "sc_item.kind === 'conversation' ? conversationCopy(cargo.chatTurns, language) : String(sc_item.content || '')"),
|
|
84
|
+
set('sc_too_long', 'sc_too_long', `!sc_item.sender && sc_content.length > ${TEXT_MAX}`),
|
|
85
|
+
set('sc_media', 'sc_media', "Array.isArray(sc_item.media) && sc_item.media.length ? sc_item.media : ((sc_item.sender || cargo.twilioNumber) && !sc_too_long ? ['text', 'email'] : ['email'])"),
|
|
80
86
|
set('sc_forced', 'sc_forced', "sc_media.length === 1 && !!sc_medium && sc_medium !== sc_media[0] ? sc_media[0] : ''"),
|
|
81
|
-
when('
|
|
87
|
+
when('sc_forced_long', "sc_forced === 'email' && sc_too_long", say('sc_forced_long_say', "That's too long for a text message, so I'll email it.", 'Es demasiado largo para un mensaje de texto, así que se lo enviaré por correo.')),
|
|
88
|
+
when('sc_forced_email', "sc_forced === 'email' && !sc_too_long", say('sc_forced_email_say', "I can only send that by email, so I'll email it.", 'Solo puedo enviarlo por correo, así que se lo enviaré por correo.')),
|
|
82
89
|
when('sc_forced_text', "sc_forced === 'text'", say('sc_forced_text_say', "I can only send that by text, so I'll text it.", 'Solo puedo enviarlo por mensaje de texto, así que se lo enviaré por mensaje.')),
|
|
83
90
|
set('sc_medium_one', 'sc_medium', "sc_media.length === 1 ? sc_media[0] : sc_medium"),
|
|
84
91
|
// FLOW parameters are paths only: the wording is chosen here
|
|
@@ -141,7 +148,6 @@ const sendCopy = defineWorker({
|
|
|
141
148
|
when('sc_email_none_end', "sc_medium === 'email' && !sc_to", end('sc_email_none_done')),
|
|
142
149
|
// send: a sender item runs its flow (it tells the caller); content goes as is
|
|
143
150
|
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'"),
|
|
144
|
-
set('sc_content', 'sc_content', "sc_item.kind === 'conversation' ? conversationCopy(cargo.chatTurns, language) : sc_item.content"),
|
|
145
151
|
when('sc_send_text', "sc_medium === 'text'", call('sc_send_text_call', 'send-text', { message: '{{sc_content}}' })),
|
|
146
152
|
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: '' })),
|
|
147
153
|
set('sc_sent', 'sc_sent', "sc_medium === 'text' ? cargo.textSent === true : cargo.emailSent === true"),
|
|
@@ -8,7 +8,7 @@ export function registerSendable(cargo: any, entry: any): boolean;
|
|
|
8
8
|
* Everything the caller may ask to be sent now: the registered documents, the whole conversation (once the assistant has
|
|
9
9
|
* replied), then the last REPLY_COUNT non-empty assistant turns of cargo.chatTurns, newest last. Each item is
|
|
10
10
|
* {key, label, label_es?, kind, media?, content | sender+args}; the conversation is {key: CONVERSATION_KEY, kind:
|
|
11
|
-
* 'conversation'
|
|
11
|
+
* 'conversation'} with no content (conversationCopy makes it; SendCopy texts it when it fits one message, else emails it). A reply's key is "reply-<n>" (its turn
|
|
12
12
|
* number) and its label "Reply <n>: <first 120 characters>".
|
|
13
13
|
*/
|
|
14
14
|
export function sendables(cargo: any): any[];
|
|
@@ -80,7 +80,7 @@ export function registerSendable(cargo, entry) {
|
|
|
80
80
|
* Everything the caller may ask to be sent now: the registered documents, the whole conversation (once the assistant has
|
|
81
81
|
* replied), then the last REPLY_COUNT non-empty assistant turns of cargo.chatTurns, newest last. Each item is
|
|
82
82
|
* {key, label, label_es?, kind, media?, content | sender+args}; the conversation is {key: CONVERSATION_KEY, kind:
|
|
83
|
-
* 'conversation'
|
|
83
|
+
* 'conversation'} with no content (conversationCopy makes it; SendCopy texts it when it fits one message, else emails it). A reply's key is "reply-<n>" (its turn
|
|
84
84
|
* number) and its label "Reply <n>: <first 120 characters>".
|
|
85
85
|
*/
|
|
86
86
|
export function sendables(cargo) {
|
|
@@ -92,7 +92,7 @@ export function sendables(cargo) {
|
|
|
92
92
|
return { key: `reply-${turn.n}`, label: `Reply ${turn.n}: ${head}`, kind: 'reply', content: text };
|
|
93
93
|
});
|
|
94
94
|
const conversation = replies.length
|
|
95
|
-
? [{ key: CONVERSATION_KEY, label: 'The whole conversation', label_es: 'Toda nuestra conversación', kind: 'conversation'
|
|
95
|
+
? [{ key: CONVERSATION_KEY, label: 'The whole conversation', label_es: 'Toda nuestra conversación', kind: 'conversation' }]
|
|
96
96
|
: [];
|
|
97
97
|
return [...documents, ...conversation, ...replies];
|
|
98
98
|
}
|
package/dist/runtime-identity.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const JSFE_RUNTIME_FINGERPRINT = "sha256:
|
|
1
|
+
export const JSFE_RUNTIME_FINGERPRINT = "sha256:451cfd1eb480507f96e075987ab3483c8551f01bff011e169b27d21b82eee48d";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsfe",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.85.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",
|