@voctiv/agent-runtime 0.2.2 → 0.4.1
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 +53 -20
- package/bin/voctiv-agent-check.js +98 -0
- package/dist/barge-in/barge-in-module.d.ts +0 -1
- package/dist/barge-in/barge-in-module.js +0 -1
- package/dist/barge-in/barge-in-service.d.ts +1 -1
- package/dist/barge-in/barge-in-service.js +33 -2
- package/dist/barge-in/barge-in-strategy.d.ts +11 -9
- package/dist/barge-in/barge-in-strategy.js +39 -23
- package/dist/barge-in/echo-cancellation.d.ts +0 -1
- package/dist/barge-in/echo-cancellation.js +0 -1
- package/dist/barge-in/echo.d.ts +0 -1
- package/dist/barge-in/echo.js +0 -1
- package/dist/barge-in/lexicon.d.ts +0 -1
- package/dist/barge-in/lexicon.js +0 -1
- package/dist/barge-in/speech-ledger.d.ts +0 -2
- package/dist/barge-in/speech-ledger.js +3 -4
- package/dist/barge-in/word-classifier.d.ts +0 -1
- package/dist/barge-in/word-classifier.js +0 -1
- package/dist/call/asr-usage.d.ts +53 -0
- package/dist/call/asr-usage.js +42 -0
- package/dist/call/async.d.ts +2 -0
- package/dist/call/async.js +14 -0
- package/dist/call/env.d.ts +88 -0
- package/dist/call/env.js +294 -0
- package/dist/call/extraction/core.d.ts +99 -0
- package/dist/call/extraction/core.js +259 -0
- package/dist/call/extraction/defaults.d.ts +10 -0
- package/dist/call/extraction/defaults.js +25 -0
- package/dist/call/extraction/index.d.ts +7 -0
- package/dist/call/extraction/index.js +24 -0
- package/dist/call/extraction/orchestrator.d.ts +144 -0
- package/dist/call/extraction/orchestrator.js +309 -0
- package/dist/call/failed-leg.d.ts +43 -0
- package/dist/call/failed-leg.js +77 -0
- package/dist/call/http.d.ts +94 -0
- package/dist/call/http.js +145 -0
- package/dist/call/ledger.d.ts +18 -0
- package/dist/call/ledger.js +80 -0
- package/dist/call/llm-tap.d.ts +7 -0
- package/dist/call/llm-tap.js +41 -0
- package/dist/call/logging.d.ts +16 -0
- package/dist/call/logging.js +92 -0
- package/dist/call/outbound.d.ts +144 -0
- package/dist/call/outbound.js +404 -0
- package/dist/call/output.d.ts +108 -0
- package/dist/call/output.js +77 -0
- package/dist/call/plan.d.ts +119 -0
- package/dist/call/plan.js +2 -0
- package/dist/call/recall.d.ts +115 -0
- package/dist/call/recall.js +312 -0
- package/dist/call/records.d.ts +9 -0
- package/dist/call/records.js +71 -0
- package/dist/call/report.d.ts +65 -0
- package/dist/call/report.js +263 -0
- package/dist/call/sanitize.d.ts +16 -0
- package/dist/call/sanitize.js +72 -0
- package/dist/call/sip.d.ts +111 -0
- package/dist/call/sip.js +212 -0
- package/dist/call/voicemail.d.ts +159 -0
- package/dist/call/voicemail.js +246 -0
- package/dist/core/call-disposables.d.ts +2 -2
- package/dist/core/call-disposables.js +8 -3
- package/dist/core/call-ended-budget.d.ts +11 -0
- package/dist/core/call-ended-budget.js +31 -0
- package/dist/core/container.d.ts +1 -3
- package/dist/core/container.js +9 -49
- package/dist/core/create-agent-script.d.ts +6 -1
- package/dist/core/create-agent-script.js +161 -28
- package/dist/core/decorators.d.ts +0 -1
- package/dist/core/decorators.js +0 -1
- package/dist/core/define-module.d.ts +0 -1
- package/dist/core/define-module.js +0 -1
- package/dist/core/dump-policy.d.ts +0 -1
- package/dist/core/dump-policy.js +0 -1
- package/dist/core/hooks.d.ts +15 -4
- package/dist/core/hooks.js +0 -1
- package/dist/core/media-bootstrap.d.ts +19 -4
- package/dist/core/media-bootstrap.js +53 -13
- package/dist/core/open-timeout.d.ts +12 -0
- package/dist/core/open-timeout.js +48 -0
- package/dist/core/provide-media.d.ts +0 -8
- package/dist/core/provide-media.js +1 -22
- package/dist/core/runtime-events.d.ts +28 -0
- package/dist/{llm/llm-module.js → core/runtime-events.js} +19 -16
- package/dist/core/tokens.d.ts +0 -10
- package/dist/core/tokens.js +0 -1
- package/dist/core/types.d.ts +0 -1
- package/dist/core/types.js +0 -1
- package/dist/core/version.d.ts +2 -3
- package/dist/core/version.js +2 -3
- package/dist/dialog/dialog-definition.d.ts +0 -5
- package/dist/dialog/dialog-definition.js +1 -6
- package/dist/dialog/dialog-ports.d.ts +3 -1
- package/dist/dialog/dialog-ports.js +10 -2
- package/dist/dialog/online-call-host.d.ts +26 -4
- package/dist/dialog/online-call-host.js +94 -12
- package/dist/dialog/online-call-module.d.ts +5 -11
- package/dist/dialog/online-call-module.js +4 -36
- package/dist/dialog/turn-metrics.d.ts +46 -0
- package/dist/dialog/turn-metrics.js +141 -0
- package/dist/dialog-events/active-media.d.ts +50 -2
- package/dist/dialog-events/active-media.js +146 -34
- package/dist/dialog-events/event-source.d.ts +0 -1
- package/dist/dialog-events/event-source.js +0 -1
- package/dist/dialog-events/virtual-finals-module.d.ts +0 -1
- package/dist/dialog-events/virtual-finals-module.js +0 -1
- package/dist/dialog-events/virtual-finals.d.ts +2 -1
- package/dist/dialog-events/virtual-finals.js +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.js +8 -26
- package/dist/lifecycle/lifecycle.d.ts +25 -3
- package/dist/lifecycle/lifecycle.js +92 -14
- package/dist/result/result-store.d.ts +0 -1
- package/dist/result/result-store.js +0 -1
- package/dist/templates/authoring.d.ts +222 -0
- package/dist/templates/authoring.js +2 -0
- package/dist/templates/builder/agent.d.ts +34 -0
- package/dist/templates/builder/agent.js +87 -0
- package/dist/templates/builder/blocks.d.ts +54 -0
- package/dist/templates/builder/blocks.js +92 -0
- package/dist/templates/builder/data-check.d.ts +2 -0
- package/dist/templates/builder/data-check.js +61 -0
- package/dist/templates/builder/draft.d.ts +73 -0
- package/dist/templates/builder/draft.js +142 -0
- package/dist/templates/builder/index.d.ts +8 -0
- package/dist/templates/builder/index.js +55 -0
- package/dist/templates/builder/presets.d.ts +34 -0
- package/dist/templates/builder/presets.js +45 -0
- package/dist/templates/builder/spec-of.d.ts +13 -0
- package/dist/templates/builder/spec-of.js +18 -0
- package/dist/templates/builder/steps.d.ts +25 -0
- package/dist/templates/builder/steps.js +27 -0
- package/dist/templates/business/adapter.d.ts +12 -0
- package/dist/templates/business/adapter.js +980 -0
- package/dist/templates/business/agent-integrations.d.ts +24 -0
- package/dist/templates/business/agent-integrations.js +233 -0
- package/dist/templates/business/extraction-rules-transcript.d.ts +158 -0
- package/dist/templates/business/extraction-rules-transcript.js +405 -0
- package/dist/templates/business/extraction-rules.d.ts +107 -0
- package/dist/templates/business/extraction-rules.js +267 -0
- package/dist/templates/business/index.d.ts +6 -0
- package/dist/{result → templates/business}/index.js +8 -2
- package/dist/templates/business/input.d.ts +56 -0
- package/dist/templates/business/input.js +299 -0
- package/dist/templates/business/integration-data.d.ts +87 -0
- package/dist/templates/business/integration-data.js +312 -0
- package/dist/templates/business/integrations.d.ts +76 -0
- package/dist/templates/business/integrations.js +535 -0
- package/dist/templates/business/legs-policy.d.ts +43 -0
- package/dist/templates/business/legs-policy.js +268 -0
- package/dist/templates/business/report-label.d.ts +7 -0
- package/dist/templates/business/report-label.js +29 -0
- package/dist/templates/business/report.d.ts +67 -0
- package/dist/templates/business/report.js +284 -0
- package/dist/templates/business/result-catalog.d.ts +142 -0
- package/dist/templates/business/result-catalog.js +208 -0
- package/dist/templates/business/result-rules.d.ts +105 -0
- package/dist/templates/business/result-rules.js +167 -0
- package/dist/templates/business/results.d.ts +73 -0
- package/dist/templates/business/results.js +183 -0
- package/dist/templates/business/rule-env.d.ts +18 -0
- package/dist/templates/business/rule-env.js +38 -0
- package/dist/templates/business/sources.d.ts +76 -0
- package/dist/templates/business/sources.js +239 -0
- package/dist/templates/business/test-presets.d.ts +10 -0
- package/dist/templates/business/test-presets.js +68 -0
- package/dist/templates/catalog-match/block.d.ts +32 -0
- package/dist/templates/catalog-match/block.js +95 -0
- package/dist/templates/catalog-match/catalog.d.ts +77 -0
- package/dist/templates/catalog-match/catalog.js +222 -0
- package/dist/templates/catalog-match/recognizer.d.ts +44 -0
- package/dist/templates/catalog-match/recognizer.js +206 -0
- package/dist/templates/catalog-match/reconcile.d.ts +4 -0
- package/dist/templates/catalog-match/reconcile.js +39 -0
- package/dist/templates/catalog-match/request.d.ts +57 -0
- package/dist/templates/catalog-match/request.js +139 -0
- package/dist/templates/catalog-match/types.d.ts +197 -0
- package/dist/templates/catalog-match/types.js +2 -0
- package/dist/templates/catalog-match/verify.d.ts +76 -0
- package/dist/templates/catalog-match/verify.js +220 -0
- package/dist/templates/decision-model/index.d.ts +52 -0
- package/dist/templates/decision-model/index.js +68 -0
- package/dist/templates/engine/asr-picks.d.ts +11 -0
- package/dist/templates/engine/asr-picks.js +44 -0
- package/dist/templates/engine/call.d.ts +104 -0
- package/dist/templates/engine/call.js +322 -0
- package/dist/templates/engine/config.d.ts +447 -0
- package/dist/templates/engine/config.js +493 -0
- package/dist/templates/engine/define.d.ts +1 -0
- package/dist/templates/engine/define.js +9 -0
- package/dist/templates/engine/dialog.d.ts +253 -0
- package/dist/templates/engine/dialog.js +167 -0
- package/dist/templates/engine/echo-numbers.d.ts +7 -0
- package/dist/templates/engine/echo-numbers.js +19 -0
- package/dist/templates/engine/expand.d.ts +6 -0
- package/dist/templates/engine/expand.js +125 -0
- package/dist/templates/engine/filters.d.ts +81 -0
- package/dist/templates/engine/filters.js +654 -0
- package/dist/templates/engine/hook-state.d.ts +18 -0
- package/dist/templates/engine/hook-state.js +100 -0
- package/dist/templates/engine/hooks.d.ts +51 -0
- package/dist/templates/engine/hooks.js +310 -0
- package/dist/templates/engine/index.d.ts +13 -0
- package/dist/templates/engine/index.js +30 -0
- package/dist/templates/engine/language-vars.d.ts +6 -0
- package/dist/templates/engine/language-vars.js +40 -0
- package/dist/templates/engine/language.d.ts +32 -0
- package/dist/templates/engine/language.js +155 -0
- package/dist/templates/engine/lookup.d.ts +20 -0
- package/dist/templates/engine/lookup.js +52 -0
- package/dist/templates/engine/match.d.ts +48 -0
- package/dist/templates/engine/match.js +253 -0
- package/dist/templates/engine/media.d.ts +428 -0
- package/dist/templates/engine/media.js +1240 -0
- package/dist/templates/engine/script.d.ts +11 -0
- package/dist/templates/engine/script.js +69 -0
- package/dist/templates/engine/turns/actions.d.ts +5 -0
- package/dist/templates/engine/turns/actions.js +128 -0
- package/dist/templates/engine/turns/carry.d.ts +15 -0
- package/dist/templates/engine/turns/carry.js +74 -0
- package/dist/templates/engine/turns/choices-offers.d.ts +21 -0
- package/dist/templates/engine/turns/choices-offers.js +143 -0
- package/dist/templates/engine/turns/choices.d.ts +22 -0
- package/dist/templates/engine/turns/choices.js +141 -0
- package/dist/templates/engine/turns/closing-guard.d.ts +73 -0
- package/dist/templates/engine/turns/closing-guard.js +162 -0
- package/dist/templates/engine/turns/closing.d.ts +10 -0
- package/dist/templates/engine/turns/closing.js +82 -0
- package/dist/templates/engine/turns/compile-forms.d.ts +24 -0
- package/dist/templates/engine/turns/compile-forms.js +68 -0
- package/dist/templates/engine/turns/context.d.ts +96 -0
- package/dist/templates/engine/turns/context.js +158 -0
- package/dist/templates/engine/turns/events.d.ts +409 -0
- package/dist/templates/engine/turns/events.js +5 -0
- package/dist/templates/engine/turns/hook-forms.d.ts +62 -0
- package/dist/templates/engine/turns/hook-forms.js +79 -0
- package/dist/templates/engine/turns/ladders.d.ts +42 -0
- package/dist/templates/engine/turns/ladders.js +119 -0
- package/dist/templates/engine/turns/language.d.ts +8 -0
- package/dist/templates/engine/turns/language.js +121 -0
- package/dist/templates/engine/turns/notes-dates.d.ts +9 -0
- package/dist/templates/engine/turns/notes-dates.js +42 -0
- package/dist/templates/engine/turns/notes-detect.d.ts +13 -0
- package/dist/templates/engine/turns/notes-detect.js +36 -0
- package/dist/templates/engine/turns/notes.d.ts +27 -0
- package/dist/templates/engine/turns/notes.js +176 -0
- package/dist/templates/engine/turns/opening.d.ts +34 -0
- package/dist/templates/engine/turns/opening.js +306 -0
- package/dist/templates/engine/turns/overtalk.d.ts +21 -0
- package/dist/templates/engine/turns/overtalk.js +247 -0
- package/dist/templates/engine/turns/pending.d.ts +9 -0
- package/dist/templates/engine/turns/pending.js +88 -0
- package/dist/templates/engine/turns/reply-rules.d.ts +184 -0
- package/dist/templates/engine/turns/reply-rules.js +335 -0
- package/dist/templates/engine/turns/rules.d.ts +20 -0
- package/dist/templates/engine/turns/rules.js +144 -0
- package/dist/templates/engine/turns/silence.d.ts +7 -0
- package/dist/templates/engine/turns/silence.js +127 -0
- package/dist/templates/engine/turns/state-spec.d.ts +305 -0
- package/dist/templates/engine/turns/state-spec.js +2 -0
- package/dist/templates/engine/turns/state.d.ts +38 -0
- package/dist/templates/engine/turns/state.js +101 -0
- package/dist/templates/engine/turns/tracking.d.ts +50 -0
- package/dist/templates/engine/turns/tracking.js +184 -0
- package/dist/templates/engine/turns/transfer.d.ts +19 -0
- package/dist/templates/engine/turns/transfer.js +93 -0
- package/dist/templates/engine/turns/turn.d.ts +17 -0
- package/dist/templates/engine/turns/turn.js +363 -0
- package/dist/templates/engine/turns/voicemail.d.ts +8 -0
- package/dist/templates/engine/turns/voicemail.js +101 -0
- package/dist/templates/engine/variants.d.ts +36 -0
- package/dist/templates/engine/variants.js +159 -0
- package/dist/templates/engine/voice-dialog.d.ts +24 -0
- package/dist/templates/engine/voice-dialog.js +157 -0
- package/dist/templates/engine/voice.d.ts +174 -0
- package/dist/templates/engine/voice.js +1337 -0
- package/dist/templates/expr/caller-after.d.ts +20 -0
- package/dist/templates/expr/caller-after.js +53 -0
- package/dist/templates/expr/check.d.ts +19 -0
- package/dist/templates/expr/check.js +314 -0
- package/dist/templates/expr/compiled.d.ts +8 -0
- package/dist/templates/expr/compiled.js +8 -0
- package/dist/templates/expr/context.d.ts +28 -0
- package/dist/templates/expr/context.js +55 -0
- package/dist/templates/expr/day-table.d.ts +4 -0
- package/dist/templates/expr/day-table.js +80 -0
- package/dist/templates/expr/evaluate.d.ts +26 -0
- package/dist/templates/expr/evaluate.js +885 -0
- package/dist/templates/expr/facts.d.ts +7 -0
- package/dist/templates/expr/facts.js +81 -0
- package/dist/templates/expr/index.d.ts +4 -0
- package/dist/templates/expr/index.js +11 -0
- package/dist/templates/expr/line-tally.d.ts +64 -0
- package/dist/templates/expr/line-tally.js +88 -0
- package/dist/templates/expr/matchers-state.d.ts +23 -0
- package/dist/templates/expr/matchers-state.js +37 -0
- package/dist/templates/expr/matchers.d.ts +12 -0
- package/dist/templates/expr/matchers.js +99 -0
- package/dist/templates/expr/readers.d.ts +14 -0
- package/dist/templates/expr/readers.js +351 -0
- package/dist/templates/expr/slots.d.ts +14 -0
- package/dist/templates/expr/slots.js +678 -0
- package/dist/templates/expr/template.d.ts +12 -0
- package/dist/templates/expr/template.js +76 -0
- package/dist/templates/expr/test-call.d.ts +8 -0
- package/dist/templates/expr/test-call.js +32 -0
- package/dist/templates/expr/transcript.d.ts +36 -0
- package/dist/templates/expr/transcript.js +394 -0
- package/dist/templates/expr/types.d.ts +1011 -0
- package/dist/templates/expr/types.js +2 -0
- package/dist/templates/expr/values.d.ts +42 -0
- package/dist/templates/expr/values.js +166 -0
- package/dist/templates/expr/voice-ops.d.ts +26 -0
- package/dist/templates/expr/voice-ops.js +85 -0
- package/dist/templates/helpers/decision.d.ts +55 -0
- package/dist/templates/helpers/decision.js +83 -0
- package/dist/templates/helpers/fuzzy.d.ts +9 -0
- package/dist/templates/helpers/fuzzy.js +44 -0
- package/dist/templates/helpers/index.d.ts +6 -0
- package/dist/templates/helpers/index.js +35 -0
- package/dist/templates/index.d.ts +9 -0
- package/dist/templates/index.js +68 -0
- package/dist/templates/integration-forms.d.ts +252 -0
- package/dist/templates/integration-forms.js +2 -0
- package/dist/templates/knowledge/block.d.ts +44 -0
- package/dist/templates/knowledge/block.js +199 -0
- package/dist/templates/knowledge/dense.d.ts +87 -0
- package/dist/templates/knowledge/dense.js +158 -0
- package/dist/templates/knowledge/flow.d.ts +328 -0
- package/dist/templates/knowledge/flow.js +509 -0
- package/dist/templates/knowledge/retriever.d.ts +75 -0
- package/dist/templates/knowledge/retriever.js +204 -0
- package/dist/templates/knowledge/service.d.ts +77 -0
- package/dist/templates/knowledge/service.js +316 -0
- package/dist/templates/knowledge/text.d.ts +31 -0
- package/dist/templates/knowledge/text.js +66 -0
- package/dist/templates/knowledge/types.d.ts +120 -0
- package/dist/templates/knowledge/types.js +2 -0
- package/dist/templates/locale.d.ts +259 -0
- package/dist/templates/locale.js +4 -0
- package/dist/templates/locales/en-lexicons.d.ts +9 -0
- package/dist/templates/locales/en-lexicons.js +101 -0
- package/dist/templates/locales/en.d.ts +132 -0
- package/dist/templates/locales/en.js +261 -0
- package/dist/templates/locales/es.d.ts +65 -0
- package/dist/templates/locales/es.js +208 -0
- package/dist/templates/locales/hi.d.ts +47 -0
- package/dist/templates/locales/hi.js +235 -0
- package/dist/templates/locales/id.d.ts +43 -0
- package/dist/templates/locales/id.js +127 -0
- package/dist/templates/locales/index.d.ts +34 -0
- package/dist/templates/locales/index.js +112 -0
- package/dist/templates/locales/kk-lexicons.d.ts +22 -0
- package/dist/templates/locales/kk-lexicons.js +89 -0
- package/dist/templates/locales/kk.d.ts +140 -0
- package/dist/templates/locales/kk.js +306 -0
- package/dist/templates/locales/kn.d.ts +29 -0
- package/dist/templates/locales/kn.js +22 -0
- package/dist/templates/locales/listen-only.d.ts +15 -0
- package/dist/templates/locales/listen-only.js +27 -0
- package/dist/templates/locales/ms-lexicons.d.ts +13 -0
- package/dist/templates/locales/ms-lexicons.js +113 -0
- package/dist/templates/locales/ms.d.ts +76 -0
- package/dist/templates/locales/ms.js +179 -0
- package/dist/templates/locales/parse.d.ts +86 -0
- package/dist/templates/locales/parse.js +461 -0
- package/dist/templates/locales/ru-lexicons.d.ts +27 -0
- package/dist/templates/locales/ru-lexicons.js +127 -0
- package/dist/templates/locales/ru-stem.d.ts +2 -0
- package/dist/templates/locales/ru-stem.js +53 -0
- package/dist/templates/locales/ru.d.ts +143 -0
- package/dist/templates/locales/ru.js +387 -0
- package/dist/templates/locales/shared.d.ts +122 -0
- package/dist/templates/locales/shared.js +318 -0
- package/dist/templates/locales/ta.d.ts +29 -0
- package/dist/templates/locales/ta.js +22 -0
- package/dist/templates/locales/te.d.ts +29 -0
- package/dist/templates/locales/te.js +22 -0
- package/dist/templates/locales/tl-lexicons.d.ts +2 -0
- package/dist/templates/locales/tl-lexicons.js +230 -0
- package/dist/templates/locales/tl.d.ts +59 -0
- package/dist/templates/locales/tl.js +82 -0
- package/dist/templates/locales/vi.d.ts +59 -0
- package/dist/templates/locales/vi.js +160 -0
- package/dist/templates/locales/word-regex.d.ts +13 -0
- package/dist/templates/locales/word-regex.js +43 -0
- package/dist/templates/locales/words-kk.d.ts +2 -0
- package/dist/templates/locales/words-kk.js +23 -0
- package/dist/templates/locales/words-ru.d.ts +4 -0
- package/dist/templates/locales/words-ru.js +92 -0
- package/dist/templates/spec.d.ts +2856 -0
- package/dist/templates/spec.js +2 -0
- package/dist/testing/fake-channel.d.ts +0 -1
- package/dist/testing/fake-channel.js +0 -1
- package/dist/testing/index.d.ts +24 -1
- package/dist/testing/index.js +117 -2
- package/dist/voice/call-voice.d.ts +581 -0
- package/dist/voice/call-voice.js +1399 -0
- package/dist/voice/intent-interrupt.d.ts +32 -0
- package/dist/voice/intent-interrupt.js +91 -0
- package/dist/voice/self-echo.d.ts +28 -0
- package/dist/voice/self-echo.js +135 -0
- package/dist/voice/sentence-tag.d.ts +5 -0
- package/dist/voice/sentence-tag.js +42 -0
- package/dist/voice/speech-leak.d.ts +74 -0
- package/dist/voice/speech-leak.js +216 -0
- package/dist/voice/transfer.d.ts +90 -0
- package/dist/voice/transfer.js +331 -0
- package/dist/voice/turn-timing.d.ts +293 -0
- package/dist/voice/turn-timing.js +567 -0
- package/docs/README.md +3 -6
- package/docs/framework/README.md +6 -10
- package/docs/framework/architecture.md +2 -2
- package/docs/framework/container-and-di.md +1 -2
- package/docs/framework/invariants.md +6 -6
- package/docs/framework/package-layout.md +17 -23
- package/docs/framework/testing.md +8 -6
- package/package.json +22 -55
- package/skill/AGENTS.md +43 -0
- package/skill/AGENTS.recommend.md +27 -0
- package/skill/SKILL.md +100 -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/library-dev.md +84 -0
- package/skill/references/locales.md +149 -0
- package/skill/references/migration.md +133 -0
- package/skill/references/new-agent.md +170 -0
- package/skill/references/porting.md +165 -0
- package/templates/agent/README.md +55 -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,8 @@
|
|
|
1
|
+
import type { Turn } from './context';
|
|
2
|
+
export declare function voicemail(cx: Turn, text: string, source: string): boolean;
|
|
3
|
+
/** A detector of the event source fired (NLU): the line goes to the transcript, then `voicemail.then`. */
|
|
4
|
+
export declare function voicemailDetected(cx: Turn, text: string): void;
|
|
5
|
+
export declare function voicemailThen(cx: Turn, text: string): void;
|
|
6
|
+
export declare function looped(cx: Turn, text: string): boolean;
|
|
7
|
+
export declare function repeatedLine(cx: Turn, norm: string, text: string): boolean;
|
|
8
|
+
export declare function cyclingMenu(cx: Turn, norm: string, text: string): boolean;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cyclingMenu = exports.repeatedLine = exports.looped = exports.voicemailThen = exports.voicemailDetected = exports.voicemail = void 0;
|
|
4
|
+
// Voicemail: phrases on finals and dropped lines, a detector of the event source, looped recordings and cycling menus,
|
|
5
|
+
// and `voicemail.then`.
|
|
6
|
+
const core_1 = require("../../../call/extraction/core");
|
|
7
|
+
const match_1 = require("../match");
|
|
8
|
+
function voicemail(cx, text, source) {
|
|
9
|
+
if (!cx.v.voicemail.phrases.length || !cx.cfg.voicemail)
|
|
10
|
+
return false;
|
|
11
|
+
if (cx.cfg.voicemail.scope === 'beforeFirstTurn' && cx.d.callerTurns > 0)
|
|
12
|
+
return false;
|
|
13
|
+
if (cx.cfg.voicemail.when && !cx.cfg.voicemail.when(cx.core.view(cx.d)))
|
|
14
|
+
return false;
|
|
15
|
+
const view = cx.core.view(cx.d);
|
|
16
|
+
const hit = cx.v.voicemail.phrases.findIndex((t) => t(text, view));
|
|
17
|
+
if (hit < 0)
|
|
18
|
+
return false;
|
|
19
|
+
cx.log('voicemail_detected', { source, userText: text });
|
|
20
|
+
if (cx.v.voicemail.phraseTranscript[hit])
|
|
21
|
+
cx.addLine('caller', text);
|
|
22
|
+
voicemailThen(cx, text);
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
exports.voicemail = voicemail;
|
|
26
|
+
/** A detector of the event source fired (NLU): the line goes to the transcript, then `voicemail.then`. */
|
|
27
|
+
function voicemailDetected(cx, text) {
|
|
28
|
+
if (!cx.cfg.voicemail || cx.d.phase === 'closing')
|
|
29
|
+
return;
|
|
30
|
+
if (cx.cfg.voicemail.scope === 'beforeFirstTurn' && cx.d.callerTurns > 0)
|
|
31
|
+
return;
|
|
32
|
+
if (cx.cfg.voicemail.when && !cx.cfg.voicemail.when(cx.core.view(cx.d)))
|
|
33
|
+
return;
|
|
34
|
+
cx.addLine('caller', text);
|
|
35
|
+
voicemailThen(cx, text);
|
|
36
|
+
}
|
|
37
|
+
exports.voicemailDetected = voicemailDetected;
|
|
38
|
+
function voicemailThen(cx, text) {
|
|
39
|
+
if (!cx.cfg.voicemail?.then) {
|
|
40
|
+
// Default: hang up at once (no grace), result voicemail.
|
|
41
|
+
if (cx.d.phase === 'closing')
|
|
42
|
+
return;
|
|
43
|
+
cx.d.result = core_1.BaseResult.VOICEMAIL;
|
|
44
|
+
cx.d.phase = 'closing';
|
|
45
|
+
cx.log('voicemail, hanging up', { result: cx.d.result });
|
|
46
|
+
cx.fx.push({ type: 'hangupNow', reason: 'voicemail', tailMs: 0 });
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const then = cx.cfg.voicemail.then;
|
|
50
|
+
const wasClosing = cx.d.phase === 'closing';
|
|
51
|
+
const s = { ...cx.d, phase: wasClosing ? 'conversation' : cx.d.phase };
|
|
52
|
+
const done = cx.run(s, then, { line: text, id: 'voicemail' });
|
|
53
|
+
cx.set(done.state);
|
|
54
|
+
cx.fx.push(...done.effects);
|
|
55
|
+
}
|
|
56
|
+
exports.voicemailThen = voicemailThen;
|
|
57
|
+
function looped(cx, text) {
|
|
58
|
+
const norm = (0, match_1.normalizeLine)(text);
|
|
59
|
+
const repeated = repeatedLine(cx, norm, text);
|
|
60
|
+
const cycling = cyclingMenu(cx, norm, text);
|
|
61
|
+
return repeated || cycling;
|
|
62
|
+
}
|
|
63
|
+
exports.looped = looped;
|
|
64
|
+
function repeatedLine(cx, norm, text) {
|
|
65
|
+
const loop = cx.v.voicemail.loop;
|
|
66
|
+
if (!loop || loop.repeats < 2 || loop.minChars <= 0)
|
|
67
|
+
return false;
|
|
68
|
+
const d = cx.d;
|
|
69
|
+
const previous = d.vm.last;
|
|
70
|
+
const repeats = norm.length >= loop.minChars && previous.length >= loop.minChars && (previous.includes(norm) || norm.includes(previous));
|
|
71
|
+
const loops = repeats ? Math.max(d.vm.loops, 1) + 1 : 0;
|
|
72
|
+
d.vm = { ...d.vm, last: norm, loops };
|
|
73
|
+
if (!repeats || loops < loop.repeats)
|
|
74
|
+
return false;
|
|
75
|
+
cx.log('looped_recording_detected', { userText: text, repeats: loops });
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
exports.repeatedLine = repeatedLine;
|
|
79
|
+
function cyclingMenu(cx, norm, text) {
|
|
80
|
+
const menu = cx.v.voicemail.menu;
|
|
81
|
+
if (!menu || menu.recurrences < 2 || menu.minChars <= 0 || menu.windowLines <= 0)
|
|
82
|
+
return false;
|
|
83
|
+
const d = cx.d;
|
|
84
|
+
const seq = d.vm.seq + 1;
|
|
85
|
+
const oldest = seq - menu.windowLines;
|
|
86
|
+
const recent = d.vm.recent.filter((u) => u.seq > oldest);
|
|
87
|
+
let rec = d.vm.menu.filter((u) => u.seq > oldest);
|
|
88
|
+
const recurred = norm.length >= menu.minChars && recent.some((u) => u.text === norm && u.seq < seq - 1);
|
|
89
|
+
recent.push({ text: norm, seq });
|
|
90
|
+
if (recurred)
|
|
91
|
+
rec = [...rec, { text: norm, seq }];
|
|
92
|
+
d.vm = { ...d.vm, seq, recent, menu: rec };
|
|
93
|
+
if (!recurred)
|
|
94
|
+
return false;
|
|
95
|
+
const distinct = new Set(rec.map((u) => u.text)).size;
|
|
96
|
+
if (rec.length < menu.recurrences || distinct < 2)
|
|
97
|
+
return false;
|
|
98
|
+
cx.log('looped_menu_detected', { userText: text, recurrences: rec.length, distinctLines: distinct });
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
exports.cyclingMenu = cyclingMenu;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { TtsSpec } from '../spec';
|
|
2
|
+
export type VoiceVariant = NonNullable<TtsSpec['variants']>[number];
|
|
3
|
+
/** The default call variable of the variant (`voice.tts.variantVar`). */
|
|
4
|
+
export declare const VARIANT_VAR = "voice";
|
|
5
|
+
/** FNV-1a 32-bit of a string, unsigned. */
|
|
6
|
+
export declare function fnv1a(seed: string): number;
|
|
7
|
+
/**
|
|
8
|
+
* The variant of the call by the hash (`null` without variants): the hash walks the weighted list (`variantPick`
|
|
9
|
+
* `modulo` / `range`; `random` without its kept variable reads as `modulo`).
|
|
10
|
+
*/
|
|
11
|
+
export declare function pickVoiceVariant(tts: TtsSpec, callUuid: string): VoiceVariant | null;
|
|
12
|
+
/** A weighted variant drawn by the random source (`null` without variants). */
|
|
13
|
+
export declare function randomVoiceVariant(tts: TtsSpec, random?: () => number): VoiceVariant | null;
|
|
14
|
+
/** Whether the call variable `variantVar` holds the call's variant (some variant has `vars`, or the pick is random). */
|
|
15
|
+
export declare function keepsVariantVar(tts: TtsSpec): boolean;
|
|
16
|
+
/** Whether the variant of a call is known only once its variables are (`variantBy`, `{ by }`, `random`). */
|
|
17
|
+
export declare function variantFromVars(tts: TtsSpec): boolean;
|
|
18
|
+
/** The value of the variant variable: `{ tag, ...vars }`. */
|
|
19
|
+
export declare function variantVarValue(v: VoiceVariant): Readonly<Record<string, unknown>>;
|
|
20
|
+
/**
|
|
21
|
+
* The call variables the variant sets before the input fields (`{}` when it keeps none): the hash pick, or a random
|
|
22
|
+
* draw for `random`. A variant named by the variables (`variantBy`, `{ by }`) is not known yet: none.
|
|
23
|
+
*/
|
|
24
|
+
export declare function variantSeedVars(tts: TtsSpec, callUuid: string, random?: () => number): Readonly<Record<string, unknown>>;
|
|
25
|
+
/**
|
|
26
|
+
* The variant of the call: the one the variant variable keeps, else the one `variantBy` / `variantPick.by` names
|
|
27
|
+
* from the call's variables, else the hash pick.
|
|
28
|
+
*/
|
|
29
|
+
export declare function callVoiceVariant(tts: TtsSpec, callUuid: string, vars?: Readonly<Record<string, unknown>> | null): VoiceVariant | null;
|
|
30
|
+
/**
|
|
31
|
+
* After the input fields: the variant variable of a call whose variant the fields named (`variantBy`, `{ by }`), when
|
|
32
|
+
* no field of that name set it (written into `vars`).
|
|
33
|
+
*/
|
|
34
|
+
export declare function completeVariantVar(tts: TtsSpec, callUuid: string, vars: Record<string, unknown>): void;
|
|
35
|
+
/** `{voice}` in a clip's record name or URL, filled with the call's variant tag (none: left as it is). */
|
|
36
|
+
export declare function withVoice(text: string, tag: string | null | undefined): string;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withVoice = exports.completeVariantVar = exports.callVoiceVariant = exports.variantSeedVars = exports.variantVarValue = exports.variantFromVars = exports.keepsVariantVar = exports.randomVoiceVariant = exports.pickVoiceVariant = exports.fnv1a = exports.VARIANT_VAR = void 0;
|
|
4
|
+
const compiled_1 = require("../expr/compiled");
|
|
5
|
+
const context_1 = require("../expr/context");
|
|
6
|
+
const evaluate_1 = require("../expr/evaluate");
|
|
7
|
+
const values_1 = require("../expr/values");
|
|
8
|
+
/** The default call variable of the variant (`voice.tts.variantVar`). */
|
|
9
|
+
exports.VARIANT_VAR = 'voice';
|
|
10
|
+
/** FNV-1a 32-bit of a string, unsigned. */
|
|
11
|
+
function fnv1a(seed) {
|
|
12
|
+
let hash = 0x811c9dc5;
|
|
13
|
+
for (let i = 0; i < seed.length; i++) {
|
|
14
|
+
hash ^= seed.charCodeAt(i);
|
|
15
|
+
hash = Math.imul(hash, 0x01000193);
|
|
16
|
+
}
|
|
17
|
+
return hash >>> 0;
|
|
18
|
+
}
|
|
19
|
+
exports.fnv1a = fnv1a;
|
|
20
|
+
/** The pick mode without a naming variable (`{ by }` falls back to its `otherwise`). */
|
|
21
|
+
function modeOf(tts) {
|
|
22
|
+
const p = tts.variantPick;
|
|
23
|
+
if (p == null)
|
|
24
|
+
return 'modulo';
|
|
25
|
+
return typeof p === 'object' ? p.otherwise ?? 'modulo' : p;
|
|
26
|
+
}
|
|
27
|
+
const weightsOf = (list) => list.map((v) => Math.max(0, Math.round(v.weight ?? 1)));
|
|
28
|
+
/** Walks the weighted list with `r` in [0, total). */
|
|
29
|
+
function walk(list, weights, r) {
|
|
30
|
+
for (let i = 0; i < list.length; i++) {
|
|
31
|
+
if (r < weights[i])
|
|
32
|
+
return list[i];
|
|
33
|
+
r -= weights[i];
|
|
34
|
+
}
|
|
35
|
+
return list[list.length - 1];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The variant of the call by the hash (`null` without variants): the hash walks the weighted list (`variantPick`
|
|
39
|
+
* `modulo` / `range`; `random` without its kept variable reads as `modulo`).
|
|
40
|
+
*/
|
|
41
|
+
function pickVoiceVariant(tts, callUuid) {
|
|
42
|
+
const list = tts.variants ?? [];
|
|
43
|
+
if (!list.length)
|
|
44
|
+
return null;
|
|
45
|
+
const weights = weightsOf(list);
|
|
46
|
+
const total = weights.reduce((a, b) => a + b, 0);
|
|
47
|
+
if (total <= 0)
|
|
48
|
+
return list[0];
|
|
49
|
+
const h = fnv1a(callUuid);
|
|
50
|
+
return walk(list, weights, modeOf(tts) === 'range' ? Math.floor((h / 2 ** 32) * total) : h % total);
|
|
51
|
+
}
|
|
52
|
+
exports.pickVoiceVariant = pickVoiceVariant;
|
|
53
|
+
/** A weighted variant drawn by the random source (`null` without variants). */
|
|
54
|
+
function randomVoiceVariant(tts, random = Math.random) {
|
|
55
|
+
const list = tts.variants ?? [];
|
|
56
|
+
if (!list.length)
|
|
57
|
+
return null;
|
|
58
|
+
const weights = weightsOf(list);
|
|
59
|
+
const total = weights.reduce((a, b) => a + b, 0);
|
|
60
|
+
if (total <= 0)
|
|
61
|
+
return list[0];
|
|
62
|
+
return walk(list, weights, Math.min(total - 1, Math.floor(random() * total)));
|
|
63
|
+
}
|
|
64
|
+
exports.randomVoiceVariant = randomVoiceVariant;
|
|
65
|
+
/** Whether the call variable `variantVar` holds the call's variant (some variant has `vars`, or the pick is random). */
|
|
66
|
+
function keepsVariantVar(tts) {
|
|
67
|
+
if (!tts.variants?.length)
|
|
68
|
+
return false;
|
|
69
|
+
return tts.variantPick === 'random' || tts.variants.some((v) => v.vars != null);
|
|
70
|
+
}
|
|
71
|
+
exports.keepsVariantVar = keepsVariantVar;
|
|
72
|
+
/** Whether the variant of a call is known only once its variables are (`variantBy`, `{ by }`, `random`). */
|
|
73
|
+
function variantFromVars(tts) {
|
|
74
|
+
if (!tts.variants?.length)
|
|
75
|
+
return false;
|
|
76
|
+
return tts.variantBy != null || typeof tts.variantPick === 'object' || tts.variantPick === 'random';
|
|
77
|
+
}
|
|
78
|
+
exports.variantFromVars = variantFromVars;
|
|
79
|
+
/** The value of the variant variable: `{ tag, ...vars }`. */
|
|
80
|
+
function variantVarValue(v) {
|
|
81
|
+
return { tag: v.tag, ...(v.vars ?? {}) };
|
|
82
|
+
}
|
|
83
|
+
exports.variantVarValue = variantVarValue;
|
|
84
|
+
/**
|
|
85
|
+
* The call variables the variant sets before the input fields (`{}` when it keeps none): the hash pick, or a random
|
|
86
|
+
* draw for `random`. A variant named by the variables (`variantBy`, `{ by }`) is not known yet: none.
|
|
87
|
+
*/
|
|
88
|
+
function variantSeedVars(tts, callUuid, random = Math.random) {
|
|
89
|
+
if (!keepsVariantVar(tts) || tts.variantBy != null || typeof tts.variantPick === 'object')
|
|
90
|
+
return {};
|
|
91
|
+
const v = tts.variantPick === 'random' ? randomVoiceVariant(tts, random) : pickVoiceVariant(tts, callUuid);
|
|
92
|
+
return v ? { [tts.variantVar ?? exports.VARIANT_VAR]: variantVarValue(v) } : {};
|
|
93
|
+
}
|
|
94
|
+
exports.variantSeedVars = variantSeedVars;
|
|
95
|
+
const byVars = new WeakMap();
|
|
96
|
+
/** An expression over the call variables read as a tag (cached per expression). */
|
|
97
|
+
function tagFn(e) {
|
|
98
|
+
let fn = byVars.get(e);
|
|
99
|
+
if (!fn) {
|
|
100
|
+
fn = (v) => {
|
|
101
|
+
const x = (0, evaluate_1.evalExpr)(e, (0, context_1.exprContext)({ vars: v }));
|
|
102
|
+
return (0, values_1.isEmpty)(x) ? null : (0, values_1.toText)(x);
|
|
103
|
+
};
|
|
104
|
+
byVars.set(e, fn);
|
|
105
|
+
}
|
|
106
|
+
return fn;
|
|
107
|
+
}
|
|
108
|
+
/** The tag the call variables name (`variantBy`, `variantPick.by`), or `null`. */
|
|
109
|
+
function namedTag(tts, vars) {
|
|
110
|
+
const by = tts.variantBy;
|
|
111
|
+
if (by != null) {
|
|
112
|
+
const tag = typeof by === 'function' ? (0, compiled_1.noData)(by)(vars) : tagFn(by)(vars);
|
|
113
|
+
return tag ? String(tag) : null;
|
|
114
|
+
}
|
|
115
|
+
const p = tts.variantPick;
|
|
116
|
+
return p != null && typeof p === 'object' ? tagFn(p.by)(vars) : null;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The variant of the call: the one the variant variable keeps, else the one `variantBy` / `variantPick.by` names
|
|
120
|
+
* from the call's variables, else the hash pick.
|
|
121
|
+
*/
|
|
122
|
+
function callVoiceVariant(tts, callUuid, vars) {
|
|
123
|
+
const list = tts.variants ?? [];
|
|
124
|
+
if (vars && list.length) {
|
|
125
|
+
if (keepsVariantVar(tts)) {
|
|
126
|
+
const kept = vars[tts.variantVar ?? exports.VARIANT_VAR];
|
|
127
|
+
const tag = (0, values_1.isPlainObject)(kept) ? kept['tag'] : null;
|
|
128
|
+
const hit = typeof tag === 'string' ? list.find((v) => v.tag === tag) : undefined;
|
|
129
|
+
if (hit)
|
|
130
|
+
return hit;
|
|
131
|
+
}
|
|
132
|
+
const tag = namedTag(tts, vars);
|
|
133
|
+
const named = tag ? list.find((v) => v.tag === tag) : undefined;
|
|
134
|
+
if (named)
|
|
135
|
+
return named;
|
|
136
|
+
}
|
|
137
|
+
return pickVoiceVariant(tts, callUuid);
|
|
138
|
+
}
|
|
139
|
+
exports.callVoiceVariant = callVoiceVariant;
|
|
140
|
+
/**
|
|
141
|
+
* After the input fields: the variant variable of a call whose variant the fields named (`variantBy`, `{ by }`), when
|
|
142
|
+
* no field of that name set it (written into `vars`).
|
|
143
|
+
*/
|
|
144
|
+
function completeVariantVar(tts, callUuid, vars) {
|
|
145
|
+
if (!keepsVariantVar(tts))
|
|
146
|
+
return;
|
|
147
|
+
const name = tts.variantVar ?? exports.VARIANT_VAR;
|
|
148
|
+
if (Object.prototype.hasOwnProperty.call(vars, name))
|
|
149
|
+
return;
|
|
150
|
+
const v = callVoiceVariant(tts, callUuid, vars);
|
|
151
|
+
if (v)
|
|
152
|
+
vars[name] = variantVarValue(v);
|
|
153
|
+
}
|
|
154
|
+
exports.completeVariantVar = completeVariantVar;
|
|
155
|
+
/** `{voice}` in a clip's record name or URL, filled with the call's variant tag (none: left as it is). */
|
|
156
|
+
function withVoice(text, tag) {
|
|
157
|
+
return tag ? text.replace(/\{voice\}/g, tag) : text;
|
|
158
|
+
}
|
|
159
|
+
exports.withVoice = withVoice;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { EngineEffect, EngineState } from './dialog';
|
|
2
|
+
import type { VoiceCore, VoiceEvent } from './turns/events';
|
|
3
|
+
export type { ClipItem, Done, RunContext, Runner, SilenceFacts, VoiceCore, VoiceEffect, VoiceEvent, VoiceSnapshot } from './turns/events';
|
|
4
|
+
export { GOODBYE_AFTER_SILENCE } from './turns/events';
|
|
5
|
+
export type { VoiceStep } from './config';
|
|
6
|
+
type Out = {
|
|
7
|
+
state: EngineState;
|
|
8
|
+
effects: EngineEffect[];
|
|
9
|
+
};
|
|
10
|
+
export declare function createVoiceTurns(core: VoiceCore): {
|
|
11
|
+
/** Reduce one event of the engine's call media. */
|
|
12
|
+
reduce(s: EngineState, e: VoiceEvent | {
|
|
13
|
+
type: 'VOICEMAIL';
|
|
14
|
+
text: string;
|
|
15
|
+
}, yes: ReadonlyMap<string, ReadonlySet<string>>): Out;
|
|
16
|
+
/**
|
|
17
|
+
* A failure the conversation cannot go on from (an effect that failed, agent code that threw): logged, and the
|
|
18
|
+
* call is hung up with its result as it is; nothing more while it is closing or transferred.
|
|
19
|
+
*/
|
|
20
|
+
failed(s: EngineState, source: string, error: string): Out;
|
|
21
|
+
/** Start of the call: eager LLM lines are requested first, then the first opening step. */
|
|
22
|
+
start(s: EngineState): Out;
|
|
23
|
+
};
|
|
24
|
+
export type VoiceTurns = ReturnType<typeof createVoiceTurns>;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createVoiceTurns = exports.GOODBYE_AFTER_SILENCE = void 0;
|
|
4
|
+
const carry_1 = require("./turns/carry");
|
|
5
|
+
const closing_1 = require("./turns/closing");
|
|
6
|
+
const context_1 = require("./turns/context");
|
|
7
|
+
const opening_1 = require("./turns/opening");
|
|
8
|
+
const overtalk_1 = require("./turns/overtalk");
|
|
9
|
+
const pending_1 = require("./turns/pending");
|
|
10
|
+
const rules_1 = require("./turns/rules");
|
|
11
|
+
const silence_1 = require("./turns/silence");
|
|
12
|
+
const transfer_1 = require("./turns/transfer");
|
|
13
|
+
const turn_1 = require("./turns/turn");
|
|
14
|
+
const voicemail_1 = require("./turns/voicemail");
|
|
15
|
+
const state_1 = require("./turns/state");
|
|
16
|
+
var events_1 = require("./turns/events");
|
|
17
|
+
Object.defineProperty(exports, "GOODBYE_AFTER_SILENCE", { enumerable: true, get: function () { return events_1.GOODBYE_AFTER_SILENCE; } });
|
|
18
|
+
function createVoiceTurns(core) {
|
|
19
|
+
const env = (0, context_1.turnEnv)(core);
|
|
20
|
+
return {
|
|
21
|
+
/** Reduce one event of the engine's call media. */
|
|
22
|
+
reduce(s, e, yes) {
|
|
23
|
+
const m = 'm' in e ? e.m : null;
|
|
24
|
+
// The time of the last media event: what `call.elapsedMs` counts to.
|
|
25
|
+
const cx = new context_1.Turn(env, (m ? { ...s, at: m.now } : { ...s }), m, yes);
|
|
26
|
+
switch (e.type) {
|
|
27
|
+
case 'CALLER_FINAL':
|
|
28
|
+
(0, turn_1.final)(cx, e.text);
|
|
29
|
+
break;
|
|
30
|
+
case 'CALLER_DROPPED':
|
|
31
|
+
(0, voicemail_1.voicemail)(cx, e.text, `dropped_${e.reason}`);
|
|
32
|
+
break;
|
|
33
|
+
case 'CALLER_SPEECH_START':
|
|
34
|
+
(0, carry_1.speechStart)(cx);
|
|
35
|
+
break;
|
|
36
|
+
case 'CALLER_PARTIAL':
|
|
37
|
+
(0, carry_1.partial)(cx, e.text);
|
|
38
|
+
break;
|
|
39
|
+
case 'TOOL_CALL':
|
|
40
|
+
(0, rules_1.toolCall)(cx, e.name);
|
|
41
|
+
break;
|
|
42
|
+
case 'VOICEMAIL':
|
|
43
|
+
(0, voicemail_1.voicemailDetected)(cx, e.text);
|
|
44
|
+
break;
|
|
45
|
+
case 'INPUT_UPDATED':
|
|
46
|
+
(0, opening_1.inputUpdated)(cx, e.vars, e.result);
|
|
47
|
+
break;
|
|
48
|
+
case 'AGENT_DRAINED':
|
|
49
|
+
(0, turn_1.drained)(cx);
|
|
50
|
+
break;
|
|
51
|
+
case 'GOODBYE_STARTED':
|
|
52
|
+
(0, closing_1.goodbyeStarted)(cx);
|
|
53
|
+
break;
|
|
54
|
+
case 'AGENT_SPOKEN':
|
|
55
|
+
(0, turn_1.spoken)(cx, e.text, e.unit);
|
|
56
|
+
break;
|
|
57
|
+
case 'CALL_RESULT':
|
|
58
|
+
(0, closing_1.callResult)(cx, e.result);
|
|
59
|
+
break;
|
|
60
|
+
case 'SILENCE_TIMEOUT':
|
|
61
|
+
(0, silence_1.silence)(cx, e.timeout);
|
|
62
|
+
break;
|
|
63
|
+
case 'AUDIO_DEAD':
|
|
64
|
+
(0, silence_1.deadAudio)(cx);
|
|
65
|
+
break;
|
|
66
|
+
case 'NO_PROGRESS':
|
|
67
|
+
(0, silence_1.noProgress)(cx);
|
|
68
|
+
break;
|
|
69
|
+
case 'VOICE_ANSWER':
|
|
70
|
+
(0, opening_1.voiceAnswer)(cx);
|
|
71
|
+
break;
|
|
72
|
+
case 'REPLAY_DUE':
|
|
73
|
+
(0, overtalk_1.replayDue)(cx);
|
|
74
|
+
break;
|
|
75
|
+
case 'CLASSIFIED':
|
|
76
|
+
(0, pending_1.classified)(cx, e.key, e.intents);
|
|
77
|
+
break;
|
|
78
|
+
case 'WAITING_FILLER':
|
|
79
|
+
(0, pending_1.waitingFiller)(cx, e.key);
|
|
80
|
+
break;
|
|
81
|
+
case 'HOOK_WAITING':
|
|
82
|
+
(0, pending_1.hookWaiting)(cx, e.key);
|
|
83
|
+
break;
|
|
84
|
+
case 'HOOK_RESULT':
|
|
85
|
+
(0, pending_1.hookResult)(cx, e.key, e.actions);
|
|
86
|
+
break;
|
|
87
|
+
case 'TRANSFER_REPLY':
|
|
88
|
+
(0, transfer_1.transferStart)(cx, e.via, e.spokeWords, e.trigger, e.blank ?? false);
|
|
89
|
+
break;
|
|
90
|
+
case 'EMPTY_EXHAUSTED':
|
|
91
|
+
(0, turn_1.emptyExhausted)(cx, e.errored, e.probe);
|
|
92
|
+
break;
|
|
93
|
+
case 'GUARD_REPLACED':
|
|
94
|
+
(0, turn_1.guardReplaced)(cx, e.text, e.alias, e.close);
|
|
95
|
+
break;
|
|
96
|
+
case 'REPLY_VARS':
|
|
97
|
+
cx.d.vars = { ...cx.d.vars, ...e.vars };
|
|
98
|
+
break;
|
|
99
|
+
case 'FLAG':
|
|
100
|
+
(0, rules_1.flagged)(cx, e.flag);
|
|
101
|
+
break;
|
|
102
|
+
case 'REPLY_ASR':
|
|
103
|
+
cx.d.replyAsrKeys = [...cx.d.replyAsrKeys, e.key];
|
|
104
|
+
break;
|
|
105
|
+
case 'CALLER_FINAL_REWORDED':
|
|
106
|
+
(0, turn_1.reworded)(cx, e.text, e.virtual);
|
|
107
|
+
break;
|
|
108
|
+
case 'TRANSFER_BRIDGED':
|
|
109
|
+
(0, transfer_1.transferBridged)(cx);
|
|
110
|
+
break;
|
|
111
|
+
case 'TRANSFER_FAILED':
|
|
112
|
+
(0, transfer_1.transferFailed)(cx, e.failure);
|
|
113
|
+
break;
|
|
114
|
+
case 'REVIEW_ACTIONS':
|
|
115
|
+
(0, turn_1.reviewActions)(cx, e.actions);
|
|
116
|
+
break;
|
|
117
|
+
case 'REPLY_PLAYED':
|
|
118
|
+
(0, state_1.replyPlayedEvent)(cx, e.text, e.heard);
|
|
119
|
+
break;
|
|
120
|
+
default: return { state: s, effects: [] };
|
|
121
|
+
}
|
|
122
|
+
return { state: cx.d, effects: cx.fx };
|
|
123
|
+
},
|
|
124
|
+
/**
|
|
125
|
+
* A failure the conversation cannot go on from (an effect that failed, agent code that threw): logged, and the
|
|
126
|
+
* call is hung up with its result as it is; nothing more while it is closing or transferred.
|
|
127
|
+
*/
|
|
128
|
+
failed(s, source, error) {
|
|
129
|
+
const cx = new context_1.Turn(env, { ...s }, null);
|
|
130
|
+
cx.log('engine_error', { source, error });
|
|
131
|
+
if (s.phase === 'closing' || s.transfer === 'started' || s.transfer === 'bridged')
|
|
132
|
+
return { state: s, effects: cx.fx };
|
|
133
|
+
cx.d.phase = 'closing';
|
|
134
|
+
cx.fx.push({ type: 'hangupNow', reason: 'engine_error' });
|
|
135
|
+
return { state: cx.d, effects: cx.fx };
|
|
136
|
+
},
|
|
137
|
+
/** Start of the call: eager LLM lines are requested first, then the first opening step. */
|
|
138
|
+
start(s) {
|
|
139
|
+
const cx = new context_1.Turn(env, { ...s }, null);
|
|
140
|
+
for (const r of env.cfg.rules) {
|
|
141
|
+
if (r.intents && r.nlu?.warmUp != null)
|
|
142
|
+
cx.fx.push({ type: 'warmUpNlu', text: r.nlu.warmUp, intents: r.intents, ...(r.nlu.language != null ? { language: r.nlu.language } : {}) });
|
|
143
|
+
}
|
|
144
|
+
// With a lookup still running the eager lines are requested once it is in (`INPUT_UPDATED`).
|
|
145
|
+
if (!s.lookupPending)
|
|
146
|
+
(0, opening_1.prefetchEager)(cx, 0);
|
|
147
|
+
if (env.voiceAnswerSteps)
|
|
148
|
+
cx.fx.push({ type: 'voiceAnswer', op: 'on' });
|
|
149
|
+
const presay = env.cfg.presay?.(env.core.view(cx.d)) ?? [];
|
|
150
|
+
if (presay.length)
|
|
151
|
+
cx.fx.push({ type: 'presay', texts: presay });
|
|
152
|
+
(0, opening_1.enter)(cx, 0);
|
|
153
|
+
return { state: cx.d, effects: cx.fx };
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
exports.createVoiceTurns = createVoiceTurns;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { Observable, Subject } from 'rxjs';
|
|
3
|
+
import { type AsrHandle, type PlatformApi, type ScriptFn, type ScriptLogger } from '@voctiv/agent-sdk';
|
|
4
|
+
import { type OnOnlineCall } from '../../core/hooks';
|
|
5
|
+
import { type DialogDefinition, type Transition } from '../../dialog/dialog-definition';
|
|
6
|
+
import { DialogPorts, type PortRunResult } from '../../dialog/dialog-ports';
|
|
7
|
+
import type { DialogEventSource } from '../../dialog-events/event-source';
|
|
8
|
+
import { type VoicemailConfig } from '../../call/voicemail';
|
|
9
|
+
import type { AgentHooks, EngineSpec, CallView } from '../spec';
|
|
10
|
+
import { type SourceScope } from '../business/sources';
|
|
11
|
+
import { type EngineDialogConfig } from './config';
|
|
12
|
+
import { EngineCall } from './call';
|
|
13
|
+
import { type EngineEffect, type EngineEvent, type EngineState } from './dialog';
|
|
14
|
+
import { EngineMedia, type EngineMediaSettings, type ResolvedVoice, type SourcedVoice } from './media';
|
|
15
|
+
import type { VoiceEvent } from './voice-dialog';
|
|
16
|
+
/** Voice values of the agent file that are read from sources per call (none: `undefined`). */
|
|
17
|
+
export declare function sourcedVoiceOf(file: EngineSpec): SourcedVoice | undefined;
|
|
18
|
+
/** The call's values of the sourced voice fields (a source that fails or gives nothing: the field's `default`). */
|
|
19
|
+
export declare function resolveVoice(sv: SourcedVoice, scope: SourceScope, logger?: ScriptLogger): Promise<ResolvedVoice>;
|
|
20
|
+
/** NLU voicemail detectors of the agent file (phrases, loops and menus are the reducer's). */
|
|
21
|
+
type NluDetector = {
|
|
22
|
+
readonly config: VoicemailConfig;
|
|
23
|
+
readonly onPartials: boolean;
|
|
24
|
+
readonly debounce: boolean;
|
|
25
|
+
readonly fallbackFirst: boolean;
|
|
26
|
+
};
|
|
27
|
+
/** The media settings of the call from the agent file. */
|
|
28
|
+
export declare function mediaSettings(file: EngineSpec, cfg: EngineDialogConfig): EngineMediaSettings & {
|
|
29
|
+
readonly bargeIn: BargeInSettings;
|
|
30
|
+
readonly eot: EotSettings;
|
|
31
|
+
};
|
|
32
|
+
interface BargeInSettings {
|
|
33
|
+
readonly enabled: boolean;
|
|
34
|
+
readonly interruptPatterns: readonly RegExp[];
|
|
35
|
+
readonly partialMinChars: number;
|
|
36
|
+
readonly minVadProbability: number;
|
|
37
|
+
readonly lengthTriggersInterrupt: boolean;
|
|
38
|
+
readonly whileSilent: boolean;
|
|
39
|
+
readonly countLetters: boolean;
|
|
40
|
+
}
|
|
41
|
+
interface EotSettings {
|
|
42
|
+
readonly finalizeDebounceMs: number;
|
|
43
|
+
readonly quietWindowMs?: number;
|
|
44
|
+
readonly holdOn?: RegExp;
|
|
45
|
+
readonly dropLine?: RegExp;
|
|
46
|
+
readonly minPeakVad?: number;
|
|
47
|
+
/** The peak counts over everything since the previous final (`voice.minPeakVad.over: 'line'`). */
|
|
48
|
+
readonly minPeakVadOver?: 'line';
|
|
49
|
+
readonly minPeakVadExcept?: readonly RegExp[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The call's dialog: the engine reducer with this call's variables; keeps the last state. It owns the commit of the
|
|
53
|
+
* hooks' state around the pure reduce: before an event, a snapshot of what the hooks keep (`HookApi.state`) goes into
|
|
54
|
+
* the state the reducer gets; after it, what agent code wrote to `call.hookState` in the reduce goes back to the hooks.
|
|
55
|
+
*/
|
|
56
|
+
export declare class EngineDialogDefinition implements DialogDefinition<EngineState, EngineEvent, EngineEffect> {
|
|
57
|
+
private readonly dialog;
|
|
58
|
+
/** What the call's hooks keep (the object hooks get as `api.state`). */
|
|
59
|
+
private readonly hookStore;
|
|
60
|
+
readonly initial: EngineState;
|
|
61
|
+
/** The state after the last event (what the host holds). */
|
|
62
|
+
state: EngineState;
|
|
63
|
+
constructor(cfg: EngineDialogConfig, call: EngineCall);
|
|
64
|
+
reduce(s: EngineState, e: EngineEvent): Transition<EngineState, EngineEffect>;
|
|
65
|
+
/** The call as agent code outside the reducer sees it (hooks, filters, the media): the hooks' state as it is now. */
|
|
66
|
+
view(): CallView;
|
|
67
|
+
/** The reducer's answer to a tool call of the reply in flight. */
|
|
68
|
+
toolDecision(names: readonly string[]): 'latched' | 'refused' | null;
|
|
69
|
+
private live;
|
|
70
|
+
}
|
|
71
|
+
/** Media events as the reducer's events (and the ports' own: NLU answers, filler timers). */
|
|
72
|
+
export declare class EngineVoiceSource implements DialogEventSource {
|
|
73
|
+
private readonly media;
|
|
74
|
+
private readonly call;
|
|
75
|
+
readonly name = "engine-voice";
|
|
76
|
+
readonly own: Subject<VoiceEvent>;
|
|
77
|
+
constructor(media: EngineMedia, call: EngineCall);
|
|
78
|
+
listen(): Observable<VoiceEvent>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* NLU voicemail detectors on caller partials and finals (`VOICEMAIL { text }`), while detection is on. It reads a final
|
|
82
|
+
* before the conversation does (listed first), so a final its fallback patterns match is voicemail, not a turn.
|
|
83
|
+
*/
|
|
84
|
+
export declare class EngineVoicemailSource implements DialogEventSource {
|
|
85
|
+
private readonly detectors;
|
|
86
|
+
private readonly asr$;
|
|
87
|
+
private readonly media;
|
|
88
|
+
private readonly platform;
|
|
89
|
+
private readonly logger;
|
|
90
|
+
private readonly cfg;
|
|
91
|
+
private readonly dialog;
|
|
92
|
+
readonly name = "engine-voicemail";
|
|
93
|
+
constructor(detectors: readonly NluDetector[], asr$: Observable<AsrHandle | null>, media: EngineMedia, platform: PlatformApi, logger: ScriptLogger, cfg: EngineDialogConfig, dialog: EngineDialogDefinition);
|
|
94
|
+
/** Detection runs until the first caller turn (`scope: 'beforeFirstTurn'`) or the whole call. */
|
|
95
|
+
private active;
|
|
96
|
+
listen(): Observable<{
|
|
97
|
+
type: 'VOICEMAIL';
|
|
98
|
+
text: string;
|
|
99
|
+
}>;
|
|
100
|
+
private debounced;
|
|
101
|
+
private detector;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The `'debounce'` timing of an NLU voicemail detector: a partial is checked `throttleMs` after the last one, one
|
|
105
|
+
* request at a time; every final is held until its own NLU answer (the media's final gate).
|
|
106
|
+
*/
|
|
107
|
+
export declare function debouncedVoicemail(d: NluDetector, io: {
|
|
108
|
+
readonly platform: PlatformApi;
|
|
109
|
+
readonly logger: ScriptLogger;
|
|
110
|
+
readonly partial$: Observable<string>;
|
|
111
|
+
readonly speechStart$: Observable<unknown>;
|
|
112
|
+
readonly active: () => boolean;
|
|
113
|
+
readonly setGate: (gate: ((text: string) => Promise<boolean>) | null) => void;
|
|
114
|
+
readonly onPartialHit: (text: string) => void;
|
|
115
|
+
}): Observable<{
|
|
116
|
+
type: 'VOICEMAIL';
|
|
117
|
+
text: string;
|
|
118
|
+
}>;
|
|
119
|
+
/** The agent's hooks and integrations, for hooks run during the call. */
|
|
120
|
+
interface EngineHooks {
|
|
121
|
+
readonly hooks: AgentHooks;
|
|
122
|
+
readonly integrations: EngineSpec['integrations'];
|
|
123
|
+
/** The call view before the conversation has one. */
|
|
124
|
+
readonly emptyView: CallView;
|
|
125
|
+
/** A hook of a rule, step or rung that has not answered by then counts as failed (no actions). */
|
|
126
|
+
readonly timeoutMs?: number;
|
|
127
|
+
/** The agent file has a transfer block (a hook's `transfer` action needs one). */
|
|
128
|
+
readonly transfer: boolean;
|
|
129
|
+
}
|
|
130
|
+
/** Default time an asynchronous rule / step hook gets to answer. */
|
|
131
|
+
export declare const DEFAULT_HOOK_TIMEOUT_MS = 10000;
|
|
132
|
+
/** Engine options of {@link defineVoiceAgent} (not part of the agent file). */
|
|
133
|
+
export interface VoiceAgentEngineOptions {
|
|
134
|
+
/** Time an asynchronous hook of a rule, step or rung gets before it counts as failed. Default 10 s; 0 = no limit. */
|
|
135
|
+
readonly hookTimeoutMs?: number;
|
|
136
|
+
}
|
|
137
|
+
/** `phase: 'answer'` hook steps: started when the live call is answered, before the media (nothing waits for them). */
|
|
138
|
+
export declare class EngineAnswerHooks implements OnOnlineCall {
|
|
139
|
+
private readonly context;
|
|
140
|
+
private readonly logger;
|
|
141
|
+
private readonly call;
|
|
142
|
+
private readonly agentHooks;
|
|
143
|
+
constructor(context: import('@voctiv/agent-sdk').ScriptDialogContext, logger: ScriptLogger, call: EngineCall, agentHooks: EngineHooks);
|
|
144
|
+
onOnlineCall(): void;
|
|
145
|
+
}
|
|
146
|
+
/** The reducer's effects on the media. */
|
|
147
|
+
export declare class EngineVoicePorts extends DialogPorts {
|
|
148
|
+
private readonly media;
|
|
149
|
+
private readonly source;
|
|
150
|
+
private readonly platform;
|
|
151
|
+
private readonly logger;
|
|
152
|
+
private readonly dialog;
|
|
153
|
+
private readonly call;
|
|
154
|
+
private readonly agentHooks;
|
|
155
|
+
private hookApiOf;
|
|
156
|
+
constructor(media: EngineMedia, source: EngineVoiceSource, platform: PlatformApi, logger: ScriptLogger, dialog: EngineDialogDefinition, call: EngineCall, agentHooks: EngineHooks);
|
|
157
|
+
private api;
|
|
158
|
+
/** A rule's hook on the caller's line: its actions at once, or later (the turn is held meanwhile). */
|
|
159
|
+
private runHook;
|
|
160
|
+
/** The transfer the reducer started, its target's sources read. */
|
|
161
|
+
private transfer;
|
|
162
|
+
run(effect: unknown): Promise<PortRunResult | void>;
|
|
163
|
+
/** NLU of an asynchronous rule, off the effect chain; the answer (and a filler timer) come back as events. */
|
|
164
|
+
private classify;
|
|
165
|
+
}
|
|
166
|
+
/** `turn.replyPlayed`: the agent's hook as the media calls it (with the call's view and the hook API). */
|
|
167
|
+
/** @internal exported for tests. */
|
|
168
|
+
export declare function replyPlayedOf(spec: EngineSpec, hooks: AgentHooks | undefined, view: () => CallView): EngineMediaSettings['replyPlayed'];
|
|
169
|
+
/**
|
|
170
|
+
* The whole agent from its agent file (internal: an agent calls `.build()` of its builder, which calls this). Throws at
|
|
171
|
+
* build time when the file uses a block the engine does not run (the message names the field).
|
|
172
|
+
*/
|
|
173
|
+
export declare function defineVoiceAgent(agentFile: EngineSpec, agentHooks?: AgentHooks | undefined, engineOptions?: VoiceAgentEngineOptions): ScriptFn;
|
|
174
|
+
export {};
|