@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,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bus bridge and edge processors for inter-worker frame routing.
|
|
3
|
+
*
|
|
4
|
+
* Provides:
|
|
5
|
+
*
|
|
6
|
+
* - `BusBridgeProcessor`: a mid-pipeline processor that exchanges frames with
|
|
7
|
+
* other workers through the bus, consuming local frames.
|
|
8
|
+
* - `_BusEdgeProcessor`: a pipeline-edge processor used internally by
|
|
9
|
+
* `PipelineWorker` when `bridged` is set. Tees frames between the local
|
|
10
|
+
* pipeline and the bus (frames continue locally and are also forwarded to
|
|
11
|
+
* the bus).
|
|
12
|
+
*/
|
|
13
|
+
import { type Frame } from "../frames/frames.ts";
|
|
14
|
+
import type { PipelineWorker } from "../pipeline/worker.ts";
|
|
15
|
+
import { type FrameDirection, FrameProcessor, type FrameProcessorOptions, type FrameProcessorSetup } from "../processors/frame_processor.ts";
|
|
16
|
+
import type { FrameClass } from "../utils/frame_queue.ts";
|
|
17
|
+
import type { WorkerBus } from "./bus.ts";
|
|
18
|
+
import { type BusMessage } from "./messages.ts";
|
|
19
|
+
export interface BusBridgeProcessorOptions extends FrameProcessorOptions {
|
|
20
|
+
/** The `WorkerBus` to exchange frames with. */
|
|
21
|
+
bus: WorkerBus;
|
|
22
|
+
/** Name of the owning worker, used as message source. */
|
|
23
|
+
workerName: string;
|
|
24
|
+
/** When set, only exchange frames with this worker. */
|
|
25
|
+
targetWorker?: string | null;
|
|
26
|
+
/**
|
|
27
|
+
* Optional bridge name for routing. When set, outgoing frames are tagged
|
|
28
|
+
* with this name and only incoming frames with the same bridge name are
|
|
29
|
+
* accepted.
|
|
30
|
+
*/
|
|
31
|
+
bridge?: string | null;
|
|
32
|
+
/**
|
|
33
|
+
* Extra frame types that should never cross the bus (on top of lifecycle
|
|
34
|
+
* frames which are always excluded).
|
|
35
|
+
*/
|
|
36
|
+
excludeFrames?: readonly FrameClass[] | null;
|
|
37
|
+
}
|
|
38
|
+
declare const BusBridgeProcessor_base: typeof FrameProcessor & import("../utils/mixin.ts").Ctor<import("./subscriber.ts").BusSubscriberMethods>;
|
|
39
|
+
/**
|
|
40
|
+
* Bidirectional mid-pipeline bridge between a Pipecat pipeline and the bus.
|
|
41
|
+
*
|
|
42
|
+
* Placed in a transport or session worker's pipeline to exchange frames with
|
|
43
|
+
* other workers via the `WorkerBus`. Lifecycle and excluded frames pass
|
|
44
|
+
* through locally without crossing the bus.
|
|
45
|
+
*/
|
|
46
|
+
export declare class BusBridgeProcessor extends BusBridgeProcessor_base {
|
|
47
|
+
protected _bus: WorkerBus;
|
|
48
|
+
protected _workerName: string;
|
|
49
|
+
protected _targetWorker: string | null;
|
|
50
|
+
protected _bridge: string | null;
|
|
51
|
+
protected _excludeFrames: readonly FrameClass[];
|
|
52
|
+
/**
|
|
53
|
+
* Initialize the BusBridgeProcessor.
|
|
54
|
+
*
|
|
55
|
+
* The deprecated `target_task` parameter is not ported; use `targetWorker`.
|
|
56
|
+
*/
|
|
57
|
+
constructor(options: BusBridgeProcessorOptions);
|
|
58
|
+
/** Subscribe to the bus during processor setup. */
|
|
59
|
+
setup(setup: FrameProcessorSetup): Promise<void>;
|
|
60
|
+
/** Unsubscribe from the bus on cleanup. */
|
|
61
|
+
cleanup(): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Process a frame: send to bus, or pass through locally if excluded.
|
|
64
|
+
*
|
|
65
|
+
* @param frame The frame to process.
|
|
66
|
+
* @param direction The direction the frame is traveling.
|
|
67
|
+
*/
|
|
68
|
+
processFrame(frame: Frame, direction: FrameDirection): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Handle an incoming bus message by pushing its frame into the pipeline.
|
|
71
|
+
*
|
|
72
|
+
* @param message The bus message to handle.
|
|
73
|
+
*/
|
|
74
|
+
onBusMessage(message: BusMessage): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
export interface _BusEdgeProcessorOptions extends FrameProcessorOptions {
|
|
77
|
+
/**
|
|
78
|
+
* The owning worker; the edge reads `worker.bus` lazily so the bus only
|
|
79
|
+
* needs to be set (via `PipelineWorker.attach`) by the time the processor
|
|
80
|
+
* is set up. `worker.name` is the message source.
|
|
81
|
+
*/
|
|
82
|
+
worker: PipelineWorker;
|
|
83
|
+
/** Direction this edge captures and publishes to the bus. */
|
|
84
|
+
direction: FrameDirection;
|
|
85
|
+
/**
|
|
86
|
+
* Extra frame types that should never cross the bus (lifecycle frames are
|
|
87
|
+
* always excluded).
|
|
88
|
+
*/
|
|
89
|
+
excludeFrames?: readonly FrameClass[] | null;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Pipeline-edge tap that publishes local frames onto the bus.
|
|
93
|
+
*
|
|
94
|
+
* Placed by `PipelineWorker` at the source and sink of a bridged pipeline.
|
|
95
|
+
* Frames always continue through the local pipeline; in addition, frames
|
|
96
|
+
* travelling in `direction` are published to the bus. The opposite path, a
|
|
97
|
+
* frame arriving from the bus, belongs to the worker, which queues it into
|
|
98
|
+
* the pipeline itself.
|
|
99
|
+
*
|
|
100
|
+
* Internal to pipecat (used by `pipeline/worker.ts`); exported only for that.
|
|
101
|
+
*/
|
|
102
|
+
export declare class _BusEdgeProcessor extends FrameProcessor {
|
|
103
|
+
protected _task: PipelineWorker;
|
|
104
|
+
protected _direction: FrameDirection;
|
|
105
|
+
protected _excludeFrames: readonly FrameClass[];
|
|
106
|
+
constructor(options: _BusEdgeProcessorOptions);
|
|
107
|
+
/** Pass the frame through locally and forward matching ones to the bus. */
|
|
108
|
+
processFrame(frame: Frame, direction: FrameDirection): Promise<void>;
|
|
109
|
+
}
|
|
110
|
+
export {};
|
|
111
|
+
//# sourceMappingURL=bridge_processor.d.ts.map
|
|
@@ -0,0 +1,166 @@
|
|
|
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/bus/bridge_processor.py
|
|
6
|
+
/**
|
|
7
|
+
* Bus bridge and edge processors for inter-worker frame routing.
|
|
8
|
+
*
|
|
9
|
+
* Provides:
|
|
10
|
+
*
|
|
11
|
+
* - `BusBridgeProcessor`: a mid-pipeline processor that exchanges frames with
|
|
12
|
+
* other workers through the bus, consuming local frames.
|
|
13
|
+
* - `_BusEdgeProcessor`: a pipeline-edge processor used internally by
|
|
14
|
+
* `PipelineWorker` when `bridged` is set. Tees frames between the local
|
|
15
|
+
* pipeline and the bus (frames continue locally and are also forwarded to
|
|
16
|
+
* the bus).
|
|
17
|
+
*/
|
|
18
|
+
import { CancelFrame, EndFrame, OutputTransportMessageUrgentFrame, PipelineFlushFrame, StartFrame, StopFrame, } from "../frames/frames.js";
|
|
19
|
+
import { FrameProcessor, } from "../processors/frame_processor.js";
|
|
20
|
+
import { BusFrameMessage } from "./messages.js";
|
|
21
|
+
import { BusSubscriber } from "./subscriber.js";
|
|
22
|
+
const _LIFECYCLE_FRAMES = [StartFrame, EndFrame, CancelFrame, StopFrame];
|
|
23
|
+
const _PASSTHROUGH_FRAMES = [OutputTransportMessageUrgentFrame];
|
|
24
|
+
function isInstanceOfAny(frame, types) {
|
|
25
|
+
return types.some((type) => frame instanceof type);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Bidirectional mid-pipeline bridge between a Pipecat pipeline and the bus.
|
|
29
|
+
*
|
|
30
|
+
* Placed in a transport or session worker's pipeline to exchange frames with
|
|
31
|
+
* other workers via the `WorkerBus`. Lifecycle and excluded frames pass
|
|
32
|
+
* through locally without crossing the bus.
|
|
33
|
+
*/
|
|
34
|
+
export class BusBridgeProcessor extends BusSubscriber(FrameProcessor) {
|
|
35
|
+
_bus;
|
|
36
|
+
_workerName;
|
|
37
|
+
_targetWorker;
|
|
38
|
+
_bridge;
|
|
39
|
+
_excludeFrames;
|
|
40
|
+
/**
|
|
41
|
+
* Initialize the BusBridgeProcessor.
|
|
42
|
+
*
|
|
43
|
+
* The deprecated `target_task` parameter is not ported; use `targetWorker`.
|
|
44
|
+
*/
|
|
45
|
+
constructor(options) {
|
|
46
|
+
super(options);
|
|
47
|
+
this._bus = options.bus;
|
|
48
|
+
this._workerName = options.workerName;
|
|
49
|
+
this._targetWorker = options.targetWorker ?? null;
|
|
50
|
+
this._bridge = options.bridge ?? null;
|
|
51
|
+
this._excludeFrames = options.excludeFrames ?? [];
|
|
52
|
+
}
|
|
53
|
+
/** Subscribe to the bus during processor setup. */
|
|
54
|
+
async setup(setup) {
|
|
55
|
+
await super.setup(setup);
|
|
56
|
+
await this._bus.subscribe(this);
|
|
57
|
+
}
|
|
58
|
+
/** Unsubscribe from the bus on cleanup. */
|
|
59
|
+
async cleanup() {
|
|
60
|
+
await super.cleanup();
|
|
61
|
+
await this._bus.unsubscribe(this);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Process a frame: send to bus, or pass through locally if excluded.
|
|
65
|
+
*
|
|
66
|
+
* @param frame The frame to process.
|
|
67
|
+
* @param direction The direction the frame is traveling.
|
|
68
|
+
*/
|
|
69
|
+
async processFrame(frame, direction) {
|
|
70
|
+
await super.processFrame(frame, direction);
|
|
71
|
+
// Lifecycle frames never cross the bus
|
|
72
|
+
if (isInstanceOfAny(frame, _LIFECYCLE_FRAMES)) {
|
|
73
|
+
await this.pushFrame(frame, direction);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
// Urgent transport frames belong to this pipeline rather than to a
|
|
77
|
+
// peer: they have to reach the transport even with no peer active.
|
|
78
|
+
if (isInstanceOfAny(frame, _PASSTHROUGH_FRAMES)) {
|
|
79
|
+
await this.pushFrame(frame, direction);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// Excluded frames never cross the bus
|
|
83
|
+
if (this._excludeFrames.length > 0 && isInstanceOfAny(frame, this._excludeFrames)) {
|
|
84
|
+
await this.pushFrame(frame, direction);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
// Send to bus
|
|
88
|
+
const msg = new BusFrameMessage({
|
|
89
|
+
source: this._workerName,
|
|
90
|
+
frame,
|
|
91
|
+
direction,
|
|
92
|
+
bridge: this._bridge,
|
|
93
|
+
});
|
|
94
|
+
await this._bus.send(msg);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Handle an incoming bus message by pushing its frame into the pipeline.
|
|
98
|
+
*
|
|
99
|
+
* @param message The bus message to handle.
|
|
100
|
+
*/
|
|
101
|
+
async onBusMessage(message) {
|
|
102
|
+
if (!(message instanceof BusFrameMessage)) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
// Skip own frames
|
|
106
|
+
if (message.source === this._workerName) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
// Filter by bridge name
|
|
110
|
+
if (this._bridge && message.bridge !== this._bridge) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// If targetWorker set, only accept from that worker
|
|
114
|
+
if (this._targetWorker && message.source !== this._targetWorker) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
// If message targeted at someone else, skip
|
|
118
|
+
if (message.target && message.target !== this._workerName) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
// The frame has cleared every filter, so this pipeline is the one
|
|
122
|
+
// taking it in.
|
|
123
|
+
if (message.frame instanceof PipelineFlushFrame) {
|
|
124
|
+
this.pipelineWorker.trackFlushProbe(message.frame);
|
|
125
|
+
}
|
|
126
|
+
await this.pushFrame(message.frame, message.direction);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Pipeline-edge tap that publishes local frames onto the bus.
|
|
131
|
+
*
|
|
132
|
+
* Placed by `PipelineWorker` at the source and sink of a bridged pipeline.
|
|
133
|
+
* Frames always continue through the local pipeline; in addition, frames
|
|
134
|
+
* travelling in `direction` are published to the bus. The opposite path, a
|
|
135
|
+
* frame arriving from the bus, belongs to the worker, which queues it into
|
|
136
|
+
* the pipeline itself.
|
|
137
|
+
*
|
|
138
|
+
* Internal to pipecat (used by `pipeline/worker.ts`); exported only for that.
|
|
139
|
+
*/
|
|
140
|
+
export class _BusEdgeProcessor extends FrameProcessor {
|
|
141
|
+
_task;
|
|
142
|
+
_direction;
|
|
143
|
+
_excludeFrames;
|
|
144
|
+
constructor(options) {
|
|
145
|
+
super(options);
|
|
146
|
+
this._task = options.worker;
|
|
147
|
+
this._direction = options.direction;
|
|
148
|
+
this._excludeFrames = options.excludeFrames ?? [];
|
|
149
|
+
}
|
|
150
|
+
/** Pass the frame through locally and forward matching ones to the bus. */
|
|
151
|
+
async processFrame(frame, direction) {
|
|
152
|
+
await super.processFrame(frame, direction);
|
|
153
|
+
await this.pushFrame(frame, direction);
|
|
154
|
+
if (direction !== this._direction) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (isInstanceOfAny(frame, _LIFECYCLE_FRAMES)) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (this._excludeFrames.length > 0 && isInstanceOfAny(frame, this._excludeFrames)) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
await this._task.bus.send(new BusFrameMessage({ source: this._task.name, frame, direction }));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=bridge_processor.js.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract worker bus for inter-worker pub/sub messaging.
|
|
3
|
+
*
|
|
4
|
+
* Provides the abstract `WorkerBus` base class. Concrete implementations
|
|
5
|
+
* (e.g. `AsyncQueueBus`) live in separate modules.
|
|
6
|
+
*/
|
|
7
|
+
import { Queue, type Task } from "@pipedog/asyncio";
|
|
8
|
+
import { BaseObject, type BaseObjectOptions } from "../utils/base_object.ts";
|
|
9
|
+
import { type BusMessage } from "./messages.ts";
|
|
10
|
+
import { BusMessageQueue } from "./queue.ts";
|
|
11
|
+
import type { BusSubscriber } from "./subscriber.ts";
|
|
12
|
+
export interface BusSubscriptionOptions {
|
|
13
|
+
/** The subscriber receiving messages. */
|
|
14
|
+
subscriber: BusSubscriber;
|
|
15
|
+
/** Priority queue for incoming messages. */
|
|
16
|
+
queue?: BusMessageQueue;
|
|
17
|
+
/** Secondary queue for data messages dispatched by the router worker. */
|
|
18
|
+
dataQueue?: Queue<BusMessage>;
|
|
19
|
+
/**
|
|
20
|
+
* Task that reads from the priority queue, handles system messages inline,
|
|
21
|
+
* and routes data messages to the data queue.
|
|
22
|
+
*/
|
|
23
|
+
routerTask?: Task<unknown> | null;
|
|
24
|
+
/** Task that processes data messages sequentially from the data queue. */
|
|
25
|
+
dataTask?: Task<unknown> | null;
|
|
26
|
+
}
|
|
27
|
+
/** A single subscriber's state on the bus. */
|
|
28
|
+
export declare class BusSubscription {
|
|
29
|
+
subscriber: BusSubscriber;
|
|
30
|
+
queue: BusMessageQueue;
|
|
31
|
+
dataQueue: Queue<BusMessage>;
|
|
32
|
+
routerTask: Task<unknown> | null;
|
|
33
|
+
dataTask: Task<unknown> | null;
|
|
34
|
+
constructor(options: BusSubscriptionOptions);
|
|
35
|
+
toString(): string;
|
|
36
|
+
}
|
|
37
|
+
export interface WorkerBusOptions extends BaseObjectOptions {
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Abstract base for inter-worker and runner-worker communication.
|
|
41
|
+
*
|
|
42
|
+
* Provides pub/sub messaging where each subscriber receives messages
|
|
43
|
+
* independently through its own priority queue. System messages (e.g.
|
|
44
|
+
* cancel) are delivered before normal data messages.
|
|
45
|
+
*
|
|
46
|
+
* Subclasses implement `publish()` for the specific transport. `send()`
|
|
47
|
+
* handles local-only messages automatically. For network buses, override
|
|
48
|
+
* `start()`/`stop()` to manage connections and call `onMessageReceived()`
|
|
49
|
+
* when messages arrive from the network.
|
|
50
|
+
*/
|
|
51
|
+
export declare abstract class WorkerBus extends BaseObject {
|
|
52
|
+
protected _subscriptions: Map<string, BusSubscription>;
|
|
53
|
+
protected _running: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Initialize the WorkerBus.
|
|
56
|
+
*
|
|
57
|
+
* @param options Additional arguments passed to `BaseObject`.
|
|
58
|
+
*/
|
|
59
|
+
constructor(options?: WorkerBusOptions);
|
|
60
|
+
/** Start dispatch tasks for all registered subscribers. */
|
|
61
|
+
start(): Promise<void>;
|
|
62
|
+
/** Stop all dispatch tasks. */
|
|
63
|
+
stop(): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Register a subscriber to receive messages from the bus.
|
|
66
|
+
*
|
|
67
|
+
* Idempotent: re-subscribing an already-registered subscriber is a no-op.
|
|
68
|
+
*
|
|
69
|
+
* @param subscriber The `BusSubscriber` to register.
|
|
70
|
+
*/
|
|
71
|
+
subscribe(subscriber: BusSubscriber): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Remove a subscriber and cancel its dispatch tasks.
|
|
74
|
+
*
|
|
75
|
+
* @param subscriber The `BusSubscriber` to remove.
|
|
76
|
+
*/
|
|
77
|
+
unsubscribe(subscriber: BusSubscriber): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Send a message through the bus.
|
|
80
|
+
*
|
|
81
|
+
* Local-only messages are delivered directly to subscribers. All other
|
|
82
|
+
* messages are passed to `publish()` for transport.
|
|
83
|
+
*
|
|
84
|
+
* @param message The bus message to send.
|
|
85
|
+
*/
|
|
86
|
+
send(message: BusMessage): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Publish a message to the transport.
|
|
89
|
+
*
|
|
90
|
+
* Subclasses implement this for the specific transport. Called by `send()`
|
|
91
|
+
* after filtering local-only messages.
|
|
92
|
+
*
|
|
93
|
+
* @param message The bus message to publish.
|
|
94
|
+
*/
|
|
95
|
+
abstract publish(message: BusMessage): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Deliver a message to all local subscribers via their priority queues.
|
|
98
|
+
*
|
|
99
|
+
* Called by bus implementations when a message arrives (either from a local
|
|
100
|
+
* `send()` or from a network transport).
|
|
101
|
+
*/
|
|
102
|
+
onMessageReceived(message: BusMessage): void;
|
|
103
|
+
/** Start the router and data dispatch tasks for a subscriber. */
|
|
104
|
+
protected _startDispatchTask(sub: BusSubscription): void;
|
|
105
|
+
/** Route system messages inline, data messages to the data queue. */
|
|
106
|
+
protected _routerTask(sub: BusSubscription): Promise<void>;
|
|
107
|
+
/** Process data messages sequentially from the data queue. */
|
|
108
|
+
protected _dataDispatchTask(sub: BusSubscription): Promise<void>;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=bus.d.ts.map
|
package/dist/bus/bus.js
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
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/bus/bus.py
|
|
6
|
+
/**
|
|
7
|
+
* Abstract worker bus for inter-worker pub/sub messaging.
|
|
8
|
+
*
|
|
9
|
+
* Provides the abstract `WorkerBus` base class. Concrete implementations
|
|
10
|
+
* (e.g. `AsyncQueueBus`) live in separate modules.
|
|
11
|
+
*/
|
|
12
|
+
import { Queue, rethrowIfCancelled, sleep } from "@pipedog/asyncio";
|
|
13
|
+
import { BaseObject } from "../utils/base_object.js";
|
|
14
|
+
import { logger } from "../utils/logger.js";
|
|
15
|
+
import { BusLocalMessage, BusSystemMessage } from "./messages.js";
|
|
16
|
+
import { BusMessageQueue } from "./queue.js";
|
|
17
|
+
/** A single subscriber's state on the bus. */
|
|
18
|
+
export class BusSubscription {
|
|
19
|
+
subscriber;
|
|
20
|
+
queue;
|
|
21
|
+
dataQueue;
|
|
22
|
+
routerTask;
|
|
23
|
+
dataTask;
|
|
24
|
+
constructor(options) {
|
|
25
|
+
this.subscriber = options.subscriber;
|
|
26
|
+
this.queue = options.queue ?? new BusMessageQueue();
|
|
27
|
+
this.dataQueue = options.dataQueue ?? new Queue();
|
|
28
|
+
this.routerTask = options.routerTask ?? null;
|
|
29
|
+
this.dataTask = options.dataTask ?? null;
|
|
30
|
+
}
|
|
31
|
+
toString() {
|
|
32
|
+
return `BusSubscription(subscriber=${this.subscriber.name})`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Abstract base for inter-worker and runner-worker communication.
|
|
37
|
+
*
|
|
38
|
+
* Provides pub/sub messaging where each subscriber receives messages
|
|
39
|
+
* independently through its own priority queue. System messages (e.g.
|
|
40
|
+
* cancel) are delivered before normal data messages.
|
|
41
|
+
*
|
|
42
|
+
* Subclasses implement `publish()` for the specific transport. `send()`
|
|
43
|
+
* handles local-only messages automatically. For network buses, override
|
|
44
|
+
* `start()`/`stop()` to manage connections and call `onMessageReceived()`
|
|
45
|
+
* when messages arrive from the network.
|
|
46
|
+
*/
|
|
47
|
+
export class WorkerBus extends BaseObject {
|
|
48
|
+
_subscriptions = new Map();
|
|
49
|
+
_running = false;
|
|
50
|
+
/**
|
|
51
|
+
* Initialize the WorkerBus.
|
|
52
|
+
*
|
|
53
|
+
* @param options Additional arguments passed to `BaseObject`.
|
|
54
|
+
*/
|
|
55
|
+
constructor(options = {}) {
|
|
56
|
+
super(options);
|
|
57
|
+
}
|
|
58
|
+
/** Start dispatch tasks for all registered subscribers. */
|
|
59
|
+
async start() {
|
|
60
|
+
if (this._running) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this._running = true;
|
|
64
|
+
for (const sub of this._subscriptions.values()) {
|
|
65
|
+
this._startDispatchTask(sub);
|
|
66
|
+
}
|
|
67
|
+
// Schedule tasks right away.
|
|
68
|
+
await sleep(0);
|
|
69
|
+
}
|
|
70
|
+
/** Stop all dispatch tasks. */
|
|
71
|
+
async stop() {
|
|
72
|
+
if (!this._running) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
this._running = false;
|
|
76
|
+
for (const sub of this._subscriptions.values()) {
|
|
77
|
+
if (sub.routerTask) {
|
|
78
|
+
await this.cancelTask(sub.routerTask);
|
|
79
|
+
sub.routerTask = null;
|
|
80
|
+
}
|
|
81
|
+
if (sub.dataTask) {
|
|
82
|
+
await this.cancelTask(sub.dataTask);
|
|
83
|
+
sub.dataTask = null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Register a subscriber to receive messages from the bus.
|
|
89
|
+
*
|
|
90
|
+
* Idempotent: re-subscribing an already-registered subscriber is a no-op.
|
|
91
|
+
*
|
|
92
|
+
* @param subscriber The `BusSubscriber` to register.
|
|
93
|
+
*/
|
|
94
|
+
async subscribe(subscriber) {
|
|
95
|
+
if (this._subscriptions.has(subscriber.name)) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const sub = new BusSubscription({ subscriber });
|
|
99
|
+
if (this._running) {
|
|
100
|
+
this._startDispatchTask(sub);
|
|
101
|
+
// Schedule worker right away.
|
|
102
|
+
await sleep(0);
|
|
103
|
+
}
|
|
104
|
+
this._subscriptions.set(subscriber.name, sub);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Remove a subscriber and cancel its dispatch tasks.
|
|
108
|
+
*
|
|
109
|
+
* @param subscriber The `BusSubscriber` to remove.
|
|
110
|
+
*/
|
|
111
|
+
async unsubscribe(subscriber) {
|
|
112
|
+
const sub = this._subscriptions.get(subscriber.name);
|
|
113
|
+
this._subscriptions.delete(subscriber.name);
|
|
114
|
+
if (sub) {
|
|
115
|
+
if (sub.routerTask) {
|
|
116
|
+
await this.cancelTask(sub.routerTask);
|
|
117
|
+
}
|
|
118
|
+
if (sub.dataTask) {
|
|
119
|
+
await this.cancelTask(sub.dataTask);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Send a message through the bus.
|
|
125
|
+
*
|
|
126
|
+
* Local-only messages are delivered directly to subscribers. All other
|
|
127
|
+
* messages are passed to `publish()` for transport.
|
|
128
|
+
*
|
|
129
|
+
* @param message The bus message to send.
|
|
130
|
+
*/
|
|
131
|
+
async send(message) {
|
|
132
|
+
if (message instanceof BusLocalMessage) {
|
|
133
|
+
this.onMessageReceived(message);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
await this.publish(message);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Deliver a message to all local subscribers via their priority queues.
|
|
140
|
+
*
|
|
141
|
+
* Called by bus implementations when a message arrives (either from a local
|
|
142
|
+
* `send()` or from a network transport).
|
|
143
|
+
*/
|
|
144
|
+
onMessageReceived(message) {
|
|
145
|
+
for (const sub of this._subscriptions.values()) {
|
|
146
|
+
sub.queue.putNowait(message);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/** Start the router and data dispatch tasks for a subscriber. */
|
|
150
|
+
_startDispatchTask(sub) {
|
|
151
|
+
sub.routerTask = this.createTask(() => this._routerTask(sub), `bus_router_${sub.subscriber}`);
|
|
152
|
+
sub.dataTask = this.createTask(() => this._dataDispatchTask(sub), `bus_data_${sub.subscriber}`);
|
|
153
|
+
}
|
|
154
|
+
/** Route system messages inline, data messages to the data queue. */
|
|
155
|
+
async _routerTask(sub) {
|
|
156
|
+
while (true) {
|
|
157
|
+
const message = await sub.queue.get();
|
|
158
|
+
if (!sub.subscriber.acceptsBusMessage(message)) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
if (message instanceof BusSystemMessage) {
|
|
162
|
+
// A subscriber exception must not tear down the dispatch task, or the
|
|
163
|
+
// subscriber would silently stop receiving all future messages
|
|
164
|
+
// (including cancel/cleanup). Log and keep going.
|
|
165
|
+
try {
|
|
166
|
+
await sub.subscriber.onBusMessage(message);
|
|
167
|
+
}
|
|
168
|
+
catch (e) {
|
|
169
|
+
rethrowIfCancelled(e);
|
|
170
|
+
logger.exception(`${this}: subscriber '${sub.subscriber.name}' raised handling ` +
|
|
171
|
+
`system message ${message}; keeping dispatch alive`, e);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
sub.dataQueue.putNowait(message);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/** Process data messages sequentially from the data queue. */
|
|
180
|
+
async _dataDispatchTask(sub) {
|
|
181
|
+
while (true) {
|
|
182
|
+
const message = await sub.dataQueue.get();
|
|
183
|
+
if (!sub.subscriber.acceptsBusMessage(message)) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
// A subscriber exception must not tear down the dispatch task, or the
|
|
187
|
+
// subscriber would silently stop receiving all future messages
|
|
188
|
+
// (including cancel/cleanup). Log and keep going.
|
|
189
|
+
try {
|
|
190
|
+
await sub.subscriber.onBusMessage(message);
|
|
191
|
+
}
|
|
192
|
+
catch (e) {
|
|
193
|
+
rethrowIfCancelled(e);
|
|
194
|
+
logger.exception(`${this}: subscriber '${sub.subscriber.name}' raised handling ` +
|
|
195
|
+
`data message ${message}; keeping dispatch alive`, e);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=bus.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker bus package -- pub/sub messaging between workers and the runner.
|
|
3
|
+
*
|
|
4
|
+
* Provides the pub/sub infrastructure that connects workers to each other and
|
|
5
|
+
* to the runner. Key components:
|
|
6
|
+
*
|
|
7
|
+
* - `WorkerBus` -- abstract base class defining the send/receive interface.
|
|
8
|
+
* - `AsyncQueueBus` -- in-process implementation backed by an asyncio `Queue`.
|
|
9
|
+
* - `BusBridgeProcessor` -- bidirectional mid-pipeline bridge for
|
|
10
|
+
* transport/session workers that exchanges frames with other workers
|
|
11
|
+
* through the bus.
|
|
12
|
+
* - `BusMessage` and its subclasses -- the typed message hierarchy used for
|
|
13
|
+
* worker lifecycle events (activation, cancellation, shutdown), job
|
|
14
|
+
* coordination, and frame transport.
|
|
15
|
+
*/
|
|
16
|
+
export { WorkerRegistryEntry } from "../registry/types.ts";
|
|
17
|
+
export { BusBridgeProcessor } from "./bridge_processor.ts";
|
|
18
|
+
export { WorkerBus } from "./bus.ts";
|
|
19
|
+
export { AsyncQueueBus } from "./local/index.ts";
|
|
20
|
+
export { BusActivateWorkerMessage, BusAddWorkerMessage, BusCancelMessage, BusCancelWorkerMessage, BusDataMessage, BusDeactivateWorkerMessage, BusEndMessage, BusEndWorkerMessage, BusFlushProgressMessage, BusFrameMessage, BusJobCancelMessage, BusJobRequestMessage, BusJobResponseMessage, BusJobResponseUrgentMessage, BusJobStreamDataMessage, BusJobStreamEndMessage, BusJobStreamStartMessage, BusJobUpdateMessage, BusJobUpdateRequestMessage, BusJobUpdateUrgentMessage, BusLocalMessage, BusMessage, BusSystemMessage, BusTTSSpeakMessage, BusWorkerErrorMessage, BusWorkerLocalErrorMessage, BusWorkerReadyMessage, BusWorkerRegistryMessage, } from "./messages.ts";
|
|
21
|
+
export { BusSubscriber } from "./subscriber.ts";
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
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/bus/__init__.py
|
|
6
|
+
/**
|
|
7
|
+
* Worker bus package -- pub/sub messaging between workers and the runner.
|
|
8
|
+
*
|
|
9
|
+
* Provides the pub/sub infrastructure that connects workers to each other and
|
|
10
|
+
* to the runner. Key components:
|
|
11
|
+
*
|
|
12
|
+
* - `WorkerBus` -- abstract base class defining the send/receive interface.
|
|
13
|
+
* - `AsyncQueueBus` -- in-process implementation backed by an asyncio `Queue`.
|
|
14
|
+
* - `BusBridgeProcessor` -- bidirectional mid-pipeline bridge for
|
|
15
|
+
* transport/session workers that exchanges frames with other workers
|
|
16
|
+
* through the bus.
|
|
17
|
+
* - `BusMessage` and its subclasses -- the typed message hierarchy used for
|
|
18
|
+
* worker lifecycle events (activation, cancellation, shutdown), job
|
|
19
|
+
* coordination, and frame transport.
|
|
20
|
+
*/
|
|
21
|
+
export { WorkerRegistryEntry } from "../registry/types.js";
|
|
22
|
+
export { BusBridgeProcessor } from "./bridge_processor.js";
|
|
23
|
+
export { WorkerBus } from "./bus.js";
|
|
24
|
+
export { AsyncQueueBus } from "./local/index.js";
|
|
25
|
+
export { BusActivateWorkerMessage, BusAddWorkerMessage, BusCancelMessage, BusCancelWorkerMessage, BusDataMessage, BusDeactivateWorkerMessage, BusEndMessage, BusEndWorkerMessage, BusFlushProgressMessage, BusFrameMessage, BusJobCancelMessage, BusJobRequestMessage, BusJobResponseMessage, BusJobResponseUrgentMessage, BusJobStreamDataMessage, BusJobStreamEndMessage, BusJobStreamStartMessage, BusJobUpdateMessage, BusJobUpdateRequestMessage, BusJobUpdateUrgentMessage, BusLocalMessage, BusMessage, BusSystemMessage, BusTTSSpeakMessage, BusWorkerErrorMessage, BusWorkerLocalErrorMessage, BusWorkerReadyMessage, BusWorkerRegistryMessage, } from "./messages.js";
|
|
26
|
+
export { BusSubscriber } from "./subscriber.js";
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { WorkerBus } from "../bus.ts";
|
|
2
|
+
import type { BusMessage } from "../messages.ts";
|
|
3
|
+
/** In-process bus that delivers messages via priority queues. */
|
|
4
|
+
export declare class AsyncQueueBus extends WorkerBus {
|
|
5
|
+
/**
|
|
6
|
+
* Deliver a message to all local subscriber queues.
|
|
7
|
+
*
|
|
8
|
+
* @param message The bus message to deliver.
|
|
9
|
+
*/
|
|
10
|
+
publish(message: BusMessage): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=async_queue.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
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/bus/local/async_queue.py
|
|
6
|
+
/** In-process worker bus backed by asyncio queues. */
|
|
7
|
+
import { logger } from "../../utils/logger.js";
|
|
8
|
+
import { WorkerBus } from "../bus.js";
|
|
9
|
+
/** In-process bus that delivers messages via priority queues. */
|
|
10
|
+
export class AsyncQueueBus extends WorkerBus {
|
|
11
|
+
/**
|
|
12
|
+
* Deliver a message to all local subscriber queues.
|
|
13
|
+
*
|
|
14
|
+
* @param message The bus message to deliver.
|
|
15
|
+
*/
|
|
16
|
+
async publish(message) {
|
|
17
|
+
logger.trace(`${this}: sending ${message}`);
|
|
18
|
+
this.onMessageReceived(message);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=async_queue.js.map
|