@voctiv/agent-runtime 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -20
- package/dist/barge-in/barge-in-module.d.ts +0 -1
- package/dist/barge-in/barge-in-module.js +0 -1
- package/dist/barge-in/barge-in-service.d.ts +1 -1
- package/dist/barge-in/barge-in-service.js +33 -2
- package/dist/barge-in/barge-in-strategy.d.ts +11 -9
- package/dist/barge-in/barge-in-strategy.js +39 -23
- package/dist/barge-in/echo-cancellation.d.ts +0 -1
- package/dist/barge-in/echo-cancellation.js +0 -1
- package/dist/barge-in/echo.d.ts +0 -1
- package/dist/barge-in/echo.js +0 -1
- package/dist/barge-in/lexicon.d.ts +0 -1
- package/dist/barge-in/lexicon.js +8 -2
- package/dist/barge-in/speech-ledger.d.ts +0 -2
- package/dist/barge-in/speech-ledger.js +3 -4
- package/dist/barge-in/word-classifier.d.ts +0 -1
- package/dist/barge-in/word-classifier.js +0 -1
- package/dist/call/asr-usage.d.ts +53 -0
- package/dist/call/asr-usage.js +42 -0
- package/dist/call/async.d.ts +2 -0
- package/dist/call/async.js +14 -0
- package/dist/call/env.d.ts +88 -0
- package/dist/call/env.js +294 -0
- package/dist/call/extraction/core.d.ts +99 -0
- package/dist/call/extraction/core.js +259 -0
- package/dist/call/extraction/defaults.d.ts +10 -0
- package/dist/call/extraction/defaults.js +25 -0
- package/dist/call/extraction/index.d.ts +7 -0
- package/dist/call/extraction/index.js +24 -0
- package/dist/call/extraction/orchestrator.d.ts +144 -0
- package/dist/call/extraction/orchestrator.js +309 -0
- package/dist/call/failed-leg.d.ts +43 -0
- package/dist/call/failed-leg.js +77 -0
- package/dist/call/http.d.ts +94 -0
- package/dist/call/http.js +145 -0
- package/dist/call/ledger.d.ts +18 -0
- package/dist/call/ledger.js +80 -0
- package/dist/call/llm-tap.d.ts +7 -0
- package/dist/call/llm-tap.js +41 -0
- package/dist/call/logging.d.ts +16 -0
- package/dist/call/logging.js +92 -0
- package/dist/call/outbound.d.ts +144 -0
- package/dist/call/outbound.js +404 -0
- package/dist/call/output.d.ts +108 -0
- package/dist/call/output.js +77 -0
- package/dist/call/plan.d.ts +119 -0
- package/dist/call/plan.js +2 -0
- package/dist/call/recall.d.ts +115 -0
- package/dist/call/recall.js +312 -0
- package/dist/call/records.d.ts +9 -0
- package/dist/call/records.js +71 -0
- package/dist/call/report.d.ts +65 -0
- package/dist/call/report.js +263 -0
- package/dist/call/sanitize.d.ts +16 -0
- package/dist/call/sanitize.js +72 -0
- package/dist/call/sip.d.ts +111 -0
- package/dist/call/sip.js +212 -0
- package/dist/call/voicemail.d.ts +159 -0
- package/dist/call/voicemail.js +246 -0
- package/dist/core/call-disposables.d.ts +2 -2
- package/dist/core/call-disposables.js +8 -3
- package/dist/core/call-ended-budget.d.ts +11 -0
- package/dist/core/call-ended-budget.js +31 -0
- package/dist/core/container.d.ts +1 -3
- package/dist/core/container.js +9 -49
- package/dist/core/create-agent-script.d.ts +6 -1
- package/dist/core/create-agent-script.js +161 -28
- package/dist/core/decorators.d.ts +0 -1
- package/dist/core/decorators.js +0 -1
- package/dist/core/define-module.d.ts +0 -1
- package/dist/core/define-module.js +0 -1
- package/dist/core/dump-policy.d.ts +0 -1
- package/dist/core/dump-policy.js +0 -1
- package/dist/core/hooks.d.ts +15 -4
- package/dist/core/hooks.js +0 -1
- package/dist/core/media-bootstrap.d.ts +19 -4
- package/dist/core/media-bootstrap.js +53 -13
- package/dist/core/open-timeout.d.ts +12 -0
- package/dist/core/open-timeout.js +48 -0
- package/dist/core/provide-media.d.ts +0 -8
- package/dist/core/provide-media.js +1 -22
- package/dist/core/runtime-events.d.ts +28 -0
- package/dist/{llm/llm-module.js → core/runtime-events.js} +19 -16
- package/dist/core/tokens.d.ts +0 -10
- package/dist/core/tokens.js +0 -1
- package/dist/core/types.d.ts +0 -1
- package/dist/core/types.js +0 -1
- package/dist/core/version.d.ts +2 -3
- package/dist/core/version.js +2 -3
- package/dist/dialog/dialog-definition.d.ts +0 -5
- package/dist/dialog/dialog-definition.js +1 -6
- package/dist/dialog/dialog-ports.d.ts +3 -1
- package/dist/dialog/dialog-ports.js +10 -2
- package/dist/dialog/online-call-host.d.ts +26 -4
- package/dist/dialog/online-call-host.js +94 -12
- package/dist/dialog/online-call-module.d.ts +5 -11
- package/dist/dialog/online-call-module.js +4 -36
- package/dist/dialog/turn-metrics.d.ts +46 -0
- package/dist/dialog/turn-metrics.js +141 -0
- package/dist/dialog-events/active-media.d.ts +50 -2
- package/dist/dialog-events/active-media.js +146 -34
- package/dist/dialog-events/event-source.d.ts +0 -1
- package/dist/dialog-events/event-source.js +0 -1
- package/dist/dialog-events/virtual-finals-module.d.ts +0 -1
- package/dist/dialog-events/virtual-finals-module.js +0 -1
- package/dist/dialog-events/virtual-finals.d.ts +2 -1
- package/dist/dialog-events/virtual-finals.js +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.js +8 -26
- package/dist/lifecycle/lifecycle.d.ts +25 -3
- package/dist/lifecycle/lifecycle.js +92 -14
- package/dist/result/result-store.d.ts +0 -1
- package/dist/result/result-store.js +0 -1
- package/dist/templates/authoring.d.ts +222 -0
- package/dist/templates/authoring.js +2 -0
- package/dist/templates/builder/agent.d.ts +34 -0
- package/dist/templates/builder/agent.js +87 -0
- package/dist/templates/builder/blocks.d.ts +54 -0
- package/dist/templates/builder/blocks.js +92 -0
- package/dist/templates/builder/data-check.d.ts +2 -0
- package/dist/templates/builder/data-check.js +61 -0
- package/dist/templates/builder/draft.d.ts +73 -0
- package/dist/templates/builder/draft.js +142 -0
- package/dist/templates/builder/index.d.ts +8 -0
- package/dist/templates/builder/index.js +55 -0
- package/dist/templates/builder/presets.d.ts +34 -0
- package/dist/templates/builder/presets.js +45 -0
- package/dist/templates/builder/spec-of.d.ts +13 -0
- package/dist/templates/builder/spec-of.js +18 -0
- package/dist/templates/builder/steps.d.ts +25 -0
- package/dist/templates/builder/steps.js +27 -0
- package/dist/templates/business/adapter.d.ts +12 -0
- package/dist/templates/business/adapter.js +980 -0
- package/dist/templates/business/agent-integrations.d.ts +24 -0
- package/dist/templates/business/agent-integrations.js +233 -0
- package/dist/templates/business/extraction-rules-transcript.d.ts +158 -0
- package/dist/templates/business/extraction-rules-transcript.js +405 -0
- package/dist/templates/business/extraction-rules.d.ts +107 -0
- package/dist/templates/business/extraction-rules.js +267 -0
- package/dist/templates/business/index.d.ts +6 -0
- package/dist/{result → templates/business}/index.js +8 -2
- package/dist/templates/business/input.d.ts +56 -0
- package/dist/templates/business/input.js +299 -0
- package/dist/templates/business/integration-data.d.ts +87 -0
- package/dist/templates/business/integration-data.js +312 -0
- package/dist/templates/business/integrations.d.ts +76 -0
- package/dist/templates/business/integrations.js +535 -0
- package/dist/templates/business/legs-policy.d.ts +43 -0
- package/dist/templates/business/legs-policy.js +268 -0
- package/dist/templates/business/report-label.d.ts +7 -0
- package/dist/templates/business/report-label.js +29 -0
- package/dist/templates/business/report.d.ts +67 -0
- package/dist/templates/business/report.js +284 -0
- package/dist/templates/business/result-catalog.d.ts +142 -0
- package/dist/templates/business/result-catalog.js +208 -0
- package/dist/templates/business/result-rules.d.ts +105 -0
- package/dist/templates/business/result-rules.js +167 -0
- package/dist/templates/business/results.d.ts +73 -0
- package/dist/templates/business/results.js +183 -0
- package/dist/templates/business/rule-env.d.ts +18 -0
- package/dist/templates/business/rule-env.js +38 -0
- package/dist/templates/business/sources.d.ts +76 -0
- package/dist/templates/business/sources.js +239 -0
- package/dist/templates/business/test-presets.d.ts +10 -0
- package/dist/templates/business/test-presets.js +68 -0
- package/dist/templates/catalog-match/block.d.ts +32 -0
- package/dist/templates/catalog-match/block.js +95 -0
- package/dist/templates/catalog-match/catalog.d.ts +77 -0
- package/dist/templates/catalog-match/catalog.js +222 -0
- package/dist/templates/catalog-match/recognizer.d.ts +44 -0
- package/dist/templates/catalog-match/recognizer.js +206 -0
- package/dist/templates/catalog-match/reconcile.d.ts +4 -0
- package/dist/templates/catalog-match/reconcile.js +39 -0
- package/dist/templates/catalog-match/request.d.ts +57 -0
- package/dist/templates/catalog-match/request.js +139 -0
- package/dist/templates/catalog-match/types.d.ts +197 -0
- package/dist/templates/catalog-match/types.js +2 -0
- package/dist/templates/catalog-match/verify.d.ts +76 -0
- package/dist/templates/catalog-match/verify.js +220 -0
- package/dist/templates/decision-model/index.d.ts +52 -0
- package/dist/templates/decision-model/index.js +68 -0
- package/dist/templates/engine/asr-picks.d.ts +11 -0
- package/dist/templates/engine/asr-picks.js +44 -0
- package/dist/templates/engine/call.d.ts +104 -0
- package/dist/templates/engine/call.js +322 -0
- package/dist/templates/engine/config.d.ts +447 -0
- package/dist/templates/engine/config.js +493 -0
- package/dist/templates/engine/define.d.ts +1 -0
- package/dist/templates/engine/define.js +9 -0
- package/dist/templates/engine/dialog.d.ts +253 -0
- package/dist/templates/engine/dialog.js +167 -0
- package/dist/templates/engine/echo-numbers.d.ts +7 -0
- package/dist/templates/engine/echo-numbers.js +19 -0
- package/dist/templates/engine/expand.d.ts +6 -0
- package/dist/templates/engine/expand.js +125 -0
- package/dist/templates/engine/filters.d.ts +81 -0
- package/dist/templates/engine/filters.js +654 -0
- package/dist/templates/engine/hook-state.d.ts +18 -0
- package/dist/templates/engine/hook-state.js +100 -0
- package/dist/templates/engine/hooks.d.ts +51 -0
- package/dist/templates/engine/hooks.js +310 -0
- package/dist/templates/engine/index.d.ts +13 -0
- package/dist/templates/engine/index.js +30 -0
- package/dist/templates/engine/language-vars.d.ts +6 -0
- package/dist/templates/engine/language-vars.js +40 -0
- package/dist/templates/engine/language.d.ts +32 -0
- package/dist/templates/engine/language.js +155 -0
- package/dist/templates/engine/lookup.d.ts +20 -0
- package/dist/templates/engine/lookup.js +52 -0
- package/dist/templates/engine/match.d.ts +48 -0
- package/dist/templates/engine/match.js +253 -0
- package/dist/templates/engine/media.d.ts +428 -0
- package/dist/templates/engine/media.js +1240 -0
- package/dist/templates/engine/script.d.ts +11 -0
- package/dist/templates/engine/script.js +69 -0
- package/dist/templates/engine/turns/actions.d.ts +5 -0
- package/dist/templates/engine/turns/actions.js +128 -0
- package/dist/templates/engine/turns/carry.d.ts +15 -0
- package/dist/templates/engine/turns/carry.js +74 -0
- package/dist/templates/engine/turns/choices-offers.d.ts +21 -0
- package/dist/templates/engine/turns/choices-offers.js +143 -0
- package/dist/templates/engine/turns/choices.d.ts +22 -0
- package/dist/templates/engine/turns/choices.js +141 -0
- package/dist/templates/engine/turns/closing-guard.d.ts +73 -0
- package/dist/templates/engine/turns/closing-guard.js +162 -0
- package/dist/templates/engine/turns/closing.d.ts +10 -0
- package/dist/templates/engine/turns/closing.js +82 -0
- package/dist/templates/engine/turns/compile-forms.d.ts +24 -0
- package/dist/templates/engine/turns/compile-forms.js +68 -0
- package/dist/templates/engine/turns/context.d.ts +96 -0
- package/dist/templates/engine/turns/context.js +158 -0
- package/dist/templates/engine/turns/events.d.ts +409 -0
- package/dist/templates/engine/turns/events.js +5 -0
- package/dist/templates/engine/turns/hook-forms.d.ts +62 -0
- package/dist/templates/engine/turns/hook-forms.js +79 -0
- package/dist/templates/engine/turns/ladders.d.ts +42 -0
- package/dist/templates/engine/turns/ladders.js +119 -0
- package/dist/templates/engine/turns/language.d.ts +8 -0
- package/dist/templates/engine/turns/language.js +121 -0
- package/dist/templates/engine/turns/notes-dates.d.ts +9 -0
- package/dist/templates/engine/turns/notes-dates.js +42 -0
- package/dist/templates/engine/turns/notes-detect.d.ts +13 -0
- package/dist/templates/engine/turns/notes-detect.js +36 -0
- package/dist/templates/engine/turns/notes.d.ts +27 -0
- package/dist/templates/engine/turns/notes.js +176 -0
- package/dist/templates/engine/turns/opening.d.ts +34 -0
- package/dist/templates/engine/turns/opening.js +306 -0
- package/dist/templates/engine/turns/overtalk.d.ts +21 -0
- package/dist/templates/engine/turns/overtalk.js +247 -0
- package/dist/templates/engine/turns/pending.d.ts +9 -0
- package/dist/templates/engine/turns/pending.js +88 -0
- package/dist/templates/engine/turns/reply-rules.d.ts +184 -0
- package/dist/templates/engine/turns/reply-rules.js +335 -0
- package/dist/templates/engine/turns/rules.d.ts +20 -0
- package/dist/templates/engine/turns/rules.js +144 -0
- package/dist/templates/engine/turns/silence.d.ts +7 -0
- package/dist/templates/engine/turns/silence.js +127 -0
- package/dist/templates/engine/turns/state-spec.d.ts +305 -0
- package/dist/templates/engine/turns/state-spec.js +2 -0
- package/dist/templates/engine/turns/state.d.ts +38 -0
- package/dist/templates/engine/turns/state.js +101 -0
- package/dist/templates/engine/turns/tracking.d.ts +50 -0
- package/dist/templates/engine/turns/tracking.js +184 -0
- package/dist/templates/engine/turns/transfer.d.ts +19 -0
- package/dist/templates/engine/turns/transfer.js +93 -0
- package/dist/templates/engine/turns/turn.d.ts +17 -0
- package/dist/templates/engine/turns/turn.js +363 -0
- package/dist/templates/engine/turns/voicemail.d.ts +8 -0
- package/dist/templates/engine/turns/voicemail.js +101 -0
- package/dist/templates/engine/variants.d.ts +36 -0
- package/dist/templates/engine/variants.js +159 -0
- package/dist/templates/engine/voice-dialog.d.ts +24 -0
- package/dist/templates/engine/voice-dialog.js +157 -0
- package/dist/templates/engine/voice.d.ts +174 -0
- package/dist/templates/engine/voice.js +1337 -0
- package/dist/templates/expr/caller-after.d.ts +20 -0
- package/dist/templates/expr/caller-after.js +53 -0
- package/dist/templates/expr/check.d.ts +19 -0
- package/dist/templates/expr/check.js +314 -0
- package/dist/templates/expr/compiled.d.ts +8 -0
- package/dist/templates/expr/compiled.js +8 -0
- package/dist/templates/expr/context.d.ts +28 -0
- package/dist/templates/expr/context.js +55 -0
- package/dist/templates/expr/day-table.d.ts +4 -0
- package/dist/templates/expr/day-table.js +80 -0
- package/dist/templates/expr/evaluate.d.ts +26 -0
- package/dist/templates/expr/evaluate.js +885 -0
- package/dist/templates/expr/facts.d.ts +7 -0
- package/dist/templates/expr/facts.js +81 -0
- package/dist/templates/expr/index.d.ts +4 -0
- package/dist/templates/expr/index.js +11 -0
- package/dist/templates/expr/line-tally.d.ts +64 -0
- package/dist/templates/expr/line-tally.js +88 -0
- package/dist/templates/expr/matchers-state.d.ts +23 -0
- package/dist/templates/expr/matchers-state.js +37 -0
- package/dist/templates/expr/matchers.d.ts +12 -0
- package/dist/templates/expr/matchers.js +99 -0
- package/dist/templates/expr/readers.d.ts +14 -0
- package/dist/templates/expr/readers.js +351 -0
- package/dist/templates/expr/slots.d.ts +14 -0
- package/dist/templates/expr/slots.js +678 -0
- package/dist/templates/expr/template.d.ts +12 -0
- package/dist/templates/expr/template.js +76 -0
- package/dist/templates/expr/test-call.d.ts +8 -0
- package/dist/templates/expr/test-call.js +32 -0
- package/dist/templates/expr/transcript.d.ts +36 -0
- package/dist/templates/expr/transcript.js +394 -0
- package/dist/templates/expr/types.d.ts +1011 -0
- package/dist/templates/expr/types.js +2 -0
- package/dist/templates/expr/values.d.ts +42 -0
- package/dist/templates/expr/values.js +166 -0
- package/dist/templates/expr/voice-ops.d.ts +26 -0
- package/dist/templates/expr/voice-ops.js +85 -0
- package/dist/templates/helpers/decision.d.ts +55 -0
- package/dist/templates/helpers/decision.js +83 -0
- package/dist/templates/helpers/fuzzy.d.ts +9 -0
- package/dist/templates/helpers/fuzzy.js +44 -0
- package/dist/templates/helpers/index.d.ts +6 -0
- package/dist/templates/helpers/index.js +35 -0
- package/dist/templates/index.d.ts +9 -0
- package/dist/templates/index.js +68 -0
- package/dist/templates/integration-forms.d.ts +252 -0
- package/dist/templates/integration-forms.js +2 -0
- package/dist/templates/knowledge/block.d.ts +44 -0
- package/dist/templates/knowledge/block.js +199 -0
- package/dist/templates/knowledge/dense.d.ts +87 -0
- package/dist/templates/knowledge/dense.js +158 -0
- package/dist/templates/knowledge/flow.d.ts +328 -0
- package/dist/templates/knowledge/flow.js +509 -0
- package/dist/templates/knowledge/retriever.d.ts +75 -0
- package/dist/templates/knowledge/retriever.js +204 -0
- package/dist/templates/knowledge/service.d.ts +77 -0
- package/dist/templates/knowledge/service.js +316 -0
- package/dist/templates/knowledge/text.d.ts +31 -0
- package/dist/templates/knowledge/text.js +66 -0
- package/dist/templates/knowledge/types.d.ts +120 -0
- package/dist/templates/knowledge/types.js +2 -0
- package/dist/templates/locale.d.ts +259 -0
- package/dist/templates/locale.js +4 -0
- package/dist/templates/locales/en-lexicons.d.ts +9 -0
- package/dist/templates/locales/en-lexicons.js +101 -0
- package/dist/templates/locales/en.d.ts +132 -0
- package/dist/templates/locales/en.js +261 -0
- package/dist/templates/locales/es.d.ts +65 -0
- package/dist/templates/locales/es.js +208 -0
- package/dist/templates/locales/hi.d.ts +47 -0
- package/dist/templates/locales/hi.js +235 -0
- package/dist/templates/locales/id.d.ts +43 -0
- package/dist/templates/locales/id.js +127 -0
- package/dist/templates/locales/index.d.ts +34 -0
- package/dist/templates/locales/index.js +112 -0
- package/dist/templates/locales/kk-lexicons.d.ts +22 -0
- package/dist/templates/locales/kk-lexicons.js +89 -0
- package/dist/templates/locales/kk.d.ts +140 -0
- package/dist/templates/locales/kk.js +306 -0
- package/dist/templates/locales/kn.d.ts +29 -0
- package/dist/templates/locales/kn.js +22 -0
- package/dist/templates/locales/listen-only.d.ts +15 -0
- package/dist/templates/locales/listen-only.js +27 -0
- package/dist/templates/locales/ms-lexicons.d.ts +13 -0
- package/dist/templates/locales/ms-lexicons.js +113 -0
- package/dist/templates/locales/ms.d.ts +76 -0
- package/dist/templates/locales/ms.js +179 -0
- package/dist/templates/locales/parse.d.ts +86 -0
- package/dist/templates/locales/parse.js +461 -0
- package/dist/templates/locales/ru-lexicons.d.ts +27 -0
- package/dist/templates/locales/ru-lexicons.js +127 -0
- package/dist/templates/locales/ru-stem.d.ts +2 -0
- package/dist/templates/locales/ru-stem.js +53 -0
- package/dist/templates/locales/ru.d.ts +143 -0
- package/dist/templates/locales/ru.js +387 -0
- package/dist/templates/locales/shared.d.ts +122 -0
- package/dist/templates/locales/shared.js +318 -0
- package/dist/templates/locales/ta.d.ts +29 -0
- package/dist/templates/locales/ta.js +22 -0
- package/dist/templates/locales/te.d.ts +29 -0
- package/dist/templates/locales/te.js +22 -0
- package/dist/templates/locales/tl-lexicons.d.ts +2 -0
- package/dist/templates/locales/tl-lexicons.js +230 -0
- package/dist/templates/locales/tl.d.ts +59 -0
- package/dist/templates/locales/tl.js +82 -0
- package/dist/templates/locales/vi.d.ts +59 -0
- package/dist/templates/locales/vi.js +160 -0
- package/dist/templates/locales/word-regex.d.ts +13 -0
- package/dist/templates/locales/word-regex.js +43 -0
- package/dist/templates/locales/words-kk.d.ts +2 -0
- package/dist/templates/locales/words-kk.js +23 -0
- package/dist/templates/locales/words-ru.d.ts +4 -0
- package/dist/templates/locales/words-ru.js +92 -0
- package/dist/templates/spec.d.ts +2856 -0
- package/dist/templates/spec.js +2 -0
- package/dist/testing/fake-channel.d.ts +0 -1
- package/dist/testing/fake-channel.js +0 -1
- package/dist/testing/index.d.ts +24 -1
- package/dist/testing/index.js +117 -2
- package/dist/voice/call-voice.d.ts +581 -0
- package/dist/voice/call-voice.js +1399 -0
- package/dist/voice/intent-interrupt.d.ts +32 -0
- package/dist/voice/intent-interrupt.js +91 -0
- package/dist/voice/self-echo.d.ts +28 -0
- package/dist/voice/self-echo.js +135 -0
- package/dist/voice/sentence-tag.d.ts +5 -0
- package/dist/voice/sentence-tag.js +42 -0
- package/dist/voice/speech-leak.d.ts +74 -0
- package/dist/voice/speech-leak.js +216 -0
- package/dist/voice/transfer.d.ts +90 -0
- package/dist/voice/transfer.js +331 -0
- package/dist/voice/turn-timing.d.ts +293 -0
- package/dist/voice/turn-timing.js +567 -0
- package/docs/README.md +3 -6
- package/docs/framework/README.md +6 -10
- package/docs/framework/architecture.md +2 -2
- package/docs/framework/container-and-di.md +1 -2
- package/docs/framework/invariants.md +6 -6
- package/docs/framework/package-layout.md +16 -23
- package/docs/framework/testing.md +8 -6
- package/package.json +10 -54
- package/skill/SKILL.md +213 -0
- package/skill/references/agent-file.md +230 -0
- package/skill/references/blocks.md +246 -0
- package/skill/references/builder.md +163 -0
- package/skill/references/business.md +659 -0
- package/skill/references/conversation.md +586 -0
- package/skill/references/core.md +89 -0
- package/skill/references/examples.md +73 -0
- package/skill/references/expressions.md +342 -0
- package/skill/references/format.md +114 -0
- package/skill/references/locales.md +149 -0
- package/skill/references/migration.md +133 -0
- package/skill/references/new-agent.md +81 -0
- package/skill/references/porting.md +109 -0
- package/templates/agent/README.md +50 -0
- package/templates/agent/package.json +24 -0
- package/templates/agent/src/agent.spec.ts +51 -0
- package/templates/agent/src/agent.ts +268 -0
- package/templates/agent/src/entities.ts +44 -0
- package/templates/agent/src/prompt.sqrl +21 -0
- package/templates/agent/src/variants/fixed-opening.ts +144 -0
- package/templates/agent/tsconfig.build.json +4 -0
- package/templates/agent/tsconfig.json +18 -0
- package/dist/asr/index.d.ts +0 -3
- package/dist/asr/index.d.ts.map +0 -1
- package/dist/asr/index.js +0 -6
- package/dist/asr/index.js.map +0 -1
- package/dist/barge-in/barge-in-module.d.ts.map +0 -1
- package/dist/barge-in/barge-in-module.js.map +0 -1
- package/dist/barge-in/barge-in-service.d.ts.map +0 -1
- package/dist/barge-in/barge-in-service.js.map +0 -1
- package/dist/barge-in/barge-in-strategy.d.ts.map +0 -1
- package/dist/barge-in/barge-in-strategy.js.map +0 -1
- package/dist/barge-in/echo-cancellation.d.ts.map +0 -1
- package/dist/barge-in/echo-cancellation.js.map +0 -1
- package/dist/barge-in/echo.d.ts.map +0 -1
- package/dist/barge-in/echo.js.map +0 -1
- package/dist/barge-in/index.d.ts +0 -13
- package/dist/barge-in/index.d.ts.map +0 -1
- package/dist/barge-in/index.js +0 -28
- package/dist/barge-in/index.js.map +0 -1
- package/dist/barge-in/lexicon.d.ts.map +0 -1
- package/dist/barge-in/lexicon.js.map +0 -1
- package/dist/barge-in/lexicons/en.d.ts +0 -2
- package/dist/barge-in/lexicons/en.d.ts.map +0 -1
- package/dist/barge-in/lexicons/en.js +0 -36
- package/dist/barge-in/lexicons/en.js.map +0 -1
- package/dist/barge-in/lexicons/id.d.ts +0 -2
- package/dist/barge-in/lexicons/id.d.ts.map +0 -1
- package/dist/barge-in/lexicons/id.js +0 -39
- package/dist/barge-in/lexicons/id.js.map +0 -1
- package/dist/barge-in/lexicons/index.d.ts +0 -10
- package/dist/barge-in/lexicons/index.d.ts.map +0 -1
- package/dist/barge-in/lexicons/index.js +0 -11
- package/dist/barge-in/lexicons/index.js.map +0 -1
- package/dist/barge-in/lexicons/ru.d.ts +0 -2
- package/dist/barge-in/lexicons/ru.d.ts.map +0 -1
- package/dist/barge-in/lexicons/ru.js +0 -39
- package/dist/barge-in/lexicons/ru.js.map +0 -1
- package/dist/barge-in/speech-ledger.d.ts.map +0 -1
- package/dist/barge-in/speech-ledger.js.map +0 -1
- package/dist/barge-in/word-classifier.d.ts.map +0 -1
- package/dist/barge-in/word-classifier.js.map +0 -1
- package/dist/bridge/bridge.d.ts +0 -28
- package/dist/bridge/bridge.d.ts.map +0 -1
- package/dist/bridge/bridge.js +0 -117
- package/dist/bridge/bridge.js.map +0 -1
- package/dist/bridge/index.d.ts +0 -3
- package/dist/bridge/index.d.ts.map +0 -1
- package/dist/bridge/index.js +0 -8
- package/dist/bridge/index.js.map +0 -1
- package/dist/core/call-disposables.d.ts.map +0 -1
- package/dist/core/call-disposables.js.map +0 -1
- package/dist/core/container.d.ts.map +0 -1
- package/dist/core/container.js.map +0 -1
- package/dist/core/create-agent-script.d.ts.map +0 -1
- package/dist/core/create-agent-script.js.map +0 -1
- package/dist/core/decorators.d.ts.map +0 -1
- package/dist/core/decorators.js.map +0 -1
- package/dist/core/define-module.d.ts.map +0 -1
- package/dist/core/define-module.js.map +0 -1
- package/dist/core/dump-policy.d.ts.map +0 -1
- package/dist/core/dump-policy.js.map +0 -1
- package/dist/core/hooks.d.ts.map +0 -1
- package/dist/core/hooks.js.map +0 -1
- package/dist/core/index.d.ts +0 -16
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -36
- package/dist/core/index.js.map +0 -1
- package/dist/core/media-bootstrap.d.ts.map +0 -1
- package/dist/core/media-bootstrap.js.map +0 -1
- package/dist/core/provide-media.d.ts.map +0 -1
- package/dist/core/provide-media.js.map +0 -1
- package/dist/core/tokens.d.ts.map +0 -1
- package/dist/core/tokens.js.map +0 -1
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/types.js.map +0 -1
- package/dist/core/version.d.ts.map +0 -1
- package/dist/core/version.js.map +0 -1
- package/dist/dialog/basic-ports.d.ts +0 -54
- package/dist/dialog/basic-ports.d.ts.map +0 -1
- package/dist/dialog/basic-ports.js +0 -206
- package/dist/dialog/basic-ports.js.map +0 -1
- package/dist/dialog/define-dialog.d.ts +0 -21
- package/dist/dialog/define-dialog.d.ts.map +0 -1
- package/dist/dialog/define-dialog.js +0 -21
- package/dist/dialog/define-dialog.js.map +0 -1
- package/dist/dialog/dialog-definition.d.ts.map +0 -1
- package/dist/dialog/dialog-definition.js.map +0 -1
- package/dist/dialog/dialog-ports.d.ts.map +0 -1
- package/dist/dialog/dialog-ports.js.map +0 -1
- package/dist/dialog/index.d.ts +0 -7
- package/dist/dialog/index.d.ts.map +0 -1
- package/dist/dialog/index.js +0 -23
- package/dist/dialog/index.js.map +0 -1
- package/dist/dialog/online-call-host.d.ts.map +0 -1
- package/dist/dialog/online-call-host.js.map +0 -1
- package/dist/dialog/online-call-module.d.ts.map +0 -1
- package/dist/dialog/online-call-module.js.map +0 -1
- package/dist/dialog-events/active-media.d.ts.map +0 -1
- package/dist/dialog-events/active-media.js.map +0 -1
- package/dist/dialog-events/event-source.d.ts.map +0 -1
- package/dist/dialog-events/event-source.js.map +0 -1
- package/dist/dialog-events/index.d.ts +0 -8
- package/dist/dialog-events/index.d.ts.map +0 -1
- package/dist/dialog-events/index.js +0 -24
- package/dist/dialog-events/index.js.map +0 -1
- package/dist/dialog-events/max-listen-source.d.ts +0 -27
- package/dist/dialog-events/max-listen-source.d.ts.map +0 -1
- package/dist/dialog-events/max-listen-source.js +0 -98
- package/dist/dialog-events/max-listen-source.js.map +0 -1
- package/dist/dialog-events/overtalk-source.d.ts +0 -61
- package/dist/dialog-events/overtalk-source.d.ts.map +0 -1
- package/dist/dialog-events/overtalk-source.js +0 -232
- package/dist/dialog-events/overtalk-source.js.map +0 -1
- package/dist/dialog-events/silence-source.d.ts +0 -32
- package/dist/dialog-events/silence-source.d.ts.map +0 -1
- package/dist/dialog-events/silence-source.js +0 -128
- package/dist/dialog-events/silence-source.js.map +0 -1
- package/dist/dialog-events/virtual-finals-module.d.ts.map +0 -1
- package/dist/dialog-events/virtual-finals-module.js.map +0 -1
- package/dist/dialog-events/virtual-finals.d.ts.map +0 -1
- package/dist/dialog-events/virtual-finals.js.map +0 -1
- package/dist/dtmf/dtmf.d.ts +0 -27
- package/dist/dtmf/dtmf.d.ts.map +0 -1
- package/dist/dtmf/dtmf.js +0 -87
- package/dist/dtmf/dtmf.js.map +0 -1
- package/dist/dtmf/index.d.ts +0 -3
- package/dist/dtmf/index.d.ts.map +0 -1
- package/dist/dtmf/index.js +0 -8
- package/dist/dtmf/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lifecycle/index.d.ts +0 -3
- package/dist/lifecycle/index.d.ts.map +0 -1
- package/dist/lifecycle/index.js +0 -9
- package/dist/lifecycle/index.js.map +0 -1
- package/dist/lifecycle/lifecycle.d.ts.map +0 -1
- package/dist/lifecycle/lifecycle.js.map +0 -1
- package/dist/llm/index.d.ts +0 -7
- package/dist/llm/index.d.ts.map +0 -1
- package/dist/llm/index.js +0 -18
- package/dist/llm/index.js.map +0 -1
- package/dist/llm/llm-markers-module.d.ts +0 -15
- package/dist/llm/llm-markers-module.d.ts.map +0 -1
- package/dist/llm/llm-markers-module.js +0 -48
- package/dist/llm/llm-markers-module.js.map +0 -1
- package/dist/llm/llm-markers.d.ts +0 -36
- package/dist/llm/llm-markers.d.ts.map +0 -1
- package/dist/llm/llm-markers.js +0 -210
- package/dist/llm/llm-markers.js.map +0 -1
- package/dist/llm/llm-module.d.ts +0 -20
- package/dist/llm/llm-module.d.ts.map +0 -1
- package/dist/llm/llm-module.js.map +0 -1
- package/dist/match/index.d.ts +0 -3
- package/dist/match/index.d.ts.map +0 -1
- package/dist/match/index.js +0 -10
- package/dist/match/index.js.map +0 -1
- package/dist/match/match.d.ts +0 -33
- package/dist/match/match.d.ts.map +0 -1
- package/dist/match/match.js +0 -85
- package/dist/match/match.js.map +0 -1
- package/dist/outbound/index.d.ts +0 -3
- package/dist/outbound/index.d.ts.map +0 -1
- package/dist/outbound/index.js +0 -8
- package/dist/outbound/index.js.map +0 -1
- package/dist/outbound/outbound.d.ts +0 -40
- package/dist/outbound/outbound.d.ts.map +0 -1
- package/dist/outbound/outbound.js +0 -84
- package/dist/outbound/outbound.js.map +0 -1
- package/dist/result/index.d.ts +0 -2
- package/dist/result/index.d.ts.map +0 -1
- package/dist/result/index.js.map +0 -1
- package/dist/result/result-store.d.ts.map +0 -1
- package/dist/result/result-store.js.map +0 -1
- package/dist/testing/fake-channel.d.ts.map +0 -1
- package/dist/testing/fake-channel.js.map +0 -1
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/index.js.map +0 -1
- package/docs/agents/README.md +0 -41
- package/docs/agents/barge-in.md +0 -67
- package/docs/agents/dialog.md +0 -98
- package/docs/agents/getting-started.md +0 -142
- package/docs/agents/imports.md +0 -40
- package/docs/agents/media-and-ports.md +0 -82
- package/docs/agents/modules.md +0 -83
- package/docs/agents/phases.md +0 -83
- package/docs/framework/extending.md +0 -59
- package/docs/framework/idn-parity.md +0 -18
- package/examples/minimal-agent/README.md +0 -7
- package/examples/minimal-agent/agent.ts +0 -94
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# The agent file (`AgentSpec`) — field guide
|
|
2
|
+
|
|
3
|
+
Source of truth: `src/templates/spec.ts`. An agent sets each section with its block of the builder (`voice({ … })`
|
|
4
|
+
sets `voice`; `builder.md`); the field names and types below are the same. This page explains every section: what it
|
|
5
|
+
controls, defaults, units, and how agents typically fill it. Behaviour of the blocks during a call is in `conversation.md`; input/extraction/report in
|
|
6
|
+
`business.md`.
|
|
7
|
+
|
|
8
|
+
Conventions used below:
|
|
9
|
+
|
|
10
|
+
- **Value\<T\>** — a literal, or `{ from: Source | Source[], default?, map? }`. Sources are tried in order; the first
|
|
11
|
+
non-empty wins; `map` translates the raw value (e.g. a region name to a host; looked up as is, then trimmed and
|
|
12
|
+
lower-cased; an unlisted value gives `default`).
|
|
13
|
+
- **Source** — `{ header }` (`X-` header, prefix optional: the dialer's header bag, then the INVITE's; `order:
|
|
14
|
+
'inviteFirst' | 'invite'`), `{ param }` (dialog/campaign parameter), `{ proto }`
|
|
15
|
+
(`proto_additional`), `{ entity }` (CMS input entity), `{ global }` (CMS global variable of the agent), `{ storage }`
|
|
16
|
+
(CMS storage — use for secrets), `{ env }` (process env of the script host), `{ call: 'msisdn' | 'callUuid' |
|
|
17
|
+
'dialogUuid' | 'agentUuid' | 'attempt' | 'today' | 'now' | 'direction' | 'trunkName' | 'bulkUuid' }` (`direction`:
|
|
18
|
+
`in` / `out` from the platform's call row; `trunkName`: the agent's trunk; `bulkUuid`: the campaign upload of the
|
|
19
|
+
dialog; `startedAt`: epoch ms of the dial on the call row), `{ platform: true }` (the value the platform/campaign
|
|
20
|
+
supplies for this feature, e.g. recall budget), `{ dialogEnv: key }` (a value kept in the dialog env, e.g. by the
|
|
21
|
+
pre-call pass), `{ callRow: 'a.b.c' }` (a field of the platform's call row, a dotted path).
|
|
22
|
+
- **Text** — string with `{placeholders}` from call variables; or `{ en: '…', ms: '…' }` picked by the reply
|
|
23
|
+
language; or an expression of the data language (`{ template }`, `{ cases }`, … — `expressions.md`; `null` = say
|
|
24
|
+
nothing).
|
|
25
|
+
- **Condition / Expr** — the data language: every slot that depends on the call (`when`, computed fields, texts,
|
|
26
|
+
report fields, integration bodies…) takes it as data (`{ var: 'dpd', gte: 3 }`, `{ cases: [...] }`). Every operator
|
|
27
|
+
with an example, and which slots take which: `expressions.md`.
|
|
28
|
+
- **Matcher** — `RegExp`; `{ phrases }` (normalized whole-word phrases, optionally per language); `{ lexicon, in? }`
|
|
29
|
+
(a word list of the reply language's pack — and the pack's `patterns` of that name, tested on the line as it is;
|
|
30
|
+
`in: 'all'` reads every call language's pack; `'hi:voicemail'` reads the `hi` pack whatever the call's languages —
|
|
31
|
+
how an agent hears a language it does not reply in; token shapes take such names too); `{ intent }` (platform NLU, an asynchronous rule); `{ tail, chars,
|
|
32
|
+
words? }` (only the last N characters; `words: true` first turns every non-letter into a space and lower-cases);
|
|
33
|
+
`{ normalized }` (the inner matcher on the normalized line); `{ tokens }` (the shape of a short answer, word by word:
|
|
34
|
+
`{ has: lexicon }`, or `{ ignore?, lead?, core, min?, rest? }` — drop `ignore` words wherever they stand, skip `lead` words, at least `min` `core` words, then nothing,
|
|
35
|
+
a whole `rest` phrase, or `rest: { all, some }`); `{ any } / { all } / { not }`.
|
|
36
|
+
- **Action** — see `conversation.md` § Actions. An action (or a list) may also be `{ choose: [{ when: Condition, then:
|
|
37
|
+
actions }], otherwise? }`: the actions chosen by the call.
|
|
38
|
+
- All times are milliseconds unless the name ends in `Sec`.
|
|
39
|
+
|
|
40
|
+
## `id`
|
|
41
|
+
|
|
42
|
+
| Field | Meaning |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `name` | Package name of the agent; appears in logs. |
|
|
45
|
+
| `uuid` | CMS agent UUID; used when the dialog does not carry one (tests, replays). |
|
|
46
|
+
| `version` | Written to every report row (`fact: 'agentVersion'`). Bump on every release. |
|
|
47
|
+
|
|
48
|
+
## `languages`
|
|
49
|
+
|
|
50
|
+
Ordered list of locale codes; the first is the default reply language. Each language needs a recognizer in
|
|
51
|
+
`voice.asr` and a locale pack. A one-language agent: `['en']`. A bilingual opening with a language pick:
|
|
52
|
+
`['ru', 'kk']` plus an opening step `language`.
|
|
53
|
+
|
|
54
|
+
## `platform`
|
|
55
|
+
|
|
56
|
+
| Field | Default | Meaning |
|
|
57
|
+
|---|---|---|
|
|
58
|
+
| `outboundMode` | `'on_answer'` | `'from_invite'` starts the script at INVITE so 1xx/4xx/5xx reach the row (needed to report failed legs with SIP codes). |
|
|
59
|
+
| `ringingTimeoutMs` | 45 000 | Give up on an unanswered leg. |
|
|
60
|
+
| `maxCallMs` | required | Hard limit of a connected call; the call closes with result `timeout` (overridable by `results.fromFacts`). |
|
|
61
|
+
| `maxCallGraceMs` | 0 | At `maxCallMs` the agent's line stops at once and the hangup follows this long after (the caller hears the line end, then a short pause). |
|
|
62
|
+
| `scheduleOutbound` | `true` | On the pre-call pass the script schedules its outbound leg(s) from dialog params. `false` for inbound-only agents; a condition decides per pass from the pass's variables (e.g. only over listed trunks — `{ call: 'trunkName' }`, only for a dialog of a campaign upload — `{ call: 'bulkUuid' }`). `{ priority?, msisdnFromDialog? }`: the first leg with that `priority`; `msisdnFromDialog: false` dials only a number from the dialog params / row (not the dialog's own number; none: no leg), also for the script's redials; `quietAfterCall: true`: a pass after a call places no leg without the `[outbound] post-call phase` log line. Not together with `preDial`. |
|
|
63
|
+
| `preDial` | — | `{ integration, failOpen }`: an integration with `phase: 'preDial'` is asked before every dial (first and redials). `answer(response)` must return true to dial. `failOpen: true` dials when the check fails. |
|
|
64
|
+
| `followLeg` | `'platform'` | Who follows the leg (`from_invite` is always `script`). `'script'` on a script started on the answer: it latches the SIP status, sends "ready" at once, the row starts when the script took the call and its service fields are the script's own view (`call_status` of its SIP view, `call_record` the CMS records page, the start time with ms, the recognizer's seconds), as the old fixed-phrase agents did (`report.service.source: 'script'` takes only the row's service fields that way). |
|
|
65
|
+
| `failedLegPass` | `false` | A leg that never connected is reported on the `after_call_failed` pass instead of the live pass (one row per failed dial, see `report.failedDialRow`); the handler named on the legs for it is `legs.onFailedCall`. `{ statusFrom }`: the row's `call_status` / `call_status_phrase` — `'host'` (the platform's `call_status` param of the pass, then what a live pass handed over; default), `'liveRun'` (the other way round) or `'none'` (null). |
|
|
66
|
+
| `legs` | — | How every leg the script places is placed — the first one, the redials of the failed-leg pass and of the `afterLeg` policy. `dialNumber` (an expression of the raw number, `{ self: true }`): the number as the leg dials it (a trunk prefix, a country code added; a number value is read as its text — `numberMsisdn: false`: not dialled; an empty result: no leg); `trunkLog`: the leg lines name the pool's trunk (`business.md` § Leg policy as data); the dialog and the row keep the number as uploaded. `trunkId`: the trunk when the dialog params name none (before the dialog env's). `protoAdditional`: SIP extras (caller id…) every leg carries — the dialog params' own on top, or with `protoAdditionalOver: true` these win (a header named in both, in any case, is the agent's). `onSuccessCall`: the headless handler of the pass after a leg that connected (`after_call_success`, it runs `afterLeg`; needs `failedLegPass`). `onFailedCall`: the handler named for a dial that fails (default `on_failed_call`; `null`: none — the platform's own continuation runs the failed-leg pass, or without `failedLegPass` an unanswered leg is the live pass's, see `report.unansweredLegRow`, and the platform's own recall chain stays on). Re-routing one leg (test numbers over a test trunk): `routeRules`, `trunkPool`, and `callbacks` at the time the caller named (`business.md` § Leg policy as data). `redialFailed`: the `after_call_failed` pass redials the number itself — `'campaign'` (needs `failedLegPass`; after the leg's row) by the campaign's contact rule a leg naming a handler gives up: at most `recallCount` redials, `recallDelay` seconds from now, counted in the dialog env (`failed_leg_redials`), the dialog's result set `pending`, the row's `attempt` counting them; `'atOnce'`: the same leg again at once (no budget, no delay). Default: a post-call pass never dials. With `legs` and no `failedLegPass` the script schedules the first leg as with `scheduleOutbound` as an object. |
|
|
67
|
+
| `afterLeg` | — | An `AfterLegPolicy` as data (`business.md` § Leg policy as data): what the passes after a leg do — `after_call_success`, and `after_call_failed` after its row (needs `failedLegPass`): which results redial, how many times, when, a client callback when the dialog is over; the live pass leaves what it needs with `results.remember`. |
|
|
68
|
+
| `recall` | — | Redials, see below. |
|
|
69
|
+
| `links` | on | CMS links (record, transcript, LLM log) in the row: `{ host, llmHost?, dialogHost? }` (`Value<string>`; a host read from a source is resolved after the call, links move from its default); `false` to omit. |
|
|
70
|
+
| `llmDialogPerCall` | `true` | The LLM conversation is written to a per-call dialog (`callUuid`) instead of the CMS dialog; extraction reads the same. `'answered'`: the same, but the row of a dial that never connected names the CMS dialog (no LLM dialog was opened). |
|
|
71
|
+
| `cancel` | — | `{ when(call), report? }`: a pass that must not go on (the record is unusable) — `when` reads the pass's variables and returns the result to end it with, or `null`. The pre-call pass dials nothing; a live leg is refused unanswered (no 200 OK). The row is the input fields with that result; `report: true` resolves the links and runs the after-call integrations on it (their `when` sees the row). |
|
|
72
|
+
| `dialogLocale` | — | `{ language, voiceFlag? }` (`{voice}` in `voiceFlag`: the call's voice variant) set on the CMS dialog at call start (some platform features read it). |
|
|
73
|
+
| `dialogResult` | — | Written to the platform dialog's result (the legacy dialog store shows the dialog completed) after a connected call ended, and on the failed-dial pass of a leg that booked no redial. |
|
|
74
|
+
| `dialogResultAt` | `'callEnd'` | When `dialogResult` is written after a connected call: as it ends, or `'row'` once its row is built (after extraction). |
|
|
75
|
+
|
|
76
|
+
### `platform.recall`
|
|
77
|
+
|
|
78
|
+
| Field | Default | Meaning |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| `budget` | required | Redials allowed after the first attempt; `{ from: { platform: true } }` reads the campaign's value. |
|
|
81
|
+
| `budgetCheck` | `'>'` | Stop when `attempt > budget` (default) or `attempt >= budget` (one redial fewer). |
|
|
82
|
+
| `platformRecallOff` | `false` | The script owns the redial chain alone: every leg it places (the first and each redial) carries `recallCount: 0, recallDelay: 0` (the platform's own recall chain stays off), a repeated pre-call pass places no second first leg (dialog env `outboundScheduled`, or a dialog that already has a call), and the row's `triggers_callback` is written false (the redial is booked already). |
|
|
83
|
+
| `delaySec` | required | Seconds; a `Value` (`{ from: { platform: true } }`: the campaign's), or a table by result label whose `default` is a number or the campaign's (`{ busy: 3600, default: { from: { platform: true } } }`). |
|
|
84
|
+
| `dedupBy` | `'callUuid'` | Dedup key of a booked redial (prevents double booking when two passes report). |
|
|
85
|
+
| `beforeIntegrations` | `false` | Book the redial before the after-call integrations run (some copies booked it first). |
|
|
86
|
+
| `legLedger` | `false` | Count attempts by a ledger of the legs the script placed (dialog env `dial_legs_scheduled`, `dial_leg_due_at`, `dial_attempts`) instead of by call UUID: every live pass counts one; a failed-dial report counts only while a placed leg is uncounted and due (a repeated report writes no row, books nothing); no redial while a placed leg is uncounted, none on a dialog the script placed no leg on (inbound). |
|
|
87
|
+
| `entryPoint` | `'on_recall'` | Entry point of the redialed leg. |
|
|
88
|
+
|
|
89
|
+
The script books every redial itself and never redials a dialog it did not dial (inbound). Which results book a
|
|
90
|
+
redial: `results.table[label].recall`.
|
|
91
|
+
|
|
92
|
+
## `voice`
|
|
93
|
+
|
|
94
|
+
| Field | Meaning |
|
|
95
|
+
|---|---|
|
|
96
|
+
| `asr` | Empty (`{}`) only when the opening ends the call (a last step `close`): no recognizer is started. Otherwise one recognizer per language: `{ vendor?, name?, language, data?, pick? }`. `language` is the vendor code (`kk-KZ`), not the locale code. No `name`: the platform's default recognizer of the agent. `picks` chooses `{ name?, data? }` for this call from its variables (e.g. a share of calls on another vendor): `[{ when?: Condition, share?: { from: Expr, default?, seed: Expr }, name?, data? }]`, the first that applies (its `when` holds over the call variables and the call falls in its `share`: FNV-1a 32 of `seed` / 2^32 × 100 below the percent `from` gives, clamped to 0..100; empty: `default`, not a number: 0); none: the agent's own recognizer. E.g. `[{ when: { var: 'asr_vendor', eq: 'vais', normalize: 'lower' }, data: VAIS }, { share: { from: { var: 'vais_percent' }, seed: { template: '{call_uuid}#asr' } }, name: 'vais-key', data: VAIS }]`. `data` (also a pick'ss) is `AsrVendorSettings`: `model`, `phrase_list`, `vais_use_enhanced`, `vais_endpoint`, `vais_timeout`. |
|
|
97
|
+
| `tts` | `{ vendor?, name?, voiceId, model?, strategy?, session?, variants?, variantPick?, variantBy?, variantVar?, respell?, respellScope?, respellBy?, presay?, sentenceTag? }` plus the vendor settings (`TtsVendorSettings`, below). `respell: [{ match, say, keepCase? }]` (`keepCase`: a match starting lower case gets `say` with a lower-case first letter); `respellBy: 'word'` respells a streamed reply up to its last space and holds the rest for the next chunk (a brand split across chunks is still respelled; default each chunk as it comes). `strategy`: the SDK's TTS chunking (`sentence`, `streaming`, `full`). `variants: [{ tag, voiceId, model?, weight?, session?, strategy?, settings?, vars? }]`: one voice per call, picked by a stable hash (FNV-1a) of the call UUID, weighted (`variantPick: 'modulo'`, default: the hash modulo the total weight; `'range'`: the hash as a fraction of 2^32 scaled to the total weight — a variant of weight 1 in 100 takes the lowest 1 % of hashes); `settings` are the voice's own vendor settings (`TtsVendorSettings`, e.g. its speed); the variant's voice, model, settings and strategy go to every TTS play of the call (`session: false`: no TTS session), its tag fills `{voice}` in clip URLs, record names and filler URLs, `platform.dialogLocale.voiceFlag` and the row (`fact: 'voiceTag'`, also `call.voiceTag`). `variantBy` (an expression of the input variables): the variant from the call's input variables instead (its tag; e.g. a persona the input picked, each with its voice, or `{ var: 'persona' }` for an input field holding the tag); a tag that names no variant falls back to the hash; the dialog's voice flag is set again once the variables exist. As data: `variantPick: { by: Expr, otherwise? }` (e.g. `{ by: { var: 'persona.flag' } }`; `otherwise`: the mode when it names no variant, default `modulo`). `variantPick: 'random'`: a weighted draw by the random source (`Math.random`; the stand fixes it) when the call variables are built — the first draw of the call, before the fields. A variant's `vars` (a persona's `name`, `pronouns`, a verb form…) travel with it: with `vars` on a variant or `variantPick: 'random'` the call variable `variantVar` (default `voice`) is `{ tag, ...vars }` of the call's variant, set before the input fields (they read `{ var: 'voice.name' }`; not a prompt variable itself — give a field `prompt` to show it); with `variantBy` / `{ by }` it is set after the fields (when no field has that name). The variant the variable keeps is the call's voice everywhere (TTS, `{voice}`, the dialog flag, `voiceTag`). `respellScope: 'replies'` limits `respell` to the conversation's LLM replies (not the greeting, fixed lines or clips; default `all`). `sentenceTag`: a delivery tag the vendor reads (e.g. a style tag in brackets) put in front of every sentence of every spoken line (each sentence is synthesized alone); the transcript keeps the text without it. `session: true \| { openTimeoutMs }`: one TTS session for the call; it gets `openTimeoutMs` (default 10 s) to open, past it the call goes on without one and a late session is closed (the recognizer gets 10 s the same way: past it the start counts as failed). `presay: string[] \| Expr` (a list of texts): fixed lines put into the TTS cache when the call starts (before the opening's first line, on the TTS session; none without one), so said later they start without the synthesis delay. |
|
|
98
|
+
| `vad` | Vendor VAD settings, passed through **in the vendor's units** (many vendors count frames). |
|
|
99
|
+
| `endOfTurn` | `smartTurn` (vendor end-of-turn model settings), `finalizeDebounceMs`, `quietWindowMs`; `holdOn: Matcher` — while a partial matches (digits, a date being dictated) wait for the vendor final, no early final; `maxUtteranceMs` cuts very long lines (the recognizer is asked to finalize; default 120 000); `vendorFinalInTranscript: true` — the vendor's own final of an utterance an early final already answered (it comes within `quietWindowMs` and is no turn) replaces that line's text in the call transcript while it is still the caller's last line (default: the early final's text stays). |
|
|
100
|
+
| `minPeakVad` | Drop finals whose peak VAD is below the value (line noise); `{ value, except }` keeps matching lines anyway (`except`: any matcher, e.g. short quiet answers). `{ value, over: 'line' }` counts the peak over everything heard since the previous final, not only the speech segment the final closes (a long quiet answer split into segments keeps its louder start); default `over: 'segment'`. |
|
|
101
|
+
| `selfEcho` | The agent's own line coming back on an echoing line: a caller final that reproduces a run of one of the agent's last `lookback` spoken lines (≥ `minEchoTokens` caller words covering ≥ `minAgentCoverage` of the line's distinct words, gaps ≤ `maxGapTokens`; or a whole non-final sentence of the last line, ≥ `sentenceEchoMinTokens` words, and nothing else) is dropped, or cut to the caller's words around it, before voicemail detection and the conversation read it. `expandToken(word)`: a caller word (a number in digits) as the words the agent spoke (agent data). As data: `expandNumbers: true | { prefixes?, ordinals? }` — a word of up to 9 figures (after one of `prefixes`, e.g. `['r']`; with one of the pack's `ordinalSuffixes` when `ordinals`, default on) is the number words (ordinal words) of the first language's pack. |
|
|
102
|
+
| `corrections` | `[{ match, replace }]` applied to every final before anything reads it (vendor mishearings of names, brands). |
|
|
103
|
+
| `dropLine` | Lines dropped before anything reads them (fillers, echoes of the agent). |
|
|
104
|
+
| `dropLineAnswer` | A `RegExp`: a line `dropLine` dropped as a filler that matches it (a bare «uh-huh») is the caller's answer after all when nothing of the agent plays and the line is not held. |
|
|
105
|
+
| `transcriptHeard` | Caller finals the conversation does not answer (speech over the greeting or another opening line, lines dropped within `overtalk.guardMs`) still go to the transcript as caller lines, as heard. Default: only lines that became (part of) a turn. |
|
|
106
|
+
| `ignoreLine` | Caller finals that are not the caller (an advert the line plays): ignored (logged) after the voicemail detectors read them — no turn, no transcript line; any matcher. |
|
|
107
|
+
| `ambient` | Background loop `{ url, volume }` or `{ record, volume }`; `url` is a path or URL as the host plays it (build it from `__dirname` for a file of the agent package); `record` is a CMS record looked up under the dialog's voice flag and played once found. Stopped when the call ends. |
|
|
108
|
+
| `recordFlag` | CMS record flag of the clips (`play` records) when it is not the dialog's voice flag (`platform.dialogLocale.voiceFlag`). |
|
|
109
|
+
| `filler` | `{ urls, afterMs }`: a reply that has streamed nothing after `afterMs` while nothing plays gets one clip picked at random from `urls` (`{voice}` filled) on the agent queue ahead of it (alias `filler`). Not on the LLM greeting. |
|
|
110
|
+
| `asrByReply` | The recognizer follows the agent's replies: a reply as it streams names the `voice.asr` key the caller will answer in, the recognizer is re-created for it; once the call left `noReturnTo` it never goes back. Every `voice.asr` key may be named (not only `languages`). `{ byScript: { scripts: { hi: 'Devanagari', ta: 'Tamil', en: 'Latin' }, minLetters?, minShare?, switchTo? }, noReturnTo? }` — the reply's letters are counted per listed Unicode script; the script with the most wins (a tie: the key listed first) when it has ≥ `minLetters` (default 1) letters and ≥ `minShare` (0..1, default 0) of the listed scripts' letters; only keys of `switchTo` (default all) move the recognizer. The keys detected reach texts and the row as `call.replyAsr` (last) and `call.replyAsrKeys` (every change), e.g. a closing line in the caller's language (`{ lookup: { of: { fact: 'replyAsr' }, table, default } }`), the language the call was served in (`{ replyAsr: { ignore: ['en'], map, default } }`). |
|
|
111
|
+
| `clipTranscript` | Clips played from a file or record (not TTS) are written to the platform's call transcript as agent lines (the CMS log), as they play. |
|
|
112
|
+
| `mixer` | Queue numbers and volumes when the defaults do not fit: `tts` (1), `ambient` (2), `sfx` (0), `sfxVolume`. |
|
|
113
|
+
|
|
114
|
+
Voice values that are `Value`s (`tts.voiceId`, `tts.model`, `asr.<lang>.vendor`, `ambient.url`,
|
|
115
|
+
`transfer.humanDetect.asr.vendor`) may be read from sources (`{ from: { global: 'voice_id' }, default: 'voice-1' }`):
|
|
116
|
+
each call reads them before its media starts (a source that fails or gives nothing: the `default`); a voice variant's
|
|
117
|
+
voice still wins. Matchers the media tests lines with (`dropLine`, `endOfTurn.holdOn`, `minPeakVad.except`,
|
|
118
|
+
`overtalk.interrupt.match`, the NLU voicemail `fallback`, the dial transfer's `queue`) may be any matcher but an
|
|
119
|
+
`intent`; the media knows no reply language, so a lexicon reads the agent's first language (`in: 'all'`: every one).
|
|
120
|
+
|
|
121
|
+
## `input`
|
|
122
|
+
|
|
123
|
+
`input.headerBagEnvKey`: `{ header }` sources also read a header bag kept in the dialog env under that key (e.g.
|
|
124
|
+
`proto_additional`) when the dialog params and the call row carry none (before the INVITE headers). A field with
|
|
125
|
+
`secret: true` (a one-time code) and the dialog keys it reads are `[redacted]` in the integration-context log line.
|
|
126
|
+
|
|
127
|
+
`input.dialogEnv: [{ key, value(call), unless?(current), on? }]`: values written to the dialog env (`undefined` leaves the
|
|
128
|
+
key), skipped when `unless` holds for the value already there — e.g. the day of the dialog's first call, kept for its
|
|
129
|
+
report. `on: 'call'` (default): when the call is set up (the live pass and the failed-leg pass; not the pre-call pass);
|
|
130
|
+
`'everyPass'`: on every pass once its variables are read (also the pre-call pass and the passes after a leg — e.g. a
|
|
131
|
+
client callback URL the pass after a leg needs when its own dialog params lack it).
|
|
132
|
+
|
|
133
|
+
`input.fields.*.read`: a reader (`ReadSpec`, `expressions.md` § Readers) applied to the sourced value before `default`
|
|
134
|
+
and `format` — `'msisdn'`, `{ kind: 'date', orders: ['mdy'], trailingTime: true }`, `{ kind: 'amount', separators:
|
|
135
|
+
'lastIsDecimal' }`, `{ kind: 'personName', punctuation: 'keep' }`; an empty read value takes `default`. `from` may be an
|
|
136
|
+
expression of the data language (any object that is not one `Source`), computed from the fields before it and the
|
|
137
|
+
clock; `default` too. `value` and `unless` of `dialogEnv` may be data (`unless` reads the kept value as `{ self: true }`).
|
|
138
|
+
|
|
139
|
+
See `business.md` § Input. Fields: `fields`, `timeZone`, `required`, `testData`, `dialogEnv`.
|
|
140
|
+
|
|
141
|
+
## `matchers`, `facts`
|
|
142
|
+
|
|
143
|
+
`matchers: { name: Matcher }` — named matchers, used as `{ matcher: 'name' }` anywhere a matcher goes (resolved when
|
|
144
|
+
the agent is defined; an unknown name fails it). `facts: { name: { condition } | { value } }` — named facts of the call,
|
|
145
|
+
read as `{ fact: 'name' }` in conditions and expressions (evaluated when read; a built-in fact name is refused). See
|
|
146
|
+
`expressions.md`.
|
|
147
|
+
|
|
148
|
+
## Conversation blocks are optional when the opening ends the call
|
|
149
|
+
|
|
150
|
+
`prompt`, `silence` and `closing` are required, except in an agent whose opening ends the call (its last step is
|
|
151
|
+
`close`, e.g. a code read to the customer and a hangup): there is no LLM conversation, the blocks may be left out
|
|
152
|
+
(and `voice.asr` may be `{}`).
|
|
153
|
+
|
|
154
|
+
**An agent without an LLM** leaves out `prompt` only (`silence` and `closing` stay): every line it says is a fixed
|
|
155
|
+
text that rules and blocks pick — e.g. the `knowledgeAnswer` block (`blocks.md`), which answers every caller line from
|
|
156
|
+
a knowledge base, silence rungs `{ do: { knowledge: 'silence' } }`. While the block decides, the agent stops and the
|
|
157
|
+
silence windows wait (no LLM turn is held); a line nothing answered is only written to the transcript (log
|
|
158
|
+
`turn_not_answered`). No LLM request is ever made.
|
|
159
|
+
|
|
160
|
+
## `prompt`
|
|
161
|
+
|
|
162
|
+
| Field | Meaning |
|
|
163
|
+
|---|---|
|
|
164
|
+
| `template` | File name of the system instruction template; the platform renders it with the call's variables. |
|
|
165
|
+
| `engine` | `'squirrelly'` (`{{ it.name }}`) or `'jinja'`. Must match what the CMS agent uses. |
|
|
166
|
+
| `vars` | Extra variables for the prompt only; a record expression (`{ object }`, `{ merge }`, `{ cases }`) is evaluated before every LLM request (reply language, gate state…) and merged after the input's prompt variables, in its own key order. |
|
|
167
|
+
| `variants` | `[{ when, vars }]`: the first set whose `when` holds is added to the prompt variables (after the input fields and `vars`) at every LLM request; `vars` may be a record expression (scenario variants: one wording set per scenario). |
|
|
168
|
+
| `handoff` | First message to the LLM after a fixed opening (engine media). Placeholders (also `{ var }` of a text expression): `{said_1}`, `{said_2}`… (opening lines spoken), `{callerLine}` (the turn's text with its marks), `{firstReply}` (the caller's answer to the opening, lines joined by ` | `, empty when none), `{language}`, `{askedLanguage}` (language of the opening question), `{provisional}`. |
|
|
169
|
+
| `languageNames` | How the prompt names the call languages in markers, reasons and `llmTurn` (e.g. `{ kk: 'kz' }`); default the locale code. |
|
|
170
|
+
| `callVars` | Prompt variables of every LLM request from the call's language state: `{ name: 'languageName' \| 'languageProvisional' \| 'language' }` (the reply language as `languageNames` names it, whether the pick is still provisional, its locale code). They come first; `vars` and `variants` after (a key they set keeps its place, with their value). `true`: the usual set `{ reply_language: 'languageName', reply_language_provisional: 'languageProvisional', opening_language: 'languageName' }` (the variables every bilingual agent set by hand); absent or `false`: none. |
|
|
171
|
+
| `silenceSignal` | Text the LLM gets on a silence turn; placeholders `{attempt}`, `{heardSpeech}`. A `Text` by language or an expression is read at each use (the media compares a request with the signal of the moment). |
|
|
172
|
+
| `errorSignal` | Written to the log when the call ends without a goodbye; not sent to the LLM (the production agents only logged it). |
|
|
173
|
+
| `systemNotes` | `{ mark }`: lines the agent spoke without the LLM (fixed replies, rung `say`s, probes, the guard's re-asks; not closing lines, not the opening) reach the LLM in front of the caller's next line, each as `mark` with `{line}` filled, joined by spaces; an empty reply to that turn is asked again without them. |
|
|
174
|
+
| `persistentStream` | `true`: keep one LLM stream for the call (every request a send on it). |
|
|
175
|
+
| `hiddenSignals` | LLM requests whose text is one of the agent's own signals (an LLM greeting's `signal`, `silenceSignal`, a silence rung's `llm` text) go with `hidden: true` (kept out of the visible dialog). Default: no `hidden` option is sent. |
|
|
176
|
+
|
|
177
|
+
`voice.tts`: `name`, `voiceId` → `ttsConfig.voice_id`, `model` → `ttsConfig.model_id`, `strategy` → the TTS chunking,
|
|
178
|
+
`vendor` → the TTS vendor; the vendor settings (`TtsVendorSettings`, flat on `voice.tts`: `voice_settings_stability`,
|
|
179
|
+
`voice_settings_similarity_boost`, `voice_settings_speed`, `language_code`, `output_format`, `cache: { flag }`) go into
|
|
180
|
+
`ttsConfig` as they are; other keys do not type-check (no pass-through). `turn.drainCeiling.minMs` (default 20 000) also bounds the hangup drain and a played LLM line.
|
|
181
|
+
|
|
182
|
+
## `opening`, `gates`, `turn`, `overtalk`, `silence`, `voicemail`, `rules`, `closing`, `transfer`
|
|
183
|
+
|
|
184
|
+
See `conversation.md` — these blocks only make sense together. The transfer's options and their defaults, in short:
|
|
185
|
+
`answerTimeoutMs` (bridge ring time, 30 000), `onFailure.then` (`log`: nothing said, the customer stays on the line),
|
|
186
|
+
`results.notAnswered` / `customerDropped` (the result before the transfer); every outcome (`connected`, `no_answer`,
|
|
187
|
+
`timeout`, `rejected`, `operator_gone`, `dial_failed`, `not_configured`, `customer_gone`) is in `conversation.md` §
|
|
188
|
+
Transfer.
|
|
189
|
+
|
|
190
|
+
## `extraction`, `results`, `report`, `integrations`
|
|
191
|
+
|
|
192
|
+
See `business.md`.
|
|
193
|
+
|
|
194
|
+
## `decisionModel`, `knowledgeAnswer`, `catalogMatch`
|
|
195
|
+
|
|
196
|
+
See `blocks.md`: blocks that bring their own rules and integrations (silence rung action `{ knowledge }`, report
|
|
197
|
+
fields `{ knowledgeTrace }` / `{ catalogMatch: 'row' }`).
|
|
198
|
+
|
|
199
|
+
## What the data language sees of the call
|
|
200
|
+
|
|
201
|
+
The engine's view of the call (`CallView`) is what the data language reads: `{ var }`, `{ fact }`, `{ entity }`, `{ flag }`, `{ counter }`,
|
|
202
|
+
`{ memory }`, `{ row }` (`expressions.md` § References).
|
|
203
|
+
|
|
204
|
+
`CallView` (`spec.ts`): `vars`, `language` / `languageProvisional` (the reply language and whether the pick may still
|
|
205
|
+
change), `phase` (`transfer` once a transfer started), `lines` / `agentLines` / `callerLines`, `callerTurns` /
|
|
206
|
+
`callerFinals`, `counters`, `flags` (gates set `<id>.passed`; a gate's `passedBy` line counts too), `attempt`, `memory`;
|
|
207
|
+
after the call `extracted` (entities), `result` (the decided label, before `labels.map`), and for report fields
|
|
208
|
+
`preResult`, `extractedResult`, `triggersCallback` (`null` on rows without them: failed dials, failed legs),
|
|
209
|
+
`endedBy` (`agent`: the agent hung up,
|
|
210
|
+
`caller`, `timeout`: the call's time limit), `replyAsr` / `replyAsrKeys` (`voice.asrByReply`) and `transfer`
|
|
211
|
+
(`{ started, completed, startedAt }`: how far a started operator transfer got — dialled, bridged; absent when none
|
|
212
|
+
started; a transfer that did not connect has `completed: false` and its outcome's result, see `conversation.md` §
|
|
213
|
+
Transfer). An agent line of `lines` carries `unit`, its mixer alias (a fixed line's name, `reply` for the LLM's), where the
|
|
214
|
+
call knows it (the conversation, a connected call's row). Report fields also read `rowFacts`: the row's `kind`
|
|
215
|
+
(`call`, `error`, `failedLeg`, …), the platform's `service` fields as the library would write them, `callUuid`,
|
|
216
|
+
`dialogUuid`, `asrDurationSec` — for a row in the client's own layout (`report.service: false` and every column an
|
|
217
|
+
expression). After-call integrations get `outcome`: the decided `result`, `preResult`, `triggersCallback`, `entities`
|
|
218
|
+
(`null` when extraction threw; absent on a leg that never connected).
|
|
219
|
+
|
|
220
|
+
## No agent code
|
|
221
|
+
|
|
222
|
+
An agent is data only: the authoring types (`AgentSpec` and its section types) take data forms, and a function or a
|
|
223
|
+
reference to agent code anywhere in the agent file is a compile error. The engine compiles the data forms into its
|
|
224
|
+
own functions when the script is built (`compiledSpecOf` of `@voctiv/agent-runtime/testing` shows the result). A
|
|
225
|
+
failed effect (`PORT_ERROR`) or a step of the engine that throws inside the reducer is logged `engine_error` and hangs
|
|
226
|
+
the call up (no phrase, result kept; nothing while closing or transferred).
|
|
227
|
+
|
|
228
|
+
What an agent needs and the data cannot say yet — a client business rule, a client API with an unusual protocol, a
|
|
229
|
+
domain algorithm — is added to the library as a generic template or field, chosen by values, with a default that keeps
|
|
230
|
+
every other agent unchanged; then the agent uses it as data.
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# Blocks with their own engine: `decisionModel`, `knowledgeAnswer`, `catalogMatch` (+ `verify`); state blocks `tracking`, notes, `ladders`, `choices`
|
|
2
|
+
|
|
3
|
+
These blocks carry runtime behaviour of their own (a planner, a recognizer, client lookups): the engine adds their own
|
|
4
|
+
steps, rules and integrations to the agent file when the script is built (`engine/expand.ts`, `withBlocks`). The agent
|
|
5
|
+
writes only data. Source: `src/templates/decision-model/`, `src/templates/knowledge/`, `src/templates/catalog-match/`.
|
|
6
|
+
|
|
7
|
+
## `decisionModel` — the choice model in one place
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
decisionModel: {
|
|
11
|
+
model: 'jev' | 'clef-flash'; // asked unless the storage override names another model
|
|
12
|
+
timeoutMs: number; // past it the request failed
|
|
13
|
+
hedgeAfterMs: number; // a second identical request after this long; first answer wins (0: never)
|
|
14
|
+
credentials: { accountId: { storage }, apiToken: { storage } }; // CMS storage keys, read once per call
|
|
15
|
+
modelOverride?: { storage }; // read in the same storage call, after the credentials
|
|
16
|
+
warmup?: { state, questions }; // one request right after the credentials are read (logged, never waited on)
|
|
17
|
+
logPrefix: string; // events `<p>_ready` (+ `missing` without credentials), `<p>_init_failed`,
|
|
18
|
+
// `<p>_warmup`, `<p>_warmup_failed`; knowledgeAnswer also `<p>_skipped`,
|
|
19
|
+
// `<p>_stale`, `<p>_failed`, `<p>_turn_merged`, perf `<p>_superseded`
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
A block takes its own `decision` (`knowledgeAnswer.decision`, `catalogMatch.pick.decision`) or, by default, the agent's
|
|
24
|
+
`decisionModel`. Without either, `.build()` throws. When the credentials are read: `knowledgeAnswer` at answer
|
|
25
|
+
(its start integration, after the greeting plan); `catalogMatch` at the call's first caller line. A request without
|
|
26
|
+
credentials rejects unsent (`no decision credentials`).
|
|
27
|
+
|
|
28
|
+
## `knowledgeAnswer` — fixed answers from a knowledge base, no LLM
|
|
29
|
+
|
|
30
|
+
Every caller line is planned by the cheapest step that can: a whole-line control pattern (`controls.*.fast`), an exact
|
|
31
|
+
phrasing of one card (`exactMatch`), or retrieval (lexical BM25 over stems and trigrams, plus dense vectors when
|
|
32
|
+
`kb.vectors` match `kb.version`) and ONE `choice` request over the candidates, the controls and `other`. A confident
|
|
33
|
+
card says its answer then `anythingElse`; two close cards ask `clarifyTemplate`; a topic says its menu; the rest walks
|
|
34
|
+
the ladders.
|
|
35
|
+
|
|
36
|
+
| Field | Meaning |
|
|
37
|
+
|---|---|
|
|
38
|
+
| `kb.cards` / `kb.topics` / `kb.version` / `kb.vectors` | generated agent data (`KbCard`, `KbTopic`, `KbVectors`) |
|
|
39
|
+
| `phrases` | system phrases by id; card answers / topic menus are `card:<id>` / `topic:<id>` |
|
|
40
|
+
| `greeting` | phrase ids of the start plan (the opening says them); `presay: 'systemPhrases'` presays every other phrase (unless `voice.tts.presay` is set) |
|
|
41
|
+
| `anythingElse`, `clarifyTemplate` (`{a}`, `{b}`) | after an answer; two close cards |
|
|
42
|
+
| `question.{context, instructions, otherCriterion, lastSaidMaxChars}` | the request's state line, the question, the `other` option, the cut of `bot_last_said` |
|
|
43
|
+
| `controls` | `{ kind: 'listen' \| 'repeat' \| 'say' \| 'goodbye' \| 'operator' \| 'not_found', criterion, say?, end?, fast?, fastPatterns?, noFastAfterChoice?, resetFocus? }` in fast-path order; `fast` is a regexp alternation the whole normalized line must be, padded with `fastPad` words: `^PAD(?:fast)\s*PAD$` |
|
|
44
|
+
| `retrieval.{candidates, maxTopicCandidates, followUpCandidates, fusionDepth=60, lexicalFusionWeight=0.15, options}` | candidates per request, topics among them, neighbours of the last answer pinned; BM25 options |
|
|
45
|
+
| `retrieval.synonyms`, `retrieval.transliterate` | query expansion groups; Latin words → the agent's script before reading |
|
|
46
|
+
| `retrieval.languages` (default: the agent's), `retrieval.stopwords: { languages, add? }` | packs whose `words.fold` / `words.stem` read the text; stopwords = the packs' `words.stopwords` + `add` |
|
|
47
|
+
| `retrieval.dense: { model, timeoutMs, probeTimeoutMs=3000, probeMinCosine=0.97 }` | the embedding model of the vectors; the call-start probe turns dense off on a model mismatch |
|
|
48
|
+
| `thresholds.{answer, clarify, clarifySecond, control}`, `exactMatch` (default true) | the answer policy |
|
|
49
|
+
| `ladders.{unclear, unclearExhausted, notFound, notFoundExhausted, silence, silenceExhausted, badConnection}` | n-th turn plays the n-th phrase list; past the end the terminal `{ say, end }` (or the operator) |
|
|
50
|
+
| `transfer.{enabled, say, unavailable, afterAnswer?}`, `operatorRequest` | operator requests (a whole line, or inside a question) |
|
|
51
|
+
| `results.{answered, unanswered, rewrite}` | at the call's end a result of `rewrite` becomes `answered` (a card was answered) or `unanswered` (asked, never answered) |
|
|
52
|
+
| `unheardLine` | the caller line of speech without words (default `silence.speechWithoutText.transcriptLine`) |
|
|
53
|
+
| `ruleId` (default `knowledge`), `startId` (default `knowledge_start`) | ids of the added rule and integration |
|
|
54
|
+
|
|
55
|
+
What the block adds: a caller-line rule on every line (a line said while a decision is in flight is decided together
|
|
56
|
+
with it; an older answer is dropped), an answer-phase integration (the planner, its greeting plan, the decision
|
|
57
|
+
model's credentials, warm-up and the vectors' probe), two `callEnd` result rules, the engine's steps `knowledgeAnswer:*`.
|
|
58
|
+
The agent writes silence rungs as `do: { knowledge: 'silence' }` (the silence ladder; its end closes the call) and
|
|
59
|
+
`speechWithoutText.do: { knowledge: 'unheard' }` (the unclear ladder), and the row's trace as report fields
|
|
60
|
+
`{ knowledgeTrace: 'notConnected' }` (17 `decision_*` / `qna_*` keys, all `null`, on a dial that never connected) and
|
|
61
|
+
`{ knowledgeTrace: 'call' }` (on a call). A plan says its phrases as one `say` (parts), re-prompts with
|
|
62
|
+
`speechOver: 'answer'`; an ending plan closes with `reason: dialog_<kind>`.
|
|
63
|
+
|
|
64
|
+
## `catalogMatch` — a spoken name matched to a two-level list, then `verify`
|
|
65
|
+
|
|
66
|
+
The caller names a parent and a child of the agent's list (`catalog: { key, name, aliases, children: ['name / alias'] }`,
|
|
67
|
+
parentheses mark words that may be left out). Each line answering the value's question (`readWhen.asked` within
|
|
68
|
+
`lookbackAgentLines`) is read with no network (lower case, the packs' `fold`, `numberWord`, `loose`, `words.ignore`
|
|
69
|
+
type words dropped) and scored against every spelling; the best `pick.candidates` above `pick.minScore` go to the
|
|
70
|
+
decision model in one request — a question per level (keys = `levels.parent` / `levels.child`) over the options plus
|
|
71
|
+
`none`. A pick under `pick.minProbability` is no pick. What changed rides in front of the NEXT caller turn as
|
|
72
|
+
`recognizedMark` (`{fields}` = `slot=name;` pairs). A new parent drops a child of another one; a stale answer never
|
|
73
|
+
replaces a newer pick.
|
|
74
|
+
|
|
75
|
+
| Field | Meaning |
|
|
76
|
+
|---|---|
|
|
77
|
+
| `levels.{parent, child}` | slot names: question keys, mark fields, extracted entity names, `customer_<parent>` in the state |
|
|
78
|
+
| `words.{ignore, qualifier, numberEndings, numberLetters, numberKey?}` | type words; words that let a bare number be a name; number endings; letters kept with a number; a child key that is a number renamed (`{ match, key }` on the ASCII slug) |
|
|
79
|
+
| `scoring.*` | `minWordSimilarity` 0.7, `numberMissingFactor` 0.9, `numberOnlyScore` 0.8, `optionalBonus` 0.02 at `optionalMinSimilarity` 0.85 |
|
|
80
|
+
| `readWhen.steps` | `{ step, asked }` in priority order: which step a line answers (the parent's pattern also re-asks the parent once one is known) |
|
|
81
|
+
| `pick.{context, lastSaidMaxChars, parent, child, aliases, answerInstructions}` | request texts; `parent`/`child` = `{ instructions, none, option ('{name}{aliases}', child also `{parent}`), named, other }` |
|
|
82
|
+
| `reconcile.{keys, sameNameScore=0.75, sure=0.9, lead=0.05}` | the row: the recognizer's pick when the extractor read the same name, else the extractor's value in the list's spelling when it names one entry by itself, else as read (`keys.childAsSaid`, `keys.parentInList`, `keys.childInList`) |
|
|
83
|
+
| `hold: { afterMs, say }` | the added rule's `whileWaiting` while a check holds the reply |
|
|
84
|
+
| `languages` (default the agent's), `logPrefix`, `ruleId` (default `catalogMatch`) | packs; events `<p>_recognition`, `_recognition_failed`, `_recognition_skipped`, `_check`, `_check_skipped`, `_check_failed`, `_lookup`, `_lookup_http`, `_normalizer_http`, `_<step>_normalized` |
|
|
85
|
+
|
|
86
|
+
### `verify` — checked with a client service one step at a time
|
|
87
|
+
|
|
88
|
+
A line answering a step of the check (`readWhen.steps`) holds the reply until the step is settled; the steps of a call
|
|
89
|
+
run one after another; only the newest waiting line gets the marks. A level step asks the model for the spelling and
|
|
90
|
+
whether the line names one at all (answer question `named` / `other`), then looks up the list's spelling first and the
|
|
91
|
+
line as said second (stops on found or unavailable). A step without a level reads its value with a CMS chat agent
|
|
92
|
+
(`normalize: { host, agentUuid, timeoutMs, accept }`, POST `<host>/api/v1/chat/<dialog>/send`, a dialog derived from
|
|
93
|
+
the call uuid per request); `''` (no value) skips the line, a failure falls back to the line when it matches `accept`.
|
|
94
|
+
Three answers: the service's `notFoundText` is `not_found`; a failed request, a bad body or a missing id is
|
|
95
|
+
`unavailable` — never a no; a miss on a line nobody vetted (no model, no list name near it) is `unavailable` too.
|
|
96
|
+
|
|
97
|
+
| Field | Meaning |
|
|
98
|
+
|---|---|
|
|
99
|
+
| `steps[]` | `{ step, level?: 'parent' \| 'child', spelledAs, lookup: { url, body: { key: { query: true } \| { id: '<step>' } }, read?: { id?, name? } }, clears?: ['<step>'], normalize? }` — a body id an earlier step has not found makes the step `unavailable` unsent |
|
|
100
|
+
| `round` | round flags at the start (e.g. `{ recheck: false, lenient: false }`) |
|
|
101
|
+
| `transitions[]` | `{ step, status?, when? /* Condition over the round flags ({ flag: name }, unset false; expressions.md), or the older map of flag values */, action, next?, set?, outcome? }`, first match wins; `outcome` is the check's status (default `in_progress`; any other value decides the call: no more check steps) |
|
|
102
|
+
| `mark`, `spelledMark` | `{step}`, `{status}`, `{spelled}` (`spelledMark` with `{field}` = `spelledAs`, `{value}` = the found name, on found), `{action}` |
|
|
103
|
+
| `timeoutMs`, `notFoundText` | lookups |
|
|
104
|
+
| `report.{status, fields[{ key, step, of: 'id' \| 'name' \| 'value' }]}` | the check on the row, every key present (`null` when not reached) |
|
|
105
|
+
|
|
106
|
+
The row: report field `{ catalogMatch: 'row', entities: 'all' }` — on a call's row (nothing on a failed dial) every
|
|
107
|
+
extraction entity (`null` when not extracted), the extracted values, the reconciled levels and keys, the check's keys.
|
|
108
|
+
|
|
109
|
+
## State blocks — per-call state as data: `tracking`, caller-line notes, `ladders`, `choices`
|
|
110
|
+
|
|
111
|
+
Per-call state a client agent once kept in its own code (what the caller heard, how far the call got, which question is open, how often a line
|
|
112
|
+
was said, which option the caller picked) is data. The engine keeps their state in its own state (flags, counters,
|
|
113
|
+
`noteLadders`), everything else is read off the transcript when a condition asks; the reduce stays pure. Source:
|
|
114
|
+
`src/templates/engine/turns/` (`tracking.ts`, `notes.ts`, `ladders.ts`, `choices.ts`, `state.ts`; types in
|
|
115
|
+
`state-spec.ts`).
|
|
116
|
+
|
|
117
|
+
### `tracking` — sticky facts off the conversation
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
tracking: {
|
|
121
|
+
flags?: { // read as { flag: name }; sticky
|
|
122
|
+
[name]: { on: 'agentLine' | 'callerLine' | 'anyLine'; match; normalize?: 'NFC' } // some such line matches
|
|
123
|
+
| { on: 'heard'; match?; impliedBy?: string[]; log?: string } // a reply heard to its end matches
|
|
124
|
+
| { on: 'cut'; when?: Condition; log?: string }; // a reply not heard while `when`
|
|
125
|
+
};
|
|
126
|
+
stages?: { list: string[]; rules: { on; match?; from?: string[] | { not: string[] }; to }[];
|
|
127
|
+
source?: 'transcript' | 'platformTranscript' }; // { stage: … }, { fact: 'stage' }
|
|
128
|
+
questions?: { list: { id; asked: Matcher }[]; keepOn?: Matcher; else?: string }; // { openQuestion }, { asked }, { answers }
|
|
129
|
+
log?: string; // event when heard / cut flags change: { <log name>: value } of every flag of that kind
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
- Heard / cut: the media reports each conversation reply (not the greeting) as heard (played to its end as the current
|
|
134
|
+
turn, nobody cut it) or not; `heard` flags test the reply's text, `impliedBy` sets a flag when another is set (to a
|
|
135
|
+
fixpoint), `cut` flags read `when` before the reply's flags change. The flags are the call's (`call.flags`): prompt
|
|
136
|
+
variables read them as `{ test: { flag } }` (`prompt.vars: { object: { reply_cut: { test: { flag: 'replyCut' } } } }`).
|
|
137
|
+
- Stages: per line, the first rule whose speaker, `from` and `match` hold moves the stage to `to`; never back (a move to an
|
|
138
|
+
earlier or the same stage of `list` is none). `platformTranscript` reads the platform's `call_transcript` (`USER:` /
|
|
139
|
+
`AGENT:` lines, unprefixed lines continue the one before) after the call; during it, the call's lines.
|
|
140
|
+
- Questions: each agent line leaves open the first of `list` whose `asked` matches; a line matching `keepOn` keeps the one
|
|
141
|
+
before; else `else` (counted as asked) or none. `{ openQuestion: id }` reads the question open now, `{ asked: id }` the
|
|
142
|
+
agent lines that asked it, `{ answers: { question, match? } }` the caller lines said while it was open.
|
|
143
|
+
|
|
144
|
+
### Caller-line notes — `turn.filters: [{ filter: 'annotateCaller', notes, perRequest? }]`
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
notes: (NoteRule | { oneOf: NoteRule[] })[] // in order; oneOf: the first that notes anything
|
|
148
|
+
NoteRule = { id; when?: Condition; unlessNotes?: string[]; detect?: NoteDetector; note: Expr;
|
|
149
|
+
place: 'front' | 'beforeWords' | 'append'; dedupe?: true }
|
|
150
|
+
NoteDetector = { dayHints: { groups; resolved: Expr; notFollowedBy?: RegExp } }
|
|
151
|
+
| { ladder: name } // the note ladder's next note
|
|
152
|
+
| { choice: { set; mode: 'chosen' | 'yesToNamed'; yes?: Matcher } }
|
|
153
|
+
| { dates: { of?; today?; pack?; bareDay?; nextMonthUntil?; pastMonth?; numeric?; relative?; todayWhen?;
|
|
154
|
+
only?: 'date' | 'past'; first?: true } } // the pack's parse.dates
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
- `when` reads `line` = the caller's words and the locals `notes` (the notes in front so far, with the space after
|
|
158
|
+
them), `noted` (the whole text so far), `words`. The note is evaluated once per detected item with its fields as
|
|
159
|
+
locals (without `detect`: once); an empty text is no note. `front`: the items in order in front of everything;
|
|
160
|
+
`beforeWords`: after the notes in front, right before the words; `append`: right after the text (give the note its own
|
|
161
|
+
leading space).
|
|
162
|
+
- `dayHints` groups (read in order, each gives the first of its words found as a whole word, spaces as any spaces, lower
|
|
163
|
+
case, not followed by `notFollowedBy`; that match is blanked for the groups after it): `{ words, days }` (today +
|
|
164
|
+
days), `{ words, monthEnd: true }`, `{ nextToday: 'next {weekday}' }` (today's weekday word, a week ahead),
|
|
165
|
+
`{ weekdays: [[sunday words], [monday words], …] }` (next such day, today itself included; Monday first),
|
|
166
|
+
`{ ordinalDays: { wordsFrom?, lead? } }` (days of this month from today and of the next month before it: «12th», and
|
|
167
|
+
from `wordsFrom` on `lead` + the ordinal word, also with a space for the hyphen). Items: `word`, `resolved`, `date`,
|
|
168
|
+
`year`, `month`, `day`, `weekday`, `weekdayName`, `monthName`, `dayOrdinal` (the reply language's pack); `resolved`
|
|
169
|
+
sees the same locals.
|
|
170
|
+
- `dayHints.pack`: the pack whose weekday, month and ordinal words fill the locals (default the reply language).
|
|
171
|
+
- `dates` reads the days a text names (`of`, default the words) with the pack's `parse.dates` (`pack`, default the
|
|
172
|
+
reply language), seen from `today` (an expression, default the clock's day); `bareDay` / `nextMonthUntil` (expressions;
|
|
173
|
+
the latter only when bare days are read), `pastMonth`, `numeric`, `relative` go to the parser; a text matching
|
|
174
|
+
`todayWhen` names today; `only` keeps `date` or `past` items, `first` the first. Items: `said`, `past`, `kind`, `date`.
|
|
175
|
+
- Rules and ladders read the same detectors: condition `{ detects: detector | detectors }` (something found in the
|
|
176
|
+
line), expression `{ detected: … }` (the items, in order); `{ lastLineOf: { who, match?, skip? } }` is the latest line
|
|
177
|
+
of a speaker that matches (wordless lines not skipped).
|
|
178
|
+
- `choice` items: `key`, `said`, `name`, `spoken`, `value` of the option; `yesToNamed`: the last agent line names
|
|
179
|
+
exactly one option by number and the words match `yes`.
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
// A note while a cut status line is unheard wins over the bare «oo» ladder note.
|
|
183
|
+
notes: [{ oneOf: [
|
|
184
|
+
{ id: 'status', when: { all: [{ flag: 'identityConfirmed' }, { not: { flag: 'offerHeard' } }, { flag: 'replyCut' }] }, note: ' (note: …)', place: 'append' },
|
|
185
|
+
{ id: 'oo', when: { line: /^[\s.,!?…]*oo+[\s.,!?…]*$/i }, detect: { ladder: 'oo' }, note: { local: 'note' }, place: 'append' },
|
|
186
|
+
] }]
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### `ladders` — lines once each, or notes by stage
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
ladders: {
|
|
193
|
+
[name]: { lines: (Expr | { text; when?; spokenAs?; unlessSaid?: number[] })[]; spokenBy?: 'includes' | 'includesCI';
|
|
194
|
+
fill?: { slot; with: Expr }; goodbyeCloses?: { result; reason? }; alias?; then: 'llm' | Action | Action[] }
|
|
195
|
+
| { notes: Expr[]; stages: { name; question: Matcher; probes?: string[]; next }[]; start; stageBy: 'lastQuestionOfHeardReply';
|
|
196
|
+
repeatUntilHeard?: true; log?: string }
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
- A line ladder is said by the action `{ ladder: name }`: the first rung not said yet whose `when` holds and none of whose
|
|
201
|
+
`unlessSaid` rungs had its own text said; a rung counts as said once an agent line contains `spokenAs` (default its
|
|
202
|
+
text). All
|
|
203
|
+
said: `then`. No state: what was said is read off the agent's lines. `{ ladderOpen: name }` asks whether it has a line
|
|
204
|
+
(put it in a rule's `when` so the next rule gets the line when it has none).
|
|
205
|
+
- A note ladder is read by a note's `{ ladder }` detector: the stage is the first of `stages` whose `question` matches the
|
|
206
|
+
last question (`?` sentence) of the reply the caller last heard (`start` before one); each noted line counts at its
|
|
207
|
+
stage, the n-th gets `notes[n-1]` (the last from then on) with the locals `count`, `stage`, `next`, `probe`
|
|
208
|
+
(`probes[count-1]`, `null` without); `repeatUntilHeard`: the line's note again (not counted) until a reply is heard.
|
|
209
|
+
|
|
210
|
+
### `choices` — option sets
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
choices: { [set]: {
|
|
214
|
+
options?: { [key]: { words: Matcher | string[]; value?: Expr; spoken?: Expr; name? } };
|
|
215
|
+
numbers?: { nearest: { closeRatio; digitsInside?: { minValue } } }; // a number said picks the nearest option
|
|
216
|
+
offers?: { id; text: Expr; questions: { ask: Expr; options: { name; match: Matcher }[] }[] }[];
|
|
217
|
+
interested?: { chose; sep };
|
|
218
|
+
headers?: { id; text; idFormat /* '{n}' | '{id}' */; cap?; encode?: 'uri'; sep; between; spoken?: { clause: RegExp; identifyBy: RegExp } };
|
|
219
|
+
enabledWhen?: Condition;
|
|
220
|
+
} }
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
A line picks every option whose `words` it names (a regular expression: its first match is the words said; a list: whole
|
|
224
|
+
words of the normalized line), then with `numbers` each number the reply language's pack reads in it picks the option
|
|
225
|
+
whose value is nearest (the same whole value, else within `closeRatio`, else its digits inside the number's when the
|
|
226
|
+
number is at least `minValue`; two options by the same rule: none). Read as `{ choice: set, op }` expressions and note
|
|
227
|
+
detectors.
|
|
228
|
+
|
|
229
|
+
Offers (a product, then its variants) are read off the transcript: agent lines and questions compared letters only
|
|
230
|
+
(`letters: 'latin'` on the set: only `a`–`z` count as letters, an accented or Cyrillic letter is a space). The
|
|
231
|
+
latest agent line containing an offer's question names the offer (later questions before earlier ones, offers in order);
|
|
232
|
+
the last question's option comes from the caller lines after it, an earlier question's from those between the latest
|
|
233
|
+
agent line asking it and the next one; in each, the latest caller line naming exactly one option gives it. Ops: `offer`
|
|
234
|
+
(its id), `offerText`, `selected` (option names in question order), `complete` (every question answered), `lastAsked`
|
|
235
|
+
(the last agent line with words asks one), `interested` (the offer's text, then `chose` and the options joined by
|
|
236
|
+
`sep`), `headers` (the operator leg's headers: from the restatement `spoken.clause` in the line `of`, default the last
|
|
237
|
+
agent line, the offer found by its `identifyBy` part; else from the selection; values cut to `cap`, URI-encoded).
|
|
238
|
+
`transfer.headers`, report fields and the transfer text read them as expressions.
|
|
239
|
+
|
|
240
|
+
## Testing an agent's block data
|
|
241
|
+
|
|
242
|
+
`@voctiv/agent-runtime/testing` (test-only, unstable) exports `withBlocks` (the agent file as it runs), `knowledgeIndex`,
|
|
243
|
+
`KnowledgeService`, `QnaFlow`, `knowledgeActions`, `knowledgeResult`, `knowledgeTrace`, `knowledgeTraced`,
|
|
244
|
+
`KNOWLEDGE_HOOKS` / `KNOWLEDGE_STATE`, `createDecisionClient`, `catalogRequests` (the compiled list: `index`
|
|
245
|
+
`shortlistParents` / `shortlistChildren`, `build`, `buildStep`, `stepOf`), `createCatalogRecognizer`,
|
|
246
|
+
`reconcileCatalog`, `nextVerifyAction`, `createVerifyLookup`, `derivedDialogUuid`, `verifyRow`.
|