@livekit/agents 1.0.6 → 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.
Files changed (149) hide show
  1. package/dist/index.cjs +3 -0
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +2 -1
  4. package/dist/index.d.ts +2 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +2 -0
  7. package/dist/index.js.map +1 -1
  8. package/dist/inference/api_protos.cjs +104 -0
  9. package/dist/inference/api_protos.cjs.map +1 -0
  10. package/dist/inference/api_protos.d.cts +222 -0
  11. package/dist/inference/api_protos.d.ts +222 -0
  12. package/dist/inference/api_protos.d.ts.map +1 -0
  13. package/dist/inference/api_protos.js +70 -0
  14. package/dist/inference/api_protos.js.map +1 -0
  15. package/dist/inference/index.cjs +56 -0
  16. package/dist/inference/index.cjs.map +1 -0
  17. package/dist/inference/index.d.cts +8 -0
  18. package/dist/inference/index.d.ts +8 -0
  19. package/dist/inference/index.d.ts.map +1 -0
  20. package/dist/inference/index.js +23 -0
  21. package/dist/inference/index.js.map +1 -0
  22. package/dist/inference/llm.cjs +299 -0
  23. package/dist/inference/llm.cjs.map +1 -0
  24. package/dist/inference/llm.d.cts +107 -0
  25. package/dist/inference/llm.d.ts +107 -0
  26. package/dist/inference/llm.d.ts.map +1 -0
  27. package/dist/inference/llm.js +270 -0
  28. package/dist/inference/llm.js.map +1 -0
  29. package/dist/inference/stt.cjs +313 -0
  30. package/dist/inference/stt.cjs.map +1 -0
  31. package/dist/inference/stt.d.cts +87 -0
  32. package/dist/inference/stt.d.ts +87 -0
  33. package/dist/inference/stt.d.ts.map +1 -0
  34. package/dist/inference/stt.js +292 -0
  35. package/dist/inference/stt.js.map +1 -0
  36. package/dist/inference/tts.cjs +324 -0
  37. package/dist/inference/tts.cjs.map +1 -0
  38. package/dist/inference/tts.d.cts +77 -0
  39. package/dist/inference/tts.d.ts +77 -0
  40. package/dist/inference/tts.d.ts.map +1 -0
  41. package/dist/inference/tts.js +306 -0
  42. package/dist/inference/tts.js.map +1 -0
  43. package/dist/inference/utils.cjs +76 -0
  44. package/dist/inference/utils.cjs.map +1 -0
  45. package/dist/inference/utils.d.cts +5 -0
  46. package/dist/inference/utils.d.ts +5 -0
  47. package/dist/inference/utils.d.ts.map +1 -0
  48. package/dist/inference/utils.js +51 -0
  49. package/dist/inference/utils.js.map +1 -0
  50. package/dist/llm/remote_chat_context.cjs.map +1 -1
  51. package/dist/llm/remote_chat_context.d.cts +2 -0
  52. package/dist/llm/remote_chat_context.d.ts +2 -0
  53. package/dist/llm/remote_chat_context.d.ts.map +1 -1
  54. package/dist/llm/remote_chat_context.js.map +1 -1
  55. package/dist/tts/tts.cjs +1 -1
  56. package/dist/tts/tts.cjs.map +1 -1
  57. package/dist/tts/tts.js +1 -1
  58. package/dist/tts/tts.js.map +1 -1
  59. package/dist/utils.cjs +11 -0
  60. package/dist/utils.cjs.map +1 -1
  61. package/dist/utils.d.cts +1 -0
  62. package/dist/utils.d.ts +1 -0
  63. package/dist/utils.d.ts.map +1 -1
  64. package/dist/utils.js +10 -0
  65. package/dist/utils.js.map +1 -1
  66. package/dist/voice/agent.cjs +16 -3
  67. package/dist/voice/agent.cjs.map +1 -1
  68. package/dist/voice/agent.d.cts +5 -3
  69. package/dist/voice/agent.d.ts +5 -3
  70. package/dist/voice/agent.d.ts.map +1 -1
  71. package/dist/voice/agent.js +20 -3
  72. package/dist/voice/agent.js.map +1 -1
  73. package/dist/voice/agent_activity.cjs +4 -2
  74. package/dist/voice/agent_activity.cjs.map +1 -1
  75. package/dist/voice/agent_activity.d.ts.map +1 -1
  76. package/dist/voice/agent_activity.js +4 -2
  77. package/dist/voice/agent_activity.js.map +1 -1
  78. package/dist/voice/agent_session.cjs +16 -3
  79. package/dist/voice/agent_session.cjs.map +1 -1
  80. package/dist/voice/agent_session.d.cts +4 -3
  81. package/dist/voice/agent_session.d.ts +4 -3
  82. package/dist/voice/agent_session.d.ts.map +1 -1
  83. package/dist/voice/agent_session.js +20 -3
  84. package/dist/voice/agent_session.js.map +1 -1
  85. package/dist/voice/events.cjs +2 -0
  86. package/dist/voice/events.cjs.map +1 -1
  87. package/dist/voice/events.d.cts +4 -1
  88. package/dist/voice/events.d.ts +4 -1
  89. package/dist/voice/events.d.ts.map +1 -1
  90. package/dist/voice/events.js +2 -0
  91. package/dist/voice/events.js.map +1 -1
  92. package/dist/voice/generation.cjs.map +1 -1
  93. package/dist/voice/generation.d.cts +1 -0
  94. package/dist/voice/generation.d.ts +1 -0
  95. package/dist/voice/generation.d.ts.map +1 -1
  96. package/dist/voice/generation.js.map +1 -1
  97. package/dist/voice/room_io/_input.cjs.map +1 -1
  98. package/dist/voice/room_io/_input.d.ts.map +1 -1
  99. package/dist/voice/room_io/_input.js +1 -0
  100. package/dist/voice/room_io/_input.js.map +1 -1
  101. package/dist/voice/room_io/_output.cjs +1 -1
  102. package/dist/voice/room_io/_output.cjs.map +1 -1
  103. package/dist/voice/room_io/_output.d.cts +1 -0
  104. package/dist/voice/room_io/_output.d.ts +1 -0
  105. package/dist/voice/room_io/_output.d.ts.map +1 -1
  106. package/dist/voice/room_io/_output.js +1 -1
  107. package/dist/voice/room_io/_output.js.map +1 -1
  108. package/dist/voice/room_io/room_io.cjs +1 -1
  109. package/dist/voice/room_io/room_io.cjs.map +1 -1
  110. package/dist/voice/room_io/room_io.d.cts +20 -0
  111. package/dist/voice/room_io/room_io.d.ts +20 -0
  112. package/dist/voice/room_io/room_io.d.ts.map +1 -1
  113. package/dist/voice/room_io/room_io.js +1 -1
  114. package/dist/voice/room_io/room_io.js.map +1 -1
  115. package/dist/voice/transcription/synchronizer.cjs +1 -1
  116. package/dist/voice/transcription/synchronizer.cjs.map +1 -1
  117. package/dist/voice/transcription/synchronizer.d.cts +1 -0
  118. package/dist/voice/transcription/synchronizer.d.ts +1 -0
  119. package/dist/voice/transcription/synchronizer.d.ts.map +1 -1
  120. package/dist/voice/transcription/synchronizer.js +1 -1
  121. package/dist/voice/transcription/synchronizer.js.map +1 -1
  122. package/dist/worker.cjs +3 -3
  123. package/dist/worker.cjs.map +1 -1
  124. package/dist/worker.d.cts +3 -0
  125. package/dist/worker.d.ts +3 -0
  126. package/dist/worker.d.ts.map +1 -1
  127. package/dist/worker.js +4 -4
  128. package/dist/worker.js.map +1 -1
  129. package/package.json +3 -2
  130. package/src/index.ts +2 -1
  131. package/src/inference/api_protos.ts +82 -0
  132. package/src/inference/index.ts +32 -0
  133. package/src/inference/llm.ts +463 -0
  134. package/src/inference/stt.ts +444 -0
  135. package/src/inference/tts.ts +432 -0
  136. package/src/inference/utils.ts +66 -0
  137. package/src/llm/remote_chat_context.ts +2 -2
  138. package/src/tts/tts.ts +1 -1
  139. package/src/utils.ts +11 -0
  140. package/src/voice/agent.ts +31 -7
  141. package/src/voice/agent_activity.ts +2 -0
  142. package/src/voice/agent_session.ts +30 -6
  143. package/src/voice/events.ts +6 -0
  144. package/src/voice/generation.ts +1 -1
  145. package/src/voice/room_io/_input.ts +1 -1
  146. package/src/voice/room_io/_output.ts +1 -1
  147. package/src/voice/room_io/room_io.ts +21 -2
  148. package/src/voice/transcription/synchronizer.ts +1 -1
  149. package/src/worker.ts +5 -10
@@ -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
 
@@ -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
- /* @internal */
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,
@@ -290,7 +290,7 @@ export class ParticipantLegacyTranscriptionOutput extends BaseParticipantTranscr
290
290
  }
291
291
 
292
292
  export class ParalellTextOutput extends TextOutput {
293
- /* @internal */
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
- /* Switch to a different participant */
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
- // -- attatch the agent to the session --
476
+ // attach the agent to the session
458
477
  if (this.audioInput) {
459
478
  this.agentSession.input.audio = this.audioInput;
460
479
  }
@@ -277,7 +277,7 @@ export class TranscriptionSynchronizer {
277
277
  private _enabled: boolean = true;
278
278
  private closed: boolean = false;
279
279
 
280
- /* @internal */
280
+ /** @internal */
281
281
  _impl: SegmentSynchronizerImpl;
282
282
 
283
283
  private logger = log();
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
- /* @throws {@link MissingCredentialsError} if URL, API key or API secret are missing */
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
- /* @throws {@link WorkerError} if worker failed to connect or already running */
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
- /* @throws {@link WorkerError} if worker did not drain in time */
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;