@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,305 @@
|
|
|
1
|
+
import type { LocaleCode } from '../../locale';
|
|
2
|
+
import type { Action, Matcher } from '../../spec';
|
|
3
|
+
import type { Condition, Expr } from '../../expr/types';
|
|
4
|
+
/**
|
|
5
|
+
* A sticky flag of the call, read as `{ flag: name }`:
|
|
6
|
+
* - `agentLine` / `callerLine` / `anyLine`: some line of that speaker matches (read off the transcript; `normalize:
|
|
7
|
+
* 'NFC'` tests the line in NFC form);
|
|
8
|
+
* - `heard`: a reply the caller heard to its end matches (`impliedBy`: also set when one of these flags is);
|
|
9
|
+
* - `cut`: a reply was not heard (cut, superseded, asked again) while `when` held (read before the reply's flags change).
|
|
10
|
+
* `log`: the name of the flag in the `tracking.log` event (heard / cut flags).
|
|
11
|
+
*/
|
|
12
|
+
export type TrackFlagSpec = {
|
|
13
|
+
readonly on: 'agentLine' | 'callerLine' | 'anyLine';
|
|
14
|
+
readonly match: Matcher;
|
|
15
|
+
readonly normalize?: 'NFC';
|
|
16
|
+
} | {
|
|
17
|
+
readonly on: 'heard';
|
|
18
|
+
readonly match?: Matcher;
|
|
19
|
+
readonly impliedBy?: readonly string[];
|
|
20
|
+
readonly log?: string;
|
|
21
|
+
} | {
|
|
22
|
+
readonly on: 'cut';
|
|
23
|
+
readonly when?: Condition;
|
|
24
|
+
readonly log?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* One move of `stages`: a line of `on`'s speaker that matches `match` (any line when absent) moves the stage to `to`
|
|
28
|
+
* when the current stage is in `from` (`{ not }`: not in it; absent: any). The first rule that applies moves; a stage
|
|
29
|
+
* never goes back (a move to an earlier or the same stage of `list` is no move).
|
|
30
|
+
*/
|
|
31
|
+
export interface StageRule {
|
|
32
|
+
readonly on: 'agentLine' | 'callerLine' | 'anyLine';
|
|
33
|
+
readonly match?: Matcher;
|
|
34
|
+
readonly from?: readonly string[] | {
|
|
35
|
+
readonly not: readonly string[];
|
|
36
|
+
};
|
|
37
|
+
readonly to: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Per-call state read off the conversation:
|
|
41
|
+
* - `flags`: sticky flags ({@link TrackFlagSpec});
|
|
42
|
+
* - `stages`: how far the call got (`list` in order, the first is the start; read as `{ stage: name | names }` in
|
|
43
|
+
* conditions and `{ fact: 'stage' }`); `source: 'platformTranscript'` reads the platform's `call_transcript` text
|
|
44
|
+
* (`USER:` / `AGENT:` lines; after the call), default the call's lines;
|
|
45
|
+
* - `questions`: the question each agent line leaves open (the first of `list` whose `asked` matches; a line matching
|
|
46
|
+
* `keepOn` keeps the one before; else `else`, default none). Read as `{ openQuestion: id | ids | null }` (the question
|
|
47
|
+
* open now), `{ asked: id | ids }` (agent lines that asked it, a number) and `{ answers: { question, match } }`
|
|
48
|
+
* (caller lines said while it was open, matching);
|
|
49
|
+
* - `log`: the event logged when heard / cut flags change (`{ <flag log name>: value }` of every flag of that kind).
|
|
50
|
+
*/
|
|
51
|
+
export interface TrackingSpec {
|
|
52
|
+
readonly flags?: Readonly<Record<string, TrackFlagSpec>>;
|
|
53
|
+
readonly stages?: {
|
|
54
|
+
readonly list: readonly string[];
|
|
55
|
+
readonly rules: readonly StageRule[];
|
|
56
|
+
readonly source?: 'transcript' | 'platformTranscript';
|
|
57
|
+
};
|
|
58
|
+
readonly questions?: {
|
|
59
|
+
readonly list: readonly {
|
|
60
|
+
readonly id: string;
|
|
61
|
+
readonly asked: Matcher;
|
|
62
|
+
}[];
|
|
63
|
+
readonly keepOn?: Matcher;
|
|
64
|
+
readonly else?: string;
|
|
65
|
+
};
|
|
66
|
+
readonly log?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Spoken day words resolved to days (`resolved`, evaluated with the locals `date` `YYYY-MM-DD`, `year`, `month`,
|
|
70
|
+
* `day`, `weekday` (0 = Sunday), `weekdayName`, `monthName`, `dayOrdinal` of the reply language's pack). Groups are
|
|
71
|
+
* read in order; each gives the first of its words the line names (whole words, spaces as any spaces, lower case, not
|
|
72
|
+
* followed by `notFollowedBy`), and that match is blanked for the groups after it. Items: `{ word, resolved, date }`.
|
|
73
|
+
* - `{ words, days }`: today plus `days`; `{ words, monthEnd: true }`: the last day of this month;
|
|
74
|
+
* - `{ nextToday }`: a template with `{weekday}` (today's weekday word, lower case): a week from today;
|
|
75
|
+
* - `{ weekdays }`: words by weekday (index 0 = Sunday), each group the next such day from today (today itself when it
|
|
76
|
+
* is), Monday first;
|
|
77
|
+
* - `{ ordinalDays }`: day numbers of this month from today and of the next month before it: the day in figures with its
|
|
78
|
+
* ordinal suffix, and from `wordsFrom` on also `lead` + the ordinal word (and with spaces for hyphens).
|
|
79
|
+
*/
|
|
80
|
+
export interface DayHintsSpec {
|
|
81
|
+
readonly groups: readonly DayHintGroup[];
|
|
82
|
+
readonly resolved: Expr;
|
|
83
|
+
readonly notFollowedBy?: RegExp;
|
|
84
|
+
/** The pack whose weekday, month and ordinal words the hints use (default the reply language's). */
|
|
85
|
+
readonly pack?: LocaleCode;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The days a text names, read by a pack's day parser (`LocaleParse.dates`): see `datesIn` (./notes-dates). Items
|
|
89
|
+
* `{ said, past, kind, date }`.
|
|
90
|
+
*/
|
|
91
|
+
export interface DatesDetector {
|
|
92
|
+
readonly of?: Expr;
|
|
93
|
+
readonly today?: Expr;
|
|
94
|
+
readonly pack?: LocaleCode;
|
|
95
|
+
readonly bareDay?: Expr;
|
|
96
|
+
readonly nextMonthUntil?: Expr;
|
|
97
|
+
readonly pastMonth?: 'past' | 'thisMonth';
|
|
98
|
+
readonly numeric?: 'dayFirst' | 'monthFirst' | 'none';
|
|
99
|
+
readonly relative?: boolean;
|
|
100
|
+
readonly todayWhen?: Matcher;
|
|
101
|
+
readonly only?: 'date' | 'past';
|
|
102
|
+
readonly first?: boolean;
|
|
103
|
+
}
|
|
104
|
+
export type DayHintGroup = {
|
|
105
|
+
readonly words: readonly string[];
|
|
106
|
+
readonly days: number;
|
|
107
|
+
} | {
|
|
108
|
+
readonly words: readonly string[];
|
|
109
|
+
readonly monthEnd: true;
|
|
110
|
+
} | {
|
|
111
|
+
readonly nextToday: string;
|
|
112
|
+
} | {
|
|
113
|
+
readonly weekdays: readonly (readonly string[])[];
|
|
114
|
+
} | {
|
|
115
|
+
readonly ordinalDays: {
|
|
116
|
+
readonly wordsFrom?: number;
|
|
117
|
+
readonly lead?: string;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* What a note looks for in the caller's words; each item found is noted (the note is evaluated with the item's fields
|
|
122
|
+
* as locals). None found: no note.
|
|
123
|
+
* - `dayHints`: {@link DayHintsSpec};
|
|
124
|
+
* - `ladder`: the next note of a note ladder (`ladders.<name>.notes`; item `{ note, count, stage }`);
|
|
125
|
+
* - `choice`: the option of a choice set the words pick (`choices.<set>`; `chosen`: exactly one option named; `yesToNamed`:
|
|
126
|
+
* a yes to an agent line naming exactly one option); item `{ key, said, name, spoken, value }`;
|
|
127
|
+
* - `dates`: the days a text names ({@link DatesDetector}).
|
|
128
|
+
*/
|
|
129
|
+
export type NoteDetector = {
|
|
130
|
+
readonly dayHints: DayHintsSpec;
|
|
131
|
+
} | {
|
|
132
|
+
readonly ladder: string;
|
|
133
|
+
} | {
|
|
134
|
+
readonly choice: {
|
|
135
|
+
readonly set: string;
|
|
136
|
+
readonly mode: 'chosen' | 'yesToNamed';
|
|
137
|
+
readonly yes?: Matcher;
|
|
138
|
+
};
|
|
139
|
+
} | {
|
|
140
|
+
readonly dates: DatesDetector;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* A note on the caller's line for the LLM (not in the transcript). Notes are made in order, each seeing the notes made
|
|
144
|
+
* before it. `when` is read with `line` = the caller's words and the locals `notes` (the notes in front so far, with
|
|
145
|
+
* the space after them), `noted` (the whole text so far) and `words`. `unlessNotes`: no note when one of these notes is
|
|
146
|
+
* on the line. `note` is evaluated per item of `detect` (with its fields as locals), once without one; an empty text is
|
|
147
|
+
* no note. `place`: `front` (in front of everything, items in order), `beforeWords` (after the notes in front, right
|
|
148
|
+
* before the words), `append` (right after the text, as it is: give the note its own leading space). `dedupe`: the
|
|
149
|
+
* same text once.
|
|
150
|
+
*/
|
|
151
|
+
export interface NoteRule {
|
|
152
|
+
readonly id: string;
|
|
153
|
+
readonly when?: Condition;
|
|
154
|
+
readonly unlessNotes?: readonly string[];
|
|
155
|
+
readonly detect?: NoteDetector;
|
|
156
|
+
readonly note: Expr;
|
|
157
|
+
readonly place: 'front' | 'beforeWords' | 'append';
|
|
158
|
+
readonly dedupe?: boolean;
|
|
159
|
+
}
|
|
160
|
+
/** A note, or a group of notes of which the first that notes anything is the group's. */
|
|
161
|
+
export type NoteEntry = NoteRule | {
|
|
162
|
+
readonly oneOf: readonly NoteRule[];
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* A rung of a line ladder: the line (`null` / empty: none), said when `when` holds; it counts as said once an agent line
|
|
166
|
+
* contains `spokenAs` (default the line); `unlessSaid`: not said once the line of one of these rungs (indexes; its own
|
|
167
|
+
* text, not its `spokenAs`) was.
|
|
168
|
+
*/
|
|
169
|
+
export interface LadderRung {
|
|
170
|
+
readonly text: Expr;
|
|
171
|
+
readonly when?: Condition;
|
|
172
|
+
readonly spokenAs?: Expr;
|
|
173
|
+
readonly unlessSaid?: readonly number[];
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Lines said by the `{ ladder: name }` action, each once per call: the first rung not said yet (`spokenBy`: how an agent
|
|
177
|
+
* line contains a rung, `includesCI` ignores case). `fill`: `slot` in a rung replaced by `with`. A rung that is a
|
|
178
|
+
* goodbye (`closing.goodbye`) closes with `goodbyeCloses`. All said: `then` (`'llm'`: the ladder says nothing and the
|
|
179
|
+
* LLM answers). `alias`: the lines' mixer alias (default the rule's id).
|
|
180
|
+
*/
|
|
181
|
+
export interface LineLadderSpec {
|
|
182
|
+
readonly lines: readonly (Expr | LadderRung)[];
|
|
183
|
+
readonly spokenBy?: 'includes' | 'includesCI';
|
|
184
|
+
readonly fill?: {
|
|
185
|
+
readonly slot: string;
|
|
186
|
+
readonly with: Expr;
|
|
187
|
+
};
|
|
188
|
+
readonly goodbyeCloses?: {
|
|
189
|
+
readonly result: string;
|
|
190
|
+
readonly reason?: string;
|
|
191
|
+
};
|
|
192
|
+
readonly then: 'llm' | Action | readonly Action[];
|
|
193
|
+
readonly alias?: string;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Notes by stage for a short answer that is not clear (a note ladder, read by the note detector `{ ladder }`). The stage
|
|
197
|
+
* is the first of `stages` whose `question` matches the last question of the reply the caller last heard (`start`
|
|
198
|
+
* before one; `stageBy: 'lastQuestionOfHeardReply'`). Each such line counts at its stage: the n-th gets `notes[n-1]`
|
|
199
|
+
* (the last from `notes.length` on), evaluated with the locals `count`, `stage`, `next`, `probe` (`probes[count-1]` of the
|
|
200
|
+
* stage, `null` without). With `repeatUntilHeard`, the note stays the line's until the caller hears a reply: a line said
|
|
201
|
+
* before that gets it again, not counted.
|
|
202
|
+
*/
|
|
203
|
+
export interface NoteLadderSpec {
|
|
204
|
+
readonly notes: readonly Expr[];
|
|
205
|
+
readonly stages: readonly {
|
|
206
|
+
readonly name: string;
|
|
207
|
+
readonly question: Matcher;
|
|
208
|
+
readonly probes?: readonly string[];
|
|
209
|
+
readonly next: string;
|
|
210
|
+
}[];
|
|
211
|
+
readonly start: string;
|
|
212
|
+
readonly stageBy: 'lastQuestionOfHeardReply';
|
|
213
|
+
readonly repeatUntilHeard?: boolean;
|
|
214
|
+
/** Logged with `{ stage }` when the stage changes. */
|
|
215
|
+
readonly log?: string;
|
|
216
|
+
}
|
|
217
|
+
export type LadderSpec = LineLadderSpec | NoteLadderSpec;
|
|
218
|
+
/** An option of a choice set: the words that name it (whole words of the lower-cased line), its value and texts. */
|
|
219
|
+
export interface ChoiceSetOption {
|
|
220
|
+
readonly words: Matcher | readonly string[];
|
|
221
|
+
readonly value?: Expr;
|
|
222
|
+
readonly spoken?: Expr;
|
|
223
|
+
readonly name?: string;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* A product the caller may pick and the questions about it (offers). Agent lines and choice questions are compared
|
|
227
|
+
* letters only (lower case, every run of non-letters one space). The latest agent line containing a question names the
|
|
228
|
+
* offer (later questions of the offers are looked for before earlier ones, offers in order). The options of the last
|
|
229
|
+
* question asked are read from the caller lines after it; of an earlier question, from the caller lines between the
|
|
230
|
+
* latest agent line before that asks it (of any offer) and the next one: the latest caller line naming exactly one
|
|
231
|
+
* option gives it.
|
|
232
|
+
*/
|
|
233
|
+
export interface ChoiceOffer {
|
|
234
|
+
readonly id: string;
|
|
235
|
+
/** The offer's text (the deal as the agent says it). */
|
|
236
|
+
readonly text: Expr;
|
|
237
|
+
readonly questions: readonly {
|
|
238
|
+
readonly ask: Expr;
|
|
239
|
+
readonly options: readonly {
|
|
240
|
+
readonly name: string;
|
|
241
|
+
readonly match: Matcher;
|
|
242
|
+
}[];
|
|
243
|
+
}[];
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Operator-leg headers of the offer a caller chose (`{ choice, op: 'headers', of? }`, a record): from the line `of` (default
|
|
247
|
+
* the call's last agent line) when `spoken.clause` finds the restated choice in it (its group 1, `text` header; the
|
|
248
|
+
* offer is the one whose text's `spoken.identifyBy` group 1 the line contains, else no `id` header); else from the
|
|
249
|
+
* transcript's selection (`id` header `idFormat` with `{n}` the 1-based offer and `{id}` its id; `text` header the chosen
|
|
250
|
+
* options joined by `sep`, `between`, the offer's text — or the text alone). Values cut to `cap` characters, then
|
|
251
|
+
* URI-encoded with `encode: 'uri'`. No offer: no headers.
|
|
252
|
+
*/
|
|
253
|
+
export interface ChoiceHeadersSpec {
|
|
254
|
+
readonly id: string;
|
|
255
|
+
readonly text: string;
|
|
256
|
+
readonly idFormat: string;
|
|
257
|
+
readonly cap?: number;
|
|
258
|
+
readonly encode?: 'uri';
|
|
259
|
+
readonly sep: string;
|
|
260
|
+
readonly between: string;
|
|
261
|
+
readonly spoken?: {
|
|
262
|
+
readonly clause: RegExp;
|
|
263
|
+
readonly identifyBy: RegExp;
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* A named set of options read off the words of a line or the transcript:
|
|
268
|
+
* - `options`: options by key; a line picks the options it names (`numbers`: a number the line says picks the option
|
|
269
|
+
* whose value is nearest: the same whole value, else within `closeRatio`, else its digits inside the number);
|
|
270
|
+
* - `offers`: products with their questions ({@link ChoiceOffer}); ops `offer` (id), `offerText`, `selected` (option
|
|
271
|
+
* names in question order), `complete` (every question of the offer answered), `lastAsked` (the last agent line with
|
|
272
|
+
* words — not only dots or ellipses — asks one of the questions), `interested` (`interested`: the offer's text, then
|
|
273
|
+
* `chose` and the options joined by `sep` when any), `headers` ({@link ChoiceHeadersSpec});
|
|
274
|
+
* - `enabledWhen`: the set reads nothing when this does not hold.
|
|
275
|
+
*/
|
|
276
|
+
export interface ChoiceSetSpec {
|
|
277
|
+
readonly options?: Readonly<Record<string, ChoiceSetOption>>;
|
|
278
|
+
readonly numbers?: {
|
|
279
|
+
readonly nearest: {
|
|
280
|
+
readonly closeRatio: number;
|
|
281
|
+
readonly digitsInside?: {
|
|
282
|
+
readonly minValue: number;
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
readonly offers?: readonly ChoiceOffer[];
|
|
287
|
+
readonly interested?: {
|
|
288
|
+
readonly chose: string;
|
|
289
|
+
readonly sep: string;
|
|
290
|
+
};
|
|
291
|
+
readonly headers?: ChoiceHeadersSpec;
|
|
292
|
+
readonly enabledWhen?: Condition;
|
|
293
|
+
/**
|
|
294
|
+
* How lines and choice questions are compared: lower case, every run of non-letters one space — `any` (default):
|
|
295
|
+
* any Unicode letter is a letter; `latin`: only `a`–`z` (accented and other scripts' letters become spaces).
|
|
296
|
+
*/
|
|
297
|
+
readonly letters?: 'any' | 'latin';
|
|
298
|
+
}
|
|
299
|
+
export type ChoicesSpec = Readonly<Record<string, ChoiceSetSpec>>;
|
|
300
|
+
/** The blocks of this file an expression may read (`ExprContext.blocks`). */
|
|
301
|
+
export interface StateBlocks {
|
|
302
|
+
readonly tracking?: TrackingSpec;
|
|
303
|
+
readonly ladders?: Readonly<Record<string, LadderSpec>>;
|
|
304
|
+
readonly choices?: ChoicesSpec;
|
|
305
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Action, EngineSpec, CallView } from '../../spec';
|
|
2
|
+
import { type ExprEnv } from '../../expr/context';
|
|
3
|
+
import type { ExprContext } from '../../expr/types';
|
|
4
|
+
import type { EngineState } from '../dialog';
|
|
5
|
+
import type { Turn } from './context';
|
|
6
|
+
import type { RunContext } from './events';
|
|
7
|
+
import type { NoteEntry, StateBlocks } from './state-spec';
|
|
8
|
+
import { type PlayedTracking } from './tracking';
|
|
9
|
+
/** The state blocks as the reducer runs them. */
|
|
10
|
+
export interface StateRuntime {
|
|
11
|
+
readonly env: ExprEnv;
|
|
12
|
+
readonly notes: readonly NoteEntry[] | null;
|
|
13
|
+
readonly played: PlayedTracking | null;
|
|
14
|
+
readonly noteLadders: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** The state blocks of the agent file an expression reads (`ExprEnv.blocks`); `undefined` without any. */
|
|
17
|
+
export declare function stateBlocksOf(spec: Pick<EngineSpec, 'tracking' | 'ladders' | 'choices'>): StateBlocks | undefined;
|
|
18
|
+
/** The notes of `turn.filters` `annotateCaller` (data form), if any. */
|
|
19
|
+
export declare function notesOf(spec: EngineSpec): readonly NoteEntry[] | null;
|
|
20
|
+
/** The runtime of the state blocks (`null`: the file has none). */
|
|
21
|
+
export declare function stateRuntime(spec: EngineSpec): StateRuntime | null;
|
|
22
|
+
/** Whether the media must report what the caller heard of each reply. */
|
|
23
|
+
export declare const tracksPlayed: (rt: StateRuntime | null) => boolean;
|
|
24
|
+
export declare function ctxOf(rt: StateRuntime, call: CallView, extra?: Partial<ExprContext>): ExprContext;
|
|
25
|
+
/** A reply played to its end as the current turn (`heard`), or cut / superseded. */
|
|
26
|
+
export declare function replyPlayedEvent(cx: Turn, text: string, heard: boolean): void;
|
|
27
|
+
/** The caller's words with the notes (the note ladders move on). */
|
|
28
|
+
export declare function noteLine(cx: Turn, words: string): string;
|
|
29
|
+
/** The notes of a line asked again (a reply cut before it streamed): read only, the ladders keep their state. */
|
|
30
|
+
export declare function noteAgain(rt: StateRuntime, call: CallView, state: Pick<EngineState, 'noteLadders'> | null, words: string): string;
|
|
31
|
+
/** `{ ladder: name }`: the ladder's next line (or its terminal actions) as the actions to run. */
|
|
32
|
+
export declare function ladderStep(cx: Turn, name: string, ctx: RunContext): readonly Action[];
|
|
33
|
+
/** `{ count: name }`: one more on the counter (read as `{ counter: name }`). */
|
|
34
|
+
export declare function countUp(cx: Turn, a: {
|
|
35
|
+
readonly count: string;
|
|
36
|
+
readonly by?: number;
|
|
37
|
+
readonly log?: string;
|
|
38
|
+
}, ctx: RunContext): void;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.countUp = exports.ladderStep = exports.noteAgain = exports.noteLine = exports.replyPlayedEvent = exports.ctxOf = exports.tracksPlayed = exports.stateRuntime = exports.notesOf = exports.stateBlocksOf = void 0;
|
|
4
|
+
const context_1 = require("../../expr/context");
|
|
5
|
+
const ladders_1 = require("./ladders");
|
|
6
|
+
const notes_1 = require("./notes");
|
|
7
|
+
const tracking_1 = require("./tracking");
|
|
8
|
+
/** The state blocks of the agent file an expression reads (`ExprEnv.blocks`); `undefined` without any. */
|
|
9
|
+
function stateBlocksOf(spec) {
|
|
10
|
+
if (!spec.tracking && !spec.ladders && !spec.choices)
|
|
11
|
+
return undefined;
|
|
12
|
+
return {
|
|
13
|
+
...(spec.tracking ? { tracking: spec.tracking } : {}),
|
|
14
|
+
...(spec.ladders ? { ladders: spec.ladders } : {}),
|
|
15
|
+
...(spec.choices ? { choices: spec.choices } : {}),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.stateBlocksOf = stateBlocksOf;
|
|
19
|
+
/** The notes of `turn.filters` `annotateCaller` (data form), if any. */
|
|
20
|
+
function notesOf(spec) {
|
|
21
|
+
const f = (spec.turn?.filters ?? []).find((x) => x.filter === 'annotateCaller');
|
|
22
|
+
return f && 'notes' in f && f.notes ? f.notes : null;
|
|
23
|
+
}
|
|
24
|
+
exports.notesOf = notesOf;
|
|
25
|
+
/** The runtime of the state blocks (`null`: the file has none). */
|
|
26
|
+
function stateRuntime(spec) {
|
|
27
|
+
const blocks = stateBlocksOf(spec);
|
|
28
|
+
const notes = notesOf(spec);
|
|
29
|
+
if (!blocks && !notes)
|
|
30
|
+
return null;
|
|
31
|
+
return {
|
|
32
|
+
env: {
|
|
33
|
+
timeZone: spec.input.timeZone,
|
|
34
|
+
languages: spec.languages,
|
|
35
|
+
...(spec.matchers ? { matchers: spec.matchers } : {}),
|
|
36
|
+
...(spec.facts ? { facts: spec.facts } : {}),
|
|
37
|
+
...(blocks ? { blocks } : {}),
|
|
38
|
+
},
|
|
39
|
+
notes,
|
|
40
|
+
played: (0, tracking_1.playedTracking)(spec.tracking),
|
|
41
|
+
noteLadders: (0, ladders_1.hasNoteLadders)(spec.ladders),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
exports.stateRuntime = stateRuntime;
|
|
45
|
+
/** Whether the media must report what the caller heard of each reply. */
|
|
46
|
+
const tracksPlayed = (rt) => rt != null && (rt.played != null || rt.noteLadders);
|
|
47
|
+
exports.tracksPlayed = tracksPlayed;
|
|
48
|
+
function ctxOf(rt, call, extra = {}) {
|
|
49
|
+
return (0, context_1.callContext)(rt.env, call, extra);
|
|
50
|
+
}
|
|
51
|
+
exports.ctxOf = ctxOf;
|
|
52
|
+
/** A reply played to its end as the current turn (`heard`), or cut / superseded. */
|
|
53
|
+
function replyPlayedEvent(cx, text, heard) {
|
|
54
|
+
const rt = cx.v.state;
|
|
55
|
+
if (!rt)
|
|
56
|
+
return;
|
|
57
|
+
if (rt.played)
|
|
58
|
+
(0, tracking_1.replyPlayed)(cx, rt.played, text, heard, (call) => ctxOf(rt, call));
|
|
59
|
+
if (heard && rt.noteLadders) {
|
|
60
|
+
const r = (0, ladders_1.laddersHeard)(ctxOf(rt, cx.core.view(cx.d)), cx.d.noteLadders, text);
|
|
61
|
+
cx.d.noteLadders = r.states;
|
|
62
|
+
for (const l of r.logs)
|
|
63
|
+
cx.log(l.event, l.data);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.replyPlayedEvent = replyPlayedEvent;
|
|
67
|
+
/** The caller's words with the notes (the note ladders move on). */
|
|
68
|
+
function noteLine(cx, words) {
|
|
69
|
+
const rt = cx.v.state;
|
|
70
|
+
if (!rt?.notes)
|
|
71
|
+
return words;
|
|
72
|
+
const r = (0, notes_1.annotate)(rt.notes, words, ctxOf(rt, cx.core.view(cx.d), { line: words }), cx.d.noteLadders ?? {});
|
|
73
|
+
if (rt.noteLadders)
|
|
74
|
+
cx.d.noteLadders = r.ladders;
|
|
75
|
+
return r.text;
|
|
76
|
+
}
|
|
77
|
+
exports.noteLine = noteLine;
|
|
78
|
+
/** The notes of a line asked again (a reply cut before it streamed): read only, the ladders keep their state. */
|
|
79
|
+
function noteAgain(rt, call, state, words) {
|
|
80
|
+
if (!rt.notes)
|
|
81
|
+
return words;
|
|
82
|
+
return (0, notes_1.annotate)(rt.notes, words, ctxOf(rt, call, { line: words }), (state?.noteLadders ?? {})).text;
|
|
83
|
+
}
|
|
84
|
+
exports.noteAgain = noteAgain;
|
|
85
|
+
/** `{ ladder: name }`: the ladder's next line (or its terminal actions) as the actions to run. */
|
|
86
|
+
function ladderStep(cx, name, ctx) {
|
|
87
|
+
const rt = cx.v.state;
|
|
88
|
+
if (!rt)
|
|
89
|
+
throw new Error(`[templates/engine] ladder "${name}": the agent file has no ladders`);
|
|
90
|
+
const view = cx.core.view(cx.d);
|
|
91
|
+
return (0, ladders_1.ladderActions)(ctxOf(rt, view, ctx.line != null ? { line: ctx.line } : {}), name, ctx.id, (t) => cx.cfg.goodbye(t, view));
|
|
92
|
+
}
|
|
93
|
+
exports.ladderStep = ladderStep;
|
|
94
|
+
/** `{ count: name }`: one more on the counter (read as `{ counter: name }`). */
|
|
95
|
+
function countUp(cx, a, ctx) {
|
|
96
|
+
const n = (cx.d.counters[a.count] ?? 0) + (a.by ?? 1);
|
|
97
|
+
cx.d.counters = { ...cx.d.counters, [a.count]: n };
|
|
98
|
+
if (a.log)
|
|
99
|
+
cx.log(a.log, { userText: ctx.line ?? '', [a.count]: n });
|
|
100
|
+
}
|
|
101
|
+
exports.countUp = countUp;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { CallView, Matcher } from '../../spec';
|
|
2
|
+
import type { ExprContext } from '../../expr/types';
|
|
3
|
+
import type { TrackFlagSpec, TrackingSpec } from './state-spec';
|
|
4
|
+
import type { Turn } from './context';
|
|
5
|
+
interface Line {
|
|
6
|
+
readonly who: 'agent' | 'caller';
|
|
7
|
+
readonly text: string;
|
|
8
|
+
}
|
|
9
|
+
/** What the transcript tells of the call: line flags, the stage, the open question, asks, caller lines by question. */
|
|
10
|
+
export interface Track {
|
|
11
|
+
readonly flags: Readonly<Record<string, boolean>>;
|
|
12
|
+
readonly stage: string | null;
|
|
13
|
+
readonly openQuestion: string | null;
|
|
14
|
+
readonly asked: Readonly<Record<string, number>>;
|
|
15
|
+
/** Caller lines with the question open when each was said. */
|
|
16
|
+
readonly answers: readonly {
|
|
17
|
+
readonly text: string;
|
|
18
|
+
readonly open: string | null;
|
|
19
|
+
}[];
|
|
20
|
+
}
|
|
21
|
+
/** The platform's transcript text (`USER:` / `AGENT:` lines; a line without a prefix continues the one before). */
|
|
22
|
+
export declare function platformLines(text: string | null | undefined): Line[];
|
|
23
|
+
/** The stage the lines reach (`null` without `stages`). */
|
|
24
|
+
export declare function stageOf(spec: TrackingSpec, lines: readonly Line[], ctx: ExprContext): string | null;
|
|
25
|
+
/** The track of a transcript (cached per lines array and spec). */
|
|
26
|
+
export declare function trackOfLines(spec: TrackingSpec, lines: readonly Line[], ctx: ExprContext): Track;
|
|
27
|
+
/** The track of the call an expression reads (`stages.source` decides the stage's lines). */
|
|
28
|
+
export declare function trackOf(ctx: ExprContext): Track | null;
|
|
29
|
+
/** A line flag's value (`undefined`: not a line flag of `tracking`). */
|
|
30
|
+
export declare function lineFlag(ctx: ExprContext, name: string): boolean | undefined;
|
|
31
|
+
/** `{ stage: name | names }`. */
|
|
32
|
+
export declare function stageIs(ctx: ExprContext, want: unknown): boolean;
|
|
33
|
+
/** `{ openQuestion: id | ids | null }`. */
|
|
34
|
+
export declare function openQuestionIs(ctx: ExprContext, want: unknown): boolean;
|
|
35
|
+
/** `{ asked: id | ids }`: agent lines that asked it. */
|
|
36
|
+
export declare function askedCount(ctx: ExprContext, want: unknown): number;
|
|
37
|
+
/** `{ answers: { question, match } }`: caller lines said while the question was open, matching. */
|
|
38
|
+
export declare function answersCount(ctx: ExprContext, want: {
|
|
39
|
+
readonly question: string | readonly string[];
|
|
40
|
+
readonly match?: Matcher;
|
|
41
|
+
}): number;
|
|
42
|
+
/** The compiled heard / cut flags of `tracking` (built once per dialog). */
|
|
43
|
+
export interface PlayedTracking {
|
|
44
|
+
readonly spec: TrackingSpec;
|
|
45
|
+
readonly flags: readonly (readonly [string, TrackFlagSpec])[];
|
|
46
|
+
}
|
|
47
|
+
export declare function playedTracking(spec: TrackingSpec | undefined): PlayedTracking | null;
|
|
48
|
+
/** A reply the caller heard to its end (`heard`) or not: the heard / cut flags it sets, and their log. */
|
|
49
|
+
export declare function replyPlayed(cx: Turn, p: PlayedTracking, text: string, heard: boolean, ctxOf: (call: CallView) => ExprContext): void;
|
|
50
|
+
export {};
|