@voctiv/agent-runtime 0.2.1 → 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 +8 -2
- 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,586 @@
|
|
|
1
|
+
# The conversation blocks and how they interact
|
|
2
|
+
|
|
3
|
+
Blocks: `opening`, `gates`, `turn`, `overtalk`, `silence`, `voicemail`, `rules`, `closing`, `transfer`. One engine runs
|
|
4
|
+
them for every agent (the engine, `src/templates/engine/`) on one call media; the agent file only sets values.
|
|
5
|
+
This page describes the order of things in a call, then each block, then actions, then what the engine runs today
|
|
6
|
+
(§ What the engine runs, § What the engine refuses).
|
|
7
|
+
|
|
8
|
+
## A call, in order
|
|
9
|
+
|
|
10
|
+
1. **Answer.** The leg is answered (or the script started at INVITE with `outboundMode: 'from_invite'` and waits for
|
|
11
|
+
200 OK). Recognizer(s), TTS, ambient start. Voicemail detectors start listening.
|
|
12
|
+
2. **Opening.** Steps of `opening` run in order (see below). Eager `llmGreeting` requests go out first, at answer.
|
|
13
|
+
Caller lines during the opening go through voicemail detection, rules with `when.phase: 'opening'`, and the current
|
|
14
|
+
step. A line heard while a step plays belongs to the `listen` step right after it (or to the `listen` step whose
|
|
15
|
+
re-prompt plays) as its `speechOverPrevious` says; it is taken when the line or clip is done. Otherwise (e.g. speech
|
|
16
|
+
over the LLM greeting) it is dropped. Silence is handled by the `listen` step's own ladder, not by
|
|
17
|
+
`silence.ladder`. The result stays `greeting drop` until the opening ends or the caller makes a turn; then it is
|
|
18
|
+
`default`.
|
|
19
|
+
3. **Handoff.** When the steps end, the LLM takes over: its first request is either the LLM greeting already prepared
|
|
20
|
+
(`llmGreeting`) or the `prompt.handoff` text describing what was said.
|
|
21
|
+
4. **Conversation loop**, for each caller line:
|
|
22
|
+
1. The line passes `voice.corrections`, `voice.dropLine`, `minPeakVad`.
|
|
23
|
+
2. Overtalk decides whether it is a turn now, a buffered line, or dropped (see Overtalk).
|
|
24
|
+
3. Voicemail detectors read it (until the first turn, or the whole call).
|
|
25
|
+
4. The reply language reads it (provisional pick, explicit request, one-way fallback).
|
|
26
|
+
5. Rules on `callerLine` run in order; the first matching rule acts unless it has `continue: true`.
|
|
27
|
+
Rules with async matchers (NLU) delay the turn; `whileWaiting` says a filler if that takes long.
|
|
28
|
+
6. When no rule answered the line, gates read it (marks, take-backs, the ask limit).
|
|
29
|
+
7. If no action replaced the turn, the LLM is asked (with marks from rules/gates, `annotateCaller` filter applied).
|
|
30
|
+
8. The reply streams through `turn.filters` to TTS as its chunks come (§ Turn).
|
|
31
|
+
9. Agent-line rules (`agentLine`) and gates (`asked`, `passedBy`) read the reply; after playback,
|
|
32
|
+
`agentLineHeard` / `agentLineCut` rules fire.
|
|
33
|
+
10. If the reply matches `closing.goodbye`, the call closes after it is spoken.
|
|
34
|
+
5. **Silence.** After every agent line the silence timer starts; rungs of `silence.ladder` fire in order.
|
|
35
|
+
6. **End.** Hangup (agent, caller, timeout, error). Then extraction, result decision, report row, integrations,
|
|
36
|
+
redial booking — see `business.md`.
|
|
37
|
+
|
|
38
|
+
## Opening steps
|
|
39
|
+
|
|
40
|
+
| Step | What it does | Moves on when |
|
|
41
|
+
|---|---|---|
|
|
42
|
+
| `play` | Plays (after `delayMs`, default 0) a CMS record (by name; `{voice}` in the name picks the voice variant's clip) or URL. Record names are looked up once, at answer. `alias` names the clip on the queue (default: the record name). `text` is written to the transcript (also when the caller hung up during the clip, as far as the platform played it); when the record is missing, `text` is spoken by TTS. Clips are not cut by the caller unless `bargeIn: true`. The step ends `tailMs` after the clip was handed over (a record: played out; TTS: synthesized; `waitFinished`: when the agent queue says the item finished — a clip the caller hung up on is then not in the transcript); the silence window of the next `listen` step counts from there. `voice.clipTranscript` also writes the clip's text to the platform's call transcript. | clip handed over, then `tailMs` |
|
|
43
|
+
| `say` | Speaks fixed text (TTS); `bargeIn: false` plays it whole. | playback ends (the last step does not wait) |
|
|
44
|
+
| `llmGreeting` | Asks the LLM for the greeting with `signal` as the user message. With `eager: true` the request goes out at answer, before the first step, and streams into a buffer, so the greeting plays the moment its step comes. The step holds until the greeting played out (`turn.drainFloor` when set, then the agent queue's drain, capped by `turn.drainCeiling`); the caller cannot cut it, and speech over it is dropped. A greeting that ends on the goodbye marker closes the call. `fallback` (a clip: `record` or `url` with `text`, or a `Text` said by TTS with the reply voice): when the greeting streamed no text (its stream failed, or `firstTokenMs` passed with no chunk) it plays instead, counts as playing at least its text × `turn.drainFloor.msPerChar` (and a clip's `minPlayMs`) from the moment it is played, and its text goes to the transcript. `bargeInAfterMs`: the caller can cut the greeting that long after it started; a cut greeting ends the opening at once — speech heard before the cut is dropped, the line that cut it is the first turn. `waitMs` bounds the wait of a `listen` step's `toLlmWhen` for the eager request. | greeting played out |
|
|
45
|
+
| `listen` | Waits for a caller line. `silence` is a ladder of its own (rung n acts on the n-th silence; rungs may `play` a re-prompt, `next` to go on anyway, or `close`; the n-th silence waits the n-th rung's `afterMs` (the last one past the end); when the first differs from `silence.beforeFirstLineMs`, the step waits its own window and `beforeFirstLineMs` applies once the opening is over); each window counts from the end of the agent's last line (the hello, the re-prompt); `holdWhileSpeaking: { pollMs, maxMs }`: the window does not start over when the caller speaks — run out while they speak, it fires as soon as they stop (polled), at most `maxMs` later (a «say it unprompted after N ms» greeting that never talks over an answer); `transcriptLine` (e.g. `[silence]`) is written as a caller line each time a rung fires; when the rungs run out the step keeps waiting (no rungs: the first silence goes on). `speechOverPrevious` (default `'answer'`) says what speech heard over the previous step (or over a re-prompt) means: `'answer'` (it is the answer), `'drop'`, or `{ keepIfWithinMs }` (only if it ended within N ms of the step's end; older speech is kept as the speech before the question: it still picks the language and goes to the handoff). `answer` sets where the caller's line goes: `'toLlm'` (default — a caller turn; with `prompt.handoff` it goes to the first LLM turn as `{firstReply}`, without one it is the first LLM turn once the opening is over), `'transcriptOnly'` (written, not a turn — e.g. answers to «hello?»), `'discard'`. `toLlmWhen` (a matcher): an answer that matches is a caller turn whatever `answer` says — the first LLM turn — and the rest of the opening is skipped (an LLM greeting still to come is not played; its eager request is waited for first, at most its `waitMs`, so the turn follows it in the LLM's history); for answers to «hello?» that already say what the caller wants («who is this?», «don't call me»). `voiceWithoutTextMs`: VAD heard the caller but no final came — the step is answered with nothing `voiceWithoutTextMs` after the voice ends, at the latest `voiceWithoutTextMaxMs` (default the same) after the opening's first voice (also voice over the clip before the step); a clip still on the wire (or its tail) defers it in 200 ms steps; off once the LLM greeting starts. | caller line, or a rung with `next` |
|
|
46
|
+
| `language` | Picks the reply language among `languages` from the caller's answer (or nothing) using the locale packs' `evidence` (§ The language ladder). `provisional: true` lets the pick be revised on later lines until settled. `askedIn` (a language or a list) reads a plain «yes» to the opening question asked in that language as consent to it (the first LLM turn settles the language the question was asked in); `plainYes` (a matcher) says what a plain «yes» is (default: every word in a `yes` lexicon; e.g. some yes word, every other word a filler like «алло»). `fallback: { to, afterLines, resetOnOther }` switches one way after N lines plainly in that language (a line with evidence of another language resets the count). `honourRequests` (default true) switches when the caller asks for a language (or refuses one) at any point. `neutral`: the agent's own words with no evidence (brand names). `answers: [{ match, language }]`: the opening asked a question whose short answer names the language («may I go on in this language?»): an opening answer (or the speech before the question) matching an entry picks its language for good before the ladder (first match; e.g. `{ tokens: { ignore: 'lead', core: 'consent' } }` → the asked language, `core: 'no'` → the other). `changeMark` (`{language}`, `{reason}`) goes in front of the next LLM turn after a change in the conversation. `asrSwitch: 'openingEnd'`: the recognizer of a settled pick starts as the opening ends (right after its last line went out), not at the caller's next turn (default `nextTurn`). While provisional, `voice.asr.undecided` listens; the recognizer of the settled language starts at the next caller turn. | always (immediately) |
|
|
47
|
+
| `gate` | Says a gate's `question` now, in the reply language (`alias` names the line; the caller can cut it unless `bargeIn: false`). As the last step, the opening ends as the question starts (its answer is a conversation line). | the line is queued |
|
|
48
|
+
| `close` | The last step (or an earlier one with `when`: the call ends there when it holds): ends the call (`result` may be an expression of the call) — says `text` (uninterruptible; none by default; `alias`: its mixer alias, default the step's key), then hangs up `graceMs` after it played out (default `closing.hangupGraceMs`) with `result`. An agent whose opening ends this way has no conversation: `prompt`, `silence`, `closing` may be left out and `voice.asr` may be `{}` (no recognizer). | — |
|
|
49
|
+
|
|
50
|
+
A `play` step may play a **sequence** read from the call: `records`, an expression giving the list
|
|
51
|
+
(one record per digit of a code: `{ each: { list: { var: 'otp' }, split: '' }, to: { lookup: { of: { local: 'item' },
|
|
52
|
+
table: { '0': 'digit_zero', … } } } }`; empty items dropped), `gapMs` of pause between two clips (not after the last); a missing record is spoken by TTS of its text; `recordSet` lists every record the sequence may name, looked up
|
|
53
|
+
once at answer with the other clips (the lookups and their log lines then do not follow the call's data; only the
|
|
54
|
+
sequence's length is logged). An opening step's clip queues behind the step before it (a clip spoken by TTS may still
|
|
55
|
+
be playing); re-prompts and actions stop what plays.
|
|
56
|
+
|
|
57
|
+
Every step takes `when` (a condition): the step runs only on a call where it holds (read when its turn comes);
|
|
58
|
+
otherwise it is skipped (an eager `llmGreeting` whose `when` is false is not requested at answer). E.g. a call the
|
|
59
|
+
caller placed skips the liveness clip and the listen step, so its LLM greeting plays at once; a `close` step with `when`
|
|
60
|
+
says one fixed line and ends a call that must not go on.
|
|
61
|
+
|
|
62
|
+
Typical openings:
|
|
63
|
+
|
|
64
|
+
- **Recorded hello + LLM greeting** (NG school): `play HELLO_MAIN` (`tailMs` 400) → `listen` (`answer:
|
|
65
|
+
'transcriptOnly'`, `transcriptLine: '[silence]'`, ladder: `play HELLO_NULL`, then close `silence`) → `llmGreeting`
|
|
66
|
+
(eager).
|
|
67
|
+
- **Fixed greeting, language pick, identity question** (fixed-phrase school): `say` bilingual greeting →
|
|
68
|
+
`listen` (`speechOverPrevious: { keepIfWithinMs }`, ladder: one rung `next`) → `language` → `gate identity`.
|
|
69
|
+
|
|
70
|
+
### The language ladder
|
|
71
|
+
|
|
72
|
+
For a line (labels like `[ru]` dropped, words lower case, one-letter words and the packs' `neutralWords` + the step's
|
|
73
|
+
`neutral` ignored; the step's `notNeutral` takes words off the packs' lists — another campaign's product words): (1) a request for one language, or a refusal of one (`evidence.request` / `reject`; a question about
|
|
74
|
+
a language — `metaQuestion` — is none; a bare language name needs a `requestCue` unless the line is ≤ 3 words) picks it
|
|
75
|
+
for good; (2) the language with the most distinct `strong` words wins (reason `<name>_marker:w1,w2,w3`); a tie with
|
|
76
|
+
any strong word keeps the first language (`mixed_evidence`); (3) two distinct `weak` words of a language pick it
|
|
77
|
+
(`<name>_weak_pair`); (4) a single line labelled with a language's name, ≥ 3 words, no strong word of the first
|
|
78
|
+
language and ≥ 2 words (≥ 40 %) with that language's `letters` picks it (`<name>_selected_reading`); (5) ≥ 4 words and
|
|
79
|
+
≤ 20 % of them with another language's `letters` picks the first language (`<name>_plain_orthography`); otherwise the
|
|
80
|
+
first language, provisional (`neutral_reply`; `no_reply` for nothing). The one-way fallback to `to` counts a line when
|
|
81
|
+
it has no strong/weak word of another language and either two strong words of `to` or the plain-orthography shape.
|
|
82
|
+
|
|
83
|
+
## Gates
|
|
84
|
+
|
|
85
|
+
A gate is a question the call must settle (who is on the line, consent to continue). It works across the whole
|
|
86
|
+
conversation, not only in the opening:
|
|
87
|
+
|
|
88
|
+
- The gate notices the question when the agent asks it — the fixed `question` (opening step `gate`) or any LLM line
|
|
89
|
+
matching `asked`.
|
|
90
|
+
- The next caller line is classified by `answers` (first matching class; none = `other`).
|
|
91
|
+
- `on[class]` sets `passed` and/or adds a `mark` to the next LLM turn (e.g. `<<< identity_confirmed;`).
|
|
92
|
+
- `unheardMark`: an answer to a question the caller did not hear (the agent line was cut) is ignored and the LLM is told
|
|
93
|
+
so with this marker.
|
|
94
|
+
- After `maxAsks` asks without a passing answer, `onExhausted` runs (usually `close` with a fixed phrase).
|
|
95
|
+
- Texts and conditions read it as `{ flag: '<id>.passed' }`.
|
|
96
|
+
|
|
97
|
+
The gate reads every caller line that no rule answered, in this order: an agent line
|
|
98
|
+
matching `passedBy` (the agent went past the question, e.g. named the debt) passes it silently; the line's class is the
|
|
99
|
+
first matching `answers` entry; a class with `on.passed` passes only when the agent line it answers is the question —
|
|
100
|
+
the last agent line, skipping lines matching `skip` («please repeat»), or a line matching `reask.match` («can you hear
|
|
101
|
+
me?») for the classes in `reask.answers` — and every caller line since the agent's last line is of a passing class; a
|
|
102
|
+
pass puts `on[class].mark` in front of the turn. A pass whose reply the caller did not hear (the next line came before
|
|
103
|
+
it played out) is taken back unless that line passes too, with `unheardMark`. A line of no class after `maxAsks`
|
|
104
|
+
agent lines matching `asked` (not `skip` / `reask`) runs `onExhausted`.
|
|
105
|
+
|
|
106
|
+
## Turn
|
|
107
|
+
|
|
108
|
+
| Field | Default | Meaning |
|
|
109
|
+
|---|---|---|
|
|
110
|
+
| `filters` | none | Reply text filters in order (below). |
|
|
111
|
+
| `emptyReply` | none | Without it an empty reply just hands the turn back (the silence ladder goes on). With it: empty replies in a row are counted (an empty greeting counts too, a reply with text resets the count); below `max` the turn is retried (`retry: 'ellipsis'` sends `prompt.silenceSignal`, `'same'` the same request, `'none'` waits); at `max` the next unused fixed `probe` is said instead (the count starts over), and with no probe left `onExhausted` runs (usually close with `bad connection`). Any `retry` with any `max`, with or without probes. |
|
|
112
|
+
| `playedOut` | queue empty | When a line counts as played out after its `drainFloor`: when the agent queue runs dry (default), or `{ by: 'queueIdle', startAllowanceMs }` — once the queue's first clip started (within `startAllowanceMs`, else at once), nothing more was queued for 500 ms and 45 ms per spoken character passed since that start (fixed); a closing line waits up to its drain ceiling then. |
|
|
113
|
+
| `abortedRetries` | 0 | A reply whose playback ended empty before its LLM stream did (the stop of the turn before it cut it) is requested again with the same text up to N times before it counts as empty (with the prompt variables as they are now; with `annotateCaller.perRequest` the caller's words are annotated anew). |
|
|
114
|
+
| `drainFloor` | none | Hold every line (reply, fixed line, greeting) at least `max(minMs, msPerChar × spoken chars)`, counted `from` the turn start, the first chunk, or playback start (credited only with what already played; nothing played yet: from now), before the agent queue's drain is waited for (and the next silence window opens); `staticFrom`: how a fixed line counts. Without it a line has played out when the agent queue runs dry (an empty reply: at once). |
|
|
115
|
+
| `drainFloor.from: 'spokenChunk'` | — | Like `firstChunk` (the first chunk that reached TTS), but a reply nothing of which was spoken (a filter took it all) is held from now. |
|
|
116
|
+
| `drainCeiling` | `{ msPerChar: 90, minMs: 20000 }` | Never wait longer than this for playback (stuck TTS). |
|
|
117
|
+
| `maxLines` | none | `{ count, do }`: once `count` agent lines played out (the opening's fixed lines included), `do` runs at that drain (e.g. `{ hangup: 'failsafe', result: 'failsafe' }`: a cap on the call's length in replies). |
|
|
118
|
+
| `holdLivenessPrompt` | none | `{ match, maxMs }`: a caller line matching `match` while the LLM turn in flight has streamed nothing yet (for at most `maxMs`) goes to the transcript only; the reply in flight goes on. |
|
|
119
|
+
| `carryOn` | none | `{ startGraceMs, maxPlayedMs, mark, lapsedMark }`: a caller who was only pausing takes the reply back. Speech that starts while the reply to their line is not on the line yet (or within `startGraceMs` of its first audio) and brings words of its own (not the answered line again, not a `voice.dropLine` filler) stops the reply as soon as those words come (a partial or the final), at most `maxPlayedMs` into its audio; no turn starts then. Their next line goes to the LLM behind `mark` (`{line}`: the line the stopped reply answered; the new turn may be taken back the same way, as the two lines together); a silence window that runs out first asks the LLM with `lapsedMark`. The media reads speech starts and partials only with it. |
|
|
120
|
+
| `supersede` | `'replace'` | A caller line said while the reply to their previous line is still in the making (nothing of it plays yet) supersedes it: `'join'` asks the LLM with the previous line's request text and the new line joined (the caller paused mid-sentence) — one caller turn; the transcript keeps both lines. |
|
|
121
|
+
| `continuation` | none | `{ windowMs }`: a caller line the recognizer split — its tail heard over the reply within `windowMs` of the caller's previous line, not contained in it — rejoins that line: when answered, the two go to the LLM as one and the transcript's last caller line is rewritten (when it is still the last line). (A reply taken back because the caller went on speaking: `turn.carryOn`.) |
|
|
122
|
+
| `review` | none | `{ start, held }` rules: a reply judged before any of it is spoken (§ Verdicts). |
|
|
123
|
+
| `replyRules` | none | Rules on the streaming reply as data, one reply filter per set (§ Reply rules). |
|
|
124
|
+
| `regenerateEmpty` | none | `{ signal }`: a reply with no words that started no transfer, on a turn that is not itself a regeneration (not the greeting), is asked again once with `signal` (a `Text`; an expression reads the call and the caller's line, `null`: not asked). |
|
|
125
|
+
|
|
126
|
+
### Reply filters
|
|
127
|
+
|
|
128
|
+
| Filter | Effect |
|
|
129
|
+
|---|---|
|
|
130
|
+
| `cutAfter { match, at }` | Stop the reply after a marker (goodbye, end-of-turn tag): at once (`at: 'match'`), or when the next chunk comes (`'nextChunk'`: the reply's text so far matches, the following chunk is not spoken; a tool call's second completion round is cut this way). |
|
|
131
|
+
| `strip { match }` | Remove tags/labels from the spoken text. |
|
|
132
|
+
| `labels { lines }` | A reply that is only a label is replaced by that label's line (a map label → `Text`). `match: 'snakeCase'` (any `snake_case` word alone, any case, trailing `.…,:;!?`, looked up lower case), `unknown: 'drop'` (a label not listed says nothing; default `keep`), `greeting: false` (not on the greeting turn). |
|
|
133
|
+
| `closingGuard` | Where `closing.guard` reads the reply among the filters (default first; put it after `labels` so a label's line is judged). |
|
|
134
|
+
| `replyRules` | Where `turn.replyRules` run among the filters (default first). |
|
|
135
|
+
| `scriptLeak { allow, retry }` | Drop sentences mostly in another script than the reply language (model reasoning leaking into speech: Latin letters more than half of a sentence's Latin and Cyrillic letters); `allow` keeps listed words (an expression of the call: this call's words, e.g. the names); `retry`: a reply all of whose sentences were dropped is asked again with this note in front of its request, once until a reply with words comes. |
|
|
136
|
+
| `replace { match, with }` | Text replacement before TTS. |
|
|
137
|
+
| `numbersAsWords { languages? }` | Figures in the reply as words of the reply language (the pack's `format.text`), written into the reply — the transcript and the extractor read the words. `languages`: only replies in these. A figure the stream split («1» + « 999») is held until the next chunk settles it. |
|
|
138
|
+
| `insertAfter { match, text, once }` | Insert a line after a chunk that matches (e.g. a disclosure after the introduction); once per call unless `once: false`. A line inserted after the reply's first sentence only when the caller asked something is `turn.replyRules` `insertAfterFirst`. |
|
|
139
|
+
| `wholeWords { space? }` | Cut the stream at word boundaries only; `space: 'start'` keeps the space with the word held back (a piece never ends in a space; default `end`). |
|
|
140
|
+
| `annotateCaller { with, perRequest? }` | Change the text sent to the LLM for the caller's line (add notes, parsed dates; notes as data: `annotateCaller.notes`, `blocks.md`). `perRequest`: the note is made from the caller's words for every request (an aborted retry is annotated anew) and the echo check compares with the words, not the note. |
|
|
141
|
+
| `annotateCaller { notes, perRequest? }` | The notes as data (`NoteEntry[]`, `blocks.md`): made in order on the caller's words, each with a condition, a detector (day words, a note ladder's rung, a choice) and a place (in front, before the words, after). The note ladders' state is the engine's; `perRequest` makes the notes anew read only (a ladder rung waiting to be heard is given again, not counted). |
|
|
142
|
+
| `cutAtSentence { match, regenerate? }` | The reply passes one sentence at a time and stops at the first sentence matching (the model's own reasoning): nothing of it or after it is spoken. When nothing at all was spoken and no transfer started, the turn is asked again once with `regenerate` (not on a regeneration, not on the greeting). Text a cut reply held back still goes to the transcript. |
|
|
143
|
+
|
|
144
|
+
An unclear-reply ladder (the first «Sorry, I did not catch that» re-ask whole, the second without its probe
|
|
145
|
+
sentence, the third closes the call; the count is a call variable the prompt reads) is data, `turn.replyRules`
|
|
146
|
+
`unclearLadder` (§ Reply rules):
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
turn({ replyRules: [{ unclearLadder: {
|
|
150
|
+
probe: /^\s*sorry, i did not catch that/i, rungs: 2, countVar: 'unclear_streak',
|
|
151
|
+
onExhausted: { close: 'The line is bad, I will call you back…', result: 'default' },
|
|
152
|
+
} }] })
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**How a reply is spoken (every agent).** The reply goes to TTS as its chunks come (the `say()` starts with the
|
|
156
|
+
request). A caller line before the first chunk is a new turn: the reply in flight is dropped (superseded) and the new
|
|
157
|
+
request goes out. Once the first chunk came, speech over the reply is overtalk (below). Holding a reply until its first
|
|
158
|
+
chunk was measured on both replayed prod agents and dropped: it changed nothing for one and broke the other's recovery
|
|
159
|
+
from a stream that fails before its first chunk (that must count as an empty reply and be retried).
|
|
160
|
+
|
|
161
|
+
`emptyReply` runs two ways. `{ retry: 'ellipsis', max: 1 | 2, onExhausted: [] | [{ hangup, result }] }` — with `max: 2`
|
|
162
|
+
the first of empty replies in a row is asked again with `prompt.silenceSignal` (an `ellipsis` file that names
|
|
163
|
+
`errorEvent` or closes with a line in `onExhausted` runs the counted way below, asking again with the silence text). `{ retry: 'same' | 'none', max, onExhausted,
|
|
164
|
+
errorEvent?, erroredResult? }` (or any `abortedRetries`): a reply cut before its stream ended is asked again
|
|
165
|
+
(`abortedRetries`, not counted); otherwise it counts, and below `max` is asked again with the same request text (a reply
|
|
166
|
+
that carried the LLM's `errorEvent` is not asked again); at `max` `onExhausted` runs (e.g. `{ close: '…', result:
|
|
167
|
+
'default', alias }`), with `erroredResult` as the result when the last reply carried the error. An empty greeting counts;
|
|
168
|
+
any reply with text resets both counts. `sayTimeoutMs` (default 30 000) counts a line whose synthesis never settles as
|
|
169
|
+
played.
|
|
170
|
+
|
|
171
|
+
## Overtalk (caller speaks over the agent)
|
|
172
|
+
|
|
173
|
+
| Field | Meaning |
|
|
174
|
+
|---|---|
|
|
175
|
+
| `pendingMs` | A line heard within N ms after a turn started, before any of it plays, is speech over the agent (buffered). |
|
|
176
|
+
| `overSilenceTurn` | `'answer'`: a caller line heard over the agent's reply to a silence turn (the re-engagement the ladder asked for) is a turn at once, not buffered (default `'buffer'`). |
|
|
177
|
+
| `guardDrop` | Within `guardMs` a line matching this is dropped too (a bare call: «hello?»); other lines are buffered. |
|
|
178
|
+
| `guardMs` | With `dropEcho`: finals heard in the first N ms of a reply's playback are dropped as echo. Without `dropEcho` such finals are buffered like any other speech over the agent (the value documents the agent's guard). |
|
|
179
|
+
| `dropEcho` | Drop a final that repeats the line that triggered the reply (echo). |
|
|
180
|
+
| `interrupt` | Absent: speech never cuts a reply (it is buffered). When speech interrupts the reply: `minChars` of a partial, `confirmMs` of speech, `minVad`, and/or words `match` (usually `{ lexicon: 'interrupt' }`); `byLength` lets length alone interrupt; `requireText` ignores VAD-only speech; `minCharsOf: 'letters'` counts only letters and digits of a partial toward `minChars`. `intents: { intents, minChars, throttleMs }`: the platform NLU reads partials while the agent speaks (one request at a time, at most one per `throttleMs`, once per line) and one of the intents stops the agent whatever the VAD. `whileSilent`: speech stops the agent also while nothing of it plays yet (the reply still in the making is dropped). |
|
|
181
|
+
| `cutMark` | An `Expr`: the caller's line after a reply they cut gets its value as a mark in front of its LLM request (`{ input: 'heardMs' }`: how long the reply had played; `null`: no mark; the trigger stays the line). |
|
|
182
|
+
| `buffer` | Speech that did not interrupt is buffered (the last line wins) and answered after the reply: `replayAfterGapMs` after the agent queue ran dry (`gapFrom: 'drained'`, default) or after the line was heard (`gapFrom: 'heard'`; at the drain at the earliest) (without `buffer`: at once); `holdWhileSpeaking: { pollMs, maxMs, extend? }` waits while the caller is still talking (`extend: { whilePartialWithinMs, maxHeldMs }`: past `maxMs` it keeps waiting while a partial with text came within `whilePartialWithinMs` and the line was held less than `maxHeldMs`); `merge: { windowMs?, maxChars?, supersede? }` joins pieces (a piece the buffer holds is skipped; one heard more than `windowMs` after the last, or past `maxChars`, replaces the buffer; `supersede`: a piece that holds the whole buffer replaces it); `earlyFragment: { leadMs, replayAfterGapMs }` replays a line heard `leadMs` or more before the drain after the longer gap; `backchannel: { match?, holdMs, marker, markerAt? }` holds a buffered line that matches (default the lexicon `backchannel`) for `holdMs` after the drain instead of the replay gap — a caller line in that time replaces it (dropped, not joined), otherwise it goes to the LLM with `marker` (`markerAt`: `before` the words, default, or `after`; the transcript keeps the words alone); `answerOnSilence` (default true) answers the buffered line when a silence window runs out — `false` leaves it to its replay (armed again then, the replay gap) and no rung runs; a buffered line always goes in front of the caller's next line (one turn); `predating`: a buffered line that predates the reply's question is replayed `replayAfterGapMs` after the drain whatever `gapFrom` says, so the question gets its own answer first (a caller line meanwhile joins the buffer) — `{ by: 'speechBeforeReply' }`: its speech began before the reply played (the rest of the caller's previous line, not an answer to the reply); `{ by: 'heardBeforeDrain', olderThanMs }`: heard more than `olderThanMs` before the drain, when the reply ended on a question (`?`). |
|
|
183
|
+
| `startedBeforeReply` | `{ graceMs }`: speech the caller began before the reply started playing (at most `graceMs` after) is the rest of the line the reply answers — appended to that caller line in the transcript (the extractor reads it) and to the line the echo check compares with; neither buffered nor replayed. Not for a silence turn, a line contained in the trigger, or speech of unknown start. |
|
|
184
|
+
| `reverse` | Drops a buffered line that the reply already covered: by age (`tailMs`: heard more than N ms before the reply ended; with `minTurnMs` and no `positionRatio`: only on a reply that played at least that long, from its first audio), by position in the reply (`positionRatio`, `minTurnMs`: heard in the first ratio of a reply that played at least that long, counted from its first audio, at the drain), short backchannels (`backchannelMaxChars`); `keep` lists lines never dropped (answers, contact attempts). `preReplyMs`: a line heard within N ms of the reply's first audio (begun before the reply) is dropped at the drain unless it matches `keep`; `beforeLastSentence`: a line heard before the reply's last sentence (its last agent-queue item) started is dropped whatever it says (the question is the last sentence; lines within `preReplyMs` are left to that rule); `exceptSilenceTurn`: none of these drops (nor `tailMs`) applies to the reply of a silence turn. Order at the drain: `positionRatio`, `preReplyMs`, `beforeLastSentence`, `tailMs`. lastPart: 'answerAtDrain'`: a line heard once the last part of a fixed line started playing (a `say` in parts; one part: the whole line) is never dropped and is answered at the drain without the replay gap (speech over the closing question of a long answer). |
|
|
185
|
+
| `buffer.keep` | `{ interjectionMaxChars }` (without `merge`): a new line that is no answer (`reverse.keep`) does not replace a buffered answer, and one of at most N characters that is no answer does not replace a longer one — unless the buffered line was heard before the sentence now playing and `reverse.beforeLastSentence` will drop it. |
|
|
186
|
+
|
|
187
|
+
The conversation itself buffers speech over the agent (from the reply's first chunk, or a fixed line's start, until it
|
|
188
|
+
drains): within `guardMs` of a reply's playback a line that is empty or (with `dropEcho`) contained in the reply's
|
|
189
|
+
request is dropped, any other line is buffered (the last wins; `merge` joins); when the reply drains the buffer is
|
|
190
|
+
dropped if `reverse.tailMs` passed since it was heard, it is at most `reverse.backchannelMaxChars` characters long and
|
|
191
|
+
it does not match `reverse.keep`; otherwise it is replayed after the gap (`gapFrom`; `holdWhileSpeaking`: polled every
|
|
192
|
+
`pollMs` while the caller still speaks, up to `maxMs`). A caller line arriving first is joined after the buffer; a
|
|
193
|
+
silence window that runs out answers the buffer (unless `answerOnSilence: false`).
|
|
194
|
+
|
|
195
|
+
## Silence
|
|
196
|
+
|
|
197
|
+
- Rungs count from the end of the agent's last line (the agent queue running dry, or the line's `turn.drainFloor` when
|
|
198
|
+
it is longer; after a clip: the clip handed over plus its `tailMs`), after any reply a rung caused; each rung starts
|
|
199
|
+
a new count. Silence while an LLM reply is still in flight does not
|
|
200
|
+
count. A caller turn starts the ladder over. `when` false skips the rung (the next one acts now). After the last
|
|
201
|
+
rung nothing more happens, so the last rung usually closes.
|
|
202
|
+
- Default rung action (empty `do`): an LLM turn with `prompt.silenceSignal` (placeholders `{attempt}`, `{heardSpeech}`).
|
|
203
|
+
An LLM rung (`{ llm: '…' }`) is not written to the transcript. A rung that closes (`close`, `hangup`) decides its
|
|
204
|
+
result through `results.fromFacts` at `silenceLimit`.
|
|
205
|
+
- `held`: ladder used while the line is held (`hold` action, e.g. «I'll call him»).
|
|
206
|
+
- `afterDroppedLineMs`: the window after a line the filters dropped as noise (`dropLine`, `minPeakVad`), until the next
|
|
207
|
+
real caller line (the first drop re-arms a window already running).
|
|
208
|
+
- `speechWithoutText`: voice heard but no text — counts as a turn after `afterMs`; the first `excused` such turns do not
|
|
209
|
+
count toward the ladder; `do` runs when it fires; `minSpeechMs`: shorter speech is
|
|
210
|
+
noise; `transcriptLine` (e.g. `[inaudible]`) is written as the caller's line each time it fires.
|
|
211
|
+
- `maxAwaitMs`: the longest wait after an agent line for a caller line, however often speech starts and stops: past it
|
|
212
|
+
the next pause (after the speech-without-text window) is a true silence turn and new speech no longer puts it off.
|
|
213
|
+
- `deadAudio`: no audio at all for `ms` (broken media) → actions.
|
|
214
|
+
- `noProgress`: `ms` after the agent's line ended no agent turn started and no caller line came (whatever VAD says) → `do`, or `inOpening` while the opening is on. A `hangup` action without `result` keeps the result.
|
|
215
|
+
- `noWordsMs`: no-words backstop — a silence turn of the ladder when no recognised word (a partial with text) came within N ms of the end of the agent's line, whatever VAD says (noise VAD reads as speech holds the ordinary window off); each partial with text restarts it.
|
|
216
|
+
- After a goodbye that answered a silence turn the call has the flag `closing.afterSilence` (results and integrations
|
|
217
|
+
after the call).
|
|
218
|
+
- `noWordsMs`: after the agent's line played out, the next silence turn comes when no word was recognised for this
|
|
219
|
+
long, whatever VAD reports (line noise read as speech otherwise holds the window off); every partial with text starts
|
|
220
|
+
it over.
|
|
221
|
+
|
|
222
|
+
The window is chosen by situation, and each window that runs out is one silence turn:
|
|
223
|
+
|
|
224
|
+
| Situation | Window | Turn | Counts toward the ladder |
|
|
225
|
+
|---|---|---|---|
|
|
226
|
+
| The line is held (`hold` action), held turns left | `held.rungs[n].afterMs` (the n-th held silence; the last one past the end) | the next `held` rung | no |
|
|
227
|
+
| Voice was heard in the window, no text came | `speechWithoutText.afterMs` | `speechWithoutText.do` | not for the first `excused` in a row |
|
|
228
|
+
| The caller has not said a line yet in the call | `beforeFirstLineMs` (also the opening listen step's window) | the ladder | yes |
|
|
229
|
+
| Otherwise | the n-th rung's `afterMs` for the n-th silence (the last one past the end) | the ladder | yes |
|
|
230
|
+
|
|
231
|
+
The ladder: rung `n` acts on the `n`-th true silence in a row; the last rung acts when the others are spent (usually
|
|
232
|
+
the hangup). `when` false runs `otherwise` instead (or skips). Placeholders `{attempt}` (silence turns in a row of any
|
|
233
|
+
kind) and `{heardSpeech}` fill rung texts. A silence turn the caller cuts before hearing any of it is voided:
|
|
234
|
+
`voidMark` (`{action}` = the rung's `name`) goes in front of the caller's line. `speechLatchMaxMs` disbelieves speech
|
|
235
|
+
that never ends after that long. `noWordsMs`: no recognized word (a partial with text) that long after the agent's
|
|
236
|
+
line ended is a silent turn of the ladder even while VAD hears speech (line noise that VAD reads as speech never lets
|
|
237
|
+
the ordinary window run out); every partial with text starts it again. `deadAudio`: no audio at all for `ms` after a recognizer starts → its actions, only
|
|
238
|
+
while the caller was never heard.
|
|
239
|
+
|
|
240
|
+
## Voicemail
|
|
241
|
+
|
|
242
|
+
Detectors run on caller lines; the first that fires runs `then` (default: hang up at once — no `hangupGraceMs`, a
|
|
243
|
+
line still in flight is not said — with result `voicemail`). An `nlu` detector writes the line to the transcript first
|
|
244
|
+
and reads a final before the conversation does (a final its `fallback` matches is voicemail, not a turn).
|
|
245
|
+
|
|
246
|
+
| Detector | Fires when |
|
|
247
|
+
|---|---|
|
|
248
|
+
| `nlu` | `timing: 'debounce'`: a partial is checked `throttleMs` after the last one (each partial and the next speech start restart the wait; one request at a time) and every final waits for its own NLU answer before the conversation reads it (a hit is never a turn; no `fallback`). Default: the platform NLU returns one of `intents` (on partials too unless `onPartials: false`, throttled by `throttleMs`, lines shorter than `minChars` skipped; finals bypass the throttle). `fallback` phrases are checked on finals only when the NLU did not answer (error, unavailable); with `fallbackFirst` they are read on every final before the NLU (a match is voicemail at once; no queueing of finals while a request runs). |
|
|
249
|
+
| `phrases` | A line matches (locale lexicon `voicemail` + the agent's own); `firstFinals` is recorded but not applied (agents that declare it replay as they are; limit a detector with `when`); `when` (a `Condition` of the call): read only while it holds — `{ fact: 'phase', eq: 'opening' }` (opening answers only), `{ not: { flag: 'loanNamed' } }` (before a tracking line flag). |
|
|
250
|
+
| `loop` | The same long line repeats `repeats` times. |
|
|
251
|
+
| `menu` | A long line recurs `recurrences` times within `windowLines` lines (an IVR menu cycling; two different lines at least). |
|
|
252
|
+
| `monologue` | The caller's first speech run starts within `startWithinMs` of answer and lasts `ms` or more (VAD pauses up to `mergeGapMs` do not end it): sets the flag `voicemail.monologue` (texts, rules and conditions read it as `{ flag }`). Once per call. |
|
|
253
|
+
|
|
254
|
+
A `phrases` detector with `transcript` writes the line it caught; a detector's `when` reads the call (e.g. «before the
|
|
255
|
+
identity check is over»). `transcriptLine`: a line an NLU detector caught on a partial goes to the platform's call
|
|
256
|
+
transcript. Phrase detectors also read lines the filters dropped (`dropLine`, `minPeakVad`), and the detectors
|
|
257
|
+
run before anything else reads a line — also while the agent is closing. `loop`: `minChars` normalized characters,
|
|
258
|
+
the same line (or one containing the other) `repeats` times in a row.
|
|
259
|
+
|
|
260
|
+
`when` (a condition): detection runs only on calls where it holds (e.g. not on a call the caller placed).
|
|
261
|
+
`scope: 'beforeFirstTurn'` (default) stops detection (no more NLU requests) after the first caller turn of the
|
|
262
|
+
conversation; answers to liveness checks during the opening do not count. `'wholeCall'` keeps it on.
|
|
263
|
+
|
|
264
|
+
## Rules
|
|
265
|
+
|
|
266
|
+
`{ id, on, match?, when?, then, continue?, whileWaiting? }`.
|
|
267
|
+
|
|
268
|
+
- `on`: `callerLine`, `callerPartial` (the caller's words so far; synchronous matchers; once a partial rule acted, none
|
|
269
|
+
acts again until the caller's next final), `agentLine` (the reply text),
|
|
270
|
+
`agentLineHeard` / `agentLineCut` (after playback: heard to the end or cut by the caller), `toolCall` (the name of a
|
|
271
|
+
tool the LLM's reply called, once per reply; the transfer's own tool is `transfer.toolName`).
|
|
272
|
+
- `intent` matchers (the platform NLU, asynchronous) only on `callerLine`: the turn waits for the NLU; partials, agent
|
|
273
|
+
lines and tool names are matched synchronously (NLU while the agent speaks: `overtalk.interrupt.intents`).
|
|
274
|
+
- `when`: phase(s) (default: `conversation` only), `max` (act at most N times), `held` (the line is / is not held) —
|
|
275
|
+
or a `Condition` (any key besides these three): read when the rule's turn comes in the pass, so it sees what the
|
|
276
|
+
rules before it did (a `{ count }` of a `continue` rule before it, flags they set); its `line` is the line. Such a
|
|
277
|
+
rule acts in the conversation; `match` may be left out (every line). A rule whose actions are a `choose` with a
|
|
278
|
+
condition chooses only when the condition holds.
|
|
279
|
+
- Order: first matching rule acts and the rest are skipped, unless the rule has `continue: true`. A rule skipped by
|
|
280
|
+
`max` does not stop the pass. Marks of the acting rules go in front of the next LLM request.
|
|
281
|
+
- A caller-line rule that answers the line itself (`say`, `play`, `llm`, `close`, `hangup`) replaces the LLM turn; `mark`, `flag`, `set` let the LLM answer.
|
|
282
|
+
- `agentLine` and `agentLineHeard` read a reply that played (the turn was not cut); `agentLineCut` reads what the caller
|
|
283
|
+
heard of a reply cut by a barge-in.
|
|
284
|
+
- Every caller-line rule is evaluated before the LLM turn; async matchers (NLU) and the planners of blocks
|
|
285
|
+
(`knowledgeAnswer`, `catalogMatch`) delay the turn, `whileWaiting: { afterMs, say }` says a filler meanwhile (a
|
|
286
|
+
**held turn**: the LLM turn starts at once and waits for the text; `whileWaiting.say` is said after `afterMs` as the
|
|
287
|
+
start of the reply; a caller line said meanwhile joins the waiting line, the two go as one turn).
|
|
288
|
+
- NLU (`intent`) matchers: `language` of the request, `timeoutMs` (no answer by then: no match), `normalized` (the
|
|
289
|
+
line lower case without punctuation), `warmUp` (a request with this text at answer, its answer ignored — the first
|
|
290
|
+
request of a call is slow). A line said while the NLU checks an earlier one joins it (one turn, one more request).
|
|
291
|
+
Several rules on one intent split its hits: e.g. `when: { max: 2 }` replies twice, the next rule closes; the
|
|
292
|
+
counter (`{ counter: id }`) tells a text expression which hit it is.
|
|
293
|
+
|
|
294
|
+
Examples:
|
|
295
|
+
|
|
296
|
+
```ts
|
|
297
|
+
rules: [
|
|
298
|
+
// «I'll call him» — hold the line, the held silence ladder runs.
|
|
299
|
+
{ id: 'handover', on: 'callerLine', match: { lexicon: 'wait' }, then: { hold: true } },
|
|
300
|
+
// Wrong number — fixed close.
|
|
301
|
+
{ id: 'wrongNumber', on: 'callerLine', match: { lexicon: 'wrongNumber' }, then: { close: { ru: 'Извините…', kk: 'Кешіріңіз…' }, result: 'wrong_number' } },
|
|
302
|
+
// «Put me through to a person» — transfer, at most once.
|
|
303
|
+
{ id: 'operator', on: 'callerLine', match: /\b(operator|a person)\b/i, when: { max: 1 }, then: { transfer: true } },
|
|
304
|
+
// Abuse: NLU check before the LLM, fixed reply.
|
|
305
|
+
{ id: 'abuse', on: 'callerLine', match: { intent: 'abuse' }, then: { say: 'Please, let us keep it polite.' }, whileWaiting: { afterMs: 1500, say: 'Mm.' } },
|
|
306
|
+
// Tell the LLM its last line was cut.
|
|
307
|
+
{ id: 'cut', on: 'agentLineCut', then: { mark: '<<< previous_reply_cut;' }, continue: true },
|
|
308
|
+
]
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Closing
|
|
312
|
+
|
|
313
|
+
| Field | Meaning |
|
|
314
|
+
|---|---|
|
|
315
|
+
| `goodbye` | A reply (or the LLM greeting) matching this is a goodbye: the call hangs up after it played out, plus `hangupGraceMs`. Usually `{ tail: { lexicon: 'goodbye' }, chars: 40 }` or a marker regex (`tail` tests the last `chars` characters of the trimmed reply). |
|
|
316
|
+
| `goodbyeResult` | Result of a goodbye (default `goodbye`), decided through `results.fromFacts` at `goodbye`. |
|
|
317
|
+
| `reopenOnSpeech` | `{ startWithinMs, runGapMs?, ignore?, marker?, markerAt? }`: the caller was still finishing their answer when an LLM goodbye started → cancel the hangup (the goodbye is cut), result back to `default`, the words are a new turn with `marker` (`before` / `after` them; not in the transcript). Once per call; for a final heard while the goodbye plays, or a line buffered over it while it streamed (looked at when the goodbye was said in full). The words' run of speech (segments less than `runGapMs` apart are one) must have started no later than `startWithinMs` after the goodbye's first audio (any time before its audio); not when they match `ignore` (thanks / yes / bye), repeat the line the goodbye answered, only echo the goodbye's words, or the hangup was already sent. |
|
|
318
|
+
| `hangupGraceMs` | Pause after the last line before hanging up. |
|
|
319
|
+
| `drainFloor` | Hold a goodbye (a reply ending the call, a closing line) at least `max(minMs, msPerChar × spoken chars)` from `turnStart` / `firstChunk` / `playbackStart` before the hangup waits for the agent queue's drain. Default none. |
|
|
320
|
+
| `emptyGoodbye` | `'hangupNow'`: a goodbye with no letter or digit (a bare «…» plays nothing, so no end of playback comes) hangs up at once, without `hangupGraceMs`; `'wait'` (default) waits like any goodbye. |
|
|
321
|
+
| `openUntilFloor` | A goodbye reply stays a reply until its `drainFloor` passed: the caller can still cut it and a line of theirs takes the call over (the goodbye does not hang up); the hangup and the goodbye result start after the floor. |
|
|
322
|
+
| `guard` | Lines that end the call too early, judged before any of them is spoken: the reply's opening is held while it can still be one of `closings` (up to `holdChars`, default 60, or the line's length; `leading` is cut first), `openings` are held to their first `?`. A judged line is replaced by a fixed line said instead (`alias`, default `closing_guard_reask`; a replacement that is a goodbye closes the call with `goodbyeResult`): what `replace` gives for the line (`null`: spoken as it is): the re-ask plan `{ reask }` (below), or an `Expr` (its `line` is the judged line; empty: as it is). `closings` / `openings` may be `Expr` lists (a list variable among them is flattened). The replacement counts as a reply with text (empty-reply counts start over). Not on the greeting. |
|
|
323
|
+
|
|
324
|
+
## Transfer
|
|
325
|
+
|
|
326
|
+
The transfer hands the call to a person. It starts when a reply played out that is the transfer (the LLM's tool call
|
|
327
|
+
`toolName` latched during it, or the reply matches `spoken`), or on the rule action `{ transfer: true }`. From then the
|
|
328
|
+
conversation is over while it runs (`phase: 'transfer'`, result `results.connected` for `bridge`,
|
|
329
|
+
`results.customerDropped` for `dialAndWhisper`): caller lines are not read, silence and voicemail stop.
|
|
330
|
+
|
|
331
|
+
Every transfer ends with one **outcome**, logged (`transfer_outcome`, `transfer_failed`) and handed to the conversation:
|
|
332
|
+
|
|
333
|
+
| Outcome | When | What happens |
|
|
334
|
+
|---|---|---|
|
|
335
|
+
| `connected` | the operator answered (`dialAndWhisper`: a person spoke and was whispered to); the legs are bridged | result `results.connected`; the call clock stops; either side hanging up ends the other |
|
|
336
|
+
| `no_answer` | `bridge`: the operator leg rang `answerTimeoutMs` | the operator leg is hung up; `onFailure` |
|
|
337
|
+
| `timeout` | `dialAndWhisper`: no person within `humanDetect.holdTimeoutMs` | the operator leg is hung up; `onFailure` |
|
|
338
|
+
| `rejected` | the operator leg refused the call (its answer failed: busy, declined) | `onFailure` |
|
|
339
|
+
| `operator_gone` | the operator leg ended before answering | `onFailure` |
|
|
340
|
+
| `dial_failed` | no operator leg could be placed (the dial threw; a non-SIP call) | `onFailure` |
|
|
341
|
+
| `not_configured` | the target is empty or its source could not be read | `onFailure` (nothing dialled) |
|
|
342
|
+
| `customer_gone` | the customer left before it connected | the operator leg is hung up; result `results.customerDropped` |
|
|
343
|
+
|
|
344
|
+
Before the operator answers the library hangs up **only the operator leg**, never the customer: after any failure the
|
|
345
|
+
customer is still on the line and the agent's `onFailure` alone decides what they hear. A call whose transfer did not
|
|
346
|
+
connect is reported as not transferred: its result is `results.notAnswered` / `results.customerDropped`, each by
|
|
347
|
+
default the result the call had before the transfer started (`default` mid-conversation), and the call is reported
|
|
348
|
+
like any other (extraction runs; `whileBridged.skipExtraction` skips it only for a connected call); the fact
|
|
349
|
+
`transfer.completed` is false.
|
|
350
|
+
|
|
351
|
+
| Field | Meaning |
|
|
352
|
+
|---|---|
|
|
353
|
+
| `toolName` | LLM tool (Omni event) that starts the transfer. The reply it came with is spoken; the transfer starts when it played. A reply with nothing in it but the tool call, asked again by the empty-reply retry, hands the tool call to the retry: the retry's reply, once played, is the transfer. |
|
|
354
|
+
| `spoken` | A reply matching this is the transfer line (the LLM said it, with or without the tool). Compose it: e.g. `{ all: [endsWithEllipsis, { not: /\?\s*$/ }, markers] }`. |
|
|
355
|
+
| `requireRequest` | `{ match, lookbackTurns, refusedSignal }`: the tool call counts only when the caller's last `lookbackTurns` lines (joined) match `match`. Otherwise the reply is cut at the tool call (nothing more of it is spoken) and, when it said nothing, asked once more with `refusedSignal` (the overtalk echo check keeps the caller's line; a second refusal is not asked again and is not counted as an empty reply). |
|
|
356
|
+
| `mode` | `'bridge'`: the platform bridge — a B leg to `target.did` on `target.channel` with `headers`, both legs watched, rung at most `answerTimeoutMs`, cross-connect; the silence windows stop at once, the call clock when the operator answers. `'dialAndWhisper'`: dial `target.msisdn` (`channel`), hold the customer until a person answers it (`humanDetect.asr` recognizer on the operator leg; lines matching `humanDetect.queue` are queue announcements; `holdTimeoutMs` from the end of the transfer line), say `whisper` to them, bridge; the clock stops when bridged. A target that resolves to nothing fails as `not_configured`. |
|
|
357
|
+
| `answerTimeoutMs` | `bridge`: how long the operator leg may ring, from the moment it is placed (default 30 000; `0`: no limit — it rings until the operator or the trunk ends it, or the call's time limit `platform.maxCallMs`). Then it is hung up: outcome `no_answer`. |
|
|
358
|
+
| `target` | `did`, `msisdn` (each a `Value`: literal or from a source; `did` may be an expression of the call, e.g. a call variable read from the CMS at the start), `channel`. |
|
|
359
|
+
| `text` | `{ say, when, alias, transcript?, clip? }` — said before the transfer; absent = the LLM's reply is the transfer line; `when: 'replyEmpty'`: only when the reply that started it said no words (no letter or digit, e.g. the tool's raw «…»); `when: 'replyBlank'`: only when it said nothing at all (a «…» counts as the line); said in the reply language. A `say` expression reads the call and the caller's line the turn answered. `transcript`: the line goes to the transcript and (with `phraseFloor`) counts as playing at least its floor from its start. `clip: { url | record, text, playMs }`: played when `say` gives nothing; counts as playing `playMs`; a clip that cannot play is said by TTS. |
|
|
360
|
+
| `phraseFloor`, `graceMs` | The transfer line plays out before the dial: at least `max(minMs, msPerChar × chars)` from `from` (as `turn.drainFloor`), then the agent queue's drain (default: the drain only, under `turn.drainCeiling.minMs`); then `graceMs` of pause; for `bridge` the agent and background queues are stopped before the B leg. |
|
|
361
|
+
| `whileBridged` | `{ skipExtraction }` (default true; the clock and silence windows always stop and caller lines are never read once the transfer started). `skipExtraction`: a call the transfer took over is reported without extraction (`result` the transfer's label through `labels.map`, `extracted_result` null, entities `transfer.entities`). |
|
|
362
|
+
| `onFailure` | The transfer did not connect with the customer on the line (every outcome above but `connected` and `customer_gone`): `say` (by reply language, `alias`, default `transfer_failed`) then `then`: `close` (hang up after the phrase, or at once without one; hangup reason `transfer_<outcome>`), `continue` (back to the conversation: the phrase is a turn, without one the silence window starts again; caller lines are read again, a later transfer may start), or `log` (default: nothing more — the customer stays on the line in silence until they hang up or the call's time limit `platform.maxCallMs` ends it). The library picks no reaction for the agent: what the customer hears after a failure is exactly this field. |
|
|
363
|
+
| `results` | `connected`, `notAnswered` (did not connect, the customer on the line), `customerDropped` (the customer left first); `notAnswered` / `customerDropped` absent: the result the call had before the transfer. Give them `outranksExtraction` in `results.table` when the transfer's result must win over the extracted one. |
|
|
364
|
+
| `headers` | An expression of the call giving `{ 'X-…': … }` — headers of the operator leg (the platform bridge's `proto_additional`). |
|
|
365
|
+
| `entities` | Entities of the row of a call whose extraction the transfer skipped (e.g. the destination); a record or a record expression of the call. |
|
|
366
|
+
| `extract` | Entities still extracted from such a call (only ones that imply no result), in front of `entities`. |
|
|
367
|
+
| `veto` | An `Expr` of the caller's line: the tool latched on a reply with no words → `null` (the transfer goes on) or a text: nothing more of the reply is spoken and the LLM is asked again with it, once (a tool call on that regeneration goes through). |
|
|
368
|
+
| `toolReply` | Data: `{ overOnQuestion?, overAfter?: { phrases, oneMoreStartingWith? }, dropOn?: { question?, goodbye?: { unless?: Condition, emptyGoodbye?: RegExp } } }` — over when the reply so far ends with `?`, or once the transfer line (from the first of `phrases`, any case, to its sentence end) is said and what follows is no longer a beginning of `oneMoreStartingWith`; at its end the tool call is dropped on a `?`, or on a goodbye that is not only `emptyGoodbye` and does not hold `unless` (its `line`: the reply). |
|
|
369
|
+
|
|
370
|
+
The generic code is the call media's (`src/voice/transfer.ts`: `bridgeToOperator`, `DialTransfer`).
|
|
371
|
+
|
|
372
|
+
## Actions
|
|
373
|
+
|
|
374
|
+
| Action | Effect |
|
|
375
|
+
|---|---|
|
|
376
|
+
| `{ say, alias?, speechOver? }` | Speak fixed text instead of the LLM reply. `say` as a list: said part by part (each part its own clip, alias `<alias>-<n>`, synthesized once the one before it is; a barge-in or a newer turn stops the parts not said yet; the transcript has the parts said, joined). `speechOver: 'answer'`: speech heard while it plays (after the guard's echo check) is the answer at once — a caller turn, the line stops (a re-prompt); default `'buffer'`. |
|
|
377
|
+
| `{ play: PlaySpec }` | Play a record/URL (re-prompts, clips). |
|
|
378
|
+
| `{ llm }` | Send this line to the LLM instead of the caller's text. |
|
|
379
|
+
| `{ mark }` | Prefix the next LLM turn with a marker. |
|
|
380
|
+
| `{ hold: true }` / `{ hold: false }` | Hold the line (`silence.held` runs) / release it. Does not answer the line: the LLM still replies. |
|
|
381
|
+
| `{ next: true }` | Opening: go on with the next step. |
|
|
382
|
+
| `{ close, result, reason?, alias? }` | Say the text (uninterruptible; or nothing with `null`; a list: in parts, as `say`), hang up after it played out plus `closing.hangupGraceMs`, set the result (`result`, `reason`, `alias` may be expressions of the call: one close that says different lines on different calls, e.g. a silence rung's `otherwise`). |
|
|
383
|
+
| `{ hangup, result, graceMs? }` | Hang up now, no phrase (after `closing.hangupGraceMs`, or `graceMs`; `0`: at once, a line in flight is not said). |
|
|
384
|
+
| `{ transfer: true }` | Start the transfer. |
|
|
385
|
+
| `{ flag, value? }`, `{ set, value }` | Flags, variables (`value` as written, or an expression of the call and the line: `{ set: 'transfer_line', value: { cases: [{ when: { fact: 'offerAccepted' }, value: ORDER_LINE }], else: PLAIN_LINE } }`; a literal object with an operator key: `{ quote }`). |
|
|
386
|
+
| `{ ladder: name }` | The next line of the line ladder `ladders.<name>` not said yet (a goodbye line closes with `goodbyeCloses`), or its terminal action once all were said (`then: 'llm'`: nothing, the rule does not answer). `blocks.md`. |
|
|
387
|
+
| `{ count: name, by?, log? }` | One more (`by`) on the counter `name`, read as `{ counter: name }`; `log`: an event `{ userText, <name>: n }`. Does not answer the line. |
|
|
388
|
+
| `{ log: event, data? }` | Log an event with these fields (each a value or an `Expr` of the call; `{ fact: 'line' }` is the caller's line): `{ log: 'guard_close', data: { reason: 'refused', userText: { fact: 'line' }, objections: { counter: 'objections' } } }`. Does not answer the line. |
|
|
389
|
+
|
|
390
|
+
Several actions in an array run in order.
|
|
391
|
+
|
|
392
|
+
### Client guards read off the words
|
|
393
|
+
|
|
394
|
+
As data: `tracking.questions` (the question each agent line leaves open), caller-line rules with a condition `when`
|
|
395
|
+
(`{ openQuestion }`, `{ asked }`, `{ answers }`, `{ counter }`), a `{ count }` rule with `continue: true` first, then
|
|
396
|
+
the closes and the directive `mark`s in their order (`blocks.md`). They stand after the rules that must win over
|
|
397
|
+
them (a request not to be called, a wrong number) and before the held-line rules. A silence rung reads the same facts
|
|
398
|
+
through `when` / `otherwise`; flags set by rules (`{ flag }`) tell it what happened.
|
|
399
|
+
|
|
400
|
+
## Closing guard re-asks (`closing.guard.replace: { reask }`)
|
|
401
|
+
|
|
402
|
+
«Re-ask before giving up, never repeat word for word» as data (`src/templates/engine/turns/closing-guard.ts`). For a
|
|
403
|
+
held line, in order (each `Expr` sees the call; `line` is the held line unless said otherwise):
|
|
404
|
+
|
|
405
|
+
1. `sequence { when?, lines, close, rewordings?, alsoFirst?, replace?, dayLines? }` — asks said in order (a ladder;
|
|
406
|
+
`lines` is a list, nested lists flattened, then `close`). A held line of `replace` never plays: the next ask does
|
|
407
|
+
(as it is while the sequence is off). A line starting with one of `dayLines.openings` for which `dayLines.when`
|
|
408
|
+
holds plays the next ask; when it also starts with one of `dayLines.reaskOpenings` the last ask said is asked again
|
|
409
|
+
(reworded). An ask ahead of the next one is replaced by the next one; one already said is asked in other words
|
|
410
|
+
(`rewordings[i]` of ask `i`: the first not said yet, else the one said longest ago; none: as it is). `alsoFirst`:
|
|
411
|
+
a line that counts as the first ask once said.
|
|
412
|
+
2. `repeats { openings, opening, rewordings }` (after `replace` / `dayLines`, before the ladder lines of 1) — a held
|
|
413
|
+
line starting with one of `openings` whose part from `opening` to its `?` was already said is replaced by the least
|
|
414
|
+
recently said of `rewordings`; else as it is.
|
|
415
|
+
3. `until { heard, prefixChars?, reask, max, asks }` — before the agent said `heard` (its first `prefixChars`
|
|
416
|
+
characters), the re-ask is `reask` while fewer than `max` agent lines contain one of `asks`; then the line plays.
|
|
417
|
+
4. `allow [{ closing, after, times }]` — the closing plays once `after` was said `times` times.
|
|
418
|
+
5. `steps [{ asked, reasks?, nested? }]`, `fallback` — the newest agent line that asked a step (it contains one of the
|
|
419
|
+
`asked` texts, or matches a `{ match }`; steps in order) gives its `reasks` (its `line`: the asking line; default
|
|
420
|
+
`fallback`); none: `fallback`. The first re-ask not said yet replaces the line; all said: the line plays. `nested`:
|
|
421
|
+
the second re-ask contains the first, a line counts toward the second only.
|
|
422
|
+
|
|
423
|
+
«Said» compares texts with whitespace collapsed and in lower case: a re-ask is said by a line that contains it and is
|
|
424
|
+
at most `slackChars` (default 40) longer; elsewhere a line «contains» the text.
|
|
425
|
+
|
|
426
|
+
```ts
|
|
427
|
+
closing: { goodbye, guard: {
|
|
428
|
+
closings: ['I will call you later. Goodbye…'], holdChars: 60, alias: 'closing_guard_reask',
|
|
429
|
+
replace: { reask: {
|
|
430
|
+
until: { heard: { var: 'reminder' }, prefixChars: 40, reask: 'Is this Ann?', max: 3, asks: ['Is this Ann?'] },
|
|
431
|
+
steps: [
|
|
432
|
+
{ asked: ['When will you pay?'], reasks: ['When will you pay?', 'Sorry, I did not hear. When will you pay?'], nested: true },
|
|
433
|
+
{ asked: [{ var: 'amount_question' }], reasks: [{ template: 'Sorry, I did not hear. {amount_question}' }] },
|
|
434
|
+
],
|
|
435
|
+
fallback: ['Can you pay today?', 'Sorry, I did not hear. Can you pay today?'],
|
|
436
|
+
} },
|
|
437
|
+
} }
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
## Reply rules (`turn.replyRules`)
|
|
441
|
+
|
|
442
|
+
Rule sets on the streaming reply, written as data; each set is one reply filter, run in the order listed where
|
|
443
|
+
`{ filter: 'replyRules' }` stands in `turn.filters` (first without it). Source: `src/templates/engine/turns/reply-rules.ts`.
|
|
444
|
+
|
|
445
|
+
| Set | Effect |
|
|
446
|
+
|---|---|
|
|
447
|
+
| `sentenceRules { counters?, rules }` | One sentence at a time (a sentence ends at `.`/`!`/`?`/`।`/`…` and a space). The first rule whose `when` (a reply condition, below) holds decides: `'drop'` (this sentence), `'cut'` (it and the rest), `{ replace, alias?, close? }` (nothing of the reply is spoken; `replace` is said when it ended, `close: { result, reason? }` ends the call after it); `log` names the reason (`llm_reply_rejected`). `counters: [{ name, when?, inc }]` are updated on the reply's first sentence that was not dropped or cut, on turns where `when` holds: `inc` holds → +1, else 0; kept for the call, read before the update as `{ count: name, gte: 2 }`. `replace` is an `Expr` (its `line` is the sentence) or `{ byScript: { texts: { Devanagari: …, Tamil: … }, else } }` (the script the sentence is mostly written in; ties: the first listed). |
|
|
448
|
+
| `unclearLadder { probe, whole?, rungs, countVar, onExhausted, early?, sentenceEnd?, normalize?, skip? }` | The first sentence (held to `sentenceEnd`, default `/[.?!…]/`) matching `probe` (or `whole`) is a re-ask; the count in a row is the call variable `countVar` (written when it changes, so the prompt reads it). Count 0: spoken whole; below `rungs`: a `whole` re-ask whole, a probe without its first sentence (the probe alone when nothing follows); `rungs` reached: nothing is spoken and `onExhausted` runs. Another reply sets the count to 0. `early: { when, then }`: on a probe when `when` held at the reply's start, `then` runs instead (e.g. a voicemail hangup). `normalize: 'NFC'`; `skip` default greeting and silence replies. |
|
|
449
|
+
| `insertAfterFirst { when, after, unless, text, sentenceEnd?, normalize?, skip? }` | On turns whose caller words hold `when` (its `line`), a first sentence matching `after` is followed by ` ` + `text`, unless it or the next sentence matches `unless`. |
|
|
450
|
+
| `asClip { play, skip? }` | A reply whose words are `play.text` (NFC, trimmed, lower case) plays the clip instead (held while it can still be them; not on the greeting). |
|
|
451
|
+
| `stripLetters { keep }` | A word with a letter of a script not in `keep` (Common, Inherited always kept) loses its letters; a word left empty goes with its space. Per chunk. |
|
|
452
|
+
|
|
453
|
+
Reply conditions: any `Condition` (its `line` is the sentence) and `{ sentence: Matcher }`, `{ first: boolean }` (the
|
|
454
|
+
reply's first sentence not dropped), `{ turn: { tag?, silence? } }` (`tag: 'turn'` a caller turn, `'bootstrap'` the
|
|
455
|
+
greeting), `{ scriptChanged: { scripts, minLetters } }` (the sentence is mostly in another of `scripts` than the latest
|
|
456
|
+
agent line with as many letters), `{ earlier: ReplyCondition }` (a sentence of an agent line said before this reply),
|
|
457
|
+
`{ count: name, …Cmp }`, `{ answered: Matcher }` (the last agent line, whatever its words). The agent lines are those
|
|
458
|
+
at the reply's start.
|
|
459
|
+
|
|
460
|
+
```ts
|
|
461
|
+
turn: { replyRules: [
|
|
462
|
+
{ sentenceRules: {
|
|
463
|
+
counters: [{ name: 'unclear', when: { turn: { tag: 'turn', silence: false } }, inc: { sentence: /did not (catch|hear)/i } }],
|
|
464
|
+
rules: [
|
|
465
|
+
{ when: { sentence: /[<>]/ }, then: 'cut', log: 'markup' },
|
|
466
|
+
{ when: { all: [{ sentence: /credit score/i }, { earlier: { sentence: /credit score/i } }] }, then: 'drop' },
|
|
467
|
+
{ when: { all: [{ first: true }, { sentence: /did not (catch|hear)/i }, { count: 'unclear', gte: 2 }] },
|
|
468
|
+
then: { replace: 'Sorry, I cannot hear you. Goodbye.', alias: 'unclear_close', close: { result: 'default' } } },
|
|
469
|
+
] } },
|
|
470
|
+
{ stripLetters: { keep: ['Latin', 'Devanagari'] } },
|
|
471
|
+
] }
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
## Verdicts on a reply
|
|
475
|
+
|
|
476
|
+
An agent may judge a reply before any of it is spoken, as data; the engine gives the mechanics, the rules the decision:
|
|
477
|
+
|
|
478
|
+
- `turn.review` as rules: `{ start: [{ when?, then: { holdChars: Expr } | null }], held: [{ when?, then: 'release' |
|
|
479
|
+
'wait' | { regenerate: Text } | { then: actions } }] }` — the first rule that holds answers (none: `null` / keep
|
|
480
|
+
holding); conditions read `{ input: 'request' | 'trigger' | 'regenerated' | 'silence' | 'held' | 'final' }` and the
|
|
481
|
+
caller's words as `line`. `start` is read at the start of every LLM turn but the greeting: `null` (spoken as it
|
|
482
|
+
comes) or `{ holdChars }` (held until the first sentence ended and `holdChars` more characters came). While held,
|
|
483
|
+
`held` is read on the held text: keep holding (spoken when the hold is over), `'release'`, `{ regenerate: text }`
|
|
484
|
+
(nothing is spoken; the LLM is asked again with `text` when the stream ended — the trigger stays the caller's line,
|
|
485
|
+
the regeneration carries `regenerated: 'review'`, its tool call is dropped) or `{ then: actions }` (nothing is
|
|
486
|
+
spoken; the actions run, e.g. `close`, or `set` + `transfer` with the line the transfer's `text` reads).
|
|
487
|
+
- `transfer.veto`, `turn.regenerateEmpty`, filter `cutAtSentence` — a wordless transfer refused, an empty reply, a
|
|
488
|
+
reply that was only reasoning: asked again once with the agent's text.
|
|
489
|
+
- `overtalk.cutMark` — a mark for the line after a reply the caller cut, from how long it had played.
|
|
490
|
+
|
|
491
|
+
Each regeneration says why (`regenerated`: `review`, `veto`, `empty`, `cutAtSentence`); a check does not run again on
|
|
492
|
+
its own regeneration.
|
|
493
|
+
|
|
494
|
+
## What the engine runs
|
|
495
|
+
|
|
496
|
+
One media layer for every agent: one recognizer per language (`voice.asr.undecided` while the pick is provisional,
|
|
497
|
+
switched at the next caller turn once it settles), the TTS session when `voice.tts.session`, clips (CMS records, URLs,
|
|
498
|
+
TTS of their text), LLM lines requested early (`llmGreeting.eager`), one LLM request per turn or one persistent stream
|
|
499
|
+
(`prompt.persistentStream`), the silence windows above, overtalk handled by the conversation, every reply streamed to
|
|
500
|
+
TTS as it comes, drain floors from the agent file, a closing line uninterruptible and followed by
|
|
501
|
+
`closing.hangupGraceMs`. A recognizer that fails to start leaves the call going (the silence ladder decides). A leg
|
|
502
|
+
that never connected is reported by its `after_call_failed` pass when `platform.failedLegPass` is set.
|
|
503
|
+
|
|
504
|
+
Checked on two replayed prod agents: a recorded hello with an LLM greeting (35 calls; 33 identical to production at
|
|
505
|
+
0 ms; one LLM error on the greeting and one recognizer that failed to start differ, as they did before) and a
|
|
506
|
+
fixed-phrase opening with a language pick and an identity gate (47 calls identical to production at 0 ms: phrases,
|
|
507
|
+
timings, LLM requests and payloads, HTTP bodies, rows). The transfer on two more: a recorded hello with the platform
|
|
508
|
+
bridge on a tool call or a spoken transfer line (33 calls; 31 identical at 0 ms, the two others an LLM error on the
|
|
509
|
+
greeting and a recognizer that failed to start, as above), and a fixed-phrase opening with an address checked with a
|
|
510
|
+
client service (held turns, client HTTP) and dial-and-whisper (40 calls; 39 identical at 0 ms, HTTP bodies and LLM payloads all
|
|
511
|
+
identical; the other reports the platform's SIP status of a failed leg). Two more recorded-hello agents with the client
|
|
512
|
+
rules of this page's later blocks (voice variants, system notes, the reply guard with labels, fixed replies by rules,
|
|
513
|
+
probes, the slow-reply filler, the unclear ladder, NLU swearing rules, an opening-monologue flag, an English
|
|
514
|
+
machine line, an AI disclosure, a reply played as its clip): 35 and 36 calls, 33 and 34 identical to production at
|
|
515
|
+
0 ms (LLM payloads, HTTP bodies, rows); the others are the LLM error on the greeting and the recognizer that failed to
|
|
516
|
+
start, as above. A recorded hello with an unprompted greeting (held through the caller's speech), a recorded fallback
|
|
517
|
+
greeting, client verdicts on replies (review with regeneration and actions, regenerated empty replies, a reasoning cut,
|
|
518
|
+
a cut mark), NLU interruption, a goodbye the caller can cut until its floor, a wait cap and the platform bridge with a
|
|
519
|
+
clip, the transfer's progress and extraction on transfer: 32 calls, 30 identical at 0 ms (a voicemail hang-up stops the
|
|
520
|
+
line 60 ms before the platform would; the recognizer that failed to start), and 10 more for the paths the common set
|
|
521
|
+
does not reach, all identical.
|
|
522
|
+
|
|
523
|
+
- opening steps `play`, `say` (`bargeIn: false` plays whole), `listen` (`speechOverPrevious: 'answer' | 'drop' |
|
|
524
|
+
{ keepIfWithinMs }`, `answer`, `transcriptLine`, its own ladder: `play`, `next`, `close`), `llmGreeting` (`eager`),
|
|
525
|
+
`language`, `gate`, `close`; clips with `alias`, `waitFinished`, `{voice}`; `prompt.handoff` on the
|
|
526
|
+
first LLM turn; `prompt.variants`, `prompt.systemNotes`;
|
|
527
|
+
- the language ladder, `askedIn` (one language or several) with `plainYes`, the one-way fallback, caller requests, `changeMark`, `prompt.languageNames`;
|
|
528
|
+
- `gates`, `hold` and `silence.held`, `silence.speechWithoutText`, `deadAudio`, `noProgress` (`inOpening`), `noWordsMs`,
|
|
529
|
+
`beforeFirstLineMs`, `voidMark`, the listen step's `voiceWithoutTextMs` / `voiceWithoutTextMaxMs`, `voice.selfEcho`,
|
|
530
|
+
`minPeakVad.except`, NLU voicemail `timing: 'debounce'`,
|
|
531
|
+
`speechWithoutText.transcriptLine`, rung `when` / `otherwise` / `name`;
|
|
532
|
+
- rules: synchronous; `intent` matchers (the turn waits for the platform NLU, `whileWaiting` says its filler as a fixed
|
|
533
|
+
line after `afterMs`); rules run before gates; `annotateCaller` changes the request; actions `say`, `play`,
|
|
534
|
+
`llm`, `mark`, `next`, `close`, `hangup` (`graceMs`), `hold`, `flag`, `set`; NLU options
|
|
535
|
+
(`language`, `timeoutMs`, `normalized`, `warmUp`), lines joining while the NLU checks;
|
|
536
|
+
- reply filters `cutAfter`, `strip`, `replace`, `insertAfter` (once per call by default), `labels` (a label key, or any `snake_case` label), `closingGuard`, `wholeWords`,
|
|
537
|
+
`replyRules` (rules over the stream as data: an unclear-reply ladder, a disclosure after the first sentence, a
|
|
538
|
+
reply played as its clip, sentence rules), `scriptLeak` (`allow`: Latin words that are speech); `closing.guard`;
|
|
539
|
+
`voice.tts.respell` on every spoken line; the reply filter `numbersAsWords` (`languages`), `overtalk.buffer.predating`, `turn.maxLines`, the language step's
|
|
540
|
+
`notNeutral`;
|
|
541
|
+
- overtalk `guardMs` + `dropEcho`, `pendingMs`, `buffer.replayAfterGapMs` / `gapFrom` / `holdWhileSpeaking` / `merge`
|
|
542
|
+
(`windowMs`, `maxChars`) / `earlyFragment` / `predating`, `reverse.tailMs` + `backchannelMaxChars` + `keep`, `reverse.positionRatio`
|
|
543
|
+
+ `minTurnMs`, `buffer.backchannel` (held with its marker); `turn.continuation.windowMs`; `closing.reopenOnSpeech`;
|
|
544
|
+
`voice.minPeakVad.over`; `overtalk.startedBeforeReply`; `turn.replyPlayed`;
|
|
545
|
+
- the transfer (both modes, above), tool events of the LLM stream, held turns;
|
|
546
|
+
- `language.asrSwitch: 'openingEnd'`, `turn.playedOut` (`queueIdle`), `overtalk.overSilenceTurn`,
|
|
547
|
+
`buffer.merge.supersede`, `holdWhileSpeaking.extend`, `voice.dropLineAnswer`, `scriptLeak.allow` as an expression
|
|
548
|
+
and `scriptLeak.retry`, a close's `alias` / `reason` as expressions, each agent line's mixer alias kept (`lines[].unit`);
|
|
549
|
+
- an agent without an LLM (no `prompt`): a block answering every line with fixed lines (the agent stops while it
|
|
550
|
+
decides), `knowledge` actions of silence rungs and `speechWithoutText`, `say` / `close` in parts, `speechOver:
|
|
551
|
+
'answer'`, `reverse.lastPart`, `voice.tts.presay`;
|
|
552
|
+
- `turn.emptyReply` (both ways, `probes`), `abortedRetries`, `holdLivenessPrompt`; the verdicts (`turn.review`,
|
|
553
|
+
`turn.regenerateEmpty`, `cutAtSentence`, `overtalk.cutMark`, `transfer.veto`, `transfer.toolReply`); the greeting's
|
|
554
|
+
`fallback` clip, `firstTokenMs`, `bargeInAfterMs`; `listen.holdWhileSpeaking` and its own window;
|
|
555
|
+
`overtalk.interrupt.intents` / `whileSilent`; `silence.maxAwaitMs`; `closing.openUntilFloor`; `voice.ignoreLine`;
|
|
556
|
+
`cutAfter` at the match or the next chunk; `silence.afterDroppedLineMs`, `silence.noWordsMs`; `turn.carryOn`; the
|
|
557
|
+
`language` step's `answers`; `voice.filler`,
|
|
558
|
+
`voice.clipTranscript`, `voice.tts.variants` (`variantBy`), `voice.asr.<lang>.picks`; the opening listen step's
|
|
559
|
+
`toLlmWhen`; `closing.emptyGoodbye`;
|
|
560
|
+
- the greeting's `fallback` as a text (TTS), rules `on: callerPartial` / `toolCall`,
|
|
561
|
+
clip `records` in actions, a silence window per rung (ladder, held
|
|
562
|
+
line, opening listen step), `buffer.answerOnSilence: false`, voice values read from sources, `silenceSignal` by
|
|
563
|
+
language or as an expression, any matcher in the media's patterns, `call.elapsedMs`;
|
|
564
|
+
- clips with `minPlayMs` (a record counts as playing at least that long before its `tailMs`), the ambient bed from a CMS
|
|
565
|
+
record, `voice.recordFlag`;
|
|
566
|
+
- voicemail `nlu` (partials and finals, `fallback` patterns), `phrases` (`transcript`), `loop`, `menu`, `monologue`
|
|
567
|
+
(`then` on each; `voicemail.transcriptLine`);
|
|
568
|
+
`closing.goodbye` on every reply (use `{ lexicon, in: 'all' }` matchers: the media tests replies without the reply
|
|
569
|
+
language); `turn.drainFloor`, `closing.drainFloor`, `turn.drainCeiling`, `turn.sayTimeoutMs`, `turn.emptyReply`
|
|
570
|
+
(above).
|
|
571
|
+
|
|
572
|
+
## What the engine refuses
|
|
573
|
+
|
|
574
|
+
Nothing of the format: every field of `AgentSpec` is run. Build-time errors are rules of the file itself:
|
|
575
|
+
|
|
576
|
+
- an `intent` matcher where a line must be tested synchronously (partials, agent lines, tool names, the media's
|
|
577
|
+
patterns, filters, gates): the platform NLU is asynchronous and classifies caller lines; it runs on `callerLine`
|
|
578
|
+
rules and `overtalk.interrupt.intents` (`NotRunByEngine`, naming the field);
|
|
579
|
+
- missing parts (`transfer.target.did`, `humanDetect` for `dialAndWhisper`, a gate's `question`).
|
|
580
|
+
|
|
581
|
+
Removed from the format (they duplicated a field that runs): `closing.emptyRepliesToHangup` (the engine has no LLM
|
|
582
|
+
turns while closing; empty replies in a row → `turn.emptyReply` with `max` and `onExhausted: { hangup }`),
|
|
583
|
+
`voice.endOfTurn.mergeWithinMs` (finals of one line → `turn.supersede: 'join'`, `turn.continuation`,
|
|
584
|
+
`overtalk.buffer.merge`), `turn.continuation.graceMs` / `maxReplyMs` (a reply taken back while the caller goes on →
|
|
585
|
+
`turn.carryOn`). `prompt.errorSignal` is logged when the call ends without a goodbye, not sent to the LLM (the
|
|
586
|
+
production agents only logged it). `call.elapsedMs` counts from the call's start to the last media event.
|