@voctiv/agent-runtime 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -20
- package/dist/barge-in/barge-in-module.d.ts +0 -1
- package/dist/barge-in/barge-in-module.js +0 -1
- package/dist/barge-in/barge-in-service.d.ts +1 -1
- package/dist/barge-in/barge-in-service.js +33 -2
- package/dist/barge-in/barge-in-strategy.d.ts +11 -9
- package/dist/barge-in/barge-in-strategy.js +39 -23
- package/dist/barge-in/echo-cancellation.d.ts +0 -1
- package/dist/barge-in/echo-cancellation.js +0 -1
- package/dist/barge-in/echo.d.ts +0 -1
- package/dist/barge-in/echo.js +0 -1
- package/dist/barge-in/lexicon.d.ts +0 -1
- package/dist/barge-in/lexicon.js +8 -2
- package/dist/barge-in/speech-ledger.d.ts +0 -2
- package/dist/barge-in/speech-ledger.js +3 -4
- package/dist/barge-in/word-classifier.d.ts +0 -1
- package/dist/barge-in/word-classifier.js +0 -1
- package/dist/call/asr-usage.d.ts +53 -0
- package/dist/call/asr-usage.js +42 -0
- package/dist/call/async.d.ts +2 -0
- package/dist/call/async.js +14 -0
- package/dist/call/env.d.ts +88 -0
- package/dist/call/env.js +294 -0
- package/dist/call/extraction/core.d.ts +99 -0
- package/dist/call/extraction/core.js +259 -0
- package/dist/call/extraction/defaults.d.ts +10 -0
- package/dist/call/extraction/defaults.js +25 -0
- package/dist/call/extraction/index.d.ts +7 -0
- package/dist/call/extraction/index.js +24 -0
- package/dist/call/extraction/orchestrator.d.ts +144 -0
- package/dist/call/extraction/orchestrator.js +309 -0
- package/dist/call/failed-leg.d.ts +43 -0
- package/dist/call/failed-leg.js +77 -0
- package/dist/call/http.d.ts +94 -0
- package/dist/call/http.js +145 -0
- package/dist/call/ledger.d.ts +18 -0
- package/dist/call/ledger.js +80 -0
- package/dist/call/llm-tap.d.ts +7 -0
- package/dist/call/llm-tap.js +41 -0
- package/dist/call/logging.d.ts +16 -0
- package/dist/call/logging.js +92 -0
- package/dist/call/outbound.d.ts +144 -0
- package/dist/call/outbound.js +404 -0
- package/dist/call/output.d.ts +108 -0
- package/dist/call/output.js +77 -0
- package/dist/call/plan.d.ts +119 -0
- package/dist/call/plan.js +2 -0
- package/dist/call/recall.d.ts +115 -0
- package/dist/call/recall.js +312 -0
- package/dist/call/records.d.ts +9 -0
- package/dist/call/records.js +71 -0
- package/dist/call/report.d.ts +65 -0
- package/dist/call/report.js +263 -0
- package/dist/call/sanitize.d.ts +16 -0
- package/dist/call/sanitize.js +72 -0
- package/dist/call/sip.d.ts +111 -0
- package/dist/call/sip.js +212 -0
- package/dist/call/voicemail.d.ts +159 -0
- package/dist/call/voicemail.js +246 -0
- package/dist/core/call-disposables.d.ts +2 -2
- package/dist/core/call-disposables.js +8 -3
- package/dist/core/call-ended-budget.d.ts +11 -0
- package/dist/core/call-ended-budget.js +31 -0
- package/dist/core/container.d.ts +1 -3
- package/dist/core/container.js +9 -49
- package/dist/core/create-agent-script.d.ts +6 -1
- package/dist/core/create-agent-script.js +161 -28
- package/dist/core/decorators.d.ts +0 -1
- package/dist/core/decorators.js +0 -1
- package/dist/core/define-module.d.ts +0 -1
- package/dist/core/define-module.js +0 -1
- package/dist/core/dump-policy.d.ts +0 -1
- package/dist/core/dump-policy.js +0 -1
- package/dist/core/hooks.d.ts +15 -4
- package/dist/core/hooks.js +0 -1
- package/dist/core/media-bootstrap.d.ts +19 -4
- package/dist/core/media-bootstrap.js +53 -13
- package/dist/core/open-timeout.d.ts +12 -0
- package/dist/core/open-timeout.js +48 -0
- package/dist/core/provide-media.d.ts +0 -8
- package/dist/core/provide-media.js +1 -22
- package/dist/core/runtime-events.d.ts +28 -0
- package/dist/{llm/llm-module.js → core/runtime-events.js} +19 -16
- package/dist/core/tokens.d.ts +0 -10
- package/dist/core/tokens.js +0 -1
- package/dist/core/types.d.ts +0 -1
- package/dist/core/types.js +0 -1
- package/dist/core/version.d.ts +2 -3
- package/dist/core/version.js +2 -3
- package/dist/dialog/dialog-definition.d.ts +0 -5
- package/dist/dialog/dialog-definition.js +1 -6
- package/dist/dialog/dialog-ports.d.ts +3 -1
- package/dist/dialog/dialog-ports.js +10 -2
- package/dist/dialog/online-call-host.d.ts +26 -4
- package/dist/dialog/online-call-host.js +94 -12
- package/dist/dialog/online-call-module.d.ts +5 -11
- package/dist/dialog/online-call-module.js +4 -36
- package/dist/dialog/turn-metrics.d.ts +46 -0
- package/dist/dialog/turn-metrics.js +141 -0
- package/dist/dialog-events/active-media.d.ts +50 -2
- package/dist/dialog-events/active-media.js +146 -34
- package/dist/dialog-events/event-source.d.ts +0 -1
- package/dist/dialog-events/event-source.js +0 -1
- package/dist/dialog-events/virtual-finals-module.d.ts +0 -1
- package/dist/dialog-events/virtual-finals-module.js +0 -1
- package/dist/dialog-events/virtual-finals.d.ts +2 -1
- package/dist/dialog-events/virtual-finals.js +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.js +8 -26
- package/dist/lifecycle/lifecycle.d.ts +25 -3
- package/dist/lifecycle/lifecycle.js +92 -14
- package/dist/result/result-store.d.ts +0 -1
- package/dist/result/result-store.js +0 -1
- package/dist/templates/authoring.d.ts +222 -0
- package/dist/templates/authoring.js +2 -0
- package/dist/templates/builder/agent.d.ts +34 -0
- package/dist/templates/builder/agent.js +87 -0
- package/dist/templates/builder/blocks.d.ts +54 -0
- package/dist/templates/builder/blocks.js +92 -0
- package/dist/templates/builder/data-check.d.ts +2 -0
- package/dist/templates/builder/data-check.js +61 -0
- package/dist/templates/builder/draft.d.ts +73 -0
- package/dist/templates/builder/draft.js +142 -0
- package/dist/templates/builder/index.d.ts +8 -0
- package/dist/templates/builder/index.js +55 -0
- package/dist/templates/builder/presets.d.ts +34 -0
- package/dist/templates/builder/presets.js +45 -0
- package/dist/templates/builder/spec-of.d.ts +13 -0
- package/dist/templates/builder/spec-of.js +18 -0
- package/dist/templates/builder/steps.d.ts +25 -0
- package/dist/templates/builder/steps.js +27 -0
- package/dist/templates/business/adapter.d.ts +12 -0
- package/dist/templates/business/adapter.js +980 -0
- package/dist/templates/business/agent-integrations.d.ts +24 -0
- package/dist/templates/business/agent-integrations.js +233 -0
- package/dist/templates/business/extraction-rules-transcript.d.ts +158 -0
- package/dist/templates/business/extraction-rules-transcript.js +405 -0
- package/dist/templates/business/extraction-rules.d.ts +107 -0
- package/dist/templates/business/extraction-rules.js +267 -0
- package/dist/templates/business/index.d.ts +6 -0
- package/dist/{result → templates/business}/index.js +8 -2
- package/dist/templates/business/input.d.ts +56 -0
- package/dist/templates/business/input.js +299 -0
- package/dist/templates/business/integration-data.d.ts +87 -0
- package/dist/templates/business/integration-data.js +312 -0
- package/dist/templates/business/integrations.d.ts +76 -0
- package/dist/templates/business/integrations.js +535 -0
- package/dist/templates/business/legs-policy.d.ts +43 -0
- package/dist/templates/business/legs-policy.js +268 -0
- package/dist/templates/business/report-label.d.ts +7 -0
- package/dist/templates/business/report-label.js +29 -0
- package/dist/templates/business/report.d.ts +67 -0
- package/dist/templates/business/report.js +284 -0
- package/dist/templates/business/result-catalog.d.ts +142 -0
- package/dist/templates/business/result-catalog.js +208 -0
- package/dist/templates/business/result-rules.d.ts +105 -0
- package/dist/templates/business/result-rules.js +167 -0
- package/dist/templates/business/results.d.ts +73 -0
- package/dist/templates/business/results.js +183 -0
- package/dist/templates/business/rule-env.d.ts +18 -0
- package/dist/templates/business/rule-env.js +38 -0
- package/dist/templates/business/sources.d.ts +76 -0
- package/dist/templates/business/sources.js +239 -0
- package/dist/templates/business/test-presets.d.ts +10 -0
- package/dist/templates/business/test-presets.js +68 -0
- package/dist/templates/catalog-match/block.d.ts +32 -0
- package/dist/templates/catalog-match/block.js +95 -0
- package/dist/templates/catalog-match/catalog.d.ts +77 -0
- package/dist/templates/catalog-match/catalog.js +222 -0
- package/dist/templates/catalog-match/recognizer.d.ts +44 -0
- package/dist/templates/catalog-match/recognizer.js +206 -0
- package/dist/templates/catalog-match/reconcile.d.ts +4 -0
- package/dist/templates/catalog-match/reconcile.js +39 -0
- package/dist/templates/catalog-match/request.d.ts +57 -0
- package/dist/templates/catalog-match/request.js +139 -0
- package/dist/templates/catalog-match/types.d.ts +197 -0
- package/dist/templates/catalog-match/types.js +2 -0
- package/dist/templates/catalog-match/verify.d.ts +76 -0
- package/dist/templates/catalog-match/verify.js +220 -0
- package/dist/templates/decision-model/index.d.ts +52 -0
- package/dist/templates/decision-model/index.js +68 -0
- package/dist/templates/engine/asr-picks.d.ts +11 -0
- package/dist/templates/engine/asr-picks.js +44 -0
- package/dist/templates/engine/call.d.ts +104 -0
- package/dist/templates/engine/call.js +322 -0
- package/dist/templates/engine/config.d.ts +447 -0
- package/dist/templates/engine/config.js +493 -0
- package/dist/templates/engine/define.d.ts +1 -0
- package/dist/templates/engine/define.js +9 -0
- package/dist/templates/engine/dialog.d.ts +253 -0
- package/dist/templates/engine/dialog.js +167 -0
- package/dist/templates/engine/echo-numbers.d.ts +7 -0
- package/dist/templates/engine/echo-numbers.js +19 -0
- package/dist/templates/engine/expand.d.ts +6 -0
- package/dist/templates/engine/expand.js +125 -0
- package/dist/templates/engine/filters.d.ts +81 -0
- package/dist/templates/engine/filters.js +654 -0
- package/dist/templates/engine/hook-state.d.ts +18 -0
- package/dist/templates/engine/hook-state.js +100 -0
- package/dist/templates/engine/hooks.d.ts +51 -0
- package/dist/templates/engine/hooks.js +310 -0
- package/dist/templates/engine/index.d.ts +13 -0
- package/dist/templates/engine/index.js +30 -0
- package/dist/templates/engine/language-vars.d.ts +6 -0
- package/dist/templates/engine/language-vars.js +40 -0
- package/dist/templates/engine/language.d.ts +32 -0
- package/dist/templates/engine/language.js +155 -0
- package/dist/templates/engine/lookup.d.ts +20 -0
- package/dist/templates/engine/lookup.js +52 -0
- package/dist/templates/engine/match.d.ts +48 -0
- package/dist/templates/engine/match.js +253 -0
- package/dist/templates/engine/media.d.ts +428 -0
- package/dist/templates/engine/media.js +1240 -0
- package/dist/templates/engine/script.d.ts +11 -0
- package/dist/templates/engine/script.js +69 -0
- package/dist/templates/engine/turns/actions.d.ts +5 -0
- package/dist/templates/engine/turns/actions.js +128 -0
- package/dist/templates/engine/turns/carry.d.ts +15 -0
- package/dist/templates/engine/turns/carry.js +74 -0
- package/dist/templates/engine/turns/choices-offers.d.ts +21 -0
- package/dist/templates/engine/turns/choices-offers.js +143 -0
- package/dist/templates/engine/turns/choices.d.ts +22 -0
- package/dist/templates/engine/turns/choices.js +141 -0
- package/dist/templates/engine/turns/closing-guard.d.ts +73 -0
- package/dist/templates/engine/turns/closing-guard.js +162 -0
- package/dist/templates/engine/turns/closing.d.ts +10 -0
- package/dist/templates/engine/turns/closing.js +82 -0
- package/dist/templates/engine/turns/compile-forms.d.ts +24 -0
- package/dist/templates/engine/turns/compile-forms.js +68 -0
- package/dist/templates/engine/turns/context.d.ts +96 -0
- package/dist/templates/engine/turns/context.js +158 -0
- package/dist/templates/engine/turns/events.d.ts +409 -0
- package/dist/templates/engine/turns/events.js +5 -0
- package/dist/templates/engine/turns/hook-forms.d.ts +62 -0
- package/dist/templates/engine/turns/hook-forms.js +79 -0
- package/dist/templates/engine/turns/ladders.d.ts +42 -0
- package/dist/templates/engine/turns/ladders.js +119 -0
- package/dist/templates/engine/turns/language.d.ts +8 -0
- package/dist/templates/engine/turns/language.js +121 -0
- package/dist/templates/engine/turns/notes-dates.d.ts +9 -0
- package/dist/templates/engine/turns/notes-dates.js +42 -0
- package/dist/templates/engine/turns/notes-detect.d.ts +13 -0
- package/dist/templates/engine/turns/notes-detect.js +36 -0
- package/dist/templates/engine/turns/notes.d.ts +27 -0
- package/dist/templates/engine/turns/notes.js +176 -0
- package/dist/templates/engine/turns/opening.d.ts +34 -0
- package/dist/templates/engine/turns/opening.js +306 -0
- package/dist/templates/engine/turns/overtalk.d.ts +21 -0
- package/dist/templates/engine/turns/overtalk.js +247 -0
- package/dist/templates/engine/turns/pending.d.ts +9 -0
- package/dist/templates/engine/turns/pending.js +88 -0
- package/dist/templates/engine/turns/reply-rules.d.ts +184 -0
- package/dist/templates/engine/turns/reply-rules.js +335 -0
- package/dist/templates/engine/turns/rules.d.ts +20 -0
- package/dist/templates/engine/turns/rules.js +144 -0
- package/dist/templates/engine/turns/silence.d.ts +7 -0
- package/dist/templates/engine/turns/silence.js +127 -0
- package/dist/templates/engine/turns/state-spec.d.ts +305 -0
- package/dist/templates/engine/turns/state-spec.js +2 -0
- package/dist/templates/engine/turns/state.d.ts +38 -0
- package/dist/templates/engine/turns/state.js +101 -0
- package/dist/templates/engine/turns/tracking.d.ts +50 -0
- package/dist/templates/engine/turns/tracking.js +184 -0
- package/dist/templates/engine/turns/transfer.d.ts +19 -0
- package/dist/templates/engine/turns/transfer.js +93 -0
- package/dist/templates/engine/turns/turn.d.ts +17 -0
- package/dist/templates/engine/turns/turn.js +363 -0
- package/dist/templates/engine/turns/voicemail.d.ts +8 -0
- package/dist/templates/engine/turns/voicemail.js +101 -0
- package/dist/templates/engine/variants.d.ts +36 -0
- package/dist/templates/engine/variants.js +159 -0
- package/dist/templates/engine/voice-dialog.d.ts +24 -0
- package/dist/templates/engine/voice-dialog.js +157 -0
- package/dist/templates/engine/voice.d.ts +174 -0
- package/dist/templates/engine/voice.js +1337 -0
- package/dist/templates/expr/caller-after.d.ts +20 -0
- package/dist/templates/expr/caller-after.js +53 -0
- package/dist/templates/expr/check.d.ts +19 -0
- package/dist/templates/expr/check.js +314 -0
- package/dist/templates/expr/compiled.d.ts +8 -0
- package/dist/templates/expr/compiled.js +8 -0
- package/dist/templates/expr/context.d.ts +28 -0
- package/dist/templates/expr/context.js +55 -0
- package/dist/templates/expr/day-table.d.ts +4 -0
- package/dist/templates/expr/day-table.js +80 -0
- package/dist/templates/expr/evaluate.d.ts +26 -0
- package/dist/templates/expr/evaluate.js +885 -0
- package/dist/templates/expr/facts.d.ts +7 -0
- package/dist/templates/expr/facts.js +81 -0
- package/dist/templates/expr/index.d.ts +4 -0
- package/dist/templates/expr/index.js +11 -0
- package/dist/templates/expr/line-tally.d.ts +64 -0
- package/dist/templates/expr/line-tally.js +88 -0
- package/dist/templates/expr/matchers-state.d.ts +23 -0
- package/dist/templates/expr/matchers-state.js +37 -0
- package/dist/templates/expr/matchers.d.ts +12 -0
- package/dist/templates/expr/matchers.js +99 -0
- package/dist/templates/expr/readers.d.ts +14 -0
- package/dist/templates/expr/readers.js +351 -0
- package/dist/templates/expr/slots.d.ts +14 -0
- package/dist/templates/expr/slots.js +678 -0
- package/dist/templates/expr/template.d.ts +12 -0
- package/dist/templates/expr/template.js +76 -0
- package/dist/templates/expr/test-call.d.ts +8 -0
- package/dist/templates/expr/test-call.js +32 -0
- package/dist/templates/expr/transcript.d.ts +36 -0
- package/dist/templates/expr/transcript.js +394 -0
- package/dist/templates/expr/types.d.ts +1011 -0
- package/dist/templates/expr/types.js +2 -0
- package/dist/templates/expr/values.d.ts +42 -0
- package/dist/templates/expr/values.js +166 -0
- package/dist/templates/expr/voice-ops.d.ts +26 -0
- package/dist/templates/expr/voice-ops.js +85 -0
- package/dist/templates/helpers/decision.d.ts +55 -0
- package/dist/templates/helpers/decision.js +83 -0
- package/dist/templates/helpers/fuzzy.d.ts +9 -0
- package/dist/templates/helpers/fuzzy.js +44 -0
- package/dist/templates/helpers/index.d.ts +6 -0
- package/dist/templates/helpers/index.js +35 -0
- package/dist/templates/index.d.ts +9 -0
- package/dist/templates/index.js +68 -0
- package/dist/templates/integration-forms.d.ts +252 -0
- package/dist/templates/integration-forms.js +2 -0
- package/dist/templates/knowledge/block.d.ts +44 -0
- package/dist/templates/knowledge/block.js +199 -0
- package/dist/templates/knowledge/dense.d.ts +87 -0
- package/dist/templates/knowledge/dense.js +158 -0
- package/dist/templates/knowledge/flow.d.ts +328 -0
- package/dist/templates/knowledge/flow.js +509 -0
- package/dist/templates/knowledge/retriever.d.ts +75 -0
- package/dist/templates/knowledge/retriever.js +204 -0
- package/dist/templates/knowledge/service.d.ts +77 -0
- package/dist/templates/knowledge/service.js +316 -0
- package/dist/templates/knowledge/text.d.ts +31 -0
- package/dist/templates/knowledge/text.js +66 -0
- package/dist/templates/knowledge/types.d.ts +120 -0
- package/dist/templates/knowledge/types.js +2 -0
- package/dist/templates/locale.d.ts +259 -0
- package/dist/templates/locale.js +4 -0
- package/dist/templates/locales/en-lexicons.d.ts +9 -0
- package/dist/templates/locales/en-lexicons.js +101 -0
- package/dist/templates/locales/en.d.ts +132 -0
- package/dist/templates/locales/en.js +261 -0
- package/dist/templates/locales/es.d.ts +65 -0
- package/dist/templates/locales/es.js +208 -0
- package/dist/templates/locales/hi.d.ts +47 -0
- package/dist/templates/locales/hi.js +235 -0
- package/dist/templates/locales/id.d.ts +43 -0
- package/dist/templates/locales/id.js +127 -0
- package/dist/templates/locales/index.d.ts +34 -0
- package/dist/templates/locales/index.js +112 -0
- package/dist/templates/locales/kk-lexicons.d.ts +22 -0
- package/dist/templates/locales/kk-lexicons.js +89 -0
- package/dist/templates/locales/kk.d.ts +140 -0
- package/dist/templates/locales/kk.js +306 -0
- package/dist/templates/locales/kn.d.ts +29 -0
- package/dist/templates/locales/kn.js +22 -0
- package/dist/templates/locales/listen-only.d.ts +15 -0
- package/dist/templates/locales/listen-only.js +27 -0
- package/dist/templates/locales/ms-lexicons.d.ts +13 -0
- package/dist/templates/locales/ms-lexicons.js +113 -0
- package/dist/templates/locales/ms.d.ts +76 -0
- package/dist/templates/locales/ms.js +179 -0
- package/dist/templates/locales/parse.d.ts +86 -0
- package/dist/templates/locales/parse.js +461 -0
- package/dist/templates/locales/ru-lexicons.d.ts +27 -0
- package/dist/templates/locales/ru-lexicons.js +127 -0
- package/dist/templates/locales/ru-stem.d.ts +2 -0
- package/dist/templates/locales/ru-stem.js +53 -0
- package/dist/templates/locales/ru.d.ts +143 -0
- package/dist/templates/locales/ru.js +387 -0
- package/dist/templates/locales/shared.d.ts +122 -0
- package/dist/templates/locales/shared.js +318 -0
- package/dist/templates/locales/ta.d.ts +29 -0
- package/dist/templates/locales/ta.js +22 -0
- package/dist/templates/locales/te.d.ts +29 -0
- package/dist/templates/locales/te.js +22 -0
- package/dist/templates/locales/tl-lexicons.d.ts +2 -0
- package/dist/templates/locales/tl-lexicons.js +230 -0
- package/dist/templates/locales/tl.d.ts +59 -0
- package/dist/templates/locales/tl.js +82 -0
- package/dist/templates/locales/vi.d.ts +59 -0
- package/dist/templates/locales/vi.js +160 -0
- package/dist/templates/locales/word-regex.d.ts +13 -0
- package/dist/templates/locales/word-regex.js +43 -0
- package/dist/templates/locales/words-kk.d.ts +2 -0
- package/dist/templates/locales/words-kk.js +23 -0
- package/dist/templates/locales/words-ru.d.ts +4 -0
- package/dist/templates/locales/words-ru.js +92 -0
- package/dist/templates/spec.d.ts +2856 -0
- package/dist/templates/spec.js +2 -0
- package/dist/testing/fake-channel.d.ts +0 -1
- package/dist/testing/fake-channel.js +0 -1
- package/dist/testing/index.d.ts +24 -1
- package/dist/testing/index.js +117 -2
- package/dist/voice/call-voice.d.ts +581 -0
- package/dist/voice/call-voice.js +1399 -0
- package/dist/voice/intent-interrupt.d.ts +32 -0
- package/dist/voice/intent-interrupt.js +91 -0
- package/dist/voice/self-echo.d.ts +28 -0
- package/dist/voice/self-echo.js +135 -0
- package/dist/voice/sentence-tag.d.ts +5 -0
- package/dist/voice/sentence-tag.js +42 -0
- package/dist/voice/speech-leak.d.ts +74 -0
- package/dist/voice/speech-leak.js +216 -0
- package/dist/voice/transfer.d.ts +90 -0
- package/dist/voice/transfer.js +331 -0
- package/dist/voice/turn-timing.d.ts +293 -0
- package/dist/voice/turn-timing.js +567 -0
- package/docs/README.md +3 -6
- package/docs/framework/README.md +6 -10
- package/docs/framework/architecture.md +2 -2
- package/docs/framework/container-and-di.md +1 -2
- package/docs/framework/invariants.md +6 -6
- package/docs/framework/package-layout.md +16 -23
- package/docs/framework/testing.md +8 -6
- package/package.json +10 -54
- package/skill/SKILL.md +213 -0
- package/skill/references/agent-file.md +230 -0
- package/skill/references/blocks.md +246 -0
- package/skill/references/builder.md +163 -0
- package/skill/references/business.md +659 -0
- package/skill/references/conversation.md +586 -0
- package/skill/references/core.md +89 -0
- package/skill/references/examples.md +73 -0
- package/skill/references/expressions.md +342 -0
- package/skill/references/format.md +114 -0
- package/skill/references/locales.md +149 -0
- package/skill/references/migration.md +133 -0
- package/skill/references/new-agent.md +81 -0
- package/skill/references/porting.md +109 -0
- package/templates/agent/README.md +50 -0
- package/templates/agent/package.json +24 -0
- package/templates/agent/src/agent.spec.ts +51 -0
- package/templates/agent/src/agent.ts +268 -0
- package/templates/agent/src/entities.ts +44 -0
- package/templates/agent/src/prompt.sqrl +21 -0
- package/templates/agent/src/variants/fixed-opening.ts +144 -0
- package/templates/agent/tsconfig.build.json +4 -0
- package/templates/agent/tsconfig.json +18 -0
- package/dist/asr/index.d.ts +0 -3
- package/dist/asr/index.d.ts.map +0 -1
- package/dist/asr/index.js +0 -6
- package/dist/asr/index.js.map +0 -1
- package/dist/barge-in/barge-in-module.d.ts.map +0 -1
- package/dist/barge-in/barge-in-module.js.map +0 -1
- package/dist/barge-in/barge-in-service.d.ts.map +0 -1
- package/dist/barge-in/barge-in-service.js.map +0 -1
- package/dist/barge-in/barge-in-strategy.d.ts.map +0 -1
- package/dist/barge-in/barge-in-strategy.js.map +0 -1
- package/dist/barge-in/echo-cancellation.d.ts.map +0 -1
- package/dist/barge-in/echo-cancellation.js.map +0 -1
- package/dist/barge-in/echo.d.ts.map +0 -1
- package/dist/barge-in/echo.js.map +0 -1
- package/dist/barge-in/index.d.ts +0 -13
- package/dist/barge-in/index.d.ts.map +0 -1
- package/dist/barge-in/index.js +0 -28
- package/dist/barge-in/index.js.map +0 -1
- package/dist/barge-in/lexicon.d.ts.map +0 -1
- package/dist/barge-in/lexicon.js.map +0 -1
- package/dist/barge-in/lexicons/en.d.ts +0 -2
- package/dist/barge-in/lexicons/en.d.ts.map +0 -1
- package/dist/barge-in/lexicons/en.js +0 -36
- package/dist/barge-in/lexicons/en.js.map +0 -1
- package/dist/barge-in/lexicons/id.d.ts +0 -2
- package/dist/barge-in/lexicons/id.d.ts.map +0 -1
- package/dist/barge-in/lexicons/id.js +0 -39
- package/dist/barge-in/lexicons/id.js.map +0 -1
- package/dist/barge-in/lexicons/index.d.ts +0 -10
- package/dist/barge-in/lexicons/index.d.ts.map +0 -1
- package/dist/barge-in/lexicons/index.js +0 -11
- package/dist/barge-in/lexicons/index.js.map +0 -1
- package/dist/barge-in/lexicons/ru.d.ts +0 -2
- package/dist/barge-in/lexicons/ru.d.ts.map +0 -1
- package/dist/barge-in/lexicons/ru.js +0 -39
- package/dist/barge-in/lexicons/ru.js.map +0 -1
- package/dist/barge-in/speech-ledger.d.ts.map +0 -1
- package/dist/barge-in/speech-ledger.js.map +0 -1
- package/dist/barge-in/word-classifier.d.ts.map +0 -1
- package/dist/barge-in/word-classifier.js.map +0 -1
- package/dist/bridge/bridge.d.ts +0 -28
- package/dist/bridge/bridge.d.ts.map +0 -1
- package/dist/bridge/bridge.js +0 -117
- package/dist/bridge/bridge.js.map +0 -1
- package/dist/bridge/index.d.ts +0 -3
- package/dist/bridge/index.d.ts.map +0 -1
- package/dist/bridge/index.js +0 -8
- package/dist/bridge/index.js.map +0 -1
- package/dist/core/call-disposables.d.ts.map +0 -1
- package/dist/core/call-disposables.js.map +0 -1
- package/dist/core/container.d.ts.map +0 -1
- package/dist/core/container.js.map +0 -1
- package/dist/core/create-agent-script.d.ts.map +0 -1
- package/dist/core/create-agent-script.js.map +0 -1
- package/dist/core/decorators.d.ts.map +0 -1
- package/dist/core/decorators.js.map +0 -1
- package/dist/core/define-module.d.ts.map +0 -1
- package/dist/core/define-module.js.map +0 -1
- package/dist/core/dump-policy.d.ts.map +0 -1
- package/dist/core/dump-policy.js.map +0 -1
- package/dist/core/hooks.d.ts.map +0 -1
- package/dist/core/hooks.js.map +0 -1
- package/dist/core/index.d.ts +0 -16
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -36
- package/dist/core/index.js.map +0 -1
- package/dist/core/media-bootstrap.d.ts.map +0 -1
- package/dist/core/media-bootstrap.js.map +0 -1
- package/dist/core/provide-media.d.ts.map +0 -1
- package/dist/core/provide-media.js.map +0 -1
- package/dist/core/tokens.d.ts.map +0 -1
- package/dist/core/tokens.js.map +0 -1
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/types.js.map +0 -1
- package/dist/core/version.d.ts.map +0 -1
- package/dist/core/version.js.map +0 -1
- package/dist/dialog/basic-ports.d.ts +0 -54
- package/dist/dialog/basic-ports.d.ts.map +0 -1
- package/dist/dialog/basic-ports.js +0 -206
- package/dist/dialog/basic-ports.js.map +0 -1
- package/dist/dialog/define-dialog.d.ts +0 -21
- package/dist/dialog/define-dialog.d.ts.map +0 -1
- package/dist/dialog/define-dialog.js +0 -21
- package/dist/dialog/define-dialog.js.map +0 -1
- package/dist/dialog/dialog-definition.d.ts.map +0 -1
- package/dist/dialog/dialog-definition.js.map +0 -1
- package/dist/dialog/dialog-ports.d.ts.map +0 -1
- package/dist/dialog/dialog-ports.js.map +0 -1
- package/dist/dialog/index.d.ts +0 -7
- package/dist/dialog/index.d.ts.map +0 -1
- package/dist/dialog/index.js +0 -23
- package/dist/dialog/index.js.map +0 -1
- package/dist/dialog/online-call-host.d.ts.map +0 -1
- package/dist/dialog/online-call-host.js.map +0 -1
- package/dist/dialog/online-call-module.d.ts.map +0 -1
- package/dist/dialog/online-call-module.js.map +0 -1
- package/dist/dialog-events/active-media.d.ts.map +0 -1
- package/dist/dialog-events/active-media.js.map +0 -1
- package/dist/dialog-events/event-source.d.ts.map +0 -1
- package/dist/dialog-events/event-source.js.map +0 -1
- package/dist/dialog-events/index.d.ts +0 -8
- package/dist/dialog-events/index.d.ts.map +0 -1
- package/dist/dialog-events/index.js +0 -24
- package/dist/dialog-events/index.js.map +0 -1
- package/dist/dialog-events/max-listen-source.d.ts +0 -27
- package/dist/dialog-events/max-listen-source.d.ts.map +0 -1
- package/dist/dialog-events/max-listen-source.js +0 -98
- package/dist/dialog-events/max-listen-source.js.map +0 -1
- package/dist/dialog-events/overtalk-source.d.ts +0 -61
- package/dist/dialog-events/overtalk-source.d.ts.map +0 -1
- package/dist/dialog-events/overtalk-source.js +0 -232
- package/dist/dialog-events/overtalk-source.js.map +0 -1
- package/dist/dialog-events/silence-source.d.ts +0 -32
- package/dist/dialog-events/silence-source.d.ts.map +0 -1
- package/dist/dialog-events/silence-source.js +0 -128
- package/dist/dialog-events/silence-source.js.map +0 -1
- package/dist/dialog-events/virtual-finals-module.d.ts.map +0 -1
- package/dist/dialog-events/virtual-finals-module.js.map +0 -1
- package/dist/dialog-events/virtual-finals.d.ts.map +0 -1
- package/dist/dialog-events/virtual-finals.js.map +0 -1
- package/dist/dtmf/dtmf.d.ts +0 -27
- package/dist/dtmf/dtmf.d.ts.map +0 -1
- package/dist/dtmf/dtmf.js +0 -87
- package/dist/dtmf/dtmf.js.map +0 -1
- package/dist/dtmf/index.d.ts +0 -3
- package/dist/dtmf/index.d.ts.map +0 -1
- package/dist/dtmf/index.js +0 -8
- package/dist/dtmf/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lifecycle/index.d.ts +0 -3
- package/dist/lifecycle/index.d.ts.map +0 -1
- package/dist/lifecycle/index.js +0 -9
- package/dist/lifecycle/index.js.map +0 -1
- package/dist/lifecycle/lifecycle.d.ts.map +0 -1
- package/dist/lifecycle/lifecycle.js.map +0 -1
- package/dist/llm/index.d.ts +0 -7
- package/dist/llm/index.d.ts.map +0 -1
- package/dist/llm/index.js +0 -18
- package/dist/llm/index.js.map +0 -1
- package/dist/llm/llm-markers-module.d.ts +0 -15
- package/dist/llm/llm-markers-module.d.ts.map +0 -1
- package/dist/llm/llm-markers-module.js +0 -48
- package/dist/llm/llm-markers-module.js.map +0 -1
- package/dist/llm/llm-markers.d.ts +0 -36
- package/dist/llm/llm-markers.d.ts.map +0 -1
- package/dist/llm/llm-markers.js +0 -210
- package/dist/llm/llm-markers.js.map +0 -1
- package/dist/llm/llm-module.d.ts +0 -20
- package/dist/llm/llm-module.d.ts.map +0 -1
- package/dist/llm/llm-module.js.map +0 -1
- package/dist/match/index.d.ts +0 -3
- package/dist/match/index.d.ts.map +0 -1
- package/dist/match/index.js +0 -10
- package/dist/match/index.js.map +0 -1
- package/dist/match/match.d.ts +0 -33
- package/dist/match/match.d.ts.map +0 -1
- package/dist/match/match.js +0 -85
- package/dist/match/match.js.map +0 -1
- package/dist/outbound/index.d.ts +0 -3
- package/dist/outbound/index.d.ts.map +0 -1
- package/dist/outbound/index.js +0 -8
- package/dist/outbound/index.js.map +0 -1
- package/dist/outbound/outbound.d.ts +0 -40
- package/dist/outbound/outbound.d.ts.map +0 -1
- package/dist/outbound/outbound.js +0 -84
- package/dist/outbound/outbound.js.map +0 -1
- package/dist/result/index.d.ts +0 -2
- package/dist/result/index.d.ts.map +0 -1
- package/dist/result/index.js.map +0 -1
- package/dist/result/result-store.d.ts.map +0 -1
- package/dist/result/result-store.js.map +0 -1
- package/dist/testing/fake-channel.d.ts.map +0 -1
- package/dist/testing/fake-channel.js.map +0 -1
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/index.js.map +0 -1
- package/docs/agents/README.md +0 -41
- package/docs/agents/barge-in.md +0 -67
- package/docs/agents/dialog.md +0 -98
- package/docs/agents/getting-started.md +0 -142
- package/docs/agents/imports.md +0 -40
- package/docs/agents/media-and-ports.md +0 -82
- package/docs/agents/modules.md +0 -83
- package/docs/agents/phases.md +0 -83
- package/docs/framework/extending.md +0 -59
- package/docs/framework/idn-parity.md +0 -18
- package/examples/minimal-agent/README.md +0 -7
- package/examples/minimal-agent/agent.ts +0 -94
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bufferDrained = exports.takeBackchannel = exports.replayDue = exports.scheduleReplay = exports.buffer = exports.continuesTrigger = exports.triggerText = exports.overSilenceTurn = void 0;
|
|
4
|
+
// Speech over the agent: the guard, the buffer (merge, keep, predating), what the drain does with a buffered line
|
|
5
|
+
// (reverse, pre-reply, last part, backchannel) and its replay.
|
|
6
|
+
const match_1 = require("../match");
|
|
7
|
+
const turn_1 = require("./turn");
|
|
8
|
+
/** `overtalk.overSilenceTurn: 'answer'`: words over the reply to a silence turn are answered at once, not buffered. */
|
|
9
|
+
function overSilenceTurn(cx, text) {
|
|
10
|
+
const rung = cx.d.silence.pendingRung;
|
|
11
|
+
if (!cx.v.overtalk.answerOverSilenceTurn || rung == null || (0, match_1.normalizeLine)(text).length === 0)
|
|
12
|
+
return false;
|
|
13
|
+
cx.log('overtalk_cuts_silence_probe', { userText: text, requiredAction: rung, elapsedMs: cx.now() - (cx.m?.playbackStartedAt ?? 0) });
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
exports.overSilenceTurn = overSilenceTurn;
|
|
17
|
+
/** The caller's line the reply in flight answers (with what `startedBeforeReply` added to it). */
|
|
18
|
+
function triggerText(cx) {
|
|
19
|
+
const m = cx.m;
|
|
20
|
+
const j = cx.d.triggerJoin;
|
|
21
|
+
return j != null && j.seq === m.turnSeq ? j.text : m.lastTurnTriggerText;
|
|
22
|
+
}
|
|
23
|
+
exports.triggerText = triggerText;
|
|
24
|
+
/**
|
|
25
|
+
* `overtalk.startedBeforeReply`: speech the caller began before the reply played is the rest of the line the reply
|
|
26
|
+
* answers — added to that caller line in the transcript and to the trigger line, not buffered.
|
|
27
|
+
*/
|
|
28
|
+
function continuesTrigger(cx, text) {
|
|
29
|
+
const sb = cx.v.overtalk.startedBeforeReply;
|
|
30
|
+
const m = cx.m;
|
|
31
|
+
if (!sb)
|
|
32
|
+
return false;
|
|
33
|
+
const trigger = triggerText(cx);
|
|
34
|
+
const silence = cx.core.text(cx.cfg.silenceSignal, cx.d);
|
|
35
|
+
if (trigger == null || trigger === silence || !m.userSpeechStartedAt)
|
|
36
|
+
return false;
|
|
37
|
+
const startedBeforeReplyMs = m.playbackStartedAt - m.userSpeechStartedAt;
|
|
38
|
+
if (startedBeforeReplyMs < -sb.graceMs)
|
|
39
|
+
return false;
|
|
40
|
+
const norm = (0, match_1.normalizeLine)(text);
|
|
41
|
+
if (!norm.length || (0, match_1.normalizeLine)(trigger).includes(norm))
|
|
42
|
+
return false;
|
|
43
|
+
const d = cx.d;
|
|
44
|
+
const tail = text.trim();
|
|
45
|
+
let at = -1;
|
|
46
|
+
for (const i of [d.lines.length - 1, d.lines.length - 2]) {
|
|
47
|
+
if (i >= 0 && d.lines[i].who === 'caller') {
|
|
48
|
+
at = i;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (at < 0 || !tail)
|
|
53
|
+
return false;
|
|
54
|
+
d.lines = d.lines.map((l, i) => (i === at ? { who: 'caller', text: `${l.text} ${tail}` } : l));
|
|
55
|
+
d.triggerJoin = { seq: m.turnSeq ?? 0, text: `${trigger} ${text}` };
|
|
56
|
+
cx.log('overtalk_continues_trigger', { userText: text, trigger, startedBeforeReplyMs, elapsedMs: m.now - m.playbackStartedAt });
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
exports.continuesTrigger = continuesTrigger;
|
|
60
|
+
/** Buffer speech heard over the agent (`elapsedMs` into the reply's playback); false: the buffer kept its line. */
|
|
61
|
+
function buffer(cx, text, elapsedMs = 0) {
|
|
62
|
+
const d = cx.d;
|
|
63
|
+
const held = d.buffered;
|
|
64
|
+
const kb = cx.v.overtalk.keepBuffered;
|
|
65
|
+
if (kb && held != null && held.length > 0 && !cx.v.overtalk.merge) {
|
|
66
|
+
const view = cx.core.view(d);
|
|
67
|
+
const incomingAnswer = kb.answer?.(text, view) === true;
|
|
68
|
+
const keepAnswer = kb.answer?.(held, view) === true && !incomingAnswer;
|
|
69
|
+
const incomingLen = (0, match_1.normalizeLine)(text).length;
|
|
70
|
+
const keepOver = !incomingAnswer && kb.interjectionMaxChars > 0 && incomingLen <= kb.interjectionMaxChars && (0, match_1.normalizeLine)(held).length > incomingLen;
|
|
71
|
+
// A line the last-sentence rule will drop at the drain does not block a newer one.
|
|
72
|
+
const doomed = cx.v.overtalk.beforeLastSentence && !(cx.v.overtalk.exceptSilenceTurn && d.bufferedOnSilence)
|
|
73
|
+
&& (d.bufferedElapsedMs ?? 0) >= (cx.v.overtalk.preReply?.ms ?? 0) && d.bufferedAt < (cx.m?.lastItemStartedAt ?? 0);
|
|
74
|
+
if ((keepAnswer || keepOver) && !doomed) {
|
|
75
|
+
cx.log('overtalk_buffer_overwrite_declined', { keptUserText: held, incomingUserText: text, reason: keepAnswer ? 'buffered_is_answer' : 'incoming_interjection', elapsedMs });
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
d.bufferedContinuation = false;
|
|
80
|
+
const gapMs = cx.now() - d.bufferedAt;
|
|
81
|
+
d.bufferedAt = cx.now();
|
|
82
|
+
d.bufferedElapsedMs = elapsedMs;
|
|
83
|
+
d.bufferedOnSilence = d.silence.pendingRung != null;
|
|
84
|
+
if (held == null || held.length === 0) {
|
|
85
|
+
// The tail of the caller's last line, heard close enough to it, continues it.
|
|
86
|
+
const c = cx.cfg.voice.continuation;
|
|
87
|
+
d.bufferContinues = c != null && d.trigger.length > 0 && d.triggerAt > 0 && cx.now() - d.triggerAt <= c.windowMs
|
|
88
|
+
&& !(0, match_1.normalizeLine)(d.trigger).includes((0, match_1.normalizeLine)(text));
|
|
89
|
+
d.buffered = text;
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
if (!cx.v.overtalk.merge) {
|
|
93
|
+
d.buffered = text;
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
const heldNorm = (0, match_1.normalizeLine)(held);
|
|
97
|
+
const norm = (0, match_1.normalizeLine)(text);
|
|
98
|
+
if (heldNorm.includes(norm))
|
|
99
|
+
return true;
|
|
100
|
+
const o = cx.v.overtalk;
|
|
101
|
+
if (o.mergeWindowMs != null && gapMs > o.mergeWindowMs) {
|
|
102
|
+
cx.log('overtalk_buffer_gap_exceeded', { droppedText: held, userText: text, gapMs, windowMs: o.mergeWindowMs });
|
|
103
|
+
d.bufferContinues = false;
|
|
104
|
+
d.buffered = text;
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
if (o.mergeSupersede && norm.includes(heldNorm)) {
|
|
108
|
+
d.buffered = text;
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
const merged = `${held} ${text}`;
|
|
112
|
+
d.buffered = o.mergeMaxChars != null && merged.length > o.mergeMaxChars ? text : merged;
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
exports.buffer = buffer;
|
|
116
|
+
function scheduleReplay(cx) {
|
|
117
|
+
const d = cx.d;
|
|
118
|
+
cx.clearReplay();
|
|
119
|
+
const waitedMs = cx.now() - d.bufferedAt;
|
|
120
|
+
// The gap counts from the drain (now), or from when the line was heard.
|
|
121
|
+
const early = cx.v.overtalk.early;
|
|
122
|
+
const gapMs = early && waitedMs >= early.leadMs ? early.gapMs : cx.v.overtalk.gapMs;
|
|
123
|
+
// A line that predates the reply's question (`buffer.predating`): the caller first gets the window to answer it.
|
|
124
|
+
const pr = cx.v.overtalk.predating;
|
|
125
|
+
const predates = pr != null && (pr.by === 'speechBeforeReply'
|
|
126
|
+
? d.bufferedContinuation === true
|
|
127
|
+
: waitedMs > pr.olderThanMs && /[??]\s*$/u.test(cx.agentLines().at(-1) ?? ''));
|
|
128
|
+
const remainingMs = predates ? pr.gapMs : cx.v.overtalk.gapFrom === 'heard' ? Math.max(0, gapMs - waitedMs) : gapMs;
|
|
129
|
+
cx.log('overtalk_replay_scheduled', { userText: d.buffered, waitedMs, remainingMs, ...(pr ? { predates } : {}) });
|
|
130
|
+
cx.fx.push({ type: 'armReplay', ms: remainingMs });
|
|
131
|
+
}
|
|
132
|
+
exports.scheduleReplay = scheduleReplay;
|
|
133
|
+
function replayDue(cx) {
|
|
134
|
+
const d = cx.d;
|
|
135
|
+
const m = cx.m;
|
|
136
|
+
if (m.callEnding || d.buffered == null)
|
|
137
|
+
return;
|
|
138
|
+
const hold = cx.v.overtalk.hold;
|
|
139
|
+
if (hold && m.userSpeaking) {
|
|
140
|
+
if (d.replayHoldAt === 0)
|
|
141
|
+
d.replayHoldAt = m.now;
|
|
142
|
+
const heldMs = m.now - d.replayHoldAt;
|
|
143
|
+
// Past the hold, agent code may keep it while the caller still speaks (`extend`).
|
|
144
|
+
const lastPartialAt = m.lastPartialAt ?? 0;
|
|
145
|
+
const msSinceLastPartial = lastPartialAt > 0 ? m.now - lastPartialAt : null;
|
|
146
|
+
if (hold.extend && heldMs >= hold.maxMs && hold.extend(cx.core.view(d), { heldMs, msSinceLastPartial })) {
|
|
147
|
+
cx.log('overtalk_replay_held_extended', { heldMs, msSinceLastPartial });
|
|
148
|
+
cx.fx.push({ type: 'armReplay', ms: hold.pollMs });
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (heldMs < hold.maxMs) {
|
|
152
|
+
cx.log('overtalk_replay_held_user_speaking', { heldMs, pollMs: hold.pollMs });
|
|
153
|
+
cx.fx.push({ type: 'armReplay', ms: hold.pollMs });
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
cx.log('overtalk_replay_hold_expired', { heldMs, userText: d.buffered });
|
|
157
|
+
}
|
|
158
|
+
const buffered = d.buffered;
|
|
159
|
+
d.buffered = null;
|
|
160
|
+
d.replayHoldAt = 0;
|
|
161
|
+
const withNote = takeBackchannel(cx);
|
|
162
|
+
cx.log('overtalk_buffered_result_replayed', { userText: buffered, ...(withNote ? { withNote } : {}) });
|
|
163
|
+
(0, turn_1.callerLine)(cx, buffered, undefined, undefined, undefined, d.bufferedAt);
|
|
164
|
+
}
|
|
165
|
+
exports.replayDue = replayDue;
|
|
166
|
+
/** A held backchannel goes to the LLM now: its marker goes with it. */
|
|
167
|
+
function takeBackchannel(cx) {
|
|
168
|
+
const d = cx.d;
|
|
169
|
+
const bc = cx.v.overtalk.backchannel;
|
|
170
|
+
const held = d.bufferedBackchannel;
|
|
171
|
+
d.bufferedBackchannel = false;
|
|
172
|
+
if (!held || !bc)
|
|
173
|
+
return false;
|
|
174
|
+
d.callerNote = { text: bc.marker, at: bc.markerAt };
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
exports.takeBackchannel = takeBackchannel;
|
|
178
|
+
/**
|
|
179
|
+
* The agent's line played out with speech buffered over it: the answer now, dropped (reverse, before the reply or its
|
|
180
|
+
* question), held as a backchannel, or replayed after the gap. `silenceTurn`: the line was the reply to a silence turn.
|
|
181
|
+
*/
|
|
182
|
+
function bufferDrained(cx, silenceTurn) {
|
|
183
|
+
const d = cx.d;
|
|
184
|
+
if (d.buffered == null)
|
|
185
|
+
return;
|
|
186
|
+
const ageMs = cx.now() - d.bufferedAt;
|
|
187
|
+
const lastPartAt = cx.m?.lastPartStartedAt ?? 0;
|
|
188
|
+
if (cx.v.overtalk.lastPartAnswers && lastPartAt > 0 && d.bufferedAt >= lastPartAt) {
|
|
189
|
+
// Heard over the line's last part (its closing question): the answer to it, now.
|
|
190
|
+
cx.log('overtalk_answer_replayed_now', { userText: d.buffered, ageMs });
|
|
191
|
+
replayDue(cx);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const pos = cx.v.overtalk.positional;
|
|
195
|
+
const startedAt = cx.m?.lastPlaybackStartedAt ?? 0;
|
|
196
|
+
if (pos && startedAt > 0) {
|
|
197
|
+
// Speech from the opening part of a long reply answers the question before it, not this one.
|
|
198
|
+
const playbackMs = cx.now() - startedAt;
|
|
199
|
+
const fragmentAtMs = d.bufferedAt - startedAt;
|
|
200
|
+
if (playbackMs >= pos.minTurnMs && fragmentAtMs < playbackMs * pos.ratio) {
|
|
201
|
+
cx.log('overtalk_reverse_discarded', { userText: d.buffered, fragmentAtMs, playbackMs, ratio: Number((fragmentAtMs / playbackMs).toFixed(2)), minRatio: pos.ratio });
|
|
202
|
+
d.buffered = null;
|
|
203
|
+
d.bufferContinues = false;
|
|
204
|
+
cx.timing('playbackEnd');
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const o = cx.v.overtalk;
|
|
209
|
+
const guarded = !(o.exceptSilenceTurn && silenceTurn);
|
|
210
|
+
const elapsed = d.bufferedElapsedMs ?? 0;
|
|
211
|
+
if (guarded && o.preReply && elapsed < o.preReply.ms && o.preReply.keep?.(d.buffered, cx.core.view(d)) !== true) {
|
|
212
|
+
// The caller began before the reply did: no answer to the question it ends with.
|
|
213
|
+
cx.log('overtalk_pre_reply_discarded', { userText: d.buffered, elapsedMs: elapsed, guardMs: o.preReply.ms, ageMs });
|
|
214
|
+
d.buffered = null;
|
|
215
|
+
cx.timing('playbackEnd');
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const lastItemAt = cx.m?.lastItemStartedAt ?? 0;
|
|
219
|
+
if (guarded && o.beforeLastSentence && lastItemAt > 0 && d.bufferedAt < lastItemAt && elapsed >= (o.preReply?.ms ?? 0)) {
|
|
220
|
+
// Heard before the reply's last sentence (its question) was on the wire.
|
|
221
|
+
cx.log('overtalk_pre_question_discarded', { userText: d.buffered, elapsedMs: elapsed, deferredBeforeLastSentenceMs: lastItemAt - d.bufferedAt });
|
|
222
|
+
d.buffered = null;
|
|
223
|
+
cx.timing('playbackEnd');
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const r = guarded ? cx.v.overtalk.reverse : null;
|
|
227
|
+
const longEnough = r?.minTurnMs == null || (startedAt > 0 && cx.now() - startedAt >= r.minTurnMs);
|
|
228
|
+
if (r && longEnough && ageMs > r.tailMs && (0, match_1.normalizeLine)(d.buffered).length <= r.maxChars && !(r.keep?.(d.buffered, cx.core.view(d)) ?? false)) {
|
|
229
|
+
cx.log('overtalk_reverse_discarded', { userText: d.buffered, ageMs });
|
|
230
|
+
d.buffered = null;
|
|
231
|
+
cx.timing('playbackEnd');
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const bc = cx.v.overtalk.backchannel;
|
|
235
|
+
if (bc && bc.test(d.buffered, cx.core.view(d))) {
|
|
236
|
+
// A backchannel over the question is not its answer yet: the caller gets time to answer for real.
|
|
237
|
+
d.bufferedBackchannel = true;
|
|
238
|
+
cx.log('overtalk_backchannel_held', { userText: d.buffered, holdMs: bc.holdMs });
|
|
239
|
+
cx.clearReplay();
|
|
240
|
+
cx.log('overtalk_replay_scheduled', { userText: d.buffered, gapMs: bc.holdMs });
|
|
241
|
+
cx.fx.push({ type: 'armReplay', ms: bc.holdMs });
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
scheduleReplay(cx);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
exports.bufferDrained = bufferDrained;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Action } from '../../spec';
|
|
2
|
+
import type { Turn } from './context';
|
|
3
|
+
/** The hook of a rule answers later: the turn starts now, its text waits (a filler after `whileWaiting.afterMs`). */
|
|
4
|
+
export declare function hookWaiting(cx: Turn, key: string): void;
|
|
5
|
+
/** The hook answered: its actions are the rule's; the turn goes on (its held text now). A stale answer is dropped. */
|
|
6
|
+
export declare function hookResult(cx: Turn, key: string, actions: readonly Action[]): void;
|
|
7
|
+
/** NLU answered: the rules pass and the rest of the turn. */
|
|
8
|
+
export declare function classified(cx: Turn, key: string, intents: readonly string[] | null): void;
|
|
9
|
+
export declare function waitingFiller(cx: Turn, key: string): void;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.waitingFiller = exports.classified = exports.hookResult = exports.hookWaiting = void 0;
|
|
4
|
+
const language_1 = require("./language");
|
|
5
|
+
const opening_1 = require("./opening");
|
|
6
|
+
const turn_1 = require("./turn");
|
|
7
|
+
/** The hook of a rule answers later: the turn starts now, its text waits (a filler after `whileWaiting.afterMs`). */
|
|
8
|
+
function hookWaiting(cx, key) {
|
|
9
|
+
const p = cx.d.pending;
|
|
10
|
+
if (!p || p.key !== key || !p.hook)
|
|
11
|
+
return;
|
|
12
|
+
if (cx.cfg.noLlm) {
|
|
13
|
+
// No LLM turn to hold: the agent stops and the turn waits for the hook's line.
|
|
14
|
+
cx.d.answerOver = false;
|
|
15
|
+
cx.fx.push({ type: 'pendingTurn' });
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
cx.d.pending = { ...p, held: true };
|
|
19
|
+
(0, language_1.syncAsr)(cx);
|
|
20
|
+
cx.heldTurn(key, p.line, p.filler != null ? { text: p.filler, afterMs: p.fillerAfterMs ?? 0 } : null);
|
|
21
|
+
}
|
|
22
|
+
exports.hookWaiting = hookWaiting;
|
|
23
|
+
/** The hook answered: its actions are the rule's; the turn goes on (its held text now). A stale answer is dropped. */
|
|
24
|
+
function hookResult(cx, key, actions) {
|
|
25
|
+
const ah = cx.d.actionHook;
|
|
26
|
+
if (ah && ah.key === key) {
|
|
27
|
+
// A hook action's actions: dropped when the call moved on meanwhile (a caller turn, the closing).
|
|
28
|
+
cx.d.actionHook = null;
|
|
29
|
+
if (cx.d.phase === 'closing' || cx.d.callerTurns !== ah.turns || cx.m?.callEnding)
|
|
30
|
+
return;
|
|
31
|
+
const done = cx.run(cx.d, actions.filter((a) => !('hook' in a)), { id: ah.id, ...(ah.at ? { at: ah.at } : {}) });
|
|
32
|
+
cx.set(done.state);
|
|
33
|
+
cx.fx.push(...done.effects);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const st = cx.steps[cx.d.step];
|
|
37
|
+
if (cx.d.phase === 'opening' && st?.kind === 'hook' && st.key === key && cx.d.playing === key) {
|
|
38
|
+
// The opening's hook step answered: its actions, then the next step (unless they closed the call or asked to wait).
|
|
39
|
+
cx.d.playing = null;
|
|
40
|
+
const mark = cx.fx.length;
|
|
41
|
+
const done = cx.run(cx.d, actions, { id: st.name });
|
|
42
|
+
cx.set(done.state);
|
|
43
|
+
cx.fx.push(...done.effects);
|
|
44
|
+
if (cx.d.phase !== 'opening')
|
|
45
|
+
return;
|
|
46
|
+
// A line it said is waited for (the next step starts when it played out).
|
|
47
|
+
if (cx.startedTurn(mark))
|
|
48
|
+
cx.d.playing = st.key;
|
|
49
|
+
else
|
|
50
|
+
(0, opening_1.enter)(cx, cx.d.step + 1);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const p = cx.d.pending;
|
|
54
|
+
if (!p || p.key !== key || !p.hook)
|
|
55
|
+
return;
|
|
56
|
+
cx.d.pending = null;
|
|
57
|
+
const rule = (p.rule != null ? cx.cfg.rules.find((r) => r.id === p.rule) : undefined)
|
|
58
|
+
?? cx.cfg.rules.find((r) => r.hook != null && r.on === 'callerLine');
|
|
59
|
+
const hits = new Set();
|
|
60
|
+
const acts = new Map();
|
|
61
|
+
if (rule && actions.length) {
|
|
62
|
+
hits.add(rule.id);
|
|
63
|
+
acts.set(rule.id, actions);
|
|
64
|
+
}
|
|
65
|
+
(0, turn_1.callerLine)(cx, p.line, hits, acts, p.held ? key : undefined);
|
|
66
|
+
}
|
|
67
|
+
exports.hookResult = hookResult;
|
|
68
|
+
/** NLU answered: the rules pass and the rest of the turn. */
|
|
69
|
+
function classified(cx, key, intents) {
|
|
70
|
+
const p = cx.d.pending;
|
|
71
|
+
if (!p || p.key !== key)
|
|
72
|
+
return;
|
|
73
|
+
cx.d.pending = null;
|
|
74
|
+
const hits = new Set();
|
|
75
|
+
for (const r of cx.cfg.rules)
|
|
76
|
+
if (r.intents && (intents ?? []).some((i) => r.intents.includes(i)))
|
|
77
|
+
hits.add(r.id);
|
|
78
|
+
(0, turn_1.callerLine)(cx, p.line, hits);
|
|
79
|
+
}
|
|
80
|
+
exports.classified = classified;
|
|
81
|
+
function waitingFiller(cx, key) {
|
|
82
|
+
const p = cx.d.pending;
|
|
83
|
+
if (!p || p.key !== key || !p.filler)
|
|
84
|
+
return;
|
|
85
|
+
cx.staticTurn(p.filler, 'filler');
|
|
86
|
+
cx.d.pending = { ...p, filler: null };
|
|
87
|
+
}
|
|
88
|
+
exports.waitingFiller = waitingFiller;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { Action, AnyHook, CallView, Matcher, PlaySpec } from '../../spec';
|
|
2
|
+
import type { Cmp, Condition, Expr, ExprContext } from '../../expr/types';
|
|
3
|
+
/**
|
|
4
|
+
* A condition on a reply sentence: any `Condition` (its `line` is the sentence), or a reply predicate:
|
|
5
|
+
* - `sentence`: the sentence matches;
|
|
6
|
+
* - `first`: the sentence is the reply's first one that was not dropped (`true`) or a later one (`false`);
|
|
7
|
+
* - `turn`: the reply's turn — `tag` (`bootstrap`: the LLM greeting; `turn`: a caller turn), `silence` (it answers a
|
|
8
|
+
* silence turn);
|
|
9
|
+
* - `scriptChanged`: the sentence (with at least `minLetters` letters) is mostly in another of `scripts` (or in none)
|
|
10
|
+
* than the latest agent line with at least `minLetters` letters (false when there is none);
|
|
11
|
+
* - `earlier`: some sentence of an agent line said before this reply holds the inner condition;
|
|
12
|
+
* - `count`: the value of a counter of the rule set (before this sentence), with the tests of `Cmp`;
|
|
13
|
+
* - `answered`: the agent line the reply answers (the last one, whatever its words) matches.
|
|
14
|
+
*/
|
|
15
|
+
export type ReplyCondition = Condition | {
|
|
16
|
+
readonly all: readonly ReplyCondition[];
|
|
17
|
+
} | {
|
|
18
|
+
readonly any: readonly ReplyCondition[];
|
|
19
|
+
} | {
|
|
20
|
+
readonly not: ReplyCondition;
|
|
21
|
+
} | {
|
|
22
|
+
readonly sentence: Matcher;
|
|
23
|
+
} | {
|
|
24
|
+
readonly first: boolean;
|
|
25
|
+
} | {
|
|
26
|
+
readonly turn: {
|
|
27
|
+
readonly tag?: string;
|
|
28
|
+
readonly silence?: boolean;
|
|
29
|
+
};
|
|
30
|
+
} | {
|
|
31
|
+
readonly scriptChanged: {
|
|
32
|
+
readonly scripts: readonly string[];
|
|
33
|
+
readonly minLetters: number;
|
|
34
|
+
};
|
|
35
|
+
} | {
|
|
36
|
+
readonly earlier: ReplyCondition;
|
|
37
|
+
} | ({
|
|
38
|
+
readonly count: string;
|
|
39
|
+
} & Cmp) | {
|
|
40
|
+
readonly answered: Matcher;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* A text of a rule: an `Expr` (its `line` is the sentence), or `byScript`: the text of the script the sentence is
|
|
44
|
+
* mostly written in (`texts` keyed by Unicode script name, e.g. `Devanagari`; ties go to the first listed), `else`
|
|
45
|
+
* when it has none of them.
|
|
46
|
+
*/
|
|
47
|
+
export type ReplyText = Expr | {
|
|
48
|
+
readonly byScript: {
|
|
49
|
+
readonly texts: Readonly<Record<string, Expr>>;
|
|
50
|
+
readonly else: Expr;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* One sentence at a time (a sentence ends at `.`/`!`/`?`/`।`/`…` and a space): the first rule whose `when` holds
|
|
55
|
+
* decides — `drop` (this sentence is not spoken), `cut` (nor anything after it), `replace` (nothing of the reply is
|
|
56
|
+
* spoken; `replace` is said once it ended, `close` ends the call after it). `log`: the reason logged
|
|
57
|
+
* (`llm_reply_rejected`). Counters are updated on the reply's first sentence that was not dropped or cut (on turns
|
|
58
|
+
* where `when` holds): `inc` holds → one more, else back to 0; rules read them before the update. They are kept for
|
|
59
|
+
* the call.
|
|
60
|
+
*/
|
|
61
|
+
export interface SentenceRulesSpec {
|
|
62
|
+
readonly counters?: readonly {
|
|
63
|
+
readonly name: string;
|
|
64
|
+
readonly when?: ReplyCondition;
|
|
65
|
+
readonly inc: ReplyCondition;
|
|
66
|
+
}[];
|
|
67
|
+
readonly rules: readonly {
|
|
68
|
+
readonly when: ReplyCondition;
|
|
69
|
+
readonly then: 'drop' | 'cut' | {
|
|
70
|
+
readonly replace: ReplyText;
|
|
71
|
+
readonly alias?: string;
|
|
72
|
+
readonly close?: {
|
|
73
|
+
readonly result: string;
|
|
74
|
+
readonly reason?: string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
readonly log?: string;
|
|
78
|
+
}[];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The «I did not catch that» ladder on a reply's first sentence (held to its end, `sentenceEnd`). A first sentence
|
|
82
|
+
* matching `probe` (or `whole`) is a re-ask; the count of re-asks in a row is the call variable `countVar` (0 when
|
|
83
|
+
* unset; written when it changes, so the prompt reads it). Count 0: spoken whole; below `rungs`: a `whole` re-ask
|
|
84
|
+
* whole, a probe without its first sentence (the probe alone when nothing follows); `rungs` reached: nothing is spoken
|
|
85
|
+
* and `onExhausted` runs. Any other reply sets the count back to 0. `early`: on a probe when `when` holds (read at the
|
|
86
|
+
* reply's start) nothing is spoken and `then` runs instead. `normalize: 'NFC'` before matching; `skip` (default
|
|
87
|
+
* greeting and silence replies) leaves those replies alone and the count as it is.
|
|
88
|
+
*/
|
|
89
|
+
export interface UnclearLadderSpec {
|
|
90
|
+
readonly probe: Matcher;
|
|
91
|
+
readonly whole?: Matcher;
|
|
92
|
+
readonly rungs: number;
|
|
93
|
+
readonly countVar: string;
|
|
94
|
+
readonly onExhausted: Action | readonly Action[];
|
|
95
|
+
readonly early?: {
|
|
96
|
+
readonly when: Condition;
|
|
97
|
+
readonly then: Action | readonly Action[];
|
|
98
|
+
};
|
|
99
|
+
readonly sentenceEnd?: RegExp;
|
|
100
|
+
readonly normalize?: 'NFC';
|
|
101
|
+
readonly skip?: {
|
|
102
|
+
readonly greeting?: boolean;
|
|
103
|
+
readonly silence?: boolean;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A sentence inserted after the reply's first sentence: on turns whose caller words hold `when` (its `line`), a first
|
|
108
|
+
* sentence matching `after` is followed by ` ` + `text`, unless the first sentence or the next one already matches
|
|
109
|
+
* `unless` (the rest is held to its sentence end). `skip`: default greeting and silence replies.
|
|
110
|
+
*/
|
|
111
|
+
export interface InsertAfterFirstSpec {
|
|
112
|
+
readonly text: Expr;
|
|
113
|
+
readonly when: Condition;
|
|
114
|
+
readonly after: Matcher;
|
|
115
|
+
readonly unless: Matcher;
|
|
116
|
+
readonly sentenceEnd?: RegExp;
|
|
117
|
+
readonly normalize?: 'NFC';
|
|
118
|
+
readonly skip?: {
|
|
119
|
+
readonly greeting?: boolean;
|
|
120
|
+
readonly silence?: boolean;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* A reply whose words are a recorded clip's (`play.text`; compared NFC, trimmed, lower case) plays the clip instead:
|
|
125
|
+
* the reply is held while it is a beginning of those words. `skip`: default greeting replies.
|
|
126
|
+
*/
|
|
127
|
+
export interface AsClipSpec {
|
|
128
|
+
readonly play: PlaySpec;
|
|
129
|
+
readonly skip?: {
|
|
130
|
+
readonly greeting?: boolean;
|
|
131
|
+
readonly silence?: boolean;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The rule sets of `turn.replyRules`, run in order as reply filters:
|
|
136
|
+
* - `sentenceRules` ({@link SentenceRulesSpec});
|
|
137
|
+
* - `unclearLadder` ({@link UnclearLadderSpec});
|
|
138
|
+
* - `insertAfterFirst` ({@link InsertAfterFirstSpec});
|
|
139
|
+
* - `asClip` ({@link AsClipSpec});
|
|
140
|
+
* - `stripLetters`: a word with a letter of a script not in `keep` (Common and Inherited always kept) loses its
|
|
141
|
+
* letters; a word left without any text goes with the space after it. Applied to each chunk.
|
|
142
|
+
*/
|
|
143
|
+
export type ReplyRuleSet = {
|
|
144
|
+
readonly sentenceRules: SentenceRulesSpec;
|
|
145
|
+
} | {
|
|
146
|
+
readonly unclearLadder: UnclearLadderSpec;
|
|
147
|
+
} | {
|
|
148
|
+
readonly insertAfterFirst: InsertAfterFirstSpec;
|
|
149
|
+
} | {
|
|
150
|
+
readonly asClip: AsClipSpec;
|
|
151
|
+
} | {
|
|
152
|
+
readonly stripLetters: {
|
|
153
|
+
readonly keep: readonly string[];
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
/** What the rule sets need of the compiler: contexts of the call and compiled actions. */
|
|
157
|
+
export interface ReplyFormsCompiler {
|
|
158
|
+
ctx(call: CallView, extra?: Partial<ExprContext>): ExprContext;
|
|
159
|
+
actions<T extends Action | readonly Action[] | undefined | null>(x: T, path: string): T;
|
|
160
|
+
}
|
|
161
|
+
/** A reply filter of a rule set: its kind and the generated hook it runs. */
|
|
162
|
+
export interface GeneratedReplyFilter {
|
|
163
|
+
readonly filter: 'sentences' | 'stream' | 'hook';
|
|
164
|
+
readonly fn: AnyHook;
|
|
165
|
+
}
|
|
166
|
+
/** The reply filter of one rule set. */
|
|
167
|
+
export declare function replyRuleFilter(set: ReplyRuleSet, path: string, c: ReplyFormsCompiler): GeneratedReplyFilter;
|
|
168
|
+
/** What a reply condition reads besides the call. */
|
|
169
|
+
interface SentenceScope {
|
|
170
|
+
readonly ctx: ExprContext;
|
|
171
|
+
readonly sentence: string;
|
|
172
|
+
readonly first: boolean;
|
|
173
|
+
readonly tag: string;
|
|
174
|
+
readonly silence: boolean;
|
|
175
|
+
readonly agentLines: readonly string[];
|
|
176
|
+
readonly counters: Readonly<Record<string, number>>;
|
|
177
|
+
}
|
|
178
|
+
/** The script of `scripts` with the most letters in `text` (ties: the first listed), `null` for none. */
|
|
179
|
+
export declare function dominantScript(text: string, scripts: readonly string[]): string | null;
|
|
180
|
+
/** A reply condition on the sentence of `s`. */
|
|
181
|
+
export declare function evalReplyCondition(c: ReplyCondition, s: SentenceScope): boolean;
|
|
182
|
+
/** A text without the letters of words that have a letter of a script not kept (see `stripLetters`). */
|
|
183
|
+
export declare function stripLettersExcept(keep: readonly string[]): (text: string) => string;
|
|
184
|
+
export {};
|