@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,404 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// █████ █████ █████
|
|
3
|
+
// ███ ███ ███
|
|
4
|
+
// ██████ █████ ████ ███████ ███████ ██████ █████ ████ ████████ ███████
|
|
5
|
+
// ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
|
|
6
|
+
// ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
|
|
7
|
+
// ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
|
|
8
|
+
// ██████ ████████ █████ ████████ ██████ ████████ ████ █████ ████████
|
|
9
|
+
//
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.scheduleNextLeg = exports.redialFailedLeg = exports.readAttemptWithRedials = exports.readFailedLegRedials = exports.FAILED_LEG_REDIALS_ENV_KEY = exports.scheduleOutboundFromDialogParams = exports.nameLegTrunk = exports.buildScheduleRouting = exports.readScheduleMsisdn = exports.readBulkUuidForSchedule = exports.FAILED_CALL_ENTRY_POINT = exports.SCHEDULE_OUTBOUND_PARAM_PROTO = exports.SCHEDULE_OUTBOUND_PARAM_ENTRY = exports.SCHEDULE_OUTBOUND_PARAM_BULK = exports.SCHEDULE_OUTBOUND_PARAM_POOL = exports.SCHEDULE_OUTBOUND_PARAM_TRUNK = exports.SCHEDULE_OUTBOUND_PARAM_MSISDN = void 0;
|
|
12
|
+
const agent_sdk_1 = require("@voctiv/agent-sdk");
|
|
13
|
+
const ledger_1 = require("./ledger");
|
|
14
|
+
/**
|
|
15
|
+
* Dialog-param keys used to thread legacy-V3 dialer routing data from the
|
|
16
|
+
* `dialog-initial` POST into a scheduled outbound call.
|
|
17
|
+
*
|
|
18
|
+
* Mirrors legacy `Calls.add_call(...)` columns (`trunk_id`, `pool_id`, `bulk_uuid`,
|
|
19
|
+
* `proto_additional`) so a scheduled call routes exactly like a logic-executor-
|
|
20
|
+
* scheduled one.
|
|
21
|
+
*/
|
|
22
|
+
exports.SCHEDULE_OUTBOUND_PARAM_MSISDN = 'scheduleOutboundMsisdn';
|
|
23
|
+
exports.SCHEDULE_OUTBOUND_PARAM_TRUNK = 'scheduleOutboundTrunkId';
|
|
24
|
+
exports.SCHEDULE_OUTBOUND_PARAM_POOL = 'scheduleOutboundPoolId';
|
|
25
|
+
exports.SCHEDULE_OUTBOUND_PARAM_BULK = 'scheduleOutboundBulkUuid';
|
|
26
|
+
exports.SCHEDULE_OUTBOUND_PARAM_ENTRY = 'scheduleOutboundEntryPoint';
|
|
27
|
+
exports.SCHEDULE_OUTBOUND_PARAM_PROTO = 'scheduleOutboundProtoAdditional';
|
|
28
|
+
/**
|
|
29
|
+
* Headless handler name stored as `on_failed_call` on every leg this script places. A
|
|
30
|
+
* dial that never reaches `200 OK` re-runs the script with `getScriptPhase(context) ===
|
|
31
|
+
* 'after_call_failed'`, which is where the failed attempt gets its output row
|
|
32
|
+
* (LOTASK-1735). Setting it disables the platform's own `recall_count` chain on that
|
|
33
|
+
* leg — the SDK makes the two mutually exclusive — so redials are scheduled by
|
|
34
|
+
* `runtime/recall.ts`.
|
|
35
|
+
*/
|
|
36
|
+
exports.FAILED_CALL_ENTRY_POINT = 'on_failed_call';
|
|
37
|
+
function parseOptionalDialogId(v) {
|
|
38
|
+
if (v === null || v === undefined || v === '')
|
|
39
|
+
return undefined;
|
|
40
|
+
const n = Number(v);
|
|
41
|
+
return Number.isFinite(n) ? Math.trunc(n) : undefined;
|
|
42
|
+
}
|
|
43
|
+
/** `call.bulk_uuid` like LE `Calls.add_call(..., bulk_uuid=dialog.bulk_uuid)`. */
|
|
44
|
+
function readBulkUuidForSchedule(context) {
|
|
45
|
+
const p = context.dialogParams ?? {};
|
|
46
|
+
const fromParams = p[exports.SCHEDULE_OUTBOUND_PARAM_BULK] ?? p['bulk_uuid'] ?? p['bulkUuid'];
|
|
47
|
+
if (typeof fromParams === 'string' && fromParams.trim())
|
|
48
|
+
return fromParams.trim();
|
|
49
|
+
const de = context.dialogEntity;
|
|
50
|
+
if (de && typeof de === 'object') {
|
|
51
|
+
const row = de;
|
|
52
|
+
const v = row['bulkUuid'] ?? row['bulk_uuid'];
|
|
53
|
+
if (typeof v === 'string' && v.trim())
|
|
54
|
+
return v.trim();
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
exports.readBulkUuidForSchedule = readBulkUuidForSchedule;
|
|
59
|
+
function readPoolIdForSchedule(context) {
|
|
60
|
+
const p = context.dialogParams ?? {};
|
|
61
|
+
return (parseOptionalDialogId(p[exports.SCHEDULE_OUTBOUND_PARAM_POOL]) ??
|
|
62
|
+
parseOptionalDialogId(p['pool_id']) ??
|
|
63
|
+
parseOptionalDialogId(p['poolId']));
|
|
64
|
+
}
|
|
65
|
+
/** LE `call.params.proto_additional` — string values on the SIP wire (over the agent's own `base` extras). */
|
|
66
|
+
function readProtoAdditionalForSchedule(context, logger, base) {
|
|
67
|
+
const p = context.dialogParams ?? {};
|
|
68
|
+
const raw = p[exports.SCHEDULE_OUTBOUND_PARAM_PROTO] ??
|
|
69
|
+
p['proto_additional'] ??
|
|
70
|
+
p['protoAdditional'];
|
|
71
|
+
const out = { ...(base ?? {}) };
|
|
72
|
+
if (raw === undefined || raw === null)
|
|
73
|
+
return Object.keys(out).length ? out : undefined;
|
|
74
|
+
if (typeof raw !== 'object' || Array.isArray(raw)) {
|
|
75
|
+
logger.log('[outbound] proto_additional ignored (expected object map of header -> string)');
|
|
76
|
+
return Object.keys(out).length ? out : undefined;
|
|
77
|
+
}
|
|
78
|
+
for (const [k, v] of Object.entries(raw)) {
|
|
79
|
+
const key = String(k).trim();
|
|
80
|
+
if (!key)
|
|
81
|
+
continue;
|
|
82
|
+
if (v == null || v === '')
|
|
83
|
+
continue;
|
|
84
|
+
out[key] = typeof v === 'string' ? v : String(v);
|
|
85
|
+
}
|
|
86
|
+
return Object.keys(out).length ? out : undefined;
|
|
87
|
+
}
|
|
88
|
+
/** Fixed SIP headers of the agent over the dialog params' own (a header named in both, in any case, is the agent's). */
|
|
89
|
+
function mergeProtoAdditional(fromParams, fixed) {
|
|
90
|
+
if (!fixed || Object.keys(fixed).length === 0)
|
|
91
|
+
return fromParams;
|
|
92
|
+
const fixedKeys = new Set(Object.keys(fixed).map((k) => k.toLowerCase()));
|
|
93
|
+
const out = {};
|
|
94
|
+
for (const [k, v] of Object.entries(fromParams ?? {}))
|
|
95
|
+
if (!fixedKeys.has(k.toLowerCase()))
|
|
96
|
+
out[k] = v;
|
|
97
|
+
return { ...out, ...fixed };
|
|
98
|
+
}
|
|
99
|
+
/** Destination number for a scheduled (re)call — dialog params, then the dialog row, then the leg. */
|
|
100
|
+
function readScheduleMsisdn(context, fromContext = true, numberAsText = false) {
|
|
101
|
+
const p = context.dialogParams ?? {};
|
|
102
|
+
const rawMsisdn = p[exports.SCHEDULE_OUTBOUND_PARAM_MSISDN] ??
|
|
103
|
+
p['msisdn'] ??
|
|
104
|
+
context.dialogEntity?.['msisdn'] ??
|
|
105
|
+
(fromContext ? context.msisdn : undefined);
|
|
106
|
+
if (!numberAsText)
|
|
107
|
+
return typeof rawMsisdn === 'string' ? rawMsisdn.trim() : '';
|
|
108
|
+
// A number the agent rewrites (`dialNumber`) is read as its decimal text too (dialers send either).
|
|
109
|
+
const shipped = typeof rawMsisdn === 'string'
|
|
110
|
+
? rawMsisdn.trim()
|
|
111
|
+
: typeof rawMsisdn === 'number' && Number.isFinite(rawMsisdn) ? String(rawMsisdn) : '';
|
|
112
|
+
return shipped;
|
|
113
|
+
}
|
|
114
|
+
exports.readScheduleMsisdn = readScheduleMsisdn;
|
|
115
|
+
/**
|
|
116
|
+
* Trunk / pool / bulk / proto routing shared by the initial outbound schedule and
|
|
117
|
+
* the script-scheduled recall (`runtime/recall.ts`), so a recall routes exactly
|
|
118
|
+
* like the original call.
|
|
119
|
+
*/
|
|
120
|
+
function buildScheduleRouting(context, logger, fixed = {}) {
|
|
121
|
+
const p = context.dialogParams ?? {};
|
|
122
|
+
const envSnapshot = context.env$?.getValue?.();
|
|
123
|
+
const trunkRaw = p[exports.SCHEDULE_OUTBOUND_PARAM_TRUNK] ??
|
|
124
|
+
p['trunk_id'] ??
|
|
125
|
+
p['trunkId'] ??
|
|
126
|
+
fixed.trunkId ??
|
|
127
|
+
envSnapshot?.['trunk'];
|
|
128
|
+
const trunkIdNum = parseOptionalDialogId(trunkRaw);
|
|
129
|
+
const trunkChannel = trunkRaw != null && String(trunkRaw).trim() !== ''
|
|
130
|
+
? String(trunkRaw).trim()
|
|
131
|
+
: undefined;
|
|
132
|
+
const poolId = readPoolIdForSchedule(context);
|
|
133
|
+
const bulkUuid = readBulkUuidForSchedule(context);
|
|
134
|
+
const protoAdditional = fixed.protoAdditionalOver
|
|
135
|
+
? mergeProtoAdditional(readProtoAdditionalForSchedule(context, logger), fixed.protoAdditional)
|
|
136
|
+
: readProtoAdditionalForSchedule(context, logger, fixed.protoAdditional);
|
|
137
|
+
return {
|
|
138
|
+
...(trunkIdNum != null
|
|
139
|
+
? { trunkId: trunkIdNum }
|
|
140
|
+
: trunkChannel
|
|
141
|
+
? { channel: trunkChannel }
|
|
142
|
+
: {}),
|
|
143
|
+
...(poolId != null ? { poolId } : {}),
|
|
144
|
+
...(bulkUuid ? { bulkUuid } : {}),
|
|
145
|
+
...(protoAdditional ? { protoAdditional } : {}),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
exports.buildScheduleRouting = buildScheduleRouting;
|
|
149
|
+
const legTrunks = new WeakMap();
|
|
150
|
+
/** Names the pool trunk of a route (`LegRoute` object) for the leg lines; returns the route. */
|
|
151
|
+
function nameLegTrunk(route, trunk) {
|
|
152
|
+
legTrunks.set(route, trunk);
|
|
153
|
+
return route;
|
|
154
|
+
}
|
|
155
|
+
exports.nameLegTrunk = nameLegTrunk;
|
|
156
|
+
/** Whether the dialog's msisdn may be a number value (read as its text): only for a `dialNumber`, unless switched off. */
|
|
157
|
+
function numberAsText(options) {
|
|
158
|
+
return options?.dialNumber != null && options.numberMsisdnAsText !== false;
|
|
159
|
+
}
|
|
160
|
+
/** The routing of one leg with the agent's own extras and re-routing applied. */
|
|
161
|
+
function legRouting(context, logger, msisdn, options) {
|
|
162
|
+
const routing = buildScheduleRouting(context, logger, {
|
|
163
|
+
...(options?.trunkId != null ? { trunkId: options.trunkId } : {}),
|
|
164
|
+
...(options?.protoAdditional ? { protoAdditional: options.protoAdditional } : {}),
|
|
165
|
+
...(options?.protoAdditionalOver ? { protoAdditionalOver: true } : {}),
|
|
166
|
+
});
|
|
167
|
+
const r = options?.route?.(msisdn) ?? null;
|
|
168
|
+
if (r == null)
|
|
169
|
+
return { msisdn, routing, rerouted: false };
|
|
170
|
+
const { trunkId: _t, channel: _c, ...rest } = routing;
|
|
171
|
+
void _t;
|
|
172
|
+
void _c;
|
|
173
|
+
// A trunk replaces the routing's in its place (the channel dropped).
|
|
174
|
+
const { channel: _c2, ...noChannel } = routing;
|
|
175
|
+
void _c2;
|
|
176
|
+
const base = r.channel
|
|
177
|
+
? { channel: r.channel, ...rest }
|
|
178
|
+
: r.trunkId != null
|
|
179
|
+
? { ...noChannel, trunkId: r.trunkId }
|
|
180
|
+
: routing;
|
|
181
|
+
const proto = r.protoAdditional ? { ...(routing.protoAdditional ?? {}), ...r.protoAdditional } : routing.protoAdditional;
|
|
182
|
+
const { protoAdditional: _p, ...noProto } = base;
|
|
183
|
+
void _p;
|
|
184
|
+
const trunk = legTrunks.get(r);
|
|
185
|
+
return { msisdn: r.msisdn, routing: { ...noProto, ...(proto ? { protoAdditional: proto } : {}) }, rerouted: true, ...(trunk ? { trunk } : {}) };
|
|
186
|
+
}
|
|
187
|
+
/** Dialog env flag: the pre-call pass placed the dialog's first leg. */
|
|
188
|
+
const OUTBOUND_SCHEDULED_ENV_KEY = 'outboundScheduled';
|
|
189
|
+
/** Phases that follow a call this dialog already made: dialing from them would redial in a loop. */
|
|
190
|
+
const PHASES_THAT_MUST_NOT_DIAL = new Set(['after_call_failed', 'after_call_success', 'recall', 'messaging']);
|
|
191
|
+
/**
|
|
192
|
+
* Places the outbound leg on the headless pre-call pass (`platform.call`, the `nn.call` analogue). Self-gates on
|
|
193
|
+
* `legacyV3Compat` + headless + a pre-call phase + an msisdn, so it can be called on every pass.
|
|
194
|
+
*
|
|
195
|
+
* Without `options` every leg carries {@link FAILED_CALL_ENTRY_POINT} (the default: a failed dial gets its own
|
|
196
|
+
* row and the script owns the redials); with `options`, only the `onFailedCall` they name.
|
|
197
|
+
*/
|
|
198
|
+
async function scheduleOutboundFromDialogParams(platform, context, logger, options,
|
|
199
|
+
/** Record the placed leg in the dialog's leg ledger (see `markLegScheduled`). */
|
|
200
|
+
ledger = false) {
|
|
201
|
+
if (!platform?.call || !context.legacyV3Compat || !context.headless) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const phase = (0, agent_sdk_1.getScriptPhase)(context);
|
|
205
|
+
if (PHASES_THAT_MUST_NOT_DIAL.has(phase) && !(options?.fromFailedPass && phase === 'after_call_failed')) {
|
|
206
|
+
if (!options?.quietAfterCall)
|
|
207
|
+
logger.log('[outbound] post-call phase — no call scheduled', { phase, entryPoint: context.entryPoint });
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const uploaded = readScheduleMsisdn(context, options?.msisdnFromContext !== false, numberAsText(options));
|
|
211
|
+
// `dialNumber` may find no number in the row either (no digits).
|
|
212
|
+
const msisdn = uploaded && options?.dialNumber ? options.dialNumber(uploaded) : uploaded;
|
|
213
|
+
if (!msisdn) {
|
|
214
|
+
logger.log('[outbound] no msisdn — skipping platform.call');
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const off = options?.platformRecallOff === true;
|
|
218
|
+
const env = (context.env$?.getValue?.() ?? {});
|
|
219
|
+
const calls = context.dialogEntity?.['calls'];
|
|
220
|
+
if (off && (env[OUTBOUND_SCHEDULED_ENV_KEY] === true || (Array.isArray(calls) && calls.length > 0))) {
|
|
221
|
+
logger.log('[outbound] already scheduled for this dialog — skipping duplicate before_call');
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const p = context.dialogParams ?? {};
|
|
225
|
+
const epRaw = p[exports.SCHEDULE_OUTBOUND_PARAM_ENTRY];
|
|
226
|
+
const entryPoint = typeof epRaw === 'string' && epRaw.trim() ? epRaw.trim() : 'main';
|
|
227
|
+
const leg = legRouting(context, logger, msisdn, options);
|
|
228
|
+
const routing = leg.routing;
|
|
229
|
+
const onFailedCall = options && !off ? options.onFailedCall : exports.FAILED_CALL_ENTRY_POINT;
|
|
230
|
+
const onSuccessCall = options?.onSuccessCall;
|
|
231
|
+
const callOptions = off
|
|
232
|
+
? { entryPoint, onFailedCall, recallCount: 0, recallDelay: 0, ...routing }
|
|
233
|
+
: options?.priority != null
|
|
234
|
+
? { entryPoint, ...(onFailedCall ? { onFailedCall } : {}), priority: options.priority, ...routing }
|
|
235
|
+
: options
|
|
236
|
+
? { entryPoint, ...routing, ...(onSuccessCall ? { onSuccessCall } : {}), ...(onFailedCall ? { onFailedCall } : {}) }
|
|
237
|
+
: { entryPoint, onFailedCall, ...routing };
|
|
238
|
+
try {
|
|
239
|
+
await platform.call(leg.msisdn, callOptions);
|
|
240
|
+
if (off) {
|
|
241
|
+
const env$ = context.env$;
|
|
242
|
+
if (env$?.next)
|
|
243
|
+
env$.next({ ...(env$.getValue?.() ?? {}), [OUTBOUND_SCHEDULED_ENV_KEY]: true });
|
|
244
|
+
else
|
|
245
|
+
logger.log('[outbound] scheduled, but the duplicate-before_call flag was not persisted');
|
|
246
|
+
}
|
|
247
|
+
if (ledger)
|
|
248
|
+
(0, ledger_1.markLegScheduled)(context, logger);
|
|
249
|
+
if (options?.trunkLog) {
|
|
250
|
+
logger.log('[outbound] platform.call scheduled (nn.call analogue)', {
|
|
251
|
+
msisdn, entryPoint, selectedTrunk: leg.trunk?.name, trunkNumber: leg.trunk?.callerId, trunkId: routing.trunkId,
|
|
252
|
+
});
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
logger.log('[outbound] platform.call scheduled (nn.call analogue)', {
|
|
256
|
+
msisdn,
|
|
257
|
+
entryPoint,
|
|
258
|
+
onFailedCall,
|
|
259
|
+
trunkId: routing.trunkId,
|
|
260
|
+
channel: routing.channel,
|
|
261
|
+
poolId: routing.poolId,
|
|
262
|
+
bulkUuid: routing.bulkUuid,
|
|
263
|
+
protoAdditionalKeys: routing.protoAdditional
|
|
264
|
+
? Object.keys(routing.protoAdditional)
|
|
265
|
+
: undefined,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
catch (e) {
|
|
269
|
+
logger.log('[outbound] platform.call failed', { err: String(e) });
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
exports.scheduleOutboundFromDialogParams = scheduleOutboundFromDialogParams;
|
|
273
|
+
/** Dialog env key: the redials the `after_call_failed` pass placed itself (see {@link redialFailedLeg}). */
|
|
274
|
+
exports.FAILED_LEG_REDIALS_ENV_KEY = 'failed_leg_redials';
|
|
275
|
+
function readFailedLegRedials(ctx) {
|
|
276
|
+
const env = ctx.env$?.getValue?.();
|
|
277
|
+
const raw = env?.[exports.FAILED_LEG_REDIALS_ENV_KEY];
|
|
278
|
+
return {
|
|
279
|
+
count: typeof raw?.count === 'number' && raw.count >= 0 ? Math.trunc(raw.count) : 0,
|
|
280
|
+
last_call_uuid: typeof raw?.last_call_uuid === 'string' ? raw.last_call_uuid : null,
|
|
281
|
+
last_due: typeof raw?.last_due === 'string' ? raw.last_due : null,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
exports.readFailedLegRedials = readFailedLegRedials;
|
|
285
|
+
/**
|
|
286
|
+
* Which attempt this run is when the failed-leg pass places its own redials: the platform counts only its own recalls,
|
|
287
|
+
* so the redials of {@link redialFailedLeg} before this leg count too (a pass that already redialled its own leg reads
|
|
288
|
+
* the attempt that leg was).
|
|
289
|
+
*/
|
|
290
|
+
function readAttemptWithRedials(ctx, callUuid) {
|
|
291
|
+
const record = readFailedLegRedials(ctx);
|
|
292
|
+
const own = record.last_call_uuid != null && record.last_call_uuid === callUuid;
|
|
293
|
+
const before = own ? Math.max(0, record.count - 1) : record.count;
|
|
294
|
+
const host = typeof ctx.attempt === 'number' ? ctx.attempt : 0;
|
|
295
|
+
return Math.max(host, before) + 1;
|
|
296
|
+
}
|
|
297
|
+
exports.readAttemptWithRedials = readAttemptWithRedials;
|
|
298
|
+
/**
|
|
299
|
+
* The `after_call_failed` pass of a leg nobody answered redials the number itself. A leg that names a failed-call
|
|
300
|
+
* handler gives up the platform's contact-rule recall (the host does not copy `recallCount` / `recallDelay` onto it),
|
|
301
|
+
* so the pass applies the same rule: at most `context.recallCount` redials (counted in the dialog env, not in
|
|
302
|
+
* `context.attempt`), `context.recallDelay` seconds from now, routed like the first leg and naming the same handler.
|
|
303
|
+
* Refused and logged rather than guessed: no dialog env, no delay, a second pass for a leg that already redialled.
|
|
304
|
+
* Never throws.
|
|
305
|
+
*/
|
|
306
|
+
async function redialFailedLeg(platform, context, logger, callUuid, options = {}, now = new Date()) {
|
|
307
|
+
const record = readFailedLegRedials(context);
|
|
308
|
+
const maxRedials = (0, agent_sdk_1.parseRecallCount)(context.recallCount) ?? null;
|
|
309
|
+
const delaySec = (0, agent_sdk_1.parseRecallDelaySeconds)(context.recallDelay);
|
|
310
|
+
let trunk;
|
|
311
|
+
const outcome = (reason, dueAt = null) => {
|
|
312
|
+
const result = { scheduled: reason === 'scheduled', reason, redialsSoFar: record.count, maxRedials, dueAt };
|
|
313
|
+
logger.log(result.scheduled ? 'failed_leg_redial_scheduled' : 'failed_leg_redial_skipped', options.trunkLog
|
|
314
|
+
? { ...result, callUuid, selectedTrunk: trunk?.name, trunkNumber: trunk?.callerId }
|
|
315
|
+
: { ...result, callUuid, recallCount: context.recallCount, recallDelay: context.recallDelay, onFailedCall: options.onFailedCall });
|
|
316
|
+
return result;
|
|
317
|
+
};
|
|
318
|
+
if (!context.headless || (0, agent_sdk_1.getScriptPhase)(context) !== 'after_call_failed')
|
|
319
|
+
return outcome('not_after_call_failed');
|
|
320
|
+
if (!platform?.call || !context.legacyV3Compat)
|
|
321
|
+
return outcome('platform_unavailable');
|
|
322
|
+
const env$ = context.env$;
|
|
323
|
+
if (env$ == null)
|
|
324
|
+
return outcome('no_env');
|
|
325
|
+
if (record.last_call_uuid != null && record.last_call_uuid === callUuid)
|
|
326
|
+
return outcome('already_redialled');
|
|
327
|
+
if (maxRedials == null || record.count >= maxRedials)
|
|
328
|
+
return outcome('recall_limit_reached');
|
|
329
|
+
if (delaySec == null)
|
|
330
|
+
return outcome('no_recall_delay');
|
|
331
|
+
const uploaded = readScheduleMsisdn(context, false, numberAsText(options));
|
|
332
|
+
const dialled = uploaded && options.dialNumber ? options.dialNumber(uploaded) : uploaded;
|
|
333
|
+
if (!dialled)
|
|
334
|
+
return outcome('no_msisdn');
|
|
335
|
+
const leg = legRouting(context, logger, dialled, options);
|
|
336
|
+
trunk = leg.trunk;
|
|
337
|
+
const msisdn = leg.msisdn;
|
|
338
|
+
const p = context.dialogParams ?? {};
|
|
339
|
+
const epRaw = p[exports.SCHEDULE_OUTBOUND_PARAM_ENTRY];
|
|
340
|
+
const entryPoint = typeof epRaw === 'string' && epRaw.trim() ? epRaw.trim() : 'main';
|
|
341
|
+
const due = new Date(now.getTime() + delaySec * 1000);
|
|
342
|
+
try {
|
|
343
|
+
await platform.call(msisdn, {
|
|
344
|
+
entryPoint, ...leg.routing, ...(options.onFailedCall ? { onFailedCall: options.onFailedCall } : {}), date: due,
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
catch (err) {
|
|
348
|
+
logger.log('failed_leg_redial_call_failed', { msisdn, dueAt: due.toISOString(), err: String(err) });
|
|
349
|
+
return outcome('call_failed');
|
|
350
|
+
}
|
|
351
|
+
const next = { count: record.count + 1, last_call_uuid: callUuid, last_due: due.toISOString() };
|
|
352
|
+
env$.next({ ...(env$.getValue?.() ?? {}), [exports.FAILED_LEG_REDIALS_ENV_KEY]: next });
|
|
353
|
+
try {
|
|
354
|
+
platform.dialog.result = 'pending';
|
|
355
|
+
}
|
|
356
|
+
catch {
|
|
357
|
+
/* a platform without the dialog API: the call row is what matters */
|
|
358
|
+
}
|
|
359
|
+
return outcome('scheduled', due.toISOString());
|
|
360
|
+
}
|
|
361
|
+
exports.redialFailedLeg = redialFailedLeg;
|
|
362
|
+
/**
|
|
363
|
+
* The dialog's next leg, placed by the script after a leg (an agent that owns its redials): routed like the first
|
|
364
|
+
* (`options`: the same handlers, extras and re-routing), `delaySec` from now. `true` when the call row was created.
|
|
365
|
+
*/
|
|
366
|
+
async function scheduleNextLeg(platform, context, logger, options) {
|
|
367
|
+
if (!platform?.call || !context.legacyV3Compat) {
|
|
368
|
+
logger.log('[outbound] platform.call unavailable — not scheduling', { reason: 'recall', legacyV3Compat: context.legacyV3Compat });
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
const uploaded = readScheduleMsisdn(context, options.msisdnFromContext !== false, numberAsText(options));
|
|
372
|
+
const number = uploaded && options.dialNumber ? options.dialNumber(uploaded) : uploaded;
|
|
373
|
+
if (!number) {
|
|
374
|
+
logger.log('[outbound] no msisdn — not scheduling', { reason: 'recall' });
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
// Not `context.entryPoint`: on an after-call pass it names the headless handler.
|
|
378
|
+
const p = context.dialogParams ?? {};
|
|
379
|
+
const epRaw = p[exports.SCHEDULE_OUTBOUND_PARAM_ENTRY];
|
|
380
|
+
const entryPoint = typeof epRaw === 'string' && epRaw.trim() ? epRaw.trim() : 'main';
|
|
381
|
+
const leg = legRouting(context, logger, number, options);
|
|
382
|
+
const delaySec = Math.max(0, Math.trunc(options.delaySec ?? 0));
|
|
383
|
+
const date = delaySec > 0 ? new Date(Date.now() + delaySec * 1000) : undefined;
|
|
384
|
+
const callOptions = {
|
|
385
|
+
entryPoint,
|
|
386
|
+
...(date ? { date } : {}),
|
|
387
|
+
...leg.routing,
|
|
388
|
+
...(options.onSuccessCall ? { onSuccessCall: options.onSuccessCall } : {}),
|
|
389
|
+
...(options.onFailedCall ? { onFailedCall: options.onFailedCall } : {}),
|
|
390
|
+
};
|
|
391
|
+
try {
|
|
392
|
+
await platform.call(leg.msisdn, callOptions);
|
|
393
|
+
logger.log('[outbound] platform.call scheduled (nn.call analogue)', {
|
|
394
|
+
reason: 'recall', msisdn: leg.msisdn, rerouted: leg.rerouted, delaySec, date: date?.toISOString(), entryPoint,
|
|
395
|
+
onSuccessCall: options.onSuccessCall, onFailedCall: options.onFailedCall,
|
|
396
|
+
});
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
catch (e) {
|
|
400
|
+
logger.log('[outbound] platform.call failed', { reason: 'recall', err: String(e) });
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
exports.scheduleNextLeg = scheduleNextLeg;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common per-call bookkeeping shape + the platform deep-link builder. Identical
|
|
3
|
+
* for every agent — only the CMS host URLs vary per deployment, so they are
|
|
4
|
+
* passed in as {@link CmsLinks}. Mirrors the `log_env(...)` fields written by
|
|
5
|
+
* `after_call_success` / `after_call_failed` in
|
|
6
|
+
* `sea_agent_boilerplate/agent_llm_boilerplate.py`.
|
|
7
|
+
*/
|
|
8
|
+
/** Platform host URLs used to construct the bookkeeping deep-links. */
|
|
9
|
+
export interface CmsLinks {
|
|
10
|
+
/** `_CMS_URL` — used for `call_log` and `call_record`. */
|
|
11
|
+
cmsUrl: string;
|
|
12
|
+
/** `_CMS_URL_LLM` — used for `call_llm_log`. */
|
|
13
|
+
cmsUrlLlm: string;
|
|
14
|
+
/** `_EXTRACT_URL` — used for `llm_dialog_link`. */
|
|
15
|
+
extractUrl: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Per-call bookkeeping captured by `script.ts`: ids, attempt counter, elapsed
|
|
19
|
+
* duration, and the accumulated USER/AGENT transcript. The flat fields plus
|
|
20
|
+
* URL helpers are merged into every `ScriptResult.output`.
|
|
21
|
+
*/
|
|
22
|
+
export interface CommonCallContext {
|
|
23
|
+
/** The conversation language the call ended in (the line state), when the agent reports it. */
|
|
24
|
+
replyLanguage?: string;
|
|
25
|
+
/** The reply language was still a provisional pick when the call ended. */
|
|
26
|
+
replyLanguageProvisional?: boolean;
|
|
27
|
+
callUuid: string;
|
|
28
|
+
dialogUuid: string;
|
|
29
|
+
agentUuid: string;
|
|
30
|
+
/** UUID OMNI uses to key the LLM dialog — i.e. whatever the script passes as
|
|
31
|
+
* `dialogUuid` to `channel.llm.stream()`. Currently equals `context.dialogUuid`. */
|
|
32
|
+
llmDialogUuid: string;
|
|
33
|
+
/** Recall attempt number, 1-indexed (matches `check_attempt()` semantics). */
|
|
34
|
+
attempt: number;
|
|
35
|
+
/**
|
|
36
|
+
* Wall-clock instant the call was anchored at, as epoch milliseconds. The SAME anchor
|
|
37
|
+
* {@link durationSec} is measured from, so `callStartedAtMs + durationSec` is exactly the
|
|
38
|
+
* moment the output was built — a consumer never has to reconstruct one from the other.
|
|
39
|
+
*/
|
|
40
|
+
callStartedAtMs: number;
|
|
41
|
+
/** Elapsed call seconds; `0` for headless / pre-call fallback. */
|
|
42
|
+
durationSec: number;
|
|
43
|
+
/**
|
|
44
|
+
* Seconds the ASR recognizer was UP, summed across every session this call opened
|
|
45
|
+
* (`runtime/asr-usage.ts`). Always ≤ {@link durationSec}: the engine comes up behind the
|
|
46
|
+
* opening phrase, and a call whose `createAsr` failed carries `0` here against a non-zero
|
|
47
|
+
* duration.
|
|
48
|
+
*
|
|
49
|
+
* Carried here but NOT emitted by {@link buildCommonFields}: the key it publishes under names
|
|
50
|
+
* the engine, which is per-deployment (`whisper_asr_duration` on this agent — see
|
|
51
|
+
* `agent/output.ts`), and this module is the agent-agnostic half.
|
|
52
|
+
*/
|
|
53
|
+
asrDurationSec: number;
|
|
54
|
+
/** Conversation text (USER / AGENT lines), `''` if nothing was captured. */
|
|
55
|
+
callTranscript: string;
|
|
56
|
+
/** The conversation line by line, with the mixer alias of each agent line. */
|
|
57
|
+
transcript?: readonly {
|
|
58
|
+
readonly role: 'agent' | 'user';
|
|
59
|
+
readonly text: string;
|
|
60
|
+
readonly unit: string | null;
|
|
61
|
+
}[];
|
|
62
|
+
/**
|
|
63
|
+
* `+OK` when the leg was answered, `-ERR` when it was not — the
|
|
64
|
+
* `after_call_success` / `after_call_failed` split of the Python boilerplate.
|
|
65
|
+
* It reports the CALL, not the run: a connected call whose post-call extraction
|
|
66
|
+
* failed is still `+OK`. {@link callStatus} carries the SIP code behind it.
|
|
67
|
+
*/
|
|
68
|
+
status: '+OK' | '-ERR';
|
|
69
|
+
/**
|
|
70
|
+
* SIP response code for the leg (`200`, `486`, `480`, `487`, …), `null` when the
|
|
71
|
+
* leg produced no response or the channel is not SIP. See `runtime/sip.ts`.
|
|
72
|
+
*/
|
|
73
|
+
callStatus: number | null;
|
|
74
|
+
/** Reason phrase that arrived with {@link callStatus} (`"OK"`, `"Busy Here"`, …). */
|
|
75
|
+
callStatusPhrase: string | null;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The common context of a leg whose SIP result is kept as the final status line (`'486 Busy Here'`) — the
|
|
79
|
+
* LLM-opening agents' report rows.
|
|
80
|
+
*/
|
|
81
|
+
export interface StatusLineCallContext {
|
|
82
|
+
callUuid: string;
|
|
83
|
+
dialogUuid: string;
|
|
84
|
+
agentUuid: string;
|
|
85
|
+
llmDialogUuid: string;
|
|
86
|
+
attempt: number;
|
|
87
|
+
durationSec: number;
|
|
88
|
+
/** Wall-clock ms of this dial attempt's start (platform `called_date`, else script attach). */
|
|
89
|
+
callStartedAtMs: number;
|
|
90
|
+
/** Final response to the INVITE, verbatim; `null` when the leg produced none. */
|
|
91
|
+
sipStatus: string | null;
|
|
92
|
+
callTranscript: string;
|
|
93
|
+
status: '+OK' | '-ERR';
|
|
94
|
+
}
|
|
95
|
+
/** `YYYY-MM-DDTHH:MM:SSZ` — UTC date-time with seconds and an explicit UTC marker. */
|
|
96
|
+
export declare function formatUtcCallStartTime(ms: number): string;
|
|
97
|
+
/**
|
|
98
|
+
* The common `log_env(...)` fields plus the platform deep-links. A context with a SIP code and phrase writes them
|
|
99
|
+
* with an ISO start time and the records-page link; a context with the status line writes the line, the start
|
|
100
|
+
* time to the second and the player link to the recording.
|
|
101
|
+
*/
|
|
102
|
+
export declare function buildCommonFields(c: CommonCallContext | StatusLineCallContext, cms: CmsLinks): Record<string, unknown>;
|
|
103
|
+
/**
|
|
104
|
+
* The row written when the agent's own row could not be built (its building threw): `result` `undefined`, `status`
|
|
105
|
+
* `-ERR`, no redial asked, and the service fields that are known (`common`, read without CMS links; `service` on top).
|
|
106
|
+
* Never throws: the report, the redial decision and the output go on with it.
|
|
107
|
+
*/
|
|
108
|
+
export declare function minimalRow(common: (() => CommonCallContext | StatusLineCallContext | undefined) | undefined, service?: Readonly<Record<string, unknown>>): Record<string, unknown>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// █████ █████
|
|
3
|
+
// ███ ███
|
|
4
|
+
// ██████ █████ ████ ███████ ████████ █████ ████ ███████
|
|
5
|
+
// ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
|
|
6
|
+
// ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
|
|
7
|
+
// ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
|
|
8
|
+
// ██████ ████████ █████ ███████ ████████ █████
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.minimalRow = exports.buildCommonFields = exports.formatUtcCallStartTime = void 0;
|
|
11
|
+
/** `YYYY-MM-DDTHH:MM:SSZ` — UTC date-time with seconds and an explicit UTC marker. */
|
|
12
|
+
function formatUtcCallStartTime(ms) {
|
|
13
|
+
const d = new Date(ms);
|
|
14
|
+
const t = d.getTime();
|
|
15
|
+
const iso = Number.isFinite(t) ? d.toISOString() : new Date().toISOString();
|
|
16
|
+
return `${iso.slice(0, 19)}Z`;
|
|
17
|
+
}
|
|
18
|
+
exports.formatUtcCallStartTime = formatUtcCallStartTime;
|
|
19
|
+
/**
|
|
20
|
+
* The common `log_env(...)` fields plus the platform deep-links. A context with a SIP code and phrase writes them
|
|
21
|
+
* with an ISO start time and the records-page link; a context with the status line writes the line, the start
|
|
22
|
+
* time to the second and the player link to the recording.
|
|
23
|
+
*/
|
|
24
|
+
function buildCommonFields(c, cms) {
|
|
25
|
+
const links = (record) => ({
|
|
26
|
+
call_transcript: c.callTranscript || null,
|
|
27
|
+
call_uuid: c.callUuid,
|
|
28
|
+
dialog_uuid: c.dialogUuid,
|
|
29
|
+
call_log: `${cms.cmsUrl}/logs?lng=en&agent_uuid=${c.agentUuid}&call_uuid=${c.callUuid}`,
|
|
30
|
+
call_llm_log: `${cms.cmsUrlLlm}/ext-logs-llm?lng=en&agent_uuid=${c.agentUuid}&dialogUuid=${c.llmDialogUuid}`,
|
|
31
|
+
call_record: record,
|
|
32
|
+
llm_dialog_uuid: c.llmDialogUuid,
|
|
33
|
+
llm_dialog_link: `${cms.extractUrl}/admin/agents/${c.agentUuid}/dialogs?dialogUuid=${c.llmDialogUuid}&dev=1`,
|
|
34
|
+
});
|
|
35
|
+
if ('sipStatus' in c) {
|
|
36
|
+
return {
|
|
37
|
+
status: c.status,
|
|
38
|
+
attempt: c.attempt,
|
|
39
|
+
duration: Math.max(0, Math.round(c.durationSec)),
|
|
40
|
+
call_start_time: formatUtcCallStartTime(c.callStartedAtMs),
|
|
41
|
+
call_status: c.sipStatus,
|
|
42
|
+
...links(`${cms.cmsUrl}/player?url=/api/v2/log/call/stream/${c.callUuid}`),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
status: c.status,
|
|
47
|
+
call_status: c.callStatus,
|
|
48
|
+
call_status_phrase: c.callStatusPhrase,
|
|
49
|
+
attempt: c.attempt,
|
|
50
|
+
call_start_time: new Date(c.callStartedAtMs).toISOString(),
|
|
51
|
+
duration: Math.max(0, Math.round(c.durationSec)),
|
|
52
|
+
...links(`${cms.cmsUrl}/records?lng=en&agent_uuid=${c.agentUuid}&call_uuid=${c.callUuid}`),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
exports.buildCommonFields = buildCommonFields;
|
|
56
|
+
/** The CMS link fields of {@link buildCommonFields} (left out of a row built without the deployment's hosts). */
|
|
57
|
+
const LINK_FIELDS = ['call_log', 'call_llm_log', 'call_record', 'llm_dialog_link'];
|
|
58
|
+
/**
|
|
59
|
+
* The row written when the agent's own row could not be built (its building threw): `result` `undefined`, `status`
|
|
60
|
+
* `-ERR`, no redial asked, and the service fields that are known (`common`, read without CMS links; `service` on top).
|
|
61
|
+
* Never throws: the report, the redial decision and the output go on with it.
|
|
62
|
+
*/
|
|
63
|
+
function minimalRow(common, service = {}) {
|
|
64
|
+
let known = {};
|
|
65
|
+
try {
|
|
66
|
+
const c = common?.();
|
|
67
|
+
if (c)
|
|
68
|
+
known = buildCommonFields(c, { cmsUrl: '', cmsUrlLlm: '', extractUrl: '' });
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
known = {};
|
|
72
|
+
}
|
|
73
|
+
for (const k of LINK_FIELDS)
|
|
74
|
+
delete known[k];
|
|
75
|
+
return { result: 'undefined', ...known, ...service, status: '-ERR', triggers_callback: false };
|
|
76
|
+
}
|
|
77
|
+
exports.minimalRow = minimalRow;
|