@livekit/agents 1.1.0-dev.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +2 -0
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/constants.cjs +3 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +1 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -0
- package/dist/constants.js.map +1 -1
- package/dist/cpu.cjs +189 -0
- package/dist/cpu.cjs.map +1 -0
- package/dist/cpu.d.cts +24 -0
- package/dist/cpu.d.ts +24 -0
- package/dist/cpu.d.ts.map +1 -0
- package/dist/cpu.js +152 -0
- package/dist/cpu.js.map +1 -0
- package/dist/cpu.test.cjs +227 -0
- package/dist/cpu.test.cjs.map +1 -0
- package/dist/cpu.test.js +204 -0
- package/dist/cpu.test.js.map +1 -0
- package/dist/index.cjs +12 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -10
- package/dist/index.js.map +1 -1
- package/dist/inference/interruption/defaults.cjs +1 -1
- package/dist/inference/interruption/defaults.cjs.map +1 -1
- package/dist/inference/interruption/defaults.d.cts +1 -1
- package/dist/inference/interruption/defaults.d.ts +1 -1
- package/dist/inference/interruption/defaults.d.ts.map +1 -1
- package/dist/inference/interruption/defaults.js +1 -1
- package/dist/inference/interruption/defaults.js.map +1 -1
- package/dist/inference/interruption/http_transport.cjs +44 -28
- package/dist/inference/interruption/http_transport.cjs.map +1 -1
- package/dist/inference/interruption/http_transport.d.ts.map +1 -1
- package/dist/inference/interruption/http_transport.js +45 -29
- package/dist/inference/interruption/http_transport.js.map +1 -1
- package/dist/inference/interruption/interruption_detector.cjs +22 -5
- package/dist/inference/interruption/interruption_detector.cjs.map +1 -1
- package/dist/inference/interruption/interruption_detector.d.cts +2 -2
- package/dist/inference/interruption/interruption_detector.d.ts +2 -2
- package/dist/inference/interruption/interruption_detector.d.ts.map +1 -1
- package/dist/inference/interruption/interruption_detector.js +22 -5
- package/dist/inference/interruption/interruption_detector.js.map +1 -1
- package/dist/inference/interruption/interruption_stream.cjs +4 -4
- package/dist/inference/interruption/interruption_stream.cjs.map +1 -1
- package/dist/inference/interruption/interruption_stream.js +4 -4
- package/dist/inference/interruption/interruption_stream.js.map +1 -1
- package/dist/inference/interruption/types.cjs.map +1 -1
- package/dist/inference/interruption/types.d.cts +2 -2
- package/dist/inference/interruption/types.d.ts +2 -2
- package/dist/inference/interruption/types.d.ts.map +1 -1
- package/dist/inference/interruption/ws_transport.cjs +60 -47
- package/dist/inference/interruption/ws_transport.cjs.map +1 -1
- package/dist/inference/interruption/ws_transport.d.ts.map +1 -1
- package/dist/inference/interruption/ws_transport.js +60 -47
- package/dist/inference/interruption/ws_transport.js.map +1 -1
- package/dist/inference/llm.cjs.map +1 -1
- package/dist/inference/llm.d.cts +1 -1
- package/dist/inference/llm.d.ts +1 -1
- package/dist/inference/llm.d.ts.map +1 -1
- package/dist/inference/llm.js.map +1 -1
- package/dist/inference/stt.cjs +20 -12
- package/dist/inference/stt.cjs.map +1 -1
- package/dist/inference/stt.d.cts +3 -2
- package/dist/inference/stt.d.ts +3 -2
- package/dist/inference/stt.d.ts.map +1 -1
- package/dist/inference/stt.js +20 -12
- package/dist/inference/stt.js.map +1 -1
- package/dist/inference/stt.test.cjs +14 -0
- package/dist/inference/stt.test.cjs.map +1 -1
- package/dist/inference/stt.test.js +14 -0
- package/dist/inference/stt.test.js.map +1 -1
- package/dist/inference/tts.cjs +13 -4
- package/dist/inference/tts.cjs.map +1 -1
- package/dist/inference/tts.d.cts +8 -1
- package/dist/inference/tts.d.ts +8 -1
- package/dist/inference/tts.d.ts.map +1 -1
- package/dist/inference/tts.js +13 -4
- package/dist/inference/tts.js.map +1 -1
- package/dist/inference/tts.test.cjs +10 -0
- package/dist/inference/tts.test.cjs.map +1 -1
- package/dist/inference/tts.test.js +10 -0
- package/dist/inference/tts.test.js.map +1 -1
- package/dist/ipc/job_proc_lazy_main.cjs +41 -23
- package/dist/ipc/job_proc_lazy_main.cjs.map +1 -1
- package/dist/ipc/job_proc_lazy_main.js +41 -23
- package/dist/ipc/job_proc_lazy_main.js.map +1 -1
- package/dist/job.cjs +1 -1
- package/dist/job.cjs.map +1 -1
- package/dist/job.js +1 -1
- package/dist/job.js.map +1 -1
- package/dist/language.cjs +394 -0
- package/dist/language.cjs.map +1 -0
- package/dist/language.d.cts +15 -0
- package/dist/language.d.ts +15 -0
- package/dist/language.d.ts.map +1 -0
- package/dist/language.js +363 -0
- package/dist/language.js.map +1 -0
- package/dist/language.test.cjs +43 -0
- package/dist/language.test.cjs.map +1 -0
- package/dist/language.test.js +49 -0
- package/dist/language.test.js.map +1 -0
- package/dist/llm/index.cjs +2 -0
- package/dist/llm/index.cjs.map +1 -1
- package/dist/llm/index.d.cts +1 -1
- package/dist/llm/index.d.ts +1 -1
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +2 -0
- package/dist/llm/index.js.map +1 -1
- package/dist/stream/deferred_stream.cjs +6 -2
- package/dist/stream/deferred_stream.cjs.map +1 -1
- package/dist/stream/deferred_stream.d.ts.map +1 -1
- package/dist/stream/deferred_stream.js +6 -2
- package/dist/stream/deferred_stream.js.map +1 -1
- package/dist/stt/stt.cjs.map +1 -1
- package/dist/stt/stt.d.cts +2 -1
- package/dist/stt/stt.d.ts +2 -1
- package/dist/stt/stt.d.ts.map +1 -1
- package/dist/stt/stt.js.map +1 -1
- package/dist/utils.cjs +15 -0
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +8 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +13 -0
- package/dist/utils.js.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.js +1 -1
- package/dist/voice/agent.cjs +14 -17
- package/dist/voice/agent.cjs.map +1 -1
- package/dist/voice/agent.d.cts +10 -11
- package/dist/voice/agent.d.ts +10 -11
- package/dist/voice/agent.d.ts.map +1 -1
- package/dist/voice/agent.js +15 -18
- package/dist/voice/agent.js.map +1 -1
- package/dist/voice/agent.test.cjs +194 -0
- package/dist/voice/agent.test.cjs.map +1 -1
- package/dist/voice/agent.test.js +195 -1
- package/dist/voice/agent.test.js.map +1 -1
- package/dist/voice/agent_activity.cjs +116 -39
- package/dist/voice/agent_activity.cjs.map +1 -1
- package/dist/voice/agent_activity.d.cts +2 -0
- package/dist/voice/agent_activity.d.ts +2 -0
- package/dist/voice/agent_activity.d.ts.map +1 -1
- package/dist/voice/agent_activity.js +117 -40
- package/dist/voice/agent_activity.js.map +1 -1
- package/dist/voice/agent_activity.test.cjs +135 -0
- package/dist/voice/agent_activity.test.cjs.map +1 -0
- package/dist/voice/agent_activity.test.js +134 -0
- package/dist/voice/agent_activity.test.js.map +1 -0
- package/dist/voice/agent_session.cjs +38 -38
- package/dist/voice/agent_session.cjs.map +1 -1
- package/dist/voice/agent_session.d.cts +65 -56
- package/dist/voice/agent_session.d.ts +65 -56
- package/dist/voice/agent_session.d.ts.map +1 -1
- package/dist/voice/agent_session.js +37 -37
- package/dist/voice/agent_session.js.map +1 -1
- package/dist/voice/audio_recognition.cjs +106 -52
- package/dist/voice/audio_recognition.cjs.map +1 -1
- package/dist/voice/audio_recognition.d.cts +4 -2
- package/dist/voice/audio_recognition.d.ts +4 -2
- package/dist/voice/audio_recognition.d.ts.map +1 -1
- package/dist/voice/audio_recognition.js +106 -52
- package/dist/voice/audio_recognition.js.map +1 -1
- package/dist/voice/audio_recognition_span.test.cjs +84 -22
- package/dist/voice/audio_recognition_span.test.cjs.map +1 -1
- package/dist/voice/audio_recognition_span.test.js +90 -23
- package/dist/voice/audio_recognition_span.test.js.map +1 -1
- package/dist/voice/events.cjs +1 -1
- package/dist/voice/events.cjs.map +1 -1
- package/dist/voice/events.d.cts +4 -3
- package/dist/voice/events.d.ts +4 -3
- package/dist/voice/events.d.ts.map +1 -1
- package/dist/voice/events.js +1 -1
- package/dist/voice/events.js.map +1 -1
- package/dist/voice/index.cjs +9 -1
- package/dist/voice/index.cjs.map +1 -1
- package/dist/voice/index.d.cts +1 -1
- package/dist/voice/index.d.ts +1 -1
- package/dist/voice/index.d.ts.map +1 -1
- package/dist/voice/index.js +10 -1
- package/dist/voice/index.js.map +1 -1
- package/dist/voice/remote_session.cjs +922 -0
- package/dist/voice/remote_session.cjs.map +1 -0
- package/dist/voice/remote_session.d.cts +108 -0
- package/dist/voice/remote_session.d.ts +108 -0
- package/dist/voice/remote_session.d.ts.map +1 -0
- package/dist/voice/remote_session.js +887 -0
- package/dist/voice/remote_session.js.map +1 -0
- package/dist/voice/report.cjs +11 -10
- package/dist/voice/report.cjs.map +1 -1
- package/dist/voice/report.d.cts +5 -3
- package/dist/voice/report.d.ts +5 -3
- package/dist/voice/report.d.ts.map +1 -1
- package/dist/voice/report.js +11 -10
- package/dist/voice/report.js.map +1 -1
- package/dist/voice/report.test.cjs +15 -0
- package/dist/voice/report.test.cjs.map +1 -1
- package/dist/voice/report.test.js +15 -0
- package/dist/voice/report.test.js.map +1 -1
- package/dist/voice/room_io/room_io.cjs +39 -0
- package/dist/voice/room_io/room_io.cjs.map +1 -1
- package/dist/voice/room_io/room_io.d.cts +3 -1
- package/dist/voice/room_io/room_io.d.ts +3 -1
- package/dist/voice/room_io/room_io.d.ts.map +1 -1
- package/dist/voice/room_io/room_io.js +40 -1
- package/dist/voice/room_io/room_io.js.map +1 -1
- package/dist/voice/turn_config/interruption.cjs.map +1 -1
- package/dist/voice/turn_config/interruption.d.cts +1 -1
- package/dist/voice/turn_config/interruption.d.ts +1 -1
- package/dist/voice/turn_config/interruption.d.ts.map +1 -1
- package/dist/voice/turn_config/interruption.js.map +1 -1
- package/dist/voice/turn_config/utils.cjs +95 -35
- package/dist/voice/turn_config/utils.cjs.map +1 -1
- package/dist/voice/turn_config/utils.d.cts +17 -5
- package/dist/voice/turn_config/utils.d.ts +17 -5
- package/dist/voice/turn_config/utils.d.ts.map +1 -1
- package/dist/voice/turn_config/utils.js +93 -35
- package/dist/voice/turn_config/utils.js.map +1 -1
- package/dist/voice/turn_config/utils.test.cjs +83 -41
- package/dist/voice/turn_config/utils.test.cjs.map +1 -1
- package/dist/voice/turn_config/utils.test.js +84 -42
- package/dist/voice/turn_config/utils.test.js.map +1 -1
- package/dist/worker.cjs +6 -29
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +6 -19
- package/dist/worker.js.map +1 -1
- package/package.json +3 -2
- package/src/cli.ts +2 -0
- package/src/constants.ts +1 -0
- package/src/cpu.test.ts +239 -0
- package/src/cpu.ts +173 -0
- package/src/index.ts +13 -15
- package/src/inference/interruption/defaults.ts +1 -1
- package/src/inference/interruption/http_transport.ts +49 -30
- package/src/inference/interruption/interruption_detector.ts +22 -6
- package/src/inference/interruption/interruption_stream.ts +4 -4
- package/src/inference/interruption/types.ts +2 -2
- package/src/inference/interruption/ws_transport.ts +63 -59
- package/src/inference/llm.ts +3 -1
- package/src/inference/stt.test.ts +17 -0
- package/src/inference/stt.ts +22 -14
- package/src/inference/tts.test.ts +12 -0
- package/src/inference/tts.ts +22 -6
- package/src/ipc/job_proc_lazy_main.ts +44 -24
- package/src/job.ts +1 -1
- package/src/language.test.ts +62 -0
- package/src/language.ts +380 -0
- package/src/llm/index.ts +2 -0
- package/src/stream/deferred_stream.ts +5 -1
- package/src/stt/stt.ts +2 -1
- package/src/utils.ts +20 -0
- package/src/voice/agent.test.ts +208 -1
- package/src/voice/agent.ts +21 -22
- package/src/voice/agent_activity.test.ts +194 -0
- package/src/voice/agent_activity.ts +161 -43
- package/src/voice/agent_session.ts +103 -92
- package/src/voice/audio_recognition.ts +124 -61
- package/src/voice/audio_recognition_span.test.ts +115 -35
- package/src/voice/events.ts +4 -3
- package/src/voice/index.ts +10 -1
- package/src/voice/remote_session.ts +1083 -0
- package/src/voice/report.test.ts +22 -3
- package/src/voice/report.ts +31 -14
- package/src/voice/room_io/room_io.ts +52 -2
- package/src/voice/turn_config/interruption.ts +1 -1
- package/src/voice/turn_config/utils.test.ts +91 -43
- package/src/voice/turn_config/utils.ts +120 -56
- package/src/worker.ts +34 -50
- package/dist/voice/client_events.cjs +0 -554
- package/dist/voice/client_events.cjs.map +0 -1
- package/dist/voice/client_events.d.cts +0 -195
- package/dist/voice/client_events.d.ts +0 -195
- package/dist/voice/client_events.d.ts.map +0 -1
- package/dist/voice/client_events.js +0 -548
- package/dist/voice/client_events.js.map +0 -1
- package/dist/voice/wire_format.cjs +0 -798
- package/dist/voice/wire_format.cjs.map +0 -1
- package/dist/voice/wire_format.d.cts +0 -5503
- package/dist/voice/wire_format.d.ts +0 -5503
- package/dist/voice/wire_format.d.ts.map +0 -1
- package/dist/voice/wire_format.js +0 -728
- package/dist/voice/wire_format.js.map +0 -1
- package/src/voice/client_events.ts +0 -838
- package/src/voice/wire_format.ts +0 -827
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/voice/turn_config/utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { log } from '../../log.js';\nimport {\n type AgentSessionOptions,\n type InternalSessionOptions,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/voice/turn_config/utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { log } from '../../log.js';\nimport {\n type AgentSessionOptions,\n type InternalSessionOptions,\n type TurnDetectionMode,\n type VoiceOptions,\n} from '../agent_session.js';\nimport { defaultEndpointingOptions } from './endpointing.js';\nimport { defaultInterruptionOptions } from './interruption.js';\nimport { type TurnHandlingOptions, defaultTurnHandlingOptions } from './turn_handling.js';\n\nconst defaultSessionOptions = {\n maxToolSteps: 3,\n preemptiveGeneration: true,\n userAwayTimeout: 15.0,\n aecWarmupDuration: 3000,\n turnHandling: {},\n useTtsAlignedTranscript: true,\n} as const satisfies AgentSessionOptions;\n\nconst defaultLegacyVoiceOptions: VoiceOptions = {\n minEndpointingDelay: defaultTurnHandlingOptions.endpointing.minDelay,\n maxEndpointingDelay: defaultTurnHandlingOptions.endpointing.maxDelay,\n maxToolSteps: defaultSessionOptions.maxToolSteps,\n preemptiveGeneration: defaultSessionOptions.preemptiveGeneration,\n};\n\nexport function migrateLegacyOptions<UserData>(legacyOptions: AgentSessionOptions<UserData>): {\n agentSessionOptions: InternalSessionOptions<UserData>;\n legacyVoiceOptions: VoiceOptions;\n} {\n const logger = log();\n const {\n voiceOptions,\n turnDetection,\n stt,\n vad,\n llm,\n tts,\n userData,\n connOptions,\n ...sessionOptions\n } = legacyOptions;\n\n if (voiceOptions !== undefined) {\n logger.warn(\n 'voiceOptions is deprecated, use top-level SessionOptions fields on AgentSessionOptions instead',\n );\n }\n\n const turnHandling: TurnHandlingOptions = {\n interruption: {\n discardAudioIfUninterruptible: voiceOptions?.discardAudioIfUninterruptible,\n minDuration: voiceOptions?.minInterruptionDuration,\n minWords: voiceOptions?.minInterruptionWords,\n ...sessionOptions.turnHandling?.interruption,\n },\n endpointing: {\n minDelay: voiceOptions?.minEndpointingDelay,\n maxDelay: voiceOptions?.maxEndpointingDelay,\n ...sessionOptions.turnHandling?.endpointing,\n },\n\n turnDetection: sessionOptions?.turnHandling?.turnDetection ?? turnDetection,\n } as const;\n\n if (\n voiceOptions?.allowInterruptions === false &&\n turnHandling.interruption.enabled === undefined\n ) {\n turnHandling.interruption.enabled = false;\n }\n\n const migratedVoiceOptions: AgentSessionOptions<UserData> = {};\n\n if (voiceOptions?.maxToolSteps !== undefined) {\n migratedVoiceOptions.maxToolSteps = voiceOptions.maxToolSteps;\n }\n if (voiceOptions?.preemptiveGeneration !== undefined) {\n migratedVoiceOptions.preemptiveGeneration = voiceOptions.preemptiveGeneration;\n }\n if (voiceOptions?.userAwayTimeout !== undefined) {\n migratedVoiceOptions.userAwayTimeout = voiceOptions.userAwayTimeout;\n }\n\n const legacyVoiceOptions = { ...defaultLegacyVoiceOptions, ...voiceOptions };\n\n const agentSessionOptions = {\n stt,\n vad,\n llm,\n tts,\n userData,\n connOptions,\n ...defaultSessionOptions,\n ...migratedVoiceOptions,\n ...sessionOptions,\n turnHandling: mergeWithDefaults(turnHandling),\n // repopulate the deprecated voice options with migrated options for backwards compatibility\n voiceOptions: legacyVoiceOptions,\n };\n\n return { agentSessionOptions, legacyVoiceOptions };\n}\n\n/** Remove keys whose value is `undefined` so they don't shadow defaults when spread. */\nexport function stripUndefined<T extends object>(obj: T): Partial<T> {\n return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined)) as Partial<T>;\n}\n\nexport function mergeWithDefaults(config: TurnHandlingOptions) {\n return {\n turnDetection: config.turnDetection ?? defaultTurnHandlingOptions.turnDetection,\n endpointing: { ...defaultEndpointingOptions, ...stripUndefined(config.endpointing) },\n interruption: { ...defaultInterruptionOptions, ...stripUndefined(config.interruption) },\n } as const;\n}\n\n/**\n * Build a partial {@link TurnHandlingOptions} from deprecated Agent constructor fields.\n * Mirrors the Python Agent compatibility path, but keeps the JS API surface explicit.\n */\nexport function migrateTurnHandling(opts: {\n turnDetection?: TurnDetectionMode;\n allowInterruptions?: boolean;\n minEndpointingDelay?: number;\n maxEndpointingDelay?: number;\n turnHandling?: TurnHandlingOptions;\n}): Partial<TurnHandlingOptions> {\n if (opts.turnHandling !== undefined) {\n return opts.turnHandling;\n }\n\n const migrated: Partial<TurnHandlingOptions> = {};\n\n const endpointing: Partial<TurnHandlingOptions['endpointing']> = {};\n if (opts.minEndpointingDelay !== undefined) {\n endpointing.minDelay = opts.minEndpointingDelay;\n }\n if (opts.maxEndpointingDelay !== undefined) {\n endpointing.maxDelay = opts.maxEndpointingDelay;\n }\n if (Object.keys(endpointing).length > 0) {\n migrated.endpointing = endpointing;\n }\n\n const interruption: Partial<TurnHandlingOptions['interruption']> = {};\n if (opts.allowInterruptions === false) {\n interruption.enabled = false;\n }\n if (Object.keys(interruption).length > 0) {\n migrated.interruption = interruption;\n }\n\n if (opts.turnDetection !== undefined) {\n migrated.turnDetection = opts.turnDetection;\n }\n\n return {\n ...(migrated.endpointing ? { endpointing: migrated.endpointing } : {}),\n ...(migrated.interruption ? { interruption: migrated.interruption } : {}),\n ...(migrated.turnDetection !== undefined ? { turnDetection: migrated.turnDetection } : {}),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAoB;AACpB,2BAKO;AACP,yBAA0C;AAC1C,0BAA2C;AAC3C,2BAAqE;AAErE,MAAM,wBAAwB;AAAA,EAC5B,cAAc;AAAA,EACd,sBAAsB;AAAA,EACtB,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,cAAc,CAAC;AAAA,EACf,yBAAyB;AAC3B;AAEA,MAAM,4BAA0C;AAAA,EAC9C,qBAAqB,gDAA2B,YAAY;AAAA,EAC5D,qBAAqB,gDAA2B,YAAY;AAAA,EAC5D,cAAc,sBAAsB;AAAA,EACpC,sBAAsB,sBAAsB;AAC9C;AAEO,SAAS,qBAA+B,eAG7C;AAjCF;AAkCE,QAAM,aAAS,gBAAI;AACnB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAEJ,MAAI,iBAAiB,QAAW;AAC9B,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAEA,QAAM,eAAoC;AAAA,IACxC,cAAc;AAAA,MACZ,+BAA+B,6CAAc;AAAA,MAC7C,aAAa,6CAAc;AAAA,MAC3B,UAAU,6CAAc;AAAA,MACxB,IAAG,oBAAe,iBAAf,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oBAAoB,MAMH;AAC/B,MAAI,KAAK,iBAAiB,QAAW;AACnC,WAAO,KAAK;AAAA,EACd;AAEA,QAAM,WAAyC,CAAC;AAEhD,QAAM,cAA2D,CAAC;AAClE,MAAI,KAAK,wBAAwB,QAAW;AAC1C,gBAAY,WAAW,KAAK;AAAA,EAC9B;AACA,MAAI,KAAK,wBAAwB,QAAW;AAC1C,gBAAY,WAAW,KAAK;AAAA,EAC9B;AACA,MAAI,OAAO,KAAK,WAAW,EAAE,SAAS,GAAG;AACvC,aAAS,cAAc;AAAA,EACzB;AAEA,QAAM,eAA6D,CAAC;AACpE,MAAI,KAAK,uBAAuB,OAAO;AACrC,iBAAa,UAAU;AAAA,EACzB;AACA,MAAI,OAAO,KAAK,YAAY,EAAE,SAAS,GAAG;AACxC,aAAS,eAAe;AAAA,EAC1B;AAEA,MAAI,KAAK,kBAAkB,QAAW;AACpC,aAAS,gBAAgB,KAAK;AAAA,EAChC;AAEA,SAAO;AAAA,IACL,GAAI,SAAS,cAAc,EAAE,aAAa,SAAS,YAAY,IAAI,CAAC;AAAA,IACpE,GAAI,SAAS,eAAe,EAAE,cAAc,SAAS,aAAa,IAAI,CAAC;AAAA,IACvE,GAAI,SAAS,kBAAkB,SAAY,EAAE,eAAe,SAAS,cAAc,IAAI,CAAC;AAAA,EAC1F;AACF;","names":[]}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { type AgentSessionOptions, type InternalSessionOptions } from '../agent_session.js';
|
|
1
|
+
import { type AgentSessionOptions, type InternalSessionOptions, type TurnDetectionMode, type VoiceOptions } from '../agent_session.js';
|
|
2
2
|
import { type TurnHandlingOptions } from './turn_handling.js';
|
|
3
|
-
export declare function migrateLegacyOptions<UserData>(legacyOptions: AgentSessionOptions<UserData>):
|
|
4
|
-
|
|
3
|
+
export declare function migrateLegacyOptions<UserData>(legacyOptions: AgentSessionOptions<UserData>): {
|
|
4
|
+
agentSessionOptions: InternalSessionOptions<UserData>;
|
|
5
|
+
legacyVoiceOptions: VoiceOptions;
|
|
5
6
|
};
|
|
6
7
|
/** Remove keys whose value is `undefined` so they don't shadow defaults when spread. */
|
|
7
8
|
export declare function stripUndefined<T extends object>(obj: T): Partial<T>;
|
|
8
9
|
export declare function mergeWithDefaults(config: TurnHandlingOptions): {
|
|
9
|
-
readonly turnDetection:
|
|
10
|
+
readonly turnDetection: TurnDetectionMode | undefined;
|
|
10
11
|
readonly endpointing: {
|
|
11
12
|
mode: "fixed" | "dynamic";
|
|
12
13
|
minDelay: number;
|
|
@@ -14,7 +15,7 @@ export declare function mergeWithDefaults(config: TurnHandlingOptions): {
|
|
|
14
15
|
};
|
|
15
16
|
readonly interruption: {
|
|
16
17
|
enabled: boolean;
|
|
17
|
-
mode:
|
|
18
|
+
mode: "vad" | "adaptive" | undefined;
|
|
18
19
|
discardAudioIfUninterruptible: boolean;
|
|
19
20
|
minDuration: number;
|
|
20
21
|
minWords: number;
|
|
@@ -22,4 +23,15 @@ export declare function mergeWithDefaults(config: TurnHandlingOptions): {
|
|
|
22
23
|
resumeFalseInterruption: boolean;
|
|
23
24
|
};
|
|
24
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Build a partial {@link TurnHandlingOptions} from deprecated Agent constructor fields.
|
|
28
|
+
* Mirrors the Python Agent compatibility path, but keeps the JS API surface explicit.
|
|
29
|
+
*/
|
|
30
|
+
export declare function migrateTurnHandling(opts: {
|
|
31
|
+
turnDetection?: TurnDetectionMode;
|
|
32
|
+
allowInterruptions?: boolean;
|
|
33
|
+
minEndpointingDelay?: number;
|
|
34
|
+
maxEndpointingDelay?: number;
|
|
35
|
+
turnHandling?: TurnHandlingOptions;
|
|
36
|
+
}): Partial<TurnHandlingOptions>;
|
|
25
37
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { type AgentSessionOptions, type InternalSessionOptions } from '../agent_session.js';
|
|
1
|
+
import { type AgentSessionOptions, type InternalSessionOptions, type TurnDetectionMode, type VoiceOptions } from '../agent_session.js';
|
|
2
2
|
import { type TurnHandlingOptions } from './turn_handling.js';
|
|
3
|
-
export declare function migrateLegacyOptions<UserData>(legacyOptions: AgentSessionOptions<UserData>):
|
|
4
|
-
|
|
3
|
+
export declare function migrateLegacyOptions<UserData>(legacyOptions: AgentSessionOptions<UserData>): {
|
|
4
|
+
agentSessionOptions: InternalSessionOptions<UserData>;
|
|
5
|
+
legacyVoiceOptions: VoiceOptions;
|
|
5
6
|
};
|
|
6
7
|
/** Remove keys whose value is `undefined` so they don't shadow defaults when spread. */
|
|
7
8
|
export declare function stripUndefined<T extends object>(obj: T): Partial<T>;
|
|
8
9
|
export declare function mergeWithDefaults(config: TurnHandlingOptions): {
|
|
9
|
-
readonly turnDetection:
|
|
10
|
+
readonly turnDetection: TurnDetectionMode | undefined;
|
|
10
11
|
readonly endpointing: {
|
|
11
12
|
mode: "fixed" | "dynamic";
|
|
12
13
|
minDelay: number;
|
|
@@ -14,7 +15,7 @@ export declare function mergeWithDefaults(config: TurnHandlingOptions): {
|
|
|
14
15
|
};
|
|
15
16
|
readonly interruption: {
|
|
16
17
|
enabled: boolean;
|
|
17
|
-
mode:
|
|
18
|
+
mode: "vad" | "adaptive" | undefined;
|
|
18
19
|
discardAudioIfUninterruptible: boolean;
|
|
19
20
|
minDuration: number;
|
|
20
21
|
minWords: number;
|
|
@@ -22,4 +23,15 @@ export declare function mergeWithDefaults(config: TurnHandlingOptions): {
|
|
|
22
23
|
resumeFalseInterruption: boolean;
|
|
23
24
|
};
|
|
24
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Build a partial {@link TurnHandlingOptions} from deprecated Agent constructor fields.
|
|
28
|
+
* Mirrors the Python Agent compatibility path, but keeps the JS API surface explicit.
|
|
29
|
+
*/
|
|
30
|
+
export declare function migrateTurnHandling(opts: {
|
|
31
|
+
turnDetection?: TurnDetectionMode;
|
|
32
|
+
allowInterruptions?: boolean;
|
|
33
|
+
minEndpointingDelay?: number;
|
|
34
|
+
maxEndpointingDelay?: number;
|
|
35
|
+
turnHandling?: TurnHandlingOptions;
|
|
36
|
+
}): Partial<TurnHandlingOptions>;
|
|
25
37
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/voice/turn_config/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/voice/turn_config/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAClB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,KAAK,mBAAmB,EAA8B,MAAM,oBAAoB,CAAC;AAkB1F,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,aAAa,EAAE,mBAAmB,CAAC,QAAQ,CAAC,GAAG;IAC5F,mBAAmB,EAAE,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IACtD,kBAAkB,EAAE,YAAY,CAAC;CAClC,CAyEA;AAED,wFAAwF;AACxF,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAEnE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,mBAAmB;;;;;;;;;;;;;;;;EAM5D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAClC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,mBAAmB,CAAC;CACpC,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAmC/B"}
|
|
@@ -1,59 +1,85 @@
|
|
|
1
1
|
import { log } from "../../log.js";
|
|
2
2
|
import {
|
|
3
|
-
defaultSessionOptions
|
|
4
3
|
} from "../agent_session.js";
|
|
5
4
|
import { defaultEndpointingOptions } from "./endpointing.js";
|
|
6
5
|
import { defaultInterruptionOptions } from "./interruption.js";
|
|
7
6
|
import { defaultTurnHandlingOptions } from "./turn_handling.js";
|
|
7
|
+
const defaultSessionOptions = {
|
|
8
|
+
maxToolSteps: 3,
|
|
9
|
+
preemptiveGeneration: true,
|
|
10
|
+
userAwayTimeout: 15,
|
|
11
|
+
aecWarmupDuration: 3e3,
|
|
12
|
+
turnHandling: {},
|
|
13
|
+
useTtsAlignedTranscript: true
|
|
14
|
+
};
|
|
15
|
+
const defaultLegacyVoiceOptions = {
|
|
16
|
+
minEndpointingDelay: defaultTurnHandlingOptions.endpointing.minDelay,
|
|
17
|
+
maxEndpointingDelay: defaultTurnHandlingOptions.endpointing.maxDelay,
|
|
18
|
+
maxToolSteps: defaultSessionOptions.maxToolSteps,
|
|
19
|
+
preemptiveGeneration: defaultSessionOptions.preemptiveGeneration
|
|
20
|
+
};
|
|
8
21
|
function migrateLegacyOptions(legacyOptions) {
|
|
9
|
-
var _a, _b;
|
|
22
|
+
var _a, _b, _c;
|
|
10
23
|
const logger = log();
|
|
11
|
-
const {
|
|
12
|
-
|
|
24
|
+
const {
|
|
25
|
+
voiceOptions,
|
|
26
|
+
turnDetection,
|
|
27
|
+
stt,
|
|
28
|
+
vad,
|
|
29
|
+
llm,
|
|
30
|
+
tts,
|
|
31
|
+
userData,
|
|
32
|
+
connOptions,
|
|
33
|
+
...sessionOptions
|
|
34
|
+
} = legacyOptions;
|
|
35
|
+
if (voiceOptions !== void 0) {
|
|
13
36
|
logger.warn(
|
|
14
|
-
"
|
|
37
|
+
"voiceOptions is deprecated, use top-level SessionOptions fields on AgentSessionOptions instead"
|
|
15
38
|
);
|
|
16
39
|
}
|
|
17
|
-
const originalTurnDetection = ((_a = sessionOptions == null ? void 0 : sessionOptions.turnHandling) == null ? void 0 : _a.turnDetection) ?? ((_b = voiceOptions == null ? void 0 : voiceOptions.turnHandling) == null ? void 0 : _b.turnDetection) ?? turnDetection;
|
|
18
|
-
const cloneableVoiceOptions = voiceOptions ? {
|
|
19
|
-
...voiceOptions,
|
|
20
|
-
turnHandling: voiceOptions.turnHandling ? { ...voiceOptions.turnHandling, turnDetection: void 0 } : voiceOptions.turnHandling
|
|
21
|
-
} : voiceOptions;
|
|
22
|
-
const cloneableSessionOptions = sessionOptions ? {
|
|
23
|
-
...sessionOptions,
|
|
24
|
-
turnHandling: sessionOptions.turnHandling ? { ...sessionOptions.turnHandling, turnDetection: void 0 } : sessionOptions.turnHandling
|
|
25
|
-
} : sessionOptions;
|
|
26
|
-
const mergedOptions = structuredClone({ ...cloneableVoiceOptions, ...cloneableSessionOptions });
|
|
27
40
|
const turnHandling = {
|
|
28
41
|
interruption: {
|
|
29
|
-
discardAudioIfUninterruptible:
|
|
30
|
-
minDuration:
|
|
31
|
-
minWords:
|
|
42
|
+
discardAudioIfUninterruptible: voiceOptions == null ? void 0 : voiceOptions.discardAudioIfUninterruptible,
|
|
43
|
+
minDuration: voiceOptions == null ? void 0 : voiceOptions.minInterruptionDuration,
|
|
44
|
+
minWords: voiceOptions == null ? void 0 : voiceOptions.minInterruptionWords,
|
|
45
|
+
...(_a = sessionOptions.turnHandling) == null ? void 0 : _a.interruption
|
|
32
46
|
},
|
|
33
47
|
endpointing: {
|
|
34
|
-
minDelay:
|
|
35
|
-
maxDelay:
|
|
48
|
+
minDelay: voiceOptions == null ? void 0 : voiceOptions.minEndpointingDelay,
|
|
49
|
+
maxDelay: voiceOptions == null ? void 0 : voiceOptions.maxEndpointingDelay,
|
|
50
|
+
...(_b = sessionOptions.turnHandling) == null ? void 0 : _b.endpointing
|
|
36
51
|
},
|
|
37
|
-
|
|
38
|
-
// Restore original turnDetection after spread to preserve class instance with methods
|
|
39
|
-
// (structuredClone converts class instances to plain objects, losing prototype methods)
|
|
40
|
-
turnDetection: originalTurnDetection
|
|
52
|
+
turnDetection: ((_c = sessionOptions == null ? void 0 : sessionOptions.turnHandling) == null ? void 0 : _c.turnDetection) ?? turnDetection
|
|
41
53
|
};
|
|
42
|
-
if ((
|
|
54
|
+
if ((voiceOptions == null ? void 0 : voiceOptions.allowInterruptions) === false && turnHandling.interruption.enabled === void 0) {
|
|
43
55
|
turnHandling.interruption.enabled = false;
|
|
44
56
|
}
|
|
45
|
-
const
|
|
57
|
+
const migratedVoiceOptions = {};
|
|
58
|
+
if ((voiceOptions == null ? void 0 : voiceOptions.maxToolSteps) !== void 0) {
|
|
59
|
+
migratedVoiceOptions.maxToolSteps = voiceOptions.maxToolSteps;
|
|
60
|
+
}
|
|
61
|
+
if ((voiceOptions == null ? void 0 : voiceOptions.preemptiveGeneration) !== void 0) {
|
|
62
|
+
migratedVoiceOptions.preemptiveGeneration = voiceOptions.preemptiveGeneration;
|
|
63
|
+
}
|
|
64
|
+
if ((voiceOptions == null ? void 0 : voiceOptions.userAwayTimeout) !== void 0) {
|
|
65
|
+
migratedVoiceOptions.userAwayTimeout = voiceOptions.userAwayTimeout;
|
|
66
|
+
}
|
|
67
|
+
const legacyVoiceOptions = { ...defaultLegacyVoiceOptions, ...voiceOptions };
|
|
68
|
+
const agentSessionOptions = {
|
|
69
|
+
stt,
|
|
70
|
+
vad,
|
|
71
|
+
llm,
|
|
72
|
+
tts,
|
|
73
|
+
userData,
|
|
74
|
+
connOptions,
|
|
46
75
|
...defaultSessionOptions,
|
|
47
|
-
...
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
options: optionsWithDefaults,
|
|
53
|
-
voiceOptions: optionsWithDefaults,
|
|
54
|
-
turnDetection: turnHandling.turnDetection
|
|
76
|
+
...migratedVoiceOptions,
|
|
77
|
+
...sessionOptions,
|
|
78
|
+
turnHandling: mergeWithDefaults(turnHandling),
|
|
79
|
+
// repopulate the deprecated voice options with migrated options for backwards compatibility
|
|
80
|
+
voiceOptions: legacyVoiceOptions
|
|
55
81
|
};
|
|
56
|
-
return
|
|
82
|
+
return { agentSessionOptions, legacyVoiceOptions };
|
|
57
83
|
}
|
|
58
84
|
function stripUndefined(obj) {
|
|
59
85
|
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== void 0));
|
|
@@ -65,9 +91,41 @@ function mergeWithDefaults(config) {
|
|
|
65
91
|
interruption: { ...defaultInterruptionOptions, ...stripUndefined(config.interruption) }
|
|
66
92
|
};
|
|
67
93
|
}
|
|
94
|
+
function migrateTurnHandling(opts) {
|
|
95
|
+
if (opts.turnHandling !== void 0) {
|
|
96
|
+
return opts.turnHandling;
|
|
97
|
+
}
|
|
98
|
+
const migrated = {};
|
|
99
|
+
const endpointing = {};
|
|
100
|
+
if (opts.minEndpointingDelay !== void 0) {
|
|
101
|
+
endpointing.minDelay = opts.minEndpointingDelay;
|
|
102
|
+
}
|
|
103
|
+
if (opts.maxEndpointingDelay !== void 0) {
|
|
104
|
+
endpointing.maxDelay = opts.maxEndpointingDelay;
|
|
105
|
+
}
|
|
106
|
+
if (Object.keys(endpointing).length > 0) {
|
|
107
|
+
migrated.endpointing = endpointing;
|
|
108
|
+
}
|
|
109
|
+
const interruption = {};
|
|
110
|
+
if (opts.allowInterruptions === false) {
|
|
111
|
+
interruption.enabled = false;
|
|
112
|
+
}
|
|
113
|
+
if (Object.keys(interruption).length > 0) {
|
|
114
|
+
migrated.interruption = interruption;
|
|
115
|
+
}
|
|
116
|
+
if (opts.turnDetection !== void 0) {
|
|
117
|
+
migrated.turnDetection = opts.turnDetection;
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
...migrated.endpointing ? { endpointing: migrated.endpointing } : {},
|
|
121
|
+
...migrated.interruption ? { interruption: migrated.interruption } : {},
|
|
122
|
+
...migrated.turnDetection !== void 0 ? { turnDetection: migrated.turnDetection } : {}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
68
125
|
export {
|
|
69
126
|
mergeWithDefaults,
|
|
70
127
|
migrateLegacyOptions,
|
|
128
|
+
migrateTurnHandling,
|
|
71
129
|
stripUndefined
|
|
72
130
|
};
|
|
73
131
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/voice/turn_config/utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { log } from '../../log.js';\nimport {\n type AgentSessionOptions,\n type InternalSessionOptions,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/voice/turn_config/utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { log } from '../../log.js';\nimport {\n type AgentSessionOptions,\n type InternalSessionOptions,\n type TurnDetectionMode,\n type VoiceOptions,\n} from '../agent_session.js';\nimport { defaultEndpointingOptions } from './endpointing.js';\nimport { defaultInterruptionOptions } from './interruption.js';\nimport { type TurnHandlingOptions, defaultTurnHandlingOptions } from './turn_handling.js';\n\nconst defaultSessionOptions = {\n maxToolSteps: 3,\n preemptiveGeneration: true,\n userAwayTimeout: 15.0,\n aecWarmupDuration: 3000,\n turnHandling: {},\n useTtsAlignedTranscript: true,\n} as const satisfies AgentSessionOptions;\n\nconst defaultLegacyVoiceOptions: VoiceOptions = {\n minEndpointingDelay: defaultTurnHandlingOptions.endpointing.minDelay,\n maxEndpointingDelay: defaultTurnHandlingOptions.endpointing.maxDelay,\n maxToolSteps: defaultSessionOptions.maxToolSteps,\n preemptiveGeneration: defaultSessionOptions.preemptiveGeneration,\n};\n\nexport function migrateLegacyOptions<UserData>(legacyOptions: AgentSessionOptions<UserData>): {\n agentSessionOptions: InternalSessionOptions<UserData>;\n legacyVoiceOptions: VoiceOptions;\n} {\n const logger = log();\n const {\n voiceOptions,\n turnDetection,\n stt,\n vad,\n llm,\n tts,\n userData,\n connOptions,\n ...sessionOptions\n } = legacyOptions;\n\n if (voiceOptions !== undefined) {\n logger.warn(\n 'voiceOptions is deprecated, use top-level SessionOptions fields on AgentSessionOptions instead',\n );\n }\n\n const turnHandling: TurnHandlingOptions = {\n interruption: {\n discardAudioIfUninterruptible: voiceOptions?.discardAudioIfUninterruptible,\n minDuration: voiceOptions?.minInterruptionDuration,\n minWords: voiceOptions?.minInterruptionWords,\n ...sessionOptions.turnHandling?.interruption,\n },\n endpointing: {\n minDelay: voiceOptions?.minEndpointingDelay,\n maxDelay: voiceOptions?.maxEndpointingDelay,\n ...sessionOptions.turnHandling?.endpointing,\n },\n\n turnDetection: sessionOptions?.turnHandling?.turnDetection ?? turnDetection,\n } as const;\n\n if (\n voiceOptions?.allowInterruptions === false &&\n turnHandling.interruption.enabled === undefined\n ) {\n turnHandling.interruption.enabled = false;\n }\n\n const migratedVoiceOptions: AgentSessionOptions<UserData> = {};\n\n if (voiceOptions?.maxToolSteps !== undefined) {\n migratedVoiceOptions.maxToolSteps = voiceOptions.maxToolSteps;\n }\n if (voiceOptions?.preemptiveGeneration !== undefined) {\n migratedVoiceOptions.preemptiveGeneration = voiceOptions.preemptiveGeneration;\n }\n if (voiceOptions?.userAwayTimeout !== undefined) {\n migratedVoiceOptions.userAwayTimeout = voiceOptions.userAwayTimeout;\n }\n\n const legacyVoiceOptions = { ...defaultLegacyVoiceOptions, ...voiceOptions };\n\n const agentSessionOptions = {\n stt,\n vad,\n llm,\n tts,\n userData,\n connOptions,\n ...defaultSessionOptions,\n ...migratedVoiceOptions,\n ...sessionOptions,\n turnHandling: mergeWithDefaults(turnHandling),\n // repopulate the deprecated voice options with migrated options for backwards compatibility\n voiceOptions: legacyVoiceOptions,\n };\n\n return { agentSessionOptions, legacyVoiceOptions };\n}\n\n/** Remove keys whose value is `undefined` so they don't shadow defaults when spread. */\nexport function stripUndefined<T extends object>(obj: T): Partial<T> {\n return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined)) as Partial<T>;\n}\n\nexport function mergeWithDefaults(config: TurnHandlingOptions) {\n return {\n turnDetection: config.turnDetection ?? defaultTurnHandlingOptions.turnDetection,\n endpointing: { ...defaultEndpointingOptions, ...stripUndefined(config.endpointing) },\n interruption: { ...defaultInterruptionOptions, ...stripUndefined(config.interruption) },\n } as const;\n}\n\n/**\n * Build a partial {@link TurnHandlingOptions} from deprecated Agent constructor fields.\n * Mirrors the Python Agent compatibility path, but keeps the JS API surface explicit.\n */\nexport function migrateTurnHandling(opts: {\n turnDetection?: TurnDetectionMode;\n allowInterruptions?: boolean;\n minEndpointingDelay?: number;\n maxEndpointingDelay?: number;\n turnHandling?: TurnHandlingOptions;\n}): Partial<TurnHandlingOptions> {\n if (opts.turnHandling !== undefined) {\n return opts.turnHandling;\n }\n\n const migrated: Partial<TurnHandlingOptions> = {};\n\n const endpointing: Partial<TurnHandlingOptions['endpointing']> = {};\n if (opts.minEndpointingDelay !== undefined) {\n endpointing.minDelay = opts.minEndpointingDelay;\n }\n if (opts.maxEndpointingDelay !== undefined) {\n endpointing.maxDelay = opts.maxEndpointingDelay;\n }\n if (Object.keys(endpointing).length > 0) {\n migrated.endpointing = endpointing;\n }\n\n const interruption: Partial<TurnHandlingOptions['interruption']> = {};\n if (opts.allowInterruptions === false) {\n interruption.enabled = false;\n }\n if (Object.keys(interruption).length > 0) {\n migrated.interruption = interruption;\n }\n\n if (opts.turnDetection !== undefined) {\n migrated.turnDetection = opts.turnDetection;\n }\n\n return {\n ...(migrated.endpointing ? { endpointing: migrated.endpointing } : {}),\n ...(migrated.interruption ? { interruption: migrated.interruption } : {}),\n ...(migrated.turnDetection !== undefined ? { turnDetection: migrated.turnDetection } : {}),\n };\n}\n"],"mappings":"AAGA,SAAS,WAAW;AACpB;AAAA,OAKO;AACP,SAAS,iCAAiC;AAC1C,SAAS,kCAAkC;AAC3C,SAAmC,kCAAkC;AAErE,MAAM,wBAAwB;AAAA,EAC5B,cAAc;AAAA,EACd,sBAAsB;AAAA,EACtB,iBAAiB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;AAEA,SAAO;AAAA,IACL,GAAI,SAAS,cAAc,EAAE,aAAa,SAAS,YAAY,IAAI,CAAC;AAAA,IACpE,GAAI,SAAS,eAAe,EAAE,cAAc,SAAS,aAAa,IAAI,CAAC;AAAA,IACvE,GAAI,SAAS,kBAAkB,SAAY,EAAE,eAAe,SAAS,cAAc,IAAI,CAAC;AAAA,EAC1F;AACF;","names":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var import_vitest = require("vitest");
|
|
3
3
|
var import_log = require("../../log.cjs");
|
|
4
|
+
var import_agent_session = require("../agent_session.cjs");
|
|
4
5
|
var import_endpointing = require("./endpointing.cjs");
|
|
5
6
|
var import_interruption = require("./interruption.cjs");
|
|
6
7
|
var import_turn_handling = require("./turn_handling.cjs");
|
|
@@ -10,18 +11,18 @@ var import_utils = require("./utils.cjs");
|
|
|
10
11
|
});
|
|
11
12
|
(0, import_vitest.describe)("migrateLegacyOptions", () => {
|
|
12
13
|
(0, import_vitest.it)("should return all defaults when no options are provided", () => {
|
|
13
|
-
const result = (0, import_utils.migrateLegacyOptions)({});
|
|
14
|
-
(0, import_vitest.expect)(result.
|
|
14
|
+
const { agentSessionOptions: result } = (0, import_utils.migrateLegacyOptions)({});
|
|
15
|
+
(0, import_vitest.expect)(result.turnHandling).toEqual({
|
|
15
16
|
turnDetection: import_turn_handling.defaultTurnHandlingOptions.turnDetection,
|
|
16
17
|
endpointing: import_endpointing.defaultEndpointingOptions,
|
|
17
18
|
interruption: import_interruption.defaultInterruptionOptions
|
|
18
19
|
});
|
|
19
|
-
(0, import_vitest.expect)(result.
|
|
20
|
-
(0, import_vitest.expect)(result.
|
|
21
|
-
(0, import_vitest.expect)(result.
|
|
20
|
+
(0, import_vitest.expect)(result.maxToolSteps).toBe(import_agent_session.defaultAgentSessionOptions.maxToolSteps);
|
|
21
|
+
(0, import_vitest.expect)(result.preemptiveGeneration).toBe(import_agent_session.defaultAgentSessionOptions.preemptiveGeneration);
|
|
22
|
+
(0, import_vitest.expect)(result.userAwayTimeout).toBe(import_agent_session.defaultAgentSessionOptions.userAwayTimeout);
|
|
22
23
|
});
|
|
23
24
|
(0, import_vitest.it)("should migrate legacy flat fields into nested turnHandling config", () => {
|
|
24
|
-
const result = (0, import_utils.migrateLegacyOptions)({
|
|
25
|
+
const { agentSessionOptions: result } = (0, import_utils.migrateLegacyOptions)({
|
|
25
26
|
voiceOptions: {
|
|
26
27
|
minInterruptionDuration: 1e3,
|
|
27
28
|
minInterruptionWords: 3,
|
|
@@ -30,57 +31,98 @@ var import_utils = require("./utils.cjs");
|
|
|
30
31
|
maxEndpointingDelay: 5e3
|
|
31
32
|
}
|
|
32
33
|
});
|
|
33
|
-
(0, import_vitest.expect)(result.
|
|
34
|
-
(0, import_vitest.expect)(result.
|
|
35
|
-
(0, import_vitest.expect)(result.
|
|
36
|
-
(0, import_vitest.expect)(result.
|
|
37
|
-
(0, import_vitest.expect)(result.
|
|
34
|
+
(0, import_vitest.expect)(result.turnHandling.interruption.minDuration).toBe(1e3);
|
|
35
|
+
(0, import_vitest.expect)(result.turnHandling.interruption.minWords).toBe(3);
|
|
36
|
+
(0, import_vitest.expect)(result.turnHandling.interruption.discardAudioIfUninterruptible).toBe(false);
|
|
37
|
+
(0, import_vitest.expect)(result.turnHandling.endpointing.minDelay).toBe(800);
|
|
38
|
+
(0, import_vitest.expect)(result.turnHandling.endpointing.maxDelay).toBe(5e3);
|
|
38
39
|
});
|
|
39
40
|
(0, import_vitest.it)("should set interruption.enabled to false when allowInterruptions is false", () => {
|
|
40
|
-
const result = (0, import_utils.migrateLegacyOptions)({
|
|
41
|
-
|
|
42
|
-
allowInterruptions: false
|
|
43
|
-
}
|
|
41
|
+
const { agentSessionOptions: result } = (0, import_utils.migrateLegacyOptions)({
|
|
42
|
+
voiceOptions: { allowInterruptions: false }
|
|
44
43
|
});
|
|
45
|
-
(0, import_vitest.expect)(result.
|
|
44
|
+
(0, import_vitest.expect)(result.turnHandling.interruption.enabled).toBe(false);
|
|
46
45
|
});
|
|
47
|
-
(0, import_vitest.it)("should give
|
|
48
|
-
const result = (0, import_utils.migrateLegacyOptions)({
|
|
46
|
+
(0, import_vitest.it)("should give top-level fields precedence over voiceOptions", () => {
|
|
47
|
+
const { agentSessionOptions: result } = (0, import_utils.migrateLegacyOptions)({
|
|
49
48
|
voiceOptions: {
|
|
50
49
|
minInterruptionDuration: 1e3,
|
|
51
50
|
maxEndpointingDelay: 5e3,
|
|
52
51
|
maxToolSteps: 10
|
|
53
52
|
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
(0, import_vitest.expect)(result.options.turnHandling.interruption.minDuration).toBe(2e3);
|
|
61
|
-
(0, import_vitest.expect)(result.options.turnHandling.endpointing.maxDelay).toBe(8e3);
|
|
62
|
-
(0, import_vitest.expect)(result.options.maxToolSteps).toBe(5);
|
|
63
|
-
});
|
|
64
|
-
(0, import_vitest.it)("should let explicit turnHandling override legacy flat fields", () => {
|
|
65
|
-
const result = (0, import_utils.migrateLegacyOptions)({
|
|
66
|
-
options: {
|
|
67
|
-
minInterruptionDuration: 1e3,
|
|
68
|
-
minEndpointingDelay: 800,
|
|
69
|
-
turnHandling: {
|
|
70
|
-
interruption: { minDuration: 3e3 },
|
|
71
|
-
endpointing: { minDelay: 2e3 }
|
|
53
|
+
turnHandling: {
|
|
54
|
+
interruption: {
|
|
55
|
+
minDuration: 2e3
|
|
56
|
+
},
|
|
57
|
+
endpointing: {
|
|
58
|
+
maxDelay: 8e3
|
|
72
59
|
}
|
|
73
|
-
}
|
|
60
|
+
},
|
|
61
|
+
maxToolSteps: 5
|
|
74
62
|
});
|
|
75
|
-
(0, import_vitest.expect)(result.
|
|
76
|
-
(0, import_vitest.expect)(result.
|
|
63
|
+
(0, import_vitest.expect)(result.turnHandling.interruption.minDuration).toBe(2e3);
|
|
64
|
+
(0, import_vitest.expect)(result.turnHandling.endpointing.maxDelay).toBe(8e3);
|
|
65
|
+
(0, import_vitest.expect)(result.maxToolSteps).toBe(5);
|
|
77
66
|
});
|
|
78
67
|
(0, import_vitest.it)("should preserve top-level turnDetection in the result", () => {
|
|
79
|
-
const result = (0, import_utils.migrateLegacyOptions)({
|
|
68
|
+
const { agentSessionOptions: result } = (0, import_utils.migrateLegacyOptions)({
|
|
80
69
|
turnDetection: "vad"
|
|
81
70
|
});
|
|
71
|
+
(0, import_vitest.expect)(result.turnHandling.turnDetection).toBe("vad");
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
(0, import_vitest.describe)("migrateTurnHandling", () => {
|
|
75
|
+
(0, import_vitest.it)("should return empty partial when no deprecated Agent fields are given", () => {
|
|
76
|
+
const result = (0, import_utils.migrateTurnHandling)({});
|
|
77
|
+
(0, import_vitest.expect)(result).toEqual({});
|
|
78
|
+
});
|
|
79
|
+
(0, import_vitest.it)("should set interruption.enabled to false when allowInterruptions is false", () => {
|
|
80
|
+
const result = (0, import_utils.migrateTurnHandling)({ allowInterruptions: false });
|
|
81
|
+
(0, import_vitest.expect)(result.interruption).toEqual({ enabled: false });
|
|
82
|
+
(0, import_vitest.expect)(result.endpointing).toBeUndefined();
|
|
83
|
+
(0, import_vitest.expect)(result.turnDetection).toBeUndefined();
|
|
84
|
+
});
|
|
85
|
+
(0, import_vitest.it)("should not set interruption when allowInterruptions is true or undefined", () => {
|
|
86
|
+
(0, import_vitest.expect)((0, import_utils.migrateTurnHandling)({ allowInterruptions: true })).toEqual({});
|
|
87
|
+
(0, import_vitest.expect)((0, import_utils.migrateTurnHandling)({ allowInterruptions: void 0 })).toEqual({});
|
|
88
|
+
});
|
|
89
|
+
(0, import_vitest.it)("should map minEndpointingDelay to endpointing.minDelay", () => {
|
|
90
|
+
const result = (0, import_utils.migrateTurnHandling)({ minEndpointingDelay: 800 });
|
|
91
|
+
(0, import_vitest.expect)(result.endpointing).toEqual({ minDelay: 800 });
|
|
92
|
+
});
|
|
93
|
+
(0, import_vitest.it)("should map maxEndpointingDelay to endpointing.maxDelay", () => {
|
|
94
|
+
const result = (0, import_utils.migrateTurnHandling)({ maxEndpointingDelay: 5e3 });
|
|
95
|
+
(0, import_vitest.expect)(result.endpointing).toEqual({ maxDelay: 5e3 });
|
|
96
|
+
});
|
|
97
|
+
(0, import_vitest.it)("should pass through turnDetection", () => {
|
|
98
|
+
const result = (0, import_utils.migrateTurnHandling)({ turnDetection: "vad" });
|
|
82
99
|
(0, import_vitest.expect)(result.turnDetection).toBe("vad");
|
|
83
|
-
|
|
100
|
+
});
|
|
101
|
+
(0, import_vitest.it)("should combine all deprecated Agent fields", () => {
|
|
102
|
+
const result = (0, import_utils.migrateTurnHandling)({
|
|
103
|
+
turnDetection: "stt",
|
|
104
|
+
allowInterruptions: false,
|
|
105
|
+
minEndpointingDelay: 400,
|
|
106
|
+
maxEndpointingDelay: 3e3
|
|
107
|
+
});
|
|
108
|
+
(0, import_vitest.expect)(result.turnDetection).toBe("stt");
|
|
109
|
+
(0, import_vitest.expect)(result.interruption).toEqual({ enabled: false });
|
|
110
|
+
(0, import_vitest.expect)(result.endpointing).toEqual({ minDelay: 400, maxDelay: 3e3 });
|
|
111
|
+
});
|
|
112
|
+
(0, import_vitest.it)("should ignore deprecated Agent fields when explicit turnHandling is provided", () => {
|
|
113
|
+
const turnHandling = {
|
|
114
|
+
endpointing: { minDelay: 999, maxDelay: 4e3 },
|
|
115
|
+
interruption: { enabled: true },
|
|
116
|
+
turnDetection: "vad"
|
|
117
|
+
};
|
|
118
|
+
const result = (0, import_utils.migrateTurnHandling)({
|
|
119
|
+
turnHandling,
|
|
120
|
+
turnDetection: "stt",
|
|
121
|
+
allowInterruptions: false,
|
|
122
|
+
minEndpointingDelay: 100,
|
|
123
|
+
maxEndpointingDelay: 200
|
|
124
|
+
});
|
|
125
|
+
(0, import_vitest.expect)(result).toEqual(turnHandling);
|
|
84
126
|
});
|
|
85
127
|
});
|
|
86
128
|
//# sourceMappingURL=utils.test.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/voice/turn_config/utils.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { beforeAll, describe, expect, it } from 'vitest';\nimport { initializeLogger } from '../../log.js';\nimport { defaultEndpointingOptions } from './endpointing.js';\nimport { defaultInterruptionOptions } from './interruption.js';\nimport { defaultTurnHandlingOptions } from './turn_handling.js';\nimport { migrateLegacyOptions } from './utils.js';\n\nbeforeAll(() => {\n initializeLogger({ pretty: true, level: 'info' });\n});\n\ndescribe('migrateLegacyOptions', () => {\n it('should return all defaults when no options are provided', () => {\n const result = migrateLegacyOptions({});\n\n expect(result.
|
|
1
|
+
{"version":3,"sources":["../../../src/voice/turn_config/utils.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { beforeAll, describe, expect, it } from 'vitest';\nimport { initializeLogger } from '../../log.js';\nimport { defaultAgentSessionOptions } from '../agent_session.js';\nimport { defaultEndpointingOptions } from './endpointing.js';\nimport { defaultInterruptionOptions } from './interruption.js';\nimport { defaultTurnHandlingOptions } from './turn_handling.js';\nimport { migrateLegacyOptions, migrateTurnHandling } from './utils.js';\n\nbeforeAll(() => {\n initializeLogger({ pretty: true, level: 'info' });\n});\n\ndescribe('migrateLegacyOptions', () => {\n it('should return all defaults when no options are provided', () => {\n const { agentSessionOptions: result } = migrateLegacyOptions({});\n\n expect(result.turnHandling).toEqual({\n turnDetection: defaultTurnHandlingOptions.turnDetection,\n endpointing: defaultEndpointingOptions,\n interruption: defaultInterruptionOptions,\n });\n expect(result.maxToolSteps).toBe(defaultAgentSessionOptions.maxToolSteps);\n expect(result.preemptiveGeneration).toBe(defaultAgentSessionOptions.preemptiveGeneration);\n expect(result.userAwayTimeout).toBe(defaultAgentSessionOptions.userAwayTimeout);\n });\n\n it('should migrate legacy flat fields into nested turnHandling config', () => {\n const { agentSessionOptions: result } = migrateLegacyOptions({\n voiceOptions: {\n minInterruptionDuration: 1000,\n minInterruptionWords: 3,\n discardAudioIfUninterruptible: false,\n minEndpointingDelay: 800,\n maxEndpointingDelay: 5000,\n },\n });\n\n expect(result.turnHandling.interruption!.minDuration).toBe(1000);\n expect(result.turnHandling.interruption!.minWords).toBe(3);\n expect(result.turnHandling.interruption!.discardAudioIfUninterruptible).toBe(false);\n expect(result.turnHandling.endpointing!.minDelay).toBe(800);\n expect(result.turnHandling.endpointing!.maxDelay).toBe(5000);\n });\n\n it('should set interruption.enabled to false when allowInterruptions is false', () => {\n const { agentSessionOptions: result } = migrateLegacyOptions({\n voiceOptions: { allowInterruptions: false },\n });\n\n expect(result.turnHandling.interruption!.enabled).toBe(false);\n });\n\n it('should give top-level fields precedence over voiceOptions', () => {\n const { agentSessionOptions: result } = migrateLegacyOptions({\n voiceOptions: {\n minInterruptionDuration: 1000,\n maxEndpointingDelay: 5000,\n maxToolSteps: 10,\n },\n turnHandling: {\n interruption: {\n minDuration: 2000,\n },\n endpointing: {\n maxDelay: 8000,\n },\n },\n maxToolSteps: 5,\n });\n\n expect(result.turnHandling.interruption!.minDuration).toBe(2000);\n expect(result.turnHandling.endpointing!.maxDelay).toBe(8000);\n expect(result.maxToolSteps).toBe(5);\n });\n\n it('should preserve top-level turnDetection in the result', () => {\n const { agentSessionOptions: result } = migrateLegacyOptions({\n turnDetection: 'vad',\n });\n\n expect(result.turnHandling.turnDetection).toBe('vad');\n });\n});\n\ndescribe('migrateTurnHandling', () => {\n it('should return empty partial when no deprecated Agent fields are given', () => {\n const result = migrateTurnHandling({});\n expect(result).toEqual({});\n });\n\n it('should set interruption.enabled to false when allowInterruptions is false', () => {\n const result = migrateTurnHandling({ allowInterruptions: false });\n expect(result.interruption).toEqual({ enabled: false });\n expect(result.endpointing).toBeUndefined();\n expect(result.turnDetection).toBeUndefined();\n });\n\n it('should not set interruption when allowInterruptions is true or undefined', () => {\n expect(migrateTurnHandling({ allowInterruptions: true })).toEqual({});\n expect(migrateTurnHandling({ allowInterruptions: undefined })).toEqual({});\n });\n\n it('should map minEndpointingDelay to endpointing.minDelay', () => {\n const result = migrateTurnHandling({ minEndpointingDelay: 800 });\n expect(result.endpointing).toEqual({ minDelay: 800 });\n });\n\n it('should map maxEndpointingDelay to endpointing.maxDelay', () => {\n const result = migrateTurnHandling({ maxEndpointingDelay: 5000 });\n expect(result.endpointing).toEqual({ maxDelay: 5000 });\n });\n\n it('should pass through turnDetection', () => {\n const result = migrateTurnHandling({ turnDetection: 'vad' });\n expect(result.turnDetection).toBe('vad');\n });\n\n it('should combine all deprecated Agent fields', () => {\n const result = migrateTurnHandling({\n turnDetection: 'stt',\n allowInterruptions: false,\n minEndpointingDelay: 400,\n maxEndpointingDelay: 3000,\n });\n expect(result.turnDetection).toBe('stt');\n expect(result.interruption).toEqual({ enabled: false });\n expect(result.endpointing).toEqual({ minDelay: 400, maxDelay: 3000 });\n });\n\n it('should ignore deprecated Agent fields when explicit turnHandling is provided', () => {\n const turnHandling = {\n endpointing: { minDelay: 999, maxDelay: 4000 },\n interruption: { enabled: true },\n turnDetection: 'vad' as const,\n };\n const result = migrateTurnHandling({\n turnHandling,\n turnDetection: 'stt',\n allowInterruptions: false,\n minEndpointingDelay: 100,\n maxEndpointingDelay: 200,\n });\n expect(result).toEqual(turnHandling);\n });\n});\n"],"mappings":";AAGA,oBAAgD;AAChD,iBAAiC;AACjC,2BAA2C;AAC3C,yBAA0C;AAC1C,0BAA2C;AAC3C,2BAA2C;AAC3C,mBAA0D;AAAA,IAE1D,yBAAU,MAAM;AACd,mCAAiB,EAAE,QAAQ,MAAM,OAAO,OAAO,CAAC;AAClD,CAAC;AAAA,IAED,wBAAS,wBAAwB,MAAM;AACrC,wBAAG,2DAA2D,MAAM;AAClE,UAAM,EAAE,qBAAqB,OAAO,QAAI,mCAAqB,CAAC,CAAC;AAE/D,8BAAO,OAAO,YAAY,EAAE,QAAQ;A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