@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,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker observer for managing pipeline frame observers.
|
|
3
|
+
*
|
|
4
|
+
* Provides a proxy observer system that manages multiple observers for
|
|
5
|
+
* pipeline frame events, ensuring that observer processing doesn't block the
|
|
6
|
+
* main pipeline execution.
|
|
7
|
+
*/
|
|
8
|
+
import { Queue, type Task } from "@pipedog/asyncio";
|
|
9
|
+
import type { Frame } from "../frames/frames.ts";
|
|
10
|
+
import { BaseObserver, type BaseObserverOptions, FrameProcessed, FramePushed, ProcessorSetUp } from "../observers/base_observer.ts";
|
|
11
|
+
import type { BaseTaskManager } from "../utils/asyncio/task_manager.ts";
|
|
12
|
+
/**
|
|
13
|
+
* Proxy data for managing observer tasks and queues.
|
|
14
|
+
*
|
|
15
|
+
* This represents the data received from the main observer that is queued
|
|
16
|
+
* for later processing.
|
|
17
|
+
*
|
|
18
|
+
* - `queue`: queue for frame data awaiting observer processing.
|
|
19
|
+
* - `task`: task running the observer's frame processing loop.
|
|
20
|
+
* - `observer`: the actual observer instance being proxied.
|
|
21
|
+
*/
|
|
22
|
+
export declare class Proxy {
|
|
23
|
+
queue: Queue<unknown>;
|
|
24
|
+
task: Task<unknown>;
|
|
25
|
+
observer: BaseObserver;
|
|
26
|
+
constructor(options: {
|
|
27
|
+
queue: Queue<unknown>;
|
|
28
|
+
task: Task<unknown>;
|
|
29
|
+
observer: BaseObserver;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Frames held weakly by id, like Python's `weakref.WeakValueDictionary`: an
|
|
34
|
+
* entry goes away with its frame.
|
|
35
|
+
*/
|
|
36
|
+
declare class WeakFrameMap {
|
|
37
|
+
#private;
|
|
38
|
+
has(id: number): boolean;
|
|
39
|
+
set(id: number, frame: Frame): void;
|
|
40
|
+
/** Number of frames still alive, like `len()` of a `WeakValueDictionary`. */
|
|
41
|
+
get size(): number;
|
|
42
|
+
/** The frames still alive, like `WeakValueDictionary.values()`. */
|
|
43
|
+
values(): IterableIterator<Frame>;
|
|
44
|
+
}
|
|
45
|
+
export interface WorkerObserverOptions extends BaseObserverOptions {
|
|
46
|
+
/** List of observers to manage. Defaults to an empty list. */
|
|
47
|
+
observers?: BaseObserver[] | null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Proxy observer that manages multiple observers without blocking the pipeline.
|
|
51
|
+
*
|
|
52
|
+
* This is a pipeline frame observer that is meant to be used as a proxy to
|
|
53
|
+
* the user provided observers. That is, this is the observer that should be
|
|
54
|
+
* passed to the frame processors. Then, every time a frame is pushed this
|
|
55
|
+
* observer will call all the observers registered to the pipeline worker.
|
|
56
|
+
*
|
|
57
|
+
* This observer makes sure that passing frames to observers doesn't block the
|
|
58
|
+
* pipeline by creating a queue and a worker for each user observer. When a
|
|
59
|
+
* frame is received, it will be put in a queue for efficiency and later
|
|
60
|
+
* processed by each worker.
|
|
61
|
+
*
|
|
62
|
+
* It also tells a frame's first push from the ones that follow, and only
|
|
63
|
+
* passes the first one to observers that want a frame once.
|
|
64
|
+
*
|
|
65
|
+
* Dropped from upstream (deprecated): `on_startup_warmup` / `StartupWarmup`.
|
|
66
|
+
*/
|
|
67
|
+
export declare class WorkerObserver extends BaseObserver {
|
|
68
|
+
protected _observers: BaseObserver[];
|
|
69
|
+
protected _proxies: Map<BaseObserver, Proxy> | null;
|
|
70
|
+
protected _framesPushed: WeakFrameMap;
|
|
71
|
+
constructor(options?: WorkerObserverOptions);
|
|
72
|
+
/**
|
|
73
|
+
* Add a new observer to the managed list.
|
|
74
|
+
*
|
|
75
|
+
* @param observer The observer to add.
|
|
76
|
+
*/
|
|
77
|
+
addObserver(observer: BaseObserver): void;
|
|
78
|
+
/**
|
|
79
|
+
* Remove an observer and clean up its resources.
|
|
80
|
+
*
|
|
81
|
+
* @param observer The observer to remove.
|
|
82
|
+
*/
|
|
83
|
+
removeObserver(observer: BaseObserver): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Set up a proxy for every managed observer.
|
|
86
|
+
*
|
|
87
|
+
* Processors report their own setup to observers, so the proxies are in
|
|
88
|
+
* place before any of them is set up.
|
|
89
|
+
*
|
|
90
|
+
* @param taskManager The task manager the proxies run their tasks on.
|
|
91
|
+
*/
|
|
92
|
+
setup(taskManager: BaseTaskManager | unknown): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Cleanup all proxy observers.
|
|
95
|
+
*
|
|
96
|
+
* Tearing down is best effort: an observer that raises is logged and the
|
|
97
|
+
* rest are still cleaned up.
|
|
98
|
+
*/
|
|
99
|
+
cleanup(): Promise<void>;
|
|
100
|
+
/** Forward pipeline started signal to all managed observers. */
|
|
101
|
+
onPipelineStarted(): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Queue frame data for all managed observers.
|
|
104
|
+
*
|
|
105
|
+
* @param data The frame processing event data to distribute to observers.
|
|
106
|
+
*/
|
|
107
|
+
onProcessFrame(data: FrameProcessed): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Queue frame data for the managed observers.
|
|
110
|
+
*
|
|
111
|
+
* A repeated push only reaches the observers that want every push.
|
|
112
|
+
*
|
|
113
|
+
* @param data The frame push event data to distribute to observers.
|
|
114
|
+
*/
|
|
115
|
+
onPushFrame(data: FramePushed): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* Queue processor setup timing for all managed observers.
|
|
118
|
+
*
|
|
119
|
+
* @param data The processor setup event data to distribute to observers.
|
|
120
|
+
*/
|
|
121
|
+
onProcessorSetup(data: ProcessorSetUp): Promise<void>;
|
|
122
|
+
/** Create a proxy for a single observer. */
|
|
123
|
+
protected _createProxy(observer: BaseObserver): Proxy;
|
|
124
|
+
/** Create proxies for all observers. */
|
|
125
|
+
protected _createProxies(observers: BaseObserver[]): Map<BaseObserver, Proxy>;
|
|
126
|
+
protected _sendToProxy(data: unknown): Promise<void>;
|
|
127
|
+
/** Handle frame processing for a single observer. */
|
|
128
|
+
protected _proxyTaskHandler(queue: Queue<unknown>, observer: BaseObserver): Promise<void>;
|
|
129
|
+
}
|
|
130
|
+
export {};
|
|
131
|
+
//# sourceMappingURL=worker_observer.d.ts.map
|
|
@@ -0,0 +1,274 @@
|
|
|
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/pipeline/worker_observer.py
|
|
6
|
+
/**
|
|
7
|
+
* Worker observer for managing pipeline frame observers.
|
|
8
|
+
*
|
|
9
|
+
* Provides a proxy observer system that manages multiple observers for
|
|
10
|
+
* pipeline frame events, ensuring that observer processing doesn't block the
|
|
11
|
+
* main pipeline execution.
|
|
12
|
+
*/
|
|
13
|
+
import { currentTask, Queue, rethrowIfCancelled } from "@pipedog/asyncio";
|
|
14
|
+
import { BaseObserver, FrameProcessed, FramePushed, ProcessorSetUp, } from "../observers/base_observer.js";
|
|
15
|
+
import { logger } from "../utils/logger.js";
|
|
16
|
+
/**
|
|
17
|
+
* Proxy data for managing observer tasks and queues.
|
|
18
|
+
*
|
|
19
|
+
* This represents the data received from the main observer that is queued
|
|
20
|
+
* for later processing.
|
|
21
|
+
*
|
|
22
|
+
* - `queue`: queue for frame data awaiting observer processing.
|
|
23
|
+
* - `task`: task running the observer's frame processing loop.
|
|
24
|
+
* - `observer`: the actual observer instance being proxied.
|
|
25
|
+
*/
|
|
26
|
+
// biome-ignore lint/suspicious/noShadowRestrictedNames: upstream name (worker_observer.Proxy).
|
|
27
|
+
export class Proxy {
|
|
28
|
+
queue;
|
|
29
|
+
task;
|
|
30
|
+
observer;
|
|
31
|
+
constructor(options) {
|
|
32
|
+
this.queue = options.queue;
|
|
33
|
+
this.task = options.task;
|
|
34
|
+
this.observer = options.observer;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** Internal sentinel queued to observers when the pipeline has started. */
|
|
38
|
+
class _PipelineStartedSignal {
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Frames held weakly by id, like Python's `weakref.WeakValueDictionary`: an
|
|
42
|
+
* entry goes away with its frame.
|
|
43
|
+
*/
|
|
44
|
+
class WeakFrameMap {
|
|
45
|
+
#refs = new Map();
|
|
46
|
+
#registry = new FinalizationRegistry((id) => {
|
|
47
|
+
const ref = this.#refs.get(id);
|
|
48
|
+
if (ref && ref.deref() === undefined)
|
|
49
|
+
this.#refs.delete(id);
|
|
50
|
+
});
|
|
51
|
+
has(id) {
|
|
52
|
+
return this.#refs.get(id)?.deref() !== undefined;
|
|
53
|
+
}
|
|
54
|
+
set(id, frame) {
|
|
55
|
+
this.#refs.set(id, new WeakRef(frame));
|
|
56
|
+
this.#registry.register(frame, id);
|
|
57
|
+
}
|
|
58
|
+
/** Number of frames still alive, like `len()` of a `WeakValueDictionary`. */
|
|
59
|
+
get size() {
|
|
60
|
+
let n = 0;
|
|
61
|
+
for (const ref of this.#refs.values()) {
|
|
62
|
+
if (ref.deref() !== undefined)
|
|
63
|
+
n++;
|
|
64
|
+
}
|
|
65
|
+
return n;
|
|
66
|
+
}
|
|
67
|
+
/** The frames still alive, like `WeakValueDictionary.values()`. */
|
|
68
|
+
*values() {
|
|
69
|
+
for (const ref of this.#refs.values()) {
|
|
70
|
+
const frame = ref.deref();
|
|
71
|
+
if (frame !== undefined)
|
|
72
|
+
yield frame;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Proxy observer that manages multiple observers without blocking the pipeline.
|
|
78
|
+
*
|
|
79
|
+
* This is a pipeline frame observer that is meant to be used as a proxy to
|
|
80
|
+
* the user provided observers. That is, this is the observer that should be
|
|
81
|
+
* passed to the frame processors. Then, every time a frame is pushed this
|
|
82
|
+
* observer will call all the observers registered to the pipeline worker.
|
|
83
|
+
*
|
|
84
|
+
* This observer makes sure that passing frames to observers doesn't block the
|
|
85
|
+
* pipeline by creating a queue and a worker for each user observer. When a
|
|
86
|
+
* frame is received, it will be put in a queue for efficiency and later
|
|
87
|
+
* processed by each worker.
|
|
88
|
+
*
|
|
89
|
+
* It also tells a frame's first push from the ones that follow, and only
|
|
90
|
+
* passes the first one to observers that want a frame once.
|
|
91
|
+
*
|
|
92
|
+
* Dropped from upstream (deprecated): `on_startup_warmup` / `StartupWarmup`.
|
|
93
|
+
*/
|
|
94
|
+
export class WorkerObserver extends BaseObserver {
|
|
95
|
+
_observers;
|
|
96
|
+
// Becomes a map after setup() is called.
|
|
97
|
+
_proxies = null;
|
|
98
|
+
// Frames pushed so far, held weakly: an entry goes away with its frame, so
|
|
99
|
+
// this tracks the frames in flight, not every frame ever pushed.
|
|
100
|
+
_framesPushed = new WeakFrameMap();
|
|
101
|
+
constructor(options = {}) {
|
|
102
|
+
super(options);
|
|
103
|
+
this._observers = options.observers ?? [];
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Add a new observer to the managed list.
|
|
107
|
+
*
|
|
108
|
+
* @param observer The observer to add.
|
|
109
|
+
*/
|
|
110
|
+
addObserver(observer) {
|
|
111
|
+
// Add the observer to the list.
|
|
112
|
+
this._observers.push(observer);
|
|
113
|
+
// After setup(), create the proxy immediately; setup() handles earlier additions.
|
|
114
|
+
if (this._proxies !== null) {
|
|
115
|
+
const proxy = this._createProxy(observer);
|
|
116
|
+
this._proxies.set(observer, proxy);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Remove an observer and clean up its resources.
|
|
121
|
+
*
|
|
122
|
+
* @param observer The observer to remove.
|
|
123
|
+
*/
|
|
124
|
+
async removeObserver(observer) {
|
|
125
|
+
// If the observer has a proxy, remove it.
|
|
126
|
+
if (this._proxies && this._proxies.size > 0 && this._proxies.has(observer)) {
|
|
127
|
+
const proxy = this._proxies.get(observer);
|
|
128
|
+
// Remove the proxy so it doesn't get called anymore.
|
|
129
|
+
this._proxies.delete(observer);
|
|
130
|
+
// Cancel the proxy worker right away. An observer removing itself runs
|
|
131
|
+
// on that worker, which can't be cancelled from inside, so the worker
|
|
132
|
+
// ends itself instead.
|
|
133
|
+
if (proxy.task !== currentTask()) {
|
|
134
|
+
await this.cancelTask(proxy.task);
|
|
135
|
+
}
|
|
136
|
+
// Shutdown only cleans up the observers in _proxies.
|
|
137
|
+
await observer.cleanup();
|
|
138
|
+
}
|
|
139
|
+
// Remove the observer from the list.
|
|
140
|
+
const index = this._observers.indexOf(observer);
|
|
141
|
+
if (index >= 0) {
|
|
142
|
+
this._observers.splice(index, 1);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Set up a proxy for every managed observer.
|
|
147
|
+
*
|
|
148
|
+
* Processors report their own setup to observers, so the proxies are in
|
|
149
|
+
* place before any of them is set up.
|
|
150
|
+
*
|
|
151
|
+
* @param taskManager The task manager the proxies run their tasks on.
|
|
152
|
+
*/
|
|
153
|
+
async setup(taskManager) {
|
|
154
|
+
await super.setup(taskManager);
|
|
155
|
+
this._proxies = this._createProxies(this._observers);
|
|
156
|
+
for (const observer of this._proxies.keys()) {
|
|
157
|
+
await observer.setup(taskManager);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Cleanup all proxy observers.
|
|
162
|
+
*
|
|
163
|
+
* Tearing down is best effort: an observer that raises is logged and the
|
|
164
|
+
* rest are still cleaned up.
|
|
165
|
+
*/
|
|
166
|
+
async cleanup() {
|
|
167
|
+
await super.cleanup();
|
|
168
|
+
if (!this._proxies || this._proxies.size === 0) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
for (const proxy of this._proxies.values()) {
|
|
172
|
+
await this.cancelTask(proxy.task);
|
|
173
|
+
}
|
|
174
|
+
for (const observer of this._proxies.keys()) {
|
|
175
|
+
try {
|
|
176
|
+
await observer.cleanup();
|
|
177
|
+
}
|
|
178
|
+
catch (e) {
|
|
179
|
+
rethrowIfCancelled(e);
|
|
180
|
+
logger.error(`Error cleaning up ${observer}: ${e instanceof Error ? e.message : e}`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/** Forward pipeline started signal to all managed observers. */
|
|
185
|
+
async onPipelineStarted() {
|
|
186
|
+
await this._sendToProxy(new _PipelineStartedSignal());
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Queue frame data for all managed observers.
|
|
190
|
+
*
|
|
191
|
+
* @param data The frame processing event data to distribute to observers.
|
|
192
|
+
*/
|
|
193
|
+
async onProcessFrame(data) {
|
|
194
|
+
await this._sendToProxy(data);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Queue frame data for the managed observers.
|
|
198
|
+
*
|
|
199
|
+
* A repeated push only reaches the observers that want every push.
|
|
200
|
+
*
|
|
201
|
+
* @param data The frame push event data to distribute to observers.
|
|
202
|
+
*/
|
|
203
|
+
async onPushFrame(data) {
|
|
204
|
+
if (!this._proxies || this._proxies.size === 0) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const frame = data.frame;
|
|
208
|
+
data.firstPush = !this._framesPushed.has(frame.id);
|
|
209
|
+
if (data.firstPush) {
|
|
210
|
+
this._framesPushed.set(frame.id, frame);
|
|
211
|
+
}
|
|
212
|
+
for (const proxy of this._proxies.values()) {
|
|
213
|
+
if (data.firstPush || proxy.observer.observeEveryPush) {
|
|
214
|
+
await proxy.queue.put(data);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Queue processor setup timing for all managed observers.
|
|
220
|
+
*
|
|
221
|
+
* @param data The processor setup event data to distribute to observers.
|
|
222
|
+
*/
|
|
223
|
+
async onProcessorSetup(data) {
|
|
224
|
+
await this._sendToProxy(data);
|
|
225
|
+
}
|
|
226
|
+
/** Create a proxy for a single observer. */
|
|
227
|
+
_createProxy(observer) {
|
|
228
|
+
const queue = new Queue();
|
|
229
|
+
const task = this.createTask(() => this._proxyTaskHandler(queue, observer), "_proxyTaskHandler");
|
|
230
|
+
return new Proxy({ queue, task, observer });
|
|
231
|
+
}
|
|
232
|
+
/** Create proxies for all observers. */
|
|
233
|
+
_createProxies(observers) {
|
|
234
|
+
const proxies = new Map();
|
|
235
|
+
for (const observer of observers) {
|
|
236
|
+
const proxy = this._createProxy(observer);
|
|
237
|
+
proxies.set(observer, proxy);
|
|
238
|
+
}
|
|
239
|
+
return proxies;
|
|
240
|
+
}
|
|
241
|
+
async _sendToProxy(data) {
|
|
242
|
+
if (!this._proxies || this._proxies.size === 0) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
for (const proxy of this._proxies.values()) {
|
|
246
|
+
await proxy.queue.put(data);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/** Handle frame processing for a single observer. */
|
|
250
|
+
async _proxyTaskHandler(queue, observer) {
|
|
251
|
+
while (true) {
|
|
252
|
+
const data = await queue.get();
|
|
253
|
+
if (data instanceof _PipelineStartedSignal) {
|
|
254
|
+
await observer.onPipelineStarted();
|
|
255
|
+
}
|
|
256
|
+
else if (data instanceof FramePushed) {
|
|
257
|
+
await observer.onPushFrame(data);
|
|
258
|
+
}
|
|
259
|
+
else if (data instanceof FrameProcessed) {
|
|
260
|
+
await observer.onProcessFrame(data);
|
|
261
|
+
}
|
|
262
|
+
else if (data instanceof ProcessorSetUp) {
|
|
263
|
+
await observer.onProcessorSetup(data);
|
|
264
|
+
}
|
|
265
|
+
queue.taskDone();
|
|
266
|
+
// Stop once the observer has removed itself (see removeObserver()).
|
|
267
|
+
const proxy = this._proxies && this._proxies.size > 0 ? this._proxies.get(observer) : null;
|
|
268
|
+
if (!proxy || proxy.queue !== queue) {
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=worker_observer.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Decorator for marking methods as worker-ready handlers. */
|
|
2
|
+
type AnyFn = (...args: any[]) => any;
|
|
3
|
+
/** A function marked by `workerReady()`. */
|
|
4
|
+
export type WorkerReadyHandler<F extends AnyFn = AnyFn> = F & {
|
|
5
|
+
workerReadyName: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Mark a method as a handler for a specific worker becoming ready.
|
|
9
|
+
*
|
|
10
|
+
* Decorated methods are automatically collected by `BaseWorker` at
|
|
11
|
+
* initialization. When the worker starts, it calls `watchWorkers` for the
|
|
12
|
+
* decorated handlers. When a watched worker registers, the decorated method
|
|
13
|
+
* is called with the ready data.
|
|
14
|
+
*
|
|
15
|
+
* The returned decorator works both as a standard (TC39) method decorator and
|
|
16
|
+
* as a plain function, since runtimes that strip types (Node) do not run
|
|
17
|
+
* decorator syntax.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* class MyWorker extends BaseWorker {
|
|
21
|
+
* async onGreeterReady(data: WorkerReadyData): Promise<void> {
|
|
22
|
+
* await this.activateWorker("greeter", { args: ... });
|
|
23
|
+
* }
|
|
24
|
+
* static {
|
|
25
|
+
* workerReady({ name: "greeter" })(this.prototype.onGreeterReady);
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* @param options.name The name of the worker to watch.
|
|
30
|
+
*/
|
|
31
|
+
export declare function workerReady(options: {
|
|
32
|
+
name: string;
|
|
33
|
+
}): <F extends AnyFn>(fn: F, _context?: unknown) => F;
|
|
34
|
+
/**
|
|
35
|
+
* Collect all `workerReady` decorated bound methods from an object.
|
|
36
|
+
*
|
|
37
|
+
* Walks the prototype chain from the object's own class up, so an override in
|
|
38
|
+
* a subclass shadows the parent's method of the same name.
|
|
39
|
+
*
|
|
40
|
+
* @returns A map from worker name to the bound method.
|
|
41
|
+
* @throws Error If two handlers watch the same worker name.
|
|
42
|
+
*/
|
|
43
|
+
export declare function _collectWorkerReadyHandlers(obj: object): Map<string, AnyFn>;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=worker_ready_decorator.d.ts.map
|
|
@@ -0,0 +1,76 @@
|
|
|
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/pipeline/worker_ready_decorator.py
|
|
6
|
+
/**
|
|
7
|
+
* Mark a method as a handler for a specific worker becoming ready.
|
|
8
|
+
*
|
|
9
|
+
* Decorated methods are automatically collected by `BaseWorker` at
|
|
10
|
+
* initialization. When the worker starts, it calls `watchWorkers` for the
|
|
11
|
+
* decorated handlers. When a watched worker registers, the decorated method
|
|
12
|
+
* is called with the ready data.
|
|
13
|
+
*
|
|
14
|
+
* The returned decorator works both as a standard (TC39) method decorator and
|
|
15
|
+
* as a plain function, since runtimes that strip types (Node) do not run
|
|
16
|
+
* decorator syntax.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* class MyWorker extends BaseWorker {
|
|
20
|
+
* async onGreeterReady(data: WorkerReadyData): Promise<void> {
|
|
21
|
+
* await this.activateWorker("greeter", { args: ... });
|
|
22
|
+
* }
|
|
23
|
+
* static {
|
|
24
|
+
* workerReady({ name: "greeter" })(this.prototype.onGreeterReady);
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* @param options.name The name of the worker to watch.
|
|
29
|
+
*/
|
|
30
|
+
export function workerReady(options) {
|
|
31
|
+
const { name } = options;
|
|
32
|
+
return function decorator(fn, _context) {
|
|
33
|
+
fn.workerReadyName = name;
|
|
34
|
+
return fn;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Collect all `workerReady` decorated bound methods from an object.
|
|
39
|
+
*
|
|
40
|
+
* Walks the prototype chain from the object's own class up, so an override in
|
|
41
|
+
* a subclass shadows the parent's method of the same name.
|
|
42
|
+
*
|
|
43
|
+
* @returns A map from worker name to the bound method.
|
|
44
|
+
* @throws Error If two handlers watch the same worker name.
|
|
45
|
+
*/
|
|
46
|
+
export function _collectWorkerReadyHandlers(obj) {
|
|
47
|
+
const seen = new Set();
|
|
48
|
+
const handlers = new Map();
|
|
49
|
+
const handlerNames = new Map();
|
|
50
|
+
let proto = Object.getPrototypeOf(obj);
|
|
51
|
+
while (proto !== null && proto !== Object.prototype) {
|
|
52
|
+
for (const attrName of Object.getOwnPropertyNames(proto)) {
|
|
53
|
+
if (seen.has(attrName)) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
seen.add(attrName);
|
|
57
|
+
const descriptor = Object.getOwnPropertyDescriptor(proto, attrName);
|
|
58
|
+
// Skip accessors so collecting never runs a getter.
|
|
59
|
+
const val = descriptor && "value" in descriptor ? descriptor.value : undefined;
|
|
60
|
+
if (typeof val === "function" && typeof val.workerReadyName === "string") {
|
|
61
|
+
const workerName = val.workerReadyName;
|
|
62
|
+
if (handlers.has(workerName)) {
|
|
63
|
+
const existing = handlerNames.get(workerName);
|
|
64
|
+
throw new Error(`Duplicate @worker_ready handler for '${workerName}': ` +
|
|
65
|
+
`'${attrName}' conflicts with '${existing}'`);
|
|
66
|
+
}
|
|
67
|
+
const method = obj[attrName];
|
|
68
|
+
handlers.set(workerName, method.bind(obj));
|
|
69
|
+
handlerNames.set(workerName, attrName);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
proto = Object.getPrototypeOf(proto);
|
|
73
|
+
}
|
|
74
|
+
return handlers;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=worker_ready_decorator.js.map
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for the async-tool message protocol used in LLM contexts.
|
|
3
|
+
*
|
|
4
|
+
* When a function is registered with `cancelOnInterruption: false`, the
|
|
5
|
+
* `LLMUserContextAggregator` / `LLMAssistantContextAggregator` pair appends
|
|
6
|
+
* async-tool messages to the conversation context as the underlying task
|
|
7
|
+
* progresses:
|
|
8
|
+
*
|
|
9
|
+
* - A `started` message (`role="tool"`) is appended immediately when the tool
|
|
10
|
+
* starts running.
|
|
11
|
+
* - An `intermediate` message (`role="developer"`) is appended each time an
|
|
12
|
+
* intermediate result is reported via
|
|
13
|
+
* `resultCallback(..., new FunctionCallResultProperties({ isFinal: false }))`.
|
|
14
|
+
* - A `final` message (`role="developer"`) is appended when the task
|
|
15
|
+
* finishes. A task that is cancelled instead of finishing settles the same
|
|
16
|
+
* way, carrying a cancellation notice in place of a result.
|
|
17
|
+
*
|
|
18
|
+
* The `final` message exists so a result that arrives after the LLM has moved
|
|
19
|
+
* on still reaches it. When the result arrives first, before any model
|
|
20
|
+
* response or any new user or assistant message, there is nothing to catch up
|
|
21
|
+
* on: the `started` message is overwritten with the result, as for a
|
|
22
|
+
* synchronous call, and no `final` message is written. A cancellation always
|
|
23
|
+
* gets a `final` message, because it has to tell the LLM the task did not
|
|
24
|
+
* complete.
|
|
25
|
+
*
|
|
26
|
+
* This module is the single source of truth for the on-the-wire payload shape:
|
|
27
|
+
*
|
|
28
|
+
* - The aggregator uses the `build*Message` functions when injecting messages.
|
|
29
|
+
* - Realtime LLM services use `parseMessage` to detect async-tool messages
|
|
30
|
+
* while iterating the context, then read `payload.result` and deliver it via
|
|
31
|
+
* their formal tool-result channel.
|
|
32
|
+
*
|
|
33
|
+
* Internally, `AsyncToolMessagePayload` is the canonical structured form; the
|
|
34
|
+
* on-the-wire JSON string is always derived from it (never stored) so the two
|
|
35
|
+
* representations can't drift.
|
|
36
|
+
*
|
|
37
|
+
* Consumers are expected to import the module rather than its individual
|
|
38
|
+
* functions.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* import * as asyncToolMessages from "@pipedog/core/processors/aggregators/async_tool_messages";
|
|
42
|
+
* asyncToolMessages.buildStartedMessage(toolCallId);
|
|
43
|
+
* asyncToolMessages.parseMessage(msg);
|
|
44
|
+
*/
|
|
45
|
+
import type { LLMStandardMessage } from "./llm_context.ts";
|
|
46
|
+
export type AsyncToolMessageKind = "started" | "intermediate" | "final";
|
|
47
|
+
/**
|
|
48
|
+
* Standing guidance composed into the system instruction whenever an async
|
|
49
|
+
* tool is registered. The per-result message says the same thing, but it
|
|
50
|
+
* arrives buried in a context whose most recent turn may be the user asking
|
|
51
|
+
* for something else; a model weighing the two follows the nearer, louder
|
|
52
|
+
* request. This states the policy before any result exists, so it is in force
|
|
53
|
+
* when one arrives.
|
|
54
|
+
*/
|
|
55
|
+
export declare const ASYNC_TOOL_INSTRUCTIONS: string;
|
|
56
|
+
export interface AsyncToolMessagePayloadOptions {
|
|
57
|
+
kind: AsyncToolMessageKind;
|
|
58
|
+
toolCallId: string;
|
|
59
|
+
status: "running" | "finished";
|
|
60
|
+
description: string;
|
|
61
|
+
result: string | null;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The structured contents of an async-tool message in an LLM context.
|
|
65
|
+
*
|
|
66
|
+
* - `kind`: which of the three async-tool message stages this is.
|
|
67
|
+
* - `toolCallId`: the id of the tool invocation this payload relates to.
|
|
68
|
+
* - `status`: `"running"` for started/intermediate, `"finished"` for the
|
|
69
|
+
* final message.
|
|
70
|
+
* - `description`: human-readable description from the payload. May be empty.
|
|
71
|
+
* - `result`: for `intermediate` and `final` messages, the JSON-encoded result
|
|
72
|
+
* string (or the literal `"COMPLETED"` if the function returned no value).
|
|
73
|
+
* `null` for `started` messages.
|
|
74
|
+
*/
|
|
75
|
+
export declare class AsyncToolMessagePayload {
|
|
76
|
+
readonly kind: AsyncToolMessageKind;
|
|
77
|
+
readonly toolCallId: string;
|
|
78
|
+
readonly status: "running" | "finished";
|
|
79
|
+
readonly description: string;
|
|
80
|
+
readonly result: string | null;
|
|
81
|
+
constructor(options: AsyncToolMessagePayloadOptions);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Build a `started` async-tool message for an LLM context.
|
|
85
|
+
*
|
|
86
|
+
* Append the returned message to the LLM context immediately when an async
|
|
87
|
+
* function call (registered with `cancelOnInterruption: false`) starts
|
|
88
|
+
* running. The message lets the model know a task is in flight and that its
|
|
89
|
+
* results will arrive later in subsequent `developer`-role messages.
|
|
90
|
+
*
|
|
91
|
+
* @param toolCallId The id of the tool invocation this message is for.
|
|
92
|
+
* @returns A message ready to pass to `LLMContext.addMessage`.
|
|
93
|
+
*/
|
|
94
|
+
export declare function buildStartedMessage(toolCallId: string): LLMStandardMessage;
|
|
95
|
+
/**
|
|
96
|
+
* Build an intermediate-result async-tool message for an LLM context.
|
|
97
|
+
*
|
|
98
|
+
* Append the returned message to the LLM context each time the running async
|
|
99
|
+
* function reports a non-final result via
|
|
100
|
+
* `resultCallback(..., new FunctionCallResultProperties({ isFinal: false }))`.
|
|
101
|
+
*
|
|
102
|
+
* @param toolCallId The id of the tool invocation the result is for.
|
|
103
|
+
* @param result The JSON-encoded result string (caller is responsible for
|
|
104
|
+
* encoding the function's actual return value, typically via
|
|
105
|
+
* `JSON.stringify`).
|
|
106
|
+
* @returns A message ready to pass to `LLMContext.addMessage`.
|
|
107
|
+
*/
|
|
108
|
+
export declare function buildIntermediateResultMessage(toolCallId: string, result: string): LLMStandardMessage;
|
|
109
|
+
/**
|
|
110
|
+
* Build a final-result async-tool message for an LLM context.
|
|
111
|
+
*
|
|
112
|
+
* Append the returned message to the LLM context when the async function
|
|
113
|
+
* finishes. After this message no further async-tool messages will arrive for
|
|
114
|
+
* this `tool_call_id`.
|
|
115
|
+
*
|
|
116
|
+
* @param toolCallId The id of the tool invocation the result is for.
|
|
117
|
+
* @param result The JSON-encoded result string, or the literal `"COMPLETED"`
|
|
118
|
+
* sentinel when the function returned nothing (matching the same convention
|
|
119
|
+
* used for synchronous tool calls).
|
|
120
|
+
* @returns A message ready to pass to `LLMContext.addMessage`.
|
|
121
|
+
*/
|
|
122
|
+
export declare function buildFinalResultMessage(toolCallId: string, result: string): LLMStandardMessage;
|
|
123
|
+
/**
|
|
124
|
+
* Build a message settling a cancelled async-tool call in an LLM context.
|
|
125
|
+
*
|
|
126
|
+
* Append the returned message to the LLM context when an async function call
|
|
127
|
+
* is cancelled (by a timeout or at the model's request) instead of running to
|
|
128
|
+
* completion. It settles the `tool_call_id` the same way a final result does,
|
|
129
|
+
* carrying a cancellation notice in place of a result.
|
|
130
|
+
*
|
|
131
|
+
* @param toolCallId The id of the tool invocation that was cancelled.
|
|
132
|
+
* @returns A message ready to pass to `LLMContext.addMessage`.
|
|
133
|
+
*/
|
|
134
|
+
export declare function buildCancelledMessage(toolCallId: string): LLMStandardMessage;
|
|
135
|
+
/**
|
|
136
|
+
* Decode an async-tool message payload, or return null if not async-tool.
|
|
137
|
+
*
|
|
138
|
+
* @param message A standard message from the LLM context. Callers iterating
|
|
139
|
+
* over `LLMContext.getMessages()` should filter out `LLMSpecificMessage`
|
|
140
|
+
* entries first; only `LLMStandardMessage` values can carry async-tool
|
|
141
|
+
* payloads.
|
|
142
|
+
* @returns An `AsyncToolMessagePayload` if the message is a recognized
|
|
143
|
+
* async-tool payload, otherwise `null`.
|
|
144
|
+
*/
|
|
145
|
+
export declare function parseMessage(message: LLMStandardMessage): AsyncToolMessagePayload | null;
|
|
146
|
+
//# sourceMappingURL=async_tool_messages.d.ts.map
|