@livekit/agents 0.0.0-20260120144724
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 +201 -0
- package/README.md +17 -0
- package/dist/_exceptions.cjs +109 -0
- package/dist/_exceptions.cjs.map +1 -0
- package/dist/_exceptions.d.cts +64 -0
- package/dist/_exceptions.d.ts +64 -0
- package/dist/_exceptions.d.ts.map +1 -0
- package/dist/_exceptions.js +80 -0
- package/dist/_exceptions.js.map +1 -0
- package/dist/audio.cjs +170 -0
- package/dist/audio.cjs.map +1 -0
- package/dist/audio.d.cts +46 -0
- package/dist/audio.d.ts +46 -0
- package/dist/audio.d.ts.map +1 -0
- package/dist/audio.js +133 -0
- package/dist/audio.js.map +1 -0
- package/dist/cli.cjs +171 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +14 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +145 -0
- package/dist/cli.js.map +1 -0
- package/dist/connection_pool.cjs +242 -0
- package/dist/connection_pool.cjs.map +1 -0
- package/dist/connection_pool.d.cts +123 -0
- package/dist/connection_pool.d.ts +123 -0
- package/dist/connection_pool.d.ts.map +1 -0
- package/dist/connection_pool.js +218 -0
- package/dist/connection_pool.js.map +1 -0
- package/dist/connection_pool.test.cjs +256 -0
- package/dist/connection_pool.test.cjs.map +1 -0
- package/dist/connection_pool.test.js +255 -0
- package/dist/connection_pool.test.js.map +1 -0
- package/dist/constants.cjs +44 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +7 -0
- package/dist/constants.d.ts +7 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +15 -0
- package/dist/constants.js.map +1 -0
- package/dist/generator.cjs +36 -0
- package/dist/generator.cjs.map +1 -0
- package/dist/generator.d.cts +23 -0
- package/dist/generator.d.ts +23 -0
- package/dist/generator.d.ts.map +1 -0
- package/dist/generator.js +11 -0
- package/dist/generator.js.map +1 -0
- package/dist/http_server.cjs +75 -0
- package/dist/http_server.cjs.map +1 -0
- package/dist/http_server.d.cts +20 -0
- package/dist/http_server.d.ts +20 -0
- package/dist/http_server.d.ts.map +1 -0
- package/dist/http_server.js +51 -0
- package/dist/http_server.js.map +1 -0
- package/dist/index.cjs +100 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +35 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/inference/api_protos.cjs +104 -0
- package/dist/inference/api_protos.cjs.map +1 -0
- package/dist/inference/api_protos.d.cts +222 -0
- package/dist/inference/api_protos.d.ts +222 -0
- package/dist/inference/api_protos.d.ts.map +1 -0
- package/dist/inference/api_protos.js +70 -0
- package/dist/inference/api_protos.js.map +1 -0
- package/dist/inference/index.cjs +56 -0
- package/dist/inference/index.cjs.map +1 -0
- package/dist/inference/index.d.cts +8 -0
- package/dist/inference/index.d.ts +8 -0
- package/dist/inference/index.d.ts.map +1 -0
- package/dist/inference/index.js +23 -0
- package/dist/inference/index.js.map +1 -0
- package/dist/inference/interruption/AdaptiveInterruptionDetector.cjs +152 -0
- package/dist/inference/interruption/AdaptiveInterruptionDetector.cjs.map +1 -0
- package/dist/inference/interruption/AdaptiveInterruptionDetector.d.cts +50 -0
- package/dist/inference/interruption/AdaptiveInterruptionDetector.d.ts +50 -0
- package/dist/inference/interruption/AdaptiveInterruptionDetector.d.ts.map +1 -0
- package/dist/inference/interruption/AdaptiveInterruptionDetector.js +125 -0
- package/dist/inference/interruption/AdaptiveInterruptionDetector.js.map +1 -0
- package/dist/inference/interruption/InterruptionStream.cjs +310 -0
- package/dist/inference/interruption/InterruptionStream.cjs.map +1 -0
- package/dist/inference/interruption/InterruptionStream.d.cts +57 -0
- package/dist/inference/interruption/InterruptionStream.d.ts +57 -0
- package/dist/inference/interruption/InterruptionStream.d.ts.map +1 -0
- package/dist/inference/interruption/InterruptionStream.js +288 -0
- package/dist/inference/interruption/InterruptionStream.js.map +1 -0
- package/dist/inference/interruption/defaults.cjs +76 -0
- package/dist/inference/interruption/defaults.cjs.map +1 -0
- package/dist/inference/interruption/defaults.d.cts +14 -0
- package/dist/inference/interruption/defaults.d.ts +14 -0
- package/dist/inference/interruption/defaults.d.ts.map +1 -0
- package/dist/inference/interruption/defaults.js +42 -0
- package/dist/inference/interruption/defaults.js.map +1 -0
- package/dist/inference/interruption/errors.cjs +2 -0
- package/dist/inference/interruption/errors.cjs.map +1 -0
- package/dist/inference/interruption/errors.d.cts +2 -0
- package/dist/inference/interruption/errors.d.ts +2 -0
- package/dist/inference/interruption/errors.d.ts.map +1 -0
- package/dist/inference/interruption/errors.js +1 -0
- package/dist/inference/interruption/errors.js.map +1 -0
- package/dist/inference/interruption/http_transport.cjs +57 -0
- package/dist/inference/interruption/http_transport.cjs.map +1 -0
- package/dist/inference/interruption/http_transport.d.cts +23 -0
- package/dist/inference/interruption/http_transport.d.ts +23 -0
- package/dist/inference/interruption/http_transport.d.ts.map +1 -0
- package/dist/inference/interruption/http_transport.js +33 -0
- package/dist/inference/interruption/http_transport.js.map +1 -0
- package/dist/inference/interruption/index.cjs +34 -0
- package/dist/inference/interruption/index.cjs.map +1 -0
- package/dist/inference/interruption/index.d.cts +5 -0
- package/dist/inference/interruption/index.d.ts +5 -0
- package/dist/inference/interruption/index.d.ts.map +1 -0
- package/dist/inference/interruption/index.js +7 -0
- package/dist/inference/interruption/index.js.map +1 -0
- package/dist/inference/interruption/interruption.cjs +85 -0
- package/dist/inference/interruption/interruption.cjs.map +1 -0
- package/dist/inference/interruption/interruption.d.cts +48 -0
- package/dist/inference/interruption/interruption.d.ts +48 -0
- package/dist/inference/interruption/interruption.d.ts.map +1 -0
- package/dist/inference/interruption/interruption.js +59 -0
- package/dist/inference/interruption/interruption.js.map +1 -0
- package/dist/inference/llm.cjs +347 -0
- package/dist/inference/llm.cjs.map +1 -0
- package/dist/inference/llm.d.cts +114 -0
- package/dist/inference/llm.d.ts +114 -0
- package/dist/inference/llm.d.ts.map +1 -0
- package/dist/inference/llm.js +318 -0
- package/dist/inference/llm.js.map +1 -0
- package/dist/inference/stt.cjs +371 -0
- package/dist/inference/stt.cjs.map +1 -0
- package/dist/inference/stt.d.cts +91 -0
- package/dist/inference/stt.d.ts +91 -0
- package/dist/inference/stt.d.ts.map +1 -0
- package/dist/inference/stt.js +350 -0
- package/dist/inference/stt.js.map +1 -0
- package/dist/inference/tts.cjs +439 -0
- package/dist/inference/tts.cjs.map +1 -0
- package/dist/inference/tts.d.cts +80 -0
- package/dist/inference/tts.d.ts +80 -0
- package/dist/inference/tts.d.ts.map +1 -0
- package/dist/inference/tts.js +417 -0
- package/dist/inference/tts.js.map +1 -0
- package/dist/inference/utils.cjs +89 -0
- package/dist/inference/utils.cjs.map +1 -0
- package/dist/inference/utils.d.cts +6 -0
- package/dist/inference/utils.d.ts +6 -0
- package/dist/inference/utils.d.ts.map +1 -0
- package/dist/inference/utils.js +63 -0
- package/dist/inference/utils.js.map +1 -0
- package/dist/inference/utils.test.cjs +20 -0
- package/dist/inference/utils.test.cjs.map +1 -0
- package/dist/inference/utils.test.js +19 -0
- package/dist/inference/utils.test.js.map +1 -0
- package/dist/inference_runner.cjs +37 -0
- package/dist/inference_runner.cjs.map +1 -0
- package/dist/inference_runner.d.cts +11 -0
- package/dist/inference_runner.d.ts +11 -0
- package/dist/inference_runner.d.ts.map +1 -0
- package/dist/inference_runner.js +13 -0
- package/dist/inference_runner.js.map +1 -0
- package/dist/ipc/index.cjs +23 -0
- package/dist/ipc/index.cjs.map +1 -0
- package/dist/ipc/index.d.cts +2 -0
- package/dist/ipc/index.d.ts +2 -0
- package/dist/ipc/index.d.ts.map +1 -0
- package/dist/ipc/index.js +2 -0
- package/dist/ipc/index.js.map +1 -0
- package/dist/ipc/inference_executor.cjs +17 -0
- package/dist/ipc/inference_executor.cjs.map +1 -0
- package/dist/ipc/inference_executor.d.cts +4 -0
- package/dist/ipc/inference_executor.d.ts +4 -0
- package/dist/ipc/inference_executor.d.ts.map +1 -0
- package/dist/ipc/inference_executor.js +1 -0
- package/dist/ipc/inference_executor.js.map +1 -0
- package/dist/ipc/inference_proc_executor.cjs +101 -0
- package/dist/ipc/inference_proc_executor.cjs.map +1 -0
- package/dist/ipc/inference_proc_executor.d.cts +23 -0
- package/dist/ipc/inference_proc_executor.d.ts +23 -0
- package/dist/ipc/inference_proc_executor.d.ts.map +1 -0
- package/dist/ipc/inference_proc_executor.js +75 -0
- package/dist/ipc/inference_proc_executor.js.map +1 -0
- package/dist/ipc/inference_proc_lazy_main.cjs +86 -0
- package/dist/ipc/inference_proc_lazy_main.cjs.map +1 -0
- package/dist/ipc/inference_proc_lazy_main.d.cts +2 -0
- package/dist/ipc/inference_proc_lazy_main.d.ts +2 -0
- package/dist/ipc/inference_proc_lazy_main.d.ts.map +1 -0
- package/dist/ipc/inference_proc_lazy_main.js +85 -0
- package/dist/ipc/inference_proc_lazy_main.js.map +1 -0
- package/dist/ipc/job_executor.cjs +34 -0
- package/dist/ipc/job_executor.cjs.map +1 -0
- package/dist/ipc/job_executor.d.cts +18 -0
- package/dist/ipc/job_executor.d.ts +18 -0
- package/dist/ipc/job_executor.d.ts.map +1 -0
- package/dist/ipc/job_executor.js +10 -0
- package/dist/ipc/job_executor.js.map +1 -0
- package/dist/ipc/job_proc_executor.cjs +115 -0
- package/dist/ipc/job_proc_executor.cjs.map +1 -0
- package/dist/ipc/job_proc_executor.d.cts +19 -0
- package/dist/ipc/job_proc_executor.d.ts +19 -0
- package/dist/ipc/job_proc_executor.d.ts.map +1 -0
- package/dist/ipc/job_proc_executor.js +89 -0
- package/dist/ipc/job_proc_executor.js.map +1 -0
- package/dist/ipc/job_proc_lazy_main.cjs +210 -0
- package/dist/ipc/job_proc_lazy_main.cjs.map +1 -0
- package/dist/ipc/job_proc_lazy_main.d.cts +2 -0
- package/dist/ipc/job_proc_lazy_main.d.ts +2 -0
- package/dist/ipc/job_proc_lazy_main.d.ts.map +1 -0
- package/dist/ipc/job_proc_lazy_main.js +187 -0
- package/dist/ipc/job_proc_lazy_main.js.map +1 -0
- package/dist/ipc/message.cjs +17 -0
- package/dist/ipc/message.cjs.map +1 -0
- package/dist/ipc/message.d.cts +58 -0
- package/dist/ipc/message.d.ts +58 -0
- package/dist/ipc/message.d.ts.map +1 -0
- package/dist/ipc/message.js +1 -0
- package/dist/ipc/message.js.map +1 -0
- package/dist/ipc/proc_pool.cjs +164 -0
- package/dist/ipc/proc_pool.cjs.map +1 -0
- package/dist/ipc/proc_pool.d.cts +31 -0
- package/dist/ipc/proc_pool.d.ts +31 -0
- package/dist/ipc/proc_pool.d.ts.map +1 -0
- package/dist/ipc/proc_pool.js +140 -0
- package/dist/ipc/proc_pool.js.map +1 -0
- package/dist/ipc/supervised_proc.cjs +229 -0
- package/dist/ipc/supervised_proc.cjs.map +1 -0
- package/dist/ipc/supervised_proc.d.cts +32 -0
- package/dist/ipc/supervised_proc.d.ts +32 -0
- package/dist/ipc/supervised_proc.d.ts.map +1 -0
- package/dist/ipc/supervised_proc.js +195 -0
- package/dist/ipc/supervised_proc.js.map +1 -0
- package/dist/ipc/supervised_proc.test.cjs +145 -0
- package/dist/ipc/supervised_proc.test.cjs.map +1 -0
- package/dist/ipc/supervised_proc.test.js +122 -0
- package/dist/ipc/supervised_proc.test.js.map +1 -0
- package/dist/job.cjs +373 -0
- package/dist/job.cjs.map +1 -0
- package/dist/job.d.cts +141 -0
- package/dist/job.d.ts +141 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +332 -0
- package/dist/job.js.map +1 -0
- package/dist/llm/chat_context.cjs +527 -0
- package/dist/llm/chat_context.cjs.map +1 -0
- package/dist/llm/chat_context.d.cts +223 -0
- package/dist/llm/chat_context.d.ts +223 -0
- package/dist/llm/chat_context.d.ts.map +1 -0
- package/dist/llm/chat_context.js +496 -0
- package/dist/llm/chat_context.js.map +1 -0
- package/dist/llm/chat_context.test.cjs +911 -0
- package/dist/llm/chat_context.test.cjs.map +1 -0
- package/dist/llm/chat_context.test.js +916 -0
- package/dist/llm/chat_context.test.js.map +1 -0
- package/dist/llm/fallback_adapter.cjs +278 -0
- package/dist/llm/fallback_adapter.cjs.map +1 -0
- package/dist/llm/fallback_adapter.d.cts +73 -0
- package/dist/llm/fallback_adapter.d.ts +73 -0
- package/dist/llm/fallback_adapter.d.ts.map +1 -0
- package/dist/llm/fallback_adapter.js +254 -0
- package/dist/llm/fallback_adapter.js.map +1 -0
- package/dist/llm/fallback_adapter.test.cjs +176 -0
- package/dist/llm/fallback_adapter.test.cjs.map +1 -0
- package/dist/llm/fallback_adapter.test.js +175 -0
- package/dist/llm/fallback_adapter.test.js.map +1 -0
- package/dist/llm/index.cjs +79 -0
- package/dist/llm/index.cjs.map +1 -0
- package/dist/llm/index.d.cts +9 -0
- package/dist/llm/index.d.ts +9 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +61 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/llm.cjs +226 -0
- package/dist/llm/llm.cjs.map +1 -0
- package/dist/llm/llm.d.cts +94 -0
- package/dist/llm/llm.d.ts +94 -0
- package/dist/llm/llm.d.ts.map +1 -0
- package/dist/llm/llm.js +201 -0
- package/dist/llm/llm.js.map +1 -0
- package/dist/llm/provider_format/google.cjs +132 -0
- package/dist/llm/provider_format/google.cjs.map +1 -0
- package/dist/llm/provider_format/google.d.cts +6 -0
- package/dist/llm/provider_format/google.d.ts +6 -0
- package/dist/llm/provider_format/google.d.ts.map +1 -0
- package/dist/llm/provider_format/google.js +108 -0
- package/dist/llm/provider_format/google.js.map +1 -0
- package/dist/llm/provider_format/google.test.cjs +724 -0
- package/dist/llm/provider_format/google.test.cjs.map +1 -0
- package/dist/llm/provider_format/google.test.js +728 -0
- package/dist/llm/provider_format/google.test.js.map +1 -0
- package/dist/llm/provider_format/index.cjs +40 -0
- package/dist/llm/provider_format/index.cjs.map +1 -0
- package/dist/llm/provider_format/index.d.cts +4 -0
- package/dist/llm/provider_format/index.d.ts +4 -0
- package/dist/llm/provider_format/index.d.ts.map +1 -0
- package/dist/llm/provider_format/index.js +16 -0
- package/dist/llm/provider_format/index.js.map +1 -0
- package/dist/llm/provider_format/openai.cjs +138 -0
- package/dist/llm/provider_format/openai.cjs.map +1 -0
- package/dist/llm/provider_format/openai.d.cts +3 -0
- package/dist/llm/provider_format/openai.d.ts +3 -0
- package/dist/llm/provider_format/openai.d.ts.map +1 -0
- package/dist/llm/provider_format/openai.js +114 -0
- package/dist/llm/provider_format/openai.js.map +1 -0
- package/dist/llm/provider_format/openai.test.cjs +557 -0
- package/dist/llm/provider_format/openai.test.cjs.map +1 -0
- package/dist/llm/provider_format/openai.test.js +561 -0
- package/dist/llm/provider_format/openai.test.js.map +1 -0
- package/dist/llm/provider_format/utils.cjs +146 -0
- package/dist/llm/provider_format/utils.cjs.map +1 -0
- package/dist/llm/provider_format/utils.d.cts +38 -0
- package/dist/llm/provider_format/utils.d.ts +38 -0
- package/dist/llm/provider_format/utils.d.ts.map +1 -0
- package/dist/llm/provider_format/utils.js +122 -0
- package/dist/llm/provider_format/utils.js.map +1 -0
- package/dist/llm/realtime.cjs +77 -0
- package/dist/llm/realtime.cjs.map +1 -0
- package/dist/llm/realtime.d.cts +106 -0
- package/dist/llm/realtime.d.ts +106 -0
- package/dist/llm/realtime.d.ts.map +1 -0
- package/dist/llm/realtime.js +52 -0
- package/dist/llm/realtime.js.map +1 -0
- package/dist/llm/remote_chat_context.cjs +112 -0
- package/dist/llm/remote_chat_context.cjs.map +1 -0
- package/dist/llm/remote_chat_context.d.cts +25 -0
- package/dist/llm/remote_chat_context.d.ts +25 -0
- package/dist/llm/remote_chat_context.d.ts.map +1 -0
- package/dist/llm/remote_chat_context.js +88 -0
- package/dist/llm/remote_chat_context.js.map +1 -0
- package/dist/llm/remote_chat_context.test.cjs +225 -0
- package/dist/llm/remote_chat_context.test.cjs.map +1 -0
- package/dist/llm/remote_chat_context.test.js +224 -0
- package/dist/llm/remote_chat_context.test.js.map +1 -0
- package/dist/llm/tool_context.cjs +152 -0
- package/dist/llm/tool_context.cjs.map +1 -0
- package/dist/llm/tool_context.d.cts +153 -0
- package/dist/llm/tool_context.d.ts +153 -0
- package/dist/llm/tool_context.d.ts.map +1 -0
- package/dist/llm/tool_context.js +119 -0
- package/dist/llm/tool_context.js.map +1 -0
- package/dist/llm/tool_context.test.cjs +359 -0
- package/dist/llm/tool_context.test.cjs.map +1 -0
- package/dist/llm/tool_context.test.js +336 -0
- package/dist/llm/tool_context.test.js.map +1 -0
- package/dist/llm/tool_context.type.test.cjs +92 -0
- package/dist/llm/tool_context.type.test.cjs.map +1 -0
- package/dist/llm/tool_context.type.test.js +91 -0
- package/dist/llm/tool_context.type.test.js.map +1 -0
- package/dist/llm/utils.cjs +267 -0
- package/dist/llm/utils.cjs.map +1 -0
- package/dist/llm/utils.d.cts +41 -0
- package/dist/llm/utils.d.ts +41 -0
- package/dist/llm/utils.d.ts.map +1 -0
- package/dist/llm/utils.js +230 -0
- package/dist/llm/utils.js.map +1 -0
- package/dist/llm/utils.test.cjs +513 -0
- package/dist/llm/utils.test.cjs.map +1 -0
- package/dist/llm/utils.test.js +490 -0
- package/dist/llm/utils.test.js.map +1 -0
- package/dist/llm/zod-utils.cjs +102 -0
- package/dist/llm/zod-utils.cjs.map +1 -0
- package/dist/llm/zod-utils.d.cts +65 -0
- package/dist/llm/zod-utils.d.ts +65 -0
- package/dist/llm/zod-utils.d.ts.map +1 -0
- package/dist/llm/zod-utils.js +64 -0
- package/dist/llm/zod-utils.js.map +1 -0
- package/dist/llm/zod-utils.test.cjs +472 -0
- package/dist/llm/zod-utils.test.cjs.map +1 -0
- package/dist/llm/zod-utils.test.js +455 -0
- package/dist/llm/zod-utils.test.js.map +1 -0
- package/dist/log.cjs +81 -0
- package/dist/log.cjs.map +1 -0
- package/dist/log.d.cts +20 -0
- package/dist/log.d.ts +20 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +54 -0
- package/dist/log.js.map +1 -0
- package/dist/metrics/base.cjs +17 -0
- package/dist/metrics/base.cjs.map +1 -0
- package/dist/metrics/base.d.cts +150 -0
- package/dist/metrics/base.d.ts +150 -0
- package/dist/metrics/base.d.ts.map +1 -0
- package/dist/metrics/base.js +1 -0
- package/dist/metrics/base.js.map +1 -0
- package/dist/metrics/index.cjs +32 -0
- package/dist/metrics/index.cjs.map +1 -0
- package/dist/metrics/index.d.cts +4 -0
- package/dist/metrics/index.d.ts +4 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +7 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/usage_collector.cjs +58 -0
- package/dist/metrics/usage_collector.cjs.map +1 -0
- package/dist/metrics/usage_collector.d.cts +15 -0
- package/dist/metrics/usage_collector.d.ts +15 -0
- package/dist/metrics/usage_collector.d.ts.map +1 -0
- package/dist/metrics/usage_collector.js +34 -0
- package/dist/metrics/usage_collector.js.map +1 -0
- package/dist/metrics/utils.cjs +74 -0
- package/dist/metrics/utils.cjs.map +1 -0
- package/dist/metrics/utils.d.cts +3 -0
- package/dist/metrics/utils.d.ts +3 -0
- package/dist/metrics/utils.d.ts.map +1 -0
- package/dist/metrics/utils.js +50 -0
- package/dist/metrics/utils.js.map +1 -0
- package/dist/plugin.cjs +62 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.cts +24 -0
- package/dist/plugin.d.ts +24 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +37 -0
- package/dist/plugin.js.map +1 -0
- package/dist/stream/deferred_stream.cjs +106 -0
- package/dist/stream/deferred_stream.cjs.map +1 -0
- package/dist/stream/deferred_stream.d.cts +32 -0
- package/dist/stream/deferred_stream.d.ts +32 -0
- package/dist/stream/deferred_stream.d.ts.map +1 -0
- package/dist/stream/deferred_stream.js +81 -0
- package/dist/stream/deferred_stream.js.map +1 -0
- package/dist/stream/deferred_stream.test.cjs +527 -0
- package/dist/stream/deferred_stream.test.cjs.map +1 -0
- package/dist/stream/deferred_stream.test.js +526 -0
- package/dist/stream/deferred_stream.test.js.map +1 -0
- package/dist/stream/identity_transform.cjs +42 -0
- package/dist/stream/identity_transform.cjs.map +1 -0
- package/dist/stream/identity_transform.d.cts +6 -0
- package/dist/stream/identity_transform.d.ts +6 -0
- package/dist/stream/identity_transform.d.ts.map +1 -0
- package/dist/stream/identity_transform.js +18 -0
- package/dist/stream/identity_transform.js.map +1 -0
- package/dist/stream/identity_transform.test.cjs +125 -0
- package/dist/stream/identity_transform.test.cjs.map +1 -0
- package/dist/stream/identity_transform.test.js +124 -0
- package/dist/stream/identity_transform.test.js.map +1 -0
- package/dist/stream/index.cjs +38 -0
- package/dist/stream/index.cjs.map +1 -0
- package/dist/stream/index.d.cts +5 -0
- package/dist/stream/index.d.ts +5 -0
- package/dist/stream/index.d.ts.map +1 -0
- package/dist/stream/index.js +11 -0
- package/dist/stream/index.js.map +1 -0
- package/dist/stream/merge_readable_streams.cjs +59 -0
- package/dist/stream/merge_readable_streams.cjs.map +1 -0
- package/dist/stream/merge_readable_streams.d.cts +4 -0
- package/dist/stream/merge_readable_streams.d.ts +4 -0
- package/dist/stream/merge_readable_streams.d.ts.map +1 -0
- package/dist/stream/merge_readable_streams.js +35 -0
- package/dist/stream/merge_readable_streams.js.map +1 -0
- package/dist/stream/stream_channel.cjs +57 -0
- package/dist/stream/stream_channel.cjs.map +1 -0
- package/dist/stream/stream_channel.d.cts +11 -0
- package/dist/stream/stream_channel.d.ts +11 -0
- package/dist/stream/stream_channel.d.ts.map +1 -0
- package/dist/stream/stream_channel.js +33 -0
- package/dist/stream/stream_channel.js.map +1 -0
- package/dist/stream/stream_channel.test.cjs +124 -0
- package/dist/stream/stream_channel.test.cjs.map +1 -0
- package/dist/stream/stream_channel.test.js +123 -0
- package/dist/stream/stream_channel.test.js.map +1 -0
- package/dist/stt/index.cjs +38 -0
- package/dist/stt/index.cjs.map +1 -0
- package/dist/stt/index.d.cts +3 -0
- package/dist/stt/index.d.ts +3 -0
- package/dist/stt/index.d.ts.map +1 -0
- package/dist/stt/index.js +14 -0
- package/dist/stt/index.js.map +1 -0
- package/dist/stt/stream_adapter.cjs +115 -0
- package/dist/stt/stream_adapter.cjs.map +1 -0
- package/dist/stt/stream_adapter.d.cts +23 -0
- package/dist/stt/stream_adapter.d.ts +23 -0
- package/dist/stt/stream_adapter.d.ts.map +1 -0
- package/dist/stt/stream_adapter.js +90 -0
- package/dist/stt/stream_adapter.js.map +1 -0
- package/dist/stt/stt.cjs +253 -0
- package/dist/stt/stt.cjs.map +1 -0
- package/dist/stt/stt.d.cts +158 -0
- package/dist/stt/stt.d.ts +158 -0
- package/dist/stt/stt.d.ts.map +1 -0
- package/dist/stt/stt.js +227 -0
- package/dist/stt/stt.js.map +1 -0
- package/dist/telemetry/index.cjs +72 -0
- package/dist/telemetry/index.cjs.map +1 -0
- package/dist/telemetry/index.d.cts +7 -0
- package/dist/telemetry/index.d.ts +7 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +37 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/logging.cjs +65 -0
- package/dist/telemetry/logging.cjs.map +1 -0
- package/dist/telemetry/logging.d.cts +21 -0
- package/dist/telemetry/logging.d.ts +21 -0
- package/dist/telemetry/logging.d.ts.map +1 -0
- package/dist/telemetry/logging.js +40 -0
- package/dist/telemetry/logging.js.map +1 -0
- package/dist/telemetry/otel_http_exporter.cjs +147 -0
- package/dist/telemetry/otel_http_exporter.cjs.map +1 -0
- package/dist/telemetry/otel_http_exporter.d.cts +62 -0
- package/dist/telemetry/otel_http_exporter.d.ts +62 -0
- package/dist/telemetry/otel_http_exporter.d.ts.map +1 -0
- package/dist/telemetry/otel_http_exporter.js +123 -0
- package/dist/telemetry/otel_http_exporter.js.map +1 -0
- package/dist/telemetry/pino_otel_transport.cjs +217 -0
- package/dist/telemetry/pino_otel_transport.cjs.map +1 -0
- package/dist/telemetry/pino_otel_transport.d.cts +58 -0
- package/dist/telemetry/pino_otel_transport.d.ts +58 -0
- package/dist/telemetry/pino_otel_transport.d.ts.map +1 -0
- package/dist/telemetry/pino_otel_transport.js +189 -0
- package/dist/telemetry/pino_otel_transport.js.map +1 -0
- package/dist/telemetry/trace_types.cjs +206 -0
- package/dist/telemetry/trace_types.cjs.map +1 -0
- package/dist/telemetry/trace_types.d.cts +61 -0
- package/dist/telemetry/trace_types.d.ts +61 -0
- package/dist/telemetry/trace_types.d.ts.map +1 -0
- package/dist/telemetry/trace_types.js +123 -0
- package/dist/telemetry/trace_types.js.map +1 -0
- package/dist/telemetry/traces.cjs +444 -0
- package/dist/telemetry/traces.cjs.map +1 -0
- package/dist/telemetry/traces.d.cts +114 -0
- package/dist/telemetry/traces.d.ts +114 -0
- package/dist/telemetry/traces.d.ts.map +1 -0
- package/dist/telemetry/traces.js +409 -0
- package/dist/telemetry/traces.js.map +1 -0
- package/dist/telemetry/utils.cjs +86 -0
- package/dist/telemetry/utils.cjs.map +1 -0
- package/dist/telemetry/utils.d.cts +5 -0
- package/dist/telemetry/utils.d.ts +5 -0
- package/dist/telemetry/utils.d.ts.map +1 -0
- package/dist/telemetry/utils.js +51 -0
- package/dist/telemetry/utils.js.map +1 -0
- package/dist/tokenize/basic/basic.cjs +105 -0
- package/dist/tokenize/basic/basic.cjs.map +1 -0
- package/dist/tokenize/basic/basic.d.cts +24 -0
- package/dist/tokenize/basic/basic.d.ts +24 -0
- package/dist/tokenize/basic/basic.d.ts.map +1 -0
- package/dist/tokenize/basic/basic.js +67 -0
- package/dist/tokenize/basic/basic.js.map +1 -0
- package/dist/tokenize/basic/hyphenator.cjs +425 -0
- package/dist/tokenize/basic/hyphenator.cjs.map +1 -0
- package/dist/tokenize/basic/hyphenator.d.cts +17 -0
- package/dist/tokenize/basic/hyphenator.d.ts +17 -0
- package/dist/tokenize/basic/hyphenator.d.ts.map +1 -0
- package/dist/tokenize/basic/hyphenator.js +401 -0
- package/dist/tokenize/basic/hyphenator.js.map +1 -0
- package/dist/tokenize/basic/index.cjs +37 -0
- package/dist/tokenize/basic/index.cjs.map +1 -0
- package/dist/tokenize/basic/index.d.cts +2 -0
- package/dist/tokenize/basic/index.d.ts +2 -0
- package/dist/tokenize/basic/index.d.ts.map +1 -0
- package/dist/tokenize/basic/index.js +15 -0
- package/dist/tokenize/basic/index.js.map +1 -0
- package/dist/tokenize/basic/paragraph.cjs +57 -0
- package/dist/tokenize/basic/paragraph.cjs.map +1 -0
- package/dist/tokenize/basic/paragraph.d.cts +5 -0
- package/dist/tokenize/basic/paragraph.d.ts +5 -0
- package/dist/tokenize/basic/paragraph.d.ts.map +1 -0
- package/dist/tokenize/basic/paragraph.js +33 -0
- package/dist/tokenize/basic/paragraph.js.map +1 -0
- package/dist/tokenize/basic/sentence.cjs +97 -0
- package/dist/tokenize/basic/sentence.cjs.map +1 -0
- package/dist/tokenize/basic/sentence.d.cts +5 -0
- package/dist/tokenize/basic/sentence.d.ts +5 -0
- package/dist/tokenize/basic/sentence.d.ts.map +1 -0
- package/dist/tokenize/basic/sentence.js +73 -0
- package/dist/tokenize/basic/sentence.js.map +1 -0
- package/dist/tokenize/basic/word.cjs +44 -0
- package/dist/tokenize/basic/word.cjs.map +1 -0
- package/dist/tokenize/basic/word.d.cts +5 -0
- package/dist/tokenize/basic/word.d.ts +5 -0
- package/dist/tokenize/basic/word.d.ts.map +1 -0
- package/dist/tokenize/basic/word.js +20 -0
- package/dist/tokenize/basic/word.js.map +1 -0
- package/dist/tokenize/index.cjs +55 -0
- package/dist/tokenize/index.cjs.map +1 -0
- package/dist/tokenize/index.d.cts +5 -0
- package/dist/tokenize/index.d.ts +5 -0
- package/dist/tokenize/index.d.ts.map +1 -0
- package/dist/tokenize/index.js +19 -0
- package/dist/tokenize/index.js.map +1 -0
- package/dist/tokenize/token_stream.cjs +168 -0
- package/dist/tokenize/token_stream.cjs.map +1 -0
- package/dist/tokenize/token_stream.d.cts +40 -0
- package/dist/tokenize/token_stream.d.ts +40 -0
- package/dist/tokenize/token_stream.d.ts.map +1 -0
- package/dist/tokenize/token_stream.js +142 -0
- package/dist/tokenize/token_stream.js.map +1 -0
- package/dist/tokenize/tokenizer.cjs +184 -0
- package/dist/tokenize/tokenizer.cjs.map +1 -0
- package/dist/tokenize/tokenizer.d.cts +55 -0
- package/dist/tokenize/tokenizer.d.ts +55 -0
- package/dist/tokenize/tokenizer.d.ts.map +1 -0
- package/dist/tokenize/tokenizer.js +156 -0
- package/dist/tokenize/tokenizer.js.map +1 -0
- package/dist/tokenize/tokenizer.test.cjs +220 -0
- package/dist/tokenize/tokenizer.test.cjs.map +1 -0
- package/dist/tokenize/tokenizer.test.js +219 -0
- package/dist/tokenize/tokenizer.test.js.map +1 -0
- package/dist/transcription.cjs +247 -0
- package/dist/transcription.cjs.map +1 -0
- package/dist/transcription.d.cts +31 -0
- package/dist/transcription.d.ts +31 -0
- package/dist/transcription.d.ts.map +1 -0
- package/dist/transcription.js +222 -0
- package/dist/transcription.js.map +1 -0
- package/dist/tts/index.cjs +38 -0
- package/dist/tts/index.cjs.map +1 -0
- package/dist/tts/index.d.cts +3 -0
- package/dist/tts/index.d.ts +3 -0
- package/dist/tts/index.d.ts.map +1 -0
- package/dist/tts/index.js +14 -0
- package/dist/tts/index.js.map +1 -0
- package/dist/tts/stream_adapter.cjs +105 -0
- package/dist/tts/stream_adapter.cjs.map +1 -0
- package/dist/tts/stream_adapter.d.cts +20 -0
- package/dist/tts/stream_adapter.d.ts +20 -0
- package/dist/tts/stream_adapter.d.ts.map +1 -0
- package/dist/tts/stream_adapter.js +80 -0
- package/dist/tts/stream_adapter.js.map +1 -0
- package/dist/tts/tts.cjs +431 -0
- package/dist/tts/tts.cjs.map +1 -0
- package/dist/tts/tts.d.cts +161 -0
- package/dist/tts/tts.d.ts +161 -0
- package/dist/tts/tts.d.ts.map +1 -0
- package/dist/tts/tts.js +405 -0
- package/dist/tts/tts.js.map +1 -0
- package/dist/types.cjs +49 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +44 -0
- package/dist/types.d.ts +44 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +23 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/ws_transport.cjs +51 -0
- package/dist/utils/ws_transport.cjs.map +1 -0
- package/dist/utils/ws_transport.d.cts +9 -0
- package/dist/utils/ws_transport.d.ts +9 -0
- package/dist/utils/ws_transport.d.ts.map +1 -0
- package/dist/utils/ws_transport.js +17 -0
- package/dist/utils/ws_transport.js.map +1 -0
- package/dist/utils/ws_transport.test.cjs +212 -0
- package/dist/utils/ws_transport.test.cjs.map +1 -0
- package/dist/utils/ws_transport.test.js +211 -0
- package/dist/utils/ws_transport.test.js.map +1 -0
- package/dist/utils.cjs +669 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +244 -0
- package/dist/utils.d.ts +244 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +617 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.test.cjs +492 -0
- package/dist/utils.test.cjs.map +1 -0
- package/dist/utils.test.js +491 -0
- package/dist/utils.test.js.map +1 -0
- package/dist/vad.cjs +211 -0
- package/dist/vad.cjs.map +1 -0
- package/dist/vad.d.cts +105 -0
- package/dist/vad.d.ts +105 -0
- package/dist/vad.d.ts.map +1 -0
- package/dist/vad.js +185 -0
- package/dist/vad.js.map +1 -0
- package/dist/version.cjs +29 -0
- package/dist/version.cjs.map +1 -0
- package/dist/version.d.cts +2 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/dist/voice/agent.cjs +308 -0
- package/dist/voice/agent.cjs.map +1 -0
- package/dist/voice/agent.d.cts +83 -0
- package/dist/voice/agent.d.ts +83 -0
- package/dist/voice/agent.d.ts.map +1 -0
- package/dist/voice/agent.js +287 -0
- package/dist/voice/agent.js.map +1 -0
- package/dist/voice/agent.test.cjs +61 -0
- package/dist/voice/agent.test.cjs.map +1 -0
- package/dist/voice/agent.test.js +60 -0
- package/dist/voice/agent.test.js.map +1 -0
- package/dist/voice/agent_activity.cjs +1784 -0
- package/dist/voice/agent_activity.cjs.map +1 -0
- package/dist/voice/agent_activity.d.cts +116 -0
- package/dist/voice/agent_activity.d.ts +116 -0
- package/dist/voice/agent_activity.d.ts.map +1 -0
- package/dist/voice/agent_activity.js +1780 -0
- package/dist/voice/agent_activity.js.map +1 -0
- package/dist/voice/agent_session.cjs +592 -0
- package/dist/voice/agent_session.cjs.map +1 -0
- package/dist/voice/agent_session.d.cts +165 -0
- package/dist/voice/agent_session.d.ts +165 -0
- package/dist/voice/agent_session.d.ts.map +1 -0
- package/dist/voice/agent_session.js +582 -0
- package/dist/voice/agent_session.js.map +1 -0
- package/dist/voice/audio_recognition.cjs +668 -0
- package/dist/voice/audio_recognition.cjs.map +1 -0
- package/dist/voice/audio_recognition.d.cts +127 -0
- package/dist/voice/audio_recognition.d.ts +127 -0
- package/dist/voice/audio_recognition.d.ts.map +1 -0
- package/dist/voice/audio_recognition.js +647 -0
- package/dist/voice/audio_recognition.js.map +1 -0
- package/dist/voice/avatar/datastream_io.cjs +204 -0
- package/dist/voice/avatar/datastream_io.cjs.map +1 -0
- package/dist/voice/avatar/datastream_io.d.cts +37 -0
- package/dist/voice/avatar/datastream_io.d.ts +37 -0
- package/dist/voice/avatar/datastream_io.d.ts.map +1 -0
- package/dist/voice/avatar/datastream_io.js +188 -0
- package/dist/voice/avatar/datastream_io.js.map +1 -0
- package/dist/voice/avatar/index.cjs +23 -0
- package/dist/voice/avatar/index.cjs.map +1 -0
- package/dist/voice/avatar/index.d.cts +2 -0
- package/dist/voice/avatar/index.d.ts +2 -0
- package/dist/voice/avatar/index.d.ts.map +1 -0
- package/dist/voice/avatar/index.js +2 -0
- package/dist/voice/avatar/index.js.map +1 -0
- package/dist/voice/background_audio.cjs +366 -0
- package/dist/voice/background_audio.cjs.map +1 -0
- package/dist/voice/background_audio.d.cts +121 -0
- package/dist/voice/background_audio.d.ts +121 -0
- package/dist/voice/background_audio.d.ts.map +1 -0
- package/dist/voice/background_audio.js +342 -0
- package/dist/voice/background_audio.js.map +1 -0
- package/dist/voice/events.cjs +147 -0
- package/dist/voice/events.cjs.map +1 -0
- package/dist/voice/events.d.cts +127 -0
- package/dist/voice/events.d.ts +127 -0
- package/dist/voice/events.d.ts.map +1 -0
- package/dist/voice/events.js +112 -0
- package/dist/voice/events.js.map +1 -0
- package/dist/voice/generation.cjs +747 -0
- package/dist/voice/generation.cjs.map +1 -0
- package/dist/voice/generation.d.cts +116 -0
- package/dist/voice/generation.d.ts +116 -0
- package/dist/voice/generation.d.ts.map +1 -0
- package/dist/voice/generation.js +719 -0
- package/dist/voice/generation.js.map +1 -0
- package/dist/voice/generation_tools.test.cjs +236 -0
- package/dist/voice/generation_tools.test.cjs.map +1 -0
- package/dist/voice/generation_tools.test.js +235 -0
- package/dist/voice/generation_tools.test.js.map +1 -0
- package/dist/voice/index.cjs +49 -0
- package/dist/voice/index.cjs.map +1 -0
- package/dist/voice/index.d.cts +10 -0
- package/dist/voice/index.d.ts +10 -0
- package/dist/voice/index.d.ts.map +1 -0
- package/dist/voice/index.js +16 -0
- package/dist/voice/index.js.map +1 -0
- package/dist/voice/interruption_detection.test.cjs +114 -0
- package/dist/voice/interruption_detection.test.cjs.map +1 -0
- package/dist/voice/interruption_detection.test.js +113 -0
- package/dist/voice/interruption_detection.test.js.map +1 -0
- package/dist/voice/io.cjs +270 -0
- package/dist/voice/io.cjs.map +1 -0
- package/dist/voice/io.d.cts +126 -0
- package/dist/voice/io.d.ts +126 -0
- package/dist/voice/io.d.ts.map +1 -0
- package/dist/voice/io.js +242 -0
- package/dist/voice/io.js.map +1 -0
- package/dist/voice/recorder_io/index.cjs +23 -0
- package/dist/voice/recorder_io/index.cjs.map +1 -0
- package/dist/voice/recorder_io/index.d.cts +2 -0
- package/dist/voice/recorder_io/index.d.ts +2 -0
- package/dist/voice/recorder_io/index.d.ts.map +1 -0
- package/dist/voice/recorder_io/index.js +2 -0
- package/dist/voice/recorder_io/index.js.map +1 -0
- package/dist/voice/recorder_io/recorder_io.cjs +542 -0
- package/dist/voice/recorder_io/recorder_io.cjs.map +1 -0
- package/dist/voice/recorder_io/recorder_io.d.cts +100 -0
- package/dist/voice/recorder_io/recorder_io.d.ts +100 -0
- package/dist/voice/recorder_io/recorder_io.d.ts.map +1 -0
- package/dist/voice/recorder_io/recorder_io.js +508 -0
- package/dist/voice/recorder_io/recorder_io.js.map +1 -0
- package/dist/voice/report.cjs +75 -0
- package/dist/voice/report.cjs.map +1 -0
- package/dist/voice/report.d.cts +42 -0
- package/dist/voice/report.d.ts +42 -0
- package/dist/voice/report.d.ts.map +1 -0
- package/dist/voice/report.js +50 -0
- package/dist/voice/report.js.map +1 -0
- package/dist/voice/room_io/_input.cjs +133 -0
- package/dist/voice/room_io/_input.cjs.map +1 -0
- package/dist/voice/room_io/_input.d.cts +24 -0
- package/dist/voice/room_io/_input.d.ts +24 -0
- package/dist/voice/room_io/_input.d.ts.map +1 -0
- package/dist/voice/room_io/_input.js +114 -0
- package/dist/voice/room_io/_input.js.map +1 -0
- package/dist/voice/room_io/_output.cjs +359 -0
- package/dist/voice/room_io/_output.cjs.map +1 -0
- package/dist/voice/room_io/_output.d.cts +77 -0
- package/dist/voice/room_io/_output.d.ts +77 -0
- package/dist/voice/room_io/_output.d.ts.map +1 -0
- package/dist/voice/room_io/_output.js +343 -0
- package/dist/voice/room_io/_output.js.map +1 -0
- package/dist/voice/room_io/index.cjs +25 -0
- package/dist/voice/room_io/index.cjs.map +1 -0
- package/dist/voice/room_io/index.d.cts +3 -0
- package/dist/voice/room_io/index.d.ts +3 -0
- package/dist/voice/room_io/index.d.ts.map +1 -0
- package/dist/voice/room_io/index.js +3 -0
- package/dist/voice/room_io/index.js.map +1 -0
- package/dist/voice/room_io/room_io.cjs +373 -0
- package/dist/voice/room_io/room_io.cjs.map +1 -0
- package/dist/voice/room_io/room_io.d.cts +94 -0
- package/dist/voice/room_io/room_io.d.ts +94 -0
- package/dist/voice/room_io/room_io.d.ts.map +1 -0
- package/dist/voice/room_io/room_io.js +364 -0
- package/dist/voice/room_io/room_io.js.map +1 -0
- package/dist/voice/run_context.cjs +51 -0
- package/dist/voice/run_context.cjs.map +1 -0
- package/dist/voice/run_context.d.cts +22 -0
- package/dist/voice/run_context.d.ts +22 -0
- package/dist/voice/run_context.d.ts.map +1 -0
- package/dist/voice/run_context.js +27 -0
- package/dist/voice/run_context.js.map +1 -0
- package/dist/voice/speech_handle.cjs +228 -0
- package/dist/voice/speech_handle.cjs.map +1 -0
- package/dist/voice/speech_handle.d.cts +97 -0
- package/dist/voice/speech_handle.d.ts +97 -0
- package/dist/voice/speech_handle.d.ts.map +1 -0
- package/dist/voice/speech_handle.js +204 -0
- package/dist/voice/speech_handle.js.map +1 -0
- package/dist/voice/transcription/_utils.cjs +45 -0
- package/dist/voice/transcription/_utils.cjs.map +1 -0
- package/dist/voice/transcription/_utils.d.cts +3 -0
- package/dist/voice/transcription/_utils.d.ts +3 -0
- package/dist/voice/transcription/_utils.d.ts.map +1 -0
- package/dist/voice/transcription/_utils.js +21 -0
- package/dist/voice/transcription/_utils.js.map +1 -0
- package/dist/voice/transcription/index.cjs +23 -0
- package/dist/voice/transcription/index.cjs.map +1 -0
- package/dist/voice/transcription/index.d.cts +2 -0
- package/dist/voice/transcription/index.d.ts +2 -0
- package/dist/voice/transcription/index.d.ts.map +1 -0
- package/dist/voice/transcription/index.js +2 -0
- package/dist/voice/transcription/index.js.map +1 -0
- package/dist/voice/transcription/synchronizer.cjs +379 -0
- package/dist/voice/transcription/synchronizer.cjs.map +1 -0
- package/dist/voice/transcription/synchronizer.d.cts +87 -0
- package/dist/voice/transcription/synchronizer.d.ts +87 -0
- package/dist/voice/transcription/synchronizer.d.ts.map +1 -0
- package/dist/voice/transcription/synchronizer.js +354 -0
- package/dist/voice/transcription/synchronizer.js.map +1 -0
- package/dist/worker.cjs +680 -0
- package/dist/worker.cjs.map +1 -0
- package/dist/worker.d.cts +119 -0
- package/dist/worker.d.ts +119 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +645 -0
- package/dist/worker.js.map +1 -0
- package/package.json +86 -0
- package/resources/NOTICE +2 -0
- package/resources/keyboard-typing.ogg +0 -0
- package/resources/keyboard-typing2.ogg +0 -0
- package/resources/office-ambience.ogg +0 -0
- package/src/_exceptions.ts +137 -0
- package/src/audio.ts +205 -0
- package/src/cli.ts +224 -0
- package/src/connection_pool.test.ts +346 -0
- package/src/connection_pool.ts +307 -0
- package/src/constants.ts +9 -0
- package/src/generator.ts +38 -0
- package/src/http_server.ts +64 -0
- package/src/index.ts +41 -0
- package/src/inference/api_protos.ts +82 -0
- package/src/inference/index.ts +32 -0
- package/src/inference/interruption/AdaptiveInterruptionDetector.ts +166 -0
- package/src/inference/interruption/InterruptionStream.ts +397 -0
- package/src/inference/interruption/defaults.ts +33 -0
- package/src/inference/interruption/errors.ts +0 -0
- package/src/inference/interruption/http_transport.ts +61 -0
- package/src/inference/interruption/index.ts +4 -0
- package/src/inference/interruption/interruption.ts +88 -0
- package/src/inference/llm.ts +532 -0
- package/src/inference/stt.ts +524 -0
- package/src/inference/tts.ts +574 -0
- package/src/inference/utils.test.ts +31 -0
- package/src/inference/utils.ts +81 -0
- package/src/inference_runner.ts +19 -0
- package/src/ipc/index.ts +5 -0
- package/src/ipc/inference_executor.ts +7 -0
- package/src/ipc/inference_proc_executor.ts +101 -0
- package/src/ipc/inference_proc_lazy_main.ts +115 -0
- package/src/ipc/job_executor.ts +23 -0
- package/src/ipc/job_proc_executor.ts +122 -0
- package/src/ipc/job_proc_lazy_main.ts +247 -0
- package/src/ipc/message.ts +52 -0
- package/src/ipc/proc_pool.ts +164 -0
- package/src/ipc/supervised_proc.test.ts +153 -0
- package/src/ipc/supervised_proc.ts +242 -0
- package/src/job.ts +461 -0
- package/src/llm/__snapshots__/chat_context.test.ts.snap +527 -0
- package/src/llm/__snapshots__/tool_context.test.ts.snap +177 -0
- package/src/llm/__snapshots__/zod-utils.test.ts.snap +559 -0
- package/src/llm/chat_context.test.ts +1057 -0
- package/src/llm/chat_context.ts +759 -0
- package/src/llm/fallback_adapter.test.ts +238 -0
- package/src/llm/fallback_adapter.ts +391 -0
- package/src/llm/index.ts +74 -0
- package/src/llm/llm.ts +303 -0
- package/src/llm/provider_format/google.test.ts +843 -0
- package/src/llm/provider_format/google.ts +134 -0
- package/src/llm/provider_format/index.ts +23 -0
- package/src/llm/provider_format/openai.test.ts +675 -0
- package/src/llm/provider_format/openai.ts +146 -0
- package/src/llm/provider_format/utils.ts +187 -0
- package/src/llm/realtime.ts +163 -0
- package/src/llm/remote_chat_context.test.ts +290 -0
- package/src/llm/remote_chat_context.ts +114 -0
- package/src/llm/tool_context.test.ts +407 -0
- package/src/llm/tool_context.ts +343 -0
- package/src/llm/tool_context.type.test.ts +115 -0
- package/src/llm/utils.test.ts +670 -0
- package/src/llm/utils.ts +336 -0
- package/src/llm/zod-utils.test.ts +577 -0
- package/src/llm/zod-utils.ts +153 -0
- package/src/log.ts +83 -0
- package/src/metrics/base.ts +168 -0
- package/src/metrics/index.ts +15 -0
- package/src/metrics/usage_collector.ts +46 -0
- package/src/metrics/utils.ts +64 -0
- package/src/plugin.ts +46 -0
- package/src/stream/deferred_stream.test.ts +755 -0
- package/src/stream/deferred_stream.ts +127 -0
- package/src/stream/identity_transform.test.ts +179 -0
- package/src/stream/identity_transform.ts +18 -0
- package/src/stream/index.ts +7 -0
- package/src/stream/merge_readable_streams.ts +40 -0
- package/src/stream/stream_channel.test.ts +166 -0
- package/src/stream/stream_channel.ts +44 -0
- package/src/stt/index.ts +15 -0
- package/src/stt/stream_adapter.ts +107 -0
- package/src/stt/stt.ts +374 -0
- package/src/telemetry/index.ts +28 -0
- package/src/telemetry/logging.ts +55 -0
- package/src/telemetry/otel_http_exporter.ts +195 -0
- package/src/telemetry/pino_otel_transport.ts +265 -0
- package/src/telemetry/trace_types.ts +95 -0
- package/src/telemetry/traces.ts +612 -0
- package/src/telemetry/utils.ts +61 -0
- package/src/tokenize/basic/basic.ts +83 -0
- package/src/tokenize/basic/hyphenator.ts +434 -0
- package/src/tokenize/basic/index.ts +11 -0
- package/src/tokenize/basic/paragraph.ts +43 -0
- package/src/tokenize/basic/sentence.ts +89 -0
- package/src/tokenize/basic/word.ts +27 -0
- package/src/tokenize/index.ts +16 -0
- package/src/tokenize/token_stream.ts +180 -0
- package/src/tokenize/tokenizer.test.ts +255 -0
- package/src/tokenize/tokenizer.ts +152 -0
- package/src/transcription.ts +307 -0
- package/src/tts/index.ts +12 -0
- package/src/tts/stream_adapter.ts +110 -0
- package/src/tts/tts.ts +598 -0
- package/src/types.ts +66 -0
- package/src/utils/ws_transport.test.ts +282 -0
- package/src/utils/ws_transport.ts +22 -0
- package/src/utils.test.ts +651 -0
- package/src/utils.ts +871 -0
- package/src/vad.ts +262 -0
- package/src/version.ts +5 -0
- package/src/voice/agent.test.ts +80 -0
- package/src/voice/agent.ts +418 -0
- package/src/voice/agent_activity.ts +2375 -0
- package/src/voice/agent_session.ts +866 -0
- package/src/voice/audio_recognition.ts +877 -0
- package/src/voice/avatar/datastream_io.ts +247 -0
- package/src/voice/avatar/index.ts +4 -0
- package/src/voice/background_audio.ts +491 -0
- package/src/voice/events.ts +261 -0
- package/src/voice/generation.ts +946 -0
- package/src/voice/generation_tools.test.ts +268 -0
- package/src/voice/index.ts +12 -0
- package/src/voice/interruption_detection.test.ts +151 -0
- package/src/voice/io.ts +347 -0
- package/src/voice/recorder_io/index.ts +4 -0
- package/src/voice/recorder_io/recorder_io.ts +690 -0
- package/src/voice/report.ts +100 -0
- package/src/voice/room_io/_input.ts +162 -0
- package/src/voice/room_io/_output.ts +439 -0
- package/src/voice/room_io/index.ts +5 -0
- package/src/voice/room_io/room_io.ts +518 -0
- package/src/voice/run_context.ts +34 -0
- package/src/voice/speech_handle.ts +250 -0
- package/src/voice/transcription/_utils.ts +25 -0
- package/src/voice/transcription/index.ts +4 -0
- package/src/voice/transcription/synchronizer.ts +477 -0
- package/src/worker.ts +798 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var tool_context_exports = {};
|
|
20
|
+
__export(tool_context_exports, {
|
|
21
|
+
ToolError: () => ToolError,
|
|
22
|
+
handoff: () => handoff,
|
|
23
|
+
isAgentHandoff: () => isAgentHandoff,
|
|
24
|
+
isFunctionTool: () => isFunctionTool,
|
|
25
|
+
isProviderDefinedTool: () => isProviderDefinedTool,
|
|
26
|
+
isSameToolChoice: () => isSameToolChoice,
|
|
27
|
+
isSameToolContext: () => isSameToolContext,
|
|
28
|
+
isTool: () => isTool,
|
|
29
|
+
isToolError: () => isToolError,
|
|
30
|
+
tool: () => tool
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(tool_context_exports);
|
|
33
|
+
var import_zod = require("zod");
|
|
34
|
+
var import_zod_utils = require("./zod-utils.cjs");
|
|
35
|
+
const TOOL_SYMBOL = Symbol("tool");
|
|
36
|
+
const FUNCTION_TOOL_SYMBOL = Symbol("function_tool");
|
|
37
|
+
const PROVIDER_DEFINED_TOOL_SYMBOL = Symbol("provider_defined_tool");
|
|
38
|
+
const TOOL_ERROR_SYMBOL = Symbol("tool_error");
|
|
39
|
+
const HANDOFF_SYMBOL = Symbol("handoff");
|
|
40
|
+
class ToolError extends Error {
|
|
41
|
+
constructor(message) {
|
|
42
|
+
super(message);
|
|
43
|
+
Object.defineProperty(this, TOOL_ERROR_SYMBOL, {
|
|
44
|
+
value: true
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function handoff(options) {
|
|
49
|
+
return {
|
|
50
|
+
agent: options.agent,
|
|
51
|
+
returns: options.returns,
|
|
52
|
+
[HANDOFF_SYMBOL]: true
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function isSameToolContext(ctx1, ctx2) {
|
|
56
|
+
const toolNames = new Set(Object.keys(ctx1));
|
|
57
|
+
const toolNames2 = new Set(Object.keys(ctx2));
|
|
58
|
+
if (toolNames.size !== toolNames2.size) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
for (const name of toolNames) {
|
|
62
|
+
if (!toolNames2.has(name)) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
const tool1 = ctx1[name];
|
|
66
|
+
const tool2 = ctx2[name];
|
|
67
|
+
if (!tool1 || !tool2) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
if (tool1.description !== tool2.description) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
function isSameToolChoice(choice1, choice2) {
|
|
77
|
+
if (choice1 === choice2) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
if (choice1 === null || choice2 === null) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
if (typeof choice1 === "string" && typeof choice2 === "string") {
|
|
84
|
+
return choice1 === choice2;
|
|
85
|
+
}
|
|
86
|
+
if (typeof choice1 === "object" && typeof choice2 === "object") {
|
|
87
|
+
return choice1.type === choice2.type && choice1.function.name === choice2.function.name;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
function tool(tool2) {
|
|
92
|
+
if (tool2.execute !== void 0) {
|
|
93
|
+
const parameters = tool2.parameters ?? import_zod.z.object({});
|
|
94
|
+
if ((0, import_zod_utils.isZodSchema)(parameters) && !(0, import_zod_utils.isZodObjectSchema)(parameters)) {
|
|
95
|
+
throw new Error("Tool parameters must be a Zod object schema (z.object(...))");
|
|
96
|
+
}
|
|
97
|
+
if (!(0, import_zod_utils.isZodSchema)(parameters) && !(typeof parameters === "object")) {
|
|
98
|
+
throw new Error("Tool parameters must be a Zod object schema or a raw JSON schema");
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
type: "function",
|
|
102
|
+
description: tool2.description,
|
|
103
|
+
parameters,
|
|
104
|
+
execute: tool2.execute,
|
|
105
|
+
[TOOL_SYMBOL]: true,
|
|
106
|
+
[FUNCTION_TOOL_SYMBOL]: true
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (tool2.config !== void 0 && tool2.id !== void 0) {
|
|
110
|
+
return {
|
|
111
|
+
type: "provider-defined",
|
|
112
|
+
id: tool2.id,
|
|
113
|
+
config: tool2.config,
|
|
114
|
+
[TOOL_SYMBOL]: true,
|
|
115
|
+
[PROVIDER_DEFINED_TOOL_SYMBOL]: true
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
throw new Error("Invalid tool");
|
|
119
|
+
}
|
|
120
|
+
function isTool(tool2) {
|
|
121
|
+
return tool2 && tool2[TOOL_SYMBOL] === true;
|
|
122
|
+
}
|
|
123
|
+
function isFunctionTool(tool2) {
|
|
124
|
+
const isTool2 = tool2 && tool2[TOOL_SYMBOL] === true;
|
|
125
|
+
const isFunctionTool2 = tool2[FUNCTION_TOOL_SYMBOL] === true;
|
|
126
|
+
return isTool2 && isFunctionTool2;
|
|
127
|
+
}
|
|
128
|
+
function isProviderDefinedTool(tool2) {
|
|
129
|
+
const isTool2 = tool2 && tool2[TOOL_SYMBOL] === true;
|
|
130
|
+
const isProviderDefinedTool2 = tool2[PROVIDER_DEFINED_TOOL_SYMBOL] === true;
|
|
131
|
+
return isTool2 && isProviderDefinedTool2;
|
|
132
|
+
}
|
|
133
|
+
function isToolError(error) {
|
|
134
|
+
return error && error[TOOL_ERROR_SYMBOL] === true;
|
|
135
|
+
}
|
|
136
|
+
function isAgentHandoff(handoff2) {
|
|
137
|
+
return handoff2 && handoff2[HANDOFF_SYMBOL] === true;
|
|
138
|
+
}
|
|
139
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
140
|
+
0 && (module.exports = {
|
|
141
|
+
ToolError,
|
|
142
|
+
handoff,
|
|
143
|
+
isAgentHandoff,
|
|
144
|
+
isFunctionTool,
|
|
145
|
+
isProviderDefinedTool,
|
|
146
|
+
isSameToolChoice,
|
|
147
|
+
isSameToolContext,
|
|
148
|
+
isTool,
|
|
149
|
+
isToolError,
|
|
150
|
+
tool
|
|
151
|
+
});
|
|
152
|
+
//# sourceMappingURL=tool_context.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/llm/tool_context.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { JSONSchema7 } from 'json-schema';\nimport { z } from 'zod';\nimport type { Agent } from '../voice/agent.js';\nimport type { RunContext, UnknownUserData } from '../voice/run_context.js';\nimport { isZodObjectSchema, isZodSchema } from './zod-utils.js';\n\n// heavily inspired by Vercel AI's `tool()`:\n// https://github.com/vercel/ai/blob/3b0983b/packages/ai/core/tool/tool.ts\n\nconst TOOL_SYMBOL = Symbol('tool');\nconst FUNCTION_TOOL_SYMBOL = Symbol('function_tool');\nconst PROVIDER_DEFINED_TOOL_SYMBOL = Symbol('provider_defined_tool');\nconst TOOL_ERROR_SYMBOL = Symbol('tool_error');\nconst HANDOFF_SYMBOL = Symbol('handoff');\n\nexport type JSONValue = null | string | number | boolean | JSONObject | JSONArray;\n\nexport type JSONArray = JSONValue[];\n\nexport type JSONObject = {\n [key: string]: JSONValue;\n};\n\n// Supports both Zod v3 and v4 schemas, as well as raw JSON schema\n// Adapted from Vercel AI SDK's FlexibleSchema approach\n// Source: https://github.com/vercel/ai/blob/main/packages/provider-utils/src/schema.ts#L67-L70\n//\n// Vercel uses StandardSchemaV1 from @standard-schema/spec package.\n// We use a simpler approach by directly checking for schema properties:\n// - Zod v3: Has `_output` property\n// - Zod v4: Implements Standard Schema spec with `~standard` property\n// - JSON Schema: Plain object fallback\nexport type ToolInputSchema<T = JSONObject> =\n | {\n // Zod v3 schema - has _output property for type inference\n _output: T;\n }\n | {\n // Zod v4 schema (Standard Schema) - has ~standard property\n '~standard': {\n types?: { output: T };\n };\n }\n | JSONSchema7;\n\n/**\n * Infer the output type from a ToolInputSchema.\n * Adapted from Vercel AI SDK's InferSchema type.\n * Source: https://github.com/vercel/ai/blob/main/packages/provider-utils/src/schema.ts#L72-L79\n */\nexport type InferToolInput<T> = T extends { _output: infer O }\n ? O\n : T extends { '~standard': { types?: { output: infer O } } }\n ? O\n : any; // eslint-disable-line @typescript-eslint/no-explicit-any -- Fallback type for JSON Schema objects without type inference\n\nexport type ToolType = 'function' | 'provider-defined';\n\nexport type ToolChoice =\n | 'auto'\n | 'none'\n | 'required'\n | {\n type: 'function';\n function: {\n name: string;\n };\n };\n\nexport class ToolError extends Error {\n constructor(message: string) {\n super(message);\n\n Object.defineProperty(this, TOOL_ERROR_SYMBOL, {\n value: true,\n });\n }\n}\n\nexport interface AgentHandoff {\n /**\n * The agent to handoff to.\n */\n agent: Agent;\n\n /**\n * The return value of the tool.\n */\n returns?: any; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n [HANDOFF_SYMBOL]: true;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function handoff(options: { agent: Agent; returns?: any }): AgentHandoff {\n return {\n agent: options.agent,\n returns: options.returns,\n [HANDOFF_SYMBOL]: true,\n };\n}\n\nexport interface ToolOptions<UserData = UnknownUserData> {\n /**\n * RunContext for the current agent session.\n */\n ctx: RunContext<UserData>;\n\n /**\n * The ID of the tool call.\n */\n toolCallId: string;\n\n /**\n * An optional abort signal that indicates that the overall operation should be aborted.\n */\n abortSignal?: AbortSignal;\n}\n\nexport type ToolExecuteFunction<\n Parameters extends JSONObject,\n UserData = UnknownUserData,\n Result = unknown,\n> = (args: Parameters, opts: ToolOptions<UserData>) => Promise<Result>;\n\nexport interface Tool {\n /**\n * The type of the tool.\n * @internal Either user-defined core tool or provider-defined tool.\n */\n type: ToolType;\n\n [TOOL_SYMBOL]: true;\n}\n\n// TODO(AJS-112): support provider-defined tools\nexport interface ProviderDefinedTool extends Tool {\n type: 'provider-defined';\n\n /**\n * The ID of the tool.\n */\n id: string;\n\n /**\n * The configuration of the tool.\n */\n config: Record<string, unknown>;\n\n [PROVIDER_DEFINED_TOOL_SYMBOL]: true;\n}\n\nexport interface FunctionTool<\n Parameters extends JSONObject,\n UserData = UnknownUserData,\n Result = unknown,\n> extends Tool {\n type: 'function';\n\n /**\n * The description of the tool. Will be used by the language model to decide whether to use the tool.\n */\n description: string;\n\n /**\n * The schema of the input that the tool expects. The language model will use this to generate the input.\n * It is also used to validate the output of the language model.\n * Use descriptions to make the input understandable for the language model.\n */\n parameters: ToolInputSchema<Parameters>;\n\n /**\n * An async function that is called with the arguments from the tool call and produces a result.\n * It also carries context about current session, user-defined data, and the tool call id, etc.\n */\n execute: ToolExecuteFunction<Parameters, UserData, Result>;\n\n [FUNCTION_TOOL_SYMBOL]: true;\n}\n\n// TODO(AJS-112): support provider-defined tools in the future)\nexport type ToolContext<UserData = UnknownUserData> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Generic tool registry needs to accept any parameter/result types\n [name: string]: FunctionTool<any, UserData, any>;\n};\n\nexport function isSameToolContext(ctx1: ToolContext, ctx2: ToolContext): boolean {\n const toolNames = new Set(Object.keys(ctx1));\n const toolNames2 = new Set(Object.keys(ctx2));\n\n if (toolNames.size !== toolNames2.size) {\n return false;\n }\n\n for (const name of toolNames) {\n if (!toolNames2.has(name)) {\n return false;\n }\n\n const tool1 = ctx1[name];\n const tool2 = ctx2[name];\n\n if (!tool1 || !tool2) {\n return false;\n }\n\n if (tool1.description !== tool2.description) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function isSameToolChoice(choice1: ToolChoice | null, choice2: ToolChoice | null): boolean {\n if (choice1 === choice2) {\n return true;\n }\n if (choice1 === null || choice2 === null) {\n return false;\n }\n if (typeof choice1 === 'string' && typeof choice2 === 'string') {\n return choice1 === choice2;\n }\n if (typeof choice1 === 'object' && typeof choice2 === 'object') {\n return choice1.type === choice2.type && choice1.function.name === choice2.function.name;\n }\n return false;\n}\n\n/**\n * Create a function tool with inferred parameters from the schema.\n */\nexport function tool<\n Schema extends ToolInputSchema<any>, // eslint-disable-line @typescript-eslint/no-explicit-any -- Generic constraint needs to accept any JSONObject type\n UserData = UnknownUserData,\n Result = unknown,\n>({\n description,\n parameters,\n execute,\n}: {\n description: string;\n parameters: Schema;\n execute: ToolExecuteFunction<InferToolInput<Schema>, UserData, Result>;\n}): FunctionTool<InferToolInput<Schema>, UserData, Result>;\n\n/**\n * Create a function tool without parameters.\n */\nexport function tool<UserData = UnknownUserData, Result = unknown>({\n description,\n execute,\n}: {\n description: string;\n parameters?: never;\n execute: ToolExecuteFunction<Record<string, never>, UserData, Result>;\n}): FunctionTool<Record<string, never>, UserData, Result>;\n\n/**\n * Create a provider-defined tool.\n *\n * @param id - The ID of the tool.\n * @param config - The configuration of the tool.\n */\nexport function tool({\n id,\n config,\n}: {\n id: string;\n config: Record<string, unknown>;\n}): ProviderDefinedTool;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function tool(tool: any): any {\n if (tool.execute !== undefined) {\n // Default parameters to z.object({}) if not provided\n const parameters = tool.parameters ?? z.object({});\n\n // if parameters is a Zod schema, ensure it's an object schema\n if (isZodSchema(parameters) && !isZodObjectSchema(parameters)) {\n throw new Error('Tool parameters must be a Zod object schema (z.object(...))');\n }\n\n // Ensure parameters is either a Zod schema or a plain object (JSON schema)\n if (!isZodSchema(parameters) && !(typeof parameters === 'object')) {\n throw new Error('Tool parameters must be a Zod object schema or a raw JSON schema');\n }\n\n return {\n type: 'function',\n description: tool.description,\n parameters,\n execute: tool.execute,\n [TOOL_SYMBOL]: true,\n [FUNCTION_TOOL_SYMBOL]: true,\n };\n }\n\n if (tool.config !== undefined && tool.id !== undefined) {\n return {\n type: 'provider-defined',\n id: tool.id,\n config: tool.config,\n [TOOL_SYMBOL]: true,\n [PROVIDER_DEFINED_TOOL_SYMBOL]: true,\n };\n }\n\n throw new Error('Invalid tool');\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isTool(tool: any): tool is Tool {\n return tool && tool[TOOL_SYMBOL] === true;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isFunctionTool(tool: any): tool is FunctionTool<any, any, any> {\n const isTool = tool && tool[TOOL_SYMBOL] === true;\n const isFunctionTool = tool[FUNCTION_TOOL_SYMBOL] === true;\n return isTool && isFunctionTool;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isProviderDefinedTool(tool: any): tool is ProviderDefinedTool {\n const isTool = tool && tool[TOOL_SYMBOL] === true;\n const isProviderDefinedTool = tool[PROVIDER_DEFINED_TOOL_SYMBOL] === true;\n return isTool && isProviderDefinedTool;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isToolError(error: any): error is ToolError {\n return error && error[TOOL_ERROR_SYMBOL] === true;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isAgentHandoff(handoff: any): handoff is A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ACtD,SAAOC,WAAUC;AACnB;AAGO,SAAS,sBAAsBF,OAAwC;AAC5E,QAAMC,UAASD,SAAQA,MAAK,WAAW,MAAM;AAC7C,QAAMG,yBAAwBH,MAAK,4BAA4B,MAAM;AACrE,SAAOC,WAAUE;AACnB;AAGO,SAAS,YAAY,OAAgC;AAC1D,SAAO,SAAS,MAAM,iBAAiB,MAAM;AAC/C;AAGO,SAAS,eAAeC,UAAuC;AACpE,SAAOA,YAAWA,SAAQ,cAAc,MAAM;AAChD;","names":["tool","isTool","isFunctionTool","isProviderDefinedTool","handoff"]}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { JSONSchema7 } from 'json-schema';
|
|
2
|
+
import type { Agent } from '../voice/agent.js';
|
|
3
|
+
import type { RunContext, UnknownUserData } from '../voice/run_context.js';
|
|
4
|
+
declare const TOOL_SYMBOL: unique symbol;
|
|
5
|
+
declare const FUNCTION_TOOL_SYMBOL: unique symbol;
|
|
6
|
+
declare const PROVIDER_DEFINED_TOOL_SYMBOL: unique symbol;
|
|
7
|
+
declare const HANDOFF_SYMBOL: unique symbol;
|
|
8
|
+
export type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
|
|
9
|
+
export type JSONArray = JSONValue[];
|
|
10
|
+
export type JSONObject = {
|
|
11
|
+
[key: string]: JSONValue;
|
|
12
|
+
};
|
|
13
|
+
export type ToolInputSchema<T = JSONObject> = {
|
|
14
|
+
_output: T;
|
|
15
|
+
} | {
|
|
16
|
+
'~standard': {
|
|
17
|
+
types?: {
|
|
18
|
+
output: T;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
} | JSONSchema7;
|
|
22
|
+
/**
|
|
23
|
+
* Infer the output type from a ToolInputSchema.
|
|
24
|
+
* Adapted from Vercel AI SDK's InferSchema type.
|
|
25
|
+
* Source: https://github.com/vercel/ai/blob/main/packages/provider-utils/src/schema.ts#L72-L79
|
|
26
|
+
*/
|
|
27
|
+
export type InferToolInput<T> = T extends {
|
|
28
|
+
_output: infer O;
|
|
29
|
+
} ? O : T extends {
|
|
30
|
+
'~standard': {
|
|
31
|
+
types?: {
|
|
32
|
+
output: infer O;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
} ? O : any;
|
|
36
|
+
export type ToolType = 'function' | 'provider-defined';
|
|
37
|
+
export type ToolChoice = 'auto' | 'none' | 'required' | {
|
|
38
|
+
type: 'function';
|
|
39
|
+
function: {
|
|
40
|
+
name: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare class ToolError extends Error {
|
|
44
|
+
constructor(message: string);
|
|
45
|
+
}
|
|
46
|
+
export interface AgentHandoff {
|
|
47
|
+
/**
|
|
48
|
+
* The agent to handoff to.
|
|
49
|
+
*/
|
|
50
|
+
agent: Agent;
|
|
51
|
+
/**
|
|
52
|
+
* The return value of the tool.
|
|
53
|
+
*/
|
|
54
|
+
returns?: any;
|
|
55
|
+
[HANDOFF_SYMBOL]: true;
|
|
56
|
+
}
|
|
57
|
+
export declare function handoff(options: {
|
|
58
|
+
agent: Agent;
|
|
59
|
+
returns?: any;
|
|
60
|
+
}): AgentHandoff;
|
|
61
|
+
export interface ToolOptions<UserData = UnknownUserData> {
|
|
62
|
+
/**
|
|
63
|
+
* RunContext for the current agent session.
|
|
64
|
+
*/
|
|
65
|
+
ctx: RunContext<UserData>;
|
|
66
|
+
/**
|
|
67
|
+
* The ID of the tool call.
|
|
68
|
+
*/
|
|
69
|
+
toolCallId: string;
|
|
70
|
+
/**
|
|
71
|
+
* An optional abort signal that indicates that the overall operation should be aborted.
|
|
72
|
+
*/
|
|
73
|
+
abortSignal?: AbortSignal;
|
|
74
|
+
}
|
|
75
|
+
export type ToolExecuteFunction<Parameters extends JSONObject, UserData = UnknownUserData, Result = unknown> = (args: Parameters, opts: ToolOptions<UserData>) => Promise<Result>;
|
|
76
|
+
export interface Tool {
|
|
77
|
+
/**
|
|
78
|
+
* The type of the tool.
|
|
79
|
+
* @internal Either user-defined core tool or provider-defined tool.
|
|
80
|
+
*/
|
|
81
|
+
type: ToolType;
|
|
82
|
+
[TOOL_SYMBOL]: true;
|
|
83
|
+
}
|
|
84
|
+
export interface ProviderDefinedTool extends Tool {
|
|
85
|
+
type: 'provider-defined';
|
|
86
|
+
/**
|
|
87
|
+
* The ID of the tool.
|
|
88
|
+
*/
|
|
89
|
+
id: string;
|
|
90
|
+
/**
|
|
91
|
+
* The configuration of the tool.
|
|
92
|
+
*/
|
|
93
|
+
config: Record<string, unknown>;
|
|
94
|
+
[PROVIDER_DEFINED_TOOL_SYMBOL]: true;
|
|
95
|
+
}
|
|
96
|
+
export interface FunctionTool<Parameters extends JSONObject, UserData = UnknownUserData, Result = unknown> extends Tool {
|
|
97
|
+
type: 'function';
|
|
98
|
+
/**
|
|
99
|
+
* The description of the tool. Will be used by the language model to decide whether to use the tool.
|
|
100
|
+
*/
|
|
101
|
+
description: string;
|
|
102
|
+
/**
|
|
103
|
+
* The schema of the input that the tool expects. The language model will use this to generate the input.
|
|
104
|
+
* It is also used to validate the output of the language model.
|
|
105
|
+
* Use descriptions to make the input understandable for the language model.
|
|
106
|
+
*/
|
|
107
|
+
parameters: ToolInputSchema<Parameters>;
|
|
108
|
+
/**
|
|
109
|
+
* An async function that is called with the arguments from the tool call and produces a result.
|
|
110
|
+
* It also carries context about current session, user-defined data, and the tool call id, etc.
|
|
111
|
+
*/
|
|
112
|
+
execute: ToolExecuteFunction<Parameters, UserData, Result>;
|
|
113
|
+
[FUNCTION_TOOL_SYMBOL]: true;
|
|
114
|
+
}
|
|
115
|
+
export type ToolContext<UserData = UnknownUserData> = {
|
|
116
|
+
[name: string]: FunctionTool<any, UserData, any>;
|
|
117
|
+
};
|
|
118
|
+
export declare function isSameToolContext(ctx1: ToolContext, ctx2: ToolContext): boolean;
|
|
119
|
+
export declare function isSameToolChoice(choice1: ToolChoice | null, choice2: ToolChoice | null): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Create a function tool with inferred parameters from the schema.
|
|
122
|
+
*/
|
|
123
|
+
export declare function tool<Schema extends ToolInputSchema<any>, // eslint-disable-line @typescript-eslint/no-explicit-any -- Generic constraint needs to accept any JSONObject type
|
|
124
|
+
UserData = UnknownUserData, Result = unknown>({ description, parameters, execute, }: {
|
|
125
|
+
description: string;
|
|
126
|
+
parameters: Schema;
|
|
127
|
+
execute: ToolExecuteFunction<InferToolInput<Schema>, UserData, Result>;
|
|
128
|
+
}): FunctionTool<InferToolInput<Schema>, UserData, Result>;
|
|
129
|
+
/**
|
|
130
|
+
* Create a function tool without parameters.
|
|
131
|
+
*/
|
|
132
|
+
export declare function tool<UserData = UnknownUserData, Result = unknown>({ description, execute, }: {
|
|
133
|
+
description: string;
|
|
134
|
+
parameters?: never;
|
|
135
|
+
execute: ToolExecuteFunction<Record<string, never>, UserData, Result>;
|
|
136
|
+
}): FunctionTool<Record<string, never>, UserData, Result>;
|
|
137
|
+
/**
|
|
138
|
+
* Create a provider-defined tool.
|
|
139
|
+
*
|
|
140
|
+
* @param id - The ID of the tool.
|
|
141
|
+
* @param config - The configuration of the tool.
|
|
142
|
+
*/
|
|
143
|
+
export declare function tool({ id, config, }: {
|
|
144
|
+
id: string;
|
|
145
|
+
config: Record<string, unknown>;
|
|
146
|
+
}): ProviderDefinedTool;
|
|
147
|
+
export declare function isTool(tool: any): tool is Tool;
|
|
148
|
+
export declare function isFunctionTool(tool: any): tool is FunctionTool<any, any, any>;
|
|
149
|
+
export declare function isProviderDefinedTool(tool: any): tool is ProviderDefinedTool;
|
|
150
|
+
export declare function isToolError(error: any): error is ToolError;
|
|
151
|
+
export declare function isAgentHandoff(handoff: any): handoff is AgentHandoff;
|
|
152
|
+
export {};
|
|
153
|
+
//# sourceMappingURL=tool_context.d.ts.map
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { JSONSchema7 } from 'json-schema';
|
|
2
|
+
import type { Agent } from '../voice/agent.js';
|
|
3
|
+
import type { RunContext, UnknownUserData } from '../voice/run_context.js';
|
|
4
|
+
declare const TOOL_SYMBOL: unique symbol;
|
|
5
|
+
declare const FUNCTION_TOOL_SYMBOL: unique symbol;
|
|
6
|
+
declare const PROVIDER_DEFINED_TOOL_SYMBOL: unique symbol;
|
|
7
|
+
declare const HANDOFF_SYMBOL: unique symbol;
|
|
8
|
+
export type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
|
|
9
|
+
export type JSONArray = JSONValue[];
|
|
10
|
+
export type JSONObject = {
|
|
11
|
+
[key: string]: JSONValue;
|
|
12
|
+
};
|
|
13
|
+
export type ToolInputSchema<T = JSONObject> = {
|
|
14
|
+
_output: T;
|
|
15
|
+
} | {
|
|
16
|
+
'~standard': {
|
|
17
|
+
types?: {
|
|
18
|
+
output: T;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
} | JSONSchema7;
|
|
22
|
+
/**
|
|
23
|
+
* Infer the output type from a ToolInputSchema.
|
|
24
|
+
* Adapted from Vercel AI SDK's InferSchema type.
|
|
25
|
+
* Source: https://github.com/vercel/ai/blob/main/packages/provider-utils/src/schema.ts#L72-L79
|
|
26
|
+
*/
|
|
27
|
+
export type InferToolInput<T> = T extends {
|
|
28
|
+
_output: infer O;
|
|
29
|
+
} ? O : T extends {
|
|
30
|
+
'~standard': {
|
|
31
|
+
types?: {
|
|
32
|
+
output: infer O;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
} ? O : any;
|
|
36
|
+
export type ToolType = 'function' | 'provider-defined';
|
|
37
|
+
export type ToolChoice = 'auto' | 'none' | 'required' | {
|
|
38
|
+
type: 'function';
|
|
39
|
+
function: {
|
|
40
|
+
name: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare class ToolError extends Error {
|
|
44
|
+
constructor(message: string);
|
|
45
|
+
}
|
|
46
|
+
export interface AgentHandoff {
|
|
47
|
+
/**
|
|
48
|
+
* The agent to handoff to.
|
|
49
|
+
*/
|
|
50
|
+
agent: Agent;
|
|
51
|
+
/**
|
|
52
|
+
* The return value of the tool.
|
|
53
|
+
*/
|
|
54
|
+
returns?: any;
|
|
55
|
+
[HANDOFF_SYMBOL]: true;
|
|
56
|
+
}
|
|
57
|
+
export declare function handoff(options: {
|
|
58
|
+
agent: Agent;
|
|
59
|
+
returns?: any;
|
|
60
|
+
}): AgentHandoff;
|
|
61
|
+
export interface ToolOptions<UserData = UnknownUserData> {
|
|
62
|
+
/**
|
|
63
|
+
* RunContext for the current agent session.
|
|
64
|
+
*/
|
|
65
|
+
ctx: RunContext<UserData>;
|
|
66
|
+
/**
|
|
67
|
+
* The ID of the tool call.
|
|
68
|
+
*/
|
|
69
|
+
toolCallId: string;
|
|
70
|
+
/**
|
|
71
|
+
* An optional abort signal that indicates that the overall operation should be aborted.
|
|
72
|
+
*/
|
|
73
|
+
abortSignal?: AbortSignal;
|
|
74
|
+
}
|
|
75
|
+
export type ToolExecuteFunction<Parameters extends JSONObject, UserData = UnknownUserData, Result = unknown> = (args: Parameters, opts: ToolOptions<UserData>) => Promise<Result>;
|
|
76
|
+
export interface Tool {
|
|
77
|
+
/**
|
|
78
|
+
* The type of the tool.
|
|
79
|
+
* @internal Either user-defined core tool or provider-defined tool.
|
|
80
|
+
*/
|
|
81
|
+
type: ToolType;
|
|
82
|
+
[TOOL_SYMBOL]: true;
|
|
83
|
+
}
|
|
84
|
+
export interface ProviderDefinedTool extends Tool {
|
|
85
|
+
type: 'provider-defined';
|
|
86
|
+
/**
|
|
87
|
+
* The ID of the tool.
|
|
88
|
+
*/
|
|
89
|
+
id: string;
|
|
90
|
+
/**
|
|
91
|
+
* The configuration of the tool.
|
|
92
|
+
*/
|
|
93
|
+
config: Record<string, unknown>;
|
|
94
|
+
[PROVIDER_DEFINED_TOOL_SYMBOL]: true;
|
|
95
|
+
}
|
|
96
|
+
export interface FunctionTool<Parameters extends JSONObject, UserData = UnknownUserData, Result = unknown> extends Tool {
|
|
97
|
+
type: 'function';
|
|
98
|
+
/**
|
|
99
|
+
* The description of the tool. Will be used by the language model to decide whether to use the tool.
|
|
100
|
+
*/
|
|
101
|
+
description: string;
|
|
102
|
+
/**
|
|
103
|
+
* The schema of the input that the tool expects. The language model will use this to generate the input.
|
|
104
|
+
* It is also used to validate the output of the language model.
|
|
105
|
+
* Use descriptions to make the input understandable for the language model.
|
|
106
|
+
*/
|
|
107
|
+
parameters: ToolInputSchema<Parameters>;
|
|
108
|
+
/**
|
|
109
|
+
* An async function that is called with the arguments from the tool call and produces a result.
|
|
110
|
+
* It also carries context about current session, user-defined data, and the tool call id, etc.
|
|
111
|
+
*/
|
|
112
|
+
execute: ToolExecuteFunction<Parameters, UserData, Result>;
|
|
113
|
+
[FUNCTION_TOOL_SYMBOL]: true;
|
|
114
|
+
}
|
|
115
|
+
export type ToolContext<UserData = UnknownUserData> = {
|
|
116
|
+
[name: string]: FunctionTool<any, UserData, any>;
|
|
117
|
+
};
|
|
118
|
+
export declare function isSameToolContext(ctx1: ToolContext, ctx2: ToolContext): boolean;
|
|
119
|
+
export declare function isSameToolChoice(choice1: ToolChoice | null, choice2: ToolChoice | null): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Create a function tool with inferred parameters from the schema.
|
|
122
|
+
*/
|
|
123
|
+
export declare function tool<Schema extends ToolInputSchema<any>, // eslint-disable-line @typescript-eslint/no-explicit-any -- Generic constraint needs to accept any JSONObject type
|
|
124
|
+
UserData = UnknownUserData, Result = unknown>({ description, parameters, execute, }: {
|
|
125
|
+
description: string;
|
|
126
|
+
parameters: Schema;
|
|
127
|
+
execute: ToolExecuteFunction<InferToolInput<Schema>, UserData, Result>;
|
|
128
|
+
}): FunctionTool<InferToolInput<Schema>, UserData, Result>;
|
|
129
|
+
/**
|
|
130
|
+
* Create a function tool without parameters.
|
|
131
|
+
*/
|
|
132
|
+
export declare function tool<UserData = UnknownUserData, Result = unknown>({ description, execute, }: {
|
|
133
|
+
description: string;
|
|
134
|
+
parameters?: never;
|
|
135
|
+
execute: ToolExecuteFunction<Record<string, never>, UserData, Result>;
|
|
136
|
+
}): FunctionTool<Record<string, never>, UserData, Result>;
|
|
137
|
+
/**
|
|
138
|
+
* Create a provider-defined tool.
|
|
139
|
+
*
|
|
140
|
+
* @param id - The ID of the tool.
|
|
141
|
+
* @param config - The configuration of the tool.
|
|
142
|
+
*/
|
|
143
|
+
export declare function tool({ id, config, }: {
|
|
144
|
+
id: string;
|
|
145
|
+
config: Record<string, unknown>;
|
|
146
|
+
}): ProviderDefinedTool;
|
|
147
|
+
export declare function isTool(tool: any): tool is Tool;
|
|
148
|
+
export declare function isFunctionTool(tool: any): tool is FunctionTool<any, any, any>;
|
|
149
|
+
export declare function isProviderDefinedTool(tool: any): tool is ProviderDefinedTool;
|
|
150
|
+
export declare function isToolError(error: any): error is ToolError;
|
|
151
|
+
export declare function isAgentHandoff(handoff: any): handoff is AgentHandoff;
|
|
152
|
+
export {};
|
|
153
|
+
//# sourceMappingURL=tool_context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool_context.d.ts","sourceRoot":"","sources":["../../src/llm/tool_context.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAM3E,QAAA,MAAM,WAAW,eAAiB,CAAC;AACnC,QAAA,MAAM,oBAAoB,eAA0B,CAAC;AACrD,QAAA,MAAM,4BAA4B,eAAkC,CAAC;AAErE,QAAA,MAAM,cAAc,eAAoB,CAAC;AAEzC,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;AAElF,MAAM,MAAM,SAAS,GAAG,SAAS,EAAE,CAAC;AAEpC,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;C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AAI,CAE9C;AAGD,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,IAAI,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAI7E;AAGD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,IAAI,mBAAmB,CAI5E;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,SAAS,CAE1D;AAGD,wBAAgB,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,IAAI,YAAY,CAEpE"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { isZodObjectSchema, isZodSchema } from "./zod-utils.js";
|
|
3
|
+
const TOOL_SYMBOL = Symbol("tool");
|
|
4
|
+
const FUNCTION_TOOL_SYMBOL = Symbol("function_tool");
|
|
5
|
+
const PROVIDER_DEFINED_TOOL_SYMBOL = Symbol("provider_defined_tool");
|
|
6
|
+
const TOOL_ERROR_SYMBOL = Symbol("tool_error");
|
|
7
|
+
const HANDOFF_SYMBOL = Symbol("handoff");
|
|
8
|
+
class ToolError extends Error {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
Object.defineProperty(this, TOOL_ERROR_SYMBOL, {
|
|
12
|
+
value: true
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function handoff(options) {
|
|
17
|
+
return {
|
|
18
|
+
agent: options.agent,
|
|
19
|
+
returns: options.returns,
|
|
20
|
+
[HANDOFF_SYMBOL]: true
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function isSameToolContext(ctx1, ctx2) {
|
|
24
|
+
const toolNames = new Set(Object.keys(ctx1));
|
|
25
|
+
const toolNames2 = new Set(Object.keys(ctx2));
|
|
26
|
+
if (toolNames.size !== toolNames2.size) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
for (const name of toolNames) {
|
|
30
|
+
if (!toolNames2.has(name)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const tool1 = ctx1[name];
|
|
34
|
+
const tool2 = ctx2[name];
|
|
35
|
+
if (!tool1 || !tool2) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
if (tool1.description !== tool2.description) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
function isSameToolChoice(choice1, choice2) {
|
|
45
|
+
if (choice1 === choice2) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
if (choice1 === null || choice2 === null) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
if (typeof choice1 === "string" && typeof choice2 === "string") {
|
|
52
|
+
return choice1 === choice2;
|
|
53
|
+
}
|
|
54
|
+
if (typeof choice1 === "object" && typeof choice2 === "object") {
|
|
55
|
+
return choice1.type === choice2.type && choice1.function.name === choice2.function.name;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
function tool(tool2) {
|
|
60
|
+
if (tool2.execute !== void 0) {
|
|
61
|
+
const parameters = tool2.parameters ?? z.object({});
|
|
62
|
+
if (isZodSchema(parameters) && !isZodObjectSchema(parameters)) {
|
|
63
|
+
throw new Error("Tool parameters must be a Zod object schema (z.object(...))");
|
|
64
|
+
}
|
|
65
|
+
if (!isZodSchema(parameters) && !(typeof parameters === "object")) {
|
|
66
|
+
throw new Error("Tool parameters must be a Zod object schema or a raw JSON schema");
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
type: "function",
|
|
70
|
+
description: tool2.description,
|
|
71
|
+
parameters,
|
|
72
|
+
execute: tool2.execute,
|
|
73
|
+
[TOOL_SYMBOL]: true,
|
|
74
|
+
[FUNCTION_TOOL_SYMBOL]: true
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (tool2.config !== void 0 && tool2.id !== void 0) {
|
|
78
|
+
return {
|
|
79
|
+
type: "provider-defined",
|
|
80
|
+
id: tool2.id,
|
|
81
|
+
config: tool2.config,
|
|
82
|
+
[TOOL_SYMBOL]: true,
|
|
83
|
+
[PROVIDER_DEFINED_TOOL_SYMBOL]: true
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
throw new Error("Invalid tool");
|
|
87
|
+
}
|
|
88
|
+
function isTool(tool2) {
|
|
89
|
+
return tool2 && tool2[TOOL_SYMBOL] === true;
|
|
90
|
+
}
|
|
91
|
+
function isFunctionTool(tool2) {
|
|
92
|
+
const isTool2 = tool2 && tool2[TOOL_SYMBOL] === true;
|
|
93
|
+
const isFunctionTool2 = tool2[FUNCTION_TOOL_SYMBOL] === true;
|
|
94
|
+
return isTool2 && isFunctionTool2;
|
|
95
|
+
}
|
|
96
|
+
function isProviderDefinedTool(tool2) {
|
|
97
|
+
const isTool2 = tool2 && tool2[TOOL_SYMBOL] === true;
|
|
98
|
+
const isProviderDefinedTool2 = tool2[PROVIDER_DEFINED_TOOL_SYMBOL] === true;
|
|
99
|
+
return isTool2 && isProviderDefinedTool2;
|
|
100
|
+
}
|
|
101
|
+
function isToolError(error) {
|
|
102
|
+
return error && error[TOOL_ERROR_SYMBOL] === true;
|
|
103
|
+
}
|
|
104
|
+
function isAgentHandoff(handoff2) {
|
|
105
|
+
return handoff2 && handoff2[HANDOFF_SYMBOL] === true;
|
|
106
|
+
}
|
|
107
|
+
export {
|
|
108
|
+
ToolError,
|
|
109
|
+
handoff,
|
|
110
|
+
isAgentHandoff,
|
|
111
|
+
isFunctionTool,
|
|
112
|
+
isProviderDefinedTool,
|
|
113
|
+
isSameToolChoice,
|
|
114
|
+
isSameToolContext,
|
|
115
|
+
isTool,
|
|
116
|
+
isToolError,
|
|
117
|
+
tool
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=tool_context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/llm/tool_context.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { JSONSchema7 } from 'json-schema';\nimport { z } from 'zod';\nimport type { Agent } from '../voice/agent.js';\nimport type { RunContext, UnknownUserData } from '../voice/run_context.js';\nimport { isZodObjectSchema, isZodSchema } from './zod-utils.js';\n\n// heavily inspired by Vercel AI's `tool()`:\n// https://github.com/vercel/ai/blob/3b0983b/packages/ai/core/tool/tool.ts\n\nconst TOOL_SYMBOL = Symbol('tool');\nconst FUNCTION_TOOL_SYMBOL = Symbol('function_tool');\nconst PROVIDER_DEFINED_TOOL_SYMBOL = Symbol('provider_defined_tool');\nconst TOOL_ERROR_SYMBOL = Symbol('tool_error');\nconst HANDOFF_SYMBOL = Symbol('handoff');\n\nexport type JSONValue = null | string | number | boolean | JSONObject | JSONArray;\n\nexport type JSONArray = JSONValue[];\n\nexport type JSONObject = {\n [key: string]: JSONValue;\n};\n\n// Supports both Zod v3 and v4 schemas, as well as raw JSON schema\n// Adapted from Vercel AI SDK's FlexibleSchema approach\n// Source: https://github.com/vercel/ai/blob/main/packages/provider-utils/src/schema.ts#L67-L70\n//\n// Vercel uses StandardSchemaV1 from @standard-schema/spec package.\n// We use a simpler approach by directly checking for schema properties:\n// - Zod v3: Has `_output` property\n// - Zod v4: Implements Standard Schema spec with `~standard` property\n// - JSON Schema: Plain object fallback\nexport type ToolInputSchema<T = JSONObject> =\n | {\n // Zod v3 schema - has _output property for type inference\n _output: T;\n }\n | {\n // Zod v4 schema (Standard Schema) - has ~standard property\n '~standard': {\n types?: { output: T };\n };\n }\n | JSONSchema7;\n\n/**\n * Infer the output type from a ToolInputSchema.\n * Adapted from Vercel AI SDK's InferSchema type.\n * Source: https://github.com/vercel/ai/blob/main/packages/provider-utils/src/schema.ts#L72-L79\n */\nexport type InferToolInput<T> = T extends { _output: infer O }\n ? O\n : T extends { '~standard': { types?: { output: infer O } } }\n ? O\n : any; // eslint-disable-line @typescript-eslint/no-explicit-any -- Fallback type for JSON Schema objects without type inference\n\nexport type ToolType = 'function' | 'provider-defined';\n\nexport type ToolChoice =\n | 'auto'\n | 'none'\n | 'required'\n | {\n type: 'function';\n function: {\n name: string;\n };\n };\n\nexport class ToolError extends Error {\n constructor(message: string) {\n super(message);\n\n Object.defineProperty(this, TOOL_ERROR_SYMBOL, {\n value: true,\n });\n }\n}\n\nexport interface AgentHandoff {\n /**\n * The agent to handoff to.\n */\n agent: Agent;\n\n /**\n * The return value of the tool.\n */\n returns?: any; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n [HANDOFF_SYMBOL]: true;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function handoff(options: { agent: Agent; returns?: any }): AgentHandoff {\n return {\n agent: options.agent,\n returns: options.returns,\n [HANDOFF_SYMBOL]: true,\n };\n}\n\nexport interface ToolOptions<UserData = UnknownUserData> {\n /**\n * RunContext for the current agent session.\n */\n ctx: RunContext<UserData>;\n\n /**\n * The ID of the tool call.\n */\n toolCallId: string;\n\n /**\n * An optional abort signal that indicates that the overall operation should be aborted.\n */\n abortSignal?: AbortSignal;\n}\n\nexport type ToolExecuteFunction<\n Parameters extends JSONObject,\n UserData = UnknownUserData,\n Result = unknown,\n> = (args: Parameters, opts: ToolOptions<UserData>) => Promise<Result>;\n\nexport interface Tool {\n /**\n * The type of the tool.\n * @internal Either user-defined core tool or provider-defined tool.\n */\n type: ToolType;\n\n [TOOL_SYMBOL]: true;\n}\n\n// TODO(AJS-112): support provider-defined tools\nexport interface ProviderDefinedTool extends Tool {\n type: 'provider-defined';\n\n /**\n * The ID of the tool.\n */\n id: string;\n\n /**\n * The configuration of the tool.\n */\n config: Record<string, unknown>;\n\n [PROVIDER_DEFINED_TOOL_SYMBOL]: true;\n}\n\nexport interface FunctionTool<\n Parameters extends JSONObject,\n UserData = UnknownUserData,\n Result = unknown,\n> extends Tool {\n type: 'function';\n\n /**\n * The description of the tool. Will be used by the language model to decide whether to use the tool.\n */\n description: string;\n\n /**\n * The schema of the input that the tool expects. The language model will use this to generate the input.\n * It is also used to validate the output of the language model.\n * Use descriptions to make the input understandable for the language model.\n */\n parameters: ToolInputSchema<Parameters>;\n\n /**\n * An async function that is called with the arguments from the tool call and produces a result.\n * It also carries context about current session, user-defined data, and the tool call id, etc.\n */\n execute: ToolExecuteFunction<Parameters, UserData, Result>;\n\n [FUNCTION_TOOL_SYMBOL]: true;\n}\n\n// TODO(AJS-112): support provider-defined tools in the future)\nexport type ToolContext<UserData = UnknownUserData> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Generic tool registry needs to accept any parameter/result types\n [name: string]: FunctionTool<any, UserData, any>;\n};\n\nexport function isSameToolContext(ctx1: ToolContext, ctx2: ToolContext): boolean {\n const toolNames = new Set(Object.keys(ctx1));\n const toolNames2 = new Set(Object.keys(ctx2));\n\n if (toolNames.size !== toolNames2.size) {\n return false;\n }\n\n for (const name of toolNames) {\n if (!toolNames2.has(name)) {\n return false;\n }\n\n const tool1 = ctx1[name];\n const tool2 = ctx2[name];\n\n if (!tool1 || !tool2) {\n return false;\n }\n\n if (tool1.description !== tool2.description) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function isSameToolChoice(choice1: ToolChoice | null, choice2: ToolChoice | null): boolean {\n if (choice1 === choice2) {\n return true;\n }\n if (choice1 === null || choice2 === null) {\n return false;\n }\n if (typeof choice1 === 'string' && typeof choice2 === 'string') {\n return choice1 === choice2;\n }\n if (typeof choice1 === 'object' && typeof choice2 === 'object') {\n return choice1.type === choice2.type && choice1.function.name === choice2.function.name;\n }\n return false;\n}\n\n/**\n * Create a function tool with inferred parameters from the schema.\n */\nexport function tool<\n Schema extends ToolInputSchema<any>, // eslint-disable-line @typescript-eslint/no-explicit-any -- Generic constraint needs to accept any JSONObject type\n UserData = UnknownUserData,\n Result = unknown,\n>({\n description,\n parameters,\n execute,\n}: {\n description: string;\n parameters: Schema;\n execute: ToolExecuteFunction<InferToolInput<Schema>, UserData, Result>;\n}): FunctionTool<InferToolInput<Schema>, UserData, Result>;\n\n/**\n * Create a function tool without parameters.\n */\nexport function tool<UserData = UnknownUserData, Result = unknown>({\n description,\n execute,\n}: {\n description: string;\n parameters?: never;\n execute: ToolExecuteFunction<Record<string, never>, UserData, Result>;\n}): FunctionTool<Record<string, never>, UserData, Result>;\n\n/**\n * Create a provider-defined tool.\n *\n * @param id - The ID of the tool.\n * @param config - The configuration of the tool.\n */\nexport function tool({\n id,\n config,\n}: {\n id: string;\n config: Record<string, unknown>;\n}): ProviderDefinedTool;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function tool(tool: any): any {\n if (tool.execute !== undefined) {\n // Default parameters to z.object({}) if not provided\n const parameters = tool.parameters ?? z.object({});\n\n // if parameters is a Zod schema, ensure it's an object schema\n if (isZodSchema(parameters) && !isZodObjectSchema(parameters)) {\n throw new Error('Tool parameters must be a Zod object schema (z.object(...))');\n }\n\n // Ensure parameters is either a Zod schema or a plain object (JSON schema)\n if (!isZodSchema(parameters) && !(typeof parameters === 'object')) {\n throw new Error('Tool parameters must be a Zod object schema or a raw JSON schema');\n }\n\n return {\n type: 'function',\n description: tool.description,\n parameters,\n execute: tool.execute,\n [TOOL_SYMBOL]: true,\n [FUNCTION_TOOL_SYMBOL]: true,\n };\n }\n\n if (tool.config !== undefined && tool.id !== undefined) {\n return {\n type: 'provider-defined',\n id: tool.id,\n config: tool.config,\n [TOOL_SYMBOL]: true,\n [PROVIDER_DEFINED_TOOL_SYMBOL]: true,\n };\n }\n\n throw new Error('Invalid tool');\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isTool(tool: any): tool is Tool {\n return tool && tool[TOOL_SYMBOL] === true;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isFunctionTool(tool: any): tool is FunctionTool<any, any, any> {\n const isTool = tool && tool[TOOL_SYMBOL] === true;\n const isFunctionTool = tool[FUNCTION_TOOL_SYMBOL] === true;\n return isTool && isFunctionTool;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isProviderDefinedTool(tool: any): tool is ProviderDefinedTool {\n const isTool = tool && tool[TOOL_SYMBOL] === true;\n const isProviderDefinedTool = tool[PROVIDER_DEFINED_TOOL_SYMBOL] === true;\n return isTool && isProviderDefinedTool;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isToolError(error: any): error is ToolError {\n return error && error[TOOL_ERROR_SYMBOL] === true;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isAgentHandoff(handoff: any): handoff is AgentHandoff {\n return handoff && handoff[HANDOFF_SYMBOL] === true;\n}\n"],"mappings":"AAIA,SAAS,SAAS;AAGlB,SAAS,mBAAmB,mBAAmB;AAK/C,MAAM,cAAc,OAAO,MAAM;AACjC,MAAM,uBAAuB,OAAO,eAAe;AACnD,MAAM,+BAA+B,OAAO,uBAAuB;AACnE,MAAM,oBAAoB,OAAO,YAAY;AAC7C,MAAM,iBAAiB,OAAO,SAAS;AAwDhC,MAAM,kBAAkB,MAAM;AAAA,EACnC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AAEb,WAAO,eAAe,MAAM,mBAAmB;AAAA,MAC7C,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;AAiBO,SAAS,QAAQ,SAAwD;AAC9E,SAAO;AAAA,IACL,OAAO,QAAQ;AAAA,IACf,SAAS,QAAQ;AAAA,IACjB,CAAC,cAAc,GAAG;AAAA,EACpB;AACF;AAsFO,SAAS,kBAAkB,MAAmB,MAA4B;AAC/E,QAAM,YAAY,IAAI,IAAI,OAAO,KAAK,IAAI,CAAC;AAC3C,QAAM,aAAa,IAAI,IAAI,OAAO,KAAK,IAAI,CAAC;AAE5C,MAAI,UAAU,SAAS,WAAW,MAAM;AACtC,WAAO;AAAA,EACT;AAEA,aAAW,QAAQ,WAAW;AAC5B,QAAI,CAAC,WAAW,IAAI,IAAI,GAAG;AACzB,aAAO;AAAA,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