jsfe 1.58.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/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
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.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B,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",
|