@voctiv/agent-runtime 0.2.2 → 0.4.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 +45 -20
- package/dist/barge-in/barge-in-module.d.ts +0 -1
- package/dist/barge-in/barge-in-module.js +0 -1
- package/dist/barge-in/barge-in-service.d.ts +1 -1
- package/dist/barge-in/barge-in-service.js +33 -2
- package/dist/barge-in/barge-in-strategy.d.ts +11 -9
- package/dist/barge-in/barge-in-strategy.js +39 -23
- package/dist/barge-in/echo-cancellation.d.ts +0 -1
- package/dist/barge-in/echo-cancellation.js +0 -1
- package/dist/barge-in/echo.d.ts +0 -1
- package/dist/barge-in/echo.js +0 -1
- package/dist/barge-in/lexicon.d.ts +0 -1
- package/dist/barge-in/lexicon.js +0 -1
- package/dist/barge-in/speech-ledger.d.ts +0 -2
- package/dist/barge-in/speech-ledger.js +3 -4
- package/dist/barge-in/word-classifier.d.ts +0 -1
- package/dist/barge-in/word-classifier.js +0 -1
- package/dist/call/asr-usage.d.ts +53 -0
- package/dist/call/asr-usage.js +42 -0
- package/dist/call/async.d.ts +2 -0
- package/dist/call/async.js +14 -0
- package/dist/call/env.d.ts +88 -0
- package/dist/call/env.js +294 -0
- package/dist/call/extraction/core.d.ts +99 -0
- package/dist/call/extraction/core.js +259 -0
- package/dist/call/extraction/defaults.d.ts +10 -0
- package/dist/call/extraction/defaults.js +25 -0
- package/dist/call/extraction/index.d.ts +7 -0
- package/dist/call/extraction/index.js +24 -0
- package/dist/call/extraction/orchestrator.d.ts +144 -0
- package/dist/call/extraction/orchestrator.js +309 -0
- package/dist/call/failed-leg.d.ts +43 -0
- package/dist/call/failed-leg.js +77 -0
- package/dist/call/http.d.ts +94 -0
- package/dist/call/http.js +145 -0
- package/dist/call/ledger.d.ts +18 -0
- package/dist/call/ledger.js +80 -0
- package/dist/call/llm-tap.d.ts +7 -0
- package/dist/call/llm-tap.js +41 -0
- package/dist/call/logging.d.ts +16 -0
- package/dist/call/logging.js +92 -0
- package/dist/call/outbound.d.ts +144 -0
- package/dist/call/outbound.js +404 -0
- package/dist/call/output.d.ts +108 -0
- package/dist/call/output.js +77 -0
- package/dist/call/plan.d.ts +119 -0
- package/dist/call/plan.js +2 -0
- package/dist/call/recall.d.ts +115 -0
- package/dist/call/recall.js +312 -0
- package/dist/call/records.d.ts +9 -0
- package/dist/call/records.js +71 -0
- package/dist/call/report.d.ts +65 -0
- package/dist/call/report.js +263 -0
- package/dist/call/sanitize.d.ts +16 -0
- package/dist/call/sanitize.js +72 -0
- package/dist/call/sip.d.ts +111 -0
- package/dist/call/sip.js +212 -0
- package/dist/call/voicemail.d.ts +159 -0
- package/dist/call/voicemail.js +246 -0
- package/dist/core/call-disposables.d.ts +2 -2
- package/dist/core/call-disposables.js +8 -3
- package/dist/core/call-ended-budget.d.ts +11 -0
- package/dist/core/call-ended-budget.js +31 -0
- package/dist/core/container.d.ts +1 -3
- package/dist/core/container.js +9 -49
- package/dist/core/create-agent-script.d.ts +6 -1
- package/dist/core/create-agent-script.js +161 -28
- package/dist/core/decorators.d.ts +0 -1
- package/dist/core/decorators.js +0 -1
- package/dist/core/define-module.d.ts +0 -1
- package/dist/core/define-module.js +0 -1
- package/dist/core/dump-policy.d.ts +0 -1
- package/dist/core/dump-policy.js +0 -1
- package/dist/core/hooks.d.ts +15 -4
- package/dist/core/hooks.js +0 -1
- package/dist/core/media-bootstrap.d.ts +19 -4
- package/dist/core/media-bootstrap.js +53 -13
- package/dist/core/open-timeout.d.ts +12 -0
- package/dist/core/open-timeout.js +48 -0
- package/dist/core/provide-media.d.ts +0 -8
- package/dist/core/provide-media.js +1 -22
- package/dist/core/runtime-events.d.ts +28 -0
- package/dist/{llm/llm-module.js → core/runtime-events.js} +19 -16
- package/dist/core/tokens.d.ts +0 -10
- package/dist/core/tokens.js +0 -1
- package/dist/core/types.d.ts +0 -1
- package/dist/core/types.js +0 -1
- package/dist/core/version.d.ts +2 -3
- package/dist/core/version.js +2 -3
- package/dist/dialog/dialog-definition.d.ts +0 -5
- package/dist/dialog/dialog-definition.js +1 -6
- package/dist/dialog/dialog-ports.d.ts +3 -1
- package/dist/dialog/dialog-ports.js +10 -2
- package/dist/dialog/online-call-host.d.ts +26 -4
- package/dist/dialog/online-call-host.js +94 -12
- package/dist/dialog/online-call-module.d.ts +5 -11
- package/dist/dialog/online-call-module.js +4 -36
- package/dist/dialog/turn-metrics.d.ts +46 -0
- package/dist/dialog/turn-metrics.js +141 -0
- package/dist/dialog-events/active-media.d.ts +50 -2
- package/dist/dialog-events/active-media.js +146 -34
- package/dist/dialog-events/event-source.d.ts +0 -1
- package/dist/dialog-events/event-source.js +0 -1
- package/dist/dialog-events/virtual-finals-module.d.ts +0 -1
- package/dist/dialog-events/virtual-finals-module.js +0 -1
- package/dist/dialog-events/virtual-finals.d.ts +2 -1
- package/dist/dialog-events/virtual-finals.js +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.js +8 -26
- package/dist/lifecycle/lifecycle.d.ts +25 -3
- package/dist/lifecycle/lifecycle.js +92 -14
- package/dist/result/result-store.d.ts +0 -1
- package/dist/result/result-store.js +0 -1
- package/dist/templates/authoring.d.ts +222 -0
- package/dist/templates/authoring.js +2 -0
- package/dist/templates/builder/agent.d.ts +34 -0
- package/dist/templates/builder/agent.js +87 -0
- package/dist/templates/builder/blocks.d.ts +54 -0
- package/dist/templates/builder/blocks.js +92 -0
- package/dist/templates/builder/data-check.d.ts +2 -0
- package/dist/templates/builder/data-check.js +61 -0
- package/dist/templates/builder/draft.d.ts +73 -0
- package/dist/templates/builder/draft.js +142 -0
- package/dist/templates/builder/index.d.ts +8 -0
- package/dist/templates/builder/index.js +55 -0
- package/dist/templates/builder/presets.d.ts +34 -0
- package/dist/templates/builder/presets.js +45 -0
- package/dist/templates/builder/spec-of.d.ts +13 -0
- package/dist/templates/builder/spec-of.js +18 -0
- package/dist/templates/builder/steps.d.ts +25 -0
- package/dist/templates/builder/steps.js +27 -0
- package/dist/templates/business/adapter.d.ts +12 -0
- package/dist/templates/business/adapter.js +980 -0
- package/dist/templates/business/agent-integrations.d.ts +24 -0
- package/dist/templates/business/agent-integrations.js +233 -0
- package/dist/templates/business/extraction-rules-transcript.d.ts +158 -0
- package/dist/templates/business/extraction-rules-transcript.js +405 -0
- package/dist/templates/business/extraction-rules.d.ts +107 -0
- package/dist/templates/business/extraction-rules.js +267 -0
- package/dist/templates/business/index.d.ts +6 -0
- package/dist/{result → templates/business}/index.js +8 -2
- package/dist/templates/business/input.d.ts +56 -0
- package/dist/templates/business/input.js +299 -0
- package/dist/templates/business/integration-data.d.ts +87 -0
- package/dist/templates/business/integration-data.js +312 -0
- package/dist/templates/business/integrations.d.ts +76 -0
- package/dist/templates/business/integrations.js +535 -0
- package/dist/templates/business/legs-policy.d.ts +43 -0
- package/dist/templates/business/legs-policy.js +268 -0
- package/dist/templates/business/report-label.d.ts +7 -0
- package/dist/templates/business/report-label.js +29 -0
- package/dist/templates/business/report.d.ts +67 -0
- package/dist/templates/business/report.js +284 -0
- package/dist/templates/business/result-catalog.d.ts +142 -0
- package/dist/templates/business/result-catalog.js +208 -0
- package/dist/templates/business/result-rules.d.ts +105 -0
- package/dist/templates/business/result-rules.js +167 -0
- package/dist/templates/business/results.d.ts +73 -0
- package/dist/templates/business/results.js +183 -0
- package/dist/templates/business/rule-env.d.ts +18 -0
- package/dist/templates/business/rule-env.js +38 -0
- package/dist/templates/business/sources.d.ts +76 -0
- package/dist/templates/business/sources.js +239 -0
- package/dist/templates/business/test-presets.d.ts +10 -0
- package/dist/templates/business/test-presets.js +68 -0
- package/dist/templates/catalog-match/block.d.ts +32 -0
- package/dist/templates/catalog-match/block.js +95 -0
- package/dist/templates/catalog-match/catalog.d.ts +77 -0
- package/dist/templates/catalog-match/catalog.js +222 -0
- package/dist/templates/catalog-match/recognizer.d.ts +44 -0
- package/dist/templates/catalog-match/recognizer.js +206 -0
- package/dist/templates/catalog-match/reconcile.d.ts +4 -0
- package/dist/templates/catalog-match/reconcile.js +39 -0
- package/dist/templates/catalog-match/request.d.ts +57 -0
- package/dist/templates/catalog-match/request.js +139 -0
- package/dist/templates/catalog-match/types.d.ts +197 -0
- package/dist/templates/catalog-match/types.js +2 -0
- package/dist/templates/catalog-match/verify.d.ts +76 -0
- package/dist/templates/catalog-match/verify.js +220 -0
- package/dist/templates/decision-model/index.d.ts +52 -0
- package/dist/templates/decision-model/index.js +68 -0
- package/dist/templates/engine/asr-picks.d.ts +11 -0
- package/dist/templates/engine/asr-picks.js +44 -0
- package/dist/templates/engine/call.d.ts +104 -0
- package/dist/templates/engine/call.js +322 -0
- package/dist/templates/engine/config.d.ts +447 -0
- package/dist/templates/engine/config.js +493 -0
- package/dist/templates/engine/define.d.ts +1 -0
- package/dist/templates/engine/define.js +9 -0
- package/dist/templates/engine/dialog.d.ts +253 -0
- package/dist/templates/engine/dialog.js +167 -0
- package/dist/templates/engine/echo-numbers.d.ts +7 -0
- package/dist/templates/engine/echo-numbers.js +19 -0
- package/dist/templates/engine/expand.d.ts +6 -0
- package/dist/templates/engine/expand.js +125 -0
- package/dist/templates/engine/filters.d.ts +81 -0
- package/dist/templates/engine/filters.js +654 -0
- package/dist/templates/engine/hook-state.d.ts +18 -0
- package/dist/templates/engine/hook-state.js +100 -0
- package/dist/templates/engine/hooks.d.ts +51 -0
- package/dist/templates/engine/hooks.js +310 -0
- package/dist/templates/engine/index.d.ts +13 -0
- package/dist/templates/engine/index.js +30 -0
- package/dist/templates/engine/language-vars.d.ts +6 -0
- package/dist/templates/engine/language-vars.js +40 -0
- package/dist/templates/engine/language.d.ts +32 -0
- package/dist/templates/engine/language.js +155 -0
- package/dist/templates/engine/lookup.d.ts +20 -0
- package/dist/templates/engine/lookup.js +52 -0
- package/dist/templates/engine/match.d.ts +48 -0
- package/dist/templates/engine/match.js +253 -0
- package/dist/templates/engine/media.d.ts +428 -0
- package/dist/templates/engine/media.js +1240 -0
- package/dist/templates/engine/script.d.ts +11 -0
- package/dist/templates/engine/script.js +69 -0
- package/dist/templates/engine/turns/actions.d.ts +5 -0
- package/dist/templates/engine/turns/actions.js +128 -0
- package/dist/templates/engine/turns/carry.d.ts +15 -0
- package/dist/templates/engine/turns/carry.js +74 -0
- package/dist/templates/engine/turns/choices-offers.d.ts +21 -0
- package/dist/templates/engine/turns/choices-offers.js +143 -0
- package/dist/templates/engine/turns/choices.d.ts +22 -0
- package/dist/templates/engine/turns/choices.js +141 -0
- package/dist/templates/engine/turns/closing-guard.d.ts +73 -0
- package/dist/templates/engine/turns/closing-guard.js +162 -0
- package/dist/templates/engine/turns/closing.d.ts +10 -0
- package/dist/templates/engine/turns/closing.js +82 -0
- package/dist/templates/engine/turns/compile-forms.d.ts +24 -0
- package/dist/templates/engine/turns/compile-forms.js +68 -0
- package/dist/templates/engine/turns/context.d.ts +96 -0
- package/dist/templates/engine/turns/context.js +158 -0
- package/dist/templates/engine/turns/events.d.ts +409 -0
- package/dist/templates/engine/turns/events.js +5 -0
- package/dist/templates/engine/turns/hook-forms.d.ts +62 -0
- package/dist/templates/engine/turns/hook-forms.js +79 -0
- package/dist/templates/engine/turns/ladders.d.ts +42 -0
- package/dist/templates/engine/turns/ladders.js +119 -0
- package/dist/templates/engine/turns/language.d.ts +8 -0
- package/dist/templates/engine/turns/language.js +121 -0
- package/dist/templates/engine/turns/notes-dates.d.ts +9 -0
- package/dist/templates/engine/turns/notes-dates.js +42 -0
- package/dist/templates/engine/turns/notes-detect.d.ts +13 -0
- package/dist/templates/engine/turns/notes-detect.js +36 -0
- package/dist/templates/engine/turns/notes.d.ts +27 -0
- package/dist/templates/engine/turns/notes.js +176 -0
- package/dist/templates/engine/turns/opening.d.ts +34 -0
- package/dist/templates/engine/turns/opening.js +306 -0
- package/dist/templates/engine/turns/overtalk.d.ts +21 -0
- package/dist/templates/engine/turns/overtalk.js +247 -0
- package/dist/templates/engine/turns/pending.d.ts +9 -0
- package/dist/templates/engine/turns/pending.js +88 -0
- package/dist/templates/engine/turns/reply-rules.d.ts +184 -0
- package/dist/templates/engine/turns/reply-rules.js +335 -0
- package/dist/templates/engine/turns/rules.d.ts +20 -0
- package/dist/templates/engine/turns/rules.js +144 -0
- package/dist/templates/engine/turns/silence.d.ts +7 -0
- package/dist/templates/engine/turns/silence.js +127 -0
- package/dist/templates/engine/turns/state-spec.d.ts +305 -0
- package/dist/templates/engine/turns/state-spec.js +2 -0
- package/dist/templates/engine/turns/state.d.ts +38 -0
- package/dist/templates/engine/turns/state.js +101 -0
- package/dist/templates/engine/turns/tracking.d.ts +50 -0
- package/dist/templates/engine/turns/tracking.js +184 -0
- package/dist/templates/engine/turns/transfer.d.ts +19 -0
- package/dist/templates/engine/turns/transfer.js +93 -0
- package/dist/templates/engine/turns/turn.d.ts +17 -0
- package/dist/templates/engine/turns/turn.js +363 -0
- package/dist/templates/engine/turns/voicemail.d.ts +8 -0
- package/dist/templates/engine/turns/voicemail.js +101 -0
- package/dist/templates/engine/variants.d.ts +36 -0
- package/dist/templates/engine/variants.js +159 -0
- package/dist/templates/engine/voice-dialog.d.ts +24 -0
- package/dist/templates/engine/voice-dialog.js +157 -0
- package/dist/templates/engine/voice.d.ts +174 -0
- package/dist/templates/engine/voice.js +1337 -0
- package/dist/templates/expr/caller-after.d.ts +20 -0
- package/dist/templates/expr/caller-after.js +53 -0
- package/dist/templates/expr/check.d.ts +19 -0
- package/dist/templates/expr/check.js +314 -0
- package/dist/templates/expr/compiled.d.ts +8 -0
- package/dist/templates/expr/compiled.js +8 -0
- package/dist/templates/expr/context.d.ts +28 -0
- package/dist/templates/expr/context.js +55 -0
- package/dist/templates/expr/day-table.d.ts +4 -0
- package/dist/templates/expr/day-table.js +80 -0
- package/dist/templates/expr/evaluate.d.ts +26 -0
- package/dist/templates/expr/evaluate.js +885 -0
- package/dist/templates/expr/facts.d.ts +7 -0
- package/dist/templates/expr/facts.js +81 -0
- package/dist/templates/expr/index.d.ts +4 -0
- package/dist/templates/expr/index.js +11 -0
- package/dist/templates/expr/line-tally.d.ts +64 -0
- package/dist/templates/expr/line-tally.js +88 -0
- package/dist/templates/expr/matchers-state.d.ts +23 -0
- package/dist/templates/expr/matchers-state.js +37 -0
- package/dist/templates/expr/matchers.d.ts +12 -0
- package/dist/templates/expr/matchers.js +99 -0
- package/dist/templates/expr/readers.d.ts +14 -0
- package/dist/templates/expr/readers.js +351 -0
- package/dist/templates/expr/slots.d.ts +14 -0
- package/dist/templates/expr/slots.js +678 -0
- package/dist/templates/expr/template.d.ts +12 -0
- package/dist/templates/expr/template.js +76 -0
- package/dist/templates/expr/test-call.d.ts +8 -0
- package/dist/templates/expr/test-call.js +32 -0
- package/dist/templates/expr/transcript.d.ts +36 -0
- package/dist/templates/expr/transcript.js +394 -0
- package/dist/templates/expr/types.d.ts +1011 -0
- package/dist/templates/expr/types.js +2 -0
- package/dist/templates/expr/values.d.ts +42 -0
- package/dist/templates/expr/values.js +166 -0
- package/dist/templates/expr/voice-ops.d.ts +26 -0
- package/dist/templates/expr/voice-ops.js +85 -0
- package/dist/templates/helpers/decision.d.ts +55 -0
- package/dist/templates/helpers/decision.js +83 -0
- package/dist/templates/helpers/fuzzy.d.ts +9 -0
- package/dist/templates/helpers/fuzzy.js +44 -0
- package/dist/templates/helpers/index.d.ts +6 -0
- package/dist/templates/helpers/index.js +35 -0
- package/dist/templates/index.d.ts +9 -0
- package/dist/templates/index.js +68 -0
- package/dist/templates/integration-forms.d.ts +252 -0
- package/dist/templates/integration-forms.js +2 -0
- package/dist/templates/knowledge/block.d.ts +44 -0
- package/dist/templates/knowledge/block.js +199 -0
- package/dist/templates/knowledge/dense.d.ts +87 -0
- package/dist/templates/knowledge/dense.js +158 -0
- package/dist/templates/knowledge/flow.d.ts +328 -0
- package/dist/templates/knowledge/flow.js +509 -0
- package/dist/templates/knowledge/retriever.d.ts +75 -0
- package/dist/templates/knowledge/retriever.js +204 -0
- package/dist/templates/knowledge/service.d.ts +77 -0
- package/dist/templates/knowledge/service.js +316 -0
- package/dist/templates/knowledge/text.d.ts +31 -0
- package/dist/templates/knowledge/text.js +66 -0
- package/dist/templates/knowledge/types.d.ts +120 -0
- package/dist/templates/knowledge/types.js +2 -0
- package/dist/templates/locale.d.ts +259 -0
- package/dist/templates/locale.js +4 -0
- package/dist/templates/locales/en-lexicons.d.ts +9 -0
- package/dist/templates/locales/en-lexicons.js +101 -0
- package/dist/templates/locales/en.d.ts +132 -0
- package/dist/templates/locales/en.js +261 -0
- package/dist/templates/locales/es.d.ts +65 -0
- package/dist/templates/locales/es.js +208 -0
- package/dist/templates/locales/hi.d.ts +47 -0
- package/dist/templates/locales/hi.js +235 -0
- package/dist/templates/locales/id.d.ts +43 -0
- package/dist/templates/locales/id.js +127 -0
- package/dist/templates/locales/index.d.ts +34 -0
- package/dist/templates/locales/index.js +112 -0
- package/dist/templates/locales/kk-lexicons.d.ts +22 -0
- package/dist/templates/locales/kk-lexicons.js +89 -0
- package/dist/templates/locales/kk.d.ts +140 -0
- package/dist/templates/locales/kk.js +306 -0
- package/dist/templates/locales/kn.d.ts +29 -0
- package/dist/templates/locales/kn.js +22 -0
- package/dist/templates/locales/listen-only.d.ts +15 -0
- package/dist/templates/locales/listen-only.js +27 -0
- package/dist/templates/locales/ms-lexicons.d.ts +13 -0
- package/dist/templates/locales/ms-lexicons.js +113 -0
- package/dist/templates/locales/ms.d.ts +76 -0
- package/dist/templates/locales/ms.js +179 -0
- package/dist/templates/locales/parse.d.ts +86 -0
- package/dist/templates/locales/parse.js +461 -0
- package/dist/templates/locales/ru-lexicons.d.ts +27 -0
- package/dist/templates/locales/ru-lexicons.js +127 -0
- package/dist/templates/locales/ru-stem.d.ts +2 -0
- package/dist/templates/locales/ru-stem.js +53 -0
- package/dist/templates/locales/ru.d.ts +143 -0
- package/dist/templates/locales/ru.js +387 -0
- package/dist/templates/locales/shared.d.ts +122 -0
- package/dist/templates/locales/shared.js +318 -0
- package/dist/templates/locales/ta.d.ts +29 -0
- package/dist/templates/locales/ta.js +22 -0
- package/dist/templates/locales/te.d.ts +29 -0
- package/dist/templates/locales/te.js +22 -0
- package/dist/templates/locales/tl-lexicons.d.ts +2 -0
- package/dist/templates/locales/tl-lexicons.js +230 -0
- package/dist/templates/locales/tl.d.ts +59 -0
- package/dist/templates/locales/tl.js +82 -0
- package/dist/templates/locales/vi.d.ts +59 -0
- package/dist/templates/locales/vi.js +160 -0
- package/dist/templates/locales/word-regex.d.ts +13 -0
- package/dist/templates/locales/word-regex.js +43 -0
- package/dist/templates/locales/words-kk.d.ts +2 -0
- package/dist/templates/locales/words-kk.js +23 -0
- package/dist/templates/locales/words-ru.d.ts +4 -0
- package/dist/templates/locales/words-ru.js +92 -0
- package/dist/templates/spec.d.ts +2856 -0
- package/dist/templates/spec.js +2 -0
- package/dist/testing/fake-channel.d.ts +0 -1
- package/dist/testing/fake-channel.js +0 -1
- package/dist/testing/index.d.ts +24 -1
- package/dist/testing/index.js +117 -2
- package/dist/voice/call-voice.d.ts +581 -0
- package/dist/voice/call-voice.js +1399 -0
- package/dist/voice/intent-interrupt.d.ts +32 -0
- package/dist/voice/intent-interrupt.js +91 -0
- package/dist/voice/self-echo.d.ts +28 -0
- package/dist/voice/self-echo.js +135 -0
- package/dist/voice/sentence-tag.d.ts +5 -0
- package/dist/voice/sentence-tag.js +42 -0
- package/dist/voice/speech-leak.d.ts +74 -0
- package/dist/voice/speech-leak.js +216 -0
- package/dist/voice/transfer.d.ts +90 -0
- package/dist/voice/transfer.js +331 -0
- package/dist/voice/turn-timing.d.ts +293 -0
- package/dist/voice/turn-timing.js +567 -0
- package/docs/README.md +3 -6
- package/docs/framework/README.md +6 -10
- package/docs/framework/architecture.md +2 -2
- package/docs/framework/container-and-di.md +1 -2
- package/docs/framework/invariants.md +6 -6
- package/docs/framework/package-layout.md +16 -23
- package/docs/framework/testing.md +8 -6
- package/package.json +10 -54
- package/skill/SKILL.md +213 -0
- package/skill/references/agent-file.md +230 -0
- package/skill/references/blocks.md +246 -0
- package/skill/references/builder.md +163 -0
- package/skill/references/business.md +659 -0
- package/skill/references/conversation.md +586 -0
- package/skill/references/core.md +89 -0
- package/skill/references/examples.md +73 -0
- package/skill/references/expressions.md +342 -0
- package/skill/references/format.md +114 -0
- package/skill/references/locales.md +149 -0
- package/skill/references/migration.md +133 -0
- package/skill/references/new-agent.md +81 -0
- package/skill/references/porting.md +109 -0
- package/templates/agent/README.md +50 -0
- package/templates/agent/package.json +24 -0
- package/templates/agent/src/agent.spec.ts +51 -0
- package/templates/agent/src/agent.ts +268 -0
- package/templates/agent/src/entities.ts +44 -0
- package/templates/agent/src/prompt.sqrl +21 -0
- package/templates/agent/src/variants/fixed-opening.ts +144 -0
- package/templates/agent/tsconfig.build.json +4 -0
- package/templates/agent/tsconfig.json +18 -0
- package/dist/asr/index.d.ts +0 -3
- package/dist/asr/index.d.ts.map +0 -1
- package/dist/asr/index.js +0 -6
- package/dist/asr/index.js.map +0 -1
- package/dist/barge-in/barge-in-module.d.ts.map +0 -1
- package/dist/barge-in/barge-in-module.js.map +0 -1
- package/dist/barge-in/barge-in-service.d.ts.map +0 -1
- package/dist/barge-in/barge-in-service.js.map +0 -1
- package/dist/barge-in/barge-in-strategy.d.ts.map +0 -1
- package/dist/barge-in/barge-in-strategy.js.map +0 -1
- package/dist/barge-in/echo-cancellation.d.ts.map +0 -1
- package/dist/barge-in/echo-cancellation.js.map +0 -1
- package/dist/barge-in/echo.d.ts.map +0 -1
- package/dist/barge-in/echo.js.map +0 -1
- package/dist/barge-in/index.d.ts +0 -13
- package/dist/barge-in/index.d.ts.map +0 -1
- package/dist/barge-in/index.js +0 -28
- package/dist/barge-in/index.js.map +0 -1
- package/dist/barge-in/lexicon.d.ts.map +0 -1
- package/dist/barge-in/lexicon.js.map +0 -1
- package/dist/barge-in/lexicons/en.d.ts +0 -2
- package/dist/barge-in/lexicons/en.d.ts.map +0 -1
- package/dist/barge-in/lexicons/en.js +0 -36
- package/dist/barge-in/lexicons/en.js.map +0 -1
- package/dist/barge-in/lexicons/id.d.ts +0 -2
- package/dist/barge-in/lexicons/id.d.ts.map +0 -1
- package/dist/barge-in/lexicons/id.js +0 -39
- package/dist/barge-in/lexicons/id.js.map +0 -1
- package/dist/barge-in/lexicons/index.d.ts +0 -10
- package/dist/barge-in/lexicons/index.d.ts.map +0 -1
- package/dist/barge-in/lexicons/index.js +0 -11
- package/dist/barge-in/lexicons/index.js.map +0 -1
- package/dist/barge-in/lexicons/ru.d.ts +0 -2
- package/dist/barge-in/lexicons/ru.d.ts.map +0 -1
- package/dist/barge-in/lexicons/ru.js +0 -39
- package/dist/barge-in/lexicons/ru.js.map +0 -1
- package/dist/barge-in/speech-ledger.d.ts.map +0 -1
- package/dist/barge-in/speech-ledger.js.map +0 -1
- package/dist/barge-in/word-classifier.d.ts.map +0 -1
- package/dist/barge-in/word-classifier.js.map +0 -1
- package/dist/bridge/bridge.d.ts +0 -28
- package/dist/bridge/bridge.d.ts.map +0 -1
- package/dist/bridge/bridge.js +0 -117
- package/dist/bridge/bridge.js.map +0 -1
- package/dist/bridge/index.d.ts +0 -3
- package/dist/bridge/index.d.ts.map +0 -1
- package/dist/bridge/index.js +0 -8
- package/dist/bridge/index.js.map +0 -1
- package/dist/core/call-disposables.d.ts.map +0 -1
- package/dist/core/call-disposables.js.map +0 -1
- package/dist/core/container.d.ts.map +0 -1
- package/dist/core/container.js.map +0 -1
- package/dist/core/create-agent-script.d.ts.map +0 -1
- package/dist/core/create-agent-script.js.map +0 -1
- package/dist/core/decorators.d.ts.map +0 -1
- package/dist/core/decorators.js.map +0 -1
- package/dist/core/define-module.d.ts.map +0 -1
- package/dist/core/define-module.js.map +0 -1
- package/dist/core/dump-policy.d.ts.map +0 -1
- package/dist/core/dump-policy.js.map +0 -1
- package/dist/core/hooks.d.ts.map +0 -1
- package/dist/core/hooks.js.map +0 -1
- package/dist/core/index.d.ts +0 -16
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -36
- package/dist/core/index.js.map +0 -1
- package/dist/core/media-bootstrap.d.ts.map +0 -1
- package/dist/core/media-bootstrap.js.map +0 -1
- package/dist/core/provide-media.d.ts.map +0 -1
- package/dist/core/provide-media.js.map +0 -1
- package/dist/core/tokens.d.ts.map +0 -1
- package/dist/core/tokens.js.map +0 -1
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/types.js.map +0 -1
- package/dist/core/version.d.ts.map +0 -1
- package/dist/core/version.js.map +0 -1
- package/dist/dialog/basic-ports.d.ts +0 -54
- package/dist/dialog/basic-ports.d.ts.map +0 -1
- package/dist/dialog/basic-ports.js +0 -206
- package/dist/dialog/basic-ports.js.map +0 -1
- package/dist/dialog/define-dialog.d.ts +0 -21
- package/dist/dialog/define-dialog.d.ts.map +0 -1
- package/dist/dialog/define-dialog.js +0 -21
- package/dist/dialog/define-dialog.js.map +0 -1
- package/dist/dialog/dialog-definition.d.ts.map +0 -1
- package/dist/dialog/dialog-definition.js.map +0 -1
- package/dist/dialog/dialog-ports.d.ts.map +0 -1
- package/dist/dialog/dialog-ports.js.map +0 -1
- package/dist/dialog/index.d.ts +0 -7
- package/dist/dialog/index.d.ts.map +0 -1
- package/dist/dialog/index.js +0 -23
- package/dist/dialog/index.js.map +0 -1
- package/dist/dialog/online-call-host.d.ts.map +0 -1
- package/dist/dialog/online-call-host.js.map +0 -1
- package/dist/dialog/online-call-module.d.ts.map +0 -1
- package/dist/dialog/online-call-module.js.map +0 -1
- package/dist/dialog-events/active-media.d.ts.map +0 -1
- package/dist/dialog-events/active-media.js.map +0 -1
- package/dist/dialog-events/event-source.d.ts.map +0 -1
- package/dist/dialog-events/event-source.js.map +0 -1
- package/dist/dialog-events/index.d.ts +0 -8
- package/dist/dialog-events/index.d.ts.map +0 -1
- package/dist/dialog-events/index.js +0 -24
- package/dist/dialog-events/index.js.map +0 -1
- package/dist/dialog-events/max-listen-source.d.ts +0 -27
- package/dist/dialog-events/max-listen-source.d.ts.map +0 -1
- package/dist/dialog-events/max-listen-source.js +0 -98
- package/dist/dialog-events/max-listen-source.js.map +0 -1
- package/dist/dialog-events/overtalk-source.d.ts +0 -61
- package/dist/dialog-events/overtalk-source.d.ts.map +0 -1
- package/dist/dialog-events/overtalk-source.js +0 -232
- package/dist/dialog-events/overtalk-source.js.map +0 -1
- package/dist/dialog-events/silence-source.d.ts +0 -32
- package/dist/dialog-events/silence-source.d.ts.map +0 -1
- package/dist/dialog-events/silence-source.js +0 -128
- package/dist/dialog-events/silence-source.js.map +0 -1
- package/dist/dialog-events/virtual-finals-module.d.ts.map +0 -1
- package/dist/dialog-events/virtual-finals-module.js.map +0 -1
- package/dist/dialog-events/virtual-finals.d.ts.map +0 -1
- package/dist/dialog-events/virtual-finals.js.map +0 -1
- package/dist/dtmf/dtmf.d.ts +0 -27
- package/dist/dtmf/dtmf.d.ts.map +0 -1
- package/dist/dtmf/dtmf.js +0 -87
- package/dist/dtmf/dtmf.js.map +0 -1
- package/dist/dtmf/index.d.ts +0 -3
- package/dist/dtmf/index.d.ts.map +0 -1
- package/dist/dtmf/index.js +0 -8
- package/dist/dtmf/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lifecycle/index.d.ts +0 -3
- package/dist/lifecycle/index.d.ts.map +0 -1
- package/dist/lifecycle/index.js +0 -9
- package/dist/lifecycle/index.js.map +0 -1
- package/dist/lifecycle/lifecycle.d.ts.map +0 -1
- package/dist/lifecycle/lifecycle.js.map +0 -1
- package/dist/llm/index.d.ts +0 -7
- package/dist/llm/index.d.ts.map +0 -1
- package/dist/llm/index.js +0 -18
- package/dist/llm/index.js.map +0 -1
- package/dist/llm/llm-markers-module.d.ts +0 -15
- package/dist/llm/llm-markers-module.d.ts.map +0 -1
- package/dist/llm/llm-markers-module.js +0 -48
- package/dist/llm/llm-markers-module.js.map +0 -1
- package/dist/llm/llm-markers.d.ts +0 -36
- package/dist/llm/llm-markers.d.ts.map +0 -1
- package/dist/llm/llm-markers.js +0 -210
- package/dist/llm/llm-markers.js.map +0 -1
- package/dist/llm/llm-module.d.ts +0 -20
- package/dist/llm/llm-module.d.ts.map +0 -1
- package/dist/llm/llm-module.js.map +0 -1
- package/dist/match/index.d.ts +0 -3
- package/dist/match/index.d.ts.map +0 -1
- package/dist/match/index.js +0 -10
- package/dist/match/index.js.map +0 -1
- package/dist/match/match.d.ts +0 -33
- package/dist/match/match.d.ts.map +0 -1
- package/dist/match/match.js +0 -85
- package/dist/match/match.js.map +0 -1
- package/dist/outbound/index.d.ts +0 -3
- package/dist/outbound/index.d.ts.map +0 -1
- package/dist/outbound/index.js +0 -8
- package/dist/outbound/index.js.map +0 -1
- package/dist/outbound/outbound.d.ts +0 -40
- package/dist/outbound/outbound.d.ts.map +0 -1
- package/dist/outbound/outbound.js +0 -84
- package/dist/outbound/outbound.js.map +0 -1
- package/dist/result/index.d.ts +0 -2
- package/dist/result/index.d.ts.map +0 -1
- package/dist/result/index.js.map +0 -1
- package/dist/result/result-store.d.ts.map +0 -1
- package/dist/result/result-store.js.map +0 -1
- package/dist/testing/fake-channel.d.ts.map +0 -1
- package/dist/testing/fake-channel.js.map +0 -1
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/index.js.map +0 -1
- package/docs/agents/README.md +0 -41
- package/docs/agents/barge-in.md +0 -67
- package/docs/agents/dialog.md +0 -98
- package/docs/agents/getting-started.md +0 -142
- package/docs/agents/imports.md +0 -40
- package/docs/agents/media-and-ports.md +0 -82
- package/docs/agents/modules.md +0 -83
- package/docs/agents/phases.md +0 -83
- package/docs/framework/extending.md +0 -59
- package/docs/framework/idn-parity.md +0 -18
- package/examples/minimal-agent/README.md +0 -7
- package/examples/minimal-agent/agent.ts +0 -94
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Core runtime (internal)
|
|
2
|
+
|
|
3
|
+
The package is engine-only: agents are data — builder blocks (`voiceAgent(…).pipe(…).build()`,
|
|
4
|
+
`@voctiv/agent-runtime/templates`) — and their tests use `@voctiv/agent-runtime/testing`. The DI core below is **internal** — no subpath exports it, `dist/*` deep
|
|
5
|
+
imports are closed, and the hand-written agent style (`createAgentScript(AppModule)` with your own reducer and modules)
|
|
6
|
+
is gone. Read this page only when you change the engine or the core under it. Russian-language internals:
|
|
7
|
+
`docs/framework/*`.
|
|
8
|
+
|
|
9
|
+
## Public API
|
|
10
|
+
|
|
11
|
+
| Subpath | Exports |
|
|
12
|
+
|---|---|
|
|
13
|
+
| `@voctiv/agent-runtime/templates` | the builder and its blocks, the data-only agent file types (`AgentSpec` …, `src/templates/authoring.ts`), the data language evaluators (`evalCondition`, `evalExpr`, `exprContext`), `DEFAULT_EXTRACT_PROMPT`, `BaseResult` |
|
|
14
|
+
| `@voctiv/agent-runtime/testing` | test-only and unstable (names may change in any minor version; agent source under `src/` never imports it, the template agent's test checks that): `createFakeChannel`; the engine parts agent tests drive (`specOf`, `compiledSpecOf`, `compileDataForms`, `decideByRules`, `buildCallVars`, `buildReportRow`, `compileMatcher`, `callPlanFromSpec`, …); call units (`TurnTimingController`, `SpeechLeakFilter`, `runExtraction`, `detectVoicemail`, SIP / env / outbound helpers); the locale packs and their read-outs |
|
|
15
|
+
| `@voctiv/agent-runtime` | `AGENT_RUNTIME_PACKAGE`, `AGENT_RUNTIME_VERSION` |
|
|
16
|
+
|
|
17
|
+
Every name is listed explicitly in `src/templates/index.ts` / `src/testing/index.ts`; `src/exports.spec.ts` compares
|
|
18
|
+
them with a snapshot. A new public name is a deliberate change: add it, run `npx vitest run -u src/exports.spec.ts`,
|
|
19
|
+
review the snapshot diff. Code no entry point reaches is deleted, not kept "for later".
|
|
20
|
+
|
|
21
|
+
## How a call runs under the engine
|
|
22
|
+
|
|
23
|
+
`.build()` (the engine's `defineVoiceAgent`, internal) compiles the agent file's data forms into the engine's own
|
|
24
|
+
functions and hooks (`compileDataForms`, the blocks' own hooks by `withBlocks`), builds an `AgentModule` (the engine's
|
|
25
|
+
dialog, its ports and event sources) and hands it to `createAgentScript`, which builds a call-scoped DI container per
|
|
26
|
+
`defineScript` invocation and runs the handlers of the current phase:
|
|
27
|
+
|
|
28
|
+
| `phases` key | SDK phase |
|
|
29
|
+
|---|---|
|
|
30
|
+
| `beforeCall` | `before_call` |
|
|
31
|
+
| `onlineEarly` | `online`, `early`, `dialing` (before media) |
|
|
32
|
+
| `onlineCall` | `online`, and `early`/`dialing` after answer |
|
|
33
|
+
| `afterCallSuccess` / `afterCallFailed` | `after_call_success` / `after_call_failed` |
|
|
34
|
+
|
|
35
|
+
Order inside a phase: `@PhaseOrder(n)`, lower first (MediaBootstrap `-100`, Lifecycle `-50`, OnlineCallHost `0`).
|
|
36
|
+
`OnCallEnded` runs after `terminated$`, before the output is taken; `OnCallDestroy` always, in finally. On live phases the
|
|
37
|
+
script returns only after `channel.events.terminated$`.
|
|
38
|
+
|
|
39
|
+
The dialog loop: event sources → `reduce(state, event)` (pure) → effects → ports → follow-up events. Cancelable effects
|
|
40
|
+
are aborted by the next one; a failed effect comes back as `PORT_ERROR`. Media (`ActiveMedia`, `MediaBootstrap`) is
|
|
41
|
+
created from `MEDIA_REGISTRATIONS`; barge-in attaches on `ActiveMedia.setAsr`.
|
|
42
|
+
|
|
43
|
+
## The engine's reducer
|
|
44
|
+
|
|
45
|
+
`src/templates/engine/dialog.ts` holds the state (`EngineState`), the call view texts and rules read, and the rules
|
|
46
|
+
pass; `voice-dialog.ts` is the entry for the media's events — one `case` per event, each handed to the block that owns
|
|
47
|
+
it. The blocks are `src/templates/engine/turns/*`, plain functions over one shared context per event (`Turn` in
|
|
48
|
+
`turns/context.ts`: the draft of the state, the media snapshot, the effects collected, the agent file's blocks as
|
|
49
|
+
`TurnEnv`, built once per dialog):
|
|
50
|
+
|
|
51
|
+
| File | Block |
|
|
52
|
+
|---|---|
|
|
53
|
+
| `turns/events.ts` | the media's events, the effects, what the voice part reads of `dialog.ts` (`VoiceCore`, `Runner`) |
|
|
54
|
+
| `turns/context.ts` | `Turn` and its shared helpers (lines, effects, fixed and LLM turns, clips, hold) |
|
|
55
|
+
| `turns/actions.ts` | the actions runner (`say`, `llm`, `play`, `close`, `choose`, the engine's generated hook actions, …) the rules pass and every block use |
|
|
56
|
+
| `turns/opening.ts` | opening steps, listen answers, the eager greeting, the opening's end |
|
|
57
|
+
| `turns/rules.ts` | which rules read a line (sync, NLU, the blocks' planners), partial and tool-call rules, gates |
|
|
58
|
+
| `turns/language.ts` | the reply language, handoff and change marker, the recognizer switch |
|
|
59
|
+
| `turns/turn.ts` | a caller final, the caller line to the LLM turn, an agent line spoken / played out, verdicts of reply filters |
|
|
60
|
+
| `turns/carry.ts` | `turn.carryOn` |
|
|
61
|
+
| `turns/overtalk.ts` | speech over the agent: guard, buffer, the drain's decision, replay |
|
|
62
|
+
| `turns/silence.ts`, `voicemail.ts`, `closing.ts`, `transfer.ts`, `pending.ts` | silence ladders; voicemail; goodbye and reopen; transfer; lines waiting for NLU or a block's planner |
|
|
63
|
+
|
|
64
|
+
`EngineState` stays one flat object (the step copies it shallowly and writes the copy); its interface is the union of
|
|
65
|
+
per-block interfaces (`OpeningState`, `OvertalkState`, …) that say which block owns a field. A new behaviour goes in
|
|
66
|
+
the block it belongs to (a new file when it is a block of its own); the entry only routes a new event.
|
|
67
|
+
|
|
68
|
+
The engine's hooks (generated from data forms, and the blocks' own: `knowledgeAnswer`, `catalogMatch`) keep one
|
|
69
|
+
object of state per call (`HookApi.state`); it never reaches the reducer by reference.
|
|
70
|
+
`EngineDialogDefinition` (`voice.ts`) commits around each reduce: before the event it puts a snapshot of the hooks'
|
|
71
|
+
object into the state (`EngineState.hookState`, `hook-state.ts`: plain data copied and frozen, class instances and
|
|
72
|
+
functions by reference); `dialog.ts` gives the compiled code of that event a writable copy as `call.hookState` (and
|
|
73
|
+
`results.fromFacts` the same as `facts.hookState`); the new state carries what that code wrote, and after the reduce the
|
|
74
|
+
host writes the changed keys back to the hooks' object (untouched keys keep their values, so a hook holding one across
|
|
75
|
+
an `await` keeps it). Code outside the reducer (the engine's hooks, reply filters, the media's calls, report fields)
|
|
76
|
+
sees the hooks' object itself. So `reduce(state, event)` depends only on its arguments.
|
|
77
|
+
|
|
78
|
+
## Invariants (do not break)
|
|
79
|
+
|
|
80
|
+
1. `reduce` is pure. 2. Explicit public API, checked by the snapshot; the core is not exported. 3. One `ResultStore`,
|
|
81
|
+
host, `ActiveMedia` per call (singletons in the child container; never register on the global tsyringe container).
|
|
82
|
+
4. Media only via `ActiveMedia`. 5. Barge-in attaches on `setAsr`, never manually. 6. SDK types are primary. 7. No
|
|
83
|
+
optional `@inject(Class)`. 8. Algorithms ported from production agents keep their semantics — change behaviour only on
|
|
84
|
+
purpose and say so.
|
|
85
|
+
|
|
86
|
+
## Tests
|
|
87
|
+
|
|
88
|
+
`npm run build`, `npm test` (vitest via `unplugin-swc` with decorator metadata), `npm run typecheck`. Each test builds
|
|
89
|
+
its own call container. A media channel mock: `createFakeChannel` (`src/testing`).
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Example agent files
|
|
2
|
+
|
|
3
|
+
Two complete examples live in the library's source repository (not in the installed package, which ships only the
|
|
4
|
+
template agent `templates/agent/`): typechecked data written with the builder (`builder.md`) that compiles against the
|
|
5
|
+
data-only `AgentSpec`, so it never drifts from the format; `src/templates/builder/examples.spec.ts` of the repository
|
|
6
|
+
pins the `AgentSpec` each one makes. The table says what each shows; the patterns below are self-contained.
|
|
7
|
+
|
|
8
|
+
| File (library repository) | Shows |
|
|
9
|
+
|---|---|
|
|
10
|
+
| `src/templates/examples/reminder.agent.ts` | Recorded hello with voice variants (`{voice}` in record names), LLM greeting prepared eagerly, opening silence ladder with a re-prompt clip, input fields from header → entity, locale formats (amount, date, time-of-day greeting), drain floor, `cutAfter` filter, overtalk with interrupt lexicon, silence ladder + no-progress backstop, NLU voicemail with phrase fallback, extraction with `implies`/`priority`, result facts, report fields incl. voice tag, CRM integration with storage key, write-back and retries, recall budget and delay from the campaign, links host by region. |
|
|
11
|
+
| `src/templates/examples/collection-bilingual.agent.ts` | Fixed bilingual greeting, `listen` with `keepIfWithinMs`, provisional language pick with one-way fallback, an `undecided` recognizer, identity gate across the whole conversation (`asked`, `answers`, `unheardMark`, `maxAsks`), hold rule with a held silence ladder, wrong-number close, a rule with a flag and a mark, silence rung with a `when` condition, voice-without-text handling, phrase/loop/menu voicemail detectors, dial-and-whisper transfer with human detection, the client's category as the result (`results.rules`), a report column and an integration body as expressions, `entity: '*'` in the report, recall budget and delay. |
|
|
12
|
+
|
|
13
|
+
## Choosing a starting point
|
|
14
|
+
|
|
15
|
+
- A new agent → the library's `templates/agent/` (in the package too; `new-agent.md`); the repository files above show
|
|
16
|
+
how more fields combine.
|
|
17
|
+
- LLM greets the caller after a recorded hello → start from `reminder.agent.ts`.
|
|
18
|
+
- Fixed phrases first, language choice, a question that must be answered before the business talk → start from
|
|
19
|
+
`collection-bilingual.agent.ts`.
|
|
20
|
+
- Inbound agent → `platform.scheduleOutbound: false`, no `recall`, opening starts with `say` or `llmGreeting`.
|
|
21
|
+
|
|
22
|
+
## Patterns
|
|
23
|
+
|
|
24
|
+
**Re-prompt with a recorded clip, then close silently**
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
{ step: 'listen', silence: [
|
|
28
|
+
{ afterMs: 4000, do: { play: { record: 'HELLO_NULL_{voice}', text: 'Hello, can you hear me?' } } },
|
|
29
|
+
{ afterMs: 4000, do: { close: null, result: 'silence' } },
|
|
30
|
+
] }
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Different greeting on a callback**
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
{ step: 'say', text: { cases: [{ when: { fact: 'previousResult', eq: 'callback_requested' }, value: 'Hello again, as promised…' }], else: 'Hello!' } }
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Do not call again after a client said so (kept across attempts)**
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
rules: [{ id: 'doNotCall', on: 'callerLine', match: { lexicon: 'doNotCall' }, then: { close: 'Understood. Goodbye.', result: 'DNC' } }],
|
|
43
|
+
results: { ..., remember: [{ key: 'doNotCall', value: { cases: [{ when: { row: 'result', eq: 'DNC' }, value: true }], else: { omit: true } } }] },
|
|
44
|
+
platform: { preDial: { integration: 'dncCheck', failOpen: true } }, // its `answer` reads `{ memory: 'doNotCall' }`
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**«Put me through to a person» → transfer (once per call)**
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
{ id: 'operator', on: 'callerLine', match: /\b(operator|a person)\b/i, when: { max: 1 }, then: { transfer: true } }
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Tell the LLM its previous line was cut**
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
{ id: 'cut', on: 'agentLineCut', then: { mark: '<<< previous_reply_cut;' }, continue: true }
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**A disclosure right after the agent introduces itself (once)**
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
turn: { filters: [{ filter: 'insertAfter', match: { phrases: ['my name is'] }, text: 'I am a virtual assistant.', once: true }] }
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Scenario variants of the prompt instead of code**
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
prompt: { template: 'prompt.sqrl', silenceSignal: '…', variants: [
|
|
69
|
+
{ when: { var: 'days_overdue', lte: 0 }, vars: { scenario: 'predue' } },
|
|
70
|
+
{ when: { var: 'days_overdue', gt: 30 }, vars: { scenario: 'late' } },
|
|
71
|
+
{ when: true, vars: { scenario: 'overdue' } },
|
|
72
|
+
] }
|
|
73
|
+
```
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
# The data language: `Condition` and `Expr`
|
|
2
|
+
|
|
3
|
+
Source of truth: `src/templates/expr/types.ts` (types), `src/templates/expr/evaluate.ts` (evaluator),
|
|
4
|
+
`src/templates/expr/slots.ts` (which spec slots take them). Everything in an agent that depends on the call — `when`,
|
|
5
|
+
computed input fields, texts, report fields, integration bodies — is written as data with these two types; an agent
|
|
6
|
+
has no functions (the authoring types refuse them). The engine compiles the data forms into its own functions when the
|
|
7
|
+
script is built.
|
|
8
|
+
|
|
9
|
+
- **`Condition`** — a yes/no question: `{ var: 'dpd', gte: 3 }`, `{ all: [...] }`, `{ said: { by: 'caller', match } }`.
|
|
10
|
+
- **`Expr`** — a value or a text: a literal, a reference (`{ var: 'name' }`), or one operator object
|
|
11
|
+
(`{ template: 'Hello {name|cap}' }`, `{ cases: [...] }`, `{ read: 'msisdn', of: … }`).
|
|
12
|
+
|
|
13
|
+
Evaluation is pure: the clock, time zone (`input.timeZone`), reply language and random source come from the context
|
|
14
|
+
(`ExprContext`); randomness only through `ctx.random` (the stand fixes it; the library uses `Math.random`).
|
|
15
|
+
Public API (`@voctiv/agent-runtime/templates`): `evalCondition(c, ctx)`, `evalExpr(e, ctx)`, `evalText(e, ctx)`,
|
|
16
|
+
`exprContext(parts)`, `readValue(raw, spec, ctx, evaluate)`; types `Condition`, `Expr`, `ExprNode`, `DataExpr`,
|
|
17
|
+
`RefExpr`, `Ref`, `Cmp`, `TranscriptCondition`, `MatcherAddition`, `ReadSpec`, `DateOrder`, `DayTable`, `ExprCase`,
|
|
18
|
+
`ExprFormat`, `ExprContext`, `FactName`, `NamedFacts`, `NamedFact`, `NamedMatchers`, `Speaker`, `Literal`,
|
|
19
|
+
`RecordExpr`, `ActionChoice`.
|
|
20
|
+
|
|
21
|
+
## Where the data forms go
|
|
22
|
+
|
|
23
|
+
| Slot | Kind | What the slot's context has |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| `opening[].when`, `silence.ladder[].when` (also `held.rungs`, listen `silence`), `voicemail.when`, `prompt.variants[].when`, `results.fromFacts[].when`, `extraction.entities[].when`, `platform.scheduleOutbound` | `Condition` | the call |
|
|
26
|
+
| `integrations[].when` | `Condition` | the call, `row` |
|
|
27
|
+
| `catalogMatch.verify.transitions[].when` | `Condition` (the older flag map `{ lenient: false }` still reads) | the round flags as `{ flag: name }` |
|
|
28
|
+
| `input.dialogEnv[].unless` | `Condition` | `self` = the value kept |
|
|
29
|
+
| Every `Text` (say / close / llm texts, step texts, `prompt.handoff`, `silenceSignal`, `whisper`, `transfer.text.say`, `onFailure.say`, `regenerateEmpty.signal`, filter texts, gate `question`, probes) | `Expr` → text; `null` says nothing | the call, `line` |
|
|
30
|
+
| `input.fields.*.from` (any object that is not a single `Source`), `.default` | `Expr` | vars so far, clock (no call) |
|
|
31
|
+
| `input.fields.*.read` | `ReadSpec` | applied to the sourced value before `default` / `format` |
|
|
32
|
+
| `input.dialogEnv[].value`, `platform.cancel.when` (text or empty), close `result` / `reason` / `alias`, opening close `result`, `transfer.target.did`, `transfer.headers` | `Expr` | the call |
|
|
33
|
+
| `input.lookup.result`, `voice.tts.variantBy`, `voice.tts.variantPick.by`, `voice.asr.<lang>.picks[].when` / `share.from` / `share.seed` | `Expr` / `Condition` | vars only |
|
|
34
|
+
| `platform.legs.dialNumber` | `Expr` | `self` = the number |
|
|
35
|
+
| `voice.tts.presay`, `scriptLeak.allow`, `closing.guard.closings` / `openings` | `Expr` → list of texts | the call |
|
|
36
|
+
| `prompt.vars`, `prompt.variants[].vars`, `transfer.entities` | `{ object }`, `{ merge }` or `{ cases }` only (any other object is the record itself) | the call |
|
|
37
|
+
| `extraction.vars` | `Expr` → object | the call |
|
|
38
|
+
| `extraction.normalize[].fix` | `Expr` | `self` = the entity value |
|
|
39
|
+
| `results.remember[].value` | `Expr` (`{ omit: true }` leaves the key) | the call, `row` |
|
|
40
|
+
| `report.fields.*` | any `Expr` but the fixed forms (`{ var }`, `{ entity }`, `{ value }`, `{ fact[, omit] }` with one key stay as they were); `{ spread: Expr }` | the call (`rowFacts`), `row` |
|
|
41
|
+
| `integrations[].body` / `answer` / `writeBack.value` | `Expr` | `row`; `answer`: `self` / `input` = response; `writeBack`: `input` = outcome |
|
|
42
|
+
| `overtalk.cutMark`, `transfer.veto`, `closing.guard.replace` | `Expr` | `input` = `{ heardMs }` / the caller's line / the held line (also `line`) |
|
|
43
|
+
| `turn.review` rules (`when`, `holdChars`, `regenerate`) | `Condition` / `Expr` | `input` = the review's input (`request`, `trigger`, `held`, `final` …), `line` = the trigger |
|
|
44
|
+
| `turn.replyRules` | reply conditions (`Condition` + sentence predicates), texts | `line` = the sentence (`insertAfterFirst.when`: the caller's words) |
|
|
45
|
+
| `closing.guard.replace.reask` | `Condition` / `Expr` | `line` = the held line (`steps[].reasks`: the asking line) |
|
|
46
|
+
| `transfer.toolReply.dropOn.goodbye.unless` | `Condition` | `line` = the reply |
|
|
47
|
+
| `rules[].when` (any key besides `phase`, `max`, `held`) | `Condition` | the call, `line` = the line the rule reads |
|
|
48
|
+
| Any action (or action list) | `{ choose: [{ when, then }], otherwise? }` | the call, `line` |
|
|
49
|
+
| `integrations[].headers` / `query` / `skipWhen` / `rowFields` / `value` / `log`, `startAgentDialog`, `ask` | `Expr` / `Condition` | the call, `row`, locals (`dialogUuid`, `inputs`, outcome: `status`, `json` …; `business.md`) |
|
|
50
|
+
| `input.testData.presets` fields | `Expr` | earlier fields as vars, `input` = the switch value, clock |
|
|
51
|
+
| `platform.afterLeg` (policy) `write` / `decide` / `log`, `legs.routeRules`, `legs.callbacks.when` / `time` | `Expr` / `Condition` | the call (`memory`), locals `attempt`, `count`, `delaySec`, `msisdn` |
|
|
52
|
+
|
|
53
|
+
Static text only: `extraction.entities[].description` / `extraction.prompt` (`{placeholders}` from `extraction.vars`),
|
|
54
|
+
`input.testData.values` (dynamic test records: `presets`).
|
|
55
|
+
|
|
56
|
+
Named definitions on the agent file: `matchers: { name: Matcher }` (used as `{ matcher: 'name' }` wherever a matcher
|
|
57
|
+
goes) and `facts: { name: { condition } | { value } }` (read as `{ fact: 'name' }`; a built-in name is refused).
|
|
58
|
+
A named `{ value }` is the agent's named expression: it is evaluated where it is read, with that place's locals,
|
|
59
|
+
line and row — one block written once and read in many slots (`facts({ base_name: { value: { shorten: { local:
|
|
60
|
+
'item' }, rules } } })`, then `{ each: { var: 'items' }, to: { fact: 'base_name' } }`).
|
|
61
|
+
|
|
62
|
+
## References
|
|
63
|
+
|
|
64
|
+
| Ref | Reads | Example |
|
|
65
|
+
|---|---|---|
|
|
66
|
+
| `var` | call variable (dotted path) | `{ var: 'customer.first_name' }` |
|
|
67
|
+
| `fact` | built-in fact or `AgentSpec.facts` | `{ fact: 'hour' }`, `{ fact: 'callerEngaged' }` |
|
|
68
|
+
| `entity` | extracted entity (after the call) | `{ entity: 'ptp.date' }` |
|
|
69
|
+
| `row` | report row field | `{ row: 'result' }` |
|
|
70
|
+
| `memory` | value kept across attempts | `{ memory: 'first_due' }` |
|
|
71
|
+
| `flag` | engine flag (`true`/`false`) | `{ flag: 'closing.afterSilence' }` |
|
|
72
|
+
| `counter` | rule counter; a list is summed | `{ counter: ['bad_word', 'bad_word_close'] }` |
|
|
73
|
+
| `input` | the input of the slot (the review's input, the integration's outcome or answer, `heardMs` of `cutMark`) | `{ input: 'heardMs' }` |
|
|
74
|
+
| `self` | the value the slot transforms | `{ self: true }` |
|
|
75
|
+
| `local` | name bound by `let`, `dayTable`, `each`, `select` | `{ local: 'item' }` |
|
|
76
|
+
| `asked` | agent lines that asked a `tracking.questions` question (a list is summed) | `{ asked: 'address', gte: 2 }` |
|
|
77
|
+
| `answers` | caller lines said while the question (one of them) was open, matching `match` | `{ answers: { question: 'acquaintance', match: { matcher: 'denies' } }, gte: 2 }` |
|
|
78
|
+
|
|
79
|
+
Options on a reference: `default` (when empty), `map` (`{ var: 'region', map: { idn: 'id.example' }, default: 'x' }`;
|
|
80
|
+
looked up as is, then trimmed lower case). With tests of `Cmp` it is a yes/no (`{ var: 'dpd', gt: 5 }` → `true`).
|
|
81
|
+
|
|
82
|
+
Built-in facts: `today` (`YYYY-MM-DD`), `now` (epoch ms), `hour`, `minute`, `weekday` (0 = Sunday), `timeZone`;
|
|
83
|
+
`line`, `lastAgentLine`, `lastCallerLine`, `answeredCallerLine` (the last caller line before the agent's last line), `lastQuestion`, `phase`, `language`, `languageProvisional`, `callerTurns`,
|
|
84
|
+
`callerFinals`, `agentLines`, `callerLines`, `elapsedMs`, `attempt`, `previousResult`, `voiceTag`, `replyAsr`,
|
|
85
|
+
`afterSilence`, `stage` and `openQuestion` (`tracking`, `blocks.md`); after the call `result`, `preResult`, `extractedResult`, `triggersCallback`, `extractionFailed`,
|
|
86
|
+
`endedBy`, `endedAtMs`, `recallScheduled`, `budget`, `transferStarted`, `transferCompleted`, `transferStartedAt` (ISO, `''` when no transfer started); report rows `rowKind`,
|
|
87
|
+
`connected`, `callUuid`, `dialogUuid`, `sipCode`, `sipPhrase`, `asrDurationSec`, `replyLanguage`, `replyLanguageProvisional` (the reply language was still provisional at the end), `service.<key>`.
|
|
88
|
+
|
|
89
|
+
## Conditions
|
|
90
|
+
|
|
91
|
+
| Form | Holds when | Example |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| `true` / `false` | always / never | `when: true` |
|
|
94
|
+
| Ref + tests | the value passes every test (no test: truthy) | `{ var: 'dpd', gte: 1, lte: 30 }` |
|
|
95
|
+
| `of` + tests | any expression passes | `{ of: { daysUntil: { var: 'due' } }, lt: 0 }` |
|
|
96
|
+
| `all` / `any` / `not` | combinators | `{ all: [{ var: 'a' }, { not: { var: 'b' } }] }` |
|
|
97
|
+
| `rowKind` | the row being built is one of | `{ rowKind: ['failedDial', 'failedLeg'] }` |
|
|
98
|
+
| `weekdayIn` | today is one of (0 = Sunday) | `{ weekdayIn: [0, 6] }` |
|
|
99
|
+
| `language` | reply language is (one of) | `{ language: ['ms', 'en'] }` |
|
|
100
|
+
| `phase` | call phase is (one of) | `{ phase: 'closing' }` |
|
|
101
|
+
| `line` | the line handled matches | `{ line: { lexicon: 'yes' } }` |
|
|
102
|
+
| `stage` | the call's `tracking.stages` stage is (one of) | `{ stage: ['offer', 'offer_answered'] }` |
|
|
103
|
+
| `openQuestion` | the `tracking.questions` question open now is (one of); `null`: none | `{ openQuestion: 'identity' }` |
|
|
104
|
+
| `ladderOpen` | the line ladder has a line left to say (or a terminal action) | `{ ladderOpen: 'amount' }` |
|
|
105
|
+
|
|
106
|
+
`{ flag: name }` also reads the line flags of `tracking.flags` (read off the transcript) and its heard / cut flags (kept
|
|
107
|
+
in the call's flags).
|
|
108
|
+
|
|
109
|
+
Tests (`Cmp`), applied after `read` → `as` (`number` / `amount` / `date` / `text`) → `normalize` (`lower`,
|
|
110
|
+
`trimLower`, `noSpacesLower`, `NFC`):
|
|
111
|
+
|
|
112
|
+
| Test | Example |
|
|
113
|
+
|---|---|
|
|
114
|
+
| `eq`, `ne` (numbers as numbers; `null` only equals null) | `{ var: 'status', eq: 'paid' }`, `{ var: 'x', eq: null }` |
|
|
115
|
+
| `in`, `notIn` | `{ var: 'tier', in: ['gold', 'vip'] }` |
|
|
116
|
+
| `gt`, `gte`, `lt`, `lte` (numbers, `YYYY-MM-DD` days; operand any `Expr`) | `{ var: 'due', gt: { fact: 'today' } }` |
|
|
117
|
+
| `empty`, `truthy`, `isTrue` | `{ var: 'name', empty: false }`, `{ var: 'test_mode', isTrue: true }` |
|
|
118
|
+
| `matches` (a `Matcher`), `includes` (text or list) | `{ var: 'segment', matches: /^vip/i }`, `{ var: 'channels', includes: 'sms' }` |
|
|
119
|
+
| `isoDate`, `numeric` | `{ var: 'due', isoDate: true }` |
|
|
120
|
+
| `days: { from?, eq?, min?, max? }` (days from `from`/today to the value) | `{ var: 'promise', read: { kind: 'date', orders: ['mmdd'] }, days: { min: 0, max: 7 } }` |
|
|
121
|
+
| `type` (`string`, `number`, `boolean`, `object`, `array`, `null`, `undefined`) | `{ entity: 'promised_date', type: 'string' }` |
|
|
122
|
+
|
|
123
|
+
`strict: true` gives a comparison plain JavaScript semantics, for code that used `===` or `if (x)`: `eq` / `ne` / `in` /
|
|
124
|
+
`notIn` / list `includes` compare with `===` (the text `'true'` is not `true`, `'5'` is not `5`), and `truthy` (or a
|
|
125
|
+
value with no tests) is `Boolean(v)` (the texts `'false'`, `'0'`, `'NaN'` are true). `{ entity: 'paid', eq: true,
|
|
126
|
+
strict: true }` is `entities.paid === true`; `{ var: 'x', strict: true }` is `!!vars.x`.
|
|
127
|
+
|
|
128
|
+
A reference also takes `nullish` (JavaScript `??`: only `null` / a missing value; `{ row: 'k', nullish: null }`), next
|
|
129
|
+
to `default` (any empty value) and `map`.
|
|
130
|
+
|
|
131
|
+
Transcript questions (agent lines without words, `…`, are skipped). Every question takes reading options next to its
|
|
132
|
+
key: `includeEmpty: true` (keep agent lines without words: a `…` line is the last line, ends a run of agent lines),
|
|
133
|
+
`firstLineOnly: true` (a line is its first text line), `normalize: 'NFC'` (lines NFC-normalized before the
|
|
134
|
+
matchers), `from: { text, agent, caller }` (the lines of a speaker-prefixed transcript text, e.g.
|
|
135
|
+
`{ lastAgentLine: /bye/, from: { text: { fact: 'service.call_transcript' }, agent: 'AGENT:', caller: 'USER:' } }`; a
|
|
136
|
+
line without a prefix continues the line before, or is dropped with `firstLineOnly`).
|
|
137
|
+
|
|
138
|
+
| Form | Example |
|
|
139
|
+
|---|---|
|
|
140
|
+
| `said: { by, match?, unit?, after?, count?, firstSentence? }` | `{ said: { by: 'agent', match: { lexicon: 'notHeard' }, count: { gte: 2 } } }` |
|
|
141
|
+
| `lastAgentLine`, `lastSentence` | `{ lastAgentLine: /\?$/ }` |
|
|
142
|
+
| `lastQuestion` (+ `skip`) | `{ lastQuestion: /pay/i, skip: { lexicon: 'repeat' } }` |
|
|
143
|
+
| `lastLine: { who, match }` (the very last line) | `{ lastLine: { who: 'caller', match: { lexicon: 'goodbye' } } }` |
|
|
144
|
+
| `callerStreak: { match, gt }` | `{ callerStreak: { match: { lexicon: 'notHeard' }, gt: 1 } }` |
|
|
145
|
+
| `closedOn` (last agent line contains, normalized; `raw: true`: a plain `includes`) | `{ closedOn: { var: 'goodbye_text' } }` |
|
|
146
|
+
| `callerSaidAfter: { agent, caller, reply? }` (`reply`: the agent line right after that caller line matches it) | `{ callerSaidAfter: { agent: /amount/, caller: { lexicon: 'no' } } }`; «a heard answer to the greeting that got a real reply»: `{ callerSaidAfter: { agent: /how are you/i, caller: { not: /\[inaudible\]/ }, reply: { not: /didn't catch/i } } }` |
|
|
147
|
+
| `answeredAfter` / `unansweredAfter` | `{ unansweredAfter: /can you pay/i }` |
|
|
148
|
+
| `exchange: { before?, question, answer, scope }` | `{ exchange: { question: /is this/i, answer: { lexicon: 'yes' }, scope: 'firstAnswer' } }` |
|
|
149
|
+
| `lastAnswer: { after, matches }` | `{ lastAnswer: { after: /when/i, matches: /tomorrow/i } }` |
|
|
150
|
+
| `trailingAgentLines: { min }` | `{ trailingAgentLines: { min: 2 } }` |
|
|
151
|
+
| `sequence: [{ agent } / { caller } / { nextAgent }]` | `{ sequence: [{ agent: /offer/ }, { caller: { lexicon: 'yes' } }, { nextAgent: /thank/ }] }` |
|
|
152
|
+
| `callerEchoesAgent: { minWords }` | `{ callerEchoesAgent: { minWords: 3 } }` |
|
|
153
|
+
| `callerLineAnsweredByLastAgent` | `{ callerLineAnsweredByLastAgent: /sorry/i }` |
|
|
154
|
+
| `latest: { cases: [{ match \| { afterAgent, line }, value }], none }` | `{ latest: { cases: [{ match: { lexicon: 'no' }, value: true }], none: true } }` |
|
|
155
|
+
| `agentSaid: { text, prefixChars?, slackChars? }` | `{ agentSaid: { text: { var: 'disclosure' }, prefixChars: 40 } }` |
|
|
156
|
+
| `daysIn: { allAfter }` | `{ daysIn: { allAfter: { var: 'due_date' } } }` |
|
|
157
|
+
| `callerAfterLast: { agent, line?, scope?, question? }` — caller lines after the last agent line matching `agent` (`any`, default), until the next agent line (`untilAgent`), or the one just before it (`previous`, its question matching `question`); blank lines are no answer; `line` is a condition on the line | `{ callerAfterLast: { agent: /settle the loan/i, scope: 'previous', question: /\btoday\b/i, line: { not: { line: /\bno\b/i } } } }` |
|
|
158
|
+
|
|
159
|
+
Matcher additions (anywhere a `Matcher` goes): `{ squeezed: /^alo+$/, maxChars: 8 }` (letters and digits only),
|
|
160
|
+
`{ words: { min: 4 } }` / `{ words: { max: 2, every: /^\p{L}+$/u } }` / `{ words: { some: { lexicon: 'yes' } } }`,
|
|
161
|
+
`{ mentions: { vars: ['debtor_name'], stem: { over: 4, cut: 2 } } }`, `{ normalizedEquals: { var: 'intro' } }`
|
|
162
|
+
(`punctuation: 'space'`: punctuation becomes a space instead of being dropped), `{ lastAgentLine: /transfer/i }`
|
|
163
|
+
(`includeEmpty: true`: a wordless last agent line `…` is the line tested), `{ matcher: 'asks.date' }`, `{ spaced: /^нет$/ }` (a leading `[xx]` recognizer label
|
|
164
|
+
dropped, lower case, every run of non-letters/digits one space, trimmed), `{ contains: { vars: ['debtor.name'], stem:
|
|
165
|
+
{ over: 5, cut: 2 }, minLen: 2, all: true } }` (each var value, trimmed, lower-cased, cut when longer than `over`, is a
|
|
166
|
+
substring of the lower-cased line; values shorter than `minLen` dropped; none left: no match).
|
|
167
|
+
|
|
168
|
+
## Expressions
|
|
169
|
+
|
|
170
|
+
### Selection
|
|
171
|
+
|
|
172
|
+
| Operator | Example | Value |
|
|
173
|
+
|---|---|---|
|
|
174
|
+
| `cases` / `else` | `{ cases: [{ when: { var: 'dpd', gt: 30 }, value: 'late' }], else: 'due' }` | first match (`null` without `else`) |
|
|
175
|
+
| `lookup` | `{ lookup: { of: { var: 'product' }, table: { cash: 'Cash loan' }, key: 'trimLower', default: '' } }` | table value |
|
|
176
|
+
| `classify` | `{ classify: { of: { var: 'answer' }, classes: { yes: ['ya', 'yes'] }, else: 'other' } }` | class name |
|
|
177
|
+
| `bands` | `{ bands: { of: { fact: 'hour' }, steps: [{ below: 12, value: 'pagi' }, { below: 15, value: 'tengah hari' }], else: 'petang' } }` | `min`/`max` inclusive, `below` exclusive |
|
|
178
|
+
| `firstOf` (+ `when: 'positive'`) | `{ firstOf: [{ var: 'nickname' }, { var: 'name' }, 'Customer'] }` | first non-empty |
|
|
179
|
+
| `test` | `{ test: { var: 'dpd', gt: 0 } }` | `true` / `false` |
|
|
180
|
+
| `let` / `value` | `{ let: { d: { daysUntil: { var: 'due' } } }, value: { cases: [{ when: { local: 'd', lt: 0 }, value: 'overdue' }] } }` | with locals |
|
|
181
|
+
| `omit` | `{ omit: true }` | no value (key left, field not written) |
|
|
182
|
+
| `quote` | `{ quote: { var: 'x' } }` | the object as written |
|
|
183
|
+
|
|
184
|
+
### Text
|
|
185
|
+
|
|
186
|
+
| Operator | Example |
|
|
187
|
+
|---|---|
|
|
188
|
+
| `template` | `{ template: 'Hi {name|cap}, due {due|date:DD.MM.YYYY}, {$lastQuestion}' }` — `{a.b}` local then var, `{$fact}`, filters `cap upper lower trim title date:<style|pattern> format:<kind> default:<text> js` (`js`: as a JavaScript template literal writes it, `null` → `'null'`); empty placeholder → `''`; `{{…}}` kept |
|
|
189
|
+
| `join` | `{ join: { var: 'items' }, sep: ', ', lastSep: ' and ', dropEmpty: true }` |
|
|
190
|
+
| `nth` | `{ nth: ['Hello?', 'Hello, can you hear me?'] }` (by the acting rule's count: the times it acted, this one included; the last item after that; outside a rule the first) |
|
|
191
|
+
| `lines` | `{ lines: ['Said: {said_1}', { text: 'Asked in {askedLanguage}', when: { var: 'askedLanguage' } }], sep: '\n' }` |
|
|
192
|
+
| `listPhrase` | `{ listPhrase: { of: { var: 'goods' }, max: 2, more: { template: ' and {count} more' }, empty: 'your order' } }` |
|
|
193
|
+
| `render` | `{ render: { text: { ru: 'Здравствуйте', kk: 'Сәлеметсіз бе' }, language: { var: 'lang' } } }` |
|
|
194
|
+
| `upper`, `lower`, `trim`, `cap` | `{ cap: { var: 'name' } }` |
|
|
195
|
+
| `replace` (`with`: a text with `$1` …, or an expression per match with locals `match` and `groups` — `{ groups.1 }` …) | `{ replace: { var: 'code' }, re: /-/g, with: ' ' }`; every number in words: `{ replace: { var: 'term' }, re: /\d+/g, with: { format: { kind: 'number', locale: 'en' }, of: { local: 'match' } } }` |
|
|
196
|
+
| `capture` | `{ capture: { var: 'ref' }, re: /(\d{4})$/, group: 1 }` |
|
|
197
|
+
| `shorten` (the first rule that matches gives its group, default 1; else `else`, default the text) | `{ shorten: { local: 'name' }, rules: [/^(\p{Lu}\S+ \S+)/u, { re: /^(\S+)/u, group: 1 }], else: { local: 'name' } }` |
|
|
198
|
+
|
|
199
|
+
### Readers (`{ read: ReadSpec, of? }`; `of` defaults to `self`; also `input.fields.*.read` and `Cmp.read`)
|
|
200
|
+
|
|
201
|
+
| Reader | Example | Gives |
|
|
202
|
+
|---|---|---|
|
|
203
|
+
| `text` | `{ kind: 'text', decode: 'uriPlus', collapse: true, nullWords: ['none', 'null'] }` (`onMalformed: 'raw'`: a malformed `%` keeps the text untouched, `+` too; `trim: 'beforeDecode'`: only the raw text is trimmed, `'%20500%20'` → `' 500 '`) | clean text |
|
|
204
|
+
| `jsNumber` | `'jsNumber'` (JavaScript `Number(v)`: `''` → `0`, `'0x1A'` → `26`, `'12,5'` → `NaN`) | number |
|
|
205
|
+
| `msisdn` | `{ kind: 'msisdn', from: 'sipUri' }` (`"D" <sip:84…@h>` → digits); `out: 'asWritten'`: as written, `+` kept (`<sip:+6012…@h>;x` → `+6012…`) | digits |
|
|
206
|
+
| `digits`, `integer`, `figure` | `'integer'` | digits / whole number / decimal |
|
|
207
|
+
| `amount` | `{ kind: 'amount', separators: 'lastIsDecimal', out: 'decimalText', invalid: ['None'], invalidAs: '0' }` | `5.000.000` → `5000000`; `RM 1,234.50` → `'1234.50'` |
|
|
208
|
+
| `date` | `{ kind: 'date', orders: ['ymd', 'mdy', 'serial'], trailingTime: true, mmdd: { maxDaysAhead: 60 }, min: { fact: 'today' }, onInvalid: { fact: 'today' } }`; `separators` (default `./-`) also per order: `{ ymd: '-/', dmy: '-/.' }` | `YYYY-MM-DD` |
|
|
209
|
+
| `dateTime` | `{ kind: 'dateTime', pattern: 'DD.MM.YYYY HH:mm', timeZone: 'Asia/Almaty', within: { minMs: 0, maxMs: 86400000 } }` | epoch ms |
|
|
210
|
+
| `personName` | `{ kind: 'personName', punctuation: 'keep', caseLocale: 'vi', placeholders: ['customer'], dropTokens: /^(bpk|ibu)$/i }` | name for the voice |
|
|
211
|
+
| `flag` | `{ kind: 'flag', true: ['premium_family'], false: [''], numericOne: true }` | `true` / `false` / `null` |
|
|
212
|
+
| `enum` | `{ kind: 'enum', normalize: 'snake', map: { paid_in_full: 'paid' }, default: 'other' }` | mapped value |
|
|
213
|
+
| `int` | `{ kind: 'int', min: 1, else: 1 }` | whole number |
|
|
214
|
+
| `phone` | `{ kind: 'phone', national: 10, country: '7', plus: true }` | `+7…` |
|
|
215
|
+
|
|
216
|
+
Date orders: `ymd`, `dmy`, `mdy`, `compact` (`20261105`), `yymmdd` (pivot 70), `mmdd` / `ddmm` (next such day; past
|
|
217
|
+
`maxDaysAhead` → a year before), `serial`, `serial1900` (spreadsheet 1900 leap bug), `D-MMM-YY` (`monthNames` pack).
|
|
218
|
+
|
|
219
|
+
### Numbers
|
|
220
|
+
|
|
221
|
+
| Operator | Example |
|
|
222
|
+
|---|---|
|
|
223
|
+
| `add`, `sub`, `mul`, `div`, `min`, `max` (lists; a non-number gives `null`, `min`/`max` skip them; `min`/`max` also of one expression giving a list: `{ max: { var: 'periods' } }`) | `{ sub: [{ var: 'total' }, { var: 'paid' }] }` |
|
|
224
|
+
| `mod` (JavaScript's `%`; `null` for `b` = 0) | `{ mod: [{ add: [{ fact: 'weekday' }, 3] }, 7] }` |
|
|
225
|
+
| `sum` (of a list value) | `{ sum: { var: 'instalments' } }` |
|
|
226
|
+
| `neg` (`0` stays `0`, never `-0`), `abs`, `floor`, `ceil`, `round` (+ `digits`; half away from zero, `mode: 'js'`: `Math.round(n * 10 ** digits) / 10 ** digits`) | `{ round: { var: 'rate' }, digits: 2 }` |
|
|
227
|
+
| `ceilDiv` | `{ ceilDiv: [{ var: 'total' }, 3] }` |
|
|
228
|
+
| `share` (decimals of `of` kept; `out: 'decimalText'`: `Number(of)` / parts with `Math.round` at the text's own decimals, written with them, `''` when not positive) | `{ share: { of: { var: 'amount' }, parts: 3 } }` |
|
|
229
|
+
| `percentOff` (to cents) | `{ percentOff: { of: { var: 'amount' }, percent: 15 } }` |
|
|
230
|
+
| `fixed` (+ `trimZeros`, `mode: 'js'` as `round`) | `{ fixed: { var: 'amount' }, digits: 2, trimZeros: true }` |
|
|
231
|
+
| `number`, `count` (list / object size), `chars` (text length) | `{ count: { var: 'items' } }` |
|
|
232
|
+
|
|
233
|
+
### Dates and time (calendar days `YYYY-MM-DD`, the agent's zone)
|
|
234
|
+
|
|
235
|
+
| Operator | Example |
|
|
236
|
+
|---|---|
|
|
237
|
+
| `daysBetween` | `{ daysBetween: [{ fact: 'today' }, { var: 'due' }] }` |
|
|
238
|
+
| `addDays` | `{ addDays: [{ fact: 'today' }, 3] }` |
|
|
239
|
+
| `latestDay`, `earliestDay` | `{ latestDay: [{ var: 'due' }, { fact: 'today' }] }` (= «not before») |
|
|
240
|
+
| `weekday`, `daysUntil` | `{ daysUntil: { var: 'due' } }` |
|
|
241
|
+
| `endOfMonth` (the last day of that day's month) | `{ endOfMonth: { fact: 'today' } }` |
|
|
242
|
+
| `nextWeekday` (0 = Sunday; from `from`, default today, which counts unless `skipToday`) | `{ nextWeekday: 1 }` (the coming Monday) |
|
|
243
|
+
| `secondsBetween` (instants) | `{ secondsBetween: [{ var: 'started' }, { fact: 'now' }] }` |
|
|
244
|
+
| `dayMonth` (+ `order`, `else`) | `{ dayMonth: { entity: 'promised' }, order: 'monthFirst', else: { fact: 'today' } }` |
|
|
245
|
+
| `format` (+ `of`, `emptyAs`) | `{ format: { kind: 'date', pattern: 'DD/MM/YY' }, of: { var: 'due' } }`, `{ format: { kind: 'timestamp', pattern: 'YYYY-MM-DD HH:mm', timeZone: 'Asia/Almaty' }, of: { fact: 'now' } }`, `{ format: { kind: 'timeOfDay', locale: 'en', bands: { morning: 5, afternoon: 12, evening: 17, night: 22 } } }` |
|
|
246
|
+
| `dayTable` | see below |
|
|
247
|
+
|
|
248
|
+
`dayTable`: `{ start, end | { days }, rows?: 'weekdays', maxListed?, tail?, words?: { byOffset?, range? }, row,
|
|
249
|
+
firstRows?, join, lastJoin?, prefix?, suffix?, else?, include?, wordSep?, order?, maxDays? }`; row locals `date day
|
|
250
|
+
month year weekday offset index word`, tail locals `count last`. `end: { days }` takes a number or an expression.
|
|
251
|
+
`include: [{ date, word? }]`: extra days (also outside the range, kept by `rows: 'weekdays'`) merged by date — a day
|
|
252
|
+
already listed keeps its row and its `word` gets the extra words after its own (`wordSep`, default `', '`; empty ones
|
|
253
|
+
dropped); rows by date. `order: 'monFirst'`: rows Monday … Sunday (one weekday's days by date). `maxDays` (default
|
|
254
|
+
366): days the range lists at most.
|
|
255
|
+
|
|
256
|
+
```ts
|
|
257
|
+
// «Monday -> 2026-11-23; Tuesday -> …; Sunday -> 2026-11-22» (the next of each weekday, today included)
|
|
258
|
+
{ dayTable: { start: { fact: 'today' }, end: { days: 6 }, order: 'monFirst', join: '; ',
|
|
259
|
+
row: { let: { name: { format: { kind: 'date', pattern: 'dddd', locale: 'en' }, of: { local: 'date' } } },
|
|
260
|
+
value: { template: '{name} -> {date}' } } } }
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
{ dayTable: {
|
|
266
|
+
start: { fact: 'today' }, end: { var: 'due' }, maxListed: 3,
|
|
267
|
+
words: { byOffset: { 0: 'today', 1: 'tomorrow' } },
|
|
268
|
+
row: { cases: [{ when: { local: 'word' }, value: { template: '{word}' } }], else: { template: '{date|date:dayMonth}' } },
|
|
269
|
+
join: ', ', lastJoin: ' or ', tail: { template: ' and {count} more days' },
|
|
270
|
+
} }
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Picks and randomness
|
|
274
|
+
|
|
275
|
+
| Operator | Example |
|
|
276
|
+
|---|---|
|
|
277
|
+
| `pick` (FNV-1a of `seed`, `weights`, `override`, `emptySeed`) | `{ pick: { seed: { var: 'dialog_uuid' }, options: ['A', 'B'], override: { var: 'persona' } } }` |
|
|
278
|
+
| `pickOne` (random) | `{ pickOne: ['Hi!', 'Hello!'] }` |
|
|
279
|
+
| `random` | `{ random: { int: [1000, 5000], step: 500 } }`, `{ random: { digits: 6 } }`, `{ random: { daysFromToday: [1, 5] } }`, `{ random: { oneOf: [...] } }` |
|
|
280
|
+
| `hash` (+ `mod`, `scale`) | `{ hash: { template: '{call_uuid}#asr' }, scale: 100 }` (percent bucket) |
|
|
281
|
+
| `abArm` (A/B arm → `{ variant, source }`) | `{ abArm: { arms: [1, 2, 3, 4], override: { var: 'variant_in' }, seed: { replace: { var: 'msisdn' }, re: /\D/g, with: '' } } }` — the arm `override` names (a number arm: by a number or a text of digits) → `source: 'dialer'`; `enabled` (Condition) false → `fallback` (default the first arm), `'default'`; else `arms[fnv1a(seed) % n]` → `'ab_test'`, at random when the seed is empty (`emptySeed: 'first'`: the first arm) |
|
|
282
|
+
|
|
283
|
+
### Structure
|
|
284
|
+
|
|
285
|
+
| Operator | Example |
|
|
286
|
+
|---|---|
|
|
287
|
+
| `object` (+ `omitEmpty`; `{ omit: true }` drops a key) | `{ object: { loan_id: { var: 'loan_id' }, ptp: { entity: 'ptp.date' } } }` |
|
|
288
|
+
| `merge` | `{ merge: [{ var: 'base' }, { object: { extra: 1 } }] }` |
|
|
289
|
+
| `zip` (= lookup spread into columns) | `{ zip: { keys: ['r1', 'r2'], values: { lookup: { of: { row: 'result' }, table: { … } } } } }` |
|
|
290
|
+
| `json`, `parseJson` | `{ json: { object: { … } } }` |
|
|
291
|
+
| `list` (+ `split`) | `{ list: { var: 'channels' }, split: ';' }` |
|
|
292
|
+
| `each` / `to`, `select` / `where` (locals `item`, `index`) | `{ select: { var: 'items' }, where: { local: 'item.qty', gt: 0 } }` |
|
|
293
|
+
| `at` | `{ at: { var: 'items' }, path: '0.title' }` |
|
|
294
|
+
| `tokens` | `{ tokens: { var: 'channels' }, split: ';', table: [['sms', 'SMS']] }` |
|
|
295
|
+
| `unique` | `{ unique: { var: 'tags' } }` |
|
|
296
|
+
| `rowExcept` (report rows: the row written so far without these keys, in row order, `undefined` left out) | `stats: { json: { rowExcept: ['msisdn', 'result', 'stats'] } }` (every other column as one JSON text) |
|
|
297
|
+
|
|
298
|
+
### Choices (`AgentSpec.choices`, `blocks.md`)
|
|
299
|
+
|
|
300
|
+
`{ choice: set, op, of? }` — read off a text (`of`, default the line handled): `chosen` (the one option the words pick,
|
|
301
|
+
`null` for none or more), `picked` (every option picked), `said` (the words that picked the chosen one), `named` (the
|
|
302
|
+
options whose value a number of the text equals); off the transcript (offers): see `blocks.md`.
|
|
303
|
+
|
|
304
|
+
### Transcript values
|
|
305
|
+
|
|
306
|
+
| Operator | Example |
|
|
307
|
+
|---|---|
|
|
308
|
+
| `transcript` (`from`: the lines of a speaker-prefixed text, as in transcript conditions; `collapse`: every run of white space in a line one space) | `{ transcript: { agent: 'bot', caller: 'human', speakerSep: ': ', lineSep: '; ', from: { text: { fact: 'service.call_transcript' }, agent: 'AGENT:', caller: 'USER:' } } }` |
|
|
309
|
+
| `lastAgentLanguage` | `{ lastAgentLanguage: { skipFirst: true, letters: { kaz: 'kk' }, script: { rus: 'cyrillic' }, default: 'kaz' } }` |
|
|
310
|
+
| `scriptOf` (the key of the script a text is written in; `ScriptRule`) | `{ scriptOf: { of: { fact: 'line' }, scripts: { hi: 'Devanagari', ta: 'Tamil' }, minLetters: 1, minShare: 0, else: 'en' } }` — most letters wins, a tie the key listed first |
|
|
311
|
+
| `replyAsr` (the last `voice.asrByReply` key, `ignore`d keys skipped, through `map`; `default` when none) | `{ replyAsr: { ignore: ['en'], map: { hi: 'hindi', ta: 'tamil' }, default: 'english' } }` |
|
|
312
|
+
| `languageRequested` (the language the caller last asked for, or turned to by refusing the other, by the locale packs' request words; through `map`; `from`: the caller lines of a speaker-prefixed text) | `{ languageRequested: { map: { kk: 'переход на Казахский язык', ru: 'переход на Русский язык' } } }` |
|
|
313
|
+
| `lineTally` | `{ lineTally: { classes: [{ unit: '*', mode: 'count' }] } }` → `{'greeting': 1, 'notice': 2}` |
|
|
314
|
+
| `lastAgentQuestion` (the newest agent sentence ending in `?` that `skipSentence` does not match, from the newest line back; `split: 'punctuation'`: sentences end after every run of `.!?…`; `''` when none) | `{ lastAgentQuestion: { skipSentence: /(?<!\p{L})alo(?!\p{L})/iu, split: 'punctuation' } }` |
|
|
315
|
+
|
|
316
|
+
`lineTally` counts agent lines into one value (a legacy KPI column). Lines: the call's, or `lines: { text, agent,
|
|
317
|
+
caller }` (a speaker-prefixed transcript text; a line without a prefix continues the one before). `first`: the first
|
|
318
|
+
agent line counts as this key. `classes` are tried in order per agent line: `unit` (only lines with a mixer unit;
|
|
319
|
+
`'*'` any), `when` (a condition; `{ line }` / `{ fact: 'line' }` read the line, the call in view is the conversation
|
|
320
|
+
before it), `key` (default the unit; local `unit`), `mode` `seen` (1, default) or `count`, `once` (only while its
|
|
321
|
+
key is not counted: a later line falls to the next classes). `other`: lines no class took are counted under this
|
|
322
|
+
key, written last. `last: { when, unlessKeys, key }`: a last agent line for which `when` holds (and no `unlessKeys`
|
|
323
|
+
counted) is taken back from `other` and counted under `key`. `format`: `pyDict` (`{'k': n, …}`, default), `json`,
|
|
324
|
+
`object`; nothing counted: `empty` (default `null`).
|
|
325
|
+
|
|
326
|
+
## Locale helper options (defaults unchanged)
|
|
327
|
+
|
|
328
|
+
`parseAmount(raw, { separators: 'lastIsDecimal' })`, `parseCalendarDate(raw, { order: 'monthFirst', trailingTime: true })`,
|
|
329
|
+
`cleanName(raw, { decode: 'uri' | 'none', punctuation: 'keep' | 'space' | 'drop', case, caseLocale })`, `timeOfDay(hour,
|
|
330
|
+
{ bands })` of the packs; date patterns also take `YY`, the `timestamp` format kind `HH H mm ss`.
|
|
331
|
+
|
|
332
|
+
## Mapping from the catalog (CATALOG § 1.1–1.2)
|
|
333
|
+
|
|
334
|
+
Renamed or reshaped: `{ fact, … }` named facts are `{ condition }` / `{ value }`; `date: { format, order, days }` in
|
|
335
|
+
`Cmp` → `read` + `days`; `notBefore` → `latestDay`; `daysUntil.format/rollover` → `read` with `mmdd`; `pick.hash` is
|
|
336
|
+
always FNV-1a; `pickOne.by: 'callHash'` → `pick` with a seed; `random.times/prefix` → `join` over `each`;
|
|
337
|
+
`object.when` / `$if` / `$spread` → `cases` with `{ omit: true }` / `merge`; `lookupSpread` → `zip` + `lookup`;
|
|
338
|
+
`mul … round: 'cent', out` → `round` / `fixed`; `length` → `chars` (text) / `count` (list); `list.json/itemKeys` →
|
|
339
|
+
`json` / `each`; `{ text }` Text-operator dropped (use `template`); actions chosen by conditions are `{ choose }`.
|
|
340
|
+
Not in this wave: `{ note }` (T10), refs `stage` / `openQuestion` /
|
|
341
|
+
`asked` (T11), `slot` (T18), `selection` (T15), `storage` / `global` (read them into input fields), `dayTable.dense` /
|
|
342
|
+
`bucket` (`extra` / `merge` are `include`), amount `singularOne`.
|