jsfe 1.98.0 → 1.100.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/README.md +2 -0
- package/dist/forms/index.d.ts.map +1 -1
- package/dist/forms/index.js +2 -1
- package/dist/forms/transfer-line-flow.d.ts +2 -0
- package/dist/forms/transfer-line-flow.d.ts.map +1 -0
- package/dist/forms/transfer-line-flow.js +84 -0
- package/dist/helpers/index.d.ts +3 -1
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +4 -3
- package/dist/helpers/phone-to-speech.d.ts +2 -0
- package/dist/helpers/phone-to-speech.d.ts.map +1 -0
- package/dist/helpers/phone-to-speech.js +44 -0
- package/dist/runtime-identity.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -966,6 +966,8 @@ See the [retry/yield/recovery contract](docs/copilot-reference.md#retry-yield-an
|
|
|
966
966
|
|
|
967
967
|
### Host Responsibilities: Tool Calls, Cancellation and Concurrency
|
|
968
968
|
|
|
969
|
+
> Transfer departments (`transfer-to-line`): the host stamps `cargo.transferLines` and consumes `cargo.transferTo`, see [docs/transfer-lines.md](docs/transfer-lines.md).
|
|
970
|
+
|
|
969
971
|
A flow can take actions in the outside world through `CALL-TOOL` — charge a card, send an SMS,
|
|
970
972
|
create a ticket. For ordinary `CALL-TOOL` flows, **the session returned by `updateActivity` records
|
|
971
973
|
which steps already ran**; the host owns its persistence. Native performers can additionally use an
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/forms/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/forms/index.js"],"names":[],"mappings":"AAQA,0BAA+K"}
|
package/dist/forms/index.js
CHANGED
|
@@ -5,7 +5,8 @@ import { FLOWS as FORM_FLOWS } from './flows.js';
|
|
|
5
5
|
import { FLOWS as CHOICE_FLOWS } from './choice-flow.js';
|
|
6
6
|
import { FLOWS as IDENTITY } from './identity-flows.js';
|
|
7
7
|
import { FLOWS as SEND_COPY } from './send-copy-flow.js';
|
|
8
|
-
|
|
8
|
+
import { FLOWS as TRANSFER_LINE } from './transfer-line-flow.js';
|
|
9
|
+
export const FLOWS = [...FORM_FLOWS, ...ADDRESS_FLOWS, ...CHOICE_FLOWS, ...IDENTITY, ...SEND_COPY, ...TRANSFER_LINE].map(flow => withSafetyRevision(flow, 'dispatch-intake-2026-10-22'));
|
|
9
10
|
export { FIELD_PRESETS, formFlow, declinedFlow, textValue, confirmationFirmness } from './flows.js';
|
|
10
11
|
export { FLOWS as IDENTITY_FLOWS } from './identity-flows.js';
|
|
11
12
|
export { linkFormSchemas, defineWorker, defineProvider, defineForm, definePerformer, validateFlowContracts, operationWorkers, providerQuestions, providerParameter } from './contracts.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer-line-flow.d.ts","sourceRoot":"","sources":["../../src/forms/transfer-line-flow.js"],"names":[],"mappings":"AA0FA,0BAAsC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TransferToLine (owner 2026-11-29): offer a warm transfer to one of the tenant's approved departments, by its key.
|
|
3
|
+
* Tenant-agnostic; built into the system set by AIDevelopment forms/system-forms.mjs.
|
|
4
|
+
*
|
|
5
|
+
* The departments are the tenant's own (user-admin → Channels → Transfer departments). The host stamps them on every
|
|
6
|
+
* turn as cargo.transferLines = { <key>: { name, name_es, phone, hours, hours_es, available } }: `available` is true
|
|
7
|
+
* only on a call, inside the department's schedule. A flow names a KEY, never a number: the host dials only the number
|
|
8
|
+
* the tenant configured for that key.
|
|
9
|
+
* - Available: the caller is asked (unless `confirmed`: they already asked to be connected); YES sets cargo.transferTo = key
|
|
10
|
+
* and ends every flow with the connecting line, and the host ends the call's session and dials the department. NO gives
|
|
11
|
+
* the number.
|
|
12
|
+
* - Not available (closed, or not a call): the department's number and hours are given.
|
|
13
|
+
* - An unknown key says the team cannot be reached here.
|
|
14
|
+
*/
|
|
15
|
+
import { defineWorker } from './contracts.js';
|
|
16
|
+
const vars = (o) => Object.fromEntries(Object.entries(o).map(([k, v]) => [k, { type: Array.isArray(v) ? 'array' : v === null || typeof v === 'object' ? 'object' : typeof v, value: v }]));
|
|
17
|
+
const set = (id, variable, value) => ({ id, type: 'SET', variable, value });
|
|
18
|
+
const effect = (id, value) => set(id, 'assignment_side_effect', value);
|
|
19
|
+
const noop = (id) => set(id, 'noop', 'true');
|
|
20
|
+
const when = (id, condition, step) => ({ id, type: 'CASE', branches: { [`condition: ${condition}`]: step, default: noop(`${id}_skip`) } });
|
|
21
|
+
const say = (id, value, value_es) => ({ id, type: 'SAY', value, value_es });
|
|
22
|
+
const end = (id, extra = {}) => ({ id, type: 'END', ...extra });
|
|
23
|
+
const call = (id, value, parameters) => ({ id, type: 'FLOW', value, callType: 'call', ...(parameters ? { parameters } : {}) });
|
|
24
|
+
const ANYTHING_ELSE = "{{typeof no_closing !== 'undefined' && (no_closing === true || no_closing === 'true') ? '' : ' Is there anything else I can help you with?'}}";
|
|
25
|
+
const ANYTHING_ELSE_ES = "{{typeof no_closing !== 'undefined' && (no_closing === true || no_closing === 'true') ? '' : ' ¿Hay algo más en lo que le pueda ayudar?'}}";
|
|
26
|
+
const LEAD = "(typeof lead === 'string' && lead ? lead + ' ' : '')";
|
|
27
|
+
const LEAD_ES = "(typeof lead_es === 'string' && lead_es ? lead_es + ' ' : (typeof lead === 'string' && lead ? lead + ' ' : ''))";
|
|
28
|
+
const transferToLine = defineWorker({
|
|
29
|
+
contract: { role: 'router', summary: "Offers a warm transfer to one of the tenant's departments by key; gives its number and hours when it cannot transfer" },
|
|
30
|
+
id: 'transfer-to-line',
|
|
31
|
+
name: 'TransferToLine',
|
|
32
|
+
version: '1.1.0',
|
|
33
|
+
scope: 'isolated',
|
|
34
|
+
description: "Worker: offer to connect the caller with the tenant's department `line` (a key of cargo.transferLines). On a call inside its hours YES sets cargo.transferTo and ends the flows with the connecting line; otherwise, or on NO, its number and hours are given.",
|
|
35
|
+
parameters: [
|
|
36
|
+
{ name: 'line', type: 'string', description: 'The department key (cargo.transferLines)', required: true },
|
|
37
|
+
{ name: 'lead', type: 'string', description: 'Optional sentence said before the offer (English)' },
|
|
38
|
+
{ name: 'lead_es', type: 'string', description: 'Optional sentence said before the offer (Spanish)' },
|
|
39
|
+
{ name: 'confirmed', type: 'boolean', description: 'true when the caller already asked to be connected: no question, the transfer starts' },
|
|
40
|
+
{ name: 'no_closing', type: 'boolean', internal: true, description: 'Internal: true when the calling flow continues the conversation itself, so no closing question is asked.' },
|
|
41
|
+
],
|
|
42
|
+
variables: vars({ noop: false, tl: null, tl_name: '', tl_name_es: '', tl_reach: '', tl_reach_es: '', tl_q: '', tl_q_es: '' }),
|
|
43
|
+
steps: [
|
|
44
|
+
set('tl_line', 'tl', "(cargo.transferLines && typeof line === 'string' && cargo.transferLines[line]) || null"),
|
|
45
|
+
when('tl_unknown', '!tl', say('tl_unknown_say', "{{" + LEAD + "}}Sorry, I can't connect you with that team from here." + ANYTHING_ELSE, "{{" + LEAD_ES + "}}Lo siento, no puedo comunicarle con ese equipo desde aquí." + ANYTHING_ELSE_ES)),
|
|
46
|
+
when('tl_unknown_end', '!tl', end('tl_unknown_done', { outcome: 'unresolved', reason: 'no_transfer_line' })),
|
|
47
|
+
set('tl_name', 'tl_name', "String(tl.name || '')"),
|
|
48
|
+
set('tl_name_es', 'tl_name_es', "String(tl.name_es || tl.name || '')"),
|
|
49
|
+
// how to reach it: the number, then its hours when it has any
|
|
50
|
+
// said only when no transfer happens (closed, not a call, NO); on a call in words (phoneToSpeech)
|
|
51
|
+
set('tl_reach', 'tl_reach', "'You can reach ' + tl_name + (tl.phone ? ' at ' + phoneToSpeech(tl.phone, 'en', !!cargo.voice) : '') + (tl.hours ? ', ' + tl.hours : '') + '.'"),
|
|
52
|
+
set('tl_reach_es', 'tl_reach_es', "'Puede comunicarse con ' + tl_name_es + (tl.phone ? ' al ' + phoneToSpeech(tl.phone, 'es', !!cargo.voice) : '') + (tl.hours_es ? ', ' + tl.hours_es : '') + '.'"),
|
|
53
|
+
// not available now (closed, or not a call): the number and hours
|
|
54
|
+
when('tl_closed_call', "tl.available !== true && cargo.voice", say('tl_closed_call_say', "{{" + LEAD + " + tl_name.charAt(0).toUpperCase() + tl_name.slice(1)}} isn't available right now. {{tl_reach}}" + ANYTHING_ELSE, "{{" + LEAD_ES + " + tl_name_es.charAt(0).toUpperCase() + tl_name_es.slice(1)}} no está disponible en este momento. {{tl_reach_es}}" + ANYTHING_ELSE_ES)),
|
|
55
|
+
when('tl_closed_text', "tl.available !== true && !cargo.voice", say('tl_closed_text_say', "{{" + LEAD + " + tl_reach}}" + ANYTHING_ELSE, "{{" + LEAD_ES + " + tl_reach_es}}" + ANYTHING_ELSE_ES)),
|
|
56
|
+
when('tl_closed_end', 'tl.available !== true', end('tl_closed_done', { outcome: 'resolved', reason: 'transfer_line_number' })),
|
|
57
|
+
// already asked for by the caller: connected without a question
|
|
58
|
+
when('tl_confirmed_mark', "confirmed === true || confirmed === 'true'", effect('tl_confirmed_mark_set', 'cargo.transferTo = line')),
|
|
59
|
+
when('tl_confirmed', "confirmed === true || confirmed === 'true'", {
|
|
60
|
+
id: 'tl_confirmed_connecting', type: 'RETURN',
|
|
61
|
+
value: "language == 'es' ? 'Le comunico con ' + tl_name_es + '.' : 'Connecting you with ' + tl_name + '.'",
|
|
62
|
+
outcome: 'resolved', reason: 'transferred', keepSay: true,
|
|
63
|
+
}),
|
|
64
|
+
// available: asked; the answer is the caller's consent to the transfer
|
|
65
|
+
set('tl_q', 'tl_q', LEAD + " + 'Would you like me to connect you with ' + tl_name + ' now? ' + yesNoKeys('en', cargo)"),
|
|
66
|
+
set('tl_q_es', 'tl_q_es', LEAD_ES + " + '¿Desea que le comunique ahora con ' + tl_name_es + '? ' + yesNoKeys('es', cargo)"),
|
|
67
|
+
call('tl_ask', 'ask-choice', {
|
|
68
|
+
question: '{{tl_q}}',
|
|
69
|
+
question_es: '{{tl_q_es}}',
|
|
70
|
+
choices: [{ key: 'yes', phrases: ['1'] }, { key: 'no', phrases: ['2'] }],
|
|
71
|
+
digits: { min: 1, max: 1 },
|
|
72
|
+
rank: 'insist',
|
|
73
|
+
}),
|
|
74
|
+
when('tl_yes_mark', "cargo.choice === 'yes'", effect('tl_yes_mark_set', 'cargo.transferTo = line')),
|
|
75
|
+
when('tl_yes', "cargo.choice === 'yes'", {
|
|
76
|
+
id: 'tl_connecting', type: 'RETURN',
|
|
77
|
+
value: "language == 'es' ? 'Le comunico con ' + tl_name_es + '.' : 'Connecting you with ' + tl_name + '.'",
|
|
78
|
+
outcome: 'resolved', reason: 'transferred', keepSay: true,
|
|
79
|
+
}),
|
|
80
|
+
say('tl_no_say', "Okay. {{tl_reach}}" + ANYTHING_ELSE, "De acuerdo. {{tl_reach_es}}" + ANYTHING_ELSE_ES),
|
|
81
|
+
end('tl_no_done', { outcome: 'resolved', reason: 'transfer_declined' }),
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
export const FLOWS = [transferToLine];
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -76,6 +76,7 @@ export namespace STANDARD_FUNCTIONS {
|
|
|
76
76
|
export { channelVerb };
|
|
77
77
|
export { dateToWords };
|
|
78
78
|
export { amountToSpeech };
|
|
79
|
+
export { phoneToSpeech };
|
|
79
80
|
export { validateCardNumber };
|
|
80
81
|
export { validateExpiration };
|
|
81
82
|
export { consumeActionReceipt };
|
|
@@ -232,6 +233,7 @@ import { yesNoKeys } from './phrases.js';
|
|
|
232
233
|
import { channelVerb } from './phrases.js';
|
|
233
234
|
import { dateToWords } from './date-words.js';
|
|
234
235
|
import { amountToSpeech } from './amount-to-speech.js';
|
|
236
|
+
import { phoneToSpeech } from './phone-to-speech.js';
|
|
235
237
|
import { validateCardNumber } from './card-checks.js';
|
|
236
238
|
import { validateExpiration } from './card-checks.js';
|
|
237
239
|
import { consumeActionReceipt } from './form-actions.js';
|
|
@@ -315,5 +317,5 @@ import { chatTranscript } from './sendables.js';
|
|
|
315
317
|
import { conversationCopy } from './sendables.js';
|
|
316
318
|
import { CONVERSATION_KEY } from './sendables.js';
|
|
317
319
|
import { WEB_LINK_KEY } from './sendables.js';
|
|
318
|
-
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, keepFormLine, deferFormClarification, takeFormClarification, formClarificationKept, clearFormLines, 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, pickWholeChoice, withoutPromptEcho, isReaderFiller, readEmail, emailWithoutEnding, emailEnding, emailSaid, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational, normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, yesNoKeys, channelVerb, dateToWords, amountToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readArgument, groundAmount, joinSpokenNumbers, findNumbers, assignNumbers, addressDraft, 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, numberAlone, registerSendable, sendables, chatTranscript, conversationCopy, CONVERSATION_KEY, WEB_LINK_KEY };
|
|
320
|
+
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, keepFormLine, deferFormClarification, takeFormClarification, formClarificationKept, clearFormLines, 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, pickWholeChoice, withoutPromptEcho, isReaderFiller, readEmail, emailWithoutEnding, emailEnding, emailSaid, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational, normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, yesNoKeys, channelVerb, dateToWords, amountToSpeech, phoneToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readArgument, groundAmount, joinSpokenNumbers, findNumbers, assignNumbers, addressDraft, 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, numberAlone, registerSendable, sendables, chatTranscript, conversationCopy, CONVERSATION_KEY, WEB_LINK_KEY };
|
|
319
321
|
//# 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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;8BAAhB,gBAAgB;+BACnC,iBAAiB;8BAAjB,iBAAiB;8BAAjB,iBAAiB;4BAI7B,iBAAiB;oCAAjB,iBAAiB;iCAHiB,oBAAoB;iCAApB,oBAAoB;kCAApB,oBAAoB;4BAApB,oBAAoB;iCA9BO,gBAAgB;0BAAhB,gBAAgB;+BAAhB,gBAAgB;iCAAhB,gBAAgB;iCAAhB,gBAAgB;6BAAhB,gBAAgB"}
|
package/dist/helpers/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFo
|
|
|
10
10
|
/**
|
|
11
11
|
* jsfe/helpers — the functions JSFE's system flows call from expressions, in ONE place for every host: reading an
|
|
12
12
|
* answer (matchesChoice, pickChoice, isAnswer, readEmail, readIdentifier, amountInAnswer, matchInputs …), saying
|
|
13
|
-
* values (amountToSpeech, dateToWords, last4, urlToSpeech …), checking shapes and one-time codes. Pure: no credentials,
|
|
13
|
+
* values (amountToSpeech, phoneToSpeech, dateToWords, last4, urlToSpeech …), checking shapes and one-time codes. Pure: no credentials,
|
|
14
14
|
* no network, no host state beyond the container a caller passes in.
|
|
15
15
|
*
|
|
16
16
|
* The engine does not register them by itself. A host lists them among its approved functions, usually all at once:
|
|
@@ -39,7 +39,8 @@ import { joinSpokenDigits, spokenDigitsText, wholeSpokenNumber, numberAlone } fr
|
|
|
39
39
|
import { findNumbers, assignNumbers, joinSpokenNumbers } from './numbers.js';
|
|
40
40
|
import { addressDraft } from './address.js';
|
|
41
41
|
import { urlToSpeech, textWithUrlToSpeech } from './url-speech.js';
|
|
42
|
-
|
|
42
|
+
import { phoneToSpeech } from './phone-to-speech.js';
|
|
43
|
+
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, keepFormLine, deferFormClarification, takeFormClarification, formClarificationKept, clearFormLines, 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, pickWholeChoice, withoutPromptEcho, isReaderFiller, readEmail, emailWithoutEnding, emailEnding, emailSaid, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational, normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, yesNoKeys, channelVerb, dateToWords, amountToSpeech, phoneToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readArgument, groundAmount, joinSpokenNumbers, findNumbers, assignNumbers, addressDraft, 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, numberAlone, registerSendable, sendables, chatTranscript, conversationCopy, CONVERSATION_KEY, WEB_LINK_KEY, };
|
|
43
44
|
/** The functions flows call by name, ready to spread into a host's approved functions. */
|
|
44
45
|
export const STANDARD_FUNCTIONS = {
|
|
45
46
|
continuationSafetyProtocol, cancelFormTask, contextualResponseProtocol, validateFormResponse, hasFormResponse,
|
|
@@ -47,7 +48,7 @@ export const STANDARD_FUNCTIONS = {
|
|
|
47
48
|
clearFormMisses, formNoOwner, missFormInput, formMustComplete, formInputPrompt, formUserDescriptionSource, formConcernLine, formAcknowledges, consumeFormFeedback, keepFormLine, deferFormClarification, takeFormClarification, formClarificationKept, clearFormLines, formConversationOutcome,
|
|
48
49
|
readMoneyAmount, isMoneyAmount, moneyIntentAllows, isPastPaymentStatement, isPartialMoneyAnswer, validateMoneyOptions, takeChoiceOffer, saysConfirmWord, confirmOutOfOrderLine, matchesChoice, isAnswer, isAgentRequest, isExitRequest, isGlobalExit, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice, pickWholeChoice, withoutPromptEcho, isReaderFiller,
|
|
49
50
|
readEmail, emailWithoutEnding, emailEnding, emailSaid, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational,
|
|
50
|
-
normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, yesNoKeys, channelVerb, dateToWords, amountToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readArgument, groundAmount, joinSpokenNumbers, findNumbers, assignNumbers, addressDraft, 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,
|
|
51
|
+
normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, yesNoKeys, channelVerb, dateToWords, amountToSpeech, phoneToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readArgument, groundAmount, joinSpokenNumbers, findNumbers, assignNumbers, addressDraft, 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,
|
|
51
52
|
validateOTP, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech, joinSpokenDigits, wholeSpokenNumber, numberAlone,
|
|
52
53
|
registerSendable, sendables, chatTranscript, conversationCopy,
|
|
53
54
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone-to-speech.d.ts","sourceRoot":"","sources":["../../src/helpers/phone-to-speech.js"],"names":[],"mappings":"AA6BA,mFAYC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A phone number for a reply (owner 2026-11-29: "1-800-440-0544" was hard to follow on a call). On voice, each group in
|
|
3
|
+
* words, groups separated by commas so the speech engine pauses between them: "one, eight hundred, four four zero, zero
|
|
4
|
+
* five four four" / "uno, ochocientos, cuatro cuatro cero, cero cinco cuatro cuatro". A group that is a whole hundred
|
|
5
|
+
* ("800") is said as one ("eight hundred"), as toll-free numbers are said. Written: "1-800-440-0544" for a North American
|
|
6
|
+
* number, otherwise as given. '' when there are no digits. Pure, part of jsfe/helpers.
|
|
7
|
+
*/
|
|
8
|
+
const DIGITS = {
|
|
9
|
+
en: ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'],
|
|
10
|
+
es: ['cero', 'uno', 'dos', 'tres', 'cuatro', 'cinco', 'seis', 'siete', 'ocho', 'nueve'],
|
|
11
|
+
};
|
|
12
|
+
const HUNDREDS = {
|
|
13
|
+
en: (d) => `${DIGITS.en[d]} hundred`,
|
|
14
|
+
es: (d) => ['', 'cien', 'doscientos', 'trescientos', 'cuatrocientos', 'quinientos', 'seiscientos', 'setecientos', 'ochocientos', 'novecientos'][d],
|
|
15
|
+
};
|
|
16
|
+
function phoneGroups(raw) {
|
|
17
|
+
const digits = raw.replace(/\D/g, '');
|
|
18
|
+
if (digits.length === 11 && digits.startsWith('1')) {
|
|
19
|
+
return [digits.slice(0, 1), digits.slice(1, 4), digits.slice(4, 7), digits.slice(7)];
|
|
20
|
+
}
|
|
21
|
+
else if (digits.length === 10 && !raw.trim().startsWith('+')) {
|
|
22
|
+
return [digits.slice(0, 3), digits.slice(3, 6), digits.slice(6)];
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
// as written: its own groups ("+52 55 1234 5678"), else runs of up to four digits
|
|
26
|
+
const written = raw.split(/\D+/).filter(Boolean);
|
|
27
|
+
return written.length > 1 ? written : (digits.match(/\d{1,4}/g) || []);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function phoneToSpeech(phone, language = 'en', voice = true) {
|
|
31
|
+
const raw = String(phone ?? '');
|
|
32
|
+
const groups = phoneGroups(raw);
|
|
33
|
+
if (!groups.length) {
|
|
34
|
+
return '';
|
|
35
|
+
}
|
|
36
|
+
else if (!voice) {
|
|
37
|
+
const digits = raw.replace(/\D/g, '');
|
|
38
|
+
return digits.length === 11 && digits.startsWith('1') ? groups.join('-') : digits.length === 10 && !raw.trim().startsWith('+') ? groups.join('-') : raw.trim();
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const lang = language === 'es' ? 'es' : 'en';
|
|
42
|
+
return groups.map((g) => (/^[1-9]00$/.test(g) ? HUNDREDS[lang](Number(g[0])) : g.split('').map((d) => DIGITS[lang][Number(d)]).join(' '))).join(', ');
|
|
43
|
+
}
|
|
44
|
+
}
|
package/dist/runtime-identity.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const JSFE_RUNTIME_FINGERPRINT = "sha256:
|
|
1
|
+
export const JSFE_RUNTIME_FINGERPRINT = "sha256:c7d31f85c684478382c574b64d935a17e301c7a33a06004df303372f68f6e975";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsfe",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.100.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",
|