@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,221 @@
|
|
|
1
|
+
import type { FrameProcessor } from "../processors/frame_processor.ts";
|
|
2
|
+
import type { BaseTaskManager } from "../utils/asyncio/task_manager.ts";
|
|
3
|
+
import { BaseObserver, type BaseObserverOptions, type FrameProcessed, type FramePushed, type ProcessorSetUp } from "./base_observer.ts";
|
|
4
|
+
export type FrameProcessorClass = abstract new (...args: any[]) => FrameProcessor;
|
|
5
|
+
/** Captured once when the first StartFrame arrives at a processor. */
|
|
6
|
+
interface StartFrameInfo {
|
|
7
|
+
frameId: number;
|
|
8
|
+
arrivalNs: number;
|
|
9
|
+
wallClock: number;
|
|
10
|
+
}
|
|
11
|
+
/** Internal record of when a StartFrame arrived at a processor. */
|
|
12
|
+
interface ArrivalInfo {
|
|
13
|
+
processor: FrameProcessor;
|
|
14
|
+
arrivalTsNs: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ProcessorStartupTimingOptions {
|
|
17
|
+
/** The name of the processor. */
|
|
18
|
+
processorName: string;
|
|
19
|
+
/** Offset in seconds from the StartFrame to when this processor's start() began. */
|
|
20
|
+
startOffsetSecs: number;
|
|
21
|
+
/** What the processor cost to get ready, in seconds: its setup() and start() together. */
|
|
22
|
+
durationSecs: number;
|
|
23
|
+
/** How long the processor's setup() took, in seconds. */
|
|
24
|
+
setupDurationSecs: number;
|
|
25
|
+
/** How long the processor spent on the StartFrame, in seconds. */
|
|
26
|
+
startDurationSecs?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Startup timing for a single processor.
|
|
30
|
+
*
|
|
31
|
+
* - `processorName`: the name of the processor.
|
|
32
|
+
* - `startOffsetSecs`: offset in seconds from the StartFrame to when this
|
|
33
|
+
* processor's start() began.
|
|
34
|
+
* - `durationSecs`: what the processor cost to get ready, in seconds: its
|
|
35
|
+
* setup() and its start() together.
|
|
36
|
+
* - `setupDurationSecs`: how long the processor's setup() took, in seconds.
|
|
37
|
+
* Processors are set up concurrently, so this overlaps every other
|
|
38
|
+
* processor's and only the longest of them holds up the pipeline.
|
|
39
|
+
* - `startDurationSecs`: how long the processor spent on the StartFrame, in
|
|
40
|
+
* seconds. The frame reaches processors one after another, so this adds to
|
|
41
|
+
* what every other processor spent rather than overlapping it.
|
|
42
|
+
*/
|
|
43
|
+
export declare class ProcessorStartupTiming {
|
|
44
|
+
processorName: string;
|
|
45
|
+
startOffsetSecs: number;
|
|
46
|
+
durationSecs: number;
|
|
47
|
+
setupDurationSecs: number;
|
|
48
|
+
startDurationSecs: number;
|
|
49
|
+
constructor(options: ProcessorStartupTimingOptions);
|
|
50
|
+
}
|
|
51
|
+
export interface StartupTimingReportOptions {
|
|
52
|
+
/** Unix timestamp when the pipeline began setting up. */
|
|
53
|
+
startTime: number;
|
|
54
|
+
/** Wall-clock time from the pipeline starting to set up until it had started. */
|
|
55
|
+
totalDurationSecs: number;
|
|
56
|
+
/** How long getting every processor ready took, in seconds. */
|
|
57
|
+
setupPhaseSecs?: number;
|
|
58
|
+
/** How long the StartFrame took to travel the pipeline, in seconds. */
|
|
59
|
+
startPhaseSecs?: number;
|
|
60
|
+
/** Per-processor timing data, in pipeline order. */
|
|
61
|
+
processorTimings?: ProcessorStartupTiming[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Report of startup timings for all measured processors.
|
|
65
|
+
*
|
|
66
|
+
* - `startTime`: Unix timestamp when the pipeline began setting up.
|
|
67
|
+
* - `totalDurationSecs`: wall-clock time from the pipeline starting to set up
|
|
68
|
+
* until it had started, which is `setupPhaseSecs` and `startPhaseSecs` back
|
|
69
|
+
* to back.
|
|
70
|
+
* - `setupPhaseSecs`: how long getting every processor ready took, in
|
|
71
|
+
* seconds. Setting up runs concurrently, so the longest single processor
|
|
72
|
+
* decides this rather than their sum.
|
|
73
|
+
* - `startPhaseSecs`: how long the StartFrame took to travel the pipeline, in
|
|
74
|
+
* seconds. It reaches processors one after another, so what each spends on
|
|
75
|
+
* it adds up.
|
|
76
|
+
* - `processorTimings`: per-processor timing data, in pipeline order.
|
|
77
|
+
*/
|
|
78
|
+
export declare class StartupTimingReport {
|
|
79
|
+
startTime: number;
|
|
80
|
+
totalDurationSecs: number;
|
|
81
|
+
setupPhaseSecs: number;
|
|
82
|
+
startPhaseSecs: number;
|
|
83
|
+
processorTimings: ProcessorStartupTiming[];
|
|
84
|
+
constructor(options: StartupTimingReportOptions);
|
|
85
|
+
}
|
|
86
|
+
export interface TransportTimingReportOptions {
|
|
87
|
+
/** Unix timestamp when the pipeline began setting up. */
|
|
88
|
+
startTime: number;
|
|
89
|
+
/** Seconds until the first BotConnectedFrame (only set for SFU transports). */
|
|
90
|
+
botConnectedSecs?: number | null;
|
|
91
|
+
/** Seconds until the first ClientConnectedFrame. */
|
|
92
|
+
clientConnectedSecs?: number | null;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Time from pipeline start to transport connection milestones.
|
|
96
|
+
*
|
|
97
|
+
* - `startTime`: Unix timestamp when the pipeline began setting up.
|
|
98
|
+
* - `botConnectedSecs`: seconds from the pipeline starting to set up until
|
|
99
|
+
* the first BotConnectedFrame (only set for SFU transports).
|
|
100
|
+
* - `clientConnectedSecs`: seconds from the pipeline starting to set up until
|
|
101
|
+
* the first ClientConnectedFrame.
|
|
102
|
+
*/
|
|
103
|
+
export declare class TransportTimingReport {
|
|
104
|
+
startTime: number;
|
|
105
|
+
botConnectedSecs: number | null;
|
|
106
|
+
clientConnectedSecs: number | null;
|
|
107
|
+
constructor(options: TransportTimingReportOptions);
|
|
108
|
+
}
|
|
109
|
+
export interface StartupTimingObserverOptions extends BaseObserverOptions {
|
|
110
|
+
/**
|
|
111
|
+
* Optional processor types to measure. If null, all non-internal processors
|
|
112
|
+
* are measured.
|
|
113
|
+
*/
|
|
114
|
+
processorTypes?: readonly FrameProcessorClass[] | null;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Observer that measures processor startup times during pipeline initialization.
|
|
118
|
+
*
|
|
119
|
+
* Tracks what each processor costs to get ready: its `setup()` and its
|
|
120
|
+
* `start()` together, the latter measured from the `StartFrame` arriving at
|
|
121
|
+
* the processor to it being pushed downstream. This captures WebSocket
|
|
122
|
+
* connections, API authentication, model loading, and other initialization
|
|
123
|
+
* work, most of which happens while the processor is being set up.
|
|
124
|
+
*
|
|
125
|
+
* Also measures transport timing, the time from the pipeline starting to set
|
|
126
|
+
* up until each connection milestone. A transport connects while it is set
|
|
127
|
+
* up, so these can be reached before the `StartFrame` is pushed:
|
|
128
|
+
*
|
|
129
|
+
* - `botConnectedSecs`: when the bot joins the transport room (SFU
|
|
130
|
+
* transports only, triggered by `BotConnectedFrame`).
|
|
131
|
+
* - `clientConnectedSecs`: when a remote participant connects (triggered by
|
|
132
|
+
* `ClientConnectedFrame`).
|
|
133
|
+
*
|
|
134
|
+
* By default, internal pipeline processors (`PipelineSource`, `Pipeline`) are
|
|
135
|
+
* excluded from the report. Pass `processorTypes` to measure only specific
|
|
136
|
+
* types.
|
|
137
|
+
*
|
|
138
|
+
* Event handlers available:
|
|
139
|
+
*
|
|
140
|
+
* - on_startup_timing_report: called once after startup completes with the
|
|
141
|
+
* full timing report.
|
|
142
|
+
* - on_transport_timing_report: called once when the first client connects
|
|
143
|
+
* with a TransportTimingReport containing clientConnectedSecs and
|
|
144
|
+
* botConnectedSecs (if available).
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* const observer = new StartupTimingObserver({ processorTypes: [STTService, TTSService] });
|
|
148
|
+
*
|
|
149
|
+
* observer.eventHandler("on_startup_timing_report", async (observer, report) => {
|
|
150
|
+
* for (const t of report.processorTimings) {
|
|
151
|
+
* logger.info(`${t.processorName}: ${t.durationSecs.toFixed(3)}s`);
|
|
152
|
+
* }
|
|
153
|
+
* });
|
|
154
|
+
*/
|
|
155
|
+
export declare class StartupTimingObserver extends BaseObserver {
|
|
156
|
+
protected _processorTypes: readonly FrameProcessorClass[] | null;
|
|
157
|
+
protected _arrivals: Map<number, ArrivalInfo>;
|
|
158
|
+
protected _timings: ProcessorStartupTiming[];
|
|
159
|
+
protected _startFrame: StartFrameInfo | null;
|
|
160
|
+
protected _setupStartedNs: number;
|
|
161
|
+
protected _setupWallClock: number;
|
|
162
|
+
protected _setupFinishedNs: number;
|
|
163
|
+
protected _setupDurations: Map<number, number>;
|
|
164
|
+
protected _startupTimingReported: boolean;
|
|
165
|
+
protected _transportTimingReported: boolean;
|
|
166
|
+
protected _botConnectedSecs: number | null;
|
|
167
|
+
/** Initialize the startup timing observer. */
|
|
168
|
+
constructor(options?: StartupTimingObserverOptions);
|
|
169
|
+
/**
|
|
170
|
+
* Start the clock, before any processor has been set up.
|
|
171
|
+
*
|
|
172
|
+
* Processors connect while they are being set up, so startup begins here
|
|
173
|
+
* rather than at the StartFrame.
|
|
174
|
+
*
|
|
175
|
+
* @param taskManager The task manager to run tasks on.
|
|
176
|
+
*/
|
|
177
|
+
setup(taskManager: BaseTaskManager | unknown): Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* Record how long a processor's setup() took.
|
|
180
|
+
*
|
|
181
|
+
* @param data The processor setup event data.
|
|
182
|
+
*/
|
|
183
|
+
onProcessorSetup(data: ProcessorSetUp): Promise<void>;
|
|
184
|
+
/**
|
|
185
|
+
* Check if a processor should be tracked for timing.
|
|
186
|
+
*
|
|
187
|
+
* @param processor The processor to check.
|
|
188
|
+
* @returns True if the processor matches the filter or no filter is set.
|
|
189
|
+
*/
|
|
190
|
+
protected _shouldTrack(processor: FrameProcessor): boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Emit the startup timing report when the pipeline has fully started.
|
|
193
|
+
*
|
|
194
|
+
* Called by the `PipelineWorker` after the `StartFrame` has been processed
|
|
195
|
+
* by all processors, including nested `ParallelPipeline` branches.
|
|
196
|
+
*/
|
|
197
|
+
onPipelineStarted(): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Record when a StartFrame arrives at a processor.
|
|
200
|
+
*
|
|
201
|
+
* @param data The frame processing event data.
|
|
202
|
+
*/
|
|
203
|
+
onProcessFrame(data: FrameProcessed): Promise<void>;
|
|
204
|
+
/**
|
|
205
|
+
* Record when a StartFrame leaves a processor and compute the delta.
|
|
206
|
+
*
|
|
207
|
+
* Also handles `BotConnectedFrame` and `ClientConnectedFrame` to measure
|
|
208
|
+
* transport timing.
|
|
209
|
+
*
|
|
210
|
+
* @param data The frame push event data.
|
|
211
|
+
*/
|
|
212
|
+
onPushFrame(data: FramePushed): Promise<void>;
|
|
213
|
+
/** Record bot connected timing on first BotConnectedFrame. */
|
|
214
|
+
protected _handleBotConnected(data: FramePushed): void;
|
|
215
|
+
/** Emit transport timing report on first ClientConnectedFrame. */
|
|
216
|
+
protected _handleClientConnected(data: FramePushed): Promise<void>;
|
|
217
|
+
/** Build and emit the startup timing report. */
|
|
218
|
+
protected _emitReport(): Promise<void>;
|
|
219
|
+
}
|
|
220
|
+
export {};
|
|
221
|
+
//# sourceMappingURL=startup_timing_observer.d.ts.map
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
// Copyright (c) 2024-2026, Daily
|
|
2
|
+
// Copyright (c) 2026, pipedog contributors
|
|
3
|
+
// SPDX-License-Identifier: BSD-2-Clause
|
|
4
|
+
//
|
|
5
|
+
// Ported from pipecat: src/pipecat/observers/startup_timing_observer.py
|
|
6
|
+
/**
|
|
7
|
+
* Observer for tracking pipeline startup timing.
|
|
8
|
+
*
|
|
9
|
+
* This module provides an observer that measures how long each processor
|
|
10
|
+
* takes during pipeline startup (i.e. setup() and `StartFrame`). It works by
|
|
11
|
+
* tracking `setup()` time and when the `StartFrame` arrives at a processor
|
|
12
|
+
* (`onProcessFrame`) versus when it leaves (`onPushFrame`), giving the exact
|
|
13
|
+
* `start()` duration for each processor in the pipeline.
|
|
14
|
+
*
|
|
15
|
+
* It also measures transport timing — the time from before `setup()` to the
|
|
16
|
+
* first `BotConnectedFrame` (SFU transports only) and `ClientConnectedFrame` —
|
|
17
|
+
* via a separate `on_transport_timing_report` event.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const observer = new StartupTimingObserver();
|
|
21
|
+
*
|
|
22
|
+
* observer.eventHandler("on_startup_timing_report", async (observer, report) => {
|
|
23
|
+
* for (const t of report.processorTimings) {
|
|
24
|
+
* console.log(`${t.processorName}: ${t.durationSecs.toFixed(3)}s`);
|
|
25
|
+
* }
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* observer.eventHandler("on_transport_timing_report", async (observer, report) => {
|
|
29
|
+
* if (report.botConnectedSecs !== null) {
|
|
30
|
+
* console.log(`Bot connected in ${report.botConnectedSecs.toFixed(3)}s`);
|
|
31
|
+
* }
|
|
32
|
+
* console.log(`Client connected in ${report.clientConnectedSecs?.toFixed(3)}s`);
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* const worker = new PipelineWorker(pipeline, { observers: [observer] });
|
|
36
|
+
*/
|
|
37
|
+
import { monotonicNs, time } from "@pipedog/asyncio";
|
|
38
|
+
import { BotConnectedFrame, ClientConnectedFrame, StartFrame } from "../frames/frames.js";
|
|
39
|
+
import { BasePipeline } from "../pipeline/base_pipeline.js";
|
|
40
|
+
import { PipelineSource } from "../pipeline/pipeline.js";
|
|
41
|
+
import { BaseObserver, } from "./base_observer.js";
|
|
42
|
+
// Internal pipeline types excluded from tracking by default.
|
|
43
|
+
const INTERNAL_TYPES = [PipelineSource, BasePipeline];
|
|
44
|
+
/**
|
|
45
|
+
* Startup timing for a single processor.
|
|
46
|
+
*
|
|
47
|
+
* - `processorName`: the name of the processor.
|
|
48
|
+
* - `startOffsetSecs`: offset in seconds from the StartFrame to when this
|
|
49
|
+
* processor's start() began.
|
|
50
|
+
* - `durationSecs`: what the processor cost to get ready, in seconds: its
|
|
51
|
+
* setup() and its start() together.
|
|
52
|
+
* - `setupDurationSecs`: how long the processor's setup() took, in seconds.
|
|
53
|
+
* Processors are set up concurrently, so this overlaps every other
|
|
54
|
+
* processor's and only the longest of them holds up the pipeline.
|
|
55
|
+
* - `startDurationSecs`: how long the processor spent on the StartFrame, in
|
|
56
|
+
* seconds. The frame reaches processors one after another, so this adds to
|
|
57
|
+
* what every other processor spent rather than overlapping it.
|
|
58
|
+
*/
|
|
59
|
+
export class ProcessorStartupTiming {
|
|
60
|
+
processorName;
|
|
61
|
+
startOffsetSecs;
|
|
62
|
+
durationSecs;
|
|
63
|
+
setupDurationSecs;
|
|
64
|
+
startDurationSecs;
|
|
65
|
+
constructor(options) {
|
|
66
|
+
this.processorName = options.processorName;
|
|
67
|
+
this.startOffsetSecs = options.startOffsetSecs;
|
|
68
|
+
this.durationSecs = options.durationSecs;
|
|
69
|
+
this.setupDurationSecs = options.setupDurationSecs;
|
|
70
|
+
this.startDurationSecs = options.startDurationSecs ?? 0.0;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Report of startup timings for all measured processors.
|
|
75
|
+
*
|
|
76
|
+
* - `startTime`: Unix timestamp when the pipeline began setting up.
|
|
77
|
+
* - `totalDurationSecs`: wall-clock time from the pipeline starting to set up
|
|
78
|
+
* until it had started, which is `setupPhaseSecs` and `startPhaseSecs` back
|
|
79
|
+
* to back.
|
|
80
|
+
* - `setupPhaseSecs`: how long getting every processor ready took, in
|
|
81
|
+
* seconds. Setting up runs concurrently, so the longest single processor
|
|
82
|
+
* decides this rather than their sum.
|
|
83
|
+
* - `startPhaseSecs`: how long the StartFrame took to travel the pipeline, in
|
|
84
|
+
* seconds. It reaches processors one after another, so what each spends on
|
|
85
|
+
* it adds up.
|
|
86
|
+
* - `processorTimings`: per-processor timing data, in pipeline order.
|
|
87
|
+
*/
|
|
88
|
+
export class StartupTimingReport {
|
|
89
|
+
startTime;
|
|
90
|
+
totalDurationSecs;
|
|
91
|
+
setupPhaseSecs;
|
|
92
|
+
startPhaseSecs;
|
|
93
|
+
processorTimings;
|
|
94
|
+
constructor(options) {
|
|
95
|
+
this.startTime = options.startTime;
|
|
96
|
+
this.totalDurationSecs = options.totalDurationSecs;
|
|
97
|
+
this.setupPhaseSecs = options.setupPhaseSecs ?? 0.0;
|
|
98
|
+
this.startPhaseSecs = options.startPhaseSecs ?? 0.0;
|
|
99
|
+
this.processorTimings = options.processorTimings ?? [];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Time from pipeline start to transport connection milestones.
|
|
104
|
+
*
|
|
105
|
+
* - `startTime`: Unix timestamp when the pipeline began setting up.
|
|
106
|
+
* - `botConnectedSecs`: seconds from the pipeline starting to set up until
|
|
107
|
+
* the first BotConnectedFrame (only set for SFU transports).
|
|
108
|
+
* - `clientConnectedSecs`: seconds from the pipeline starting to set up until
|
|
109
|
+
* the first ClientConnectedFrame.
|
|
110
|
+
*/
|
|
111
|
+
export class TransportTimingReport {
|
|
112
|
+
startTime;
|
|
113
|
+
botConnectedSecs;
|
|
114
|
+
clientConnectedSecs;
|
|
115
|
+
constructor(options) {
|
|
116
|
+
this.startTime = options.startTime;
|
|
117
|
+
this.botConnectedSecs = options.botConnectedSecs ?? null;
|
|
118
|
+
this.clientConnectedSecs = options.clientConnectedSecs ?? null;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Observer that measures processor startup times during pipeline initialization.
|
|
123
|
+
*
|
|
124
|
+
* Tracks what each processor costs to get ready: its `setup()` and its
|
|
125
|
+
* `start()` together, the latter measured from the `StartFrame` arriving at
|
|
126
|
+
* the processor to it being pushed downstream. This captures WebSocket
|
|
127
|
+
* connections, API authentication, model loading, and other initialization
|
|
128
|
+
* work, most of which happens while the processor is being set up.
|
|
129
|
+
*
|
|
130
|
+
* Also measures transport timing, the time from the pipeline starting to set
|
|
131
|
+
* up until each connection milestone. A transport connects while it is set
|
|
132
|
+
* up, so these can be reached before the `StartFrame` is pushed:
|
|
133
|
+
*
|
|
134
|
+
* - `botConnectedSecs`: when the bot joins the transport room (SFU
|
|
135
|
+
* transports only, triggered by `BotConnectedFrame`).
|
|
136
|
+
* - `clientConnectedSecs`: when a remote participant connects (triggered by
|
|
137
|
+
* `ClientConnectedFrame`).
|
|
138
|
+
*
|
|
139
|
+
* By default, internal pipeline processors (`PipelineSource`, `Pipeline`) are
|
|
140
|
+
* excluded from the report. Pass `processorTypes` to measure only specific
|
|
141
|
+
* types.
|
|
142
|
+
*
|
|
143
|
+
* Event handlers available:
|
|
144
|
+
*
|
|
145
|
+
* - on_startup_timing_report: called once after startup completes with the
|
|
146
|
+
* full timing report.
|
|
147
|
+
* - on_transport_timing_report: called once when the first client connects
|
|
148
|
+
* with a TransportTimingReport containing clientConnectedSecs and
|
|
149
|
+
* botConnectedSecs (if available).
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* const observer = new StartupTimingObserver({ processorTypes: [STTService, TTSService] });
|
|
153
|
+
*
|
|
154
|
+
* observer.eventHandler("on_startup_timing_report", async (observer, report) => {
|
|
155
|
+
* for (const t of report.processorTimings) {
|
|
156
|
+
* logger.info(`${t.processorName}: ${t.durationSecs.toFixed(3)}s`);
|
|
157
|
+
* }
|
|
158
|
+
* });
|
|
159
|
+
*/
|
|
160
|
+
export class StartupTimingObserver extends BaseObserver {
|
|
161
|
+
_processorTypes;
|
|
162
|
+
// Map processor ID -> arrival info.
|
|
163
|
+
_arrivals = new Map();
|
|
164
|
+
// Collected timings in pipeline order.
|
|
165
|
+
_timings = [];
|
|
166
|
+
// Captured once when the first StartFrame arrives.
|
|
167
|
+
_startFrame = null;
|
|
168
|
+
// When the pipeline began setting up, i.e. before any processor connected,
|
|
169
|
+
// and how long each processor's setup() took.
|
|
170
|
+
_setupStartedNs = 0;
|
|
171
|
+
_setupWallClock = 0.0;
|
|
172
|
+
_setupFinishedNs = 0;
|
|
173
|
+
_setupDurations = new Map();
|
|
174
|
+
// Whether we've already emitted the startup timing report.
|
|
175
|
+
_startupTimingReported = false;
|
|
176
|
+
// Whether we've already measured transport timing.
|
|
177
|
+
_transportTimingReported = false;
|
|
178
|
+
// Bot connected timing (stored for inclusion in the transport report).
|
|
179
|
+
_botConnectedSecs = null;
|
|
180
|
+
/** Initialize the startup timing observer. */
|
|
181
|
+
constructor(options = {}) {
|
|
182
|
+
super(options);
|
|
183
|
+
this._processorTypes = options.processorTypes ?? null;
|
|
184
|
+
this._registerEventHandler("on_startup_timing_report");
|
|
185
|
+
this._registerEventHandler("on_transport_timing_report");
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Start the clock, before any processor has been set up.
|
|
189
|
+
*
|
|
190
|
+
* Processors connect while they are being set up, so startup begins here
|
|
191
|
+
* rather than at the StartFrame.
|
|
192
|
+
*
|
|
193
|
+
* @param taskManager The task manager to run tasks on.
|
|
194
|
+
*/
|
|
195
|
+
async setup(taskManager) {
|
|
196
|
+
await super.setup(taskManager);
|
|
197
|
+
this._setupStartedNs = monotonicNs();
|
|
198
|
+
this._setupWallClock = time();
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Record how long a processor's setup() took.
|
|
202
|
+
*
|
|
203
|
+
* @param data The processor setup event data.
|
|
204
|
+
*/
|
|
205
|
+
async onProcessorSetup(data) {
|
|
206
|
+
if (this._startupTimingReported) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
// Setting up runs concurrently, so the last processor to finish is what
|
|
210
|
+
// ends the phase. Filtered-out processors still hold it open, so they
|
|
211
|
+
// count here.
|
|
212
|
+
this._setupFinishedNs = Math.max(this._setupFinishedNs, data.finishedAtNs);
|
|
213
|
+
if (!this._shouldTrack(data.processor)) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
this._setupDurations.set(data.processor.id, (data.finishedAtNs - data.startedAtNs) / 1e9);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Check if a processor should be tracked for timing.
|
|
220
|
+
*
|
|
221
|
+
* @param processor The processor to check.
|
|
222
|
+
* @returns True if the processor matches the filter or no filter is set.
|
|
223
|
+
*/
|
|
224
|
+
_shouldTrack(processor) {
|
|
225
|
+
if (this._processorTypes !== null) {
|
|
226
|
+
return this._processorTypes.some((t) => processor instanceof t);
|
|
227
|
+
}
|
|
228
|
+
// Default: exclude internal pipeline plumbing.
|
|
229
|
+
return !INTERNAL_TYPES.some((t) => processor instanceof t);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Emit the startup timing report when the pipeline has fully started.
|
|
233
|
+
*
|
|
234
|
+
* Called by the `PipelineWorker` after the `StartFrame` has been processed
|
|
235
|
+
* by all processors, including nested `ParallelPipeline` branches.
|
|
236
|
+
*/
|
|
237
|
+
async onPipelineStarted() {
|
|
238
|
+
if (this._timings.length > 0) {
|
|
239
|
+
await this._emitReport();
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Record when a StartFrame arrives at a processor.
|
|
244
|
+
*
|
|
245
|
+
* @param data The frame processing event data.
|
|
246
|
+
*/
|
|
247
|
+
async onProcessFrame(data) {
|
|
248
|
+
if (this._startupTimingReported) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
if (!(data.frame instanceof StartFrame)) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
// Lock onto the first StartFrame.
|
|
255
|
+
if (this._startFrame === null) {
|
|
256
|
+
this._startFrame = {
|
|
257
|
+
frameId: data.frame.id,
|
|
258
|
+
arrivalNs: data.timestamp,
|
|
259
|
+
wallClock: time(),
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
else if (data.frame.id !== this._startFrame.frameId) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (this._shouldTrack(data.processor)) {
|
|
266
|
+
this._arrivals.set(data.processor.id, {
|
|
267
|
+
processor: data.processor,
|
|
268
|
+
arrivalTsNs: data.timestamp,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Record when a StartFrame leaves a processor and compute the delta.
|
|
274
|
+
*
|
|
275
|
+
* Also handles `BotConnectedFrame` and `ClientConnectedFrame` to measure
|
|
276
|
+
* transport timing.
|
|
277
|
+
*
|
|
278
|
+
* @param data The frame push event data.
|
|
279
|
+
*/
|
|
280
|
+
async onPushFrame(data) {
|
|
281
|
+
if (data.frame instanceof BotConnectedFrame) {
|
|
282
|
+
this._handleBotConnected(data);
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
if (data.frame instanceof ClientConnectedFrame) {
|
|
286
|
+
await this._handleClientConnected(data);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (this._startupTimingReported) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
if (!(data.frame instanceof StartFrame)) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
if (this._startFrame !== null && data.frame.id !== this._startFrame.frameId) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
const arrival = this._arrivals.get(data.source.id);
|
|
299
|
+
this._arrivals.delete(data.source.id);
|
|
300
|
+
if (arrival === undefined || this._startFrame === null) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
const durationNs = data.timestamp - arrival.arrivalTsNs;
|
|
304
|
+
const durationSecs = durationNs / 1e9;
|
|
305
|
+
const startOffsetSecs = (arrival.arrivalTsNs - this._startFrame.arrivalNs) / 1e9;
|
|
306
|
+
const setupDurationSecs = this._setupDurations.get(arrival.processor.id) ?? 0.0;
|
|
307
|
+
this._timings.push(new ProcessorStartupTiming({
|
|
308
|
+
processorName: arrival.processor.name,
|
|
309
|
+
startOffsetSecs,
|
|
310
|
+
// What the processor cost overall: it connects while being set up,
|
|
311
|
+
// and start() is whatever is left to do once it has.
|
|
312
|
+
durationSecs: setupDurationSecs + durationSecs,
|
|
313
|
+
setupDurationSecs,
|
|
314
|
+
startDurationSecs: durationSecs,
|
|
315
|
+
}));
|
|
316
|
+
}
|
|
317
|
+
/** Record bot connected timing on first BotConnectedFrame. */
|
|
318
|
+
_handleBotConnected(data) {
|
|
319
|
+
if (this._botConnectedSecs !== null) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
this._botConnectedSecs = data.timestamp / 1e9;
|
|
323
|
+
}
|
|
324
|
+
/** Emit transport timing report on first ClientConnectedFrame. */
|
|
325
|
+
async _handleClientConnected(data) {
|
|
326
|
+
if (this._transportTimingReported) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
this._transportTimingReported = true;
|
|
330
|
+
const clientConnectedSecs = data.timestamp / 1e9;
|
|
331
|
+
const report = new TransportTimingReport({
|
|
332
|
+
// Both offsets are elapsed pipeline-clock time, which starts before this
|
|
333
|
+
// observer does, so the wall clock they are offsets from comes from the
|
|
334
|
+
// same clock rather than from a second reading of its own.
|
|
335
|
+
startTime: time() - clientConnectedSecs,
|
|
336
|
+
botConnectedSecs: this._botConnectedSecs,
|
|
337
|
+
clientConnectedSecs,
|
|
338
|
+
});
|
|
339
|
+
await this._callEventHandler("on_transport_timing_report", report);
|
|
340
|
+
}
|
|
341
|
+
/** Build and emit the startup timing report. */
|
|
342
|
+
async _emitReport() {
|
|
343
|
+
if (this._startupTimingReported) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
this._startupTimingReported = true;
|
|
347
|
+
// Processors are set up concurrently, so what they cost does not add up
|
|
348
|
+
// to wall-clock time. Report the span instead.
|
|
349
|
+
const total = (monotonicNs() - this._setupStartedNs) / 1e9;
|
|
350
|
+
// Getting ready ends with the last processor to finish connecting. What
|
|
351
|
+
// follows is the StartFrame travelling the pipeline.
|
|
352
|
+
const setupPhaseEndNs = this._setupFinishedNs;
|
|
353
|
+
let setupPhaseSecs = Math.max(0, setupPhaseEndNs - this._setupStartedNs) / 1e9;
|
|
354
|
+
setupPhaseSecs = Math.min(setupPhaseSecs, total);
|
|
355
|
+
const report = new StartupTimingReport({
|
|
356
|
+
startTime: this._setupWallClock,
|
|
357
|
+
totalDurationSecs: total,
|
|
358
|
+
setupPhaseSecs,
|
|
359
|
+
startPhaseSecs: total - setupPhaseSecs,
|
|
360
|
+
processorTimings: this._timings,
|
|
361
|
+
});
|
|
362
|
+
await this._callEventHandler("on_startup_timing_report", report);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
//# sourceMappingURL=startup_timing_observer.js.map
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn tracking observer for conversation flow monitoring.
|
|
3
|
+
*
|
|
4
|
+
* Provides an observer that monitors conversation turns in a pipeline,
|
|
5
|
+
* tracking when turns start and end based on user and bot speech patterns.
|
|
6
|
+
*/
|
|
7
|
+
import { type Task } from "@pipedog/asyncio";
|
|
8
|
+
import { BaseObserver, type BaseObserverOptions, type FramePushed } from "./base_observer.ts";
|
|
9
|
+
export interface TurnTrackingObserverOptions extends Omit<BaseObserverOptions, "observeEveryPush"> {
|
|
10
|
+
/**
|
|
11
|
+
* Timeout in seconds after bot stops speaking before automatically ending
|
|
12
|
+
* the turn. Defaults to 2.5.
|
|
13
|
+
*/
|
|
14
|
+
turnEndTimeoutSecs?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Observer that tracks conversation turns in a pipeline.
|
|
18
|
+
*
|
|
19
|
+
* This observer monitors the flow of conversation by tracking when turns
|
|
20
|
+
* start and end based on user and bot speaking patterns. It handles
|
|
21
|
+
* interruptions, timeouts, and maintains turn state throughout the pipeline.
|
|
22
|
+
*
|
|
23
|
+
* Turn tracking logic:
|
|
24
|
+
*
|
|
25
|
+
* - The first turn starts immediately when the pipeline starts (StartFrame)
|
|
26
|
+
* - Subsequent turns start when the user starts speaking
|
|
27
|
+
* - A turn ends when the bot stops speaking and either:
|
|
28
|
+
* - The user starts speaking again
|
|
29
|
+
* - A timeout period elapses with no more bot speech
|
|
30
|
+
*
|
|
31
|
+
* Events:
|
|
32
|
+
*
|
|
33
|
+
* - on_turn_started: Triggered when a turn starts, providing the turn number
|
|
34
|
+
* - on_turn_ended: Triggered when a turn ends, providing the turn number, the
|
|
35
|
+
* turn's duration in seconds, and whether it was interrupted
|
|
36
|
+
*/
|
|
37
|
+
export declare class TurnTrackingObserver extends BaseObserver {
|
|
38
|
+
protected _turnCount: number;
|
|
39
|
+
protected _isTurnActive: boolean;
|
|
40
|
+
protected _isBotSpeaking: boolean;
|
|
41
|
+
protected _hasBotSpoken: boolean;
|
|
42
|
+
protected _turnStartTime: number;
|
|
43
|
+
protected _turnEndTimeoutSecs: number;
|
|
44
|
+
protected _endTurnTimer: Task<void> | null;
|
|
45
|
+
constructor(options?: TurnTrackingObserverOptions);
|
|
46
|
+
/**
|
|
47
|
+
* Process frame events for turn tracking.
|
|
48
|
+
*
|
|
49
|
+
* @param data Frame push event data containing the frame and metadata.
|
|
50
|
+
*/
|
|
51
|
+
onPushFrame(data: FramePushed): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Cancel the pending turn end timer.
|
|
54
|
+
*
|
|
55
|
+
* The pipeline can be torn down before this observer receives its EndFrame
|
|
56
|
+
* or CancelFrame, and the timer's callback holds the pipeline until it fires.
|
|
57
|
+
*/
|
|
58
|
+
cleanup(): Promise<void>;
|
|
59
|
+
/** Schedule turn end with a timeout. */
|
|
60
|
+
protected _scheduleTurnEnd(data: FramePushed): void;
|
|
61
|
+
/** Cancel the turn end timer if it exists. */
|
|
62
|
+
protected _cancelTurnEndTimer(): void;
|
|
63
|
+
/** End turn after timeout has expired. */
|
|
64
|
+
protected _endTurnAfterTimeout(data: FramePushed): Promise<void>;
|
|
65
|
+
/** Handle user speaking events, including interruptions. */
|
|
66
|
+
protected _handleUserStartedSpeaking(data: FramePushed): Promise<void>;
|
|
67
|
+
/** Handle bot speaking events. */
|
|
68
|
+
protected _handleBotStartedSpeaking(_data: FramePushed): Promise<void>;
|
|
69
|
+
/** Handle bot stopped speaking events. */
|
|
70
|
+
protected _handleBotStoppedSpeaking(data: FramePushed): Promise<void>;
|
|
71
|
+
/** Handle pipeline end or cancellation by flushing any active turn. */
|
|
72
|
+
protected _handlePipelineEnd(data: FramePushed): Promise<void>;
|
|
73
|
+
/** Start a new turn. */
|
|
74
|
+
protected _startTurn(data: FramePushed): Promise<void>;
|
|
75
|
+
/** End the current turn. */
|
|
76
|
+
protected _endTurn(data: FramePushed, wasInterrupted: boolean): Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=turn_tracking_observer.d.ts.map
|