@pipedog/core 0.0.0 → 0.1.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/LICENSE +25 -0
- package/NOTICE +9 -0
- package/dist/adapters/base_llm_adapter.d.ts +266 -0
- package/dist/adapters/base_llm_adapter.js +489 -0
- package/dist/adapters/index.d.ts +2 -0
- package/dist/adapters/index.js +8 -0
- package/dist/adapters/schemas/direct_function.d.ts +202 -0
- package/dist/adapters/schemas/direct_function.js +302 -0
- package/dist/adapters/schemas/function_schema.d.ts +67 -0
- package/dist/adapters/schemas/function_schema.js +72 -0
- package/dist/adapters/schemas/index.d.ts +2 -0
- package/dist/adapters/schemas/index.js +8 -0
- package/dist/adapters/schemas/tools_schema.d.ts +57 -0
- package/dist/adapters/schemas/tools_schema.js +79 -0
- package/dist/adapters/services/index.d.ts +2 -0
- package/dist/adapters/services/index.js +8 -0
- package/dist/adapters/services/open_ai_adapter.d.ts +147 -0
- package/dist/adapters/services/open_ai_adapter.js +250 -0
- package/dist/audio/dtmf/dtmf_data.d.ts +3 -0
- package/dist/audio/dtmf/dtmf_data.js +22 -0
- package/dist/audio/dtmf/index.d.ts +2 -0
- package/dist/audio/dtmf/index.js +8 -0
- package/dist/audio/dtmf/types.d.ts +31 -0
- package/dist/audio/dtmf/types.js +35 -0
- package/dist/audio/dtmf/utils.d.ts +13 -0
- package/dist/audio/dtmf/utils.js +62 -0
- package/dist/audio/filters/base_audio_filter.d.ts +51 -0
- package/dist/audio/filters/base_audio_filter.js +17 -0
- package/dist/audio/filters/index.d.ts +2 -0
- package/dist/audio/filters/index.js +8 -0
- package/dist/audio/index.d.ts +2 -0
- package/dist/audio/index.js +8 -0
- package/dist/audio/krisp_instance.d.ts +95 -0
- package/dist/audio/krisp_instance.js +229 -0
- package/dist/audio/mixers/base_audio_mixer.d.ts +56 -0
- package/dist/audio/mixers/base_audio_mixer.js +16 -0
- package/dist/audio/mixers/index.d.ts +2 -0
- package/dist/audio/mixers/index.js +8 -0
- package/dist/audio/resamplers/base_audio_resampler.d.ts +46 -0
- package/dist/audio/resamplers/base_audio_resampler.js +35 -0
- package/dist/audio/resamplers/index.d.ts +2 -0
- package/dist/audio/resamplers/index.js +8 -0
- package/dist/audio/resamplers/resampy_resampler.d.ts +10 -0
- package/dist/audio/resamplers/resampy_resampler.js +15 -0
- package/dist/audio/resamplers/soxr_resampler.d.ts +54 -0
- package/dist/audio/resamplers/soxr_resampler.js +69 -0
- package/dist/audio/resamplers/soxr_stream_resampler.d.ts +75 -0
- package/dist/audio/resamplers/soxr_stream_resampler.js +146 -0
- package/dist/audio/turn/base_turn_analyzer.d.ts +84 -0
- package/dist/audio/turn/base_turn_analyzer.js +61 -0
- package/dist/audio/turn/index.d.ts +2 -0
- package/dist/audio/turn/index.js +8 -0
- package/dist/audio/turn/smart_turn/_whisper_features.d.ts +30 -0
- package/dist/audio/turn/smart_turn/_whisper_features.js +225 -0
- package/dist/audio/turn/smart_turn/base_smart_turn.d.ts +94 -0
- package/dist/audio/turn/smart_turn/base_smart_turn.js +239 -0
- package/dist/audio/turn/smart_turn/local_smart_turn_v3.d.ts +76 -0
- package/dist/audio/turn/smart_turn/local_smart_turn_v3.js +143 -0
- package/dist/audio/utils.d.ts +224 -0
- package/dist/audio/utils.js +634 -0
- package/dist/audio/vad/data/index.d.ts +2 -0
- package/dist/audio/vad/data/index.js +8 -0
- package/dist/audio/vad/index.d.ts +2 -0
- package/dist/audio/vad/index.js +8 -0
- package/dist/audio/vad/vad_analyzer.d.ts +126 -0
- package/dist/audio/vad/vad_analyzer.js +211 -0
- package/dist/audio/vad/vad_controller.d.ts +143 -0
- package/dist/audio/vad/vad_controller.js +228 -0
- package/dist/audio/volume.d.ts +38 -0
- package/dist/audio/volume.js +75 -0
- package/dist/bus/adapters/base.d.ts +35 -0
- package/dist/bus/adapters/base.js +19 -0
- package/dist/bus/adapters/index.d.ts +10 -0
- package/dist/bus/adapters/index.js +15 -0
- package/dist/bus/adapters/llm_context_adapter.d.ts +36 -0
- package/dist/bus/adapters/llm_context_adapter.js +82 -0
- package/dist/bus/adapters/tools_schema_adapter.d.ts +25 -0
- package/dist/bus/adapters/tools_schema_adapter.js +70 -0
- package/dist/bus/bridge_processor.d.ts +111 -0
- package/dist/bus/bridge_processor.js +166 -0
- package/dist/bus/bus.d.ts +110 -0
- package/dist/bus/bus.js +200 -0
- package/dist/bus/index.d.ts +22 -0
- package/dist/bus/index.js +27 -0
- package/dist/bus/local/async_queue.d.ts +12 -0
- package/dist/bus/local/async_queue.js +21 -0
- package/dist/bus/local/index.d.ts +3 -0
- package/dist/bus/local/index.js +8 -0
- package/dist/bus/messages.d.ts +378 -0
- package/dist/bus/messages.js +357 -0
- package/dist/bus/network/index.d.ts +16 -0
- package/dist/bus/network/index.js +21 -0
- package/dist/bus/queue.d.ts +27 -0
- package/dist/bus/queue.js +51 -0
- package/dist/bus/serializers/base.d.ts +25 -0
- package/dist/bus/serializers/base.js +14 -0
- package/dist/bus/serializers/index.d.ts +9 -0
- package/dist/bus/serializers/index.js +14 -0
- package/dist/bus/serializers/json.d.ts +77 -0
- package/dist/bus/serializers/json.js +367 -0
- package/dist/bus/subscriber.d.ts +46 -0
- package/dist/bus/subscriber.js +27 -0
- package/dist/bus/ui/index.d.ts +3 -0
- package/dist/bus/ui/index.js +8 -0
- package/dist/bus/ui/messages.d.ts +186 -0
- package/dist/bus/ui/messages.js +171 -0
- package/dist/classifiers/base_classifier.d.ts +263 -0
- package/dist/classifiers/base_classifier.js +346 -0
- package/dist/classifiers/cloudflare/clef/classifier.d.ts +70 -0
- package/dist/classifiers/cloudflare/clef/classifier.js +204 -0
- package/dist/classifiers/cloudflare/clef/client.d.ts +104 -0
- package/dist/classifiers/cloudflare/clef/client.js +234 -0
- package/dist/classifiers/cloudflare/clef/index.d.ts +2 -0
- package/dist/classifiers/cloudflare/clef/index.js +8 -0
- package/dist/classifiers/cloudflare/index.d.ts +2 -0
- package/dist/classifiers/cloudflare/index.js +8 -0
- package/dist/classifiers/http_client.d.ts +70 -0
- package/dist/classifiers/http_client.js +161 -0
- package/dist/classifiers/index.d.ts +2 -0
- package/dist/classifiers/index.js +8 -0
- package/dist/classifiers/jev/classifier.d.ts +8 -0
- package/dist/classifiers/jev/classifier.js +13 -0
- package/dist/classifiers/jev/client.d.ts +8 -0
- package/dist/classifiers/jev/client.js +13 -0
- package/dist/classifiers/jev/index.d.ts +2 -0
- package/dist/classifiers/jev/index.js +8 -0
- package/dist/classifiers/llm/classifier.d.ts +72 -0
- package/dist/classifiers/llm/classifier.js +304 -0
- package/dist/classifiers/llm/index.d.ts +2 -0
- package/dist/classifiers/llm/index.js +8 -0
- package/dist/classifiers/openai/decisions/classifier.d.ts +77 -0
- package/dist/classifiers/openai/decisions/classifier.js +241 -0
- package/dist/classifiers/openai/decisions/client.d.ts +108 -0
- package/dist/classifiers/openai/decisions/client.js +234 -0
- package/dist/classifiers/openai/decisions/index.d.ts +2 -0
- package/dist/classifiers/openai/decisions/index.js +8 -0
- package/dist/classifiers/openai/index.d.ts +2 -0
- package/dist/classifiers/openai/index.js +8 -0
- package/dist/classifiers/typesafe/index.d.ts +2 -0
- package/dist/classifiers/typesafe/index.js +8 -0
- package/dist/classifiers/typesafe/jev/classifier.d.ts +70 -0
- package/dist/classifiers/typesafe/jev/classifier.js +220 -0
- package/dist/classifiers/typesafe/jev/client.d.ts +105 -0
- package/dist/classifiers/typesafe/jev/client.js +233 -0
- package/dist/classifiers/typesafe/jev/index.d.ts +2 -0
- package/dist/classifiers/typesafe/jev/index.js +8 -0
- package/dist/clocks/base_clock.d.ts +13 -0
- package/dist/clocks/base_clock.js +14 -0
- package/dist/clocks/index.d.ts +2 -0
- package/dist/clocks/index.js +8 -0
- package/dist/clocks/system_clock.d.ts +15 -0
- package/dist/clocks/system_clock.js +25 -0
- package/dist/frames/frames.d.ts +2533 -0
- package/dist/frames/frames.js +2485 -0
- package/dist/frames/index.d.ts +2 -0
- package/dist/frames/index.js +8 -0
- package/dist/frames/protobufs/frames_pb2.d.ts +229 -0
- package/dist/frames/protobufs/frames_pb2.js +466 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +56 -0
- package/dist/metrics/index.d.ts +2 -0
- package/dist/metrics/index.js +8 -0
- package/dist/metrics/metrics.d.ts +276 -0
- package/dist/metrics/metrics.js +254 -0
- package/dist/observers/base_observer.d.ts +173 -0
- package/dist/observers/base_observer.js +151 -0
- package/dist/observers/error_observer.d.ts +75 -0
- package/dist/observers/error_observer.js +87 -0
- package/dist/observers/function_call_observer.d.ts +157 -0
- package/dist/observers/function_call_observer.js +222 -0
- package/dist/observers/index.d.ts +2 -0
- package/dist/observers/index.js +8 -0
- package/dist/observers/loggers/debug_log_observer.d.ts +91 -0
- package/dist/observers/loggers/debug_log_observer.js +228 -0
- package/dist/observers/loggers/index.d.ts +2 -0
- package/dist/observers/loggers/index.js +8 -0
- package/dist/observers/loggers/llm_log_observer.d.ts +24 -0
- package/dist/observers/loggers/llm_log_observer.js +110 -0
- package/dist/observers/loggers/metrics_log_observer.d.ts +85 -0
- package/dist/observers/loggers/metrics_log_observer.js +186 -0
- package/dist/observers/loggers/transcription_log_observer.d.ts +23 -0
- package/dist/observers/loggers/transcription_log_observer.js +74 -0
- package/dist/observers/service_metrics_observer.d.ts +168 -0
- package/dist/observers/service_metrics_observer.js +236 -0
- package/dist/observers/speaking_observer.d.ts +104 -0
- package/dist/observers/speaking_observer.js +150 -0
- package/dist/observers/startup_timing_observer.d.ts +221 -0
- package/dist/observers/startup_timing_observer.js +365 -0
- package/dist/observers/turn_tracking_observer.d.ts +78 -0
- package/dist/observers/turn_tracking_observer.js +189 -0
- package/dist/observers/user_bot_latency_observer.d.ts +411 -0
- package/dist/observers/user_bot_latency_observer.js +974 -0
- package/dist/pipeline/base_pipeline.d.ts +49 -0
- package/dist/pipeline/base_pipeline.js +101 -0
- package/dist/pipeline/capabilities.d.ts +76 -0
- package/dist/pipeline/capabilities.js +97 -0
- package/dist/pipeline/index.d.ts +2 -0
- package/dist/pipeline/index.js +8 -0
- package/dist/pipeline/job_context.d.ts +317 -0
- package/dist/pipeline/job_context.js +450 -0
- package/dist/pipeline/job_decorator.d.ts +54 -0
- package/dist/pipeline/job_decorator.js +92 -0
- package/dist/pipeline/llm_switcher.d.ts +84 -0
- package/dist/pipeline/llm_switcher.js +107 -0
- package/dist/pipeline/llm_with_backend.d.ts +435 -0
- package/dist/pipeline/llm_with_backend.js +806 -0
- package/dist/pipeline/parallel_pipeline.d.ts +83 -0
- package/dist/pipeline/parallel_pipeline.js +200 -0
- package/dist/pipeline/pipeline.d.ts +126 -0
- package/dist/pipeline/pipeline.js +196 -0
- package/dist/pipeline/service_switcher.d.ts +287 -0
- package/dist/pipeline/service_switcher.js +509 -0
- package/dist/pipeline/sync_parallel_pipeline.d.ts +192 -0
- package/dist/pipeline/sync_parallel_pipeline.js +387 -0
- package/dist/pipeline/worker.d.ts +814 -0
- package/dist/pipeline/worker.js +1639 -0
- package/dist/pipeline/worker_observer.d.ts +131 -0
- package/dist/pipeline/worker_observer.js +274 -0
- package/dist/pipeline/worker_ready_decorator.d.ts +45 -0
- package/dist/pipeline/worker_ready_decorator.js +76 -0
- package/dist/processors/aggregators/async_tool_messages.d.ts +146 -0
- package/dist/processors/aggregators/async_tool_messages.js +291 -0
- package/dist/processors/aggregators/dtmf_aggregator.d.ts +61 -0
- package/dist/processors/aggregators/dtmf_aggregator.js +144 -0
- package/dist/processors/aggregators/gated.d.ts +43 -0
- package/dist/processors/aggregators/gated.js +86 -0
- package/dist/processors/aggregators/gated_llm_context.d.ts +42 -0
- package/dist/processors/aggregators/gated_llm_context.js +86 -0
- package/dist/processors/aggregators/index.d.ts +2 -0
- package/dist/processors/aggregators/index.js +8 -0
- package/dist/processors/aggregators/llm_context.d.ts +370 -0
- package/dist/processors/aggregators/llm_context.js +580 -0
- package/dist/processors/aggregators/llm_context_summarizer.d.ts +219 -0
- package/dist/processors/aggregators/llm_context_summarizer.js +447 -0
- package/dist/processors/aggregators/llm_response.d.ts +37 -0
- package/dist/processors/aggregators/llm_response.js +71 -0
- package/dist/processors/aggregators/llm_response_universal.d.ts +966 -0
- package/dist/processors/aggregators/llm_response_universal.js +2394 -0
- package/dist/processors/aggregators/llm_text_processor.d.ts +53 -0
- package/dist/processors/aggregators/llm_text_processor.js +102 -0
- package/dist/processors/aggregators/sentence.d.ts +39 -0
- package/dist/processors/aggregators/sentence.js +69 -0
- package/dist/processors/async_generator.d.ts +42 -0
- package/dist/processors/async_generator.js +76 -0
- package/dist/processors/audio/audio_buffer_processor.d.ts +241 -0
- package/dist/processors/audio/audio_buffer_processor.js +565 -0
- package/dist/processors/audio/index.d.ts +2 -0
- package/dist/processors/audio/index.js +8 -0
- package/dist/processors/audio/vad_processor.d.ts +67 -0
- package/dist/processors/audio/vad_processor.js +103 -0
- package/dist/processors/consumer_processor.d.ts +49 -0
- package/dist/processors/consumer_processor.js +85 -0
- package/dist/processors/filters/frame_filter.d.ts +39 -0
- package/dist/processors/filters/frame_filter.js +52 -0
- package/dist/processors/filters/function_filter.d.ts +59 -0
- package/dist/processors/filters/function_filter.js +78 -0
- package/dist/processors/filters/identity_filter.d.ts +33 -0
- package/dist/processors/filters/identity_filter.js +37 -0
- package/dist/processors/filters/index.d.ts +2 -0
- package/dist/processors/filters/index.js +8 -0
- package/dist/processors/filters/null_filter.d.ts +34 -0
- package/dist/processors/filters/null_filter.js +47 -0
- package/dist/processors/filters/wake_notifier_filter.d.ts +48 -0
- package/dist/processors/filters/wake_notifier_filter.js +49 -0
- package/dist/processors/frame_processor.d.ts +360 -0
- package/dist/processors/frame_processor.js +932 -0
- package/dist/processors/frameworks/index.d.ts +2 -0
- package/dist/processors/frameworks/index.js +8 -0
- package/dist/processors/frameworks/rtvi/frames.d.ts +241 -0
- package/dist/processors/frameworks/rtvi/frames.js +259 -0
- package/dist/processors/frameworks/rtvi/index.d.ts +6 -0
- package/dist/processors/frameworks/rtvi/index.js +11 -0
- package/dist/processors/frameworks/rtvi/models.d.ts +1741 -0
- package/dist/processors/frameworks/rtvi/models.js +1807 -0
- package/dist/processors/frameworks/rtvi/observer.d.ts +340 -0
- package/dist/processors/frameworks/rtvi/observer.js +1113 -0
- package/dist/processors/frameworks/rtvi/processor.d.ts +182 -0
- package/dist/processors/frameworks/rtvi/processor.js +676 -0
- package/dist/processors/idle_frame_processor.d.ts +44 -0
- package/dist/processors/idle_frame_processor.js +86 -0
- package/dist/processors/index.d.ts +2 -0
- package/dist/processors/index.js +8 -0
- package/dist/processors/logger.d.ts +42 -0
- package/dist/processors/logger.js +87 -0
- package/dist/processors/metrics/frame_processor_metrics.d.ts +172 -0
- package/dist/processors/metrics/frame_processor_metrics.js +372 -0
- package/dist/processors/metrics/index.d.ts +2 -0
- package/dist/processors/metrics/index.js +8 -0
- package/dist/processors/producer_processor.d.ts +68 -0
- package/dist/processors/producer_processor.js +78 -0
- package/dist/processors/text_transformer.d.ts +30 -0
- package/dist/processors/text_transformer.js +48 -0
- package/dist/registry/index.d.ts +3 -0
- package/dist/registry/index.js +8 -0
- package/dist/registry/registry.d.ts +69 -0
- package/dist/registry/registry.js +149 -0
- package/dist/registry/types.d.ts +47 -0
- package/dist/registry/types.js +39 -0
- package/dist/serializers/base_serializer.d.ts +94 -0
- package/dist/serializers/base_serializer.js +82 -0
- package/dist/serializers/index.d.ts +2 -0
- package/dist/serializers/index.js +8 -0
- package/dist/services/ai_service.d.ts +145 -0
- package/dist/services/ai_service.js +262 -0
- package/dist/services/anthropic/index.d.ts +2 -0
- package/dist/services/anthropic/index.js +7 -0
- package/dist/services/assemblyai/index.d.ts +2 -0
- package/dist/services/assemblyai/index.js +7 -0
- package/dist/services/asyncai/index.d.ts +2 -0
- package/dist/services/asyncai/index.js +7 -0
- package/dist/services/aws/index.d.ts +2 -0
- package/dist/services/aws/index.js +7 -0
- package/dist/services/azure/index.d.ts +2 -0
- package/dist/services/azure/index.js +7 -0
- package/dist/services/baseten/index.d.ts +2 -0
- package/dist/services/baseten/index.js +7 -0
- package/dist/services/bland/index.d.ts +2 -0
- package/dist/services/bland/index.js +7 -0
- package/dist/services/camb/index.d.ts +2 -0
- package/dist/services/camb/index.js +7 -0
- package/dist/services/cartesia/index.d.ts +2 -0
- package/dist/services/cartesia/index.js +7 -0
- package/dist/services/cerebras/index.d.ts +2 -0
- package/dist/services/cerebras/index.js +7 -0
- package/dist/services/crusoe/index.d.ts +2 -0
- package/dist/services/crusoe/index.js +7 -0
- package/dist/services/deepgram/index.d.ts +2 -0
- package/dist/services/deepgram/index.js +7 -0
- package/dist/services/deepseek/index.d.ts +2 -0
- package/dist/services/deepseek/index.js +7 -0
- package/dist/services/elevenlabs/index.d.ts +2 -0
- package/dist/services/elevenlabs/index.js +7 -0
- package/dist/services/fal/index.d.ts +2 -0
- package/dist/services/fal/index.js +7 -0
- package/dist/services/fireworks/index.d.ts +2 -0
- package/dist/services/fireworks/index.js +7 -0
- package/dist/services/fish/index.d.ts +2 -0
- package/dist/services/fish/index.js +7 -0
- package/dist/services/funasr/index.d.ts +3 -0
- package/dist/services/funasr/index.js +8 -0
- package/dist/services/gladia/index.d.ts +2 -0
- package/dist/services/gladia/index.js +7 -0
- package/dist/services/google/index.d.ts +2 -0
- package/dist/services/google/index.js +7 -0
- package/dist/services/gradium/index.d.ts +2 -0
- package/dist/services/gradium/index.js +7 -0
- package/dist/services/grok/index.d.ts +2 -0
- package/dist/services/grok/index.js +7 -0
- package/dist/services/groq/index.d.ts +2 -0
- package/dist/services/groq/index.js +7 -0
- package/dist/services/heygen/index.d.ts +2 -0
- package/dist/services/heygen/index.js +7 -0
- package/dist/services/hume/index.d.ts +2 -0
- package/dist/services/hume/index.js +7 -0
- package/dist/services/image_service.d.ts +52 -0
- package/dist/services/image_service.js +60 -0
- package/dist/services/inception/index.d.ts +2 -0
- package/dist/services/inception/index.js +7 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +8 -0
- package/dist/services/inworld/index.d.ts +2 -0
- package/dist/services/inworld/index.js +7 -0
- package/dist/services/keenable/index.d.ts +2 -0
- package/dist/services/keenable/index.js +7 -0
- package/dist/services/kokoro/index.d.ts +2 -0
- package/dist/services/kokoro/index.js +7 -0
- package/dist/services/llm_service.d.ts +1106 -0
- package/dist/services/llm_service.js +2231 -0
- package/dist/services/mem0/index.d.ts +2 -0
- package/dist/services/mem0/index.js +7 -0
- package/dist/services/meta/index.d.ts +2 -0
- package/dist/services/meta/index.js +7 -0
- package/dist/services/minimax/index.d.ts +2 -0
- package/dist/services/minimax/index.js +7 -0
- package/dist/services/mistral/index.d.ts +2 -0
- package/dist/services/mistral/index.js +7 -0
- package/dist/services/moondream/index.d.ts +2 -0
- package/dist/services/moondream/index.js +7 -0
- package/dist/services/moonshine/index.d.ts +2 -0
- package/dist/services/moonshine/index.js +7 -0
- package/dist/services/nebius/index.d.ts +2 -0
- package/dist/services/nebius/index.js +7 -0
- package/dist/services/neuphonic/index.d.ts +2 -0
- package/dist/services/neuphonic/index.js +7 -0
- package/dist/services/novita/index.d.ts +2 -0
- package/dist/services/novita/index.js +7 -0
- package/dist/services/nvidia/index.d.ts +2 -0
- package/dist/services/nvidia/index.js +11 -0
- package/dist/services/ollama/index.d.ts +2 -0
- package/dist/services/ollama/index.js +7 -0
- package/dist/services/openai/index.d.ts +2 -0
- package/dist/services/openai/index.js +7 -0
- package/dist/services/openclaw/index.d.ts +14 -0
- package/dist/services/openclaw/index.js +19 -0
- package/dist/services/openrouter/index.d.ts +2 -0
- package/dist/services/openrouter/index.js +7 -0
- package/dist/services/perplexity/index.d.ts +2 -0
- package/dist/services/perplexity/index.js +7 -0
- package/dist/services/piper/index.d.ts +2 -0
- package/dist/services/piper/index.js +7 -0
- package/dist/services/pocket_tts/index.d.ts +2 -0
- package/dist/services/pocket_tts/index.js +7 -0
- package/dist/services/qwen/index.d.ts +2 -0
- package/dist/services/qwen/index.js +7 -0
- package/dist/services/resembleai/index.d.ts +2 -0
- package/dist/services/resembleai/index.js +7 -0
- package/dist/services/rime/index.d.ts +2 -0
- package/dist/services/rime/index.js +7 -0
- package/dist/services/sambanova/index.d.ts +2 -0
- package/dist/services/sambanova/index.js +7 -0
- package/dist/services/sarvam/index.d.ts +2 -0
- package/dist/services/sarvam/index.js +7 -0
- package/dist/services/settings.d.ts +356 -0
- package/dist/services/settings.js +437 -0
- package/dist/services/simli/index.d.ts +2 -0
- package/dist/services/simli/index.js +7 -0
- package/dist/services/smallest/index.d.ts +2 -0
- package/dist/services/smallest/index.js +7 -0
- package/dist/services/soniox/index.d.ts +2 -0
- package/dist/services/soniox/index.js +7 -0
- package/dist/services/speechify/index.d.ts +2 -0
- package/dist/services/speechify/index.js +7 -0
- package/dist/services/speechmatics/index.d.ts +2 -0
- package/dist/services/speechmatics/index.js +7 -0
- package/dist/services/stt_latency.d.ts +62 -0
- package/dist/services/stt_latency.js +71 -0
- package/dist/services/stt_service.d.ts +601 -0
- package/dist/services/stt_service.js +1044 -0
- package/dist/services/tavus/index.d.ts +2 -0
- package/dist/services/tavus/index.js +7 -0
- package/dist/services/together/index.d.ts +2 -0
- package/dist/services/together/index.js +7 -0
- package/dist/services/tts_service.d.ts +909 -0
- package/dist/services/tts_service.js +2018 -0
- package/dist/services/ultravox/index.d.ts +2 -0
- package/dist/services/ultravox/index.js +9 -0
- package/dist/services/vision_service.d.ts +56 -0
- package/dist/services/vision_service.js +62 -0
- package/dist/services/websocket_service.d.ts +213 -0
- package/dist/services/websocket_service.js +654 -0
- package/dist/services/whisper/index.d.ts +2 -0
- package/dist/services/whisper/index.js +9 -0
- package/dist/services/xai/index.d.ts +2 -0
- package/dist/services/xai/index.js +9 -0
- package/dist/services/xtts/index.d.ts +2 -0
- package/dist/services/xtts/index.js +9 -0
- package/dist/tests/index.d.ts +2 -0
- package/dist/tests/index.js +8 -0
- package/dist/tests/utils.d.ts +123 -0
- package/dist/tests/utils.js +212 -0
- package/dist/transcriptions/index.d.ts +2 -0
- package/dist/transcriptions/index.js +8 -0
- package/dist/transcriptions/language.d.ts +376 -0
- package/dist/transcriptions/language.js +543 -0
- package/dist/transports/base_input.d.ts +149 -0
- package/dist/transports/base_input.js +338 -0
- package/dist/transports/base_output.d.ts +432 -0
- package/dist/transports/base_output.js +1231 -0
- package/dist/transports/base_transport.d.ts +223 -0
- package/dist/transports/base_transport.js +167 -0
- package/dist/transports/daily/index.d.ts +2 -0
- package/dist/transports/daily/index.js +9 -0
- package/dist/transports/heygen/index.d.ts +2 -0
- package/dist/transports/heygen/index.js +9 -0
- package/dist/transports/index.d.ts +2 -0
- package/dist/transports/index.js +8 -0
- package/dist/transports/lemonslice/index.d.ts +2 -0
- package/dist/transports/lemonslice/index.js +9 -0
- package/dist/transports/livekit/index.d.ts +2 -0
- package/dist/transports/livekit/index.js +9 -0
- package/dist/transports/local/index.d.ts +2 -0
- package/dist/transports/local/index.js +9 -0
- package/dist/transports/moq/index.d.ts +2 -0
- package/dist/transports/moq/index.js +9 -0
- package/dist/transports/smallwebrtc/index.d.ts +2 -0
- package/dist/transports/smallwebrtc/index.js +9 -0
- package/dist/transports/tavus/index.d.ts +2 -0
- package/dist/transports/tavus/index.js +9 -0
- package/dist/transports/video_in_sampler.d.ts +157 -0
- package/dist/transports/video_in_sampler.js +258 -0
- package/dist/transports/vonage/index.d.ts +2 -0
- package/dist/transports/vonage/index.js +9 -0
- package/dist/transports/websocket/index.d.ts +2 -0
- package/dist/transports/websocket/index.js +9 -0
- package/dist/transports/whatsapp/index.d.ts +2 -0
- package/dist/transports/whatsapp/index.js +9 -0
- package/dist/turns/eager_end_of_turn_mixin.d.ts +70 -0
- package/dist/turns/eager_end_of_turn_mixin.js +122 -0
- package/dist/turns/empty_user_turn.d.ts +55 -0
- package/dist/turns/empty_user_turn.js +53 -0
- package/dist/turns/index.d.ts +2 -0
- package/dist/turns/index.js +8 -0
- package/dist/turns/speculation_gate.d.ts +169 -0
- package/dist/turns/speculation_gate.js +294 -0
- package/dist/turns/types.d.ts +33 -0
- package/dist/turns/types.js +35 -0
- package/dist/turns/user_idle_controller.d.ts +94 -0
- package/dist/turns/user_idle_controller.js +187 -0
- package/dist/turns/user_mute/always_user_mute_strategy.d.ts +15 -0
- package/dist/turns/user_mute/always_user_mute_strategy.js +29 -0
- package/dist/turns/user_mute/base_user_mute_strategy.d.ts +39 -0
- package/dist/turns/user_mute/base_user_mute_strategy.js +45 -0
- package/dist/turns/user_mute/first_speech_user_mute_strategy.d.ts +28 -0
- package/dist/turns/user_mute/first_speech_user_mute_strategy.js +52 -0
- package/dist/turns/user_mute/function_call_user_mute_strategy.d.ts +25 -0
- package/dist/turns/user_mute/function_call_user_mute_strategy.js +50 -0
- package/dist/turns/user_mute/index.d.ts +6 -0
- package/dist/turns/user_mute/index.js +11 -0
- package/dist/turns/user_mute/mute_until_first_bot_complete_user_mute_strategy.d.ts +43 -0
- package/dist/turns/user_mute/mute_until_first_bot_complete_user_mute_strategy.js +76 -0
- package/dist/turns/user_start/base_user_turn_start_strategy.d.ts +135 -0
- package/dist/turns/user_start/base_user_turn_start_strategy.js +134 -0
- package/dist/turns/user_start/external_user_turn_start_strategy.d.ts +45 -0
- package/dist/turns/user_start/external_user_turn_start_strategy.js +64 -0
- package/dist/turns/user_start/index.d.ts +8 -0
- package/dist/turns/user_start/index.js +16 -0
- package/dist/turns/user_start/krisp_viva_ip_user_turn_start_strategy.d.ts +133 -0
- package/dist/turns/user_start/krisp_viva_ip_user_turn_start_strategy.js +243 -0
- package/dist/turns/user_start/min_words_user_turn_start_strategy.d.ts +60 -0
- package/dist/turns/user_start/min_words_user_turn_start_strategy.js +102 -0
- package/dist/turns/user_start/transcription_user_turn_start_strategy.d.ts +29 -0
- package/dist/turns/user_start/transcription_user_turn_start_strategy.js +43 -0
- package/dist/turns/user_start/vad_user_turn_start_strategy.d.ts +20 -0
- package/dist/turns/user_start/vad_user_turn_start_strategy.js +31 -0
- package/dist/turns/user_start/wake_phrase_user_turn_start_strategy.d.ts +141 -0
- package/dist/turns/user_start/wake_phrase_user_turn_start_strategy.js +238 -0
- package/dist/turns/user_stop/base_user_turn_stop_strategy.d.ts +174 -0
- package/dist/turns/user_stop/base_user_turn_stop_strategy.js +170 -0
- package/dist/turns/user_stop/deferred_user_turn_stop_strategy.d.ts +81 -0
- package/dist/turns/user_stop/deferred_user_turn_stop_strategy.js +107 -0
- package/dist/turns/user_stop/eager_match_policy.d.ts +36 -0
- package/dist/turns/user_stop/eager_match_policy.js +50 -0
- package/dist/turns/user_stop/eager_user_turn_stop_strategy.d.ts +84 -0
- package/dist/turns/user_stop/eager_user_turn_stop_strategy.js +154 -0
- package/dist/turns/user_stop/external_user_turn_completion_stop_strategy.d.ts +45 -0
- package/dist/turns/user_stop/external_user_turn_completion_stop_strategy.js +55 -0
- package/dist/turns/user_stop/external_user_turn_stop_strategy.d.ts +115 -0
- package/dist/turns/user_stop/external_user_turn_stop_strategy.js +205 -0
- package/dist/turns/user_stop/index.d.ts +10 -0
- package/dist/turns/user_stop/index.js +15 -0
- package/dist/turns/user_stop/llm_turn_completion_user_turn_stop_strategy.d.ts +44 -0
- package/dist/turns/user_stop/llm_turn_completion_user_turn_stop_strategy.js +59 -0
- package/dist/turns/user_stop/speech_timeout_user_turn_stop_strategy.d.ts +140 -0
- package/dist/turns/user_stop/speech_timeout_user_turn_stop_strategy.js +303 -0
- package/dist/turns/user_stop/turn_analyzer_user_turn_stop_strategy.d.ts +135 -0
- package/dist/turns/user_stop/turn_analyzer_user_turn_stop_strategy.js +332 -0
- package/dist/turns/user_turn_completion_mixin.d.ts +147 -0
- package/dist/turns/user_turn_completion_mixin.js +591 -0
- package/dist/turns/user_turn_controller.d.ts +134 -0
- package/dist/turns/user_turn_controller.js +335 -0
- package/dist/turns/user_turn_processor.d.ts +87 -0
- package/dist/turns/user_turn_processor.js +180 -0
- package/dist/turns/user_turn_strategies.d.ts +187 -0
- package/dist/turns/user_turn_strategies.js +222 -0
- package/dist/utils/async_tool_cancellation.d.ts +35 -0
- package/dist/utils/async_tool_cancellation.js +78 -0
- package/dist/utils/asyncio/index.d.ts +2 -0
- package/dist/utils/asyncio/index.js +7 -0
- package/dist/utils/asyncio/task_manager.d.ts +49 -0
- package/dist/utils/asyncio/task_manager.js +105 -0
- package/dist/utils/base_object.d.ts +76 -0
- package/dist/utils/base_object.js +154 -0
- package/dist/utils/context/aggregated_frame_sequencer.d.ts +491 -0
- package/dist/utils/context/aggregated_frame_sequencer.js +803 -0
- package/dist/utils/context/audio_context_manager.d.ts +131 -0
- package/dist/utils/context/audio_context_manager.js +233 -0
- package/dist/utils/context/index.d.ts +2 -0
- package/dist/utils/context/index.js +7 -0
- package/dist/utils/context/llm_context_summarization.d.ts +258 -0
- package/dist/utils/context/llm_context_summarization.js +511 -0
- package/dist/utils/context/text_segment_map.d.ts +611 -0
- package/dist/utils/context/text_segment_map.js +1132 -0
- package/dist/utils/context/word_completion_tracker.d.ts +273 -0
- package/dist/utils/context/word_completion_tracker.js +441 -0
- package/dist/utils/context/word_timestamp_tracker.d.ts +72 -0
- package/dist/utils/context/word_timestamp_tracker.js +98 -0
- package/dist/utils/deprecation.d.ts +28 -0
- package/dist/utils/deprecation.js +75 -0
- package/dist/utils/env.d.ts +38 -0
- package/dist/utils/env.js +62 -0
- package/dist/utils/errors.d.ts +75 -0
- package/dist/utils/errors.js +202 -0
- package/dist/utils/file_resolver.d.ts +126 -0
- package/dist/utils/file_resolver.js +314 -0
- package/dist/utils/file_storage.d.ts +99 -0
- package/dist/utils/file_storage.js +100 -0
- package/dist/utils/frame_queue.d.ts +36 -0
- package/dist/utils/frame_queue.js +66 -0
- package/dist/utils/http.d.ts +39 -0
- package/dist/utils/http.js +53 -0
- package/dist/utils/image.d.ts +15 -0
- package/dist/utils/image.js +30 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/log_config.d.ts +34 -0
- package/dist/utils/log_config.js +76 -0
- package/dist/utils/logger.d.ts +40 -0
- package/dist/utils/logger.js +91 -0
- package/dist/utils/mixin.d.ts +14 -0
- package/dist/utils/mixin.js +63 -0
- package/dist/utils/network.d.ts +73 -0
- package/dist/utils/network.js +90 -0
- package/dist/utils/security/allowed_origins.d.ts +16 -0
- package/dist/utils/security/allowed_origins.js +34 -0
- package/dist/utils/security/index.d.ts +2 -0
- package/dist/utils/security/index.js +7 -0
- package/dist/utils/security/redaction.d.ts +27 -0
- package/dist/utils/security/redaction.js +123 -0
- package/dist/utils/security/ssrf.d.ts +79 -0
- package/dist/utils/security/ssrf.js +327 -0
- package/dist/utils/shared.d.ts +35 -0
- package/dist/utils/shared.js +136 -0
- package/dist/utils/startup.d.ts +17 -0
- package/dist/utils/startup.js +130 -0
- package/dist/utils/string.d.ts +116 -0
- package/dist/utils/string.js +460 -0
- package/dist/utils/sync/base_notifier.d.ts +25 -0
- package/dist/utils/sync/base_notifier.js +16 -0
- package/dist/utils/sync/event_notifier.d.ts +38 -0
- package/dist/utils/sync/event_notifier.js +51 -0
- package/dist/utils/sync/index.d.ts +2 -0
- package/dist/utils/sync/index.js +7 -0
- package/dist/utils/text/alnum_utils.d.ts +109 -0
- package/dist/utils/text/alnum_utils.js +262 -0
- package/dist/utils/text/base_text_aggregator.d.ts +146 -0
- package/dist/utils/text/base_text_aggregator.js +102 -0
- package/dist/utils/text/base_text_filter.d.ts +54 -0
- package/dist/utils/text/base_text_filter.js +50 -0
- package/dist/utils/text/index.d.ts +2 -0
- package/dist/utils/text/index.js +7 -0
- package/dist/utils/text/markdown_text_filter.d.ts +147 -0
- package/dist/utils/text/markdown_text_filter.js +522 -0
- package/dist/utils/text/markup_utils.d.ts +54 -0
- package/dist/utils/text/markup_utils.js +156 -0
- package/dist/utils/text/pattern_pair_aggregator.d.ts +251 -0
- package/dist/utils/text/pattern_pair_aggregator.js +478 -0
- package/dist/utils/text/phonemes.d.ts +60 -0
- package/dist/utils/text/phonemes.js +172 -0
- package/dist/utils/text/simple_text_aggregator.d.ts +135 -0
- package/dist/utils/text/simple_text_aggregator.js +254 -0
- package/dist/utils/text/skip_tags_aggregator.d.ts +85 -0
- package/dist/utils/text/skip_tags_aggregator.js +147 -0
- package/dist/utils/text/transforms/pronunciations.d.ts +65 -0
- package/dist/utils/text/transforms/pronunciations.js +111 -0
- package/dist/utils/text/word_timestamp_utils.d.ts +26 -0
- package/dist/utils/text/word_timestamp_utils.js +52 -0
- package/dist/utils/time.d.ts +13 -0
- package/dist/utils/time.js +31 -0
- package/dist/utils/tracing/index.d.ts +3 -0
- package/dist/utils/tracing/index.js +8 -0
- package/dist/utils/tracing/service_attributes.d.ts +198 -0
- package/dist/utils/tracing/service_attributes.js +434 -0
- package/dist/utils/tracing/service_decorators.d.ts +214 -0
- package/dist/utils/tracing/service_decorators.js +1662 -0
- package/dist/utils/tracing/setup.d.ts +95 -0
- package/dist/utils/tracing/setup.js +110 -0
- package/dist/utils/tracing/tracing_context.d.ts +55 -0
- package/dist/utils/tracing/tracing_context.js +97 -0
- package/dist/utils/tracing/turn_trace_observer.d.ts +90 -0
- package/dist/utils/tracing/turn_trace_observer.js +219 -0
- package/dist/utils/types.d.ts +80 -0
- package/dist/utils/types.js +108 -0
- package/dist/utils/utils.d.ts +5 -0
- package/dist/utils/utils.js +22 -0
- package/dist/utils/yaml.d.ts +64 -0
- package/dist/utils/yaml.js +41 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.js +7 -0
- package/dist/workers/base_worker.d.ts +772 -0
- package/dist/workers/base_worker.js +1298 -0
- package/dist/workers/index.d.ts +2 -0
- package/dist/workers/index.js +8 -0
- package/dist/workers/llm/backend_llm_worker.d.ts +552 -0
- package/dist/workers/llm/backend_llm_worker.js +1055 -0
- package/dist/workers/llm/index.d.ts +6 -0
- package/dist/workers/llm/index.js +11 -0
- package/dist/workers/llm/llm_context_worker.d.ts +66 -0
- package/dist/workers/llm/llm_context_worker.js +72 -0
- package/dist/workers/llm/llm_worker.d.ts +180 -0
- package/dist/workers/llm/llm_worker.js +323 -0
- package/dist/workers/llm/tool_decorator.d.ts +68 -0
- package/dist/workers/llm/tool_decorator.js +60 -0
- package/dist/workers/runner.d.ts +268 -0
- package/dist/workers/runner.js +489 -0
- package/dist/workers/ui/index.d.ts +22 -0
- package/dist/workers/ui/index.js +27 -0
- package/dist/workers/ui/ui_event_decorator.d.ts +43 -0
- package/dist/workers/ui/ui_event_decorator.js +75 -0
- package/dist/workers/ui/ui_job_context.d.ts +12 -0
- package/dist/workers/ui/ui_job_context.js +17 -0
- package/dist/workers/ui/ui_prompts.d.ts +21 -0
- package/dist/workers/ui/ui_prompts.js +41 -0
- package/dist/workers/ui/ui_tools.d.ts +32 -0
- package/dist/workers/ui/ui_tools.js +112 -0
- package/dist/workers/ui/ui_worker.d.ts +571 -0
- package/dist/workers/ui/ui_worker.js +1156 -0
- package/package.json +46 -3
- package/README.md +0 -5
|
@@ -0,0 +1,966 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM response aggregators for handling conversation context and message aggregation.
|
|
3
|
+
*
|
|
4
|
+
* This module provides aggregators that process and accumulate LLM responses,
|
|
5
|
+
* user inputs, and conversation context. These aggregators handle the flow
|
|
6
|
+
* between speech-to-text, LLM processing, and text-to-speech components in
|
|
7
|
+
* conversational AI pipelines.
|
|
8
|
+
*
|
|
9
|
+
* Porting notes: the deprecated `LLMUserAggregatorParams.filterIncompleteUserTurns`
|
|
10
|
+
* / `userTurnCompletionConfig` and `LLMAssistantAggregatorParams.enableContextSummarization`
|
|
11
|
+
* / `contextSummarizationConfig` fields are not ported.
|
|
12
|
+
*/
|
|
13
|
+
import { type Task } from "@pipedog/asyncio";
|
|
14
|
+
import type { ToolsSchema } from "../../adapters/schemas/tools_schema.ts";
|
|
15
|
+
import type { VADAnalyzer } from "../../audio/vad/vad_analyzer.ts";
|
|
16
|
+
import { VADController } from "../../audio/vad/vad_controller.ts";
|
|
17
|
+
import { AssistantImageRawFrame, CancelFrame, EndFrame, type Frame, FunctionCallCancelFrame, FunctionCallInProgressFrame, FunctionCallResultFrame, FunctionCallsStartedFrame, InterruptionFrame, LLMContextFrame, type LLMContextSummaryRequestFrame, LLMFullResponseEndFrame, LLMFullResponseStartFrame, LLMMarkerFrame, LLMMessagesAppendFrame, LLMMessagesTransformFrame, LLMMessagesUpdateFrame, LLMRunFrame, LLMServiceMetadataFrame, LLMThoughtEndFrame, LLMThoughtStartFrame, LLMThoughtTextFrame, ServiceMetadataFrame, STTMetadataFrame, StartFrame, TextFrame, TranscriptionFrame, TTSStartedFrame, UserFileRawFrame, UserImageRawFrame } from "../../frames/frames.ts";
|
|
18
|
+
import { EmptyUserTurnConfig } from "../../turns/empty_user_turn.ts";
|
|
19
|
+
import type { UserTurnSpeculation } from "../../turns/types.ts";
|
|
20
|
+
import { UserIdleController } from "../../turns/user_idle_controller.ts";
|
|
21
|
+
import type { BaseUserMuteStrategy } from "../../turns/user_mute/base_user_mute_strategy.ts";
|
|
22
|
+
import type { BaseUserTurnStartStrategy, UserTurnStartedParams } from "../../turns/user_start/base_user_turn_start_strategy.ts";
|
|
23
|
+
import type { BaseUserTurnStopStrategy, UserTurnStoppedParams } from "../../turns/user_stop/base_user_turn_stop_strategy.ts";
|
|
24
|
+
import { UserTurnController } from "../../turns/user_turn_controller.ts";
|
|
25
|
+
import { UserTurnStrategies } from "../../turns/user_turn_strategies.ts";
|
|
26
|
+
import type { LLMAutoContextSummarizationConfig } from "../../utils/context/llm_context_summarization.ts";
|
|
27
|
+
import { TextPartForConcatenation } from "../../utils/string.ts";
|
|
28
|
+
import { FrameDirection, FrameProcessor, type FrameProcessorOptions, type FrameProcessorSetup } from "../frame_processor.ts";
|
|
29
|
+
import { LLMContext, type LLMContextMessage, type NotGiven } from "./llm_context.ts";
|
|
30
|
+
import { LLMContextSummarizer, type SummaryAppliedEvent } from "./llm_context_summarizer.ts";
|
|
31
|
+
export interface LLMUserAggregatorParamsOptions {
|
|
32
|
+
/**
|
|
33
|
+
* When true, on each `LLMSetToolsFrame` the aggregator computes the diff
|
|
34
|
+
* against the currently advertised tools and appends a developer-role
|
|
35
|
+
* message to the context describing additions/removals. Helps the LLM stay
|
|
36
|
+
* coherent across mid-conversation tool changes, mitigating several
|
|
37
|
+
* flavors of tool-call-related hallucination: calling tools that have been
|
|
38
|
+
* removed, avoiding tools that have been re-added, and hallucinating output
|
|
39
|
+
* (made-up answers or tool-call-shaped non-tool-calls) when tools are
|
|
40
|
+
* unavailable. Only standard tools are diffed; custom (LLM-specific) tools
|
|
41
|
+
* are ignored. When using `LLMContextAggregatorPair`, prefer setting this
|
|
42
|
+
* via its `addToolChangeMessages` argument instead. Defaults to false.
|
|
43
|
+
*/
|
|
44
|
+
addToolChangeMessages?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Timeout in seconds to force speech stop when no audio frames are
|
|
47
|
+
* received while in SPEAKING state (e.g. user mutes mic mid-speech). Set to
|
|
48
|
+
* 0 to disable. Defaults to 1.0.
|
|
49
|
+
*/
|
|
50
|
+
audioIdleTimeout?: number;
|
|
51
|
+
/** User turn start and stop strategies. */
|
|
52
|
+
userTurnStrategies?: UserTurnStrategies | null;
|
|
53
|
+
/** List of user mute strategies. */
|
|
54
|
+
userMuteStrategies?: BaseUserMuteStrategy[];
|
|
55
|
+
/** Time in seconds to wait before considering the user's turn finished. */
|
|
56
|
+
userTurnStopTimeout?: number;
|
|
57
|
+
/**
|
|
58
|
+
* Timeout in seconds for detecting user idle state. The aggregator will
|
|
59
|
+
* emit an `on_user_turn_idle` event when the user has been idle (not
|
|
60
|
+
* speaking) for this duration. Set to 0 to disable idle detection.
|
|
61
|
+
*/
|
|
62
|
+
userIdleTimeout?: number;
|
|
63
|
+
/** Voice Activity Detection analyzer instance. */
|
|
64
|
+
vadAnalyzer?: VADAnalyzer | null;
|
|
65
|
+
/**
|
|
66
|
+
* How to respond to a user turn that ends with no transcript. By default,
|
|
67
|
+
* the bot answers such a turn when it interrupted the bot, and leaves it
|
|
68
|
+
* unanswered otherwise. `null` leaves every such turn unanswered. Ignored
|
|
69
|
+
* with a realtime LLM service, which hears the user's audio directly.
|
|
70
|
+
*/
|
|
71
|
+
emptyUserTurn?: EmptyUserTurnConfig | null;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Parameters for configuring LLM user aggregation behavior.
|
|
75
|
+
*
|
|
76
|
+
* See `LLMUserAggregatorParamsOptions` for the fields.
|
|
77
|
+
*/
|
|
78
|
+
export declare class LLMUserAggregatorParams {
|
|
79
|
+
addToolChangeMessages: boolean;
|
|
80
|
+
audioIdleTimeout: number;
|
|
81
|
+
userTurnStrategies: UserTurnStrategies | null;
|
|
82
|
+
userMuteStrategies: BaseUserMuteStrategy[];
|
|
83
|
+
userTurnStopTimeout: number;
|
|
84
|
+
userIdleTimeout: number;
|
|
85
|
+
vadAnalyzer: VADAnalyzer | null;
|
|
86
|
+
emptyUserTurn: EmptyUserTurnConfig | null;
|
|
87
|
+
constructor(options?: LLMUserAggregatorParamsOptions);
|
|
88
|
+
}
|
|
89
|
+
export interface LLMAssistantAggregatorParamsOptions {
|
|
90
|
+
/**
|
|
91
|
+
* Enable automatic context summarization when token or message-count
|
|
92
|
+
* limits are reached (disabled by default). When enabled, older
|
|
93
|
+
* conversation messages are automatically compressed into summaries to
|
|
94
|
+
* manage context size.
|
|
95
|
+
*/
|
|
96
|
+
enableAutoContextSummarization?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Configuration for automatic context summarization. Controls trigger
|
|
99
|
+
* thresholds, message preservation, and summarization prompts. If null,
|
|
100
|
+
* uses default `LLMAutoContextSummarizationConfig` values.
|
|
101
|
+
*/
|
|
102
|
+
autoContextSummarizationConfig?: LLMAutoContextSummarizationConfig | null;
|
|
103
|
+
/**
|
|
104
|
+
* When true, on each `LLMSetToolsFrame` the aggregator computes the diff
|
|
105
|
+
* against the currently advertised tools and appends a developer-role
|
|
106
|
+
* message to the context describing additions/removals. See
|
|
107
|
+
* `LLMUserAggregatorParamsOptions.addToolChangeMessages`. Defaults to false.
|
|
108
|
+
*/
|
|
109
|
+
addToolChangeMessages?: boolean;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Parameters for configuring LLM assistant aggregation behavior.
|
|
113
|
+
*
|
|
114
|
+
* See `LLMAssistantAggregatorParamsOptions` for the fields.
|
|
115
|
+
*/
|
|
116
|
+
export declare class LLMAssistantAggregatorParams {
|
|
117
|
+
enableAutoContextSummarization: boolean;
|
|
118
|
+
autoContextSummarizationConfig: LLMAutoContextSummarizationConfig | null;
|
|
119
|
+
addToolChangeMessages: boolean;
|
|
120
|
+
constructor(options?: LLMAssistantAggregatorParamsOptions);
|
|
121
|
+
}
|
|
122
|
+
export interface UserTurnStoppedMessageOptions {
|
|
123
|
+
content: string | null;
|
|
124
|
+
timestamp: string;
|
|
125
|
+
userId?: string | null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* A user turn stopped message containing a user transcript update.
|
|
129
|
+
*
|
|
130
|
+
* A message in a conversation transcript containing the user content. This
|
|
131
|
+
* is the aggregated transcript that is then used in the context.
|
|
132
|
+
*
|
|
133
|
+
* - `content`: The message content/text. `null` in realtime mode
|
|
134
|
+
* (`realtimeServiceMode: true`) when fired from a user-turn-stop frame: in
|
|
135
|
+
* realtime mode the user message isn't finalized until the assistant
|
|
136
|
+
* response start acts as the effective end-of-turn signal. Subscribers that
|
|
137
|
+
* need the finalized text should listen to `on_user_turn_message_added`
|
|
138
|
+
* instead.
|
|
139
|
+
* - `timestamp`: When the user turn started.
|
|
140
|
+
* - `userId`: Optional identifier for the user.
|
|
141
|
+
*/
|
|
142
|
+
export declare class UserTurnStoppedMessage {
|
|
143
|
+
content: string | null;
|
|
144
|
+
timestamp: string;
|
|
145
|
+
userId: string | null;
|
|
146
|
+
constructor(options: UserTurnStoppedMessageOptions);
|
|
147
|
+
}
|
|
148
|
+
export interface UserTurnMessageAddedMessageOptions {
|
|
149
|
+
content: string;
|
|
150
|
+
timestamp: string;
|
|
151
|
+
userId?: string | null;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* A message accompanying `on_user_turn_message_added`.
|
|
155
|
+
*
|
|
156
|
+
* Fired when a user message is written to the LLM context. In cascade mode
|
|
157
|
+
* (`realtimeServiceMode: false`) this coincides with `on_user_turn_stopped`.
|
|
158
|
+
* In realtime mode (`realtimeServiceMode: true`) the write is triggered by
|
|
159
|
+
* the assistant response start (or session end), so this event fires
|
|
160
|
+
* decoupled from user-turn-end frames. `content` is always populated.
|
|
161
|
+
*
|
|
162
|
+
* - `content`: The aggregated user transcript.
|
|
163
|
+
* - `timestamp`: When the user turn started.
|
|
164
|
+
* - `userId`: Optional identifier for the user.
|
|
165
|
+
*/
|
|
166
|
+
export declare class UserTurnMessageAddedMessage {
|
|
167
|
+
content: string;
|
|
168
|
+
timestamp: string;
|
|
169
|
+
userId: string | null;
|
|
170
|
+
constructor(options: UserTurnMessageAddedMessageOptions);
|
|
171
|
+
}
|
|
172
|
+
export interface UserBackchannelMessageOptions {
|
|
173
|
+
content: string;
|
|
174
|
+
timestamp: string;
|
|
175
|
+
userId?: string | null;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* A message accompanying `on_user_backchannel`.
|
|
179
|
+
*
|
|
180
|
+
* A short acknowledgment the user said while the bot talks, such as "mhm",
|
|
181
|
+
* which stays out of the LLM context.
|
|
182
|
+
*
|
|
183
|
+
* - `content`: What the user said.
|
|
184
|
+
* - `timestamp`: When the user said it.
|
|
185
|
+
* - `userId`: Optional identifier for the user.
|
|
186
|
+
*/
|
|
187
|
+
export declare class UserBackchannelMessage {
|
|
188
|
+
content: string;
|
|
189
|
+
timestamp: string;
|
|
190
|
+
userId: string | null;
|
|
191
|
+
constructor(options: UserBackchannelMessageOptions);
|
|
192
|
+
}
|
|
193
|
+
export interface AssistantTurnStoppedMessageOptions {
|
|
194
|
+
content: string;
|
|
195
|
+
interrupted: boolean;
|
|
196
|
+
timestamp: string;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* An assistant turn stopped message containing an assistant transcript update.
|
|
200
|
+
*
|
|
201
|
+
* A message in a conversation transcript containing the assistant content.
|
|
202
|
+
* This is the aggregated transcript that is then used in the context.
|
|
203
|
+
*
|
|
204
|
+
* - `content`: The message content/text. May be empty if the LLM returned
|
|
205
|
+
* zero tokens (e.g. turn was interrupted before any tokens were received or
|
|
206
|
+
* pushed).
|
|
207
|
+
* - `interrupted`: Whether the assistant turn was interrupted.
|
|
208
|
+
* - `timestamp`: When the assistant turn started.
|
|
209
|
+
*/
|
|
210
|
+
export declare class AssistantTurnStoppedMessage {
|
|
211
|
+
content: string;
|
|
212
|
+
interrupted: boolean;
|
|
213
|
+
timestamp: string;
|
|
214
|
+
constructor(options: AssistantTurnStoppedMessageOptions);
|
|
215
|
+
}
|
|
216
|
+
export interface AssistantBackchannelMessageOptions {
|
|
217
|
+
content: string;
|
|
218
|
+
timestamp: string;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* A message accompanying `on_assistant_backchannel`.
|
|
222
|
+
*
|
|
223
|
+
* A short acknowledgment the assistant said while the user talks, such as
|
|
224
|
+
* "Mm-hmm.".
|
|
225
|
+
*
|
|
226
|
+
* - `content`: What the assistant said.
|
|
227
|
+
* - `timestamp`: When the assistant started saying it.
|
|
228
|
+
*/
|
|
229
|
+
export declare class AssistantBackchannelMessage {
|
|
230
|
+
content: string;
|
|
231
|
+
timestamp: string;
|
|
232
|
+
constructor(options: AssistantBackchannelMessageOptions);
|
|
233
|
+
}
|
|
234
|
+
export interface AssistantThoughtMessageOptions {
|
|
235
|
+
content: string;
|
|
236
|
+
timestamp: string;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* An assistant thought message containing an assistant thought update.
|
|
240
|
+
*
|
|
241
|
+
* A message in a conversation transcript containing the assistant thought
|
|
242
|
+
* content.
|
|
243
|
+
*
|
|
244
|
+
* - `content`: The message content/text.
|
|
245
|
+
* - `timestamp`: When the thought started.
|
|
246
|
+
*/
|
|
247
|
+
export declare class AssistantThoughtMessage {
|
|
248
|
+
content: string;
|
|
249
|
+
timestamp: string;
|
|
250
|
+
constructor(options: AssistantThoughtMessageOptions);
|
|
251
|
+
}
|
|
252
|
+
export interface LLMContextAggregatorOptions extends FrameProcessorOptions {
|
|
253
|
+
/** The LLM context to use for conversation storage. */
|
|
254
|
+
context: LLMContext;
|
|
255
|
+
/** The role this aggregator represents (e.g. "user", "assistant"). */
|
|
256
|
+
role: string;
|
|
257
|
+
/**
|
|
258
|
+
* See the field of the same name on the aggregator-specific params
|
|
259
|
+
* classes. Subclasses propagate this from their `params`.
|
|
260
|
+
*/
|
|
261
|
+
addToolChangeMessages?: boolean;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Base LLM aggregator that uses an LLMContext for conversation storage.
|
|
265
|
+
*
|
|
266
|
+
* This aggregator maintains conversation state using an LLMContext and pushes
|
|
267
|
+
* LLMContextFrame objects as aggregation frames. It provides common
|
|
268
|
+
* functionality for context-based conversation management.
|
|
269
|
+
*/
|
|
270
|
+
export declare abstract class LLMContextAggregator extends FrameProcessor {
|
|
271
|
+
static readonly TOOL_ACTIVATION_MESSAGE_TEMPLATE: string;
|
|
272
|
+
static readonly TOOL_DEACTIVATION_MESSAGE_TEMPLATE: string;
|
|
273
|
+
protected _context: LLMContext;
|
|
274
|
+
protected _role: string;
|
|
275
|
+
protected _addToolChangeMessages: boolean;
|
|
276
|
+
protected _aggregation: TextPartForConcatenation[];
|
|
277
|
+
/** Initialize the context response aggregator. */
|
|
278
|
+
constructor(options: LLMContextAggregatorOptions);
|
|
279
|
+
/**
|
|
280
|
+
* Append a developer message describing tool add/remove deltas.
|
|
281
|
+
*
|
|
282
|
+
* No-op unless `addToolChangeMessages` was enabled on the aggregator, and
|
|
283
|
+
* no-op when the diff against the currently advertised tools is empty.
|
|
284
|
+
* Custom (LLM-specific) tools are ignored — only standard tools are diffed.
|
|
285
|
+
*
|
|
286
|
+
* Both aggregators call this on every `LLMSetToolsFrame` they handle.
|
|
287
|
+
* Whichever aggregator handles the frame first computes a real diff against
|
|
288
|
+
* the shared context and adds the announcement; by the time the other
|
|
289
|
+
* aggregator sees it (if at all), the context already reflects the new
|
|
290
|
+
* tools, so its diff is empty and no duplicate message is added. This is
|
|
291
|
+
* order-independent: it works whether the frame flows downstream (user
|
|
292
|
+
* aggregator first) or upstream (assistant aggregator first, and consumed
|
|
293
|
+
* without being forwarded).
|
|
294
|
+
*/
|
|
295
|
+
protected _maybeAddToolChangeMessages(newTools: ToolsSchema | NotGiven): void;
|
|
296
|
+
/** Messages from the LLM context. */
|
|
297
|
+
get messages(): LLMContextMessage[];
|
|
298
|
+
/** The role for this aggregator. */
|
|
299
|
+
get role(): string;
|
|
300
|
+
/** The LLMContext instance used by this aggregator. */
|
|
301
|
+
get context(): LLMContext;
|
|
302
|
+
/**
|
|
303
|
+
* Create a context frame with the current context.
|
|
304
|
+
*
|
|
305
|
+
* @returns LLMContextFrame containing the current context.
|
|
306
|
+
*/
|
|
307
|
+
protected _getContextFrame(): LLMContextFrame;
|
|
308
|
+
/**
|
|
309
|
+
* Push a context frame in the specified direction.
|
|
310
|
+
*
|
|
311
|
+
* @param direction The direction to push the frame (upstream or downstream).
|
|
312
|
+
*/
|
|
313
|
+
pushContextFrame(direction?: FrameDirection): Promise<void>;
|
|
314
|
+
/**
|
|
315
|
+
* Add messages to the context.
|
|
316
|
+
*
|
|
317
|
+
* @param messages Messages to add to the conversation context.
|
|
318
|
+
*/
|
|
319
|
+
addMessages(messages: LLMContextMessage[]): void;
|
|
320
|
+
/**
|
|
321
|
+
* Set the context messages.
|
|
322
|
+
*
|
|
323
|
+
* @param messages Messages to replace the current context messages.
|
|
324
|
+
*/
|
|
325
|
+
setMessages(messages: LLMContextMessage[]): void;
|
|
326
|
+
/**
|
|
327
|
+
* Transform the context messages using a provided function.
|
|
328
|
+
*
|
|
329
|
+
* @param transform A function that takes the current list of messages and
|
|
330
|
+
* returns a modified list of messages to set in the context.
|
|
331
|
+
*/
|
|
332
|
+
transformMessages(transform: (messages: LLMContextMessage[]) => LLMContextMessage[]): void;
|
|
333
|
+
/**
|
|
334
|
+
* Set tools in the context.
|
|
335
|
+
*
|
|
336
|
+
* @param tools List of tool definitions to set in the context.
|
|
337
|
+
*/
|
|
338
|
+
setTools(tools: ToolsSchema | NotGiven): void;
|
|
339
|
+
/**
|
|
340
|
+
* Set tool choice in the context.
|
|
341
|
+
*
|
|
342
|
+
* @param toolChoice Tool choice configuration for the context.
|
|
343
|
+
*/
|
|
344
|
+
setToolChoice(toolChoice: "none" | "auto" | "required" | Record<string, unknown>): void;
|
|
345
|
+
/** Reset the aggregation state. */
|
|
346
|
+
reset(): Promise<void>;
|
|
347
|
+
/**
|
|
348
|
+
* Push the current aggregation downstream.
|
|
349
|
+
*
|
|
350
|
+
* @returns The pushed aggregation.
|
|
351
|
+
*/
|
|
352
|
+
abstract pushAggregation(): Promise<string>;
|
|
353
|
+
/**
|
|
354
|
+
* Get the current aggregation as a string.
|
|
355
|
+
*
|
|
356
|
+
* @returns The concatenated aggregation string.
|
|
357
|
+
*/
|
|
358
|
+
aggregationString(): string;
|
|
359
|
+
}
|
|
360
|
+
export interface LLMUserAggregatorOptions extends FrameProcessorOptions {
|
|
361
|
+
/** Configuration parameters for aggregation behavior. */
|
|
362
|
+
params?: LLMUserAggregatorParams | null;
|
|
363
|
+
/**
|
|
364
|
+
* Pair-internal. Realtime-mode flag propagated from
|
|
365
|
+
* `LLMContextAggregatorPair` (`null` = auto-configure from service
|
|
366
|
+
* metadata). Not intended for direct use — construct the aggregators via
|
|
367
|
+
* the pair.
|
|
368
|
+
*/
|
|
369
|
+
_realtimeServiceMode?: boolean | null;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* User LLM aggregator that aggregates user input during active user turns.
|
|
373
|
+
*
|
|
374
|
+
* This aggregator uses a turn controller and operates within turn boundaries
|
|
375
|
+
* defined by the controller's configured user turn strategies. User turn
|
|
376
|
+
* start strategies indicate when a user turn begins, while user turn stop
|
|
377
|
+
* strategies signal when the user turn has ended.
|
|
378
|
+
*
|
|
379
|
+
* The aggregator collects and aggregates speech-to-text transcriptions that
|
|
380
|
+
* occur while a user turn is active and pushes the final aggregation when the
|
|
381
|
+
* user turn is finished.
|
|
382
|
+
*
|
|
383
|
+
* Event handlers available:
|
|
384
|
+
*
|
|
385
|
+
* - on_user_turn_started: Called when the user turn starts
|
|
386
|
+
* - on_user_turn_stopped: Called when the user turn ends
|
|
387
|
+
* - on_user_turn_stop_timeout: Called when no user turn stop strategy triggers
|
|
388
|
+
* - on_user_turn_idle: Called when the user has been idle for the configured timeout
|
|
389
|
+
* - on_user_turn_message_added: Called when a user message is written to
|
|
390
|
+
* context. In realtime mode (`realtimeServiceMode: true`) the write is
|
|
391
|
+
* triggered by the assistant response start rather than the user-turn-end
|
|
392
|
+
* frame, so this fires decoupled from `on_user_turn_stopped` — subscribe
|
|
393
|
+
* here for the finalized user text.
|
|
394
|
+
* - on_user_mute_started: Called when the user becomes muted
|
|
395
|
+
* - on_user_mute_stopped: Called when the user becomes unmuted
|
|
396
|
+
* - on_user_backchannel: Called when the user acknowledges the bot without
|
|
397
|
+
* interrupting it, from a `UserBackchannelFrame`
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* aggregator.eventHandler("on_user_turn_started", async (aggregator, strategy: BaseUserTurnStartStrategy) => {});
|
|
401
|
+
* aggregator.eventHandler(
|
|
402
|
+
* "on_user_turn_stopped",
|
|
403
|
+
* async (aggregator, strategy: BaseUserTurnStopStrategy, message: UserTurnStoppedMessage) => {},
|
|
404
|
+
* );
|
|
405
|
+
* aggregator.eventHandler("on_user_turn_stop_timeout", async (aggregator) => {});
|
|
406
|
+
* aggregator.eventHandler("on_user_turn_idle", async (aggregator) => {});
|
|
407
|
+
* // In realtime mode the user message is written when the assistant response
|
|
408
|
+
* // starts, not at user-turn-end — subscribe here for the finalized text.
|
|
409
|
+
* aggregator.eventHandler(
|
|
410
|
+
* "on_user_turn_message_added",
|
|
411
|
+
* async (aggregator, message: UserTurnMessageAddedMessage) => {},
|
|
412
|
+
* );
|
|
413
|
+
* aggregator.eventHandler("on_user_mute_started", async (aggregator) => {});
|
|
414
|
+
* aggregator.eventHandler("on_user_mute_stopped", async (aggregator) => {});
|
|
415
|
+
* aggregator.eventHandler("on_user_backchannel", async (aggregator, message: UserBackchannelMessage) => {});
|
|
416
|
+
*/
|
|
417
|
+
export declare class LLMUserAggregator extends LLMContextAggregator {
|
|
418
|
+
protected _params: LLMUserAggregatorParams;
|
|
419
|
+
protected _realtimeServiceMode: boolean | null;
|
|
420
|
+
protected _userIsMuted: boolean;
|
|
421
|
+
protected _userTurnStartTimestamp: string;
|
|
422
|
+
protected _realtimeMetadataHandled: boolean;
|
|
423
|
+
protected _ttfsP99Latency: number | null;
|
|
424
|
+
protected _realtimeHandoffFlushTask: Task<unknown> | null;
|
|
425
|
+
protected _fullUserTurnAggregation: string | null;
|
|
426
|
+
protected _userTurnInterruptedBot: boolean;
|
|
427
|
+
protected _consecutiveEmptyUserTurnRecoveries: number;
|
|
428
|
+
_userTurnController: UserTurnController;
|
|
429
|
+
protected _userIdleController: UserIdleController;
|
|
430
|
+
protected _vadController: VADController | null;
|
|
431
|
+
/**
|
|
432
|
+
* Initialize the user context aggregator.
|
|
433
|
+
*
|
|
434
|
+
* @param context The LLM context for conversation storage.
|
|
435
|
+
*/
|
|
436
|
+
constructor(context: LLMContext, options?: LLMUserAggregatorOptions);
|
|
437
|
+
/**
|
|
438
|
+
* Set up the aggregator.
|
|
439
|
+
*
|
|
440
|
+
* @param setup Configuration object containing setup parameters.
|
|
441
|
+
*/
|
|
442
|
+
setup(setup: FrameProcessorSetup): Promise<void>;
|
|
443
|
+
/** Release this aggregator's resources at teardown. */
|
|
444
|
+
cleanup(): Promise<void>;
|
|
445
|
+
/**
|
|
446
|
+
* Process frames for user speech aggregation and context management.
|
|
447
|
+
*
|
|
448
|
+
* @param frame The frame to process.
|
|
449
|
+
* @param direction The direction of frame flow in the pipeline.
|
|
450
|
+
*/
|
|
451
|
+
processFrame(frame: Frame, direction: FrameDirection): Promise<void>;
|
|
452
|
+
/** Push the current aggregation. */
|
|
453
|
+
pushAggregation(): Promise<string>;
|
|
454
|
+
/**
|
|
455
|
+
* Write the aggregated user turn to the context.
|
|
456
|
+
*
|
|
457
|
+
* @param options.runLlm Whether to emit the LLMContextFrame that runs
|
|
458
|
+
* inference. False when the response is already generated — an eager end
|
|
459
|
+
* of turn that held — and only the context write is still owed.
|
|
460
|
+
* @returns The text written, or "" when there was nothing to write.
|
|
461
|
+
*/
|
|
462
|
+
protected _pushAggregation(options?: {
|
|
463
|
+
runLlm?: boolean;
|
|
464
|
+
}): Promise<string>;
|
|
465
|
+
protected _start(_frame: StartFrame): Promise<void>;
|
|
466
|
+
protected _stop(_frame: EndFrame): Promise<void>;
|
|
467
|
+
protected _cancel(_frame: CancelFrame): Promise<void>;
|
|
468
|
+
/**
|
|
469
|
+
* Mutate turn strategies for realtime mode.
|
|
470
|
+
*
|
|
471
|
+
* Drops `TranscriptionUserTurnStartStrategy` from the start strategies
|
|
472
|
+
* (transcripts shouldn't start a turn when the realtime service drives the
|
|
473
|
+
* conversation) and flips `waitForTranscript = false` on stop strategies
|
|
474
|
+
* that expose the flag, so end-of-turn fires as soon as VAD / the turn
|
|
475
|
+
* analyzer reports end-of-speech.
|
|
476
|
+
*/
|
|
477
|
+
protected _applyRealtimeModeStrategyMutations(userTurnStrategies: UserTurnStrategies, areUserProvidedCustomStrategies: boolean): void;
|
|
478
|
+
/**
|
|
479
|
+
* Turn off empty user turn recovery for realtime mode.
|
|
480
|
+
*
|
|
481
|
+
* A realtime LLM service hears the user's audio directly, so an empty
|
|
482
|
+
* transcript doesn't mean the model missed the speech.
|
|
483
|
+
*/
|
|
484
|
+
protected _disableEmptyUserTurnRecovery(): void;
|
|
485
|
+
/**
|
|
486
|
+
* Dispatch a service metadata frame.
|
|
487
|
+
*
|
|
488
|
+
* Any service may recommend user turn strategies via the base
|
|
489
|
+
* `userTurnStrategies` field, so apply that first — regardless of service
|
|
490
|
+
* type or realtime mode — then run type-specific handling.
|
|
491
|
+
*/
|
|
492
|
+
protected _handleServiceMetadata(frame: ServiceMetadataFrame): Promise<void>;
|
|
493
|
+
/**
|
|
494
|
+
* Handle an `STTMetadataFrame` broadcast by an STT service at start.
|
|
495
|
+
*
|
|
496
|
+
* Captures the STT TTFS P99 so the realtime-mode deferred handoff flush can
|
|
497
|
+
* size itself to the real transcript-arrival latency. Any recommended user
|
|
498
|
+
* turn strategies were already applied by `_handleServiceMetadata`.
|
|
499
|
+
*/
|
|
500
|
+
protected _handleSttMetadata(frame: STTMetadataFrame): Promise<void>;
|
|
501
|
+
/**
|
|
502
|
+
* Apply user turn strategies a service recommends via its metadata frame.
|
|
503
|
+
*
|
|
504
|
+
* Honored only when the user did not pass their own `userTurnStrategies`,
|
|
505
|
+
* which always wins. `updateStrategies` is idempotent, so this is safe to
|
|
506
|
+
* re-run on a later broadcast (e.g. a ServiceSwitcher switch).
|
|
507
|
+
*/
|
|
508
|
+
protected _handleServiceUserTurnStrategies(serviceName: string, userTurnStrategies: UserTurnStrategies | null): Promise<void>;
|
|
509
|
+
/**
|
|
510
|
+
* Warn when (maybe unintentionally) overruling a service silently turns interruptions back on.
|
|
511
|
+
*
|
|
512
|
+
* A service recommends turn strategies by putting them on its
|
|
513
|
+
* `ServiceMetadataFrame.userTurnStrategies`, and one configured with
|
|
514
|
+
* `shouldInterrupt: false` carries that setting there. User-provided
|
|
515
|
+
* strategies discard the recommendation whole — so the pipeline would
|
|
516
|
+
* start interrupting with no indication why.
|
|
517
|
+
*
|
|
518
|
+
* Passing `ExternalUserTurnStrategies` explicitly was a safe way to opt out
|
|
519
|
+
* of the recommendation until 1.8.0, because the external start strategy
|
|
520
|
+
* never interrupted no matter how it was constructed. It broadcasts the
|
|
521
|
+
* interruption now, so explicit strategies can contradict the service, and
|
|
522
|
+
* this warning names the two ways to reconcile them.
|
|
523
|
+
*
|
|
524
|
+
* Only that container is checked. A `UserTurnStrategies` assembled by hand
|
|
525
|
+
* around a bare `ExternalUserTurnStartStrategy` contradicts the service the
|
|
526
|
+
* same way and goes unwarned — not expected to come up often enough to
|
|
527
|
+
* justify inspecting the individual strategies.
|
|
528
|
+
*/
|
|
529
|
+
protected _warnOnDiscardedInterruptionSetting(serviceName: string, recommended: UserTurnStrategies): void;
|
|
530
|
+
/**
|
|
531
|
+
* Handle an `LLMServiceMetadataFrame` broadcast by an LLM service.
|
|
532
|
+
*
|
|
533
|
+
* Non-realtime services need no configuration. For a realtime service,
|
|
534
|
+
* auto-configure `realtimeServiceMode` (once) when the user left it unset
|
|
535
|
+
* (`null`); an explicit `true`/`false` is honored as-is (`false` opts out
|
|
536
|
+
* silently). When the mode is active, strip transcript dependence from the
|
|
537
|
+
* active strategies — including any external strategies
|
|
538
|
+
* `_handleServiceMetadata` just adopted.
|
|
539
|
+
*
|
|
540
|
+
* The strategy mutation re-runs on every broadcast (so a re-adopted
|
|
541
|
+
* recommendation is re-mutated, e.g. after a ServiceSwitcher switch); only
|
|
542
|
+
* the auto-configuration + log is one-shot. `updateStrategies` is
|
|
543
|
+
* idempotent, so re-applying is safe.
|
|
544
|
+
*/
|
|
545
|
+
protected _handleLlmServiceMetadata(frame: LLMServiceMetadataFrame): Promise<void>;
|
|
546
|
+
/**
|
|
547
|
+
* Commit the user message in realtime mode, allowing for late transcripts.
|
|
548
|
+
*
|
|
549
|
+
* Called by the paired assistant half when the assistant response starts —
|
|
550
|
+
* realtime mode treats that as the user turn's end signal for
|
|
551
|
+
* context-writing purposes (in place of `UserStoppedSpeakingFrame`).
|
|
552
|
+
* Realtime services may deliver the finalized user `TranscriptionFrame` in
|
|
553
|
+
* pieces, and some deliver it only after the assistant starts responding,
|
|
554
|
+
* so we always defer the flush by `ttfsP99Latency` to let any in-flight
|
|
555
|
+
* transcript land. The `_realtimeHandoffFlushImmediate` failsafe on
|
|
556
|
+
* `LLMFullResponseEndFrame` catches any stragglers.
|
|
557
|
+
*
|
|
558
|
+
* Pair-internal: called by the paired LLMAssistantAggregator.
|
|
559
|
+
*/
|
|
560
|
+
_realtimeHandoffFlush(): Promise<void>;
|
|
561
|
+
/** Wait one `ttfsP99Latency` window, then flush whatever has arrived. */
|
|
562
|
+
protected _realtimeDeferredHandoffFlush(): Promise<void>;
|
|
563
|
+
/**
|
|
564
|
+
* Failsafe flush invoked when the assistant response ends.
|
|
565
|
+
*
|
|
566
|
+
* By the time the assistant response has fully completed, even slow
|
|
567
|
+
* transcripts should have landed. Cancel any pending deferred flush and
|
|
568
|
+
* write the user message now so it precedes the assistant message in
|
|
569
|
+
* context.
|
|
570
|
+
*
|
|
571
|
+
* Pair-internal: called by the paired LLMAssistantAggregator.
|
|
572
|
+
*/
|
|
573
|
+
_realtimeHandoffFlushImmediate(): Promise<void>;
|
|
574
|
+
protected _cancelRealtimeHandoffFlushTask(): Promise<void>;
|
|
575
|
+
protected _startControllers(): Promise<void>;
|
|
576
|
+
protected _stopControllers(): Promise<void>;
|
|
577
|
+
protected _maybeMuteFrame(frame: Frame): Promise<boolean>;
|
|
578
|
+
protected _handleLlmRun(_frame: LLMRunFrame): Promise<void>;
|
|
579
|
+
protected _handleLlmMessagesAppend(frame: LLMMessagesAppendFrame): Promise<void>;
|
|
580
|
+
protected _handleLlmMessagesUpdate(frame: LLMMessagesUpdateFrame): Promise<void>;
|
|
581
|
+
protected _handleLlmMessagesTransform(frame: LLMMessagesTransformFrame): Promise<void>;
|
|
582
|
+
protected _handleTranscription(frame: TranscriptionFrame): Promise<void>;
|
|
583
|
+
/**
|
|
584
|
+
* Broadcasts a frame upstream and queues it for internal processing.
|
|
585
|
+
*
|
|
586
|
+
* Queues the frame so it flows through `processFrame` and is handled
|
|
587
|
+
* internally (e.g. by the `UserTurnController`). The upstream frame is
|
|
588
|
+
* pushed directly.
|
|
589
|
+
*
|
|
590
|
+
* @param frameCls The class of the frame to be broadcasted.
|
|
591
|
+
* @param options Options to be passed to the frame's constructor.
|
|
592
|
+
*/
|
|
593
|
+
protected _queuedBroadcastFrame<O>(frameCls: new (options: O) => Frame, options?: O): Promise<void>;
|
|
594
|
+
protected _onPushFrame(_controller: unknown, frame: Frame, direction?: FrameDirection): Promise<void>;
|
|
595
|
+
protected _onBroadcastFrame<O>(_controller: unknown, frameCls: new (options: O) => Frame, options?: O): Promise<void>;
|
|
596
|
+
protected _onUserTurnSpeculationCancelled(_controller: unknown): Promise<void>;
|
|
597
|
+
protected _onVadSpeechStarted(controller: VADController): Promise<void>;
|
|
598
|
+
protected _onVadSpeechStopped(controller: VADController): Promise<void>;
|
|
599
|
+
protected _onVadSpeechActivity(_controller: VADController): Promise<void>;
|
|
600
|
+
protected _onUserTurnStarted(_controller: UserTurnController, strategy: BaseUserTurnStartStrategy, params: UserTurnStartedParams): Promise<void>;
|
|
601
|
+
protected _onUserTurnInferenceTriggered(_controller: UserTurnController, strategy: BaseUserTurnStopStrategy, speculation?: UserTurnSpeculation | null): Promise<void>;
|
|
602
|
+
/**
|
|
603
|
+
* Run an inference for a turn that hasn't ended yet.
|
|
604
|
+
*
|
|
605
|
+
* The turn is still open, so the context must not record it. The inference
|
|
606
|
+
* runs against a provisional copy carrying the speculated turn text:
|
|
607
|
+
* nothing here mutates the real context, and `_aggregation` keeps
|
|
608
|
+
* accumulating for whenever the turn does end. The response is held
|
|
609
|
+
* downstream until the turn is confirmed, and discarded if it isn't.
|
|
610
|
+
*
|
|
611
|
+
* @param speculation The speculation to run, from the stop strategy that
|
|
612
|
+
* started it.
|
|
613
|
+
*/
|
|
614
|
+
protected _runSpeculativeInference(speculation: UserTurnSpeculation): Promise<void>;
|
|
615
|
+
protected _onUserTurnStopped(_controller: UserTurnController, strategy: BaseUserTurnStopStrategy, params: UserTurnStoppedParams): Promise<void>;
|
|
616
|
+
protected _onResetAggregation(_controller: UserTurnController, strategy: BaseUserTurnStartStrategy): Promise<void>;
|
|
617
|
+
protected _onUserTurnStopTimeout(_controller: unknown): Promise<void>;
|
|
618
|
+
protected _onUserTurnIdle(_controller: unknown): Promise<void>;
|
|
619
|
+
/**
|
|
620
|
+
* Maybe emit user turn stopped event.
|
|
621
|
+
*
|
|
622
|
+
* Earlier inference triggers in the same turn have already pushed their
|
|
623
|
+
* segments to the context and accumulated them into
|
|
624
|
+
* `this._fullUserTurnAggregation`. Any aggregation that arrived after the
|
|
625
|
+
* last inference trigger is flushed here so end-of-turn content is never
|
|
626
|
+
* lost from the public event.
|
|
627
|
+
*
|
|
628
|
+
* @param options.strategy The strategy that triggered the turn stop.
|
|
629
|
+
* @param options.onSessionEnd If true, only emit if there's unemitted
|
|
630
|
+
* content (avoids duplicate events when session ends).
|
|
631
|
+
* @param options.runLlm Whether the context write should run inference.
|
|
632
|
+
*/
|
|
633
|
+
protected _maybeEmitUserTurnStopped(options?: {
|
|
634
|
+
strategy?: BaseUserTurnStopStrategy | null;
|
|
635
|
+
onSessionEnd?: boolean;
|
|
636
|
+
runLlm?: boolean;
|
|
637
|
+
}): Promise<void>;
|
|
638
|
+
/**
|
|
639
|
+
* Run the LLM for a user turn that ended with no transcript.
|
|
640
|
+
*
|
|
641
|
+
* @param interruptedBot Whether the turn interrupted a response in progress.
|
|
642
|
+
* @returns Whether the LLM was asked to respond.
|
|
643
|
+
*/
|
|
644
|
+
protected _maybeRecoverEmptyUserTurn(interruptedBot: boolean): Promise<boolean>;
|
|
645
|
+
}
|
|
646
|
+
export interface LLMAssistantAggregatorOptions extends FrameProcessorOptions {
|
|
647
|
+
/** Configuration parameters for aggregation behavior. */
|
|
648
|
+
params?: LLMAssistantAggregatorParams | null;
|
|
649
|
+
/**
|
|
650
|
+
* Pair-internal. Realtime-mode flag propagated from
|
|
651
|
+
* `LLMContextAggregatorPair` (`null` = auto-configure from service
|
|
652
|
+
* metadata). Not intended for direct use — construct the aggregators via
|
|
653
|
+
* the pair.
|
|
654
|
+
*/
|
|
655
|
+
_realtimeServiceMode?: boolean | null;
|
|
656
|
+
/**
|
|
657
|
+
* Pair-internal. Back-reference to the paired `LLMUserAggregator`. The
|
|
658
|
+
* assistant flushes it on `LLMFullResponseStartFrame` so the user message
|
|
659
|
+
* lands in context before the assistant turn starts.
|
|
660
|
+
*/
|
|
661
|
+
_pairedUserAggregator?: LLMUserAggregator | null;
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Assistant LLM aggregator that processes bot responses and function calls.
|
|
665
|
+
*
|
|
666
|
+
* This aggregator handles the complex logic of processing assistant
|
|
667
|
+
* responses including:
|
|
668
|
+
*
|
|
669
|
+
* - Text frame aggregation between response start/end markers
|
|
670
|
+
* - Function call lifecycle management
|
|
671
|
+
* - Context updates with timestamps
|
|
672
|
+
* - Tool execution and result handling
|
|
673
|
+
* - Interruption handling during responses
|
|
674
|
+
*
|
|
675
|
+
* The aggregator manages function calls in progress and coordinates between
|
|
676
|
+
* text generation and tool execution phases of LLM responses.
|
|
677
|
+
*
|
|
678
|
+
* Event handlers available:
|
|
679
|
+
*
|
|
680
|
+
* - on_assistant_turn_started: Called when the assistant turn starts
|
|
681
|
+
* - on_assistant_turn_stopped: Called when the assistant turn ends
|
|
682
|
+
* - on_assistant_thought: Called when an assistant thought is available
|
|
683
|
+
* - on_assistant_backchannel: Called when the assistant starts saying text of
|
|
684
|
+
* type `backchannel`, such as a `BotBackchannelFrame`
|
|
685
|
+
* - on_summary_applied: Called when a context summarization is applied
|
|
686
|
+
*
|
|
687
|
+
* @example
|
|
688
|
+
* aggregator.eventHandler("on_assistant_turn_started", async (aggregator) => {});
|
|
689
|
+
* aggregator.eventHandler(
|
|
690
|
+
* "on_assistant_turn_stopped",
|
|
691
|
+
* async (aggregator, message: AssistantTurnStoppedMessage) => {},
|
|
692
|
+
* );
|
|
693
|
+
* aggregator.eventHandler("on_assistant_thought", async (aggregator, message: AssistantThoughtMessage) => {});
|
|
694
|
+
* aggregator.eventHandler(
|
|
695
|
+
* "on_assistant_backchannel",
|
|
696
|
+
* async (aggregator, message: AssistantBackchannelMessage) => {},
|
|
697
|
+
* );
|
|
698
|
+
* aggregator.eventHandler(
|
|
699
|
+
* "on_summary_applied",
|
|
700
|
+
* async (aggregator, summarizer: LLMContextSummarizer, event: SummaryAppliedEvent) => {},
|
|
701
|
+
* );
|
|
702
|
+
*/
|
|
703
|
+
export declare class LLMAssistantAggregator extends LLMContextAggregator {
|
|
704
|
+
protected _params: LLMAssistantAggregatorParams;
|
|
705
|
+
protected _realtimeServiceMode: boolean | null;
|
|
706
|
+
protected _pairedUserAggregator: LLMUserAggregator | null;
|
|
707
|
+
protected _functionCallsInProgress: Map<string, FunctionCallInProgressFrame | null>;
|
|
708
|
+
protected _functionCallsImageResults: Map<string, UserImageRawFrame>;
|
|
709
|
+
protected _seenTurnMarkers: Set<string>;
|
|
710
|
+
protected _contextUpdatedTasks: Set<Task<unknown>>;
|
|
711
|
+
protected _userSpeaking: boolean;
|
|
712
|
+
protected _botSpeaking: boolean;
|
|
713
|
+
protected _pushContextOnBotStoppedSpeaking: boolean;
|
|
714
|
+
protected _contextPushOwed: boolean;
|
|
715
|
+
protected _assistantTurnStartTimestamp: string;
|
|
716
|
+
protected _thoughtAppendToContext: boolean;
|
|
717
|
+
protected _thoughtLlm: string;
|
|
718
|
+
protected _thoughtAggregation: TextPartForConcatenation[];
|
|
719
|
+
protected _thoughtStartTime: string;
|
|
720
|
+
protected _summarizer: LLMContextSummarizer | null;
|
|
721
|
+
/**
|
|
722
|
+
* Initialize the assistant context aggregator.
|
|
723
|
+
*
|
|
724
|
+
* @param context The LLM context for conversation storage.
|
|
725
|
+
*/
|
|
726
|
+
constructor(context: LLMContext, options?: LLMAssistantAggregatorOptions);
|
|
727
|
+
/** Whether there are any function calls currently in progress. */
|
|
728
|
+
get hasFunctionCallsInProgress(): boolean;
|
|
729
|
+
/**
|
|
730
|
+
* Whether a synchronous call is in flight, one whose result the model waits for.
|
|
731
|
+
*
|
|
732
|
+
* A synchronous call leaves the context without its result until it
|
|
733
|
+
* returns, so the model cannot run in the meantime; an asynchronous one
|
|
734
|
+
* (`cancelOnInterruption: false`) has a placeholder result in the context
|
|
735
|
+
* and the model runs on. A call announced but not yet started counts as
|
|
736
|
+
* synchronous.
|
|
737
|
+
*/
|
|
738
|
+
get hasSynchronousFunctionCallsInProgress(): boolean;
|
|
739
|
+
/**
|
|
740
|
+
* Set up the aggregator.
|
|
741
|
+
*
|
|
742
|
+
* @param setup Configuration object containing setup parameters.
|
|
743
|
+
*/
|
|
744
|
+
setup(setup: FrameProcessorSetup): Promise<void>;
|
|
745
|
+
/** Release this aggregator's resources at teardown. */
|
|
746
|
+
cleanup(): Promise<void>;
|
|
747
|
+
/** Reset the aggregation state. */
|
|
748
|
+
reset(): Promise<void>;
|
|
749
|
+
/** Reset the thought aggregation state. */
|
|
750
|
+
protected _resetThoughtAggregation(): Promise<void>;
|
|
751
|
+
/**
|
|
752
|
+
* Process frames for assistant response aggregation and function call management.
|
|
753
|
+
*
|
|
754
|
+
* @param frame The frame to process.
|
|
755
|
+
* @param direction The direction of frame flow in the pipeline.
|
|
756
|
+
*/
|
|
757
|
+
processFrame(frame: Frame, direction: FrameDirection): Promise<void>;
|
|
758
|
+
protected _start(_frame: StartFrame): Promise<void>;
|
|
759
|
+
/**
|
|
760
|
+
* Throw if realtime mode is active without a paired user aggregator.
|
|
761
|
+
*
|
|
762
|
+
* Realtime mode needs the assistant half to hold a back-reference to the
|
|
763
|
+
* user half so it can flush the user message on `LLMFullResponseStartFrame`.
|
|
764
|
+
* The pair wires this unconditionally (so the halves are always configured
|
|
765
|
+
* together); this guards unsupported direct construction, surfacing the
|
|
766
|
+
* missing flush loudly instead of silently dropping user messages. Checked
|
|
767
|
+
* at `StartFrame` for an explicit mode and again when the mode auto-enables.
|
|
768
|
+
*
|
|
769
|
+
* @throws Error (upstream: RuntimeError) when no user aggregator is paired.
|
|
770
|
+
*/
|
|
771
|
+
protected _requirePairedUserAggregator(): void;
|
|
772
|
+
/** Push the current assistant aggregation with timestamp. */
|
|
773
|
+
pushAggregation(): Promise<string>;
|
|
774
|
+
/**
|
|
775
|
+
* Commit the held assistant aggregation as a context message, pushing no frames.
|
|
776
|
+
*
|
|
777
|
+
* For flushes in the middle of an open assistant turn (a user file or image
|
|
778
|
+
* arriving mid-reply), where the downstream context and timestamp frames —
|
|
779
|
+
* and pushContextFrame()'s side effects — belong to the turn's real end,
|
|
780
|
+
* not to this commit.
|
|
781
|
+
*
|
|
782
|
+
* @returns The committed aggregation, or an empty string if none was held.
|
|
783
|
+
*/
|
|
784
|
+
protected _addAggregationToContext(): Promise<string>;
|
|
785
|
+
/**
|
|
786
|
+
* Push a context frame in the specified direction.
|
|
787
|
+
*
|
|
788
|
+
* @param direction The direction to push the frame (upstream or downstream).
|
|
789
|
+
*/
|
|
790
|
+
pushContextFrame(direction?: FrameDirection): Promise<void>;
|
|
791
|
+
protected _handleLlmRun(_frame: LLMRunFrame): Promise<void>;
|
|
792
|
+
protected _handleLlmMessagesAppend(frame: LLMMessagesAppendFrame): Promise<void>;
|
|
793
|
+
protected _handleLlmMessagesUpdate(frame: LLMMessagesUpdateFrame): Promise<void>;
|
|
794
|
+
protected _handleLlmMessagesTransform(frame: LLMMessagesTransformFrame): Promise<void>;
|
|
795
|
+
protected _handleInterruptions(_frame: InterruptionFrame): Promise<void>;
|
|
796
|
+
protected _handleEndOrCancel(frame: Frame): Promise<void>;
|
|
797
|
+
protected _cleanup(): Promise<void>;
|
|
798
|
+
protected _handleFunctionCallsStarted(frame: FunctionCallsStartedFrame): Promise<void>;
|
|
799
|
+
protected _handleFunctionCallInProgress(frame: FunctionCallInProgressFrame): Promise<void>;
|
|
800
|
+
protected _handleFunctionCallResult(frame: FunctionCallResultFrame): Promise<void>;
|
|
801
|
+
/**
|
|
802
|
+
* Decide whether to push a context frame after a function call settles or a message is appended.
|
|
803
|
+
*
|
|
804
|
+
* Push an `LLMContextFrame` upstream (with care to avoid duplicate pushes
|
|
805
|
+
* while results or appends are queued or the bot is still speaking).
|
|
806
|
+
* Cascade LLMs use the context frame to re-run inference with the new tool
|
|
807
|
+
* result in scope. Realtime LLMs read the new tool result out of the
|
|
808
|
+
* context the same way — they don't get function results from
|
|
809
|
+
* `FunctionCallResultFrame` directly — so the same push is load-bearing for
|
|
810
|
+
* both modes.
|
|
811
|
+
*/
|
|
812
|
+
protected _maybePushContext(): Promise<void>;
|
|
813
|
+
/**
|
|
814
|
+
* Handle an intermediate result for an async function call.
|
|
815
|
+
*
|
|
816
|
+
* Injects an intermediate developer message into the context without
|
|
817
|
+
* removing the call from the in-progress map.
|
|
818
|
+
*/
|
|
819
|
+
protected _handleFunctionCallIntermediateResult(frame: FunctionCallResultFrame, _inProgressFrame: FunctionCallInProgressFrame): Promise<void>;
|
|
820
|
+
/**
|
|
821
|
+
* Handle the final result of a function call.
|
|
822
|
+
*
|
|
823
|
+
* Removes the call from the in-progress map, updates the context, and
|
|
824
|
+
* triggers LLM inference when appropriate.
|
|
825
|
+
*/
|
|
826
|
+
protected _handleFunctionCallFinished(frame: FunctionCallResultFrame, inProgressFrame: FunctionCallInProgressFrame): Promise<void>;
|
|
827
|
+
protected _handleFunctionCallCancel(frame: FunctionCallCancelFrame): Promise<void>;
|
|
828
|
+
protected _handleUserImageFrame(frame: UserImageRawFrame): Promise<void>;
|
|
829
|
+
protected _handleUserFileFrame(frame: UserFileRawFrame): Promise<void>;
|
|
830
|
+
protected _handleAssistantImageFrame(frame: AssistantImageRawFrame): Promise<void>;
|
|
831
|
+
protected _handleLlmStart(_frame: LLMFullResponseStartFrame): Promise<void>;
|
|
832
|
+
/**
|
|
833
|
+
* Realtime mode: commit the paired user message, then start the assistant turn.
|
|
834
|
+
*
|
|
835
|
+
* Realtime mode treats `LLMFullResponseStartFrame` as the user turn's end
|
|
836
|
+
* signal for context-writing purposes (in place of
|
|
837
|
+
* `UserStoppedSpeakingFrame`). The paired user aggregator may defer the
|
|
838
|
+
* actual write for one `ttfsP99Latency` window to allow a late-arriving
|
|
839
|
+
* transcript to land.
|
|
840
|
+
*/
|
|
841
|
+
protected _realtimeHandleLlmStart(): Promise<void>;
|
|
842
|
+
protected _handleLlmEnd(_frame: LLMFullResponseEndFrame): Promise<void>;
|
|
843
|
+
protected _handleTtsStarted(frame: TTSStartedFrame): Promise<void>;
|
|
844
|
+
protected _handlePushAggregation(): Promise<void>;
|
|
845
|
+
protected _handleText(frame: TextFrame): Promise<void>;
|
|
846
|
+
protected _handleMarkerFrame(frame: LLMMarkerFrame): Promise<void>;
|
|
847
|
+
protected _handleThoughtStart(frame: LLMThoughtStartFrame): Promise<void>;
|
|
848
|
+
protected _handleThoughtText(frame: LLMThoughtTextFrame): Promise<void>;
|
|
849
|
+
protected _handleThoughtEnd(frame: LLMThoughtEndFrame): Promise<void>;
|
|
850
|
+
protected _maybeAppendImageToContext(frame: UserImageRawFrame): Promise<boolean>;
|
|
851
|
+
/**
|
|
852
|
+
* Whether a call's final result must be delivered as a deferred message.
|
|
853
|
+
*
|
|
854
|
+
* An async call (`cancelOnInterruption: false`) whose result arrives before
|
|
855
|
+
* the conversation moved on is indistinguishable from a synchronous one,
|
|
856
|
+
* and settles in place: its "started" placeholder becomes the tool result,
|
|
857
|
+
* and the LLM sees an ordinary call. The context alone decides. The result
|
|
858
|
+
* is deferred when a user or developer message follows the placeholder:
|
|
859
|
+
* something the user said, new task instructions, or an intermediate update
|
|
860
|
+
* from this call. Assistant messages are ignored, so filler spoken with a
|
|
861
|
+
* `TTSSpeakFrame` while the call runs does not defer it, whether the tool
|
|
862
|
+
* handler or an event handler spoke it. The same holds for text the model
|
|
863
|
+
* wrote after seeing the placeholder with no user turn in between, as when
|
|
864
|
+
* an ungrouped sibling's result runs inference; the result still settles in
|
|
865
|
+
* place. Other calls' placeholders, results, and deferred messages are
|
|
866
|
+
* ignored too. A placeholder that is no longer in the context, because the
|
|
867
|
+
* context was rebuilt while the call ran, also defers.
|
|
868
|
+
*
|
|
869
|
+
* @param inProgressFrame The call's in-progress frame.
|
|
870
|
+
* @returns True when the result goes into a developer message.
|
|
871
|
+
*/
|
|
872
|
+
protected _isDeferred(inProgressFrame: FunctionCallInProgressFrame): boolean;
|
|
873
|
+
protected _updateFunctionCallResult(_functionName: string, toolCallId: string, result: unknown): void;
|
|
874
|
+
protected _contextUpdatedTaskFinished(task: Task<unknown>): void;
|
|
875
|
+
protected _triggerAssistantTurnStarted(): Promise<void>;
|
|
876
|
+
protected _triggerAssistantTurnStopped(options?: {
|
|
877
|
+
interrupted?: boolean;
|
|
878
|
+
}): Promise<void>;
|
|
879
|
+
/**
|
|
880
|
+
* Strip turn completion markers from assistant transcript.
|
|
881
|
+
*
|
|
882
|
+
* Turn completion markers are used internally for turn completion detection
|
|
883
|
+
* and shouldn't appear in the final transcript. Both the default markers
|
|
884
|
+
* and any seen on this turn's marker frames are removed, so a custom marker
|
|
885
|
+
* set is stripped too.
|
|
886
|
+
*/
|
|
887
|
+
protected _maybeStripTurnCompletionMarkers(text: string): string;
|
|
888
|
+
/**
|
|
889
|
+
* Handle summarization request from the summarizer.
|
|
890
|
+
*
|
|
891
|
+
* Push the request frame UPSTREAM to the LLM service for processing.
|
|
892
|
+
*
|
|
893
|
+
* @param summarizer The summarizer that generated the request.
|
|
894
|
+
* @param frame The summarization request frame to broadcast.
|
|
895
|
+
*/
|
|
896
|
+
protected _onRequestSummarization(_summarizer: LLMContextSummarizer, frame: LLMContextSummaryRequestFrame): Promise<void>;
|
|
897
|
+
/**
|
|
898
|
+
* Handle summary applied event from the summarizer.
|
|
899
|
+
*
|
|
900
|
+
* Forwards the event to any registered `on_summary_applied` handlers.
|
|
901
|
+
*
|
|
902
|
+
* @param summarizer The summarizer that applied the summary.
|
|
903
|
+
* @param event The summary applied event.
|
|
904
|
+
*/
|
|
905
|
+
protected _onSummaryApplied(summarizer: LLMContextSummarizer, event: SummaryAppliedEvent): Promise<void>;
|
|
906
|
+
}
|
|
907
|
+
export interface LLMContextAggregatorPairOptions {
|
|
908
|
+
/** Parameters for the user context aggregator. */
|
|
909
|
+
userParams?: LLMUserAggregatorParams | null;
|
|
910
|
+
/** Parameters for the assistant context aggregator. */
|
|
911
|
+
assistantParams?: LLMAssistantAggregatorParams | null;
|
|
912
|
+
/**
|
|
913
|
+
* When provided, sets the field of the same name on both `userParams` and
|
|
914
|
+
* `assistantParams`, overriding any value already set on either. This is
|
|
915
|
+
* the preferred way to enable tool-change announcements: it ensures both
|
|
916
|
+
* aggregators participate, which makes the feature robust regardless of
|
|
917
|
+
* which aggregator handles a given `LLMSetToolsFrame`. The shared context
|
|
918
|
+
* guarantees the announcement is added exactly once (the second
|
|
919
|
+
* aggregator's diff is empty by the time it sees the frame). Leave as
|
|
920
|
+
* `null` to respect per-params settings.
|
|
921
|
+
*/
|
|
922
|
+
addToolChangeMessages?: boolean | null;
|
|
923
|
+
/**
|
|
924
|
+
* Configures the pair for use with a realtime (speech-to-speech) LLM
|
|
925
|
+
* service. When enabled, context writes become trailing — driven by the
|
|
926
|
+
* content stream itself (transcripts, `LLMFullResponseStartFrame`) rather
|
|
927
|
+
* than turn frames — and turn-end strategies stop waiting for transcripts.
|
|
928
|
+
* `null` (the default) auto-configures: the mode turns on when a realtime
|
|
929
|
+
* service announces itself via service metadata, and stays off otherwise.
|
|
930
|
+
* `true` / `false` force it on or off (`false` keeps legacy pre-realtime
|
|
931
|
+
* context-write behavior). Both halves share this setting.
|
|
932
|
+
*/
|
|
933
|
+
realtimeServiceMode?: boolean | null;
|
|
934
|
+
}
|
|
935
|
+
/** Pair of LLM context aggregators for updating context with user and assistant messages. */
|
|
936
|
+
export declare class LLMContextAggregatorPair {
|
|
937
|
+
protected _user: LLMUserAggregator;
|
|
938
|
+
protected _assistant: LLMAssistantAggregator;
|
|
939
|
+
/**
|
|
940
|
+
* Initialize the LLM context aggregator pair.
|
|
941
|
+
*
|
|
942
|
+
* @param context The context to be managed by the aggregators.
|
|
943
|
+
*/
|
|
944
|
+
constructor(context: LLMContext, options?: LLMContextAggregatorPairOptions);
|
|
945
|
+
/**
|
|
946
|
+
* Get the user context aggregator.
|
|
947
|
+
*
|
|
948
|
+
* @returns The user context aggregator instance.
|
|
949
|
+
*/
|
|
950
|
+
user(): LLMUserAggregator;
|
|
951
|
+
/**
|
|
952
|
+
* Get the assistant context aggregator.
|
|
953
|
+
*
|
|
954
|
+
* @returns The assistant context aggregator instance.
|
|
955
|
+
*/
|
|
956
|
+
assistant(): LLMAssistantAggregator;
|
|
957
|
+
/**
|
|
958
|
+
* Allow destructuring of the aggregator pair.
|
|
959
|
+
*
|
|
960
|
+
* @example
|
|
961
|
+
* const pair = new LLMContextAggregatorPair(context); // The instance
|
|
962
|
+
* const [user, assistant] = new LLMContextAggregatorPair(context); // Destructured
|
|
963
|
+
*/
|
|
964
|
+
[Symbol.iterator](): IterableIterator<LLMUserAggregator | LLMAssistantAggregator>;
|
|
965
|
+
}
|
|
966
|
+
//# sourceMappingURL=llm_response_universal.d.ts.map
|