@livekit/agents 1.0.5 → 1.0.7
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/index.cjs +3 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- 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/llm.cjs +299 -0
- package/dist/inference/llm.cjs.map +1 -0
- package/dist/inference/llm.d.cts +107 -0
- package/dist/inference/llm.d.ts +107 -0
- package/dist/inference/llm.d.ts.map +1 -0
- package/dist/inference/llm.js +270 -0
- package/dist/inference/llm.js.map +1 -0
- package/dist/inference/stt.cjs +313 -0
- package/dist/inference/stt.cjs.map +1 -0
- package/dist/inference/stt.d.cts +87 -0
- package/dist/inference/stt.d.ts +87 -0
- package/dist/inference/stt.d.ts.map +1 -0
- package/dist/inference/stt.js +292 -0
- package/dist/inference/stt.js.map +1 -0
- package/dist/inference/tts.cjs +324 -0
- package/dist/inference/tts.cjs.map +1 -0
- package/dist/inference/tts.d.cts +77 -0
- package/dist/inference/tts.d.ts +77 -0
- package/dist/inference/tts.d.ts.map +1 -0
- package/dist/inference/tts.js +306 -0
- package/dist/inference/tts.js.map +1 -0
- package/dist/inference/utils.cjs +76 -0
- package/dist/inference/utils.cjs.map +1 -0
- package/dist/inference/utils.d.cts +5 -0
- package/dist/inference/utils.d.ts +5 -0
- package/dist/inference/utils.d.ts.map +1 -0
- package/dist/inference/utils.js +51 -0
- package/dist/inference/utils.js.map +1 -0
- package/dist/llm/remote_chat_context.cjs.map +1 -1
- package/dist/llm/remote_chat_context.d.cts +2 -0
- package/dist/llm/remote_chat_context.d.ts +2 -0
- package/dist/llm/remote_chat_context.d.ts.map +1 -1
- package/dist/llm/remote_chat_context.js.map +1 -1
- package/dist/tts/tts.cjs +1 -1
- package/dist/tts/tts.cjs.map +1 -1
- package/dist/tts/tts.js +1 -1
- package/dist/tts/tts.js.map +1 -1
- package/dist/utils.cjs +11 -0
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +1 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +10 -0
- package/dist/utils.js.map +1 -1
- package/dist/voice/agent.cjs +16 -3
- package/dist/voice/agent.cjs.map +1 -1
- package/dist/voice/agent.d.cts +5 -3
- package/dist/voice/agent.d.ts +5 -3
- package/dist/voice/agent.d.ts.map +1 -1
- package/dist/voice/agent.js +20 -3
- package/dist/voice/agent.js.map +1 -1
- package/dist/voice/agent_activity.cjs +4 -2
- package/dist/voice/agent_activity.cjs.map +1 -1
- package/dist/voice/agent_activity.d.ts.map +1 -1
- package/dist/voice/agent_activity.js +4 -2
- package/dist/voice/agent_activity.js.map +1 -1
- package/dist/voice/agent_session.cjs +16 -3
- package/dist/voice/agent_session.cjs.map +1 -1
- package/dist/voice/agent_session.d.cts +4 -3
- package/dist/voice/agent_session.d.ts +4 -3
- package/dist/voice/agent_session.d.ts.map +1 -1
- package/dist/voice/agent_session.js +20 -3
- package/dist/voice/agent_session.js.map +1 -1
- package/dist/voice/events.cjs +2 -0
- package/dist/voice/events.cjs.map +1 -1
- package/dist/voice/events.d.cts +4 -1
- package/dist/voice/events.d.ts +4 -1
- package/dist/voice/events.d.ts.map +1 -1
- package/dist/voice/events.js +2 -0
- package/dist/voice/events.js.map +1 -1
- package/dist/voice/generation.cjs.map +1 -1
- package/dist/voice/generation.d.cts +1 -0
- package/dist/voice/generation.d.ts +1 -0
- package/dist/voice/generation.d.ts.map +1 -1
- package/dist/voice/generation.js.map +1 -1
- package/dist/voice/room_io/_input.cjs +9 -0
- package/dist/voice/room_io/_input.cjs.map +1 -1
- package/dist/voice/room_io/_input.d.ts.map +1 -1
- package/dist/voice/room_io/_input.js +10 -0
- package/dist/voice/room_io/_input.js.map +1 -1
- package/dist/voice/room_io/_output.cjs +1 -1
- package/dist/voice/room_io/_output.cjs.map +1 -1
- package/dist/voice/room_io/_output.d.cts +1 -0
- package/dist/voice/room_io/_output.d.ts +1 -0
- package/dist/voice/room_io/_output.d.ts.map +1 -1
- package/dist/voice/room_io/_output.js +1 -1
- package/dist/voice/room_io/_output.js.map +1 -1
- package/dist/voice/room_io/room_io.cjs +1 -1
- package/dist/voice/room_io/room_io.cjs.map +1 -1
- package/dist/voice/room_io/room_io.d.cts +20 -0
- package/dist/voice/room_io/room_io.d.ts +20 -0
- package/dist/voice/room_io/room_io.d.ts.map +1 -1
- package/dist/voice/room_io/room_io.js +1 -1
- package/dist/voice/room_io/room_io.js.map +1 -1
- package/dist/voice/transcription/synchronizer.cjs +1 -1
- package/dist/voice/transcription/synchronizer.cjs.map +1 -1
- package/dist/voice/transcription/synchronizer.d.cts +1 -0
- package/dist/voice/transcription/synchronizer.d.ts +1 -0
- package/dist/voice/transcription/synchronizer.d.ts.map +1 -1
- package/dist/voice/transcription/synchronizer.js +1 -1
- package/dist/voice/transcription/synchronizer.js.map +1 -1
- package/dist/worker.cjs +3 -3
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +3 -0
- package/dist/worker.d.ts +3 -0
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +4 -4
- package/dist/worker.js.map +1 -1
- package/package.json +3 -2
- package/src/index.ts +2 -1
- package/src/inference/api_protos.ts +82 -0
- package/src/inference/index.ts +32 -0
- package/src/inference/llm.ts +463 -0
- package/src/inference/stt.ts +444 -0
- package/src/inference/tts.ts +432 -0
- package/src/inference/utils.ts +66 -0
- package/src/llm/remote_chat_context.ts +2 -2
- package/src/tts/tts.ts +1 -1
- package/src/utils.ts +11 -0
- package/src/voice/agent.ts +31 -7
- package/src/voice/agent_activity.ts +2 -0
- package/src/voice/agent_session.ts +30 -6
- package/src/voice/events.ts +6 -0
- package/src/voice/generation.ts +1 -1
- package/src/voice/room_io/_input.ts +12 -1
- package/src/voice/room_io/_output.ts +1 -1
- package/src/voice/room_io/room_io.ts +21 -2
- package/src/voice/transcription/synchronizer.ts +1 -1
- package/src/worker.ts +5 -10
package/src/voice/events.ts
CHANGED
|
@@ -80,25 +80,31 @@ export type UserInputTranscribedEvent = {
|
|
|
80
80
|
type: 'user_input_transcribed';
|
|
81
81
|
transcript: string;
|
|
82
82
|
isFinal: boolean;
|
|
83
|
+
// TODO(AJS-106): add multi participant support
|
|
84
|
+
/** Not supported yet. Always null by default. */
|
|
83
85
|
speakerId: string | null;
|
|
84
86
|
createdAt: number;
|
|
87
|
+
language: string | null;
|
|
85
88
|
};
|
|
86
89
|
|
|
87
90
|
export const createUserInputTranscribedEvent = ({
|
|
88
91
|
transcript,
|
|
89
92
|
isFinal,
|
|
90
93
|
speakerId = null,
|
|
94
|
+
language = null,
|
|
91
95
|
createdAt = Date.now(),
|
|
92
96
|
}: {
|
|
93
97
|
transcript: string;
|
|
94
98
|
isFinal: boolean;
|
|
95
99
|
speakerId?: string | null;
|
|
100
|
+
language?: string | null;
|
|
96
101
|
createdAt?: number;
|
|
97
102
|
}): UserInputTranscribedEvent => ({
|
|
98
103
|
type: 'user_input_transcribed',
|
|
99
104
|
transcript,
|
|
100
105
|
isFinal,
|
|
101
106
|
speakerId,
|
|
107
|
+
language,
|
|
102
108
|
createdAt,
|
|
103
109
|
});
|
|
104
110
|
|
package/src/voice/generation.ts
CHANGED
|
@@ -28,7 +28,7 @@ import type { AudioOutput, LLMNode, TTSNode, TextOutput } from './io.js';
|
|
|
28
28
|
import { RunContext } from './run_context.js';
|
|
29
29
|
import type { SpeechHandle } from './speech_handle.js';
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
/** @internal */
|
|
32
32
|
export class _LLMGenerationData {
|
|
33
33
|
generatedText: string = '';
|
|
34
34
|
generatedToolCalls: FunctionCall[];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2025 LiveKit, Inc.
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
import type { AudioFrame } from '@livekit/rtc-node';
|
|
5
4
|
import {
|
|
5
|
+
AudioFrame,
|
|
6
6
|
AudioStream,
|
|
7
7
|
type NoiseCancellationOptions,
|
|
8
8
|
RemoteParticipant,
|
|
@@ -66,6 +66,17 @@ export class ParticipantAudioInputStream extends AudioInput {
|
|
|
66
66
|
? participant
|
|
67
67
|
: this.room.remoteParticipants.get(participantIdentity);
|
|
68
68
|
|
|
69
|
+
// Convert Map iterator to array for Pino serialization
|
|
70
|
+
const trackPublicationsArray = Array.from(participantValue?.trackPublications.values() ?? []);
|
|
71
|
+
|
|
72
|
+
this.logger.info(
|
|
73
|
+
{
|
|
74
|
+
participantValue: participantValue?.identity,
|
|
75
|
+
trackPublications: trackPublicationsArray,
|
|
76
|
+
lengthOfTrackPublications: trackPublicationsArray.length,
|
|
77
|
+
},
|
|
78
|
+
'participantValue.trackPublications',
|
|
79
|
+
);
|
|
69
80
|
// We need to check if the participant has a microphone track and subscribe to it
|
|
70
81
|
// in case we miss the tracksubscribed event
|
|
71
82
|
if (participantValue) {
|
|
@@ -290,7 +290,7 @@ export class ParticipantLegacyTranscriptionOutput extends BaseParticipantTranscr
|
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
export class ParalellTextOutput extends TextOutput {
|
|
293
|
-
|
|
293
|
+
/** @internal */
|
|
294
294
|
_sinks: TextOutput[];
|
|
295
295
|
|
|
296
296
|
constructor(sinks: TextOutput[], nextInChain?: TextOutput) {
|
|
@@ -64,22 +64,41 @@ const CLOSE_ON_DISCONNECT_REASONS: DisconnectReason[] = [
|
|
|
64
64
|
export interface RoomInputOptions {
|
|
65
65
|
audioSampleRate: number;
|
|
66
66
|
audioNumChannels: number;
|
|
67
|
+
/** If not given, default to True. */
|
|
67
68
|
textEnabled: boolean;
|
|
69
|
+
/** If not given, default to True. */
|
|
68
70
|
audioEnabled: boolean;
|
|
71
|
+
/** If not given, default to False. */
|
|
69
72
|
videoEnabled: boolean;
|
|
73
|
+
/** The participant to link to. If not provided, link to the first participant.
|
|
74
|
+
Can be overridden by the `participant` argument of RoomIO constructor or `set_participant`.
|
|
75
|
+
*/
|
|
70
76
|
participantIdentity?: string;
|
|
71
77
|
noiseCancellation?: NoiseCancellationOptions;
|
|
72
78
|
textInputCallback?: TextInputCallback;
|
|
79
|
+
/** Participant kinds accepted for auto subscription. If not provided,
|
|
80
|
+
accept `DEFAULT_PARTICIPANT_KINDS`
|
|
81
|
+
*/
|
|
73
82
|
participantKinds?: ParticipantKind[];
|
|
83
|
+
/** Close the AgentSession if the linked participant disconnects with reasons in
|
|
84
|
+
CLIENT_INITIATED, ROOM_DELETED, or USER_REJECTED.
|
|
85
|
+
*/
|
|
74
86
|
closeOnDisconnect: boolean;
|
|
75
87
|
}
|
|
76
88
|
|
|
77
89
|
export interface RoomOutputOptions {
|
|
90
|
+
/** If not given, default to True. */
|
|
78
91
|
transcriptionEnabled: boolean;
|
|
92
|
+
/** If not given, default to True. */
|
|
79
93
|
audioEnabled: boolean;
|
|
80
94
|
audioSampleRate: number;
|
|
81
95
|
audioNumChannels: number;
|
|
96
|
+
/** False to disable transcription synchronization with audio output.
|
|
97
|
+
Otherwise, transcription is emitted as quickly as available.
|
|
98
|
+
*/
|
|
82
99
|
syncTranscription: boolean;
|
|
100
|
+
/** The name of the audio track to publish. If not provided, default to "roomio_audio".
|
|
101
|
+
*/
|
|
83
102
|
audioPublishOptions: TrackPublishOptions;
|
|
84
103
|
}
|
|
85
104
|
|
|
@@ -350,7 +369,7 @@ export class RoomIO {
|
|
|
350
369
|
return this.transcriptionSynchronizer.textOutput;
|
|
351
370
|
}
|
|
352
371
|
|
|
353
|
-
|
|
372
|
+
/** Switch to a different participant */
|
|
354
373
|
setParticipant(participantIdentity: string | null) {
|
|
355
374
|
this.logger.debug({ participantIdentity }, 'setting participant');
|
|
356
375
|
if (participantIdentity === null) {
|
|
@@ -454,7 +473,7 @@ export class RoomIO {
|
|
|
454
473
|
|
|
455
474
|
this.initTask = Task.from((controller) => this.init(controller.signal));
|
|
456
475
|
|
|
457
|
-
//
|
|
476
|
+
// attach the agent to the session
|
|
458
477
|
if (this.audioInput) {
|
|
459
478
|
this.agentSession.input.audio = this.audioInput;
|
|
460
479
|
}
|
package/src/worker.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
import type {
|
|
5
|
-
JobAssignment,
|
|
6
|
-
JobTermination,
|
|
7
|
-
ParticipantInfo,
|
|
8
|
-
TrackSource,
|
|
9
|
-
} from '@livekit/protocol';
|
|
4
|
+
import type { JobAssignment, JobTermination, TrackSource } from '@livekit/protocol';
|
|
10
5
|
import {
|
|
11
6
|
type AvailabilityRequest,
|
|
12
7
|
JobType,
|
|
@@ -15,7 +10,7 @@ import {
|
|
|
15
10
|
WorkerMessage,
|
|
16
11
|
WorkerStatus,
|
|
17
12
|
} from '@livekit/protocol';
|
|
18
|
-
import { AccessToken, RoomServiceClient } from 'livekit-server-sdk';
|
|
13
|
+
import { AccessToken, ParticipantInfo, RoomServiceClient } from 'livekit-server-sdk';
|
|
19
14
|
import { EventEmitter } from 'node:events';
|
|
20
15
|
import os from 'node:os';
|
|
21
16
|
import { WebSocket } from 'ws';
|
|
@@ -284,7 +279,7 @@ export class Worker {
|
|
|
284
279
|
#logger = log().child({ version });
|
|
285
280
|
#inferenceExecutor?: InferenceProcExecutor;
|
|
286
281
|
|
|
287
|
-
|
|
282
|
+
/** @throws {@link MissingCredentialsError} if URL, API key or API secret are missing */
|
|
288
283
|
constructor(opts: WorkerOptions) {
|
|
289
284
|
opts.wsURL = opts.wsURL || process.env.LIVEKIT_URL || '';
|
|
290
285
|
opts.apiKey = opts.apiKey || process.env.LIVEKIT_API_KEY || '';
|
|
@@ -352,7 +347,7 @@ export class Worker {
|
|
|
352
347
|
}));
|
|
353
348
|
}
|
|
354
349
|
|
|
355
|
-
|
|
350
|
+
/** @throws {@link WorkerError} if worker failed to connect or already running */
|
|
356
351
|
async run() {
|
|
357
352
|
if (!this.#closed) {
|
|
358
353
|
throw new WorkerError('worker is already running');
|
|
@@ -433,7 +428,7 @@ export class Worker {
|
|
|
433
428
|
.map((proc) => proc.runningJob!);
|
|
434
429
|
}
|
|
435
430
|
|
|
436
|
-
|
|
431
|
+
/** @throws {@link WorkerError} if worker did not drain in time */
|
|
437
432
|
async drain(timeout?: number) {
|
|
438
433
|
if (this.#draining) {
|
|
439
434
|
return;
|