@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,156 @@
|
|
|
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/utils/text/markup_utils.py
|
|
6
|
+
/**
|
|
7
|
+
* Shared XML/SSML markup utilities for text matching and cursor advancement.
|
|
8
|
+
*
|
|
9
|
+
* Two notions of "what is markup" live here, and they differ on a single point
|
|
10
|
+
* -- a `'<'` with no later `'>'`:
|
|
11
|
+
*
|
|
12
|
+
* - `stripMarkup` treats it as an open tag and swallows the rest of the
|
|
13
|
+
* string. Correct for a *fragment* that may have been cut mid-tag, such as a
|
|
14
|
+
* single token from a TTS word-timestamp stream.
|
|
15
|
+
* - `stripCompleteMarkup` treats it as content. Correct for a *complete*
|
|
16
|
+
* text, where a lone `'<'` is real (`"5 < 10"`, `"<3"`).
|
|
17
|
+
*
|
|
18
|
+
* Every markup decision in the word-timestamp path routes through one of the
|
|
19
|
+
* two, so the callers can't disagree about which characters are a tag.
|
|
20
|
+
*
|
|
21
|
+
* Positions are UTF-16 code unit offsets, as everywhere in JavaScript.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Yield `[rawIndex, char]` for each character of `text` outside markup.
|
|
25
|
+
*
|
|
26
|
+
* The fragment-tolerant definition of markup -- anything between '<' and '>',
|
|
27
|
+
* syntax-based and tag-name independent -- shared by `stripMarkup` and
|
|
28
|
+
* `rawOffsetAfterCleanChars` so the two can't disagree. An unclosed '<'
|
|
29
|
+
* swallows the rest of the string.
|
|
30
|
+
*/
|
|
31
|
+
function* iterCleanChars(text) {
|
|
32
|
+
let inTag = false;
|
|
33
|
+
for (let i = 0; i < text.length; i++) {
|
|
34
|
+
const ch = text[i];
|
|
35
|
+
if (inTag) {
|
|
36
|
+
if (ch === ">") {
|
|
37
|
+
inTag = false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else if (ch === "<") {
|
|
41
|
+
inTag = true;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
yield [i, ch];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Remove XML/SSML-like markup from a possibly-truncated text fragment.
|
|
50
|
+
*
|
|
51
|
+
* Syntax-based, not tag-name based: treats anything between '<' and '>' as
|
|
52
|
+
* markup and preserves text outside it. An unclosed '<' swallows the rest of
|
|
53
|
+
* `text`, matching how a raw word-timestamp token can arrive mid-tag.
|
|
54
|
+
*
|
|
55
|
+
* For a *complete* text, use `stripCompleteMarkup` instead.
|
|
56
|
+
*
|
|
57
|
+
* Used by `TextSegmentMap` to match a word against a segment, where the
|
|
58
|
+
* incoming word may be a fragment of a still-open tag.
|
|
59
|
+
*/
|
|
60
|
+
export function stripMarkup(text) {
|
|
61
|
+
let out = "";
|
|
62
|
+
for (const [, ch] of iterCleanChars(text))
|
|
63
|
+
out += ch;
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Matched '<...>' pairs in a complete text.
|
|
68
|
+
*
|
|
69
|
+
* The definition of markup for a static text, shared by `stripCompleteMarkup`
|
|
70
|
+
* and `splitMarkupRuns` so the two can't disagree about which characters a
|
|
71
|
+
* segment split may treat as a tag.
|
|
72
|
+
*/
|
|
73
|
+
const COMPLETE_MARKUP_RE = /<[^>]+>/g;
|
|
74
|
+
/**
|
|
75
|
+
* Remove well-formed '<...>' markup from a complete, static text.
|
|
76
|
+
*
|
|
77
|
+
* Unlike `stripMarkup`, only strips matched '<...>' pairs -- a lone '<' with
|
|
78
|
+
* no later '>' is left in place as real content rather than swallowing the
|
|
79
|
+
* rest of `text`, since there is no streamed fragment here that could be
|
|
80
|
+
* mid-tag.
|
|
81
|
+
*
|
|
82
|
+
* Used by `TextSegment.isTransformed`, by `alnumOnly`, and by
|
|
83
|
+
* `WordCompletionTracker` to default `userFacingText` to a tag-free string.
|
|
84
|
+
*/
|
|
85
|
+
export function stripCompleteMarkup(text) {
|
|
86
|
+
return text.replace(COMPLETE_MARKUP_RE, "");
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Return the raw offset into `text` just past its `n`-th markup-stripped char.
|
|
90
|
+
*
|
|
91
|
+
* Inverse of `stripMarkup` for a prefix: where `stripMarkup` collects every
|
|
92
|
+
* non-markup char, this finds the raw index one past the `n`-th of them --
|
|
93
|
+
* converting a match measured in markup-stripped space back to a raw offset.
|
|
94
|
+
* Returns `text.length` when `text` has fewer than `n` non-markup chars.
|
|
95
|
+
*/
|
|
96
|
+
export function rawOffsetAfterCleanChars(text, n) {
|
|
97
|
+
if (n <= 0) {
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
let seen = 0;
|
|
101
|
+
for (const [i] of iterCleanChars(text)) {
|
|
102
|
+
seen += 1;
|
|
103
|
+
if (seen === n) {
|
|
104
|
+
return i + 1;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return text.length;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Split `text` into alternating runs of tagged and untagged words.
|
|
111
|
+
*
|
|
112
|
+
* A word is considered tagged if it overlaps a complete `'<...>'` pair. A lone
|
|
113
|
+
* `'<'` is treated as content, not as the start of a tag (see
|
|
114
|
+
* `stripCompleteMarkup`). Consecutive words with the same classification form
|
|
115
|
+
* a single run, so whitespace inside a tag such as `<phoneme alphabet="ipa">`
|
|
116
|
+
* never splits the words it spans across runs.
|
|
117
|
+
*
|
|
118
|
+
* Text with no markup yields a single run, unchanged.
|
|
119
|
+
*
|
|
120
|
+
* Used by `TextSegmentMap` when it builds its segments, to give a tag one of
|
|
121
|
+
* its own.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* splitMarkupRuns("I love to count <spell>1234</spell>.");
|
|
125
|
+
* // -> ["I love to count ", "<spell>1234</spell>."]
|
|
126
|
+
*/
|
|
127
|
+
export function splitMarkupRuns(text) {
|
|
128
|
+
const tagSpans = [];
|
|
129
|
+
for (const m of text.matchAll(COMPLETE_MARKUP_RE)) {
|
|
130
|
+
tagSpans.push([m.index, m.index + m[0].length]);
|
|
131
|
+
}
|
|
132
|
+
if (tagSpans.length === 0) {
|
|
133
|
+
return text ? [text] : [];
|
|
134
|
+
}
|
|
135
|
+
const runs = [];
|
|
136
|
+
let runIsTagged = null;
|
|
137
|
+
let pos = 0;
|
|
138
|
+
for (const token of text.split(/(\s+)/)) {
|
|
139
|
+
if (!token) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
const start = pos;
|
|
143
|
+
const end = pos + token.length;
|
|
144
|
+
pos = end;
|
|
145
|
+
const isTagged = tagSpans.some(([tagStart, tagEnd]) => tagStart < end && start < tagEnd);
|
|
146
|
+
if (isTagged === runIsTagged) {
|
|
147
|
+
runs[runs.length - 1] += token;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
runs.push(token);
|
|
151
|
+
runIsTagged = isTagged;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return runs;
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=markup_utils.js.map
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { Aggregation } from "./base_text_aggregator.ts";
|
|
2
|
+
import { SimpleTextAggregator, type SimpleTextAggregatorOptions } from "./simple_text_aggregator.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Actions to take when a pattern pair is matched.
|
|
5
|
+
*
|
|
6
|
+
* - `REMOVE`: The text along with its delimiters will be removed from the streaming text.
|
|
7
|
+
* Sentence aggregation will continue on as if this text did not exist.
|
|
8
|
+
* - `KEEP`: The delimiters will be removed, but the content between them will be kept.
|
|
9
|
+
* Sentence aggregation will continue on with the internal text included.
|
|
10
|
+
* - `AGGREGATE`: The delimiters will be removed and the content between will be treated
|
|
11
|
+
* as a separate aggregation. Any text before the start of the pattern will be
|
|
12
|
+
* returned early, whether or not a complete sentence was found. Then the pattern
|
|
13
|
+
* will be returned. Then the aggregation will continue on sentence matching after
|
|
14
|
+
* the closing delimiter is found. The content between the delimiters is not
|
|
15
|
+
* aggregated by sentence. It is aggregated as one single block of text.
|
|
16
|
+
*/
|
|
17
|
+
export declare const MatchAction: {
|
|
18
|
+
readonly REMOVE: "remove";
|
|
19
|
+
readonly KEEP: "keep";
|
|
20
|
+
readonly AGGREGATE: "aggregate";
|
|
21
|
+
};
|
|
22
|
+
export type MatchAction = (typeof MatchAction)[keyof typeof MatchAction];
|
|
23
|
+
export interface PatternMatchOptions {
|
|
24
|
+
/** The text content between the start and end patterns. */
|
|
25
|
+
content: string;
|
|
26
|
+
/**
|
|
27
|
+
* The type of the matched pattern pair. It should be representative of the
|
|
28
|
+
* content type (e.g., 'sentence', 'code', 'speaker', 'custom').
|
|
29
|
+
*/
|
|
30
|
+
type: string;
|
|
31
|
+
/** The complete text including start and end patterns. */
|
|
32
|
+
fullMatch: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Represents a matched pattern pair with its content.
|
|
36
|
+
*
|
|
37
|
+
* A PatternMatch object is created when a complete pattern pair is found
|
|
38
|
+
* in the text. It contains information about which pattern was matched,
|
|
39
|
+
* the full matched text (including start and end patterns), and the
|
|
40
|
+
* content between the patterns.
|
|
41
|
+
*/
|
|
42
|
+
export declare class PatternMatch extends Aggregation {
|
|
43
|
+
fullMatch: string;
|
|
44
|
+
/** Initialize a pattern match. */
|
|
45
|
+
constructor(options: PatternMatchOptions);
|
|
46
|
+
/**
|
|
47
|
+
* Return a string representation of the pattern match.
|
|
48
|
+
*
|
|
49
|
+
* @returns A descriptive string showing the pattern type and content.
|
|
50
|
+
*/
|
|
51
|
+
toString(): string;
|
|
52
|
+
}
|
|
53
|
+
/** A registered pattern pair. */
|
|
54
|
+
interface PatternInfo {
|
|
55
|
+
start: string;
|
|
56
|
+
end: string;
|
|
57
|
+
type: string;
|
|
58
|
+
action: MatchAction;
|
|
59
|
+
}
|
|
60
|
+
/** Handler called when a pattern pair is matched. */
|
|
61
|
+
export type PatternMatchHandler = (match: PatternMatch) => Promise<void> | void;
|
|
62
|
+
export interface PatternPairAggregatorOptions extends SimpleTextAggregatorOptions {
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Aggregator that identifies and processes content between pattern pairs.
|
|
66
|
+
*
|
|
67
|
+
* This aggregator buffers text until it can identify complete pattern pairs
|
|
68
|
+
* (defined by start and end patterns), processes the content between these
|
|
69
|
+
* patterns using registered handlers. By default, its aggregation method
|
|
70
|
+
* returns text at sentence boundaries, and remove the content found between
|
|
71
|
+
* any matched patterns. However, matched patterns can also be configured to
|
|
72
|
+
* returned as a separate aggregation object containing the content between
|
|
73
|
+
* their start and end patterns or left in, so that only the delimiters are
|
|
74
|
+
* removed and a callback can be triggered.
|
|
75
|
+
*
|
|
76
|
+
* This aggregator is particularly useful for processing structured content in
|
|
77
|
+
* streaming text, such as XML tags, markdown formatting, or custom delimiters.
|
|
78
|
+
*
|
|
79
|
+
* The aggregator ensures that patterns spanning multiple text chunks are
|
|
80
|
+
* correctly identified.
|
|
81
|
+
*/
|
|
82
|
+
export declare class PatternPairAggregator extends SimpleTextAggregator {
|
|
83
|
+
protected _patterns: Map<string, PatternInfo>;
|
|
84
|
+
protected _handlers: Map<string, PatternMatchHandler>;
|
|
85
|
+
protected _lastProcessedPosition: number;
|
|
86
|
+
/**
|
|
87
|
+
* Initialize the pattern pair aggregator.
|
|
88
|
+
*
|
|
89
|
+
* Creates an empty aggregator with no patterns or handlers registered.
|
|
90
|
+
* Text buffering and pattern detection will begin when text is aggregated.
|
|
91
|
+
*
|
|
92
|
+
* @param options Additional arguments passed to SimpleTextAggregator (e.g. aggregationType).
|
|
93
|
+
*/
|
|
94
|
+
constructor(options?: PatternPairAggregatorOptions);
|
|
95
|
+
/**
|
|
96
|
+
* Get the currently aggregated text.
|
|
97
|
+
*
|
|
98
|
+
* @returns The text that has been accumulated in the buffer.
|
|
99
|
+
*/
|
|
100
|
+
get text(): Aggregation;
|
|
101
|
+
/**
|
|
102
|
+
* Add a pattern pair to detect in the text.
|
|
103
|
+
*
|
|
104
|
+
* Registers a new pattern pair with a unique identifier. The aggregator
|
|
105
|
+
* will look for text that starts with the start pattern and ends with
|
|
106
|
+
* the end pattern, and treat the content between them as a match.
|
|
107
|
+
*
|
|
108
|
+
* @param type Identifier for this pattern pair. Should be unique and ideally descriptive.
|
|
109
|
+
* (e.g., 'code', 'speaker', 'custom'). type can not be 'sentence' or 'word' as
|
|
110
|
+
* those are reserved for the default behavior.
|
|
111
|
+
* @param startPattern Pattern that marks the beginning of content.
|
|
112
|
+
* @param endPattern Pattern that marks the end of content.
|
|
113
|
+
* @param action What to do when a complete pattern is matched.
|
|
114
|
+
*
|
|
115
|
+
* - `MatchAction.REMOVE`: Remove the matched pattern from the text.
|
|
116
|
+
* - `MatchAction.KEEP`: Keep the matched pattern in the text and treat it as
|
|
117
|
+
* normal text. This allows you to register handlers for the pattern without
|
|
118
|
+
* affecting the aggregation logic.
|
|
119
|
+
* - `MatchAction.AGGREGATE`: Return the matched pattern as a separate aggregation object.
|
|
120
|
+
* @returns Self for method chaining.
|
|
121
|
+
* @throws Error If `type` is reserved (upstream: ValueError).
|
|
122
|
+
*/
|
|
123
|
+
addPattern(type: string, startPattern: string, endPattern: string, action?: MatchAction): this;
|
|
124
|
+
/**
|
|
125
|
+
* Register a handler for when a pattern pair is matched.
|
|
126
|
+
*
|
|
127
|
+
* The handler will be called whenever a complete match for the
|
|
128
|
+
* specified type is found in the text.
|
|
129
|
+
*
|
|
130
|
+
* @param type The type of the pattern pair to trigger the handler.
|
|
131
|
+
* @param handler Async function to call when pattern is matched.
|
|
132
|
+
* The function should accept a PatternMatch object.
|
|
133
|
+
* @returns Self for method chaining.
|
|
134
|
+
*/
|
|
135
|
+
onPatternMatch(type: string, handler: PatternMatchHandler): this;
|
|
136
|
+
/**
|
|
137
|
+
* Process newly complete pattern pairs in the text.
|
|
138
|
+
*
|
|
139
|
+
* Searches for pattern pairs that have been completed since lastProcessedPosition,
|
|
140
|
+
* calls the appropriate handlers, and optionally removes the matches.
|
|
141
|
+
*
|
|
142
|
+
* @param text The text to process for pattern matches.
|
|
143
|
+
* @param lastProcessedPosition The position in text that was already processed.
|
|
144
|
+
* Only patterns that end at or after this position will be processed.
|
|
145
|
+
* @returns Tuple of [allMatches, processedText] where:
|
|
146
|
+
*
|
|
147
|
+
* - allMatches is a list of all pattern matches found. Note: There really should only ever be 1.
|
|
148
|
+
* - processedText is the text after processing patterns. If no patterns are
|
|
149
|
+
* found, it will be the same as input text.
|
|
150
|
+
*/
|
|
151
|
+
protected _processCompletePatterns(text: string, lastProcessedPosition?: number): Promise<[PatternMatch[], string]>;
|
|
152
|
+
/**
|
|
153
|
+
* Check if text contains incomplete pattern pairs.
|
|
154
|
+
*
|
|
155
|
+
* Determines whether the text contains any start patterns without
|
|
156
|
+
* matching end patterns, which would indicate incomplete content.
|
|
157
|
+
*
|
|
158
|
+
* @param text The text to check for incomplete patterns.
|
|
159
|
+
* @returns A tuple of [startIndex, patternInfo] if an incomplete pattern is found,
|
|
160
|
+
* or null if no patterns are found or all patterns are complete.
|
|
161
|
+
*/
|
|
162
|
+
protected _matchStartOfPattern(text: string): [number, PatternInfo] | null;
|
|
163
|
+
/**
|
|
164
|
+
* Aggregate text and process pattern pairs.
|
|
165
|
+
*
|
|
166
|
+
* Processes the input text character-by-character, handles pattern pairs,
|
|
167
|
+
* and uses the parent's lookahead logic for sentence detection when no
|
|
168
|
+
* patterns are active.
|
|
169
|
+
*
|
|
170
|
+
* In TOKEN mode, pattern detection still works but non-pattern text is
|
|
171
|
+
* yielded as TOKEN aggregations instead of waiting for sentence boundaries.
|
|
172
|
+
* Text ending in a partial start delimiter (e.g. `<thin` of `<think>`) is
|
|
173
|
+
* held back until a later chunk determines whether it begins a pattern, so
|
|
174
|
+
* a delimiter split across chunks is still recognized.
|
|
175
|
+
*
|
|
176
|
+
* @param text Text to aggregate.
|
|
177
|
+
* @returns PatternMatch objects as patterns complete or sentences are detected.
|
|
178
|
+
*/
|
|
179
|
+
aggregate(text: string): AsyncGenerator<PatternMatch>;
|
|
180
|
+
/**
|
|
181
|
+
* Flush any remaining text in the buffer.
|
|
182
|
+
*
|
|
183
|
+
* Degrades incomplete pattern state the same way a closed pair's
|
|
184
|
+
* action would, without knowing whether the pair would ever have
|
|
185
|
+
* closed:
|
|
186
|
+
*
|
|
187
|
+
* - REMOVE and AGGREGATE: an unclosed start delimiter and everything
|
|
188
|
+
* from it onward is dropped (their content is either stripped or
|
|
189
|
+
* treated as a side channel once closed, so it's never spoken
|
|
190
|
+
* incomplete). The pattern handler is not invoked. Text before the
|
|
191
|
+
* earliest such unclosed start delimiter is kept.
|
|
192
|
+
* - KEEP: a closed KEEP pair is spoken verbatim, delimiters included
|
|
193
|
+
* (see `aggregate`), so an unclosed one degrades to the same
|
|
194
|
+
* thing rather than being dropped.
|
|
195
|
+
*
|
|
196
|
+
* If the buffer ends with a proper prefix of a REMOVE/AGGREGATE start
|
|
197
|
+
* delimiter (the stream cut off mid-delimiter), that trailing partial
|
|
198
|
+
* text is trimmed too. This accepts an inherent ambiguity: a legitimate
|
|
199
|
+
* trailing character sequence that happens to match a delimiter prefix
|
|
200
|
+
* (e.g. a stray `<`) is trimmed the same way.
|
|
201
|
+
*
|
|
202
|
+
* @returns Any remaining text with incomplete REMOVE/AGGREGATE pattern
|
|
203
|
+
* content dropped, or null if there is nothing left to return.
|
|
204
|
+
*/
|
|
205
|
+
flush(): Promise<Aggregation | null>;
|
|
206
|
+
/**
|
|
207
|
+
* Find the earliest unmatched start delimiter that flush() should cut at.
|
|
208
|
+
*
|
|
209
|
+
* For each registered pattern, replicates the same left-to-right,
|
|
210
|
+
* non-overlapping pairing that `_processCompletePatterns` uses
|
|
211
|
+
* (earliest start paired with earliest following end) to determine
|
|
212
|
+
* which start-delimiter occurrences are still unmatched. Only
|
|
213
|
+
* REMOVE/AGGREGATE patterns' unmatched starts are candidates: KEEP
|
|
214
|
+
* patterns are excluded because unclosed KEEP content is kept, not cut.
|
|
215
|
+
*
|
|
216
|
+
* @param text The buffered text to scan.
|
|
217
|
+
* @returns The index of the earliest droppable unmatched start delimiter,
|
|
218
|
+
* or null if there isn't one.
|
|
219
|
+
*/
|
|
220
|
+
protected _findEarliestDroppableStart(text: string): number | null;
|
|
221
|
+
/**
|
|
222
|
+
* Trim a trailing partial REMOVE/AGGREGATE start delimiter, if any.
|
|
223
|
+
*
|
|
224
|
+
* The stream can end mid-delimiter (e.g. buffered text ending in
|
|
225
|
+
* `<te` of `<test>`). That partial text isn't a complete start
|
|
226
|
+
* delimiter, so `_findEarliestDroppableStart` won't catch it,
|
|
227
|
+
* but it also isn't safe to speak. KEEP patterns are excluded since a
|
|
228
|
+
* KEEP delimiter is kept whether or not it's complete.
|
|
229
|
+
*
|
|
230
|
+
* @param text The text to check for a trailing partial delimiter.
|
|
231
|
+
* @returns The text with a trailing partial start delimiter removed, or the
|
|
232
|
+
* original text if there isn't one.
|
|
233
|
+
*/
|
|
234
|
+
protected _trimTrailingPartialStart(text: string): string;
|
|
235
|
+
/**
|
|
236
|
+
* Handle interruptions by clearing the buffer and pattern state.
|
|
237
|
+
*
|
|
238
|
+
* Called when an interruption occurs in the processing pipeline,
|
|
239
|
+
* to reset the state and discard any partially aggregated text.
|
|
240
|
+
*/
|
|
241
|
+
handleInterruption(): Promise<void>;
|
|
242
|
+
/**
|
|
243
|
+
* Clear the internally aggregated text.
|
|
244
|
+
*
|
|
245
|
+
* Resets the aggregator to its initial state, discarding any
|
|
246
|
+
* buffered text and clearing pattern tracking state.
|
|
247
|
+
*/
|
|
248
|
+
reset(): Promise<void>;
|
|
249
|
+
}
|
|
250
|
+
export {};
|
|
251
|
+
//# sourceMappingURL=pattern_pair_aggregator.d.ts.map
|