jsfe 1.68.0 → 1.69.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 +27 -17
- package/dist/forms/flows.js +5 -5
- package/dist/helpers/expression-sandbox.d.ts +68 -0
- package/dist/helpers/expression-sandbox.d.ts.map +1 -0
- package/dist/helpers/expression-sandbox.js +542 -0
- package/dist/helpers/named-functions.d.ts +7 -4
- package/dist/helpers/named-functions.d.ts.map +1 -1
- package/dist/helpers/named-functions.js +11 -15
- package/dist/host/reply-rank.d.ts +1 -1
- package/dist/host/reply-rank.js +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -9
- package/dist/runtime-identity.js +1 -1
- package/dist/vendor/quickjs.js +3696 -0
- package/docs/architecture-guide.md +36 -10
- package/docs/copilot-reference.md +20 -13
- package/package.json +6 -3
|
@@ -334,7 +334,7 @@ rules should decide.
|
|
|
334
334
|
- A picked choice is applied first, then its arguments. An argument that answers the choice's own exclusive group
|
|
335
335
|
replaces it, being the more specific answer ("other amount" with $100 is the amount $100).
|
|
336
336
|
- Each reading carries `origin: 'rank_argument'` and `argument: '<name>'`, so the input's validator can tell an
|
|
337
|
-
extracted value from a typed one (
|
|
337
|
+
extracted value from a typed one (a tenant's amount check treats an extracted definite amount as an amount, never a
|
|
338
338
|
key or a sub account number).
|
|
339
339
|
|
|
340
340
|
**Writing the descriptions.** The description is the whole instruction to the model, so it states what counts and what
|
|
@@ -365,9 +365,9 @@ it.
|
|
|
365
365
|
**A provider's menu.** `provides.menu.whole_phrases: true` (default off) applies the same rule to a menu: a fact's phrase answers only as the whole reply, and a phrase inside a longer sentence goes to the reply ranker, offered every fact with phrases, every action, `done` and a person. A fact pick is answered with every other fact that cleared `REPLY_ALSO_CUT` (0.6), so one sentence that asks two things hears both; an action pick runs alone. `answers` and `irrelevant` fall to the menu's plain DISPATCH, which hands the turn to the host without intent detection (a Guru answers from the user context the flow set); `new_request` runs intent detection. A reply with no phrase is unchanged. `menu.unanswered` handles a question the provider cannot answer: when a reply from its own menu comes back to it through intent detection with no fact to say, the caller hears the declared apology and offer (`provider-unanswered`) instead of the same facts again.
|
|
366
366
|
|
|
367
367
|
Some options are **never offered**, so the ranker cannot pick them: the YES of a firm confirmation (an input's, or a form's
|
|
368
|
-
confirmation of
|
|
369
|
-
match it, not what it does, so exact choices are offered. A charge or a cancellation is
|
|
370
|
-
on its action. A form confirmation is firm only when it authorizes a payment (effect `charge`), unless the form declares
|
|
368
|
+
confirmation of a payment), a `current_only` choice while another question is asked, and text. `exact` on a choice says how words
|
|
369
|
+
match it, not what it does, so exact choices are offered. A charge or a cancellation is bound by `confirm: {exact: true}`
|
|
370
|
+
on its action: it runs only on the values the caller confirmed (binding, not firmness). A form confirmation is firm only when it authorizes a payment (effect `charge`), unless the form declares
|
|
371
371
|
`confirm.confirmation`: a firm one offers the ranker NO, corrections and a person (a ranker can understand "no thanks,
|
|
372
372
|
maybe later" as NO; it can never produce a YES to a payment). Every other confirmation is soft: its YES is read as a
|
|
373
373
|
soft confirmation's and is offered to the ranker too. Options that cost more when wrong need a higher score (a NO that would cancel what the
|
|
@@ -413,7 +413,7 @@ lives:
|
|
|
413
413
|
| --- | --- |
|
|
414
414
|
| No private fact before identity is verified | a provider's `gate` and a performer's `gate` run the verification worker and check the verified paths |
|
|
415
415
|
| No value accepted unchecked | every value, whether read, extracted at activation or understood by the ranker, passes the same field validator |
|
|
416
|
-
| No charge without a clear YES | `confirm: { exact: true }
|
|
416
|
+
| No charge without a clear YES | a form that charges (`effect: "charge"`, which requires `confirm: { exact: true }`) confirms firmly: only confirmation words or the option's exact phrases; never offered to the ranker |
|
|
417
417
|
| The YES confirms what the caller heard | consent is bound to the request and the input revision; changing any input invalidates it |
|
|
418
418
|
| "Yes, but make it 60" is not consent | an answer with YES plus a correction or another request is not approval of the old request |
|
|
419
419
|
| No guessed success | an executor reports success, failure or unknown; unknown holds the action, it is never retried as if it failed |
|
|
@@ -448,12 +448,36 @@ Cancellation and Concurrency" explains each rule and the production incident beh
|
|
|
448
448
|
and the payment asks its question again.
|
|
449
449
|
- **Menus after an answer.** A provider may offer a short menu ("To make a payment, say PAY. For a payment link, say
|
|
450
450
|
LINK."). Menu choices start their flows; "no thanks" ends politely.
|
|
451
|
-
- **Misses.**
|
|
452
|
-
|
|
451
|
+
- **Misses.** An answer with words that the question cannot read goes to the reply ranker; one that picks nothing is
|
|
452
|
+
asked again and counts against `max_attempts`. An answer without words (symbols, an unexpected key) is acknowledged
|
|
453
|
+
and asked again three times, and the fourth goes to DISPATCH (`max_misses`, default 4). Validator rejections count
|
|
454
|
+
against `max_attempts` (default 3), with a declared recovery (`on_exhausted`). Every question also accepts a request
|
|
453
455
|
for a person.
|
|
454
456
|
|
|
455
457
|
### Endings
|
|
456
458
|
|
|
459
|
+
When the flows end, the turn closes in one of four ways, and each treats the caller's last message differently:
|
|
460
|
+
|
|
461
|
+
| Ending | The caller's last message | What the caller gets |
|
|
462
|
+
|---|---|---|
|
|
463
|
+
| **Completion**: the flow runs its last step, or reaches `END` | used by the flow | what the flow said this turn. If it said nothing on the turn it started, the engine's "Processing …" placeholder; on a later turn, "Flow completed." (`flow_completed_generic`). A flow says its result before it ends. |
|
|
464
|
+
| **`DISPATCH`** | passed on to intent detection, as if no flow had been active | the reply of the flow it starts, or, if none, the host's own answer. Anything the ending flow queued is not said. |
|
|
465
|
+
| **`RETURN` with a value** | kept by the flow: intent detection never sees it | the step's value. Queued text is not said unless the step sets `keepSay: true`. |
|
|
466
|
+
| **`RETURN ''`**: the fake flow | handed to the host, without intent detection running again | the host's own answer |
|
|
467
|
+
|
|
468
|
+
`RETURN` with a value is the one ending that keeps the message from intent detection and still tells the caller
|
|
469
|
+
something.
|
|
470
|
+
|
|
471
|
+
`RETURN ''` exists for the **fake flow**: a primary flow that deliberately does nothing, so that a message resembling
|
|
472
|
+
another flow's trigger is matched by it and answered by the host, instead of wrongly starting the similar flow. Its
|
|
473
|
+
description claims the message ("Not:" lines in the similar flow point here), and its only step is `RETURN ''`. A
|
|
474
|
+
`DISPATCH` cannot do this job: intent detection has just chosen this flow, so the engine refuses to route the same message
|
|
475
|
+
again. For the same reason a `DISPATCH` belongs only after a question.
|
|
476
|
+
|
|
477
|
+
So: completion for a finished task; `DISPATCH`, after a question, for a message that is not the flow's to handle;
|
|
478
|
+
`RETURN` with a value for a message the flow must answer but not pass on; a fake flow with `RETURN ''` for a message
|
|
479
|
+
that must not start a similar flow.
|
|
480
|
+
|
|
457
481
|
A flow ends with an outcome (`resolved`, `unresolved`, `deflected`, or `pending` for a task that was paused), and may
|
|
458
482
|
give the host recovery guidance (`resume`, `restart`, `hold`, `none`). Hosts use these for reporting and for what to
|
|
459
483
|
say when the conversation returns.
|
|
@@ -486,14 +510,14 @@ Caller: Let's do 60 with the card ending in 4242.
|
|
|
486
510
|
One answer fills two fields: the amount (the current question) and the card (an input of the nested card form).
|
|
487
511
|
|
|
488
512
|
```text
|
|
489
|
-
Agent: I'll charge $60.00 to the card ending in 4242.
|
|
513
|
+
Agent: I'll charge $60.00 to the card ending in 4242. Press 1 or say YES to pay, or press 2 or say NO.
|
|
490
514
|
Caller: Yeah, but make it 70.
|
|
491
515
|
```
|
|
492
516
|
Not consent: YES plus a correction. The amount changes, the confirmation is invalidated, and the read-back is asked
|
|
493
517
|
again for $70.00.
|
|
494
518
|
|
|
495
519
|
```text
|
|
496
|
-
Agent: I'll charge $70.00 to the card ending in 4242.
|
|
520
|
+
Agent: I'll charge $70.00 to the card ending in 4242. Press 1 or say YES to pay, or press 2 or say NO.
|
|
497
521
|
Caller: Yes.
|
|
498
522
|
Agent: Your payment of $70.00 was successful. Is there anything else I can help you with?
|
|
499
523
|
Caller: Do you have energy-saving rebates?
|
|
@@ -510,7 +534,9 @@ it from the company's documents.
|
|
|
510
534
|
4. **Flow behavior lives in flows.** Offers, prompts and wording belong to flow steps, not to the host. If a flow cannot
|
|
511
535
|
express something, it is a feature request for the engine.
|
|
512
536
|
5. **Side effects only through `CALL-TOOL`,** with an `onFail` route and a declared answer for an unknown result.
|
|
513
|
-
6. **Sensitive decisions are
|
|
537
|
+
6. **Sensitive decisions are bound.** Any action that charges, cancels or cannot be reversed declares
|
|
538
|
+
`confirm: {exact: true}`: it runs only on the exact values the caller confirmed. How the YES is read is separate: a
|
|
539
|
+
charge is asked as a firm confirmation, everything else softly, unless the form declares `confirm.confirmation`.
|
|
514
540
|
7. **Descriptions are for detection only.** A primary's description says what starts it and what does not; caller
|
|
515
541
|
wording belongs in questions and fact renderers.
|
|
516
542
|
8. **`call` for a closed sub-task, `DISPATCH` for what the caller asked for.** A loop that grows the stack is a design
|
|
@@ -107,15 +107,15 @@ Each step has `type`, a stable `id`, and the applicable fields below. CASE/SWITC
|
|
|
107
107
|
| `CALL-TOOL` | Registered `tool`, `args`, result `variable`, and explicit `onFail`. |
|
|
108
108
|
| `END` | End only this flow; resume its caller after the FLOW call. A root simply finishes. |
|
|
109
109
|
| `RETURN` | End all stacks and return the evaluated `value` to the host. Empty string forwards this turn's original input to host AI/RAG. Queued SAY text is dropped unless `keepSay:true`. |
|
|
110
|
-
| `DISPATCH` | End all stacks, drop undelivered SAY text, and reroute this turn's input through primary intent detection. A match starts in the same turn; otherwise the host handles it with its conversation context. Optional `outcome`, `reason`, `recovery`. Contextual form: `onResponse:"continue"` with `responseContext`, `responseVariable` (a declared object), `responseParameters`, `responseChoices` (a declared array variable of `{key,label?,route?:"new_request",parameters?}`), `responseReasonFor` (a string; not with `responseChoices`) and `onNoIntent:"stay"`. |
|
|
110
|
+
| `DISPATCH` | End all stacks, drop undelivered SAY text, and reroute this turn's input through primary intent detection. A match starts in the same turn; otherwise the host handles it with its conversation context. Optional `outcome`, `reason`, `recovery`. Contextual form: `onResponse:"continue"` with `responseContext`, `responseVariable` (a declared object), `responseParameters`, `responseChoices` (a declared array variable of `{key,label?,route?:"new_request",parameters?}`), `responseReasonFor` (a string; not with `responseChoices`), `responseConcern` (what the process does; offers the ranker `concern`), `responseConcernForm` (a form instance whose chain's `user_description` offers `concern`), `responseStay` (a declared boolean variable: while true, a new request is one more reply that picked nothing) and `onNoIntent:"stay"`. No other key is accepted. |
|
|
111
111
|
|
|
112
112
|
`FLOW.call` runs the child and returns to the next caller step. `FLOW.replace` replaces only the current frame; when the replacement ends, it returns to the original caller. A shared replace preserves existing variables; `initializeDefaults:true` fills declared target defaults only where a value is undefined. Versioned native builders set this explicitly. An isolated target always has its own declared context. `FLOW.reboot` clears all stacks and starts a new execution context with explicit parameters, preserving cargo. Queued SAY text normally travels with the reboot; `discardSay:true` drops it.
|
|
113
113
|
|
|
114
114
|
A `FLOW.replace` with `toParent: true` whose target flow declares `replaceTarget: true` returns to that flow's waiting frame and takes its place, dropping what ran above it. With either missing, or no such frame, it is a local replace. The validator refuses a loop holding a `call` (`stack_growth`) and a loop of replaces with no question in reach (`spin`); a flow on a loop that a runtime limit ends declares `loopBound: "<the limit>"`, and a test drives the loop to that limit. Use `call` for a closed sub-task and `DISPATCH` for anything the caller asked for.
|
|
115
115
|
|
|
116
|
-
A flow trap (a loop of flows with no question in reach, or a stack that grows with each answer)
|
|
116
|
+
A flow trap (a loop of flows with no question in reach, or a stack that grows with each answer) is a load-time validation error: it is listed in `state.errors`, and the engine still starts. Trap edges include form input form, validator, prepare, refresh, after, answer_precheck, answer_validator, on_no, on_declined; proposal prepare and on_declined; gate, source and action flow; parameters validate_flow, code_validator, answer_handler, failed_flow, cell_validator, email_validator, switch_reset (calls), restart (replace), retry_flow with retry_returns:true (replace). Not traps: a flow replacing itself, reboot, DISPATCH, loopBound, any path through a JSFE worker.
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
Every `FLOW.parameters`, `onFail.parameters` and `CALL-TOOL.args` value is interpolated by path only: `{{request.account}}` resolves, an expression resolves to ''. A value that is one whole `{{path}}` passes the value itself (object, array, number); a template mixed with text is a string. Compute expressions in a preceding SET or named worker. Provider `gateParameters` is an authoring convenience that lowers whole-expression templates to SET steps before the call.
|
|
119
119
|
|
|
120
120
|
`digits` on SAY-GET has `min`, `max`, optional `autoSubmitChars`, `autoSubmitMs`, and host-supported completion hints. A one-key answer must be exactly that key, not digits found inside a sentence. Direct `asSpoken:true` (or a condition string) preserves the original voice answer instead of digit reduction/AI cleanup. Use it for meaning-sensitive answers such as amounts; do not disable normal number/email cleanup indiscriminately. `pii:true` (or a condition) marks sensitive input for engine/host logging safeguards. FORM field spelling is `as_spoken`, not `asSpoken`.
|
|
121
121
|
|
|
@@ -167,7 +167,7 @@ Field options:
|
|
|
167
167
|
|
|
168
168
|
| Fields | Meaning |
|
|
169
169
|
| --- | --- |
|
|
170
|
-
| `label`, `label_es`; `question`, `question_es
|
|
170
|
+
| `label`, `label_es`; `question`, `question_es`; `retry`, `retry_es` | Names, first prompt and explicit retry wording. Contextual question templates compile to workers automatically. |
|
|
171
171
|
| `question_text`, `question_text_es`; `retry_text`, `retry_text_es` | Optional written-channel wording, used instead when the conversation is not a call (`cargo.voice` false). |
|
|
172
172
|
| `description` | Public extraction guidance; `response.description`, when used, describes an open answer. |
|
|
173
173
|
| `when` | Map paths to desired scalar values or arrays; siblings use field names, session paths use `cargo.*`, owner data uses `form.*`. Values prefixed `!` exclude that value. |
|
|
@@ -184,7 +184,12 @@ Field options:
|
|
|
184
184
|
| `silent` | An accepted answer is not acknowledged. For an input that hands its value on to another form's input (its `after` flow), whose own acceptance or rejection is what the caller hears. |
|
|
185
185
|
| `response` | `{description}` on a readable leaf; use existing contextual DISPATCH extraction before accepting an open-ended answer. |
|
|
186
186
|
| `proposal` | Optional approval of an inferred field candidate, independent of final action consent. |
|
|
187
|
-
| `max_misses`, `max_attempts`, `on_exhausted` | Bounds for unreadable responses, validator rejections and deliberate branch recovery. |
|
|
187
|
+
| `max_misses`, `max_attempts`, `on_exhausted` | Bounds for unreadable responses (default 4), validator rejections (default 3) and deliberate branch recovery. |
|
|
188
|
+
| `answer_precheck` | Flow called with `{answer}` before the choices are matched; an `answer_key` it sets is the answer's key (an answer that must not be read as a choice, such as a question). |
|
|
189
|
+
| `answer_validator` | Flow called with `{answer}` when an answer picks no choice; an `answer_key` it sets becomes `cargo.choice`, none leaves the answer handled as before. Fail-closed; it ends by completion (a RETURN ends the turn). |
|
|
190
|
+
| `route_keys` | `[{prefix,flow}]`: an answer key starting with `prefix` is handed to that flow, which takes the answer. |
|
|
191
|
+
| `accumulate`, `accumulate_first` | Digit inputs: a number said in groups across turns is kept and joined; short of `digits.min` the next question is "Go on.", and anything that is not digits drops the partial. `accumulate_first` is a regex the first group must match to start one. |
|
|
192
|
+
| `own_identifiers` | `true`: identifier inputs of other forms in the chain are not offered to this input's reader. |
|
|
188
193
|
| `declinable` | `true` on a readable leaf (not a choice, a confirmation or a proposal): the field may be answered "there is none". The whole answer saying so, in English or Spanish (`none`, `no`, `n/a`, `I don't have one`, `no tengo…`, `no hay…`, `ninguno`; never with a digit), stores an explicit `null`: answered, with no value, so the form moves on, while an absent key stays unanswered. The reply ranker is offered `none` at its question, and a read-back with `named_fields` offers it for correction. On a card the field may be left blank. A field that is never asked uses `required_when` instead. |
|
|
189
194
|
|
|
190
195
|
Profiles:
|
|
@@ -242,7 +247,7 @@ Rules, in order:
|
|
|
242
247
|
is asked again.
|
|
243
248
|
4. **A bare number** (no money mark, no word naming a field) is an amount only at a question that is, invites or is
|
|
244
249
|
declared `confirm_against` an amount. A single digit the question offers as a key is that key; one it does not offer reaches the invited amount,
|
|
245
|
-
whose validation decides. The engine holds no amounts, so "only a known amount" is the amount validator's rule:
|
|
250
|
+
whose validation decides. The engine holds no amounts, so "only a known amount" is the amount validator's rule: a retail tenant's
|
|
246
251
|
takes a bare number at the amount question, and at a question that only invites an amount only when it is an amount the
|
|
247
252
|
caller can pay (else it asks for it in dollars). A bare number that does not fit the current question is
|
|
248
253
|
read out of order under rule 3.
|
|
@@ -257,9 +262,9 @@ refused reading is listed with its rule, so hosts can log what was filled out of
|
|
|
257
262
|
|
|
258
263
|
## 6. Validation, reentry and contextual uncertainty
|
|
259
264
|
|
|
260
|
-
A field validator receives `{form,input,value,values,reading}` and writes `cargo.inputCheck={ok:true,value?}` or `{ok:false,message?,message_es?}`. Missing/malformed results fail closed. Activation values and conversational answers use the same validation path. `value` may normalize a valid input; never return success for a refusal to satisfy an effect's prerequisites.
|
|
265
|
+
A field validator receives `{form,input,value,values,reading}` and writes `cargo.inputCheck={ok:true,value?}` or `{ok:false,message?,message_es?,quiet?}`. Missing/malformed results fail closed. Activation values and conversational answers use the same validation path. A rejection counts an attempt (`max_attempts`, default 3). Its message (default "That {label} doesn't look right." / "No pude usar eso como {label}.") is said only in front of the next question a form of the same task asks this turn; a form that gives up, yields, exhausts or leaves by DISPATCH never says it. `quiet:true` says nothing and still counts the attempt. A number read out of order that its validator rejects is ignored: no attempt, no line. `value` may normalize a valid input; never return success for a refusal to satisfy an effect's prerequisites.
|
|
261
266
|
|
|
262
|
-
A whole-form validator writes `cargo.formCheck={ok:true}` or `{ok:false,invalid:[{name,message?,message_es?}],message?,message_es?}`. Only declared fields may be rejected. The shared loop invalidates the affected branch and reasks; it does not discard independent valid fields.
|
|
267
|
+
A whole-form validator writes `cargo.formCheck={ok:true}` or `{ok:false,invalid:[{name,message?,message_es?}],message?,message_es?}`. Only declared fields may be rejected. The shared loop invalidates the affected branch and reasks; it does not discard independent valid fields. The form-level message is said once, in front of the first re-asked question; a per-input `invalid[].message` is shown only on a form card. A fourth invalid verdict exhausts the form (`on_exhausted`, else an optional incomplete outcome, else give-up) with no message.
|
|
263
268
|
|
|
264
269
|
State lives in `cargo.forms[opaqueInstance]`, owned by a root task or `(parent instance,input slot)`. JSFE maintains values, accepted proofs, pending candidates, dependencies, revisions, attempts, children and confirmation. `cargo.formTasks` identifies active root tasks. Internal `form_instance` resumes saved arguments and progress; context services use `parent_form` without a result slot. Do not write accepted values, approval tokens, revision counters or stack snapshots directly. Use business callback outputs and the shared acceptance path.
|
|
265
270
|
|
|
@@ -267,12 +272,14 @@ The loop skips accepted data and asks the first ready missing required field. Co
|
|
|
267
272
|
|
|
268
273
|
### Retry, yield and recovery
|
|
269
274
|
|
|
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
|
|
275
|
+
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 always; YES only for a soft confirmation); after four, the `give-up` worker takes over. Validator failures use a separate `max_attempts` budget (default 3). 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
276
|
|
|
272
277
|
`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
278
|
|
|
274
279
|
**Global keys (jsfe 1.42.0).** A whole answer `*`, EXIT, QUIT or SALIR ends every flow at any question and starts `global-exit` (default: "cancelled at your request" and an offer of more help, thanks when resolved; a tenant overrides it with a flow that `wraps: "global-exit"`). On a call a whole answer `9` starts `switch-to-text` when the caller can be texted. Never write a local handler for these; to give a question its own meaning for one, declare it as a choice (key or phrase): a declared choice takes the answer. CANCEL is not an exit word.
|
|
275
280
|
|
|
281
|
+
**Yes/no keys.** Every yes/no question names 1 for YES and 2 for NO on a call; word it with `yesNoKeys(lang, cargo, yes?, no?)` rather than by hand: voice "Press 1 or say YES to submit it, or press 2 or say NO.", text "Type YES to submit it, or type NO." (Spanish SÍ, "Presione 1 o diga", "escriba"). `channelVerb(lang, cargo, capital?)` gives the verb alone: the host's `cargo.verb` / `cargo.verb_es`, else "say" on a call and "type" elsewhere. On a form confirmation, key 1 confirms and key 2 declines on every channel.
|
|
282
|
+
|
|
276
283
|
`must_complete:true` on a form (inherited by every field of it and of the forms nested in it) or on one field (`false` on a field opts out): an unreadable answer is never yielded to DISPATCH, however long, and neither is a confirmation miss or an unresolved ambiguity — the question is asked again, acknowledged. A worded reply always reaches the reply ranker, offered every choice the chain's reader accepts: a pick is taken, a clear withdrawal ends the flows, and any other verdict (a new request included) stays and says `first_task` / `first_task_es` from the nearest form declaring it, "I understand, first let's enter your new card details." / "Entiendo, primero vamos a ingresar los datos de su tarjeta nueva.", then the field's `retry` or its question. It uses no attempt. Use it where leaving would strand an effect in progress (a payment's card, its billing-ZIP correction). Other exits stay explicit: the form's stop words, `max_attempts` with `on_exhausted`, and whatever the host intercepts before the engine. The form runaway guard counts passes without a caller answer only.
|
|
277
284
|
|
|
278
285
|
`confirm.named_fields: true` lets a caller correct a read-back in their own words: each input of this form that declares `names` and holds a value is offered to the reply ranker, and a pick extracts the new value of every such input, so one reply can change several. `confirm.reply_context` tells the ranker and the extraction what a reply may contain (never spoken); an input's `argument_description` says what its value looks like ("apartment or unit number alone, such as 4 or 12B"). A reply the word readers only partly account for goes to the ranker, so none of it is lost.
|
|
@@ -316,7 +323,7 @@ A fact has unique `key`, `description`, optional `phrases`, and a `path` within
|
|
|
316
323
|
|
|
317
324
|
Supported simple `format` names include `money`, `money_nonzero`, `date`, `date_no_year`, `last4`, `digits`. An object format maps result properties to format names. List format uses `{type:"list",item,item_es?,fields?,join?,join_es?}` with `{items}` / `{count}` in the outer template; optional `say_one` / `say_one_es` handles one item. Templates use `{value}`, named result properties and supplied `{name}` / `{label}`. Bracketed optional segments can provide alternatives separated by `|`.
|
|
318
325
|
|
|
319
|
-
`menu` supports `question`, `question_es`, optional voice variants, and `choices:[{key,phrases,exact?,flow?,set?}]`. `set` applies declared cargo assignments before an action route. `menu.unanswered: {asked:[catch-all keys],choice,question,question_es}` (off by default): a reply from this menu that intent detection sends back to this provider, when the ranker found no fact or `asked` is a listed catch-all, gets that question instead of the facts again; YES runs the named menu choice, NO returns to the menu, anything else is DISPATCHed. `menu.whole_phrases: true` (off by default): a fact's phrase answers only as the whole reply; a phrase inside a longer sentence goes to the reply ranker, offered every fact, action and `done` (each by its `label` or a fact's `description`, else its key and phrases) and a person. A pick is taken, and every other fact the reply clears at 0.6 is answered with it. A reply that picks nothing goes to the host, without intent detection, so the Guru answers from the account in its user context; `new_request` goes to intent detection. A reply with no phrase is a plain DISPATCH, as before. `done` supports `phrases`, `say`, `say_es`. Keep whole-answer terminal phrases such as “no thanks” separate from a neutral “no” that offers further help. Facts take priority; a declared terminal answer must not be shortened into a different action. Test following-turn choices and facts, not just direct `asked` activations.
|
|
326
|
+
`menu` supports `question`, `question_es`, optional voice variants, and `choices:[{key,phrases,exact?,flow?,set?}]`. `set` applies declared cargo assignments before an action route. `menu.unanswered: {asked:[catch-all keys],choice,question,question_es}` (off by default): a reply from this menu that intent detection sends back to this provider, when the ranker found no fact or `asked` is a listed catch-all, gets that question instead of the facts again, followed by `yesNoKeys` (so `question` must not word the keys); YES runs the named menu choice, NO returns to the menu, anything else is DISPATCHed. `menu.whole_phrases: true` (off by default): a fact's phrase answers only as the whole reply; a phrase inside a longer sentence goes to the reply ranker, offered every fact, action and `done` (each by its `label` or a fact's `description`, else its key and phrases) and a person. A pick is taken, and every other fact the reply clears at 0.6 is answered with it. A reply that picks nothing goes to the host, without intent detection, so the Guru answers from the account in its user context; `new_request` goes to intent detection. A reply with no phrase is a plain DISPATCH, as before. `done` supports `phrases`, `say`, `say_es`. Keep whole-answer terminal phrases such as “no thanks” separate from a neutral “no” that offers further help. Facts take priority; a declared terminal answer must not be shortened into a different action. Test following-turn choices and facts, not just direct `asked` activations.
|
|
320
327
|
|
|
321
328
|
The shared `provide-data`, `load-source`, `answer-facts` and provider-menu workers gate, load and answer only the requested facts. Top-level `gateParameters` may pass literal data or whole-expression templates to the gate. Refresh clears old results before loading and records freshness only on success. `no_gate` may avoid rerunning a gate only while all declared verification paths still hold. It cannot grant access. Mid-form provider questions preserve the owner and pending verification instead of stacking repeated authentication tasks.
|
|
322
329
|
|
|
@@ -353,13 +360,13 @@ A Performer requires `form`, nonempty `performs`, `prepare` worker and `present`
|
|
|
353
360
|
| `subject` | Ownership path such as `form.data.account` or `form.data.subject`; bind account/service identity, not an unrelated session flag. |
|
|
354
361
|
| `gate:{flow?,verified:[paths]}` | Execution-time verification; rerun the declared flow before each fresh effect. |
|
|
355
362
|
| `flow`, `tool` | Installed executor worker and/or registered tool identity. |
|
|
356
|
-
| `confirm:{exact:true}` | Required for charge, cancel or `reversible:false
|
|
363
|
+
| `confirm:{exact:true}` | Binding, not firmness. Required for charge, cancel or `reversible:false`, and it requires a real form confirmation question. At execution the action runs only if the recorded confirmation matches the form's current revision, its current values and this action's proposal (request and subject); any change after the YES refuses the action until it is confirmed again. It does not change how the YES is read: that is the form confirmation's `confirmation` (`confirm.confirmation`, see the row on `confirmation` above), which, when not declared, is firm only when an action the form performs has `effect:"charge"` and soft otherwise (a cancellation included). |
|
|
357
364
|
| `outcomes` | Map declared executor statuses to business outcomes, including unknown results. |
|
|
358
365
|
| `retry` | Explicit policies: `after:[knownStatuses]`; unknown retry only for SEND with `unknown:"explicit"` and a new accepted recovery choice. |
|
|
359
366
|
|
|
360
367
|
The prepare worker receives `{form}` and writes `cargo.actionRequest` with the exact request. JSFE selects the applicable action, binds request/subject/current input revision, obtains required confirmation and guards execution. An executor returns its normalized business result through `cargo.operationResult`; transport adapters use `{transport:"ok",value}` or the declared failure path. Native execution must distinguish success, explicit refusal/failure and unknown completion. Do not claim success from a timeout, a missing status or a later balance change.
|
|
361
368
|
|
|
362
|
-
`form.confirm` contains localized `question`, `question_es`, optional additional affirmative `phrases`, `clarifications`, `no_keys`, and `interrupts:[{key,phrases,flow,exact?}]`. The default NO key is `2`; override only for a deliberately declared menu. Clarifications ask for explanation without consenting. Interrupt workers receive `{form,event,text}` and must reenter ordinary validation after corrections. An answer containing YES plus a correction or unrelated request is not approval of the old request.
|
|
369
|
+
`form.confirm` contains localized `question`, `question_es`, an optional `confirmation` (`"firm"` or `"soft"`; absent, firm only when an action has `effect:"charge"`), optional additional affirmative `phrases`, `clarifications`, `no_keys`, and `interrupts:[{key,phrases,flow,exact?}]`. The default NO key is `2`; override only for a deliberately declared menu. Clarifications ask for explanation without consenting. Interrupt workers receive `{form,event,text}` and must reenter ordinary validation after corrections. An answer containing YES plus a correction or unrelated request is not approval of the old request.
|
|
363
370
|
|
|
364
371
|
An input `proposal` separately asks whether an inferred field value is correct. It is legal only on readable leaves, not group/child/bind nodes. Options are static confirmation fields, `prepare`, `origins:["activation","answer"]`, `when`, `unless`. Its prepare worker receives `{form,input,value,values,reading}` and writes `cargo.proposalCheck` to a confirmation descriptor or explicitly null. A validator may instead return `proposal` inside a successful input check. A descriptor supports question(s), `binding`, affirmative `phrases`, NO keys, clarifications, interrupts and `on_declined`. Missing or malformed decisions fail closed. Field approval is bound to owner, revision, value and business binding; validation reruns before acceptance. It never authorizes the final action. NO cannot commit the candidate; yield cannot be treated as NO.
|
|
365
372
|
|
|
@@ -380,7 +387,7 @@ This reduced **composed-registry fragment** illustrates action authoring, not a
|
|
|
380
387
|
"confirm":{"question":"{{cargo.paymentConfirmation.question}}","question_es":"{{cargo.paymentConfirmation.question_es}}"}
|
|
381
388
|
},
|
|
382
389
|
"performs":[{
|
|
383
|
-
"action":"
|
|
390
|
+
"action":"tenant_payment", "effect":"charge", "subject":"form.data.account",
|
|
384
391
|
"gate":{"flow":"get-account","verified":["cargo.otpVerified","cargo.authenticatedAccount"]},
|
|
385
392
|
"flow":"payment-execute", "confirm":{"exact":true},
|
|
386
393
|
"outcomes":{"ok":"resolved","failed":"unresolved","unknown":"unresolved"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsfe",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.69.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",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"docs/development-release.md"
|
|
49
49
|
],
|
|
50
50
|
"scripts": {
|
|
51
|
-
"build": "tsc -p tsconfig.json && node scripts/stamp-runtime.mjs",
|
|
51
|
+
"build": "tsc -p tsconfig.json && node scripts/bundle-quickjs.mjs && node scripts/stamp-runtime.mjs",
|
|
52
52
|
"clean": "rm -rf dist",
|
|
53
53
|
"test": "for t in tests/*.test.mjs; do node \"$t\" || exit 1; done",
|
|
54
54
|
"prepublishOnly": "npm run clean && npm run build",
|
|
@@ -65,9 +65,12 @@
|
|
|
65
65
|
],
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@types/node": "^24.2.1",
|
|
68
|
+
"esbuild": "0.25.12",
|
|
68
69
|
"nodemailer": "^7.0.6",
|
|
69
70
|
"twilio": "^5.8.2",
|
|
70
|
-
"typescript": "^5.9.2"
|
|
71
|
+
"typescript": "^5.9.2",
|
|
72
|
+
"@jitl/quickjs-singlefile-mjs-release-sync": "0.32.0",
|
|
73
|
+
"quickjs-emscripten-core": "0.32.0"
|
|
71
74
|
},
|
|
72
75
|
"dependencies": {
|
|
73
76
|
"ajv": "^8.17.1",
|