@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,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one way this runtime talks HTTP to an outside service — CRM relays, uMiddleware
|
|
3
|
+
* endpoints, anything an agent posts its result to. Everything else (LLM, ASR, TTS, the
|
|
4
|
+
* post-call extractor) goes through the host's own channel APIs and never reaches here.
|
|
5
|
+
*
|
|
6
|
+
* Why a wrapper rather than a bare `fetch`: a `200` is not proof the other side stored
|
|
7
|
+
* anything, and "we never received this" is the single most common integration dispute.
|
|
8
|
+
* Both ends need the same handle to grep for, so every request logs
|
|
9
|
+
*
|
|
10
|
+
* - `requestId` — what we SENT as `X-Request-Id` (the caller supplies it; the dialog uuid
|
|
11
|
+
* is the natural choice — it is the call's identity in every CMS log, link and report
|
|
12
|
+
* column, and stable across a retry of the same call);
|
|
13
|
+
* - `responseRequestId` — whatever the peer (or a proxy in front of it) echoed or minted
|
|
14
|
+
* in its own `x-request-id`, which is the id THEY can trace;
|
|
15
|
+
* - `processTime` — the peer's `x-process-time`, its own account of how long it spent,
|
|
16
|
+
* which separates "their backend is slow" from "the network is slow" without waiting
|
|
17
|
+
* for them to pull their logs.
|
|
18
|
+
*
|
|
19
|
+
* Both response headers are optional: a peer that sends neither simply logs `null`, and
|
|
20
|
+
* nothing about the request changes. This mirrors `request_with_retry()` in
|
|
21
|
+
* `sea_agent_boilerplate/agent_llm_boilerplate.py`, which logs the same two headers.
|
|
22
|
+
*
|
|
23
|
+
* Sandbox notes: the global `fetch` is the Node ≥ 18 one the ScriptEngine exposes;
|
|
24
|
+
* `process` is NOT available (see `agent/extraction/models.ts`), so a base URL or key
|
|
25
|
+
* comes from `agent/config.ts` or a CMS global variable via `context.storage(...)`.
|
|
26
|
+
*/
|
|
27
|
+
import type { ScriptLogger } from '@voctiv/agent-sdk';
|
|
28
|
+
/** Correlation header the peer is asked to log on its side. */
|
|
29
|
+
export declare const REQUEST_ID_HEADER = "X-Request-Id";
|
|
30
|
+
/** Correlation header read back off the response, when the peer sets one. */
|
|
31
|
+
export declare const RESPONSE_REQUEST_ID_HEADER = "x-request-id";
|
|
32
|
+
/** Peer-reported server-side handling time, when the peer sets one. */
|
|
33
|
+
export declare const PROCESS_TIME_HEADER = "x-process-time";
|
|
34
|
+
/** Request time limit when the caller gives none. */
|
|
35
|
+
export declare const DEFAULT_HTTP_TIMEOUT_MS = 15000;
|
|
36
|
+
/**
|
|
37
|
+
* Whether a thrown request error means the request certainly never reached the peer (DNS, refused connection,
|
|
38
|
+
* connect timeout) — safe to repeat even for a non-idempotent method. A timeout or a reset is not: the peer may
|
|
39
|
+
* have processed it.
|
|
40
|
+
*/
|
|
41
|
+
export declare function requestNotSent(err: unknown): boolean;
|
|
42
|
+
/** The URL for a log line: no query, no fragment, no credentials (they may carry ids, keys, a phone number). */
|
|
43
|
+
export declare function urlForLog(url: string): string;
|
|
44
|
+
/** What {@link httpRequest} returns — status, body text, and both correlation handles. */
|
|
45
|
+
export interface HttpRequestOutcome {
|
|
46
|
+
status: number;
|
|
47
|
+
/** Raw response body. Parse at the call site; this module stays content-agnostic. */
|
|
48
|
+
text: string;
|
|
49
|
+
/** `X-Request-Id` sent with the request, or `null` when the caller supplied none. */
|
|
50
|
+
requestId: string | null;
|
|
51
|
+
/** The peer's own `x-request-id`, or `null` when it sent none. */
|
|
52
|
+
responseRequestId: string | null;
|
|
53
|
+
/** The peer's own `x-process-time`, or `null` when it sent none. */
|
|
54
|
+
processTime: string | null;
|
|
55
|
+
/** Wall-clock ms the whole request took, measured here. */
|
|
56
|
+
ms: number;
|
|
57
|
+
}
|
|
58
|
+
export interface HttpRequestOptions {
|
|
59
|
+
method?: string;
|
|
60
|
+
headers?: Record<string, string>;
|
|
61
|
+
body?: string;
|
|
62
|
+
/** Abort after this many ms ({@link DEFAULT_HTTP_TIMEOUT_MS} when unset, `0`: no limit). The call then throws,
|
|
63
|
+
* like any other request failure. */
|
|
64
|
+
timeoutMs?: number;
|
|
65
|
+
/** Sent as `X-Request-Id`. Pass `context.dialogUuid` unless the peer requires its own
|
|
66
|
+
* format — the sandbox has no reliable randomness to mint one with (a pooled worker
|
|
67
|
+
* repeats `Math.random()` per call). */
|
|
68
|
+
requestId?: string;
|
|
69
|
+
/** Log-line event name, so a repo with several integrations can tell them apart.
|
|
70
|
+
* Default `'http_request'`. */
|
|
71
|
+
event?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* One HTTP request, with the correlation line logged whatever the outcome.
|
|
75
|
+
*
|
|
76
|
+
* Throws on a network failure or timeout (after logging `<event>_failed`) — the caller
|
|
77
|
+
* decides whether that is fatal, exactly as it decides what a non-2xx status means. The
|
|
78
|
+
* status is NOT interpreted here: a `409` may be the expected answer for one endpoint and
|
|
79
|
+
* a bug for another. A redirect is never followed: the 3xx comes back as the status (and
|
|
80
|
+
* `<event>_redirect_not_followed` is logged). The logged URL has no query string.
|
|
81
|
+
*
|
|
82
|
+
* ```ts
|
|
83
|
+
* const res = await httpRequest(logger, `${CRM_URL}/call_statistics`, {
|
|
84
|
+
* method: 'POST',
|
|
85
|
+
* headers: { 'Content-Type': 'application/json', 'x-api-key': apiKey },
|
|
86
|
+
* body: JSON.stringify(payload),
|
|
87
|
+
* timeoutMs: 5_000,
|
|
88
|
+
* requestId: context.dialogUuid,
|
|
89
|
+
* event: 'call_result',
|
|
90
|
+
* });
|
|
91
|
+
* if (res.status < 200 || res.status >= 300) { ... }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export declare function httpRequest(logger: ScriptLogger, url: string, options?: HttpRequestOptions): Promise<HttpRequestOutcome>;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// █████ █████ █████
|
|
3
|
+
// ███ ███ ███
|
|
4
|
+
// ███████ ███████ ███████ ████████
|
|
5
|
+
// ███ ███ ███ ███ ███ ███
|
|
6
|
+
// ███ ███ ███ ███ ███ ███
|
|
7
|
+
// ███ ███ ███ ███ ███ ███ ███ ███
|
|
8
|
+
// ████████ █████ █████ ███████
|
|
9
|
+
// ███
|
|
10
|
+
// ███
|
|
11
|
+
// █████
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.httpRequest = exports.urlForLog = exports.requestNotSent = exports.DEFAULT_HTTP_TIMEOUT_MS = exports.PROCESS_TIME_HEADER = exports.RESPONSE_REQUEST_ID_HEADER = exports.REQUEST_ID_HEADER = void 0;
|
|
14
|
+
/** Correlation header the peer is asked to log on its side. */
|
|
15
|
+
exports.REQUEST_ID_HEADER = 'X-Request-Id';
|
|
16
|
+
/** Correlation header read back off the response, when the peer sets one. */
|
|
17
|
+
exports.RESPONSE_REQUEST_ID_HEADER = 'x-request-id';
|
|
18
|
+
/** Peer-reported server-side handling time, when the peer sets one. */
|
|
19
|
+
exports.PROCESS_TIME_HEADER = 'x-process-time';
|
|
20
|
+
/** Request time limit when the caller gives none. */
|
|
21
|
+
exports.DEFAULT_HTTP_TIMEOUT_MS = 15_000;
|
|
22
|
+
/** Connection errors raised before any byte of the request reached the peer. */
|
|
23
|
+
const NOT_SENT_CODES = new Set([
|
|
24
|
+
'ECONNREFUSED',
|
|
25
|
+
'ENOTFOUND',
|
|
26
|
+
'EAI_AGAIN',
|
|
27
|
+
'EHOSTUNREACH',
|
|
28
|
+
'ENETUNREACH',
|
|
29
|
+
'UND_ERR_CONNECT_TIMEOUT',
|
|
30
|
+
]);
|
|
31
|
+
/**
|
|
32
|
+
* Whether a thrown request error means the request certainly never reached the peer (DNS, refused connection,
|
|
33
|
+
* connect timeout) — safe to repeat even for a non-idempotent method. A timeout or a reset is not: the peer may
|
|
34
|
+
* have processed it.
|
|
35
|
+
*/
|
|
36
|
+
function requestNotSent(err) {
|
|
37
|
+
for (let e = err, depth = 0; e && typeof e === 'object' && depth < 4; e = e.cause, depth++) {
|
|
38
|
+
const code = e.code;
|
|
39
|
+
if (typeof code === 'string' && NOT_SENT_CODES.has(code))
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
exports.requestNotSent = requestNotSent;
|
|
45
|
+
/** The URL for a log line: no query, no fragment, no credentials (they may carry ids, keys, a phone number). */
|
|
46
|
+
function urlForLog(url) {
|
|
47
|
+
try {
|
|
48
|
+
const u = new URL(url);
|
|
49
|
+
return `${u.protocol}//${u.host}${u.pathname}`;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return url.replace(/[?#][\s\S]*$/, '');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.urlForLog = urlForLog;
|
|
56
|
+
/**
|
|
57
|
+
* One HTTP request, with the correlation line logged whatever the outcome.
|
|
58
|
+
*
|
|
59
|
+
* Throws on a network failure or timeout (after logging `<event>_failed`) — the caller
|
|
60
|
+
* decides whether that is fatal, exactly as it decides what a non-2xx status means. The
|
|
61
|
+
* status is NOT interpreted here: a `409` may be the expected answer for one endpoint and
|
|
62
|
+
* a bug for another. A redirect is never followed: the 3xx comes back as the status (and
|
|
63
|
+
* `<event>_redirect_not_followed` is logged). The logged URL has no query string.
|
|
64
|
+
*
|
|
65
|
+
* ```ts
|
|
66
|
+
* const res = await httpRequest(logger, `${CRM_URL}/call_statistics`, {
|
|
67
|
+
* method: 'POST',
|
|
68
|
+
* headers: { 'Content-Type': 'application/json', 'x-api-key': apiKey },
|
|
69
|
+
* body: JSON.stringify(payload),
|
|
70
|
+
* timeoutMs: 5_000,
|
|
71
|
+
* requestId: context.dialogUuid,
|
|
72
|
+
* event: 'call_result',
|
|
73
|
+
* });
|
|
74
|
+
* if (res.status < 200 || res.status >= 300) { ... }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
async function httpRequest(logger, url, options = {}) {
|
|
78
|
+
const { method = 'GET', headers = {}, body, requestId, event = 'http_request', } = options;
|
|
79
|
+
const timeoutMs = options.timeoutMs ?? exports.DEFAULT_HTTP_TIMEOUT_MS;
|
|
80
|
+
const logUrl = urlForLog(url);
|
|
81
|
+
const startedAt = Date.now();
|
|
82
|
+
const ac = new AbortController();
|
|
83
|
+
const timer = timeoutMs > 0
|
|
84
|
+
? setTimeout(() => ac.abort(), timeoutMs)
|
|
85
|
+
: null;
|
|
86
|
+
try {
|
|
87
|
+
const res = await fetch(url, {
|
|
88
|
+
method,
|
|
89
|
+
headers: {
|
|
90
|
+
...headers,
|
|
91
|
+
...(requestId ? { [exports.REQUEST_ID_HEADER]: requestId } : {}),
|
|
92
|
+
},
|
|
93
|
+
...(body != null ? { body } : {}),
|
|
94
|
+
signal: ac.signal,
|
|
95
|
+
// A redirect is not followed: the request's headers (keys, tokens) must not go to another host.
|
|
96
|
+
redirect: 'manual',
|
|
97
|
+
});
|
|
98
|
+
// Both headers are optional and `headers` itself may be absent on a stub response —
|
|
99
|
+
// a peer that sends neither must not turn into a thrown TypeError here.
|
|
100
|
+
const responseRequestId = res.headers?.get(exports.RESPONSE_REQUEST_ID_HEADER) ?? null;
|
|
101
|
+
const processTime = res.headers?.get(exports.PROCESS_TIME_HEADER) ?? null;
|
|
102
|
+
const text = await res.text();
|
|
103
|
+
const outcome = {
|
|
104
|
+
status: res.status,
|
|
105
|
+
text,
|
|
106
|
+
requestId: requestId ?? null,
|
|
107
|
+
responseRequestId,
|
|
108
|
+
processTime,
|
|
109
|
+
ms: Date.now() - startedAt,
|
|
110
|
+
};
|
|
111
|
+
logger.log(event, {
|
|
112
|
+
url: logUrl,
|
|
113
|
+
method,
|
|
114
|
+
status: outcome.status,
|
|
115
|
+
requestId: outcome.requestId,
|
|
116
|
+
responseRequestId,
|
|
117
|
+
processTime,
|
|
118
|
+
ms: outcome.ms,
|
|
119
|
+
});
|
|
120
|
+
if (outcome.status >= 300 && outcome.status < 400) {
|
|
121
|
+
const location = res.headers?.get('location') ?? null;
|
|
122
|
+
logger.log(`${event}_redirect_not_followed`, {
|
|
123
|
+
url: logUrl,
|
|
124
|
+
status: outcome.status,
|
|
125
|
+
location: location ? urlForLog(location) : null,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return outcome;
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
logger.log(`${event}_failed`, {
|
|
132
|
+
url: logUrl,
|
|
133
|
+
method,
|
|
134
|
+
requestId: requestId ?? null,
|
|
135
|
+
ms: Date.now() - startedAt,
|
|
136
|
+
err: String(e),
|
|
137
|
+
});
|
|
138
|
+
throw e;
|
|
139
|
+
}
|
|
140
|
+
finally {
|
|
141
|
+
if (timer)
|
|
142
|
+
clearTimeout(timer);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.httpRequest = httpRequest;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ScriptDialogContext, ScriptLogger } from '@voctiv/agent-sdk';
|
|
2
|
+
export declare const LEDGER_ATTEMPTS_ENV_KEY = "dial_attempts";
|
|
3
|
+
export declare const LEGS_SCHEDULED_ENV_KEY = "dial_legs_scheduled";
|
|
4
|
+
export declare const LEG_DUE_AT_ENV_KEY = "dial_leg_due_at";
|
|
5
|
+
/** Least time from the due moment of a leg to a failure report for it (the dialer still has to originate it). */
|
|
6
|
+
export declare const FAILED_REPORT_FLOOR_MS = 1000;
|
|
7
|
+
/** Attempts counted for this dialog (`0` when none). */
|
|
8
|
+
export declare function readLedgerAttempts(ctx: ScriptDialogContext): number;
|
|
9
|
+
/** Legs this script placed; `null` on a dialog it placed none on (inbound, or legs placed by someone else). */
|
|
10
|
+
export declare function readLegsScheduled(ctx: ScriptDialogContext): number | null;
|
|
11
|
+
/** A leg this script placed is not counted yet. */
|
|
12
|
+
export declare function hasUncountedLeg(ctx: ScriptDialogContext): boolean;
|
|
13
|
+
/** Counts the leg of a live pass; the 1-indexed attempt. */
|
|
14
|
+
export declare function countLiveLeg(ctx: ScriptDialogContext, logger: ScriptLogger): number;
|
|
15
|
+
/** Counts a failed dial; `null` when the report cannot belong to an uncounted leg (a repeated report). */
|
|
16
|
+
export declare function countFailedLeg(ctx: ScriptDialogContext, logger: ScriptLogger): number | null;
|
|
17
|
+
/** Records a leg this script just placed, due at `dueAt` (now when the leg has no date). */
|
|
18
|
+
export declare function markLegScheduled(ctx: ScriptDialogContext, logger: ScriptLogger, dueAt?: Date): void;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.markLegScheduled = exports.countFailedLeg = exports.countLiveLeg = exports.hasUncountedLeg = exports.readLegsScheduled = exports.readLedgerAttempts = exports.FAILED_REPORT_FLOOR_MS = exports.LEG_DUE_AT_ENV_KEY = exports.LEGS_SCHEDULED_ENV_KEY = exports.LEDGER_ATTEMPTS_ENV_KEY = void 0;
|
|
4
|
+
exports.LEDGER_ATTEMPTS_ENV_KEY = 'dial_attempts';
|
|
5
|
+
exports.LEGS_SCHEDULED_ENV_KEY = 'dial_legs_scheduled';
|
|
6
|
+
exports.LEG_DUE_AT_ENV_KEY = 'dial_leg_due_at';
|
|
7
|
+
/** Least time from the due moment of a leg to a failure report for it (the dialer still has to originate it). */
|
|
8
|
+
exports.FAILED_REPORT_FLOOR_MS = 1_000;
|
|
9
|
+
function readEnv(ctx) {
|
|
10
|
+
return (ctx.env$?.getValue?.() ?? {});
|
|
11
|
+
}
|
|
12
|
+
function mergeEnv(ctx, patch) {
|
|
13
|
+
const env$ = ctx.env$;
|
|
14
|
+
if (!env$?.next)
|
|
15
|
+
return false;
|
|
16
|
+
env$.next({ ...readEnv(ctx), ...patch });
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
function readCounter(ctx, key) {
|
|
20
|
+
const raw = readEnv(ctx)[key];
|
|
21
|
+
if (raw === undefined || raw === null || raw === '')
|
|
22
|
+
return null;
|
|
23
|
+
const n = Number(raw);
|
|
24
|
+
return Number.isFinite(n) && n >= 0 ? Math.trunc(n) : null;
|
|
25
|
+
}
|
|
26
|
+
/** Attempts counted for this dialog (`0` when none). */
|
|
27
|
+
function readLedgerAttempts(ctx) {
|
|
28
|
+
return readCounter(ctx, exports.LEDGER_ATTEMPTS_ENV_KEY) ?? 0;
|
|
29
|
+
}
|
|
30
|
+
exports.readLedgerAttempts = readLedgerAttempts;
|
|
31
|
+
/** Legs this script placed; `null` on a dialog it placed none on (inbound, or legs placed by someone else). */
|
|
32
|
+
function readLegsScheduled(ctx) {
|
|
33
|
+
return readCounter(ctx, exports.LEGS_SCHEDULED_ENV_KEY);
|
|
34
|
+
}
|
|
35
|
+
exports.readLegsScheduled = readLegsScheduled;
|
|
36
|
+
/** A leg this script placed is not counted yet. */
|
|
37
|
+
function hasUncountedLeg(ctx) {
|
|
38
|
+
const scheduled = readLegsScheduled(ctx);
|
|
39
|
+
return scheduled !== null && scheduled > readLedgerAttempts(ctx);
|
|
40
|
+
}
|
|
41
|
+
exports.hasUncountedLeg = hasUncountedLeg;
|
|
42
|
+
function count(ctx, logger, kind) {
|
|
43
|
+
const attempt = readLedgerAttempts(ctx) + 1;
|
|
44
|
+
const persisted = mergeEnv(ctx, { [exports.LEDGER_ATTEMPTS_ENV_KEY]: attempt });
|
|
45
|
+
logger.log(persisted ? 'dial attempt counted' : 'attempt_counter_env_unavailable — count not persisted', {
|
|
46
|
+
kind, attempt, legsScheduled: readLegsScheduled(ctx), contextAttempt: ctx.attempt ?? null,
|
|
47
|
+
});
|
|
48
|
+
return attempt;
|
|
49
|
+
}
|
|
50
|
+
/** Counts the leg of a live pass; the 1-indexed attempt. */
|
|
51
|
+
function countLiveLeg(ctx, logger) {
|
|
52
|
+
return count(ctx, logger, 'live');
|
|
53
|
+
}
|
|
54
|
+
exports.countLiveLeg = countLiveLeg;
|
|
55
|
+
/** Counts a failed dial; `null` when the report cannot belong to an uncounted leg (a repeated report). */
|
|
56
|
+
function countFailedLeg(ctx, logger) {
|
|
57
|
+
const scheduled = readLegsScheduled(ctx);
|
|
58
|
+
const dueAt = readCounter(ctx, exports.LEG_DUE_AT_ENV_KEY);
|
|
59
|
+
const allCounted = scheduled !== null && scheduled <= readLedgerAttempts(ctx);
|
|
60
|
+
const notDue = dueAt !== null && Date.now() < dueAt + exports.FAILED_REPORT_FLOOR_MS;
|
|
61
|
+
if (allCounted || notDue) {
|
|
62
|
+
logger.log('failed dial already counted — duplicate report ignored', {
|
|
63
|
+
attempt: readLedgerAttempts(ctx),
|
|
64
|
+
legsScheduled: scheduled,
|
|
65
|
+
legDueAt: dueAt !== null ? new Date(dueAt).toISOString() : null,
|
|
66
|
+
reason: allCounted ? 'every placed leg counted' : 'latest leg not due',
|
|
67
|
+
});
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return count(ctx, logger, 'failed');
|
|
71
|
+
}
|
|
72
|
+
exports.countFailedLeg = countFailedLeg;
|
|
73
|
+
/** Records a leg this script just placed, due at `dueAt` (now when the leg has no date). */
|
|
74
|
+
function markLegScheduled(ctx, logger, dueAt) {
|
|
75
|
+
const legsScheduled = Math.max(readLegsScheduled(ctx) ?? 0, readLedgerAttempts(ctx)) + 1;
|
|
76
|
+
const persisted = mergeEnv(ctx, { [exports.LEGS_SCHEDULED_ENV_KEY]: legsScheduled, [exports.LEG_DUE_AT_ENV_KEY]: dueAt?.getTime() ?? Date.now() });
|
|
77
|
+
if (!persisted)
|
|
78
|
+
logger.log('leg_ledger_env_unavailable — scheduled leg not recorded', { legsScheduled });
|
|
79
|
+
}
|
|
80
|
+
exports.markLegScheduled = markLegScheduled;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LlmStreamChunk } from '@voctiv/agent-sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Tool/event names of one LLM chunk (template runtime/llm.ts `extractToolNames`): `chunk.event` (Omni event tool
|
|
4
|
+
* `{ name: 'bridge' }`), `chunk.toolMessages`, `chunk.raw.event`; a name string, an object with a name-ish key, or
|
|
5
|
+
* an array of either. Lower-cased.
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractToolNames(chunk: LlmStreamChunk): string[];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractToolNames = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Tool/event names of one LLM chunk (template runtime/llm.ts `extractToolNames`): `chunk.event` (Omni event tool
|
|
6
|
+
* `{ name: 'bridge' }`), `chunk.toolMessages`, `chunk.raw.event`; a name string, an object with a name-ish key, or
|
|
7
|
+
* an array of either. Lower-cased.
|
|
8
|
+
*/
|
|
9
|
+
function extractToolNames(chunk) {
|
|
10
|
+
const out = [];
|
|
11
|
+
const push = (n) => {
|
|
12
|
+
if (typeof n === 'string' && n.trim())
|
|
13
|
+
out.push(n.trim().toLowerCase());
|
|
14
|
+
};
|
|
15
|
+
const fromEntry = (m) => {
|
|
16
|
+
if (typeof m === 'string')
|
|
17
|
+
return push(m);
|
|
18
|
+
if (m && typeof m === 'object') {
|
|
19
|
+
const o = m;
|
|
20
|
+
push(o['name']);
|
|
21
|
+
push(o['tool_name']);
|
|
22
|
+
push(o['toolName']);
|
|
23
|
+
push(o['function']?.['name']);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const fromContainer = (c) => {
|
|
27
|
+
if (c == null)
|
|
28
|
+
return;
|
|
29
|
+
if (Array.isArray(c))
|
|
30
|
+
for (const m of c)
|
|
31
|
+
fromEntry(m);
|
|
32
|
+
else
|
|
33
|
+
fromEntry(c);
|
|
34
|
+
};
|
|
35
|
+
const c = chunk;
|
|
36
|
+
fromContainer(c.event);
|
|
37
|
+
fromContainer(c.toolMessages);
|
|
38
|
+
fromContainer(c.raw?.['event']);
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
exports.extractToolNames = extractToolNames;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type MediaChannel, type ScriptDialogContext, type ScriptLogger } from '@voctiv/agent-sdk';
|
|
2
|
+
/**
|
|
3
|
+
* CMS input entities (`io get-initial`) this dialog did not receive as params (API / bootfile), in list order. A
|
|
4
|
+
* key sent with a `null` value counts as received; `msisdn` also counts when the platform filled `ctx.msisdn`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function findMissingInputEntities(ctx: ScriptDialogContext, inputEntities: readonly string[]): string[];
|
|
7
|
+
/**
|
|
8
|
+
* One structured line on every pass: identity, telephony routing, the SIP `X-*` headers and the agent-built render
|
|
9
|
+
* payload (every bag passed through {@link sanitizeForLog}: secret-looking keys redacted at any depth).
|
|
10
|
+
*
|
|
11
|
+
* Two forms. Without `channel`: the run's lifecycle (phase, entry point, attempt, CMS recall rule) and the header bag
|
|
12
|
+
* sanitized. With `channel` (and the agent's CMS input entities): the inbound INVITE header snapshot and the header
|
|
13
|
+
* bag (only secret-looking keys redacted) — the campaign data is what wrong-customer-data questions are answered from — and
|
|
14
|
+
* `missingInputEntities`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function logIntegrationContext(logger: ScriptLogger, ctx: ScriptDialogContext, tag: string, renderPayload: Record<string, unknown>, ...headers: [channel?: MediaChannel, inputEntities?: readonly string[]]): void;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ████ ███
|
|
3
|
+
// ███
|
|
4
|
+
// ███ ██████ ███████ ███████ ████ ████████ ███████
|
|
5
|
+
// ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
|
|
6
|
+
// ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
|
|
7
|
+
// ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
|
|
8
|
+
// █████ ██████ ███████ ███████ █████ ████ █████ ███████
|
|
9
|
+
// ███ ███ ███
|
|
10
|
+
// ███ ███ ███ ███ ███ ███
|
|
11
|
+
// ██████ ██████ ██████
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.logIntegrationContext = exports.findMissingInputEntities = void 0;
|
|
14
|
+
const agent_sdk_1 = require("@voctiv/agent-sdk");
|
|
15
|
+
const env_1 = require("./env");
|
|
16
|
+
const sanitize_1 = require("./sanitize");
|
|
17
|
+
const sip_1 = require("./sip");
|
|
18
|
+
/**
|
|
19
|
+
* CMS input entities (`io get-initial`) this dialog did not receive as params (API / bootfile), in list order. A
|
|
20
|
+
* key sent with a `null` value counts as received; `msisdn` also counts when the platform filled `ctx.msisdn`.
|
|
21
|
+
*/
|
|
22
|
+
function findMissingInputEntities(ctx, inputEntities) {
|
|
23
|
+
const params = ctx.dialogParams ?? {};
|
|
24
|
+
const initial = ctx.initialData ?? {};
|
|
25
|
+
return inputEntities.filter((name) => !(name in params) && !(name in initial) && !(name === 'msisdn' && ctx.msisdn));
|
|
26
|
+
}
|
|
27
|
+
exports.findMissingInputEntities = findMissingInputEntities;
|
|
28
|
+
/**
|
|
29
|
+
* One structured line on every pass: identity, telephony routing, the SIP `X-*` headers and the agent-built render
|
|
30
|
+
* payload (every bag passed through {@link sanitizeForLog}: secret-looking keys redacted at any depth).
|
|
31
|
+
*
|
|
32
|
+
* Two forms. Without `channel`: the run's lifecycle (phase, entry point, attempt, CMS recall rule) and the header bag
|
|
33
|
+
* sanitized. With `channel` (and the agent's CMS input entities): the inbound INVITE header snapshot and the header
|
|
34
|
+
* bag (only secret-looking keys redacted) — the campaign data is what wrong-customer-data questions are answered from — and
|
|
35
|
+
* `missingInputEntities`.
|
|
36
|
+
*/
|
|
37
|
+
function logIntegrationContext(logger, ctx, tag, renderPayload, ...headers) {
|
|
38
|
+
const direction = ctx.callEntity?.direction;
|
|
39
|
+
const protoAdditional = (0, env_1.readProtoAdditional)(ctx);
|
|
40
|
+
const headerForm = headers.length > 0;
|
|
41
|
+
const [channel, inputEntities = []] = headers;
|
|
42
|
+
const sipHeaders = channel ? (0, sip_1.readInviteSipHeaders)(channel) : undefined;
|
|
43
|
+
const identity = {
|
|
44
|
+
dialogUuid: ctx.dialogUuid,
|
|
45
|
+
callUuid: (0, env_1.readCallUuid)(ctx),
|
|
46
|
+
scriptId: ctx.scriptId,
|
|
47
|
+
scriptName: ctx.scriptName,
|
|
48
|
+
agentUuid: ctx.agentUuid,
|
|
49
|
+
legacyV3Compat: ctx.legacyV3Compat,
|
|
50
|
+
headless: ctx.headless,
|
|
51
|
+
};
|
|
52
|
+
const telephony = {
|
|
53
|
+
msisdn: renderPayload['msisdn'] || ctx.msisdn,
|
|
54
|
+
callerId: ctx.callerId,
|
|
55
|
+
destinationNumber: ctx.destinationNumber,
|
|
56
|
+
direction,
|
|
57
|
+
trunk: (0, env_1.readTrunkId)(ctx),
|
|
58
|
+
lang: ctx.lang,
|
|
59
|
+
language: ctx.language,
|
|
60
|
+
flag: ctx.flag,
|
|
61
|
+
};
|
|
62
|
+
if (headerForm) {
|
|
63
|
+
logger.log(`${tag} integration context`, {
|
|
64
|
+
identity,
|
|
65
|
+
telephony,
|
|
66
|
+
sipHeaders: (0, sanitize_1.sanitizeForLog)(sipHeaders),
|
|
67
|
+
sipHeaderKeys: sipHeaders ? Object.keys(sipHeaders) : undefined,
|
|
68
|
+
protoAdditional: (0, sanitize_1.sanitizeForLog)(protoAdditional),
|
|
69
|
+
renderPayload: (0, sanitize_1.sanitizeForLog)(renderPayload),
|
|
70
|
+
dialogParams: (0, sanitize_1.sanitizeForLog)(ctx.dialogParams),
|
|
71
|
+
initialData: (0, sanitize_1.sanitizeForLog)(ctx.initialData),
|
|
72
|
+
missingInputEntities: inputEntities.length ? findMissingInputEntities(ctx, inputEntities) : undefined,
|
|
73
|
+
});
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
logger.log(`${tag} integration context`, {
|
|
77
|
+
identity,
|
|
78
|
+
lifecycle: {
|
|
79
|
+
phase: (0, agent_sdk_1.getScriptPhase)(ctx),
|
|
80
|
+
entryPoint: ctx.entryPoint,
|
|
81
|
+
attempt: ctx.attempt,
|
|
82
|
+
recallCount: ctx.recallCount,
|
|
83
|
+
recallDelay: ctx.recallDelay,
|
|
84
|
+
},
|
|
85
|
+
telephony,
|
|
86
|
+
protoAdditional: (0, sanitize_1.sanitizeForLog)(protoAdditional),
|
|
87
|
+
renderPayload: (0, sanitize_1.sanitizeForLog)(renderPayload),
|
|
88
|
+
dialogParams: (0, sanitize_1.sanitizeForLog)(ctx.dialogParams),
|
|
89
|
+
initialData: (0, sanitize_1.sanitizeForLog)(ctx.initialData),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
exports.logIntegrationContext = logIntegrationContext;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { type PlatformApi, type ScheduleCallOptions, type ScriptDialogContext, type ScriptLogger } from '@voctiv/agent-sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Dialog-param keys used to thread legacy-V3 dialer routing data from the
|
|
4
|
+
* `dialog-initial` POST into a scheduled outbound call.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors legacy `Calls.add_call(...)` columns (`trunk_id`, `pool_id`, `bulk_uuid`,
|
|
7
|
+
* `proto_additional`) so a scheduled call routes exactly like a logic-executor-
|
|
8
|
+
* scheduled one.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SCHEDULE_OUTBOUND_PARAM_MSISDN = "scheduleOutboundMsisdn";
|
|
11
|
+
export declare const SCHEDULE_OUTBOUND_PARAM_TRUNK = "scheduleOutboundTrunkId";
|
|
12
|
+
export declare const SCHEDULE_OUTBOUND_PARAM_POOL = "scheduleOutboundPoolId";
|
|
13
|
+
export declare const SCHEDULE_OUTBOUND_PARAM_BULK = "scheduleOutboundBulkUuid";
|
|
14
|
+
export declare const SCHEDULE_OUTBOUND_PARAM_ENTRY = "scheduleOutboundEntryPoint";
|
|
15
|
+
export declare const SCHEDULE_OUTBOUND_PARAM_PROTO = "scheduleOutboundProtoAdditional";
|
|
16
|
+
/**
|
|
17
|
+
* Headless handler name stored as `on_failed_call` on every leg this script places. A
|
|
18
|
+
* dial that never reaches `200 OK` re-runs the script with `getScriptPhase(context) ===
|
|
19
|
+
* 'after_call_failed'`, which is where the failed attempt gets its output row
|
|
20
|
+
* (LOTASK-1735). Setting it disables the platform's own `recall_count` chain on that
|
|
21
|
+
* leg — the SDK makes the two mutually exclusive — so redials are scheduled by
|
|
22
|
+
* `runtime/recall.ts`.
|
|
23
|
+
*/
|
|
24
|
+
export declare const FAILED_CALL_ENTRY_POINT = "on_failed_call";
|
|
25
|
+
/** `call.bulk_uuid` like LE `Calls.add_call(..., bulk_uuid=dialog.bulk_uuid)`. */
|
|
26
|
+
export declare function readBulkUuidForSchedule(context: ScriptDialogContext): string | undefined;
|
|
27
|
+
/** Destination number for a scheduled (re)call — dialog params, then the dialog row, then the leg. */
|
|
28
|
+
export declare function readScheduleMsisdn(context: ScriptDialogContext, fromContext?: boolean, numberAsText?: boolean): string;
|
|
29
|
+
/**
|
|
30
|
+
* Trunk / pool / bulk / proto routing shared by the initial outbound schedule and
|
|
31
|
+
* the script-scheduled recall (`runtime/recall.ts`), so a recall routes exactly
|
|
32
|
+
* like the original call.
|
|
33
|
+
*/
|
|
34
|
+
export declare function buildScheduleRouting(context: ScriptDialogContext, logger: ScriptLogger, fixed?: {
|
|
35
|
+
readonly trunkId?: number;
|
|
36
|
+
readonly protoAdditional?: Readonly<Record<string, string>>;
|
|
37
|
+
readonly protoAdditionalOver?: boolean;
|
|
38
|
+
}): Pick<ScheduleCallOptions, 'trunkId' | 'channel' | 'poolId' | 'bulkUuid' | 'protoAdditional'>;
|
|
39
|
+
/** What a leg that never connects runs next (see {@link scheduleOutboundFromDialogParams}). */
|
|
40
|
+
export interface ScheduleOutboundOptions {
|
|
41
|
+
/** A pass after a call places no leg without the `post-call phase` log line. */
|
|
42
|
+
readonly quietAfterCall?: boolean;
|
|
43
|
+
/** Headless handler stored as `on_failed_call`; it also turns off the host's own recall chain on that leg. */
|
|
44
|
+
readonly onFailedCall?: string;
|
|
45
|
+
/**
|
|
46
|
+
* The leg carries `recallCount: 0, recallDelay: 0` (the platform's own recall off), and the dialog's first leg is
|
|
47
|
+
* placed once: a repeated pre-call pass (or a dialog that already has a call) places none.
|
|
48
|
+
*/
|
|
49
|
+
readonly platformRecallOff?: boolean;
|
|
50
|
+
/** `priority` of the scheduled leg (written after `onFailedCall`, before the routing). */
|
|
51
|
+
readonly priority?: number;
|
|
52
|
+
/** The number may be the call's own when the dialog params and row carry none (default true). */
|
|
53
|
+
readonly msisdnFromContext?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* The number as it is dialled, from the one the dialog carries (e.g. a trunk prefix, a country code; a number value is
|
|
56
|
+
* read as its text); the dialog and the row keep it as uploaded. Default: the text trimmed.
|
|
57
|
+
*/
|
|
58
|
+
readonly dialNumber?: (msisdn: string) => string;
|
|
59
|
+
/** With `dialNumber`: a number value of the dialog's msisdn is dialled as its text (default true); `false`: not dialled. */
|
|
60
|
+
readonly numberMsisdnAsText?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The leg lines name the trunk a re-route picked from a pool (see {@link nameLegTrunk}): the first leg's line is
|
|
63
|
+
* `{ msisdn, entryPoint, selectedTrunk, trunkNumber, trunkId }`, the failed-leg redial lines carry `selectedTrunk`,
|
|
64
|
+
* `trunkNumber` after `callUuid` (instead of the campaign's recall values and the handler). Default off.
|
|
65
|
+
*/
|
|
66
|
+
readonly trunkLog?: boolean;
|
|
67
|
+
/** The trunk when the dialog params name none (before the dialog env's `trunk`). */
|
|
68
|
+
readonly trunkId?: number;
|
|
69
|
+
/** Headless handler stored as `on_success_call` (the pass after a leg that connected), before `onFailedCall`. */
|
|
70
|
+
readonly onSuccessCall?: string;
|
|
71
|
+
/** SIP extras every leg carries; the dialog params' own go on top (`protoAdditionalOver`: these win, in any case). */
|
|
72
|
+
readonly protoAdditional?: Readonly<Record<string, string>>;
|
|
73
|
+
readonly protoAdditionalOver?: boolean;
|
|
74
|
+
/** Re-route one leg (another number, a trunk by name, more SIP extras); `null` places it as the params say. */
|
|
75
|
+
readonly route?: (msisdn: string) => LegRoute | null;
|
|
76
|
+
/** The `after_call_failed` pass places the leg again (other post-call passes still never dial). */
|
|
77
|
+
readonly fromFailedPass?: boolean;
|
|
78
|
+
}
|
|
79
|
+
/** Where one leg goes instead of the dialog's number (`ScheduleOutboundOptions.route`). */
|
|
80
|
+
export interface LegRoute {
|
|
81
|
+
readonly msisdn: string;
|
|
82
|
+
readonly channel?: string;
|
|
83
|
+
/** The leg over this trunk (the routing's channel dropped). */
|
|
84
|
+
readonly trunkId?: number;
|
|
85
|
+
readonly protoAdditional?: Readonly<Record<string, string>>;
|
|
86
|
+
}
|
|
87
|
+
/** The trunk a re-route picked from a pool (its name and caller ID), for the leg lines of `trunkLog`. */
|
|
88
|
+
export interface LegTrunk {
|
|
89
|
+
readonly name: string;
|
|
90
|
+
readonly callerId: string;
|
|
91
|
+
}
|
|
92
|
+
/** Names the pool trunk of a route (`LegRoute` object) for the leg lines; returns the route. */
|
|
93
|
+
export declare function nameLegTrunk<T extends object>(route: T, trunk: LegTrunk): T;
|
|
94
|
+
/**
|
|
95
|
+
* Places the outbound leg on the headless pre-call pass (`platform.call`, the `nn.call` analogue). Self-gates on
|
|
96
|
+
* `legacyV3Compat` + headless + a pre-call phase + an msisdn, so it can be called on every pass.
|
|
97
|
+
*
|
|
98
|
+
* Without `options` every leg carries {@link FAILED_CALL_ENTRY_POINT} (the default: a failed dial gets its own
|
|
99
|
+
* row and the script owns the redials); with `options`, only the `onFailedCall` they name.
|
|
100
|
+
*/
|
|
101
|
+
export declare function scheduleOutboundFromDialogParams(platform: PlatformApi | undefined, context: ScriptDialogContext, logger: ScriptLogger, options?: ScheduleOutboundOptions,
|
|
102
|
+
/** Record the placed leg in the dialog's leg ledger (see `markLegScheduled`). */
|
|
103
|
+
ledger?: boolean): Promise<void>;
|
|
104
|
+
/** Dialog env key: the redials the `after_call_failed` pass placed itself (see {@link redialFailedLeg}). */
|
|
105
|
+
export declare const FAILED_LEG_REDIALS_ENV_KEY = "failed_leg_redials";
|
|
106
|
+
/** How many redials the failed-leg pass placed on this dialog, and for which leg the last one was placed. */
|
|
107
|
+
export interface FailedLegRedials {
|
|
108
|
+
count: number;
|
|
109
|
+
last_call_uuid: string | null;
|
|
110
|
+
last_due: string | null;
|
|
111
|
+
}
|
|
112
|
+
export declare function readFailedLegRedials(ctx: ScriptDialogContext): FailedLegRedials;
|
|
113
|
+
/**
|
|
114
|
+
* Which attempt this run is when the failed-leg pass places its own redials: the platform counts only its own recalls,
|
|
115
|
+
* so the redials of {@link redialFailedLeg} before this leg count too (a pass that already redialled its own leg reads
|
|
116
|
+
* the attempt that leg was).
|
|
117
|
+
*/
|
|
118
|
+
export declare function readAttemptWithRedials(ctx: ScriptDialogContext, callUuid: string): number;
|
|
119
|
+
/** What {@link redialFailedLeg} did: placed the redial (when it is due) or why not; the redials before it and the limit. */
|
|
120
|
+
export interface FailedLegRedialOutcome {
|
|
121
|
+
readonly scheduled: boolean;
|
|
122
|
+
readonly reason: FailedLegRedialReason;
|
|
123
|
+
readonly redialsSoFar: number;
|
|
124
|
+
readonly maxRedials: number | null;
|
|
125
|
+
readonly dueAt: string | null;
|
|
126
|
+
}
|
|
127
|
+
/** Why {@link redialFailedLeg} placed a leg or did not. */
|
|
128
|
+
export type FailedLegRedialReason = 'scheduled' | 'not_after_call_failed' | 'platform_unavailable' | 'no_env' | 'no_recall_delay' | 'recall_limit_reached' | 'already_redialled' | 'no_msisdn' | 'call_failed';
|
|
129
|
+
/**
|
|
130
|
+
* The `after_call_failed` pass of a leg nobody answered redials the number itself. A leg that names a failed-call
|
|
131
|
+
* handler gives up the platform's contact-rule recall (the host does not copy `recallCount` / `recallDelay` onto it),
|
|
132
|
+
* so the pass applies the same rule: at most `context.recallCount` redials (counted in the dialog env, not in
|
|
133
|
+
* `context.attempt`), `context.recallDelay` seconds from now, routed like the first leg and naming the same handler.
|
|
134
|
+
* Refused and logged rather than guessed: no dialog env, no delay, a second pass for a leg that already redialled.
|
|
135
|
+
* Never throws.
|
|
136
|
+
*/
|
|
137
|
+
export declare function redialFailedLeg(platform: PlatformApi | undefined, context: ScriptDialogContext, logger: ScriptLogger, callUuid: string, options?: ScheduleOutboundOptions, now?: Date): Promise<FailedLegRedialOutcome>;
|
|
138
|
+
/**
|
|
139
|
+
* The dialog's next leg, placed by the script after a leg (an agent that owns its redials): routed like the first
|
|
140
|
+
* (`options`: the same handlers, extras and re-routing), `delaySec` from now. `true` when the call row was created.
|
|
141
|
+
*/
|
|
142
|
+
export declare function scheduleNextLeg(platform: PlatformApi | undefined, context: ScriptDialogContext, logger: ScriptLogger, options: ScheduleOutboundOptions & {
|
|
143
|
+
readonly delaySec?: number;
|
|
144
|
+
}): Promise<boolean>;
|