@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,814 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipeline worker implementation for managing frame processing pipelines.
|
|
3
|
+
*
|
|
4
|
+
* Provides the main PipelineWorker class that orchestrates pipeline
|
|
5
|
+
* execution, frame routing, lifecycle management, and monitoring capabilities
|
|
6
|
+
* including heartbeats, idle detection, and observer integration.
|
|
7
|
+
*
|
|
8
|
+
* Porting notes: the deprecated `PipelineTask` and `PipelineTaskParams`
|
|
9
|
+
* aliases, the `toolResources` option, the `ErrorFrame.fatal` branch, the
|
|
10
|
+
* deprecated `StartFrame` configuration fields and the legacy
|
|
11
|
+
* `setup_pipeline_task` setup hook name are not ported.
|
|
12
|
+
*/
|
|
13
|
+
import { Event, Queue, type Task } from "@pipedog/asyncio";
|
|
14
|
+
import { BusCancelWorkerMessage, type BusEndWorkerMessage, BusFrameMessage, type BusMessage } from "../bus/index.ts";
|
|
15
|
+
import { BusUIDataMessage } from "../bus/ui/messages.ts";
|
|
16
|
+
import type { BaseClock } from "../clocks/base_clock.ts";
|
|
17
|
+
import { type Frame, HeartbeatFrame, MetricsFrame, PipelineFlushFrame } from "../frames/frames.ts";
|
|
18
|
+
import { BaseObserver, type FramePushed } from "../observers/base_observer.ts";
|
|
19
|
+
import { TurnTrackingObserver } from "../observers/turn_tracking_observer.ts";
|
|
20
|
+
import { UserBotLatencyObserver } from "../observers/user_bot_latency_observer.ts";
|
|
21
|
+
import { FrameDirection, type FrameProcessor } from "../processors/frame_processor.ts";
|
|
22
|
+
import { type RTVIObserverParams, RTVIProcessor } from "../processors/frameworks/rtvi/index.ts";
|
|
23
|
+
import type { BaseTaskManager } from "../utils/asyncio/task_manager.ts";
|
|
24
|
+
import type { FrameClass } from "../utils/frame_queue.ts";
|
|
25
|
+
import { type OtelAttributeValue } from "../utils/tracing/setup.ts";
|
|
26
|
+
import { TracingContext } from "../utils/tracing/tracing_context.ts";
|
|
27
|
+
import { TurnTraceObserver } from "../utils/tracing/turn_trace_observer.ts";
|
|
28
|
+
import { BaseWorker, type WorkerActivationArgs, type WorkerParams } from "../workers/base_worker.ts";
|
|
29
|
+
import type { BasePipeline } from "./base_pipeline.ts";
|
|
30
|
+
import { BotCapabilities } from "./capabilities.ts";
|
|
31
|
+
import { Pipeline, PipelineSink, PipelineSource } from "./pipeline.ts";
|
|
32
|
+
import { WorkerObserver } from "./worker_observer.ts";
|
|
33
|
+
export declare const HEARTBEAT_SECS = 1;
|
|
34
|
+
export declare const HEARTBEAT_MONITOR_SECS = 10;
|
|
35
|
+
/** How often a pipeline answering someone else's flush says it is still working. */
|
|
36
|
+
export declare const FLUSH_PROGRESS_PERIOD_SECS = 1;
|
|
37
|
+
export declare const IDLE_TIMEOUT_SECS = 300;
|
|
38
|
+
export declare const CANCEL_TIMEOUT_SECS = 20;
|
|
39
|
+
export declare const SETUP_TIMEOUT_SECS = 20;
|
|
40
|
+
export declare const START_TIMEOUT_SECS = 20;
|
|
41
|
+
type AnyClass<T> = abstract new (...args: any[]) => T;
|
|
42
|
+
export interface IdleFrameObserverOptions {
|
|
43
|
+
/** The event to set if the idle timeout frames are being pushed. */
|
|
44
|
+
idleEvent: Event;
|
|
45
|
+
/** The frames that should set the event when received. */
|
|
46
|
+
idleTimeoutFrames: readonly FrameClass[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Idle timeout observer.
|
|
50
|
+
*
|
|
51
|
+
* Waits for specific frames being generated in the pipeline. If the frames
|
|
52
|
+
* are generated the given event is set. If the event is not set it means the
|
|
53
|
+
* pipeline is probably idle.
|
|
54
|
+
*/
|
|
55
|
+
export declare class IdleFrameObserver extends BaseObserver {
|
|
56
|
+
protected _idleEvent: Event;
|
|
57
|
+
protected _idleTimeoutFrames: readonly FrameClass[];
|
|
58
|
+
/**
|
|
59
|
+
* Initialize the observer.
|
|
60
|
+
*
|
|
61
|
+
* @param options.idleEvent The event to set if the idle timeout frames are being pushed.
|
|
62
|
+
* @param options.idleTimeoutFrames The frames that should set the event when received.
|
|
63
|
+
*/
|
|
64
|
+
constructor(options: IdleFrameObserverOptions);
|
|
65
|
+
/**
|
|
66
|
+
* Callback executed when a frame is pushed in the pipeline.
|
|
67
|
+
*
|
|
68
|
+
* @param data The frame push event data.
|
|
69
|
+
*/
|
|
70
|
+
onPushFrame(data: FramePushed): Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* What a pipeline worker does when a processor can no longer do its job.
|
|
74
|
+
*
|
|
75
|
+
* An unusable processor keeps failing for as long as the pipeline keeps using
|
|
76
|
+
* it, so the pipeline has to decide whether it is still worth running. A
|
|
77
|
+
* processor becomes unusable through a permanent error category or through
|
|
78
|
+
* `FrameProcessor.pushError` with `forceTreatAsPermanent: true`.
|
|
79
|
+
*
|
|
80
|
+
* - `CONTINUE`: report the error and keep running. The application can decide
|
|
81
|
+
* what to do, for example by failing over to another provider.
|
|
82
|
+
* - `END`: end the pipeline gracefully, letting queued frames drain first.
|
|
83
|
+
* - `CANCEL`: cancel the pipeline immediately, abandoning queued frames.
|
|
84
|
+
*/
|
|
85
|
+
export declare const ProcessorUnusablePolicy: {
|
|
86
|
+
readonly CONTINUE: "continue";
|
|
87
|
+
readonly END: "end";
|
|
88
|
+
readonly CANCEL: "cancel";
|
|
89
|
+
};
|
|
90
|
+
export type ProcessorUnusablePolicy = (typeof ProcessorUnusablePolicy)[keyof typeof ProcessorUnusablePolicy];
|
|
91
|
+
export interface PipelineParamsOptions {
|
|
92
|
+
audioInSampleRate?: number;
|
|
93
|
+
audioOutSampleRate?: number;
|
|
94
|
+
enableHeartbeats?: boolean;
|
|
95
|
+
enableMetrics?: boolean;
|
|
96
|
+
enableUsageMetrics?: boolean;
|
|
97
|
+
heartbeatsPeriodSecs?: number;
|
|
98
|
+
heartbeatsMonitorSecs?: number;
|
|
99
|
+
reportOnlyInitialTtfb?: boolean;
|
|
100
|
+
sendInitialEmptyMetrics?: boolean;
|
|
101
|
+
startMetadata?: Record<string, unknown>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Configuration parameters for pipeline execution.
|
|
105
|
+
*
|
|
106
|
+
* These parameters are usually passed to all frame processors through
|
|
107
|
+
* FrameProcessorSetup. For other generic pipeline worker parameters use
|
|
108
|
+
* PipelineWorker constructor options instead.
|
|
109
|
+
*
|
|
110
|
+
* - `audioInSampleRate`: input audio sample rate in Hz.
|
|
111
|
+
* - `audioOutSampleRate`: output audio sample rate in Hz.
|
|
112
|
+
* - `enableHeartbeats`: whether to enable heartbeat monitoring.
|
|
113
|
+
* - `enableMetrics`: whether to enable metrics collection.
|
|
114
|
+
* - `enableUsageMetrics`: whether to enable usage metrics.
|
|
115
|
+
* - `heartbeatsPeriodSecs`: period between heartbeats in seconds.
|
|
116
|
+
* - `heartbeatsMonitorSecs`: timeout (in seconds) before warning about missed
|
|
117
|
+
* heartbeats. Defaults to 10 seconds.
|
|
118
|
+
* - `reportOnlyInitialTtfb`: whether to report only initial time to first byte.
|
|
119
|
+
* - `sendInitialEmptyMetrics`: whether to send initial empty metrics.
|
|
120
|
+
* - `startMetadata`: additional metadata for pipeline start.
|
|
121
|
+
*/
|
|
122
|
+
export declare class PipelineParams {
|
|
123
|
+
audioInSampleRate: number;
|
|
124
|
+
audioOutSampleRate: number;
|
|
125
|
+
enableHeartbeats: boolean;
|
|
126
|
+
enableMetrics: boolean;
|
|
127
|
+
enableUsageMetrics: boolean;
|
|
128
|
+
heartbeatsPeriodSecs: number;
|
|
129
|
+
heartbeatsMonitorSecs: number;
|
|
130
|
+
reportOnlyInitialTtfb: boolean;
|
|
131
|
+
sendInitialEmptyMetrics: boolean;
|
|
132
|
+
startMetadata: Record<string, unknown>;
|
|
133
|
+
constructor(options?: PipelineParamsOptions);
|
|
134
|
+
}
|
|
135
|
+
export interface PipelineWorkerOptions {
|
|
136
|
+
/** Whether the worker starts active. Forwarded to `BaseWorker`. */
|
|
137
|
+
active?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Optional attributes to propagate as OpenTelemetry conversation span
|
|
140
|
+
* attributes.
|
|
141
|
+
*/
|
|
142
|
+
additionalSpanAttributes?: Record<string, OtelAttributeValue> | null;
|
|
143
|
+
/**
|
|
144
|
+
* Optional application-defined bag of anything your application code may
|
|
145
|
+
* want to share across this session (DB handles, HTTP clients, etc.),
|
|
146
|
+
* passed by reference. Pipecat passes it through untouched and exposes it
|
|
147
|
+
* on the worker itself as `worker.appResources` and passes it to tool
|
|
148
|
+
* handlers as `FunctionCallParams.appResources`. The framework never copies
|
|
149
|
+
* or clears this object; the caller retains their handle and can read any
|
|
150
|
+
* mutations after the worker finishes.
|
|
151
|
+
*/
|
|
152
|
+
appResources?: unknown;
|
|
153
|
+
/**
|
|
154
|
+
* Bridge configuration. `null` means the pipeline is not bridged. An empty
|
|
155
|
+
* array `[]` wraps the pipeline with bus edge processors that accept frames
|
|
156
|
+
* from all bridges. An array of names like `["voice"]` accepts only frames
|
|
157
|
+
* from those bridges. The bus comes from `attach()` (called by the runner).
|
|
158
|
+
*/
|
|
159
|
+
bridged?: readonly string[] | null;
|
|
160
|
+
/**
|
|
161
|
+
* Whether reaching the idle timeout should cancel the pipeline worker. When
|
|
162
|
+
* false, the idle event still fires `on_idle_timeout` but the worker is
|
|
163
|
+
* left alone (and `cancelRunnerOnIdleTimeout` is ignored too: opting out of
|
|
164
|
+
* local cancellation also opts out of the runner-wide cancel).
|
|
165
|
+
*/
|
|
166
|
+
cancelOnIdleTimeout?: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* When `cancelOnIdleTimeout` is also true, whether reaching the idle
|
|
169
|
+
* timeout should also cancel the entire `WorkerRunner`. The worker is
|
|
170
|
+
* always cancelled first; when this is true the worker also emits a
|
|
171
|
+
* `BusCancelMessage` so the runner broadcasts cancellation to every other
|
|
172
|
+
* root worker. Defaults to true so a multi-worker bot's helpers shut down
|
|
173
|
+
* with the main pipeline; set to false for a sidecar `PipelineWorker` that
|
|
174
|
+
* should self-cancel on idle without bringing down its peers.
|
|
175
|
+
*/
|
|
176
|
+
cancelRunnerOnIdleTimeout?: boolean;
|
|
177
|
+
/** Timeout (in seconds) to wait for cancellation to happen cleanly. */
|
|
178
|
+
cancelTimeoutSecs?: number;
|
|
179
|
+
/**
|
|
180
|
+
* What the bot does, for fields the pipeline can't show. Its known fields
|
|
181
|
+
* replace the ones derived from the pipeline's transports and parameters.
|
|
182
|
+
* See `capabilities`.
|
|
183
|
+
*/
|
|
184
|
+
capabilities?: BotCapabilities | null;
|
|
185
|
+
/**
|
|
186
|
+
* Whether to warn about tasks left running when the worker finishes. Only
|
|
187
|
+
* applies when the worker owns its task manager; otherwise the runner
|
|
188
|
+
* reports dangling tasks.
|
|
189
|
+
*/
|
|
190
|
+
checkDanglingTasks?: boolean;
|
|
191
|
+
/** Clock implementation for timing operations. */
|
|
192
|
+
clock?: BaseClock | null;
|
|
193
|
+
/** Optional custom ID for the conversation. */
|
|
194
|
+
conversationId?: string | null;
|
|
195
|
+
/** Whether to enable tracing. */
|
|
196
|
+
enableTracing?: boolean;
|
|
197
|
+
/** Whether to enable turn tracking. */
|
|
198
|
+
enableTurnTracking?: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Whether this worker answers a flush probe, bouncing it at the sink and
|
|
201
|
+
* completing it at the source. Defaults to whether the pipeline is
|
|
202
|
+
* unbridged, so a worker wired into someone else's topology leaves the
|
|
203
|
+
* probe to travel on and be completed by the pipeline that owns the
|
|
204
|
+
* transport. A bridged worker with no such peer never completes a flush and
|
|
205
|
+
* every `flushPipeline` call waits out its timeout.
|
|
206
|
+
*/
|
|
207
|
+
handleFlushFrame?: boolean | null;
|
|
208
|
+
/**
|
|
209
|
+
* Whether to automatically add RTVI support to the pipeline. `null`, the
|
|
210
|
+
* default, adds it unless the pipeline is bridged: a bridged worker has no
|
|
211
|
+
* client of its own, and its RTVI would report every frame a second time as
|
|
212
|
+
* it crosses the bridge.
|
|
213
|
+
*/
|
|
214
|
+
enableRtvi?: boolean | null;
|
|
215
|
+
/**
|
|
216
|
+
* When `bridged` is set, extra frame types that should not cross the bus
|
|
217
|
+
* (lifecycle frames are always excluded).
|
|
218
|
+
*/
|
|
219
|
+
excludeFrames?: readonly FrameClass[] | null;
|
|
220
|
+
/**
|
|
221
|
+
* The frames that should trigger an idle timeout if not received within
|
|
222
|
+
* `idleTimeoutSecs`. The default pairs the VAD-only `UserSpeakingFrame` with
|
|
223
|
+
* the turn and transcription frames a provider-driven pipeline reports
|
|
224
|
+
* instead.
|
|
225
|
+
*/
|
|
226
|
+
idleTimeoutFrames?: readonly FrameClass[];
|
|
227
|
+
/**
|
|
228
|
+
* Timeout (in seconds) to consider pipeline idle, or null. If a pipeline is
|
|
229
|
+
* idle the pipeline worker will be cancelled automatically.
|
|
230
|
+
*/
|
|
231
|
+
idleTimeoutSecs?: number | null;
|
|
232
|
+
/** Optional worker name (used for worker-style addressing on the bus). */
|
|
233
|
+
name?: string | null;
|
|
234
|
+
/** Observers for monitoring pipeline execution. */
|
|
235
|
+
observers?: BaseObserver[] | null;
|
|
236
|
+
/**
|
|
237
|
+
* What to do when a processor reports an error that leaves it unable to do
|
|
238
|
+
* its job, such as a service whose API key was rejected. Defaults to
|
|
239
|
+
* `ProcessorUnusablePolicy.CONTINUE`, leaving the decision to
|
|
240
|
+
* `on_pipeline_error` handlers.
|
|
241
|
+
*/
|
|
242
|
+
processorUnusablePolicy?: ProcessorUnusablePolicy;
|
|
243
|
+
/** Configuration parameters for the pipeline. */
|
|
244
|
+
params?: PipelineParams | null;
|
|
245
|
+
/** The RTVI processor to add if RTVI is enabled. */
|
|
246
|
+
rtviProcessor?: RTVIProcessor | null;
|
|
247
|
+
/** The RTVI observer parameters to use if RTVI is enabled. */
|
|
248
|
+
rtviObserverParams?: RTVIObserverParams | null;
|
|
249
|
+
/**
|
|
250
|
+
* Timeout (in seconds) to wait for every processor to be set up. Processors
|
|
251
|
+
* connect while they are set up, so one that blocks connecting never lets
|
|
252
|
+
* the pipeline start, and the worker is torn down instead of waiting
|
|
253
|
+
* forever. The `StartFrame` is pushed while processors are still being set
|
|
254
|
+
* up, and each processor holds it only until its own setup is done, so
|
|
255
|
+
* processors ahead of a slow one start without it.
|
|
256
|
+
*/
|
|
257
|
+
setupTimeoutSecs?: number;
|
|
258
|
+
/**
|
|
259
|
+
* Timeout (in seconds) to wait for the `StartFrame` to reach the end of the
|
|
260
|
+
* pipeline, counted from when every processor is set up. A processor that
|
|
261
|
+
* blocks while handling it never lets the pipeline start, so the worker is
|
|
262
|
+
* torn down instead of waiting forever.
|
|
263
|
+
*/
|
|
264
|
+
startTimeoutSecs?: number;
|
|
265
|
+
/** Optional task manager for handling tasks. */
|
|
266
|
+
taskManager?: BaseTaskManager | null;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Manages the execution of a pipeline, handling frame processing and worker
|
|
270
|
+
* lifecycle.
|
|
271
|
+
*
|
|
272
|
+
* Orchestrates pipeline execution with comprehensive monitoring, event
|
|
273
|
+
* handling, and lifecycle management. Provides event handlers for various
|
|
274
|
+
* pipeline states and frame types, idle detection, heartbeat monitoring, and
|
|
275
|
+
* observer integration.
|
|
276
|
+
*
|
|
277
|
+
* Event handlers available:
|
|
278
|
+
*
|
|
279
|
+
* - on_frame_reached_upstream: called when upstream frames reach the source
|
|
280
|
+
* - on_frame_reached_downstream: called when downstream frames reach the sink
|
|
281
|
+
* - on_heartbeat_timeout: called when a heartbeat frame is not received within
|
|
282
|
+
* the monitor timeout. Fires repeatedly every `heartbeatsMonitorSecs` for as
|
|
283
|
+
* long as the stall persists.
|
|
284
|
+
* - on_idle_timeout: called when pipeline is idle beyond timeout threshold
|
|
285
|
+
* - on_pipeline_started: called when pipeline starts with StartFrame
|
|
286
|
+
* - on_pipeline_finished: called after the pipeline has reached any terminal
|
|
287
|
+
* state. This includes:
|
|
288
|
+
* - StopFrame: pipeline was stopped (processors keep connections open)
|
|
289
|
+
* - EndFrame: pipeline ended normally
|
|
290
|
+
* - CancelFrame: pipeline was cancelled
|
|
291
|
+
*
|
|
292
|
+
* Use this event for cleanup, logging, or post-processing tasks. Users can
|
|
293
|
+
* inspect the frame if they need to handle specific cases.
|
|
294
|
+
* - on_pipeline_timeout: called when a frame the worker was waiting on never
|
|
295
|
+
* reached the end of the pipeline, meaning a processor is blocked. Inspect
|
|
296
|
+
* the frame to tell the cases apart:
|
|
297
|
+
* - StartFrame: the pipeline never started and is being torn down
|
|
298
|
+
* - CancelFrame: the pipeline was cancelled but did not drain
|
|
299
|
+
*
|
|
300
|
+
* There is no EndFrame case: ending flushes whatever is queued, so the
|
|
301
|
+
* worker waits for it however long that takes.
|
|
302
|
+
* - on_pipeline_error: called when an error occurs with ErrorFrame. Handler
|
|
303
|
+
* can read `frame.processor.isUsable` to distinguish between errors that
|
|
304
|
+
* end a processor's usability from those that don't.
|
|
305
|
+
* - on_setup_timeout: called when setting the pipeline up times out.
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* worker.eventHandler("on_frame_reached_upstream", async (worker, frame) => { ... });
|
|
309
|
+
* worker.eventHandler("on_heartbeat_timeout", async (worker) => { ... });
|
|
310
|
+
* worker.eventHandler("on_idle_timeout", async (worker) => { ... });
|
|
311
|
+
* worker.eventHandler("on_pipeline_started", async (worker, frame) => { ... });
|
|
312
|
+
* worker.eventHandler("on_pipeline_finished", async (worker, frame) => { ... });
|
|
313
|
+
* worker.eventHandler("on_pipeline_timeout", async (worker, frame) => { ... });
|
|
314
|
+
* worker.eventHandler("on_pipeline_error", async (worker, frame) => { ... });
|
|
315
|
+
* worker.eventHandler("on_setup_timeout", async (worker) => { ... });
|
|
316
|
+
*/
|
|
317
|
+
export declare class PipelineWorker extends BaseWorker {
|
|
318
|
+
protected _bridged: readonly string[] | null;
|
|
319
|
+
protected _handleFlushFrame: boolean;
|
|
320
|
+
protected _params: PipelineParams;
|
|
321
|
+
protected _capabilitiesOverride: BotCapabilities;
|
|
322
|
+
protected _additionalSpanAttributes: Record<string, OtelAttributeValue>;
|
|
323
|
+
protected _cancelOnIdleTimeout: boolean;
|
|
324
|
+
protected _cancelRunnerOnIdleTimeout: boolean;
|
|
325
|
+
protected _cancelTimeoutSecs: number;
|
|
326
|
+
protected _framesReachingSink: number;
|
|
327
|
+
protected _foreignProbes: Map<number, string>;
|
|
328
|
+
protected _flushProgress: Map<number, number>;
|
|
329
|
+
protected _flushProgressSent: number;
|
|
330
|
+
protected _setupTimeoutSecs: number;
|
|
331
|
+
protected _startTimeoutSecs: number;
|
|
332
|
+
protected _clock: BaseClock;
|
|
333
|
+
protected _conversationId: string | null;
|
|
334
|
+
protected _enableTracing: boolean;
|
|
335
|
+
protected _enableTurnTracking: boolean;
|
|
336
|
+
protected _idleTimeoutSecs: number | null;
|
|
337
|
+
protected _appResources: unknown;
|
|
338
|
+
protected _processorUnusablePolicy: ProcessorUnusablePolicy;
|
|
339
|
+
protected _unusableProcessors: Set<FrameProcessor>;
|
|
340
|
+
protected _turnTrackingObserver: TurnTrackingObserver | null;
|
|
341
|
+
protected _userBotLatencyObserver: UserBotLatencyObserver | null;
|
|
342
|
+
protected _turnTraceObserver: TurnTraceObserver | null;
|
|
343
|
+
protected _tracingContext: TracingContext | null;
|
|
344
|
+
protected _finished: boolean;
|
|
345
|
+
protected _cancelled: boolean;
|
|
346
|
+
protected _pushQueue: Queue<Frame>;
|
|
347
|
+
protected _processPushTask: Task<unknown> | null;
|
|
348
|
+
protected _pipelineSetupTask: Task<unknown> | null;
|
|
349
|
+
protected _pipelineStartTask: Task<boolean | undefined> | null;
|
|
350
|
+
protected _setupWatchTask: Task<unknown> | null;
|
|
351
|
+
protected _heartbeatQueue: Queue<HeartbeatFrame>;
|
|
352
|
+
protected _heartbeatPushTask: Task<unknown> | null;
|
|
353
|
+
protected _heartbeatMonitorTask: Task<unknown> | null;
|
|
354
|
+
protected _rtvi: RTVIProcessor | null;
|
|
355
|
+
protected _idleEvent: Event;
|
|
356
|
+
protected _idleMonitorTask: Task<unknown> | null;
|
|
357
|
+
protected _pipelineStartEvent: Event;
|
|
358
|
+
protected _pipelineEndEvent: Event;
|
|
359
|
+
protected _source: PipelineSource;
|
|
360
|
+
protected _sink: PipelineSink;
|
|
361
|
+
protected _pipeline: Pipeline;
|
|
362
|
+
protected _observer: WorkerObserver;
|
|
363
|
+
protected _reachedUpstreamTypes: Set<FrameClass>;
|
|
364
|
+
protected _reachedDownstreamTypes: Set<FrameClass>;
|
|
365
|
+
/**
|
|
366
|
+
* Initialize the PipelineWorker.
|
|
367
|
+
*
|
|
368
|
+
* @param pipeline The pipeline to execute.
|
|
369
|
+
* @param options See `PipelineWorkerOptions`.
|
|
370
|
+
*/
|
|
371
|
+
constructor(pipeline: BasePipeline, options?: PipelineWorkerOptions);
|
|
372
|
+
/** The pipeline parameters for this worker. */
|
|
373
|
+
get params(): PipelineParams;
|
|
374
|
+
/**
|
|
375
|
+
* What the bot does in this session.
|
|
376
|
+
*
|
|
377
|
+
* Derived from the media the pipeline's transports send and receive and
|
|
378
|
+
* from `PipelineParams.enableMetrics`, with the `capabilities` passed to the
|
|
379
|
+
* constructor applied on top. A field no transport reports is `null`
|
|
380
|
+
* (unknown). RTVI sends this to the client in `bot-ready`.
|
|
381
|
+
*/
|
|
382
|
+
get capabilities(): BotCapabilities;
|
|
383
|
+
/** Whether this pipeline is bridged onto the bus. */
|
|
384
|
+
get bridged(): boolean;
|
|
385
|
+
/**
|
|
386
|
+
* The application-defined resources passed to this worker.
|
|
387
|
+
*
|
|
388
|
+
* This is the same object passed to the constructor as `appResources`. Tool
|
|
389
|
+
* handlers can also access it via `FunctionCallParams.appResources`. The
|
|
390
|
+
* framework returns the original reference; mutations are visible to all
|
|
391
|
+
* callers. `null` if none were passed.
|
|
392
|
+
*/
|
|
393
|
+
get appResources(): unknown;
|
|
394
|
+
/**
|
|
395
|
+
* The full pipeline managed by this pipeline worker. This also includes any
|
|
396
|
+
* internal processors added by the pipeline worker.
|
|
397
|
+
*/
|
|
398
|
+
get pipeline(): BasePipeline;
|
|
399
|
+
/** The turn tracking observer if enabled, or null. */
|
|
400
|
+
get turnTrackingObserver(): TurnTrackingObserver | null;
|
|
401
|
+
/** The turn trace observer if enabled, or null. */
|
|
402
|
+
get turnTraceObserver(): TurnTraceObserver | null;
|
|
403
|
+
/** The RTVI processor added to the pipeline when RTVI is enabled. */
|
|
404
|
+
get rtvi(): RTVIProcessor;
|
|
405
|
+
/** Frame types that trigger the on_frame_reached_upstream event. */
|
|
406
|
+
get reachedUpstreamTypes(): FrameClass[];
|
|
407
|
+
/** Frame types that trigger the on_frame_reached_downstream event. */
|
|
408
|
+
get reachedDownstreamTypes(): FrameClass[];
|
|
409
|
+
/**
|
|
410
|
+
* Add an observer to monitor pipeline execution.
|
|
411
|
+
*
|
|
412
|
+
* @param observer The observer to add to the pipeline monitoring.
|
|
413
|
+
*/
|
|
414
|
+
addObserver(observer: BaseObserver): void;
|
|
415
|
+
/**
|
|
416
|
+
* Remove an observer from pipeline monitoring.
|
|
417
|
+
*
|
|
418
|
+
* @param observer The observer to remove from pipeline monitoring.
|
|
419
|
+
*/
|
|
420
|
+
removeObserver(observer: BaseObserver): Promise<void>;
|
|
421
|
+
/**
|
|
422
|
+
* Set which frame types trigger the on_frame_reached_upstream event.
|
|
423
|
+
*
|
|
424
|
+
* @param types Frame types to monitor for upstream events.
|
|
425
|
+
*/
|
|
426
|
+
setReachedUpstreamFilter(types: readonly FrameClass[]): void;
|
|
427
|
+
/**
|
|
428
|
+
* Set which frame types trigger the on_frame_reached_downstream event.
|
|
429
|
+
*
|
|
430
|
+
* @param types Frame types to monitor for downstream events.
|
|
431
|
+
*/
|
|
432
|
+
setReachedDownstreamFilter(types: readonly FrameClass[]): void;
|
|
433
|
+
/**
|
|
434
|
+
* Add frame types to trigger the on_frame_reached_upstream event.
|
|
435
|
+
*
|
|
436
|
+
* @param types Frame types to add to upstream monitoring.
|
|
437
|
+
*/
|
|
438
|
+
addReachedUpstreamFilter(types: readonly FrameClass[]): void;
|
|
439
|
+
/**
|
|
440
|
+
* Add frame types to trigger the on_frame_reached_downstream event.
|
|
441
|
+
*
|
|
442
|
+
* @param types Frame types to add to downstream monitoring.
|
|
443
|
+
*/
|
|
444
|
+
addReachedDownstreamFilter(types: readonly FrameClass[]): void;
|
|
445
|
+
/**
|
|
446
|
+
* Check if the pipeline worker has finished execution.
|
|
447
|
+
*
|
|
448
|
+
* This indicates whether the worker has finished, meaning all processors
|
|
449
|
+
* have stopped.
|
|
450
|
+
*
|
|
451
|
+
* @returns True if all processors have stopped and the worker is complete.
|
|
452
|
+
*/
|
|
453
|
+
hasFinished(): boolean;
|
|
454
|
+
/**
|
|
455
|
+
* Schedule the pipeline to stop after processing all queued frames.
|
|
456
|
+
*
|
|
457
|
+
* Sends an EndFrame to gracefully terminate the pipeline once all current
|
|
458
|
+
* processing is complete.
|
|
459
|
+
*/
|
|
460
|
+
stopWhenDone(): Promise<void>;
|
|
461
|
+
/**
|
|
462
|
+
* Request a graceful end of the session, draining the pipeline first.
|
|
463
|
+
*
|
|
464
|
+
* Whatever this worker has already pushed reaches the end of the pipeline
|
|
465
|
+
* before the session goes away, rather than being cut off wherever it
|
|
466
|
+
* happened to be.
|
|
467
|
+
*
|
|
468
|
+
* @param options.reason Optional human-readable reason for ending.
|
|
469
|
+
*/
|
|
470
|
+
end(options?: {
|
|
471
|
+
reason?: string | null;
|
|
472
|
+
}): Promise<void>;
|
|
473
|
+
/**
|
|
474
|
+
* Activate a worker by name, draining this pipeline when handing over.
|
|
475
|
+
*
|
|
476
|
+
* Deactivating this worker before its pipeline drains would let the target
|
|
477
|
+
* start producing while this worker's output is still in flight, and both
|
|
478
|
+
* would arrive interleaved. A worker that stays active is handing nothing
|
|
479
|
+
* over, so it doesn't wait: the first activation of a session would
|
|
480
|
+
* otherwise wait on the very worker it is about to wake.
|
|
481
|
+
*
|
|
482
|
+
* @param workerName The name of the worker to activate.
|
|
483
|
+
* @param options.args Optional `WorkerActivationArgs` forwarded to the
|
|
484
|
+
* target worker's `onActivated`.
|
|
485
|
+
* @param options.deactivateSelf Whether to deactivate this worker before
|
|
486
|
+
* activating the target. Deactivating this worker drains its pipeline
|
|
487
|
+
* first; staying active does not. A worker that stays active and wants to
|
|
488
|
+
* drain anyway can call `flushPipeline` before this.
|
|
489
|
+
*/
|
|
490
|
+
activateWorker(workerName: string, options?: {
|
|
491
|
+
args?: WorkerActivationArgs | null;
|
|
492
|
+
deactivateSelf?: boolean;
|
|
493
|
+
}): Promise<void>;
|
|
494
|
+
/**
|
|
495
|
+
* Wait for in-flight frames to be processed, if any can be.
|
|
496
|
+
*
|
|
497
|
+
* A pipeline that is not running has no one left to bounce the flush probe
|
|
498
|
+
* back, so waiting on it would only spend the flush timeout.
|
|
499
|
+
* `_processPushTask` is created with the worker's tasks and cleared once
|
|
500
|
+
* they are torn down, so it stands for whether there is a pipeline to
|
|
501
|
+
* drain.
|
|
502
|
+
*/
|
|
503
|
+
protected _drainPipeline(): Promise<void>;
|
|
504
|
+
/**
|
|
505
|
+
* Request the running pipeline to cancel.
|
|
506
|
+
*
|
|
507
|
+
* @param options.reason Optional reason to indicate why the pipeline is being cancelled.
|
|
508
|
+
*/
|
|
509
|
+
cancel(options?: {
|
|
510
|
+
reason?: string | null;
|
|
511
|
+
}): Promise<void>;
|
|
512
|
+
/**
|
|
513
|
+
* Start and manage the pipeline execution until completion or cancellation.
|
|
514
|
+
*
|
|
515
|
+
* @param params Configuration parameters for pipeline execution.
|
|
516
|
+
*/
|
|
517
|
+
run(params: WorkerParams): Promise<void>;
|
|
518
|
+
/**
|
|
519
|
+
* Queue a single frame to be pushed through the pipeline.
|
|
520
|
+
*
|
|
521
|
+
* Downstream frames are pushed from the beginning of the pipeline. Upstream
|
|
522
|
+
* frames are pushed from the end of the pipeline.
|
|
523
|
+
*
|
|
524
|
+
* @param frame The frame to be processed.
|
|
525
|
+
* @param direction The direction to push the frame. Defaults to downstream.
|
|
526
|
+
*/
|
|
527
|
+
queueFrame(frame: Frame, direction?: FrameDirection): Promise<void>;
|
|
528
|
+
/**
|
|
529
|
+
* Queue multiple frames to be pushed through the pipeline.
|
|
530
|
+
*
|
|
531
|
+
* Downstream frames are pushed from the beginning of the pipeline. Upstream
|
|
532
|
+
* frames are pushed from the end of the pipeline.
|
|
533
|
+
*
|
|
534
|
+
* @param frames An iterable or async iterable of frames to be processed.
|
|
535
|
+
* @param direction The direction to push the frames. Defaults to downstream.
|
|
536
|
+
*/
|
|
537
|
+
queueFrames(frames: Iterable<Frame> | AsyncIterable<Frame>, direction?: FrameDirection): Promise<void>;
|
|
538
|
+
/**
|
|
539
|
+
* Flush all in-flight frames from the pipeline and wait for it to drain.
|
|
540
|
+
*
|
|
541
|
+
* Pushes a `PipelineFlushFrame` downstream; the sink bounces it back
|
|
542
|
+
* upstream, the source turns it around, and its event is set when it
|
|
543
|
+
* reaches the sink a second time. By then every frame queued ahead of it
|
|
544
|
+
* has been processed, along with anything a processor started by pushing
|
|
545
|
+
* upstream. The probe goes on the worker's push queue, behind whatever is
|
|
546
|
+
* already waiting there, and bypasses any `queueFrame` override (e.g.
|
|
547
|
+
* tool-call deferral).
|
|
548
|
+
*
|
|
549
|
+
* @param timeout Seconds of no progress before giving up. Progress is a
|
|
550
|
+
* frame reaching this worker's sink, or a report from the pipeline
|
|
551
|
+
* answering the probe when it crossed into another worker. A pipeline
|
|
552
|
+
* still working keeps the wait alive, however long it takes; one that is
|
|
553
|
+
* stuck, or that nobody will answer, gives up after this much quiet. On
|
|
554
|
+
* giving up a warning is logged and `false` is returned rather than
|
|
555
|
+
* blocking forever.
|
|
556
|
+
* @returns True if the pipeline drained, false if it went quiet first.
|
|
557
|
+
*/
|
|
558
|
+
flushPipeline(timeout?: number): Promise<boolean>;
|
|
559
|
+
/**
|
|
560
|
+
* Report progress on a probe from another worker while we hold it.
|
|
561
|
+
*
|
|
562
|
+
* Called by whoever brings the probe into this pipeline, since only they
|
|
563
|
+
* know it is really coming in: every worker on the bus sees it, but most of
|
|
564
|
+
* them have nowhere to put it.
|
|
565
|
+
*
|
|
566
|
+
* @param frame The flush probe entering this pipeline.
|
|
567
|
+
*/
|
|
568
|
+
trackFlushProbe(frame: PipelineFlushFrame): void;
|
|
569
|
+
/**
|
|
570
|
+
* Handle outbound bus messages: TTS playback and RTVI UI translation.
|
|
571
|
+
*
|
|
572
|
+
* Runs the base lifecycle/job dispatch first. A `BusTTSSpeakMessage`
|
|
573
|
+
* targeted at this worker is queued as a `TTSSpeakFrame` (pipelines without
|
|
574
|
+
* a TTS service let it flow through). When this worker owns the RTVI
|
|
575
|
+
* processor, UI carriers produced by a `UIWorker` (`BusUIDataMessage`
|
|
576
|
+
* subclasses) are translated into RTVI frames by `_handleUiBusMessage`;
|
|
577
|
+
* other workers skip the translation.
|
|
578
|
+
*/
|
|
579
|
+
onBusMessage(message: BusMessage): Promise<void>;
|
|
580
|
+
/**
|
|
581
|
+
* Queue a frame that reached this worker over the bus.
|
|
582
|
+
*
|
|
583
|
+
* Queued rather than pushed from the edge that captured the outbound
|
|
584
|
+
* direction, so bus inbound serialises with the frames this worker queues
|
|
585
|
+
* itself (e.g. those a flow framework enqueues from `setNode`).
|
|
586
|
+
*
|
|
587
|
+
* @param message The frame carrier to inject.
|
|
588
|
+
*/
|
|
589
|
+
protected _queueBridgedFrame(message: BusFrameMessage): Promise<void>;
|
|
590
|
+
/**
|
|
591
|
+
* Translate a UI carrier into the matching RTVI frame and queue it.
|
|
592
|
+
*
|
|
593
|
+
* Called only when this worker owns the RTVI processor. The `RTVIObserver`
|
|
594
|
+
* later wraps the queued frame into a typed `ui-command` / `ui-job-group`
|
|
595
|
+
* envelope for the client. Inbound carriers (e.g. `BusUIEventMessage`)
|
|
596
|
+
* match no branch and are ignored.
|
|
597
|
+
*/
|
|
598
|
+
protected _handleUiBusMessage(message: BusUIDataMessage): Promise<void>;
|
|
599
|
+
/**
|
|
600
|
+
* Republish an inbound client UI message onto the bus.
|
|
601
|
+
*
|
|
602
|
+
* Translates a typed RTVI UI message from the client (`UIEventMessage`,
|
|
603
|
+
* `UISnapshotMessage`, or `UICancelJobGroupMessage`) into a single
|
|
604
|
+
* `BusUIEventMessage` carrier so `UIWorker` subscribers can dispatch it.
|
|
605
|
+
* This is the inbound counterpart of `onBusMessage`. Unrecognized message
|
|
606
|
+
* types are ignored.
|
|
607
|
+
*/
|
|
608
|
+
protected _republishUiMessageOnBus(message: unknown): Promise<void>;
|
|
609
|
+
/** Stop processors still setting up; they keep holding the StartFrame. */
|
|
610
|
+
protected _cancelPipelineSetup(): Promise<void>;
|
|
611
|
+
/** Stop waiting for the pipeline to start, so it is only cleaned up. */
|
|
612
|
+
protected _cancelPipelineStart(): Promise<void>;
|
|
613
|
+
/**
|
|
614
|
+
* Internal cancellation logic for the pipeline worker.
|
|
615
|
+
*
|
|
616
|
+
* @param options.reason Optional reason to indicate why the pipeline is being cancelled.
|
|
617
|
+
*/
|
|
618
|
+
protected _cancel(options?: {
|
|
619
|
+
reason?: string | null;
|
|
620
|
+
}): Promise<void>;
|
|
621
|
+
/** Create and start all pipeline processing tasks. */
|
|
622
|
+
protected _createTasks(): Promise<void>;
|
|
623
|
+
/**
|
|
624
|
+
* Give up on a pipeline whose processors don't finish setting up.
|
|
625
|
+
*
|
|
626
|
+
* Setting up is cancelled, so the processors still being set up keep
|
|
627
|
+
* holding the StartFrame: the pipeline never starts and is only cleaned up,
|
|
628
|
+
* as when setting the worker up times out.
|
|
629
|
+
*/
|
|
630
|
+
protected _watchPipelineSetup(): Promise<void>;
|
|
631
|
+
/** Start heartbeat tasks if heartbeats are enabled and not already running. */
|
|
632
|
+
protected _maybeStartHeartbeatTasks(): void;
|
|
633
|
+
/** Start the idle monitoring task if an idle timeout is configured. */
|
|
634
|
+
protected _maybeStartIdleTask(): void;
|
|
635
|
+
/** Cancel all running pipeline tasks. */
|
|
636
|
+
protected _cancelTasks(): Promise<void>;
|
|
637
|
+
/** Cancel heartbeat tasks if they are running. */
|
|
638
|
+
protected _maybeCancelHeartbeatTasks(): Promise<void>;
|
|
639
|
+
/** Cancel the idle monitoring task if it is running. */
|
|
640
|
+
protected _maybeCancelIdleTask(): Promise<void>;
|
|
641
|
+
/** Create an initial metrics frame with zero values for all processors. */
|
|
642
|
+
protected _initialMetricsFrame(): MetricsFrame;
|
|
643
|
+
/**
|
|
644
|
+
* Push the StartFrame and wait for the pipeline to start.
|
|
645
|
+
*
|
|
646
|
+
* Pushing it waits too, while the pipeline is still held, so cancelling
|
|
647
|
+
* this task gives up on both.
|
|
648
|
+
*
|
|
649
|
+
* @returns Whether the pipeline started; see `_waitForPipelineStart`.
|
|
650
|
+
*/
|
|
651
|
+
protected _startPipeline(): Promise<boolean>;
|
|
652
|
+
/**
|
|
653
|
+
* Wait for the start task, and return whether it started the pipeline (a
|
|
654
|
+
* cancelled one didn't).
|
|
655
|
+
*/
|
|
656
|
+
protected _waitForStartTask(): Promise<boolean>;
|
|
657
|
+
/**
|
|
658
|
+
* Wait for the specified start frame to reach the end of the pipeline.
|
|
659
|
+
*
|
|
660
|
+
* @returns Whether the pipeline started. A pipeline that doesn't start
|
|
661
|
+
* within `startTimeoutSecs` is torn down, since nothing pushed into it
|
|
662
|
+
* afterwards would be processed.
|
|
663
|
+
*/
|
|
664
|
+
protected _waitForPipelineStart(frame: Frame): Promise<boolean>;
|
|
665
|
+
/** Wait for the specified frame to reach the end of the pipeline. */
|
|
666
|
+
protected _waitForPipelineEnd(frame: Frame): Promise<void>;
|
|
667
|
+
protected _waitForPipelineFinished(): Promise<void>;
|
|
668
|
+
/**
|
|
669
|
+
* Set up the pipeline worker, bounded by a timeout.
|
|
670
|
+
*
|
|
671
|
+
* Processors are only started being set up here; their setup is bounded
|
|
672
|
+
* separately by `_watchPipelineSetup`.
|
|
673
|
+
*
|
|
674
|
+
* @returns Whether the worker was set up. Setup files and observers that
|
|
675
|
+
* block never let the pipeline start, so setting up is abandoned once
|
|
676
|
+
* `setupTimeoutSecs` elapses.
|
|
677
|
+
*/
|
|
678
|
+
protected _setupWithinTimeout(params: WorkerParams): Promise<boolean>;
|
|
679
|
+
/** Set up the pipeline worker and all processors. */
|
|
680
|
+
protected _setup(params: WorkerParams): Promise<void>;
|
|
681
|
+
/**
|
|
682
|
+
* Release the pipeline once it is set up, unless setting up was abandoned.
|
|
683
|
+
*
|
|
684
|
+
* A cancelled setup (timed out, or the worker was cancelled) keeps the
|
|
685
|
+
* StartFrame held, so the pipeline never starts and is only cleaned up.
|
|
686
|
+
*/
|
|
687
|
+
protected _pipelineSetupDone(task: Task<unknown>): void;
|
|
688
|
+
/** Clean up the pipeline worker and processors. */
|
|
689
|
+
protected _cleanup(cleanupPipeline: boolean): Promise<void>;
|
|
690
|
+
/**
|
|
691
|
+
* Cancel the children once this worker's pipeline is over.
|
|
692
|
+
*
|
|
693
|
+
* A pipeline that ends on its own (an `EndFrame` it queued itself, an idle
|
|
694
|
+
* timeout, a permanent error) is never told to end over the bus, so nothing
|
|
695
|
+
* has passed the end on to its children. A child that has already finished
|
|
696
|
+
* takes no notice.
|
|
697
|
+
*/
|
|
698
|
+
protected _cancelChildren(): Promise<void>;
|
|
699
|
+
/**
|
|
700
|
+
* End the pipeline after propagating end to children.
|
|
701
|
+
*
|
|
702
|
+
* Drives shutdown through the pipeline (`EndFrame`) so `_finishedEvent`
|
|
703
|
+
* fires once the frame drains through the sink, rather than calling
|
|
704
|
+
* `stop()` directly.
|
|
705
|
+
*/
|
|
706
|
+
protected _handleWorkerEnd(message: BusEndWorkerMessage): Promise<void>;
|
|
707
|
+
/**
|
|
708
|
+
* Cancel the pipeline after propagating cancel to children.
|
|
709
|
+
*
|
|
710
|
+
* Drives shutdown through the pipeline (`CancelFrame`) so `_finishedEvent`
|
|
711
|
+
* fires once the frame drains, rather than calling `stop()` directly.
|
|
712
|
+
*
|
|
713
|
+
* Children are told whatever state this worker is in: one that cancelled
|
|
714
|
+
* itself earlier, on an idle timeout or a permanent error, still has to
|
|
715
|
+
* pass the runner's cancel on.
|
|
716
|
+
*/
|
|
717
|
+
protected _handleWorkerCancel(message: BusCancelWorkerMessage): Promise<void>;
|
|
718
|
+
/**
|
|
719
|
+
* Process frames from the push queue and send them through the pipeline.
|
|
720
|
+
*
|
|
721
|
+
* Once the start task has started the pipeline, it pushes the frames queued
|
|
722
|
+
* by the user. It runs until the worker is cancelled or stopped (e.g. with
|
|
723
|
+
* an EndFrame).
|
|
724
|
+
*/
|
|
725
|
+
protected _processPushQueue(): Promise<void>;
|
|
726
|
+
/**
|
|
727
|
+
* Move a flush probe along its trip, settling it once it is done.
|
|
728
|
+
*
|
|
729
|
+
* The probe travels down to the sink, back up to the source, then down
|
|
730
|
+
* again, and only the second arrival at the sink settles it. The extra leg
|
|
731
|
+
* is what makes the probe wait for work a processor starts by pushing
|
|
732
|
+
* upstream: an `LLMContextFrame` pushed up after a function call result,
|
|
733
|
+
* say, whose response only comes back down afterwards. A probe that stopped
|
|
734
|
+
* at the source would return while that response was still being
|
|
735
|
+
* generated, or still being synthesized.
|
|
736
|
+
*
|
|
737
|
+
* @param frame The probe, carrying the event its initiator awaits.
|
|
738
|
+
* @param atSink Whether the probe has arrived at the sink or the source.
|
|
739
|
+
*/
|
|
740
|
+
protected _advanceFlushProbe(frame: PipelineFlushFrame, atSink: boolean): Promise<void>;
|
|
741
|
+
/**
|
|
742
|
+
* Tell whoever is waiting on a probe we hold that we are still working.
|
|
743
|
+
*
|
|
744
|
+
* Their own sink sees nothing while we drain, so without this they can only
|
|
745
|
+
* conclude the pipeline has gone quiet. Sent no more than once a second: it
|
|
746
|
+
* says the flush is alive, not how much is left.
|
|
747
|
+
*/
|
|
748
|
+
protected _reportFlushProgress(): Promise<void>;
|
|
749
|
+
/**
|
|
750
|
+
* Process frames coming upstream from the pipeline.
|
|
751
|
+
*
|
|
752
|
+
* These frames might indicate, for example, that we want the pipeline to be
|
|
753
|
+
* stopped (e.g. EndWorkerFrame) in which case we would send an EndFrame
|
|
754
|
+
* down the pipeline.
|
|
755
|
+
*/
|
|
756
|
+
protected _sourcePushFrame(frame: Frame, _direction: FrameDirection): Promise<void>;
|
|
757
|
+
/**
|
|
758
|
+
* Apply the unusable-processor policy, once per processor.
|
|
759
|
+
*
|
|
760
|
+
* A processor that can no longer do its job keeps failing for as long as
|
|
761
|
+
* the pipeline keeps using it, so the policy is applied to the first error
|
|
762
|
+
* that says so and not to the ones that follow.
|
|
763
|
+
*
|
|
764
|
+
* @param processor The processor that can no longer do its job.
|
|
765
|
+
*/
|
|
766
|
+
protected _handleUnusableProcessor(processor: FrameProcessor): Promise<void>;
|
|
767
|
+
/**
|
|
768
|
+
* Process frames coming downstream from the pipeline.
|
|
769
|
+
*
|
|
770
|
+
* Processes frames coming downstream from the pipeline. For example,
|
|
771
|
+
* heartbeat frames or an EndFrame which would indicate all processors have
|
|
772
|
+
* handled the EndFrame and therefore we can exit the worker cleanly.
|
|
773
|
+
*/
|
|
774
|
+
protected _sinkPushFrame(frame: Frame, _direction: FrameDirection): Promise<void>;
|
|
775
|
+
/** Push heartbeat frames at regular intervals. */
|
|
776
|
+
protected _heartbeatPushHandler(): Promise<void>;
|
|
777
|
+
/**
|
|
778
|
+
* Monitor heartbeat frames for processing time and timeout detection.
|
|
779
|
+
*
|
|
780
|
+
* Logs the time each heartbeat takes to traverse the pipeline. If no
|
|
781
|
+
* heartbeat arrives within `heartbeatsMonitorSecs`, logs a warning and
|
|
782
|
+
* fires `on_heartbeat_timeout`. The event fires repeatedly every
|
|
783
|
+
* `heartbeatsMonitorSecs` for as long as the stall persists.
|
|
784
|
+
*/
|
|
785
|
+
protected _heartbeatMonitorHandler(): Promise<void>;
|
|
786
|
+
/**
|
|
787
|
+
* Monitor pipeline activity and detect idle conditions.
|
|
788
|
+
*
|
|
789
|
+
* Tracks frame activity and triggers idle timeout events when the pipeline
|
|
790
|
+
* hasn't received relevant frames within the timeout period.
|
|
791
|
+
*
|
|
792
|
+
* Note: Heartbeats are excluded from idle detection.
|
|
793
|
+
*/
|
|
794
|
+
protected _idleMonitorHandler(): Promise<void>;
|
|
795
|
+
/**
|
|
796
|
+
* Handle idle timeout detection and optional cancellation.
|
|
797
|
+
*
|
|
798
|
+
* @returns Whether the pipeline worker should continue running.
|
|
799
|
+
*/
|
|
800
|
+
protected _idleTimeoutDetected(): Promise<boolean>;
|
|
801
|
+
/**
|
|
802
|
+
* Run `setupPipelineWorker` from each file in `PIPECAT_SETUP_FILES`.
|
|
803
|
+
*
|
|
804
|
+
* A setup file may define `setupPipelineWorker(worker)` to attach event
|
|
805
|
+
* handlers, observers, or other per-worker wiring.
|
|
806
|
+
*/
|
|
807
|
+
protected _loadSetupFiles(): Promise<void>;
|
|
808
|
+
/** Build and return start metadata including user-provided values. */
|
|
809
|
+
protected _createStartMetadata(): Record<string, unknown>;
|
|
810
|
+
/** Recursively yield the processors of the given type(s) in the pipeline. */
|
|
811
|
+
protected _iterProcessors<T>(processor: FrameProcessor, processorTypes: readonly AnyClass<T>[]): Generator<T>;
|
|
812
|
+
}
|
|
813
|
+
export {};
|
|
814
|
+
//# sourceMappingURL=worker.d.ts.map
|