@voctiv/agent-runtime 0.2.2 → 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 +0 -1
- package/dist/barge-in/speech-ledger.d.ts +0 -2
- package/dist/barge-in/speech-ledger.js +3 -4
- package/dist/barge-in/word-classifier.d.ts +0 -1
- package/dist/barge-in/word-classifier.js +0 -1
- package/dist/call/asr-usage.d.ts +53 -0
- package/dist/call/asr-usage.js +42 -0
- package/dist/call/async.d.ts +2 -0
- package/dist/call/async.js +14 -0
- package/dist/call/env.d.ts +88 -0
- package/dist/call/env.js +294 -0
- package/dist/call/extraction/core.d.ts +99 -0
- package/dist/call/extraction/core.js +259 -0
- package/dist/call/extraction/defaults.d.ts +10 -0
- package/dist/call/extraction/defaults.js +25 -0
- package/dist/call/extraction/index.d.ts +7 -0
- package/dist/call/extraction/index.js +24 -0
- package/dist/call/extraction/orchestrator.d.ts +144 -0
- package/dist/call/extraction/orchestrator.js +309 -0
- package/dist/call/failed-leg.d.ts +43 -0
- package/dist/call/failed-leg.js +77 -0
- package/dist/call/http.d.ts +94 -0
- package/dist/call/http.js +145 -0
- package/dist/call/ledger.d.ts +18 -0
- package/dist/call/ledger.js +80 -0
- package/dist/call/llm-tap.d.ts +7 -0
- package/dist/call/llm-tap.js +41 -0
- package/dist/call/logging.d.ts +16 -0
- package/dist/call/logging.js +92 -0
- package/dist/call/outbound.d.ts +144 -0
- package/dist/call/outbound.js +404 -0
- package/dist/call/output.d.ts +108 -0
- package/dist/call/output.js +77 -0
- package/dist/call/plan.d.ts +119 -0
- package/dist/call/plan.js +2 -0
- package/dist/call/recall.d.ts +115 -0
- package/dist/call/recall.js +312 -0
- package/dist/call/records.d.ts +9 -0
- package/dist/call/records.js +71 -0
- package/dist/call/report.d.ts +65 -0
- package/dist/call/report.js +263 -0
- package/dist/call/sanitize.d.ts +16 -0
- package/dist/call/sanitize.js +72 -0
- package/dist/call/sip.d.ts +111 -0
- package/dist/call/sip.js +212 -0
- package/dist/call/voicemail.d.ts +159 -0
- package/dist/call/voicemail.js +246 -0
- package/dist/core/call-disposables.d.ts +2 -2
- package/dist/core/call-disposables.js +8 -3
- package/dist/core/call-ended-budget.d.ts +11 -0
- package/dist/core/call-ended-budget.js +31 -0
- package/dist/core/container.d.ts +1 -3
- package/dist/core/container.js +9 -49
- package/dist/core/create-agent-script.d.ts +6 -1
- package/dist/core/create-agent-script.js +161 -28
- package/dist/core/decorators.d.ts +0 -1
- package/dist/core/decorators.js +0 -1
- package/dist/core/define-module.d.ts +0 -1
- package/dist/core/define-module.js +0 -1
- package/dist/core/dump-policy.d.ts +0 -1
- package/dist/core/dump-policy.js +0 -1
- package/dist/core/hooks.d.ts +15 -4
- package/dist/core/hooks.js +0 -1
- package/dist/core/media-bootstrap.d.ts +19 -4
- package/dist/core/media-bootstrap.js +53 -13
- package/dist/core/open-timeout.d.ts +12 -0
- package/dist/core/open-timeout.js +48 -0
- package/dist/core/provide-media.d.ts +0 -8
- package/dist/core/provide-media.js +1 -22
- package/dist/core/runtime-events.d.ts +28 -0
- package/dist/{llm/llm-module.js → core/runtime-events.js} +19 -16
- package/dist/core/tokens.d.ts +0 -10
- package/dist/core/tokens.js +0 -1
- package/dist/core/types.d.ts +0 -1
- package/dist/core/types.js +0 -1
- package/dist/core/version.d.ts +2 -3
- package/dist/core/version.js +2 -3
- package/dist/dialog/dialog-definition.d.ts +0 -5
- package/dist/dialog/dialog-definition.js +1 -6
- package/dist/dialog/dialog-ports.d.ts +3 -1
- package/dist/dialog/dialog-ports.js +10 -2
- package/dist/dialog/online-call-host.d.ts +26 -4
- package/dist/dialog/online-call-host.js +94 -12
- package/dist/dialog/online-call-module.d.ts +5 -11
- package/dist/dialog/online-call-module.js +4 -36
- package/dist/dialog/turn-metrics.d.ts +46 -0
- package/dist/dialog/turn-metrics.js +141 -0
- package/dist/dialog-events/active-media.d.ts +50 -2
- package/dist/dialog-events/active-media.js +146 -34
- package/dist/dialog-events/event-source.d.ts +0 -1
- package/dist/dialog-events/event-source.js +0 -1
- package/dist/dialog-events/virtual-finals-module.d.ts +0 -1
- package/dist/dialog-events/virtual-finals-module.js +0 -1
- package/dist/dialog-events/virtual-finals.d.ts +2 -1
- package/dist/dialog-events/virtual-finals.js +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.js +8 -26
- package/dist/lifecycle/lifecycle.d.ts +25 -3
- package/dist/lifecycle/lifecycle.js +92 -14
- package/dist/result/result-store.d.ts +0 -1
- package/dist/result/result-store.js +0 -1
- package/dist/templates/authoring.d.ts +222 -0
- package/dist/templates/authoring.js +2 -0
- package/dist/templates/builder/agent.d.ts +34 -0
- package/dist/templates/builder/agent.js +87 -0
- package/dist/templates/builder/blocks.d.ts +54 -0
- package/dist/templates/builder/blocks.js +92 -0
- package/dist/templates/builder/data-check.d.ts +2 -0
- package/dist/templates/builder/data-check.js +61 -0
- package/dist/templates/builder/draft.d.ts +73 -0
- package/dist/templates/builder/draft.js +142 -0
- package/dist/templates/builder/index.d.ts +8 -0
- package/dist/templates/builder/index.js +55 -0
- package/dist/templates/builder/presets.d.ts +34 -0
- package/dist/templates/builder/presets.js +45 -0
- package/dist/templates/builder/spec-of.d.ts +13 -0
- package/dist/templates/builder/spec-of.js +18 -0
- package/dist/templates/builder/steps.d.ts +25 -0
- package/dist/templates/builder/steps.js +27 -0
- package/dist/templates/business/adapter.d.ts +12 -0
- package/dist/templates/business/adapter.js +980 -0
- package/dist/templates/business/agent-integrations.d.ts +24 -0
- package/dist/templates/business/agent-integrations.js +233 -0
- package/dist/templates/business/extraction-rules-transcript.d.ts +158 -0
- package/dist/templates/business/extraction-rules-transcript.js +405 -0
- package/dist/templates/business/extraction-rules.d.ts +107 -0
- package/dist/templates/business/extraction-rules.js +267 -0
- package/dist/templates/business/index.d.ts +6 -0
- package/dist/{result → templates/business}/index.js +8 -2
- package/dist/templates/business/input.d.ts +56 -0
- package/dist/templates/business/input.js +299 -0
- package/dist/templates/business/integration-data.d.ts +87 -0
- package/dist/templates/business/integration-data.js +312 -0
- package/dist/templates/business/integrations.d.ts +76 -0
- package/dist/templates/business/integrations.js +535 -0
- package/dist/templates/business/legs-policy.d.ts +43 -0
- package/dist/templates/business/legs-policy.js +268 -0
- package/dist/templates/business/report-label.d.ts +7 -0
- package/dist/templates/business/report-label.js +29 -0
- package/dist/templates/business/report.d.ts +67 -0
- package/dist/templates/business/report.js +284 -0
- package/dist/templates/business/result-catalog.d.ts +142 -0
- package/dist/templates/business/result-catalog.js +208 -0
- package/dist/templates/business/result-rules.d.ts +105 -0
- package/dist/templates/business/result-rules.js +167 -0
- package/dist/templates/business/results.d.ts +73 -0
- package/dist/templates/business/results.js +183 -0
- package/dist/templates/business/rule-env.d.ts +18 -0
- package/dist/templates/business/rule-env.js +38 -0
- package/dist/templates/business/sources.d.ts +76 -0
- package/dist/templates/business/sources.js +239 -0
- package/dist/templates/business/test-presets.d.ts +10 -0
- package/dist/templates/business/test-presets.js +68 -0
- package/dist/templates/catalog-match/block.d.ts +32 -0
- package/dist/templates/catalog-match/block.js +95 -0
- package/dist/templates/catalog-match/catalog.d.ts +77 -0
- package/dist/templates/catalog-match/catalog.js +222 -0
- package/dist/templates/catalog-match/recognizer.d.ts +44 -0
- package/dist/templates/catalog-match/recognizer.js +206 -0
- package/dist/templates/catalog-match/reconcile.d.ts +4 -0
- package/dist/templates/catalog-match/reconcile.js +39 -0
- package/dist/templates/catalog-match/request.d.ts +57 -0
- package/dist/templates/catalog-match/request.js +139 -0
- package/dist/templates/catalog-match/types.d.ts +197 -0
- package/dist/templates/catalog-match/types.js +2 -0
- package/dist/templates/catalog-match/verify.d.ts +76 -0
- package/dist/templates/catalog-match/verify.js +220 -0
- package/dist/templates/decision-model/index.d.ts +52 -0
- package/dist/templates/decision-model/index.js +68 -0
- package/dist/templates/engine/asr-picks.d.ts +11 -0
- package/dist/templates/engine/asr-picks.js +44 -0
- package/dist/templates/engine/call.d.ts +104 -0
- package/dist/templates/engine/call.js +322 -0
- package/dist/templates/engine/config.d.ts +447 -0
- package/dist/templates/engine/config.js +493 -0
- package/dist/templates/engine/define.d.ts +1 -0
- package/dist/templates/engine/define.js +9 -0
- package/dist/templates/engine/dialog.d.ts +253 -0
- package/dist/templates/engine/dialog.js +167 -0
- package/dist/templates/engine/echo-numbers.d.ts +7 -0
- package/dist/templates/engine/echo-numbers.js +19 -0
- package/dist/templates/engine/expand.d.ts +6 -0
- package/dist/templates/engine/expand.js +125 -0
- package/dist/templates/engine/filters.d.ts +81 -0
- package/dist/templates/engine/filters.js +654 -0
- package/dist/templates/engine/hook-state.d.ts +18 -0
- package/dist/templates/engine/hook-state.js +100 -0
- package/dist/templates/engine/hooks.d.ts +51 -0
- package/dist/templates/engine/hooks.js +310 -0
- package/dist/templates/engine/index.d.ts +13 -0
- package/dist/templates/engine/index.js +30 -0
- package/dist/templates/engine/language-vars.d.ts +6 -0
- package/dist/templates/engine/language-vars.js +40 -0
- package/dist/templates/engine/language.d.ts +32 -0
- package/dist/templates/engine/language.js +155 -0
- package/dist/templates/engine/lookup.d.ts +20 -0
- package/dist/templates/engine/lookup.js +52 -0
- package/dist/templates/engine/match.d.ts +48 -0
- package/dist/templates/engine/match.js +253 -0
- package/dist/templates/engine/media.d.ts +428 -0
- package/dist/templates/engine/media.js +1240 -0
- package/dist/templates/engine/script.d.ts +11 -0
- package/dist/templates/engine/script.js +69 -0
- package/dist/templates/engine/turns/actions.d.ts +5 -0
- package/dist/templates/engine/turns/actions.js +128 -0
- package/dist/templates/engine/turns/carry.d.ts +15 -0
- package/dist/templates/engine/turns/carry.js +74 -0
- package/dist/templates/engine/turns/choices-offers.d.ts +21 -0
- package/dist/templates/engine/turns/choices-offers.js +143 -0
- package/dist/templates/engine/turns/choices.d.ts +22 -0
- package/dist/templates/engine/turns/choices.js +141 -0
- package/dist/templates/engine/turns/closing-guard.d.ts +73 -0
- package/dist/templates/engine/turns/closing-guard.js +162 -0
- package/dist/templates/engine/turns/closing.d.ts +10 -0
- package/dist/templates/engine/turns/closing.js +82 -0
- package/dist/templates/engine/turns/compile-forms.d.ts +24 -0
- package/dist/templates/engine/turns/compile-forms.js +68 -0
- package/dist/templates/engine/turns/context.d.ts +96 -0
- package/dist/templates/engine/turns/context.js +158 -0
- package/dist/templates/engine/turns/events.d.ts +409 -0
- package/dist/templates/engine/turns/events.js +5 -0
- package/dist/templates/engine/turns/hook-forms.d.ts +62 -0
- package/dist/templates/engine/turns/hook-forms.js +79 -0
- package/dist/templates/engine/turns/ladders.d.ts +42 -0
- package/dist/templates/engine/turns/ladders.js +119 -0
- package/dist/templates/engine/turns/language.d.ts +8 -0
- package/dist/templates/engine/turns/language.js +121 -0
- package/dist/templates/engine/turns/notes-dates.d.ts +9 -0
- package/dist/templates/engine/turns/notes-dates.js +42 -0
- package/dist/templates/engine/turns/notes-detect.d.ts +13 -0
- package/dist/templates/engine/turns/notes-detect.js +36 -0
- package/dist/templates/engine/turns/notes.d.ts +27 -0
- package/dist/templates/engine/turns/notes.js +176 -0
- package/dist/templates/engine/turns/opening.d.ts +34 -0
- package/dist/templates/engine/turns/opening.js +306 -0
- package/dist/templates/engine/turns/overtalk.d.ts +21 -0
- package/dist/templates/engine/turns/overtalk.js +247 -0
- package/dist/templates/engine/turns/pending.d.ts +9 -0
- package/dist/templates/engine/turns/pending.js +88 -0
- package/dist/templates/engine/turns/reply-rules.d.ts +184 -0
- package/dist/templates/engine/turns/reply-rules.js +335 -0
- package/dist/templates/engine/turns/rules.d.ts +20 -0
- package/dist/templates/engine/turns/rules.js +144 -0
- package/dist/templates/engine/turns/silence.d.ts +7 -0
- package/dist/templates/engine/turns/silence.js +127 -0
- package/dist/templates/engine/turns/state-spec.d.ts +305 -0
- package/dist/templates/engine/turns/state-spec.js +2 -0
- package/dist/templates/engine/turns/state.d.ts +38 -0
- package/dist/templates/engine/turns/state.js +101 -0
- package/dist/templates/engine/turns/tracking.d.ts +50 -0
- package/dist/templates/engine/turns/tracking.js +184 -0
- package/dist/templates/engine/turns/transfer.d.ts +19 -0
- package/dist/templates/engine/turns/transfer.js +93 -0
- package/dist/templates/engine/turns/turn.d.ts +17 -0
- package/dist/templates/engine/turns/turn.js +363 -0
- package/dist/templates/engine/turns/voicemail.d.ts +8 -0
- package/dist/templates/engine/turns/voicemail.js +101 -0
- package/dist/templates/engine/variants.d.ts +36 -0
- package/dist/templates/engine/variants.js +159 -0
- package/dist/templates/engine/voice-dialog.d.ts +24 -0
- package/dist/templates/engine/voice-dialog.js +157 -0
- package/dist/templates/engine/voice.d.ts +174 -0
- package/dist/templates/engine/voice.js +1337 -0
- package/dist/templates/expr/caller-after.d.ts +20 -0
- package/dist/templates/expr/caller-after.js +53 -0
- package/dist/templates/expr/check.d.ts +19 -0
- package/dist/templates/expr/check.js +314 -0
- package/dist/templates/expr/compiled.d.ts +8 -0
- package/dist/templates/expr/compiled.js +8 -0
- package/dist/templates/expr/context.d.ts +28 -0
- package/dist/templates/expr/context.js +55 -0
- package/dist/templates/expr/day-table.d.ts +4 -0
- package/dist/templates/expr/day-table.js +80 -0
- package/dist/templates/expr/evaluate.d.ts +26 -0
- package/dist/templates/expr/evaluate.js +885 -0
- package/dist/templates/expr/facts.d.ts +7 -0
- package/dist/templates/expr/facts.js +81 -0
- package/dist/templates/expr/index.d.ts +4 -0
- package/dist/templates/expr/index.js +11 -0
- package/dist/templates/expr/line-tally.d.ts +64 -0
- package/dist/templates/expr/line-tally.js +88 -0
- package/dist/templates/expr/matchers-state.d.ts +23 -0
- package/dist/templates/expr/matchers-state.js +37 -0
- package/dist/templates/expr/matchers.d.ts +12 -0
- package/dist/templates/expr/matchers.js +99 -0
- package/dist/templates/expr/readers.d.ts +14 -0
- package/dist/templates/expr/readers.js +351 -0
- package/dist/templates/expr/slots.d.ts +14 -0
- package/dist/templates/expr/slots.js +678 -0
- package/dist/templates/expr/template.d.ts +12 -0
- package/dist/templates/expr/template.js +76 -0
- package/dist/templates/expr/test-call.d.ts +8 -0
- package/dist/templates/expr/test-call.js +32 -0
- package/dist/templates/expr/transcript.d.ts +36 -0
- package/dist/templates/expr/transcript.js +394 -0
- package/dist/templates/expr/types.d.ts +1011 -0
- package/dist/templates/expr/types.js +2 -0
- package/dist/templates/expr/values.d.ts +42 -0
- package/dist/templates/expr/values.js +166 -0
- package/dist/templates/expr/voice-ops.d.ts +26 -0
- package/dist/templates/expr/voice-ops.js +85 -0
- package/dist/templates/helpers/decision.d.ts +55 -0
- package/dist/templates/helpers/decision.js +83 -0
- package/dist/templates/helpers/fuzzy.d.ts +9 -0
- package/dist/templates/helpers/fuzzy.js +44 -0
- package/dist/templates/helpers/index.d.ts +6 -0
- package/dist/templates/helpers/index.js +35 -0
- package/dist/templates/index.d.ts +9 -0
- package/dist/templates/index.js +68 -0
- package/dist/templates/integration-forms.d.ts +252 -0
- package/dist/templates/integration-forms.js +2 -0
- package/dist/templates/knowledge/block.d.ts +44 -0
- package/dist/templates/knowledge/block.js +199 -0
- package/dist/templates/knowledge/dense.d.ts +87 -0
- package/dist/templates/knowledge/dense.js +158 -0
- package/dist/templates/knowledge/flow.d.ts +328 -0
- package/dist/templates/knowledge/flow.js +509 -0
- package/dist/templates/knowledge/retriever.d.ts +75 -0
- package/dist/templates/knowledge/retriever.js +204 -0
- package/dist/templates/knowledge/service.d.ts +77 -0
- package/dist/templates/knowledge/service.js +316 -0
- package/dist/templates/knowledge/text.d.ts +31 -0
- package/dist/templates/knowledge/text.js +66 -0
- package/dist/templates/knowledge/types.d.ts +120 -0
- package/dist/templates/knowledge/types.js +2 -0
- package/dist/templates/locale.d.ts +259 -0
- package/dist/templates/locale.js +4 -0
- package/dist/templates/locales/en-lexicons.d.ts +9 -0
- package/dist/templates/locales/en-lexicons.js +101 -0
- package/dist/templates/locales/en.d.ts +132 -0
- package/dist/templates/locales/en.js +261 -0
- package/dist/templates/locales/es.d.ts +65 -0
- package/dist/templates/locales/es.js +208 -0
- package/dist/templates/locales/hi.d.ts +47 -0
- package/dist/templates/locales/hi.js +235 -0
- package/dist/templates/locales/id.d.ts +43 -0
- package/dist/templates/locales/id.js +127 -0
- package/dist/templates/locales/index.d.ts +34 -0
- package/dist/templates/locales/index.js +112 -0
- package/dist/templates/locales/kk-lexicons.d.ts +22 -0
- package/dist/templates/locales/kk-lexicons.js +89 -0
- package/dist/templates/locales/kk.d.ts +140 -0
- package/dist/templates/locales/kk.js +306 -0
- package/dist/templates/locales/kn.d.ts +29 -0
- package/dist/templates/locales/kn.js +22 -0
- package/dist/templates/locales/listen-only.d.ts +15 -0
- package/dist/templates/locales/listen-only.js +27 -0
- package/dist/templates/locales/ms-lexicons.d.ts +13 -0
- package/dist/templates/locales/ms-lexicons.js +113 -0
- package/dist/templates/locales/ms.d.ts +76 -0
- package/dist/templates/locales/ms.js +179 -0
- package/dist/templates/locales/parse.d.ts +86 -0
- package/dist/templates/locales/parse.js +461 -0
- package/dist/templates/locales/ru-lexicons.d.ts +27 -0
- package/dist/templates/locales/ru-lexicons.js +127 -0
- package/dist/templates/locales/ru-stem.d.ts +2 -0
- package/dist/templates/locales/ru-stem.js +53 -0
- package/dist/templates/locales/ru.d.ts +143 -0
- package/dist/templates/locales/ru.js +387 -0
- package/dist/templates/locales/shared.d.ts +122 -0
- package/dist/templates/locales/shared.js +318 -0
- package/dist/templates/locales/ta.d.ts +29 -0
- package/dist/templates/locales/ta.js +22 -0
- package/dist/templates/locales/te.d.ts +29 -0
- package/dist/templates/locales/te.js +22 -0
- package/dist/templates/locales/tl-lexicons.d.ts +2 -0
- package/dist/templates/locales/tl-lexicons.js +230 -0
- package/dist/templates/locales/tl.d.ts +59 -0
- package/dist/templates/locales/tl.js +82 -0
- package/dist/templates/locales/vi.d.ts +59 -0
- package/dist/templates/locales/vi.js +160 -0
- package/dist/templates/locales/word-regex.d.ts +13 -0
- package/dist/templates/locales/word-regex.js +43 -0
- package/dist/templates/locales/words-kk.d.ts +2 -0
- package/dist/templates/locales/words-kk.js +23 -0
- package/dist/templates/locales/words-ru.d.ts +4 -0
- package/dist/templates/locales/words-ru.js +92 -0
- package/dist/templates/spec.d.ts +2856 -0
- package/dist/templates/spec.js +2 -0
- package/dist/testing/fake-channel.d.ts +0 -1
- package/dist/testing/fake-channel.js +0 -1
- package/dist/testing/index.d.ts +24 -1
- package/dist/testing/index.js +117 -2
- package/dist/voice/call-voice.d.ts +581 -0
- package/dist/voice/call-voice.js +1399 -0
- package/dist/voice/intent-interrupt.d.ts +32 -0
- package/dist/voice/intent-interrupt.js +91 -0
- package/dist/voice/self-echo.d.ts +28 -0
- package/dist/voice/self-echo.js +135 -0
- package/dist/voice/sentence-tag.d.ts +5 -0
- package/dist/voice/sentence-tag.js +42 -0
- package/dist/voice/speech-leak.d.ts +74 -0
- package/dist/voice/speech-leak.js +216 -0
- package/dist/voice/transfer.d.ts +90 -0
- package/dist/voice/transfer.js +331 -0
- package/dist/voice/turn-timing.d.ts +293 -0
- package/dist/voice/turn-timing.js +567 -0
- package/docs/README.md +3 -6
- package/docs/framework/README.md +6 -10
- package/docs/framework/architecture.md +2 -2
- package/docs/framework/container-and-di.md +1 -2
- package/docs/framework/invariants.md +6 -6
- package/docs/framework/package-layout.md +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,1011 @@
|
|
|
1
|
+
import type { DateParseOptions, LocaleCode } from '../locale';
|
|
2
|
+
import type { NoteDetector, StateBlocks } from '../engine/turns/state-spec';
|
|
3
|
+
import type { CallView, Matcher, ScriptRule } from '../spec';
|
|
4
|
+
import type { CallerAfterLast } from './caller-after';
|
|
5
|
+
import type { LineTally } from './line-tally';
|
|
6
|
+
export type { LineTally, LineTallyClass } from './line-tally';
|
|
7
|
+
export type { CallerAfterLast } from './caller-after';
|
|
8
|
+
/**
|
|
9
|
+
* Built-in facts of the call (`{ fact: name }`); any other name is a fact the agent file defines (`AgentSpec.facts`).
|
|
10
|
+
* - clock (in the context's time zone): `today` (`YYYY-MM-DD`), `now` (epoch ms), `hour`, `minute`, `weekday`
|
|
11
|
+
* (0 = Sunday), `timeZone`;
|
|
12
|
+
* - conversation: `line` (the line being handled), `lastAgentLine`, `lastCallerLine`, `lastQuestion` (the last agent
|
|
13
|
+
* sentence ending in `?`), `phase`, `language`, `languageProvisional`, `callerTurns`, `callerFinals`, `agentLines`,
|
|
14
|
+
* `callerLines` (counts), `elapsedMs`, `attempt`, `previousResult`, `voiceTag`, `replyAsr`, `afterSilence`, `stage` and
|
|
15
|
+
* `openQuestion` (`tracking`);
|
|
16
|
+
* - after the call: `result`, `preResult`, `extractedResult`, `triggersCallback`, `extractionFailed`, `endedBy`,
|
|
17
|
+
* `endedAtMs`, `recallScheduled`, `budget`, `transferStarted`, `transferCompleted`;
|
|
18
|
+
* - a report row: `rowKind`, `connected`, `callUuid`, `dialogUuid`, `sipCode`, `sipPhrase`, `asrDurationSec`,
|
|
19
|
+
* `replyLanguage`, `service.<key>` (a platform service field of the row, e.g. `service.call_transcript`).
|
|
20
|
+
*/
|
|
21
|
+
export type FactName = 'today' | 'now' | 'hour' | 'minute' | 'weekday' | 'timeZone' | 'line' | 'lastAgentLine' | 'lastCallerLine' | 'answeredCallerLine' | 'lastQuestion' | 'phase' | 'stage' | 'openQuestion' | 'language' | 'languageProvisional' | 'callerTurns' | 'callerFinals' | 'agentLines' | 'callerLines' | 'elapsedMs' | 'attempt' | 'previousResult' | 'voiceTag' | 'replyAsr' | 'afterSilence' | 'result' | 'preResult' | 'extractedResult' | 'triggersCallback' | 'extractionFailed' | 'endedBy' | 'endedAtMs' | 'recallScheduled' | 'budget' | 'transferStarted' | 'transferCompleted' | 'transferStartedAt' | 'rowKind' | 'connected' | 'callUuid' | 'dialogUuid' | 'sipCode' | 'sipPhrase' | 'asrDurationSec' | 'replyLanguage' | 'replyLanguageProvisional' | `service.${string}` | (string & {});
|
|
22
|
+
/**
|
|
23
|
+
* Where a value is read from. Paths are dotted (`customer.name`, `items.0.title`).
|
|
24
|
+
* - `var`: a call variable (input fields, prompt variables, values `set` by rules);
|
|
25
|
+
* - `fact`: a built-in fact ({@link FactName}) or a named fact of `AgentSpec.facts`;
|
|
26
|
+
* - `entity`: an extracted entity (after the call; `outcome.entities` in after-call integrations);
|
|
27
|
+
* - `row`: a field of the report row being built (report fields, integrations, `remember`);
|
|
28
|
+
* - `memory`: a value kept across attempts of the dialog (`results.remember`);
|
|
29
|
+
* - `flag`: an engine flag (`closing.afterSilence`, `<gate>.passed`, rule flags); `counter`: a rule counter, a list
|
|
30
|
+
* is summed;
|
|
31
|
+
* - `input`: a field of what the slot handles besides the call (a hook place's input: `heardMs` of `cutMark`, the
|
|
32
|
+
* integration outcome of `writeBack`, the response of `answer`);
|
|
33
|
+
* - `self`: the value the slot transforms (a field's own source value, an entity value in `normalize`, the number in
|
|
34
|
+
* `dialNumber`, the current value in `dialogEnv.unless`);
|
|
35
|
+
* - `local`: a name bound by the enclosing operator (`let`, `dayTable` rows, `each` / `select` items: `item`, `index`);
|
|
36
|
+
* - `asked`: agent lines that asked a question of `tracking.questions` (a list is summed); `answers`: caller lines said
|
|
37
|
+
* while the question (one of the questions) was open, matching `match` when given.
|
|
38
|
+
*/
|
|
39
|
+
export type Ref = {
|
|
40
|
+
readonly var: string;
|
|
41
|
+
} | {
|
|
42
|
+
readonly fact: FactName;
|
|
43
|
+
} | {
|
|
44
|
+
readonly entity: string;
|
|
45
|
+
} | {
|
|
46
|
+
readonly row: string;
|
|
47
|
+
} | {
|
|
48
|
+
readonly memory: string;
|
|
49
|
+
} | {
|
|
50
|
+
readonly flag: string;
|
|
51
|
+
} | {
|
|
52
|
+
readonly counter: string | readonly string[];
|
|
53
|
+
} | {
|
|
54
|
+
readonly input: string;
|
|
55
|
+
} | {
|
|
56
|
+
readonly self: true;
|
|
57
|
+
} | {
|
|
58
|
+
readonly local: string;
|
|
59
|
+
} | {
|
|
60
|
+
readonly asked: string | readonly string[];
|
|
61
|
+
} | {
|
|
62
|
+
readonly answers: {
|
|
63
|
+
readonly question: string | readonly string[];
|
|
64
|
+
readonly match?: Matcher;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* A reference with value options: `default` when empty, `nullish` when the value is `null` or missing (JavaScript `??`:
|
|
69
|
+
* a blank text stays; `{ row: 'k', nullish: null }` writes a missing key as `null`), `map` (raw value → value; unlisted
|
|
70
|
+
* gives `default`, else `null`). A reference with tests of {@link Cmp} (`{ var: 'dpd', gt: 5 }`) is the yes/no of the
|
|
71
|
+
* tests.
|
|
72
|
+
*/
|
|
73
|
+
export type RefExpr = Ref & {
|
|
74
|
+
readonly default?: Expr;
|
|
75
|
+
readonly nullish?: Expr;
|
|
76
|
+
readonly map?: Readonly<Record<string, Expr>>;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Tests of one value (all given tests must hold; none given: the value is truthy). Before the tests the value is
|
|
80
|
+
* prepared in this order: `read` (a reader, see {@link ReadSpec}), `as` (coercion), `normalize`.
|
|
81
|
+
* - `eq`, `ne`, `in`, `notIn`: equality (numbers compare as numbers when both sides read as numbers, else as text);
|
|
82
|
+
* - `gt`, `gte`, `lt`, `lte`: numbers (dates `YYYY-MM-DD` compare as text, which orders them);
|
|
83
|
+
* - `empty` (null, undefined, blank text, empty list / object), `truthy` (not empty and not `false`, `0`, `'false'`,
|
|
84
|
+
* `'0'`), `isTrue` (`true` or the text `true` in any case);
|
|
85
|
+
* - `matches`: a {@link Matcher} on the value as text; `includes`: the text (or list) contains it;
|
|
86
|
+
* - `isoDate`: a valid `YYYY-MM-DD`; `numeric`: reads as a finite number;
|
|
87
|
+
* - `days`: whole days from `from` (default today) to the value as a date: `eq`, `min`, `max` (negative: before);
|
|
88
|
+
* - `type`: the value's JavaScript type (`array` and `null` apart from `object`; `undefined` for a missing value).
|
|
89
|
+
* `strict: true` switches to plain JavaScript semantics: `eq` / `ne` / `in` / `notIn` / list `includes` compare with
|
|
90
|
+
* `===` (no number or text coercion: the text `'true'` is not `true`, `'5'` is not `5`), `gt` / `gte` / `lt` / `lte`
|
|
91
|
+
* are JavaScript's `>` … (two texts compare as texts, so `'2026-02-30' > '2026-02-07'`), and `truthy` (or a value with
|
|
92
|
+
* no tests) is JavaScript truthiness (`Boolean(v)`: the texts `'false'`, `'0'`, `'NaN'`, `' '` and an empty list or
|
|
93
|
+
* object are true; `0`, `NaN`, `''`, `null`, `undefined`, `false` are false).
|
|
94
|
+
*/
|
|
95
|
+
export interface Cmp {
|
|
96
|
+
readonly eq?: Expr;
|
|
97
|
+
readonly ne?: Expr;
|
|
98
|
+
readonly in?: Expr;
|
|
99
|
+
readonly notIn?: Expr;
|
|
100
|
+
readonly gt?: Expr;
|
|
101
|
+
readonly gte?: Expr;
|
|
102
|
+
readonly lt?: Expr;
|
|
103
|
+
readonly lte?: Expr;
|
|
104
|
+
readonly empty?: boolean;
|
|
105
|
+
readonly truthy?: boolean;
|
|
106
|
+
readonly isTrue?: boolean;
|
|
107
|
+
readonly matches?: Matcher;
|
|
108
|
+
readonly includes?: Expr;
|
|
109
|
+
readonly isoDate?: boolean;
|
|
110
|
+
readonly numeric?: boolean;
|
|
111
|
+
readonly days?: {
|
|
112
|
+
readonly from?: Expr;
|
|
113
|
+
readonly eq?: number;
|
|
114
|
+
readonly min?: number;
|
|
115
|
+
readonly max?: number;
|
|
116
|
+
};
|
|
117
|
+
readonly type?: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'null' | 'undefined';
|
|
118
|
+
readonly strict?: boolean;
|
|
119
|
+
readonly read?: ReadSpec;
|
|
120
|
+
readonly as?: 'number' | 'amount' | 'date' | 'text';
|
|
121
|
+
readonly normalize?: 'lower' | 'trimLower' | 'noSpacesLower' | 'NFC';
|
|
122
|
+
}
|
|
123
|
+
/** An agent line or a caller line of the transcript. Agent selectors skip lines with no letter or digit (`…`). */
|
|
124
|
+
export type Speaker = 'agent' | 'caller' | 'any';
|
|
125
|
+
/**
|
|
126
|
+
* Questions about the conversation so far (`call.lines`; during the call and after it).
|
|
127
|
+
* - `said`: lines of `by` that match (`match`; `unit`: an agent line's mixer alias; `firstSentence`: only the first
|
|
128
|
+
* sentence of each line is tested), counted after the first agent line matching `after` (or of unit `after.unit`)
|
|
129
|
+
* when given; holds when the count is within `count` (default `{ gte: 1 }`);
|
|
130
|
+
* - `lastAgentLine`: the last agent line matches; `lastSentence`: the last sentence of that line matches;
|
|
131
|
+
* - `lastQuestion`: the agent's last question (the last sentence ending in `?` of the latest agent line that has one,
|
|
132
|
+
* lines matching `skip` passed over) matches;
|
|
133
|
+
* - `lastLine`: the transcript's last line is `who`'s and matches;
|
|
134
|
+
* - `callerStreak`: more than `gt` caller lines in a row (agent lines between them do not break the row; the line
|
|
135
|
+
* being handled not counted) match, counted back from the latest;
|
|
136
|
+
* - `closedOn`: the last agent line contains the text (normalized; `raw: true`: as it is, a plain `includes`);
|
|
137
|
+
* - `callerSaidAfter`: some caller line after an agent line matching `agent` matches `caller` (`reply`: and the next
|
|
138
|
+
* agent line after it matches `reply`);
|
|
139
|
+
* - `answeredAfter` / `unansweredAfter`: after the last agent line matching, a caller line with words came / did not
|
|
140
|
+
* come (`unansweredAfter` needs such an agent line);
|
|
141
|
+
* - `exchange`: an agent line matching `question` (after one matching `before`, when given) was answered by a caller
|
|
142
|
+
* line matching `answer`: the first caller line after it (`firstAnswer`) or any until the next agent line
|
|
143
|
+
* (`untilAgent`);
|
|
144
|
+
* - `lastAnswer`: the first caller line after the last agent line matching `after` matches `matches`;
|
|
145
|
+
* - `trailingAgentLines`: the transcript ends with at least `min` agent lines and no caller line after them;
|
|
146
|
+
* - `sequence`: lines in this order (each step a later line; `nextAgent`: the very next agent line after the step
|
|
147
|
+
* before);
|
|
148
|
+
* - `callerEchoesAgent`: a caller line of at least `minWords` words is a run of words of the agent line before it;
|
|
149
|
+
* - `callerLineAnsweredByLastAgent`: the last agent line matches and a caller line comes right before it;
|
|
150
|
+
* - `latest`: the newest caller line any case matches (case `afterAgent`: the agent line just before it must match
|
|
151
|
+
* too) gives that case's value; none: `none`;
|
|
152
|
+
* - `agentSaid`: an agent line contains the text (normalized; `prefixChars`: only its first characters;
|
|
153
|
+
* `slackChars`: the text may end that many characters short);
|
|
154
|
+
* - `callerAfterLast`: the caller's lines after (or just before) the agent's last line of a kind, each tested by a
|
|
155
|
+
* condition on the line (see `CallerAfterLast`);
|
|
156
|
+
* - `daysIn`: every day the line being handled names (locale parsers of the reply language, or of `locale`, with the
|
|
157
|
+
* parser options `parse`, counted from `today` — default the clock's day; `skipPast`: past readings left out) is
|
|
158
|
+
* after the date, and it names at least one; `hints`: a list of `{ words, date }` (day words of the call, e.g. a
|
|
159
|
+
* `date_hints` input field: lower-case spellings, longest first, and the day each names) — for each hint the first
|
|
160
|
+
* of its words found in the lower-cased line as a whole word (spaces as any run of spaces; the words found are
|
|
161
|
+
* blanked for the hints after it) names its day too.
|
|
162
|
+
* Every question also takes the reading options of {@link TranscriptOptions} next to its key.
|
|
163
|
+
*/
|
|
164
|
+
export type TranscriptCondition = TranscriptQuestion & TranscriptOptions;
|
|
165
|
+
/**
|
|
166
|
+
* How a transcript question reads the lines (all optional; the defaults are the call's lines as they are, agent lines
|
|
167
|
+
* without a letter or digit left out):
|
|
168
|
+
* - `from`: the lines of a speaker-prefixed transcript text instead (`text`, e.g. `{ row: 'call_transcript' }`; a
|
|
169
|
+
* line starting with `agent` / `caller` opens a line, a line with neither continues the one before);
|
|
170
|
+
* - `includeEmpty`: agent lines without words (`…`) are kept (they count as the last line, end a streak, …);
|
|
171
|
+
* - `firstLineOnly`: a line is only its first text line (what follows a newline in it is dropped), as code that split
|
|
172
|
+
* a `SPEAKER: text` transcript on newlines read it;
|
|
173
|
+
* - `normalize: 'NFC'`: line texts are NFC-normalized before the matchers test them.
|
|
174
|
+
*/
|
|
175
|
+
export interface TranscriptOptions {
|
|
176
|
+
readonly from?: {
|
|
177
|
+
readonly text: Expr;
|
|
178
|
+
readonly agent: string;
|
|
179
|
+
readonly caller: string;
|
|
180
|
+
};
|
|
181
|
+
readonly includeEmpty?: boolean;
|
|
182
|
+
readonly firstLineOnly?: boolean;
|
|
183
|
+
readonly normalize?: 'NFC';
|
|
184
|
+
}
|
|
185
|
+
/** The transcript questions without their reading options (see {@link TranscriptCondition}). */
|
|
186
|
+
export type TranscriptQuestion = {
|
|
187
|
+
readonly said: {
|
|
188
|
+
readonly by: Speaker;
|
|
189
|
+
readonly match?: Matcher;
|
|
190
|
+
readonly unit?: string;
|
|
191
|
+
readonly after?: Matcher | {
|
|
192
|
+
readonly unit: string;
|
|
193
|
+
};
|
|
194
|
+
readonly count?: {
|
|
195
|
+
readonly gte?: number;
|
|
196
|
+
readonly lte?: number;
|
|
197
|
+
};
|
|
198
|
+
readonly firstSentence?: boolean;
|
|
199
|
+
};
|
|
200
|
+
} | {
|
|
201
|
+
readonly lastAgentLine: Matcher;
|
|
202
|
+
} | {
|
|
203
|
+
readonly lastSentence: Matcher;
|
|
204
|
+
} | {
|
|
205
|
+
readonly lastQuestion: Matcher;
|
|
206
|
+
readonly skip?: Matcher;
|
|
207
|
+
} | {
|
|
208
|
+
readonly lastLine: {
|
|
209
|
+
readonly who: 'agent' | 'caller';
|
|
210
|
+
readonly match: Matcher;
|
|
211
|
+
};
|
|
212
|
+
} | {
|
|
213
|
+
readonly callerStreak: {
|
|
214
|
+
readonly match: Matcher;
|
|
215
|
+
readonly gt: number;
|
|
216
|
+
};
|
|
217
|
+
} | {
|
|
218
|
+
readonly closedOn: Expr;
|
|
219
|
+
readonly raw?: boolean;
|
|
220
|
+
} | {
|
|
221
|
+
readonly callerSaidAfter: {
|
|
222
|
+
readonly agent: Matcher;
|
|
223
|
+
readonly caller: Matcher;
|
|
224
|
+
readonly reply?: Matcher;
|
|
225
|
+
};
|
|
226
|
+
} | {
|
|
227
|
+
readonly answeredAfter: Matcher;
|
|
228
|
+
} | {
|
|
229
|
+
readonly unansweredAfter: Matcher;
|
|
230
|
+
} | {
|
|
231
|
+
readonly exchange: {
|
|
232
|
+
readonly before?: Matcher;
|
|
233
|
+
readonly question: Matcher;
|
|
234
|
+
readonly answer: Matcher;
|
|
235
|
+
readonly scope: 'firstAnswer' | 'untilAgent';
|
|
236
|
+
};
|
|
237
|
+
} | {
|
|
238
|
+
readonly lastAnswer: {
|
|
239
|
+
readonly after: Matcher;
|
|
240
|
+
readonly matches: Matcher;
|
|
241
|
+
};
|
|
242
|
+
} | {
|
|
243
|
+
readonly trailingAgentLines: {
|
|
244
|
+
readonly min: number;
|
|
245
|
+
};
|
|
246
|
+
} | {
|
|
247
|
+
readonly sequence: readonly ({
|
|
248
|
+
readonly agent: Matcher;
|
|
249
|
+
} | {
|
|
250
|
+
readonly caller: Matcher;
|
|
251
|
+
} | {
|
|
252
|
+
readonly nextAgent: Matcher;
|
|
253
|
+
})[];
|
|
254
|
+
} | {
|
|
255
|
+
readonly callerEchoesAgent: {
|
|
256
|
+
readonly minWords: number;
|
|
257
|
+
};
|
|
258
|
+
} | {
|
|
259
|
+
readonly callerLineAnsweredByLastAgent: Matcher;
|
|
260
|
+
} | {
|
|
261
|
+
readonly latest: {
|
|
262
|
+
readonly cases: readonly {
|
|
263
|
+
readonly match: Matcher | {
|
|
264
|
+
readonly afterAgent: Matcher;
|
|
265
|
+
readonly line: Matcher;
|
|
266
|
+
};
|
|
267
|
+
readonly value: boolean;
|
|
268
|
+
}[];
|
|
269
|
+
readonly none: boolean;
|
|
270
|
+
};
|
|
271
|
+
} | {
|
|
272
|
+
readonly agentSaid: {
|
|
273
|
+
readonly text: Expr;
|
|
274
|
+
readonly prefixChars?: number;
|
|
275
|
+
readonly slackChars?: number;
|
|
276
|
+
};
|
|
277
|
+
} | {
|
|
278
|
+
readonly daysIn: {
|
|
279
|
+
readonly allAfter: Expr;
|
|
280
|
+
readonly hints?: Expr;
|
|
281
|
+
readonly today?: Expr;
|
|
282
|
+
readonly locale?: LocaleCode;
|
|
283
|
+
readonly parse?: DateParseOptions;
|
|
284
|
+
readonly skipPast?: boolean;
|
|
285
|
+
};
|
|
286
|
+
} | {
|
|
287
|
+
readonly callerAfterLast: CallerAfterLast;
|
|
288
|
+
};
|
|
289
|
+
/**
|
|
290
|
+
* A yes/no question about the call, as data.
|
|
291
|
+
* - `true` / `false`;
|
|
292
|
+
* - a reference with tests (`{ var: 'dpd', gte: 3 }`), or any value with tests (`{ of: Expr, …Cmp }`); a reference
|
|
293
|
+
* without tests is truthy (a named fact that is a condition: its answer);
|
|
294
|
+
* - `all`, `any`, `not`;
|
|
295
|
+
* - `rowKind`: the report row being built is one of these kinds; `weekdayIn`: today (0 = Sunday) is one of these;
|
|
296
|
+
* `language`: the reply language is (one of) this; `phase`: the call phase is (one of) this;
|
|
297
|
+
* - `line`: the line being handled matches;
|
|
298
|
+
* - `stage`: the call's stage (`tracking.stages`) is (one of) this; `openQuestion`: the question open now
|
|
299
|
+
* (`tracking.questions`) is (one of) this, `null`: none; `ladderOpen`: the line ladder has a line left to say (or a
|
|
300
|
+
* terminal action); `detects`: a note detector finds something in the line;
|
|
301
|
+
* - transcript questions ({@link TranscriptCondition}).
|
|
302
|
+
*/
|
|
303
|
+
export type Condition = boolean | (Ref & Cmp) | ({
|
|
304
|
+
readonly of: Expr;
|
|
305
|
+
} & Cmp) | {
|
|
306
|
+
readonly all: readonly Condition[];
|
|
307
|
+
} | {
|
|
308
|
+
readonly any: readonly Condition[];
|
|
309
|
+
} | {
|
|
310
|
+
readonly not: Condition;
|
|
311
|
+
} | {
|
|
312
|
+
readonly rowKind: readonly ('call' | 'error' | 'failedDial' | 'cancelled' | 'failedLeg' | 'headless')[];
|
|
313
|
+
} | {
|
|
314
|
+
readonly weekdayIn: readonly number[];
|
|
315
|
+
} | {
|
|
316
|
+
readonly language: LocaleCode | readonly LocaleCode[];
|
|
317
|
+
} | {
|
|
318
|
+
readonly phase: CallView['phase'] | readonly CallView['phase'][];
|
|
319
|
+
} | {
|
|
320
|
+
readonly line: Matcher;
|
|
321
|
+
} | {
|
|
322
|
+
readonly stage: string | readonly string[];
|
|
323
|
+
} | {
|
|
324
|
+
readonly openQuestion: string | readonly string[] | null;
|
|
325
|
+
} | {
|
|
326
|
+
readonly ladderOpen: string;
|
|
327
|
+
} | {
|
|
328
|
+
readonly detects: NoteDetector | readonly NoteDetector[];
|
|
329
|
+
} | TranscriptCondition;
|
|
330
|
+
/**
|
|
331
|
+
* Matchers added by the data language (members of `Matcher`):
|
|
332
|
+
* - `squeezed`: the line lower-cased with everything but letters and digits removed (no spaces), at most `maxChars`
|
|
333
|
+
* long when given, tested by the inner matcher;
|
|
334
|
+
* - `words`: the line's word count (split on `split`, default spaces) is within `min`..`max`; `every`: each word
|
|
335
|
+
* matches; `some`: some word matches the inner matcher;
|
|
336
|
+
* - `mentions`: the line names the values of these call variables (whole words, normalized; `stem`: a word longer than
|
|
337
|
+
* `over` letters is compared without its last `cut`; words shorter than `minLen` are ignored); `all`: every
|
|
338
|
+
* variable, default any;
|
|
339
|
+
* - `normalizedEquals`: the normalized line equals the normalized text (`punctuation: 'space'`: characters other than
|
|
340
|
+
* letters, digits and spaces become spaces, default dropped);
|
|
341
|
+
* - `lastAgentLine`: the call's last agent line (not the line handled) matches (`includeEmpty`: a last agent line
|
|
342
|
+
* without words, `…`, is that line, default skipped);
|
|
343
|
+
* - `matcher`: a matcher of `AgentSpec.matchers` by name.
|
|
344
|
+
*/
|
|
345
|
+
export type MatcherAddition = {
|
|
346
|
+
readonly squeezed: Matcher;
|
|
347
|
+
readonly maxChars?: number;
|
|
348
|
+
} | {
|
|
349
|
+
readonly words: {
|
|
350
|
+
readonly min?: number;
|
|
351
|
+
readonly max?: number;
|
|
352
|
+
readonly split?: RegExp;
|
|
353
|
+
readonly every?: RegExp;
|
|
354
|
+
readonly some?: Matcher;
|
|
355
|
+
};
|
|
356
|
+
} | {
|
|
357
|
+
readonly mentions: {
|
|
358
|
+
readonly vars: readonly string[];
|
|
359
|
+
readonly stem?: {
|
|
360
|
+
readonly over: number;
|
|
361
|
+
readonly cut: number;
|
|
362
|
+
};
|
|
363
|
+
readonly minLen?: number;
|
|
364
|
+
readonly all?: boolean;
|
|
365
|
+
};
|
|
366
|
+
} | {
|
|
367
|
+
readonly normalizedEquals: Expr;
|
|
368
|
+
readonly punctuation?: 'drop' | 'space';
|
|
369
|
+
} | {
|
|
370
|
+
readonly lastAgentLine: Matcher;
|
|
371
|
+
readonly includeEmpty?: boolean;
|
|
372
|
+
} | {
|
|
373
|
+
readonly matcher: string;
|
|
374
|
+
};
|
|
375
|
+
/** Orders a date reader tries (first that reads a valid day wins). */
|
|
376
|
+
export type DateOrder =
|
|
377
|
+
/** `2026-11-05`, `2026/11/05`, `2026.11.05`. */
|
|
378
|
+
'ymd'
|
|
379
|
+
/** `05.11.2026`, `05/11/2026`, `05-11-2026`. */
|
|
380
|
+
| 'dmy'
|
|
381
|
+
/** `11/05/2026` (month first). */
|
|
382
|
+
| 'mdy'
|
|
383
|
+
/** `20261105`. */
|
|
384
|
+
| 'compact'
|
|
385
|
+
/** `261105` (two-digit year: below `70` is 20xx). */
|
|
386
|
+
| 'yymmdd'
|
|
387
|
+
/** `11.05` / `11/05`: month and day, the next such day from today (`mmdd.maxDaysAhead`). */
|
|
388
|
+
| 'mmdd'
|
|
389
|
+
/** `05.11` / `05/11`: day and month, the next such day from today. */
|
|
390
|
+
| 'ddmm'
|
|
391
|
+
/** Spreadsheet serial day (`46331`), base 1899-12-30. */
|
|
392
|
+
| 'serial'
|
|
393
|
+
/** Spreadsheet serial day with the 1900 leap-year bug (serials up to 60 one day later). */
|
|
394
|
+
| 'serial1900'
|
|
395
|
+
/** `5-Nov-26` / `05-Nov-2026`: month abbreviation in `monthNames`' language. */
|
|
396
|
+
| 'D-MMM-YY';
|
|
397
|
+
/**
|
|
398
|
+
* How a raw value (a dialer field, a header) is read into a clean value. A string names the kind with its defaults.
|
|
399
|
+
* - `text`: trimmed text; `decode` (`uri`: `%xx`; `uriPlus` / `form`: also `+` as a space; a malformed `%` keeps
|
|
400
|
+
* the text as it is, `+` turned into spaces, or untouched with `onMalformed: 'raw'`), `control` (drop control
|
|
401
|
+
* characters), `collapse` (single spaces), `case`, `replace` (pairs in order), `dropWords` (words matching are
|
|
402
|
+
* dropped), `strip` (these characters removed), `trimEnd` (these characters cut from the end), `stripPrefix`,
|
|
403
|
+
* `nullWords` (values that mean «nothing» → `''`, compared lower case); `trim: 'beforeDecode'`: the raw text is
|
|
404
|
+
* trimmed before `decode` and the text is not trimmed after it (`'%20500%20'` → `' 500 '`; default `afterDecode`);
|
|
405
|
+
* - `msisdn`: digits only (`from: 'sipUri'`: the user part of a `sip:` / `tel:` URI first); `out: 'asWritten'`: the
|
|
406
|
+
* number as written, not only its digits (`+` kept): trimmed, with `from: 'sipUri'` the `<…>` part, without the
|
|
407
|
+
* `sip:` / `sips:` / `tel:` scheme, the `@host` and `;` / `?` parameters;
|
|
408
|
+
* - `jsNumber`: the value as JavaScript's `Number(v)` reads it (`''` and `null` are `0`, `'0x1A'` is `26`, `'1,5'`
|
|
409
|
+
* and `undefined` are `NaN`, `true` is `1`); `parse: 'float'`: `Number.parseFloat` of the text (`'1.500.000'` is
|
|
410
|
+
* `1.5`, `''` is `NaN`), `parse: 'int'`: `Number.parseInt(text, 10)`;
|
|
411
|
+
* - `digits`: digits only; `integer`: the whole number of the digits (`null` without digits); `figure`: a decimal
|
|
412
|
+
* number (`,` as a decimal comma, spaces dropped; `null` when not a number);
|
|
413
|
+
* - `amount`: a money value; `separators`: `'lastIsDecimal'` (the last `.` or `,` followed by 1–2 digits at the end
|
|
414
|
+
* is the decimal point, every other separator groups thousands) or `'library'` (default: `parseAmount` of the
|
|
415
|
+
* locale helpers); `out`: `number` (default) or `decimalText` (`'1234.50'`); `invalid`: raw values read as
|
|
416
|
+
* `invalidAs`; unreadable gives `invalidAs` (default `null`);
|
|
417
|
+
* - `date`: a calendar day `YYYY-MM-DD` trying `orders` in turn; `trailingTime`: a time after the day is allowed
|
|
418
|
+
* (`true`: after any order, or a list of the orders that allow it); `validate`: the day must exist (default true);
|
|
419
|
+
* `invalidDay: 'rollover'`: a day the calendar does not have rolls over as JavaScript's `Date.UTC` does (`02-30` →
|
|
420
|
+
* March 2nd, month `13` → January of the next year, day `0` → the last day of the month before); `separators`: the
|
|
421
|
+
* characters allowed between the parts (default `./-`; or per order, `{ ymd: '-/', dmy: '-/.' }`, an order not
|
|
422
|
+
* named takes the default); `padded`: month and day need two digits; `serialDigits`:
|
|
423
|
+
* a serial day has exactly this many digits (then `0` is read too); `today`: the day `mmdd` / `ddmm` count from
|
|
424
|
+
* (default the clock's); `mmdd.maxDaysAhead`: a month-day further ahead than this is read as the year before's;
|
|
425
|
+
* `mmdd.past`: `'nextYear'` (default: a day already behind is next year's) or `'thisYear'` (this year's day, also
|
|
426
|
+
* when past); `min` / `max`: days outside give `onInvalid` (default `null`);
|
|
427
|
+
* - `dateTime`: an instant (epoch ms) from a wall-clock `pattern` (`YYYY MM DD HH mm ss`) in `timeZone`; `within`:
|
|
428
|
+
* only when it is `minMs`..`maxMs` from now; `padded`: `MM`, `DD`, `mm`, `ss` need two digits; `invalidDay:
|
|
429
|
+
* 'rollover'`: a day 1–31 past the month's end rolls into the next month (the month must still be 1–12);
|
|
430
|
+
* - `personName`: a name for the voice: `decode` (default true: URI, `+` a space), `punctuation` (`drop` default,
|
|
431
|
+
* `space`, `keep`), `case: 'title'` (default) or `'asIs'`, `caseLocale`, `placeholders` (values meaning «no name»,
|
|
432
|
+
* give `''`), `dropTokens`;
|
|
433
|
+
* - `flag`: a boolean (`true` / `false` word lists, lower case; `numericOne`: `1` is true); else `null`;
|
|
434
|
+
* - `enum`: `map` of known values (`normalize: 'snake'` first), else `default`;
|
|
435
|
+
* - `int`: a whole number at least `min`, else `else`;
|
|
436
|
+
* - `phone`: a phone number: digits only, the last `national` digits, with `country` / `prefix` in front, `plus`.
|
|
437
|
+
*/
|
|
438
|
+
export type ReadSpec = 'text' | 'msisdn' | 'digits' | 'integer' | 'figure' | 'amount' | 'date' | 'personName' | 'flag' | 'jsNumber' | {
|
|
439
|
+
readonly kind: 'text';
|
|
440
|
+
readonly decode?: 'uri' | 'uriPlus' | 'form';
|
|
441
|
+
readonly onMalformed?: 'raw';
|
|
442
|
+
readonly control?: boolean;
|
|
443
|
+
readonly collapse?: boolean;
|
|
444
|
+
readonly case?: 'upper' | 'lower';
|
|
445
|
+
readonly replace?: readonly (readonly [RegExp, string])[];
|
|
446
|
+
readonly dropWords?: RegExp;
|
|
447
|
+
readonly strip?: string;
|
|
448
|
+
readonly trimEnd?: string;
|
|
449
|
+
readonly stripPrefix?: string;
|
|
450
|
+
readonly nullWords?: readonly string[];
|
|
451
|
+
readonly trim?: 'afterDecode' | 'beforeDecode';
|
|
452
|
+
} | {
|
|
453
|
+
readonly kind: 'msisdn';
|
|
454
|
+
readonly from?: 'sipUri';
|
|
455
|
+
readonly out?: 'digits' | 'asWritten';
|
|
456
|
+
} | {
|
|
457
|
+
readonly kind: 'digits';
|
|
458
|
+
} | {
|
|
459
|
+
readonly kind: 'integer';
|
|
460
|
+
} | {
|
|
461
|
+
readonly kind: 'figure';
|
|
462
|
+
} | {
|
|
463
|
+
readonly kind: 'jsNumber';
|
|
464
|
+
readonly parse?: 'number' | 'float' | 'int';
|
|
465
|
+
} | {
|
|
466
|
+
readonly kind: 'amount';
|
|
467
|
+
readonly separators?: 'lastIsDecimal' | 'library';
|
|
468
|
+
readonly out?: 'number' | 'decimalText';
|
|
469
|
+
readonly invalid?: readonly string[];
|
|
470
|
+
readonly invalidAs?: unknown;
|
|
471
|
+
} | {
|
|
472
|
+
readonly kind: 'date';
|
|
473
|
+
readonly orders: readonly DateOrder[];
|
|
474
|
+
readonly trailingTime?: boolean | readonly DateOrder[];
|
|
475
|
+
readonly validate?: boolean;
|
|
476
|
+
readonly invalidDay?: 'refuse' | 'rollover';
|
|
477
|
+
readonly separators?: string | Readonly<Partial<Record<DateOrder, string>>>;
|
|
478
|
+
readonly padded?: boolean;
|
|
479
|
+
readonly serialDigits?: number;
|
|
480
|
+
readonly today?: Expr;
|
|
481
|
+
readonly mmdd?: {
|
|
482
|
+
readonly maxDaysAhead?: number;
|
|
483
|
+
readonly past?: 'nextYear' | 'thisYear';
|
|
484
|
+
};
|
|
485
|
+
readonly monthNames?: LocaleCode;
|
|
486
|
+
readonly min?: Expr;
|
|
487
|
+
readonly max?: Expr;
|
|
488
|
+
readonly onInvalid?: Expr;
|
|
489
|
+
} | {
|
|
490
|
+
readonly kind: 'dateTime';
|
|
491
|
+
readonly pattern: string;
|
|
492
|
+
readonly timeZone?: string;
|
|
493
|
+
readonly within?: {
|
|
494
|
+
readonly minMs: number;
|
|
495
|
+
readonly maxMs: number;
|
|
496
|
+
};
|
|
497
|
+
readonly padded?: boolean;
|
|
498
|
+
readonly invalidDay?: 'refuse' | 'rollover';
|
|
499
|
+
} | {
|
|
500
|
+
readonly kind: 'personName';
|
|
501
|
+
readonly decode?: boolean;
|
|
502
|
+
readonly punctuation?: 'keep' | 'drop' | 'space';
|
|
503
|
+
readonly case?: 'title' | 'asIs';
|
|
504
|
+
readonly caseLocale?: string;
|
|
505
|
+
readonly placeholders?: readonly string[];
|
|
506
|
+
readonly dropTokens?: RegExp;
|
|
507
|
+
} | {
|
|
508
|
+
readonly kind: 'flag';
|
|
509
|
+
readonly true?: readonly string[];
|
|
510
|
+
readonly false?: readonly string[];
|
|
511
|
+
readonly numericOne?: boolean;
|
|
512
|
+
} | {
|
|
513
|
+
readonly kind: 'enum';
|
|
514
|
+
readonly normalize?: 'snake';
|
|
515
|
+
readonly map: Readonly<Record<string, string>>;
|
|
516
|
+
readonly default: unknown;
|
|
517
|
+
} | {
|
|
518
|
+
readonly kind: 'int';
|
|
519
|
+
readonly min?: number;
|
|
520
|
+
readonly else: unknown;
|
|
521
|
+
} | {
|
|
522
|
+
readonly kind: 'phone';
|
|
523
|
+
readonly national?: number;
|
|
524
|
+
readonly country?: string;
|
|
525
|
+
readonly prefix?: string;
|
|
526
|
+
readonly plus?: boolean;
|
|
527
|
+
};
|
|
528
|
+
/**
|
|
529
|
+
* A list of days read out as one text (payment calendars, «until Friday …» lists). Days run from `start` to `end`
|
|
530
|
+
* (a date, or `{ days }` after the start), `rows: 'weekdays'` skips Saturday and Sunday. Each listed day is a row:
|
|
531
|
+
* `row` is evaluated with the locals `date` (`YYYY-MM-DD`), `day`, `month`, `year`, `weekday` (0 = Sunday), `offset`
|
|
532
|
+
* (days from today), `index` (0-based) and `word` (the day's word from `words.byOffset[offset]`, else
|
|
533
|
+
* `words.range` when `offset` is in `from`..`to`, else `''`). The first `firstRows.count` rows use `firstRows.row`.
|
|
534
|
+
* More than `maxListed` days: the first `maxListed` are listed and `tail` is added (locals `count`, `last`). Rows are
|
|
535
|
+
* joined with `join` (`lastJoin` before the last); `prefix` / `suffix` around the whole list; no day at all: `else`.
|
|
536
|
+
*/
|
|
537
|
+
export interface DayTable {
|
|
538
|
+
readonly start: Expr;
|
|
539
|
+
/** The last day, or `{ days }` after `start` (a number or an expression giving one). */
|
|
540
|
+
readonly end: Expr | {
|
|
541
|
+
readonly days: number | Expr;
|
|
542
|
+
};
|
|
543
|
+
readonly rows?: 'days' | 'weekdays';
|
|
544
|
+
/**
|
|
545
|
+
* Extra days listed with the range (also outside it; `rows` does not drop them), merged by date: a day already
|
|
546
|
+
* listed keeps its place and its `word` gets the extra one after it (joined by `wordSep`, default `', '`; empty words
|
|
547
|
+
* dropped). A `date` that is no day is skipped.
|
|
548
|
+
*/
|
|
549
|
+
readonly include?: readonly {
|
|
550
|
+
readonly date: Expr;
|
|
551
|
+
readonly word?: Expr;
|
|
552
|
+
}[];
|
|
553
|
+
readonly wordSep?: string;
|
|
554
|
+
/** Row order: by date (default) or by weekday Monday first (`monFirst`; days of one weekday by date). */
|
|
555
|
+
readonly order?: 'date' | 'monFirst';
|
|
556
|
+
/** Days the range lists at most (default 366: a guard against an end date years away). */
|
|
557
|
+
readonly maxDays?: number;
|
|
558
|
+
readonly maxListed?: number;
|
|
559
|
+
readonly tail?: Expr;
|
|
560
|
+
readonly words?: {
|
|
561
|
+
readonly byOffset?: Readonly<Record<number, Expr>>;
|
|
562
|
+
readonly range?: {
|
|
563
|
+
readonly from: number;
|
|
564
|
+
readonly to: number;
|
|
565
|
+
readonly word: Expr;
|
|
566
|
+
};
|
|
567
|
+
};
|
|
568
|
+
readonly row: Expr;
|
|
569
|
+
readonly firstRows?: {
|
|
570
|
+
readonly count: number;
|
|
571
|
+
readonly row: Expr;
|
|
572
|
+
};
|
|
573
|
+
readonly join: string;
|
|
574
|
+
readonly lastJoin?: string;
|
|
575
|
+
readonly prefix?: Expr;
|
|
576
|
+
readonly suffix?: Expr;
|
|
577
|
+
readonly else?: Expr;
|
|
578
|
+
}
|
|
579
|
+
/** A value written as it is. A list is a list of expressions. */
|
|
580
|
+
export type Literal = string | number | boolean | null;
|
|
581
|
+
/** A format of the locale packs (`FieldSpec.format`) or the `timestamp` kind (an instant on a wall clock). */
|
|
582
|
+
export type ExprFormat = string | {
|
|
583
|
+
readonly kind: string;
|
|
584
|
+
readonly locale?: LocaleCode;
|
|
585
|
+
readonly [k: string]: unknown;
|
|
586
|
+
};
|
|
587
|
+
/** A case of `cases`: the first whose `when` holds gives its value. */
|
|
588
|
+
export interface ExprCase {
|
|
589
|
+
readonly when: Condition;
|
|
590
|
+
readonly value: Expr;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* A value computed from the call, as data. Each operator is an object with one operator key (plus its options).
|
|
594
|
+
* See `skill/references/expressions.md` for every operator with an example.
|
|
595
|
+
*/
|
|
596
|
+
export type Expr = Literal | readonly Expr[] | RefExpr | ExprNode;
|
|
597
|
+
/** An expression in a slot that also takes other forms: a reference or an operator node (no bare literal or list). */
|
|
598
|
+
export type DataExpr = RefExpr | ExprNode;
|
|
599
|
+
export type ExprNode =
|
|
600
|
+
/** No value: a key left as it is (`remember`), a field not written, an object key dropped. */
|
|
601
|
+
{
|
|
602
|
+
readonly omit: true;
|
|
603
|
+
}
|
|
604
|
+
/** A literal object or list, not evaluated (`{ quote: { a: { var: 'x' } } }` is that object). */
|
|
605
|
+
| {
|
|
606
|
+
readonly quote: unknown;
|
|
607
|
+
} | {
|
|
608
|
+
readonly cases: readonly ExprCase[];
|
|
609
|
+
readonly else?: Expr;
|
|
610
|
+
} | {
|
|
611
|
+
readonly lookup: {
|
|
612
|
+
readonly of: Expr;
|
|
613
|
+
readonly table: Readonly<Record<string, Expr>>;
|
|
614
|
+
readonly key?: 'asIs' | 'trimLower' | 'noSpacesLower';
|
|
615
|
+
readonly default?: Expr;
|
|
616
|
+
};
|
|
617
|
+
} | {
|
|
618
|
+
readonly classify: {
|
|
619
|
+
readonly of: Expr;
|
|
620
|
+
readonly classes: Readonly<Record<string, readonly string[]>>;
|
|
621
|
+
readonly else?: Expr;
|
|
622
|
+
};
|
|
623
|
+
} | {
|
|
624
|
+
readonly bands: {
|
|
625
|
+
readonly of: Expr;
|
|
626
|
+
readonly steps: readonly {
|
|
627
|
+
readonly min?: number;
|
|
628
|
+
readonly max?: number;
|
|
629
|
+
readonly below?: number;
|
|
630
|
+
readonly value: Expr;
|
|
631
|
+
}[];
|
|
632
|
+
readonly else?: Expr;
|
|
633
|
+
};
|
|
634
|
+
} | {
|
|
635
|
+
readonly firstOf: readonly Expr[];
|
|
636
|
+
readonly when?: 'nonEmpty' | 'positive';
|
|
637
|
+
} | {
|
|
638
|
+
readonly test: Condition;
|
|
639
|
+
} | {
|
|
640
|
+
readonly let: Readonly<Record<string, Expr>>;
|
|
641
|
+
readonly value: Expr;
|
|
642
|
+
} | {
|
|
643
|
+
readonly template: string;
|
|
644
|
+
} | {
|
|
645
|
+
readonly join: Expr;
|
|
646
|
+
readonly sep?: string;
|
|
647
|
+
readonly lastSep?: string;
|
|
648
|
+
readonly dropEmpty?: boolean;
|
|
649
|
+
} | {
|
|
650
|
+
readonly nth: readonly Expr[];
|
|
651
|
+
} | {
|
|
652
|
+
readonly lines: readonly (Expr | {
|
|
653
|
+
readonly text: Expr;
|
|
654
|
+
readonly when: Condition;
|
|
655
|
+
})[];
|
|
656
|
+
readonly sep?: string;
|
|
657
|
+
} | {
|
|
658
|
+
readonly listPhrase: {
|
|
659
|
+
readonly of: Expr;
|
|
660
|
+
readonly max: number;
|
|
661
|
+
readonly more: Expr;
|
|
662
|
+
readonly empty?: Expr;
|
|
663
|
+
readonly sep?: string;
|
|
664
|
+
readonly lastSep?: string;
|
|
665
|
+
};
|
|
666
|
+
} | {
|
|
667
|
+
readonly render: {
|
|
668
|
+
readonly text: Readonly<Record<string, Expr>>;
|
|
669
|
+
readonly language?: Expr;
|
|
670
|
+
};
|
|
671
|
+
} | {
|
|
672
|
+
readonly upper: Expr;
|
|
673
|
+
} | {
|
|
674
|
+
readonly lower: Expr;
|
|
675
|
+
} | {
|
|
676
|
+
readonly trim: Expr;
|
|
677
|
+
} | {
|
|
678
|
+
readonly cap: Expr;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* `with`: a replacement text (`$1` …), or an expression evaluated for each match with the locals `match` (the matched
|
|
682
|
+
* text) and `groups` (its capture groups, `groups.1` …): `{ format: { kind: 'number', locale: 'en' }, of: { local: 'match' } }`
|
|
683
|
+
* spells every number of a text.
|
|
684
|
+
*/
|
|
685
|
+
| {
|
|
686
|
+
readonly replace: Expr;
|
|
687
|
+
readonly re: RegExp;
|
|
688
|
+
readonly with: string | DataExpr;
|
|
689
|
+
} | {
|
|
690
|
+
readonly capture: Expr;
|
|
691
|
+
readonly re: RegExp;
|
|
692
|
+
readonly group?: number | string;
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* The first rule whose `re` matches the text gives its `group` (default 1; a rule may be a bare RegExp); none matches:
|
|
696
|
+
* `else` (default the text itself).
|
|
697
|
+
*/
|
|
698
|
+
| {
|
|
699
|
+
readonly shorten: Expr;
|
|
700
|
+
readonly rules: readonly (RegExp | {
|
|
701
|
+
readonly re: RegExp;
|
|
702
|
+
readonly group?: number | string;
|
|
703
|
+
})[];
|
|
704
|
+
readonly else?: Expr;
|
|
705
|
+
} | {
|
|
706
|
+
readonly read: ReadSpec;
|
|
707
|
+
readonly of?: Expr;
|
|
708
|
+
} | {
|
|
709
|
+
readonly add: readonly Expr[];
|
|
710
|
+
} | {
|
|
711
|
+
readonly sub: readonly Expr[];
|
|
712
|
+
} | {
|
|
713
|
+
readonly mul: readonly Expr[];
|
|
714
|
+
} | {
|
|
715
|
+
readonly div: readonly Expr[];
|
|
716
|
+
}
|
|
717
|
+
/** A list of operands, or one expression giving a list (its numbers). */
|
|
718
|
+
| {
|
|
719
|
+
readonly min: readonly Expr[] | Expr;
|
|
720
|
+
} | {
|
|
721
|
+
readonly max: readonly Expr[] | Expr;
|
|
722
|
+
} | {
|
|
723
|
+
readonly sum: Expr;
|
|
724
|
+
}
|
|
725
|
+
/** JavaScript's remainder `a % b` (`null` when `b` is 0 or either is no number). */
|
|
726
|
+
| {
|
|
727
|
+
readonly mod: readonly [Expr, Expr];
|
|
728
|
+
} | {
|
|
729
|
+
readonly neg: Expr;
|
|
730
|
+
} | {
|
|
731
|
+
readonly abs: Expr;
|
|
732
|
+
} | {
|
|
733
|
+
readonly floor: Expr;
|
|
734
|
+
} | {
|
|
735
|
+
readonly ceil: Expr;
|
|
736
|
+
}
|
|
737
|
+
/** `mode: 'js'`: JavaScript's `Math.round(n * 10 ** digits) / 10 ** digits` (half up; default: half away from zero). */
|
|
738
|
+
| {
|
|
739
|
+
readonly round: Expr;
|
|
740
|
+
readonly digits?: number;
|
|
741
|
+
readonly mode?: 'js';
|
|
742
|
+
} | {
|
|
743
|
+
readonly ceilDiv: readonly [Expr, Expr];
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* `of / parts` rounded to the decimals `of` is written with. `out: 'decimalText'`: `of` read as text with JavaScript
|
|
747
|
+
* `Number`, rounded with `Math.round` at its own decimals and written with them (`'1000.50' / 3` → `'333.50'`,
|
|
748
|
+
* `'1000' / 3` → `'333'`); not a positive number: `''`.
|
|
749
|
+
*/
|
|
750
|
+
| {
|
|
751
|
+
readonly share: {
|
|
752
|
+
readonly of: Expr;
|
|
753
|
+
readonly parts: Expr;
|
|
754
|
+
readonly out?: 'number' | 'decimalText';
|
|
755
|
+
};
|
|
756
|
+
} | {
|
|
757
|
+
readonly percentOff: {
|
|
758
|
+
readonly of: Expr;
|
|
759
|
+
readonly percent: Expr;
|
|
760
|
+
};
|
|
761
|
+
} | {
|
|
762
|
+
readonly fixed: Expr;
|
|
763
|
+
readonly digits: number;
|
|
764
|
+
readonly trimZeros?: boolean;
|
|
765
|
+
readonly mode?: 'js';
|
|
766
|
+
} | {
|
|
767
|
+
readonly number: Expr;
|
|
768
|
+
} | {
|
|
769
|
+
readonly count: Expr;
|
|
770
|
+
} | {
|
|
771
|
+
readonly chars: Expr;
|
|
772
|
+
} | {
|
|
773
|
+
readonly daysBetween: readonly [Expr, Expr];
|
|
774
|
+
} | {
|
|
775
|
+
readonly addDays: readonly [Expr, Expr];
|
|
776
|
+
} | {
|
|
777
|
+
readonly latestDay: readonly Expr[];
|
|
778
|
+
} | {
|
|
779
|
+
readonly earliestDay: readonly Expr[];
|
|
780
|
+
} | {
|
|
781
|
+
readonly weekday: Expr;
|
|
782
|
+
}
|
|
783
|
+
/** The last day of that day's month (`YYYY-MM-DD`). */
|
|
784
|
+
| {
|
|
785
|
+
readonly endOfMonth: Expr;
|
|
786
|
+
}
|
|
787
|
+
/** The next day with this weekday (0 = Sunday) from `from` (default today), `from` itself when it is one (unless `skipToday`). */
|
|
788
|
+
| {
|
|
789
|
+
readonly nextWeekday: Expr;
|
|
790
|
+
readonly from?: Expr;
|
|
791
|
+
readonly skipToday?: boolean;
|
|
792
|
+
} | {
|
|
793
|
+
readonly daysUntil: Expr;
|
|
794
|
+
} | {
|
|
795
|
+
readonly secondsBetween: readonly [Expr, Expr];
|
|
796
|
+
}
|
|
797
|
+
/** `today`: the day the next such day is counted from (default the clock's). */
|
|
798
|
+
| {
|
|
799
|
+
readonly dayMonth: Expr;
|
|
800
|
+
readonly order?: 'monthFirst' | 'dayFirst';
|
|
801
|
+
readonly else?: Expr;
|
|
802
|
+
readonly today?: Expr;
|
|
803
|
+
} | {
|
|
804
|
+
readonly format: ExprFormat;
|
|
805
|
+
readonly of?: Expr;
|
|
806
|
+
readonly emptyAs?: Expr;
|
|
807
|
+
} | {
|
|
808
|
+
readonly dayTable: DayTable;
|
|
809
|
+
} | {
|
|
810
|
+
readonly pick: {
|
|
811
|
+
readonly seed: Expr;
|
|
812
|
+
readonly options: readonly Expr[];
|
|
813
|
+
readonly weights?: readonly number[];
|
|
814
|
+
readonly override?: Expr;
|
|
815
|
+
readonly emptySeed?: 'random' | 'first';
|
|
816
|
+
};
|
|
817
|
+
} | {
|
|
818
|
+
readonly pickOne: readonly Expr[];
|
|
819
|
+
} | {
|
|
820
|
+
readonly random: {
|
|
821
|
+
readonly int: readonly [number, number];
|
|
822
|
+
readonly step?: number;
|
|
823
|
+
} | {
|
|
824
|
+
readonly oneOf: readonly Expr[];
|
|
825
|
+
} | {
|
|
826
|
+
readonly digits: number;
|
|
827
|
+
} | {
|
|
828
|
+
readonly daysFromToday: readonly [number, number];
|
|
829
|
+
};
|
|
830
|
+
} | {
|
|
831
|
+
readonly hash: Expr;
|
|
832
|
+
readonly mod?: number;
|
|
833
|
+
readonly scale?: number;
|
|
834
|
+
} | {
|
|
835
|
+
readonly object: Readonly<Record<string, Expr>>;
|
|
836
|
+
readonly omitEmpty?: boolean;
|
|
837
|
+
} | {
|
|
838
|
+
readonly merge: readonly Expr[];
|
|
839
|
+
} | {
|
|
840
|
+
readonly zip: {
|
|
841
|
+
readonly keys: readonly string[];
|
|
842
|
+
readonly values: Expr;
|
|
843
|
+
};
|
|
844
|
+
} | {
|
|
845
|
+
readonly json: Expr;
|
|
846
|
+
} | {
|
|
847
|
+
readonly parseJson: Expr;
|
|
848
|
+
} | {
|
|
849
|
+
readonly list: Expr;
|
|
850
|
+
readonly split?: string;
|
|
851
|
+
} | {
|
|
852
|
+
readonly each: Expr;
|
|
853
|
+
readonly to: Expr;
|
|
854
|
+
} | {
|
|
855
|
+
readonly select: Expr;
|
|
856
|
+
readonly where: Condition;
|
|
857
|
+
} | {
|
|
858
|
+
readonly at: Expr;
|
|
859
|
+
readonly path: string | number;
|
|
860
|
+
} | {
|
|
861
|
+
readonly tokens: Expr;
|
|
862
|
+
readonly split: string;
|
|
863
|
+
readonly table: readonly (readonly [string, string])[];
|
|
864
|
+
} | {
|
|
865
|
+
readonly unique: Expr;
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* A choice set read off a text (`of`, default the line being handled): `chosen` the one option it picks (`null`: none
|
|
869
|
+
* or more), `picked` the options it picks, `said` the words that picked the chosen one, `named` the options whose
|
|
870
|
+
* value a number of the text equals; offers (read off the transcript, `ChoiceSetSpec`): `offer` the offer's id,
|
|
871
|
+
* `offerText`, `selected` the option names chosen, `complete` all its questions answered, `lastAsked`, `interested`,
|
|
872
|
+
* `headers` (of the restatement line `of`, default the last agent line).
|
|
873
|
+
*/
|
|
874
|
+
| {
|
|
875
|
+
readonly choice: string;
|
|
876
|
+
readonly op: 'chosen' | 'picked' | 'said' | 'named' | 'offer' | 'offerText' | 'selected' | 'complete' | 'lastAsked' | 'interested' | 'headers';
|
|
877
|
+
readonly of?: Expr;
|
|
878
|
+
}
|
|
879
|
+
/** The items the detectors find in the line being handled (`{ said, date, … }`), in order. */
|
|
880
|
+
| {
|
|
881
|
+
readonly detected: NoteDetector | readonly NoteDetector[];
|
|
882
|
+
}
|
|
883
|
+
/** The latest line of `who` that matches `match` and not `skip` (`''`: none). */
|
|
884
|
+
| {
|
|
885
|
+
readonly lastLineOf: {
|
|
886
|
+
readonly who: 'agent' | 'caller';
|
|
887
|
+
readonly match?: Matcher;
|
|
888
|
+
readonly skip?: Matcher;
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
/** `from`: the lines of a speaker-prefixed transcript text instead of the call's (as `TranscriptOptions.from`). */
|
|
892
|
+
| {
|
|
893
|
+
readonly transcript: {
|
|
894
|
+
readonly agent: string;
|
|
895
|
+
readonly caller: string;
|
|
896
|
+
readonly speakerSep?: string;
|
|
897
|
+
readonly lineSep?: string;
|
|
898
|
+
readonly heardOnly?: boolean;
|
|
899
|
+
readonly from?: TranscriptOptions['from'];
|
|
900
|
+
readonly collapse?: boolean;
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
/** Agent lines counted by class into one value (legacy KPI columns); see `LineTally`. */
|
|
904
|
+
| {
|
|
905
|
+
readonly lineTally: LineTally;
|
|
906
|
+
}
|
|
907
|
+
/** The report row written so far without these keys (in row order; keys holding `undefined` left out). */
|
|
908
|
+
| {
|
|
909
|
+
readonly rowExcept: readonly string[];
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
* The agent's last question sentence by sentence: the newest sentence ending in `?` that `skipSentence` does not match
|
|
913
|
+
* (`split: 'punctuation'`: a sentence ends after every run of `.!?…`, also without a space); `''` when none.
|
|
914
|
+
*/
|
|
915
|
+
| {
|
|
916
|
+
readonly lastAgentQuestion: {
|
|
917
|
+
readonly skipSentence?: Matcher;
|
|
918
|
+
readonly split?: 'spaced' | 'punctuation';
|
|
919
|
+
};
|
|
920
|
+
} | {
|
|
921
|
+
readonly lastAgentLanguage: {
|
|
922
|
+
readonly skipFirst?: boolean;
|
|
923
|
+
readonly letters?: Readonly<Record<string, LocaleCode>>;
|
|
924
|
+
readonly script?: Readonly<Record<string, 'cyrillic' | 'latin'>>;
|
|
925
|
+
readonly default: Expr;
|
|
926
|
+
};
|
|
927
|
+
} | {
|
|
928
|
+
readonly abArm: AbArm;
|
|
929
|
+
} | {
|
|
930
|
+
readonly scriptOf: ScriptOfExpr;
|
|
931
|
+
} | {
|
|
932
|
+
readonly replyAsr: LanguageFactMap & {
|
|
933
|
+
readonly ignore?: readonly string[];
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
/** `from`: the caller lines of a speaker-prefixed transcript text instead of the call's (as `TranscriptOptions.from`). */
|
|
937
|
+
| {
|
|
938
|
+
readonly languageRequested: LanguageFactMap & {
|
|
939
|
+
readonly from?: TranscriptOptions['from'];
|
|
940
|
+
};
|
|
941
|
+
};
|
|
942
|
+
/**
|
|
943
|
+
* The A/B arm of a call, `{ variant, source }`: the arm `override` names (a dialer column; a number arm only by a number
|
|
944
|
+
* or a text of digits) → `dialer`; with `enabled` false → `fallback` (default the first arm), `default`; else
|
|
945
|
+
* `arms[fnv1a(seed) % arms.length]` → `ab_test`, at random (the context's source) when the seed is empty
|
|
946
|
+
* (`emptySeed: 'first'`: the first arm).
|
|
947
|
+
*/
|
|
948
|
+
export interface AbArm {
|
|
949
|
+
readonly arms: readonly Expr[];
|
|
950
|
+
readonly seed: Expr;
|
|
951
|
+
readonly override?: Expr;
|
|
952
|
+
readonly emptySeed?: 'random' | 'first';
|
|
953
|
+
readonly enabled?: Condition;
|
|
954
|
+
readonly fallback?: Expr;
|
|
955
|
+
}
|
|
956
|
+
/** `scriptOf`: the key of the script a text is written in (see `ScriptRule`), else `else` (default null). */
|
|
957
|
+
export interface ScriptOfExpr extends ScriptRule {
|
|
958
|
+
readonly of: Expr;
|
|
959
|
+
readonly else?: Expr;
|
|
960
|
+
}
|
|
961
|
+
/** A language fact's key through `map` (a key the map lacks stays as it is); `default` when there is none. */
|
|
962
|
+
export interface LanguageFactMap {
|
|
963
|
+
readonly map?: Readonly<Record<string, Expr>>;
|
|
964
|
+
readonly default?: Expr;
|
|
965
|
+
}
|
|
966
|
+
/** Named matchers (`{ matcher: name }`) and named facts (`{ fact: name }`), `AgentSpec.matchers` / `AgentSpec.facts`. */
|
|
967
|
+
export type NamedMatchers = Readonly<Record<string, Matcher>>;
|
|
968
|
+
export type NamedFacts = Readonly<Record<string, NamedFact>>;
|
|
969
|
+
/** A named fact: a condition (`{ condition }`) or a value (`{ value }`); evaluated lazily, once per evaluation. */
|
|
970
|
+
export type NamedFact = {
|
|
971
|
+
readonly condition: Condition;
|
|
972
|
+
} | {
|
|
973
|
+
readonly value: Expr;
|
|
974
|
+
};
|
|
975
|
+
/**
|
|
976
|
+
* Everything an expression may read. Built by the slot that evaluates it (see `contextOf…` in `./context`); a test
|
|
977
|
+
* builds one with `exprContext`.
|
|
978
|
+
*/
|
|
979
|
+
export interface ExprContext {
|
|
980
|
+
/** The call (during it, or after it for report rows and integrations); absent while input fields are computed. */
|
|
981
|
+
readonly call?: CallView;
|
|
982
|
+
/** Call variables (`call.vars`, or the input fields computed so far). */
|
|
983
|
+
readonly vars: Readonly<Record<string, unknown>>;
|
|
984
|
+
/** The line being handled (a caller line of a rule, the text of a `Text` slot's line). */
|
|
985
|
+
readonly line?: string;
|
|
986
|
+
/** The report row being built (report fields, integrations, `remember`). */
|
|
987
|
+
readonly row?: Readonly<Record<string, unknown>>;
|
|
988
|
+
/** Extracted entities (defaults to `call.extracted`, then `call.outcome.entities`). */
|
|
989
|
+
readonly entities?: Readonly<Record<string, unknown>>;
|
|
990
|
+
/** The value the slot transforms (`{ self: true }`). */
|
|
991
|
+
readonly self?: unknown;
|
|
992
|
+
/** The hook place's input (`{ input: path }`). */
|
|
993
|
+
readonly input?: unknown;
|
|
994
|
+
/** Locals bound by enclosing operators (`{ local: name }`). */
|
|
995
|
+
readonly locals?: Readonly<Record<string, unknown>>;
|
|
996
|
+
/** Language words and formats: the reply language, and every language of the call. */
|
|
997
|
+
readonly locale: LocaleCode;
|
|
998
|
+
readonly languages: readonly LocaleCode[];
|
|
999
|
+
/** Wall clock: the zone of `input.timeZone` and the instant of the evaluation. */
|
|
1000
|
+
readonly timeZone: string;
|
|
1001
|
+
readonly now: Date;
|
|
1002
|
+
/** Random numbers in [0, 1) (the stand fixes it; the library default is `Math.random`). */
|
|
1003
|
+
readonly random: () => number;
|
|
1004
|
+
/** 1-based count of the acting rule (`nth`). */
|
|
1005
|
+
readonly nth?: number;
|
|
1006
|
+
/** `AgentSpec.matchers` / `AgentSpec.facts`. */
|
|
1007
|
+
readonly matchers?: NamedMatchers;
|
|
1008
|
+
readonly facts?: NamedFacts;
|
|
1009
|
+
/** The agent file's state blocks (`tracking`, `ladders`, `choices`) the conditions read. */
|
|
1010
|
+
readonly blocks?: StateBlocks;
|
|
1011
|
+
}
|