@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
|
@@ -74,6 +74,7 @@ export declare class AgentActivity implements RecognitionHooks {
|
|
|
74
74
|
get allowInterruptions(): boolean;
|
|
75
75
|
get useTtsAlignedTranscript(): boolean;
|
|
76
76
|
get turnDetection(): TurnDetectionMode | undefined;
|
|
77
|
+
get turnHandling(): Partial<import("./turn_config/turn_handling.js").TurnHandlingOptions>;
|
|
77
78
|
get toolCtx(): ToolContext;
|
|
78
79
|
/** @internal */
|
|
79
80
|
get inputStartedAt(): number | undefined;
|
|
@@ -147,6 +148,7 @@ export declare class AgentActivity implements RecognitionHooks {
|
|
|
147
148
|
close(): Promise<void>;
|
|
148
149
|
private resolveInterruptionDetector;
|
|
149
150
|
private restoreInterruptionByAudioActivity;
|
|
151
|
+
private fallbackToVadInterruption;
|
|
150
152
|
private _closeSessionResources;
|
|
151
153
|
}
|
|
152
154
|
export {};
|
|
@@ -74,6 +74,7 @@ export declare class AgentActivity implements RecognitionHooks {
|
|
|
74
74
|
get allowInterruptions(): boolean;
|
|
75
75
|
get useTtsAlignedTranscript(): boolean;
|
|
76
76
|
get turnDetection(): TurnDetectionMode | undefined;
|
|
77
|
+
get turnHandling(): Partial<import("./turn_config/turn_handling.js").TurnHandlingOptions>;
|
|
77
78
|
get toolCtx(): ToolContext;
|
|
78
79
|
/** @internal */
|
|
79
80
|
get inputStartedAt(): number | undefined;
|
|
@@ -147,6 +148,7 @@ export declare class AgentActivity implements RecognitionHooks {
|
|
|
147
148
|
close(): Promise<void>;
|
|
148
149
|
private resolveInterruptionDetector;
|
|
149
150
|
private restoreInterruptionByAudioActivity;
|
|
151
|
+
private fallbackToVadInterruption;
|
|
150
152
|
private _closeSessionResources;
|
|
151
153
|
}
|
|
152
154
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent_activity.d.ts","sourceRoot":"","sources":["../../src/voice/agent_activity.ts"],"names":[],"mappings":";;AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAmB,MAAM,iBAAiB,CAAC;AAGlE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,KAAK,WAAW,EAAE,WAAW,EAAsB,MAAM,wBAAwB,CAAC;AAC3F,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAChC,GAAG,EACH,aAAa,EAEb,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,WAAW,EAEjB,MAAM,iBAAiB,CAAC;AAczB,OAAO,EAAE,GAAG,EAAiB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAGrE,OAAO,EAAE,GAAG,EAAiB,MAAM,eA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OAAO,CAAC,kCAAkC;IAI1C,OAAO,CAAC,yBAAyB;YAwBnB,sBAAsB;CAwCrC"}
|
|
@@ -17,7 +17,7 @@ import { STT } from "../stt/stt.js";
|
|
|
17
17
|
import { recordRealtimeMetrics, traceTypes, tracer } from "../telemetry/index.js";
|
|
18
18
|
import { splitWords } from "../tokenize/basic/word.js";
|
|
19
19
|
import { TTS } from "../tts/tts.js";
|
|
20
|
-
import { Future, Task, cancelAndWait, waitFor } from "../utils.js";
|
|
20
|
+
import { Future, Task, cancelAndWait, isDevMode, isHosted, waitFor } from "../utils.js";
|
|
21
21
|
import { VAD } from "../vad.js";
|
|
22
22
|
import {
|
|
23
23
|
StopResponse,
|
|
@@ -85,9 +85,10 @@ class AgentActivity {
|
|
|
85
85
|
onRealtimeInputAudioTranscriptionCompleted = (ev) => this.onInputAudioTranscriptionCompleted(ev);
|
|
86
86
|
onModelError = (ev) => this.onError(ev);
|
|
87
87
|
onInterruptionOverlappingSpeech = (ev) => {
|
|
88
|
-
this.agentSession.emit(AgentSessionEventTypes.
|
|
88
|
+
this.agentSession.emit(AgentSessionEventTypes.OverlappingSpeech, ev);
|
|
89
89
|
};
|
|
90
90
|
onInterruptionMetricsCollected = (ev) => {
|
|
91
|
+
this.agentSession._usageCollector.collect(ev);
|
|
91
92
|
this.agentSession.emit(
|
|
92
93
|
AgentSessionEventTypes.MetricsCollected,
|
|
93
94
|
createMetricsCollectedEvent({ metrics: ev })
|
|
@@ -96,6 +97,11 @@ class AgentActivity {
|
|
|
96
97
|
onInterruptionError = (ev) => {
|
|
97
98
|
const errorEvent = createErrorEvent(ev, this.interruptionDetector);
|
|
98
99
|
this.agentSession.emit(AgentSessionEventTypes.Error, errorEvent);
|
|
100
|
+
if (!ev.recoverable) {
|
|
101
|
+
this.agentSession._onError(ev);
|
|
102
|
+
this.fallbackToVadInterruption();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
99
105
|
this.agentSession._onError(ev);
|
|
100
106
|
};
|
|
101
107
|
/** @internal */
|
|
@@ -183,7 +189,7 @@ class AgentActivity {
|
|
|
183
189
|
}
|
|
184
190
|
}
|
|
185
191
|
async _startSession(options) {
|
|
186
|
-
var _a;
|
|
192
|
+
var _a, _b, _c, _d, _e;
|
|
187
193
|
const { spanName, runOnEnter } = options;
|
|
188
194
|
const startSpan = tracer.startSpan({
|
|
189
195
|
name: spanName,
|
|
@@ -258,10 +264,10 @@ class AgentActivity {
|
|
|
258
264
|
turnDetector: typeof this.turnDetection === "string" ? void 0 : this.turnDetection,
|
|
259
265
|
turnDetectionMode: this.turnDetectionMode,
|
|
260
266
|
interruptionDetection: this.interruptionDetector,
|
|
261
|
-
minEndpointingDelay: this.agentSession.
|
|
262
|
-
maxEndpointingDelay: this.agentSession.
|
|
267
|
+
minEndpointingDelay: ((_b = (_a = this.agent.turnHandling) == null ? void 0 : _a.endpointing) == null ? void 0 : _b.minDelay) ?? this.agentSession.sessionOptions.turnHandling.endpointing.minDelay,
|
|
268
|
+
maxEndpointingDelay: ((_d = (_c = this.agent.turnHandling) == null ? void 0 : _c.endpointing) == null ? void 0 : _d.maxDelay) ?? this.agentSession.sessionOptions.turnHandling.endpointing.maxDelay,
|
|
263
269
|
rootSpanContext: this.agentSession.rootSpanContext,
|
|
264
|
-
sttModel: (
|
|
270
|
+
sttModel: (_e = this.stt) == null ? void 0 : _e.label,
|
|
265
271
|
sttProvider: this.getSttProvider(),
|
|
266
272
|
getLinkedParticipant: () => {
|
|
267
273
|
var _a2;
|
|
@@ -321,15 +327,31 @@ class AgentActivity {
|
|
|
321
327
|
return this.realtimeSession;
|
|
322
328
|
}
|
|
323
329
|
get allowInterruptions() {
|
|
324
|
-
var _a;
|
|
325
|
-
return ((_a = this.
|
|
330
|
+
var _a, _b;
|
|
331
|
+
return ((_b = (_a = this.agent.turnHandling) == null ? void 0 : _a.interruption) == null ? void 0 : _b.enabled) ?? this.agentSession.sessionOptions.turnHandling.interruption.enabled;
|
|
326
332
|
}
|
|
327
333
|
get useTtsAlignedTranscript() {
|
|
328
334
|
return this.agent.useTtsAlignedTranscript ?? this.agentSession.useTtsAlignedTranscript;
|
|
329
335
|
}
|
|
330
336
|
get turnDetection() {
|
|
331
|
-
|
|
332
|
-
|
|
337
|
+
var _a;
|
|
338
|
+
return ((_a = this.agent.turnHandling) == null ? void 0 : _a.turnDetection) ?? this.agentSession.turnDetection;
|
|
339
|
+
}
|
|
340
|
+
get turnHandling() {
|
|
341
|
+
return this.agent.turnHandling ?? this.agentSession.sessionOptions.turnHandling;
|
|
342
|
+
}
|
|
343
|
+
// get minEndpointingDelay(): number {
|
|
344
|
+
// return (
|
|
345
|
+
// this.agent.turnHandling?.endpointing?.minDelay ??
|
|
346
|
+
// this.agentSession.sessionOptions.turnHandling.endpointing.minDelay
|
|
347
|
+
// );
|
|
348
|
+
// }
|
|
349
|
+
// get maxEndpointingDelay(): number {
|
|
350
|
+
// return (
|
|
351
|
+
// this.agent.turnHandling?.endpointing?.maxDelay ??
|
|
352
|
+
// this.agentSession.sessionOptions.turnHandling.endpointing.maxDelay
|
|
353
|
+
// );
|
|
354
|
+
// }
|
|
333
355
|
get toolCtx() {
|
|
334
356
|
return this.agent.toolCtx;
|
|
335
357
|
}
|
|
@@ -395,12 +417,18 @@ class AgentActivity {
|
|
|
395
417
|
}
|
|
396
418
|
});
|
|
397
419
|
this.audioStreamId = this.audioStream.addInputStream(audioStream);
|
|
398
|
-
|
|
399
|
-
|
|
420
|
+
if (this.realtimeSession && this.audioRecognition) {
|
|
421
|
+
const [realtimeAudioStream, recognitionAudioStream] = this.audioStream.stream.pipeThrough(aecWarmupAudioFilter).tee();
|
|
400
422
|
this.realtimeSession.setInputAudioStream(realtimeAudioStream);
|
|
401
|
-
}
|
|
402
|
-
if (this.audioRecognition) {
|
|
403
423
|
this.audioRecognition.setInputAudioStream(recognitionAudioStream);
|
|
424
|
+
} else if (this.realtimeSession) {
|
|
425
|
+
this.realtimeSession.setInputAudioStream(
|
|
426
|
+
this.audioStream.stream.pipeThrough(aecWarmupAudioFilter)
|
|
427
|
+
);
|
|
428
|
+
} else if (this.audioRecognition) {
|
|
429
|
+
this.audioRecognition.setInputAudioStream(
|
|
430
|
+
this.audioStream.stream.pipeThrough(aecWarmupAudioFilter)
|
|
431
|
+
);
|
|
404
432
|
}
|
|
405
433
|
}
|
|
406
434
|
detachAudioInput() {
|
|
@@ -475,6 +503,7 @@ class AgentActivity {
|
|
|
475
503
|
this.realtimeSpans.delete(ev.requestId);
|
|
476
504
|
}
|
|
477
505
|
}
|
|
506
|
+
this.agentSession._usageCollector.collect(ev);
|
|
478
507
|
this.agentSession.emit(
|
|
479
508
|
AgentSessionEventTypes.MetricsCollected,
|
|
480
509
|
createMetricsCollectedEvent({ metrics: ev })
|
|
@@ -587,7 +616,10 @@ class AgentActivity {
|
|
|
587
616
|
if (ev) {
|
|
588
617
|
speechStartTime = speechStartTime - ev.speechDuration - ev.inferenceDuration;
|
|
589
618
|
}
|
|
590
|
-
this.agentSession._updateUserState("speaking",
|
|
619
|
+
this.agentSession._updateUserState("speaking", {
|
|
620
|
+
lastSpeakingTime: speechStartTime,
|
|
621
|
+
otelContext: otelContext.active()
|
|
622
|
+
});
|
|
591
623
|
if (this.isInterruptionDetectionEnabled && this.audioRecognition) {
|
|
592
624
|
this.audioRecognition.onStartOfOverlapSpeech(
|
|
593
625
|
ev.speechDuration,
|
|
@@ -607,14 +639,17 @@ class AgentActivity {
|
|
|
607
639
|
this.agentSession._userSpeakingSpan
|
|
608
640
|
);
|
|
609
641
|
}
|
|
610
|
-
this.agentSession._updateUserState("listening",
|
|
642
|
+
this.agentSession._updateUserState("listening", {
|
|
643
|
+
lastSpeakingTime: speechEndTime,
|
|
644
|
+
otelContext: otelContext.active()
|
|
645
|
+
});
|
|
611
646
|
}
|
|
612
647
|
onVADInferenceDone(ev) {
|
|
613
648
|
var _a;
|
|
614
649
|
if (this.turnDetection === "manual" || this.turnDetection === "realtime_llm") {
|
|
615
650
|
return;
|
|
616
651
|
}
|
|
617
|
-
if (ev.speechDuration >= ((_a = this.agentSession.
|
|
652
|
+
if (ev.speechDuration >= ((_a = this.agentSession.sessionOptions.turnHandling.interruption) == null ? void 0 : _a.minDuration)) {
|
|
618
653
|
this.interruptByAudioActivity();
|
|
619
654
|
}
|
|
620
655
|
}
|
|
@@ -629,11 +664,11 @@ class AgentActivity {
|
|
|
629
664
|
if (this.llm instanceof RealtimeModel && this.llm.capabilities.turnDetection) {
|
|
630
665
|
return;
|
|
631
666
|
}
|
|
632
|
-
if (this.stt && ((_a = this.agentSession.
|
|
667
|
+
if (this.stt && ((_a = this.agentSession.sessionOptions.turnHandling.interruption) == null ? void 0 : _a.minWords) > 0 && this.audioRecognition) {
|
|
633
668
|
const text = this.audioRecognition.currentTranscript;
|
|
634
669
|
const normalizedText = text ?? "";
|
|
635
670
|
const wordCount = splitWords(normalizedText, true).length;
|
|
636
|
-
if (wordCount < ((_b = this.agentSession.
|
|
671
|
+
if (wordCount < ((_b = this.agentSession.sessionOptions.turnHandling.interruption) == null ? void 0 : _b.minWords)) {
|
|
637
672
|
return;
|
|
638
673
|
}
|
|
639
674
|
}
|
|
@@ -651,7 +686,7 @@ class AgentActivity {
|
|
|
651
686
|
this.restoreInterruptionByAudioActivity();
|
|
652
687
|
this.interruptByAudioActivity();
|
|
653
688
|
if (this.audioRecognition) {
|
|
654
|
-
this.audioRecognition.onEndOfAgentSpeech(ev.overlapStartedAt || ev.
|
|
689
|
+
this.audioRecognition.onEndOfAgentSpeech(ev.overlapStartedAt || ev.detectedAt);
|
|
655
690
|
}
|
|
656
691
|
}
|
|
657
692
|
onInterimTranscript(ev) {
|
|
@@ -689,7 +724,7 @@ class AgentActivity {
|
|
|
689
724
|
}
|
|
690
725
|
}
|
|
691
726
|
onPreemptiveGeneration(info) {
|
|
692
|
-
if (!this.agentSession.
|
|
727
|
+
if (!this.agentSession.sessionOptions.preemptiveGeneration || this.schedulingPaused || this._currentSpeech !== void 0 && !this._currentSpeech.interrupted || !(this.llm instanceof LLM)) {
|
|
693
728
|
return;
|
|
694
729
|
}
|
|
695
730
|
this.cancelPreemptiveGeneration();
|
|
@@ -770,14 +805,14 @@ class AgentActivity {
|
|
|
770
805
|
);
|
|
771
806
|
return true;
|
|
772
807
|
}
|
|
773
|
-
if (this.stt && this.turnDetection !== "manual" && this._currentSpeech && this._currentSpeech.allowInterruptions && !this._currentSpeech.interrupted && ((_a = this.agentSession.
|
|
808
|
+
if (this.stt && this.turnDetection !== "manual" && this._currentSpeech && this._currentSpeech.allowInterruptions && !this._currentSpeech.interrupted && ((_a = this.agentSession.sessionOptions.turnHandling.interruption) == null ? void 0 : _a.minWords) > 0) {
|
|
774
809
|
const wordCount = splitWords(info.newTranscript, true).length;
|
|
775
|
-
if (wordCount < ((_b = this.agentSession.
|
|
810
|
+
if (wordCount < ((_b = this.agentSession.sessionOptions.turnHandling.interruption) == null ? void 0 : _b.minWords)) {
|
|
776
811
|
this.cancelPreemptiveGeneration();
|
|
777
812
|
this.logger.info(
|
|
778
813
|
{
|
|
779
814
|
wordCount,
|
|
780
|
-
minInterruptionWords: this.agentSession.
|
|
815
|
+
minInterruptionWords: this.agentSession.sessionOptions.turnHandling.interruption.minWords
|
|
781
816
|
},
|
|
782
817
|
"skipping user input, word count below minimum interruption threshold"
|
|
783
818
|
);
|
|
@@ -811,9 +846,12 @@ class AgentActivity {
|
|
|
811
846
|
throw new Error("Speech queue is empty");
|
|
812
847
|
}
|
|
813
848
|
const speechHandle = heapItem[2];
|
|
849
|
+
if (speechHandle.interrupted || speechHandle.done()) {
|
|
850
|
+
continue;
|
|
851
|
+
}
|
|
814
852
|
this._currentSpeech = speechHandle;
|
|
815
853
|
speechHandle._authorizeGeneration();
|
|
816
|
-
await speechHandle._waitForGeneration();
|
|
854
|
+
await speechHandle.waitIfNotInterrupted([speechHandle._waitForGeneration()]);
|
|
817
855
|
this._currentSpeech = void 0;
|
|
818
856
|
}
|
|
819
857
|
const toWait = this.getDrainPendingSpeechTasks();
|
|
@@ -953,7 +991,16 @@ ${instructions}`;
|
|
|
953
991
|
speech.interrupt(force);
|
|
954
992
|
}
|
|
955
993
|
(_a = this.realtimeSession) == null ? void 0 : _a.interrupt();
|
|
956
|
-
if (
|
|
994
|
+
if (force) {
|
|
995
|
+
for (const task of this.speechTasks) {
|
|
996
|
+
task.cancel();
|
|
997
|
+
}
|
|
998
|
+
if (currentSpeech && !currentSpeech.done()) {
|
|
999
|
+
currentSpeech._markDone();
|
|
1000
|
+
}
|
|
1001
|
+
this.speechQueue.clear();
|
|
1002
|
+
future.resolve();
|
|
1003
|
+
} else if (currentSpeech === void 0) {
|
|
957
1004
|
future.resolve();
|
|
958
1005
|
} else {
|
|
959
1006
|
currentSpeech.addDoneCallback(() => {
|
|
@@ -1400,9 +1447,7 @@ ${instructions}`;
|
|
|
1400
1447
|
audioOutput.clearBuffer();
|
|
1401
1448
|
}
|
|
1402
1449
|
replyAbortController.abort();
|
|
1403
|
-
await
|
|
1404
|
-
tasks.map((task) => task.cancelAndWait(AgentActivity.REPLY_TASK_CANCEL_TIMEOUT))
|
|
1405
|
-
);
|
|
1450
|
+
await cancelAndWait(tasks, AgentActivity.REPLY_TASK_CANCEL_TIMEOUT);
|
|
1406
1451
|
let forwardedText = (textOut == null ? void 0 : textOut.text) || "";
|
|
1407
1452
|
if (audioOutput) {
|
|
1408
1453
|
const playbackEv = await audioOutput.waitForPlayout();
|
|
@@ -1483,7 +1528,7 @@ ${instructions}`;
|
|
|
1483
1528
|
speechHandle._markGenerationDone();
|
|
1484
1529
|
await executeToolsTask.result;
|
|
1485
1530
|
if (toolOutput.output.length === 0) return;
|
|
1486
|
-
const { maxToolSteps } = this.agentSession.
|
|
1531
|
+
const { maxToolSteps } = this.agentSession.sessionOptions;
|
|
1487
1532
|
if (speechHandle.numSteps >= maxToolSteps) {
|
|
1488
1533
|
this.logger.warn(
|
|
1489
1534
|
{ speech_id: speechHandle.id, max_tool_steps: maxToolSteps },
|
|
@@ -1834,7 +1879,7 @@ ${instructions}`;
|
|
|
1834
1879
|
if (toolOutput.output.length === 0) {
|
|
1835
1880
|
return;
|
|
1836
1881
|
}
|
|
1837
|
-
const { maxToolSteps } = this.agentSession.
|
|
1882
|
+
const { maxToolSteps } = this.agentSession.sessionOptions;
|
|
1838
1883
|
if (speechHandle.numSteps >= maxToolSteps) {
|
|
1839
1884
|
this.logger.warn(
|
|
1840
1885
|
{ speech_id: speechHandle.id, max_tool_steps: maxToolSteps },
|
|
@@ -2053,15 +2098,16 @@ ${instructions}`;
|
|
|
2053
2098
|
const unlock = await this.lock.lock();
|
|
2054
2099
|
try {
|
|
2055
2100
|
this.cancelPreemptiveGeneration();
|
|
2101
|
+
await cancelAndWait(Array.from(this.speechTasks), AgentActivity.REPLY_TASK_CANCEL_TIMEOUT);
|
|
2102
|
+
if (this._currentSpeech && !this._currentSpeech.done()) {
|
|
2103
|
+
this._currentSpeech._markDone();
|
|
2104
|
+
}
|
|
2056
2105
|
await this._closeSessionResources();
|
|
2057
2106
|
if (this._mainTask) {
|
|
2058
2107
|
await this._mainTask.cancelAndWait();
|
|
2059
2108
|
}
|
|
2060
2109
|
if (this.interruptionDetector) {
|
|
2061
|
-
this.interruptionDetector.off(
|
|
2062
|
-
"user_overlapping_speech",
|
|
2063
|
-
this.onInterruptionOverlappingSpeech
|
|
2064
|
-
);
|
|
2110
|
+
this.interruptionDetector.off("overlapping_speech", this.onInterruptionOverlappingSpeech);
|
|
2065
2111
|
this.interruptionDetector.off("metrics_collected", this.onInterruptionMetricsCollected);
|
|
2066
2112
|
this.interruptionDetector.off("error", this.onInterruptionError);
|
|
2067
2113
|
}
|
|
@@ -2071,21 +2117,33 @@ ${instructions}`;
|
|
|
2071
2117
|
}
|
|
2072
2118
|
}
|
|
2073
2119
|
resolveInterruptionDetector() {
|
|
2074
|
-
|
|
2120
|
+
var _a, _b;
|
|
2121
|
+
const agentInterruptionDetection = (_b = (_a = this.agent.turnHandling) == null ? void 0 : _a.interruption) == null ? void 0 : _b.mode;
|
|
2122
|
+
const sessionInterruptionDetection = this.agentSession.interruptionDetection;
|
|
2075
2123
|
if (!(this.stt && this.stt.capabilities.alignedTranscript && this.stt.capabilities.streaming && this.vad && this.turnDetection !== "manual" && this.turnDetection !== "realtime_llm" && !(this.llm instanceof RealtimeModel))) {
|
|
2076
|
-
if (
|
|
2124
|
+
if (agentInterruptionDetection === "adaptive" || sessionInterruptionDetection === "adaptive") {
|
|
2077
2125
|
this.logger.warn(
|
|
2078
2126
|
"interruptionDetection is provided, but it's not compatible with the current configuration and will be disabled"
|
|
2079
2127
|
);
|
|
2080
|
-
return void 0;
|
|
2081
2128
|
}
|
|
2129
|
+
return void 0;
|
|
2130
|
+
}
|
|
2131
|
+
if (!this.allowInterruptions) {
|
|
2132
|
+
return void 0;
|
|
2133
|
+
}
|
|
2134
|
+
if (agentInterruptionDetection === "vad") {
|
|
2135
|
+
return void 0;
|
|
2082
2136
|
}
|
|
2083
|
-
if (
|
|
2137
|
+
if (sessionInterruptionDetection === "vad") {
|
|
2138
|
+
return void 0;
|
|
2139
|
+
}
|
|
2140
|
+
if (agentInterruptionDetection === void 0 && sessionInterruptionDetection === void 0 && !isHosted() && !isDevMode()) {
|
|
2141
|
+
this.logger.info("adaptive interruption is disabled by default in production mode");
|
|
2084
2142
|
return void 0;
|
|
2085
2143
|
}
|
|
2086
2144
|
try {
|
|
2087
2145
|
const detector = new AdaptiveInterruptionDetector();
|
|
2088
|
-
detector.on("
|
|
2146
|
+
detector.on("overlapping_speech", this.onInterruptionOverlappingSpeech);
|
|
2089
2147
|
detector.on("metrics_collected", this.onInterruptionMetricsCollected);
|
|
2090
2148
|
detector.on("error", this.onInterruptionError);
|
|
2091
2149
|
return detector;
|
|
@@ -2097,6 +2155,25 @@ ${instructions}`;
|
|
|
2097
2155
|
restoreInterruptionByAudioActivity() {
|
|
2098
2156
|
this.isInterruptionByAudioActivityEnabled = this.isDefaultInterruptionByAudioActivityEnabled;
|
|
2099
2157
|
}
|
|
2158
|
+
fallbackToVadInterruption() {
|
|
2159
|
+
if (!this.isInterruptionDetectionEnabled) return;
|
|
2160
|
+
this.isInterruptionDetectionEnabled = false;
|
|
2161
|
+
this.restoreInterruptionByAudioActivity();
|
|
2162
|
+
if (this.interruptionDetector) {
|
|
2163
|
+
this.interruptionDetector.off("overlapping_speech", this.onInterruptionOverlappingSpeech);
|
|
2164
|
+
this.interruptionDetector.off("metrics_collected", this.onInterruptionMetricsCollected);
|
|
2165
|
+
this.interruptionDetector.off("error", this.onInterruptionError);
|
|
2166
|
+
this.interruptionDetector = void 0;
|
|
2167
|
+
}
|
|
2168
|
+
if (this.audioRecognition) {
|
|
2169
|
+
this.audioRecognition.disableInterruptionDetection().catch((err) => {
|
|
2170
|
+
this.logger.warn({ err }, "error while disabling interruption detection");
|
|
2171
|
+
});
|
|
2172
|
+
}
|
|
2173
|
+
this.logger.warn(
|
|
2174
|
+
"adaptive interruption disabled due to unrecoverable error, falling back to VAD-based interruption"
|
|
2175
|
+
);
|
|
2176
|
+
}
|
|
2100
2177
|
async _closeSessionResources() {
|
|
2101
2178
|
var _a, _b, _c;
|
|
2102
2179
|
if (this.llm instanceof LLM) {
|