@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,428 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import type { MediaChannel, PlayOptions, ScriptLogger } from '@voctiv/agent-sdk';
|
|
3
|
+
import { type OnCallDestroy, type OnOnlineCall } from '../../core/hooks';
|
|
4
|
+
import { ActiveMedia } from '../../dialog-events/active-media';
|
|
5
|
+
import { LifecycleService } from '../../lifecycle/lifecycle';
|
|
6
|
+
import { CallVoice, type CallVoiceAgent, type CallVoiceSetup, type DrainFloor, type LlmTurnLanguage, type ReplyEnd, type VoiceTurn } from '../../voice/call-voice';
|
|
7
|
+
import type { SpeechLeakFilterConfig } from '../../voice/speech-leak';
|
|
8
|
+
import { type IntentInterruptConfig } from '../../voice/intent-interrupt';
|
|
9
|
+
import { EngineCall } from './call';
|
|
10
|
+
import type { EnginePlay } from './config';
|
|
11
|
+
import type { AsrVendorSettings, Text } from '../spec';
|
|
12
|
+
import { type VoiceVariant } from './variants';
|
|
13
|
+
/** Voice values of the agent file read from sources (`{ from }`): resolved per call, before the media starts. */
|
|
14
|
+
export interface SourcedVoice {
|
|
15
|
+
readonly voiceId?: unknown;
|
|
16
|
+
readonly model?: unknown;
|
|
17
|
+
readonly asrVendor?: unknown;
|
|
18
|
+
readonly ambientUrl?: unknown;
|
|
19
|
+
readonly operatorVendor?: unknown;
|
|
20
|
+
}
|
|
21
|
+
/** The call's values of a `SourcedVoice` (absent: the source gave nothing and there is no default). */
|
|
22
|
+
export interface ResolvedVoice {
|
|
23
|
+
readonly voiceId?: string;
|
|
24
|
+
readonly model?: string;
|
|
25
|
+
readonly asrVendor?: string;
|
|
26
|
+
readonly ambientUrl?: string;
|
|
27
|
+
readonly operatorVendor?: string;
|
|
28
|
+
}
|
|
29
|
+
/** Keep the call's resolved voice values (by its dialog context) for its media. */
|
|
30
|
+
export declare function keepResolvedVoice(context: object, v: ResolvedVoice): void;
|
|
31
|
+
/** The media settings with the call's resolved voice values. */
|
|
32
|
+
export declare function withResolvedVoice(base: CallVoiceAgent, v: ResolvedVoice | undefined): CallVoiceAgent;
|
|
33
|
+
/** The media settings of the agent file (built once per agent by ./voice). */
|
|
34
|
+
export interface EngineMediaSettings {
|
|
35
|
+
readonly voice: CallVoiceAgent;
|
|
36
|
+
/** Sound effects queue and its volume. */
|
|
37
|
+
readonly sfx?: {
|
|
38
|
+
readonly queue: number;
|
|
39
|
+
readonly volume: number;
|
|
40
|
+
};
|
|
41
|
+
/** One LLM stream for the call (`prompt.persistentStream`). */
|
|
42
|
+
readonly persistent: Readonly<Record<string, never>> | null;
|
|
43
|
+
/** Request texts sent with `hidden: true` (`prompt.hiddenSignals`). */
|
|
44
|
+
readonly hiddenTexts?: ReadonlySet<string>;
|
|
45
|
+
/**
|
|
46
|
+
* `turn.playedOut: { by: 'queueIdle' }`: after a line's floor, the agent queue counts as played out once its first
|
|
47
|
+
* clip started (within `startAllowanceMs`) and nothing more was queued for `settleMs`, not before `msPerChar` per
|
|
48
|
+
* spoken character from that start; the same ceiling bounds a closing line's wait.
|
|
49
|
+
*/
|
|
50
|
+
readonly queueIdle?: {
|
|
51
|
+
readonly startAllowanceMs: number;
|
|
52
|
+
readonly settleMs: number;
|
|
53
|
+
readonly msPerChar: number;
|
|
54
|
+
};
|
|
55
|
+
/** `voice.dropLineAnswer`: a filler `dropLine` dropped that answers when nothing plays. */
|
|
56
|
+
readonly dropLineAnswer?: RegExp;
|
|
57
|
+
/** `scriptLeak.retry`: the note a reply that was only dropped sentences is asked again with. */
|
|
58
|
+
readonly leakRetry?: string;
|
|
59
|
+
/** `scriptLeak` reply filter: Latin words that are speech (a function: read from the call). */
|
|
60
|
+
readonly speechFilter?: SpeechLeakFilterConfig | ((call: import('../spec').CallView | null) => SpeechLeakFilterConfig);
|
|
61
|
+
readonly defaultLanguage: string;
|
|
62
|
+
/** Name of the LLM's error event (a reply carrying it failed). */
|
|
63
|
+
readonly errorEvent?: string;
|
|
64
|
+
readonly transfer: MediaTransfer | null;
|
|
65
|
+
/** A reply that streamed nothing after `afterMs` gets one of `urls` ahead of it (`voice.filler`). */
|
|
66
|
+
readonly filler?: {
|
|
67
|
+
readonly urls: readonly string[];
|
|
68
|
+
readonly afterMs: number;
|
|
69
|
+
readonly alias: string;
|
|
70
|
+
} | null;
|
|
71
|
+
/** Voice values read from sources, resolved per call (`keepResolvedVoice`). */
|
|
72
|
+
readonly sourcedVoice?: SourcedVoice;
|
|
73
|
+
/** `prompt.silenceSignal` when it is not one string (by language, or a function of the call): read for each use. */
|
|
74
|
+
readonly silenceText?: Text;
|
|
75
|
+
/** Clips from a file or record go to the platform's call transcript (`voice.clipTranscript`). */
|
|
76
|
+
readonly clipTranscript?: boolean;
|
|
77
|
+
/** The voice variant of a call (`voice.tts.variants`). */
|
|
78
|
+
readonly variant?: (callUuid: string, vars?: Readonly<Record<string, unknown>> | null) => VoiceVariant | null;
|
|
79
|
+
/** `voice.asrByReply`. */
|
|
80
|
+
readonly asrByReply?: {
|
|
81
|
+
readonly detect: (textSoFar: string) => string | null;
|
|
82
|
+
readonly noReturnTo?: string;
|
|
83
|
+
};
|
|
84
|
+
/** The conversation reads the caller's speech starts and partials (`turn.carryOn`). */
|
|
85
|
+
readonly speechEvents?: boolean;
|
|
86
|
+
/** Tool calls of the replies reach the conversation (`rules` with `on: 'toolCall'`). */
|
|
87
|
+
readonly toolRules?: boolean;
|
|
88
|
+
/** `voice.endOfTurn.vendorFinalInTranscript`. */
|
|
89
|
+
readonly vendorFinalInTranscript?: boolean;
|
|
90
|
+
/** `voicemail` `monologue` detector: the caller's first speech run (flag set when it is long). */
|
|
91
|
+
readonly monologue?: {
|
|
92
|
+
readonly startWithinMs: number;
|
|
93
|
+
readonly mergeGapMs: number;
|
|
94
|
+
readonly minSpanMs: number;
|
|
95
|
+
readonly flag: string;
|
|
96
|
+
} | null;
|
|
97
|
+
/** `overtalk.interrupt.intents`: the NLU reads partials while the agent speaks; an intent stops the agent. */
|
|
98
|
+
readonly intentInterrupt?: IntentInterruptConfig | null;
|
|
99
|
+
/** `turn.regenerateEmpty`: the text an empty reply is asked again with (`null`: not asked), from the caller's line. */
|
|
100
|
+
readonly regenerateEmpty?: ((trigger: string) => string | null) | null;
|
|
101
|
+
/** `transfer.veto`: the text a wordless transfer is refused with (`null`: it goes on), from the caller's line. */
|
|
102
|
+
readonly transferVeto?: ((trigger: string) => string | null) | null;
|
|
103
|
+
/** `transfer.toolReply`: the agent's verdict on a reply with the tool latched (`next` null: the reply ended). */
|
|
104
|
+
readonly toolReply?: (text: string, next: string | null, goodbye: boolean) => 'over' | 'drop' | null;
|
|
105
|
+
/** A recognizer picked per call from its variables, by language (`voice.asr.<lang>.pick`). */
|
|
106
|
+
readonly asrPick?: Readonly<Record<string, (vars: Readonly<Record<string, unknown>>) => {
|
|
107
|
+
readonly name?: string;
|
|
108
|
+
readonly data?: AsrVendorSettings;
|
|
109
|
+
} | null>>;
|
|
110
|
+
/** `annotateCaller` with `perRequest`: the caller's words annotated now (a reply asked again after a cut). */
|
|
111
|
+
readonly annotateAgain?: (line: string) => string;
|
|
112
|
+
/** The agent file's prompt variables now (`prompt.vars` / `variants`), for a reply asked again after a cut. */
|
|
113
|
+
readonly promptVarsNow?: () => Readonly<Record<string, unknown>>;
|
|
114
|
+
/** Agent code told what the caller heard of each conversation reply (`turn.replyPlayed`). */
|
|
115
|
+
readonly replyPlayed?: (text: string, heard: boolean, call: {
|
|
116
|
+
readonly context: EngineCall['context'];
|
|
117
|
+
readonly logger: ScriptLogger;
|
|
118
|
+
}) => void;
|
|
119
|
+
/** The conversation hears what the caller heard of each reply (`REPLY_PLAYED`: `tracking`, note ladders). */
|
|
120
|
+
readonly trackPlayed?: boolean;
|
|
121
|
+
}
|
|
122
|
+
/** The transfer block as the media runs it (the reducer decides; see `TransferSpec`). */
|
|
123
|
+
export interface MediaTransfer {
|
|
124
|
+
readonly mode: 'bridge' | 'dialAndWhisper';
|
|
125
|
+
/** A reply that is the transfer line. */
|
|
126
|
+
readonly spoken: ((text: string) => boolean) | null;
|
|
127
|
+
/** A refused tool call is asked again once with this text (when the reply said nothing). */
|
|
128
|
+
readonly refusedSignal?: string;
|
|
129
|
+
readonly phraseFloor: DrainFloor | null;
|
|
130
|
+
readonly graceMs: number;
|
|
131
|
+
/** Bridge: how long the operator leg may ring (0: no limit). */
|
|
132
|
+
readonly answerTimeoutMs: number;
|
|
133
|
+
readonly dial: {
|
|
134
|
+
readonly operatorAsr: {
|
|
135
|
+
readonly name?: string;
|
|
136
|
+
readonly vendor?: string;
|
|
137
|
+
readonly language?: string;
|
|
138
|
+
};
|
|
139
|
+
readonly queuePatterns: readonly RegExp[];
|
|
140
|
+
readonly holdTimeoutMs: number;
|
|
141
|
+
readonly results: {
|
|
142
|
+
readonly connected: string;
|
|
143
|
+
readonly notAnswered: string;
|
|
144
|
+
readonly customerDropped: string;
|
|
145
|
+
};
|
|
146
|
+
} | null;
|
|
147
|
+
/** `transfer.text.transcript`: the transfer's own line (or clip text) goes to the transcript. */
|
|
148
|
+
readonly textTranscript?: boolean;
|
|
149
|
+
}
|
|
150
|
+
/** A transfer as the reducer started it, its target resolved. */
|
|
151
|
+
export interface TransferRun {
|
|
152
|
+
readonly mode: 'bridge' | 'dialAndWhisper';
|
|
153
|
+
readonly say: string | null;
|
|
154
|
+
readonly alias: string;
|
|
155
|
+
readonly whisper: string | null;
|
|
156
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
157
|
+
readonly target: {
|
|
158
|
+
readonly did?: string;
|
|
159
|
+
readonly msisdn?: string;
|
|
160
|
+
readonly channel?: string;
|
|
161
|
+
};
|
|
162
|
+
/** A clip said instead of `say` (it gave nothing): its source, its text and how long it counts as playing. */
|
|
163
|
+
readonly clip?: {
|
|
164
|
+
readonly url?: string;
|
|
165
|
+
readonly record?: string;
|
|
166
|
+
readonly text: string;
|
|
167
|
+
readonly playMs: number;
|
|
168
|
+
} | null;
|
|
169
|
+
}
|
|
170
|
+
/** An LLM turn whose text comes later (`provideHeldText`); a filler is said after `afterMs` meanwhile. */
|
|
171
|
+
export interface HeldTurn {
|
|
172
|
+
readonly heard: string;
|
|
173
|
+
readonly held: string;
|
|
174
|
+
readonly filler: {
|
|
175
|
+
readonly text: string;
|
|
176
|
+
readonly afterMs: number;
|
|
177
|
+
} | null;
|
|
178
|
+
}
|
|
179
|
+
export type EngineMediaEvent =
|
|
180
|
+
/** The reply guard held back the reply of the turn and replaced it (`closing.guard`). */
|
|
181
|
+
{
|
|
182
|
+
type: 'GUARD_REPLACED';
|
|
183
|
+
text: string;
|
|
184
|
+
alias?: string;
|
|
185
|
+
close?: {
|
|
186
|
+
result: string;
|
|
187
|
+
reason?: string;
|
|
188
|
+
};
|
|
189
|
+
m: ReturnType<CallVoice['snapshot']>;
|
|
190
|
+
}
|
|
191
|
+
/** A `stream` reply filter's call variables of a reply that ended having said something. */
|
|
192
|
+
| {
|
|
193
|
+
type: 'REPLY_VARS';
|
|
194
|
+
vars: Readonly<Record<string, unknown>>;
|
|
195
|
+
}
|
|
196
|
+
/** A detector set a flag of the call (the opening monologue). */
|
|
197
|
+
| {
|
|
198
|
+
type: 'FLAG';
|
|
199
|
+
flag: string;
|
|
200
|
+
m: ReturnType<CallVoice['snapshot']>;
|
|
201
|
+
}
|
|
202
|
+
/** The LLM's reply called a tool (`rules` with `on: 'toolCall'`): once per tool name and turn. */
|
|
203
|
+
| {
|
|
204
|
+
type: 'TOOL_CALL';
|
|
205
|
+
name: string;
|
|
206
|
+
m: ReturnType<CallVoice['snapshot']>;
|
|
207
|
+
}
|
|
208
|
+
/** The agent's reply reads as this recognizer key (`voice.asrByReply`). */
|
|
209
|
+
| {
|
|
210
|
+
type: 'REPLY_ASR';
|
|
211
|
+
key: string;
|
|
212
|
+
} | {
|
|
213
|
+
type: 'TRANSFER_REPLY';
|
|
214
|
+
via: 'tool' | 'spoken';
|
|
215
|
+
spokeWords: boolean;
|
|
216
|
+
blank?: boolean;
|
|
217
|
+
trigger?: string;
|
|
218
|
+
m: ReturnType<CallVoice['snapshot']>;
|
|
219
|
+
} | {
|
|
220
|
+
type: 'TRANSFER_BRIDGED';
|
|
221
|
+
} | {
|
|
222
|
+
type: 'TRANSFER_FAILED';
|
|
223
|
+
failure: string;
|
|
224
|
+
m: ReturnType<CallVoice['snapshot']>;
|
|
225
|
+
}
|
|
226
|
+
/** `turn.review` dropped the reply: its actions run now (the stream ended). */
|
|
227
|
+
| {
|
|
228
|
+
type: 'REVIEW_ACTIONS';
|
|
229
|
+
actions: readonly import('../spec').Action[];
|
|
230
|
+
m: ReturnType<CallVoice['snapshot']>;
|
|
231
|
+
}
|
|
232
|
+
/** What the caller heard of a conversation reply (`trackPlayed`). */
|
|
233
|
+
| {
|
|
234
|
+
type: 'REPLY_PLAYED';
|
|
235
|
+
text: string;
|
|
236
|
+
heard: boolean;
|
|
237
|
+
};
|
|
238
|
+
export declare const ENGINE_MEDIA: "TEMPLATES_ENGINE_MEDIA";
|
|
239
|
+
/** How a greeting's LLM stream ends (see `llmGreeting.firstTokenMs` / `fallback`). */
|
|
240
|
+
interface GreetingStream {
|
|
241
|
+
readonly firstTokenMs?: number;
|
|
242
|
+
readonly emptyOnError?: boolean;
|
|
243
|
+
}
|
|
244
|
+
/** A greeting's fallback clip and how soon the caller can cut it. */
|
|
245
|
+
interface GreetingPlay {
|
|
246
|
+
readonly fallback?: {
|
|
247
|
+
readonly play: EnginePlay;
|
|
248
|
+
readonly text: string;
|
|
249
|
+
};
|
|
250
|
+
readonly bargeInAfterMs?: number;
|
|
251
|
+
}
|
|
252
|
+
/** A turn requested once a prefetched LLM line (not played) has streamed, at most `maxMs` (`toLlmWhen`). */
|
|
253
|
+
export interface AfterPrefetchTurn {
|
|
254
|
+
readonly heard: string;
|
|
255
|
+
readonly after: string;
|
|
256
|
+
readonly maxMs: number;
|
|
257
|
+
}
|
|
258
|
+
export declare class EngineMedia extends CallVoice<EngineMediaEvent> implements OnOnlineCall, OnCallDestroy {
|
|
259
|
+
private readonly engineCall;
|
|
260
|
+
private readonly settings;
|
|
261
|
+
/** The reducer's answer to a tool call of the reply in flight (set by the ports). */
|
|
262
|
+
toolGate: ((names: readonly string[]) => 'latched' | 'refused' | null) | null;
|
|
263
|
+
private readonly latched;
|
|
264
|
+
/** The next turn's reply carries a tool call latched on an empty reply asked again. */
|
|
265
|
+
private latchNextTurn;
|
|
266
|
+
/** `voice.asrByReply`: the key the replies last read as, and the recognizer key the call listens with. */
|
|
267
|
+
private replyKey;
|
|
268
|
+
private listenKey;
|
|
269
|
+
private readonly refused;
|
|
270
|
+
private readonly cutLogged;
|
|
271
|
+
private readonly errored;
|
|
272
|
+
/** Text each turn sent to the LLM. */
|
|
273
|
+
private readonly sent;
|
|
274
|
+
private readonly heldTexts;
|
|
275
|
+
/** The transfer took the call over. */
|
|
276
|
+
private transferring;
|
|
277
|
+
/** `scriptLeak.retry` was used; a reply with words resets it. */
|
|
278
|
+
private leakRetried;
|
|
279
|
+
/** The agent queue ran dry (`turn.playedOut: { by: 'queueIdle' }`). */
|
|
280
|
+
private readonly queueEmptied;
|
|
281
|
+
private transferPlayedOut;
|
|
282
|
+
private dial;
|
|
283
|
+
private bridgeTeardown;
|
|
284
|
+
private readonly prefetched;
|
|
285
|
+
private persistentHandle;
|
|
286
|
+
/** The turn whose barge-in block ends when it drains (a clip or the greeting). */
|
|
287
|
+
private blockingSeq;
|
|
288
|
+
private greetingAlias;
|
|
289
|
+
/** How the current greeting's stream ends, its fallback clip, whether the caller can cut it. */
|
|
290
|
+
private greetingOpts;
|
|
291
|
+
private greeting;
|
|
292
|
+
private cutDrained;
|
|
293
|
+
private fillerTimer;
|
|
294
|
+
private fillerSeq;
|
|
295
|
+
/** Tool calls of replies already told to the conversation (`<turn>:<name>`). */
|
|
296
|
+
private readonly toolsSeen;
|
|
297
|
+
/** When the last turn-end sound played (0: never). */
|
|
298
|
+
private voiceOf;
|
|
299
|
+
/** The caller's first speech run (`monologue` detector): from answer, its start, the last end, closed. */
|
|
300
|
+
private run;
|
|
301
|
+
constructor(channel: MediaChannel, logger: ScriptLogger, am: ActiveMedia, engineCall: EngineCall, lifecycle: LifecycleService, settings: EngineMediaSettings);
|
|
302
|
+
/** `voice.asrByReply`: the reply names the caller's language; the recognizer follows it. */
|
|
303
|
+
protected replyProgress(textSoFar: string): void;
|
|
304
|
+
/** The media settings with the call's voice variant (its voice and model on every TTS play). */
|
|
305
|
+
protected get agent(): CallVoiceAgent;
|
|
306
|
+
private callAgent;
|
|
307
|
+
protected asrPick(language: string): {
|
|
308
|
+
name?: string;
|
|
309
|
+
data?: Record<string, unknown>;
|
|
310
|
+
} | null;
|
|
311
|
+
/** Speech starts and partials reach the conversation when it reads them (`turn.carryOn`). */
|
|
312
|
+
protected get speechEvents(): boolean;
|
|
313
|
+
/** Tag of the call's voice variant (`null`: none). */
|
|
314
|
+
get voiceTag(): string | null;
|
|
315
|
+
protected setup(): CallVoiceSetup;
|
|
316
|
+
private speechFilter;
|
|
317
|
+
/** A reply asked again after a cut is asked with the prompt variables as they are now (the cut may have changed them). */
|
|
318
|
+
protected abortedRetryLanguage(language: LlmTurnLanguage): LlmTurnLanguage;
|
|
319
|
+
/** `annotateCaller.perRequest`: a reply asked again after a cut is asked with the caller's words annotated anew. */
|
|
320
|
+
protected abortedRetryText(text: string, opts: {
|
|
321
|
+
trigger?: string;
|
|
322
|
+
retryText?: string;
|
|
323
|
+
}): string;
|
|
324
|
+
/** `turn.replyPlayed`: the agent's hook hears what the caller heard of a conversation reply (never the greeting). */
|
|
325
|
+
protected replyPlayed(text: string, heard: boolean, tag: string): void;
|
|
326
|
+
/** The agent file's prompt variables on the call's payload (no reply-language keys of their own). */
|
|
327
|
+
protected turnPayload(language: LlmTurnLanguage): Record<string, unknown>;
|
|
328
|
+
protected startBackground(): void;
|
|
329
|
+
private intents;
|
|
330
|
+
protected heldBack(seq: number): string;
|
|
331
|
+
protected partialHeard(text: string): void;
|
|
332
|
+
protected teardown(): void;
|
|
333
|
+
private stopSfx;
|
|
334
|
+
get callEnding(): boolean;
|
|
335
|
+
onCallDestroy(): void;
|
|
336
|
+
private llmOptions;
|
|
337
|
+
/** Text of one LLM request of turn `seq` (its tool and error events read); unsubscribing cancels it. */
|
|
338
|
+
private llmText;
|
|
339
|
+
/** An empty reply whose tool call latched is asked again: the retry's reply carries the tool call (it is the transfer). */
|
|
340
|
+
protected emptyReplyAskedAgain(seq: number): void;
|
|
341
|
+
protected replyStream(turn: VoiceTurn, seq: number, payload: Record<string, unknown>): Observable<string>;
|
|
342
|
+
/** Tool and error events of a chunk of turn `seq`: the transfer's tool latched or refused (by the reducer). */
|
|
343
|
+
private toolEvents;
|
|
344
|
+
onOnlineCall(): Promise<void>;
|
|
345
|
+
protected speechStarted(): void;
|
|
346
|
+
protected speechEnded(): void;
|
|
347
|
+
private closeRun;
|
|
348
|
+
protected replyRequested(seq: number, tag: string): void;
|
|
349
|
+
protected replyStarted(seq: number): void;
|
|
350
|
+
private clearFiller;
|
|
351
|
+
/** The held turn's reply: its text once the reducer built it, a filler meanwhile. */
|
|
352
|
+
private heldReply;
|
|
353
|
+
/** The reducer built a held turn's text (empty: the turn is not asked). */
|
|
354
|
+
provideHeldText(key: string, text: string): void;
|
|
355
|
+
protected replyCut(seq: number, tag: string, soFar: string, next: string): boolean;
|
|
356
|
+
protected replyExempt(seq: number): boolean;
|
|
357
|
+
protected replyErrored(seq: number): boolean;
|
|
358
|
+
protected sentText(turn: VoiceTurn, seq: number): string;
|
|
359
|
+
/** A refused tool call that took the whole reply: asked once more with the refused signal. */
|
|
360
|
+
protected watchQueue(ttsQueue: ReturnType<MediaChannel['audio']['queue']>): void;
|
|
361
|
+
protected closeCeilingFor(text: string): number | undefined;
|
|
362
|
+
protected awaitAfterFloor(text: string, ceilingMs: number, seq: number): Promise<void>;
|
|
363
|
+
private awaitQueueIdle;
|
|
364
|
+
private nextQueueSignal;
|
|
365
|
+
/** `voice.dropLineAnswer`: a bare «yes» dropped as a filler is the answer when nothing plays and the line is not held. */
|
|
366
|
+
protected rescueDropped(text: string, reason: string): boolean;
|
|
367
|
+
protected replyRetried(end: ReplyEnd): boolean;
|
|
368
|
+
/** A regeneration of the turn that ended: its text, the turn's trigger kept, the reason carried. */
|
|
369
|
+
private regenerate;
|
|
370
|
+
/** `cutAtSentence` and `turn.review`: a reply cut with nothing spoken, or dropped by the review (true: handled). */
|
|
371
|
+
private reviewed;
|
|
372
|
+
/** `transfer.veto`: the tool latched on a reply that said no words, and the agent refuses it (true: asked again). */
|
|
373
|
+
private vetoed;
|
|
374
|
+
/** `turn.regenerateEmpty`: a first-round reply with no words and no transfer is asked again once (true: asked). */
|
|
375
|
+
private regeneratedEmpty;
|
|
376
|
+
protected isTransferReply(text: string): boolean;
|
|
377
|
+
protected replyDoneLogFields(isTransfer: boolean): Record<string, unknown>;
|
|
378
|
+
/** The reply is the transfer: the conversation is over; the reducer starts it (`runTransfer`). */
|
|
379
|
+
protected transferReply(end: ReplyEnd): boolean;
|
|
380
|
+
protected finalsIgnored(text: string): boolean;
|
|
381
|
+
/** The transfer the reducer started: its phrase, the line played out, then the bridge or the dial. */
|
|
382
|
+
runTransfer(run: TransferRun): Promise<void>;
|
|
383
|
+
/** The transfer's target could not be read: it fails as `not_configured` before anything of it ran. */
|
|
384
|
+
transferNotConfigured(): void;
|
|
385
|
+
/**
|
|
386
|
+
* The transfer did not connect: the conversation gets the call back as it was (the background bed, caller lines
|
|
387
|
+
* read) and the reducer runs the agent's `onFailure` with the outcome. Nothing more is decided here.
|
|
388
|
+
*/
|
|
389
|
+
private transferFailedBack;
|
|
390
|
+
protected replyBlocksBargeIn(tag: string): boolean | undefined;
|
|
391
|
+
/** The LLM stream of `key` starts now and is kept, so it can play the moment its turn comes. */
|
|
392
|
+
prefetch(key: string, signal: string, language: LlmTurnLanguage, opts?: GreetingStream): void;
|
|
393
|
+
/** A greeting's LLM text: ended empty after `firstTokenMs` without a chunk, and on an error with `emptyOnError`. */
|
|
394
|
+
private greetingText;
|
|
395
|
+
private prefetchedStream;
|
|
396
|
+
/** Play the LLM line of `key` (requested now when it was not prefetched); it plays out whole. */
|
|
397
|
+
playLlm(key: string, signal: string, alias: string, language: LlmTurnLanguage, opts?: GreetingStream & GreetingPlay): void;
|
|
398
|
+
/** The greeting streamed nothing: its fallback clip, which counts as playing at least its text's reply floor. */
|
|
399
|
+
private playGreetingFallback;
|
|
400
|
+
protected llmPlay(tag: string): PlayOptions;
|
|
401
|
+
/**
|
|
402
|
+
* A clip: the CMS record when there is one, else the URL, else TTS of its text; it is not cut by
|
|
403
|
+
* the caller unless `bargeIn`. The clip's turn drains `tailMs` after the clip was handed over (a record: played;
|
|
404
|
+
* TTS: synthesized) — the silence window counts from there.
|
|
405
|
+
*/
|
|
406
|
+
playClip(play: EnginePlay, text: string, items?: readonly {
|
|
407
|
+
readonly record: string;
|
|
408
|
+
readonly text: string;
|
|
409
|
+
}[], queued?: boolean): void;
|
|
410
|
+
/**
|
|
411
|
+
* A sequence of records (`PlaySpec.records`): each looked up and played in turn (a missing one by TTS of its text),
|
|
412
|
+
* `gapMs` between two of them; the turn drains `tailMs` after the last. A hangup stops it.
|
|
413
|
+
*/
|
|
414
|
+
private playSequence;
|
|
415
|
+
/** A reply that is the clip's text: the clip plays in its place; the reply counts as said. */
|
|
416
|
+
private playReplyClip;
|
|
417
|
+
/** The agent queue finished the item `alias` (or the call ended, or a minute passed). */
|
|
418
|
+
private itemFinished;
|
|
419
|
+
/** A line of the platform's call transcript (the CMS log of the call). */
|
|
420
|
+
transcriptLine(role: 'agent' | 'user', text: string): void;
|
|
421
|
+
/** No new line once the hangup started (the effects of one event may run after the next event's hangup). */
|
|
422
|
+
runLlmTurn(...args: Parameters<CallVoice<EngineMediaEvent>['runLlmTurn']>): void;
|
|
423
|
+
runStaticTurn(...args: Parameters<CallVoice<EngineMediaEvent>['runStaticTurn']>): void;
|
|
424
|
+
protected drained(seq: number): void;
|
|
425
|
+
/** A greeting the caller can cut (`bargeInAfterMs`) ends at the cut: the opening goes on at once. */
|
|
426
|
+
protected turnCut(seq: number): void;
|
|
427
|
+
}
|
|
428
|
+
export {};
|