Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
a1c7881
feat: add ability to inject `room` into useParticipantTracks
1egoman Sep 8, 2025
3ddafb9
feat: add optional generics to TrackReference
1egoman Sep 9, 2025
cf69b81
feat: use generic TrackReference in a few core observable functions
1egoman Sep 9, 2025
b773562
feat: add manual room parameters to a few hooks / components that pre…
1egoman Sep 9, 2025
12d9b6d
fix: address missing optional type bug
1egoman Sep 9, 2025
0eb755a
feat: proxy through TrackReference with a generic Track.Source value …
1egoman Sep 9, 2025
6c9c86b
feat: add ParticipantAgentAttributes
1egoman Sep 9, 2025
7186dd0
feat: add initial agent sdk port from agent-starter-react repo
1egoman Sep 9, 2025
cb75836
fix: ensure local mic state is cleaned up when track is unpublished
1egoman Sep 9, 2025
0bc19d8
feat: make useAgent work on its own
1egoman Sep 10, 2025
c503d0e
feat: add ability to also listen to emitter objects too in useAgentEv…
1egoman Sep 10, 2025
8c08f48
feat: add new SentMessage / ReceivedMessage types for message processing
1egoman Sep 10, 2025
3b8c958
feat: add useAgentMessages hook
1egoman Sep 10, 2025
a186bdc
feat: update useAgentMessages to read from conversation again, that i…
1egoman Sep 10, 2025
0a70f30
feat: add useAgentMessages for combining transcriptions + chat messag…
1egoman Sep 10, 2025
00ca24d
refactor: rename useAgentConversation to useAgentMessages
1egoman Sep 10, 2025
af4634f
feat: add conversation stub value so useConversation can call useAgent
1egoman Sep 11, 2025
ff88d67
feat: add legacyAgentState value to useAgent so it can interop with o…
1egoman Sep 11, 2025
d7ba73d
feat: move credentials into useAgentConversation subtle value
1egoman Sep 11, 2025
79cda27
feat: add ability to specify agents to dispatch in useConversation
1egoman Sep 11, 2025
a924744
feat: add agent.waitUntilAvailable at the end of conversation.connect…
1egoman Sep 11, 2025
4fbbdcc
feat: port to use more up to date version of ConnectionCredentials
1egoman Sep 11, 2025
61b93d5
fix: address bad dependencies in useConversation
1egoman Sep 11, 2025
ca9d1ba
feat: add more TrackReference generic returns to preexisting hooks
1egoman Sep 11, 2025
0ec83b2
feat: convert waitForDisconnectSignal into signal, and make it apply …
1egoman Sep 12, 2025
e83a9d2
fix: add missing hook dependencies
1egoman Sep 12, 2025
d6dcfff
feat: add wip useLocalTrack hook to try to unify media control under …
1egoman Sep 15, 2025
5d857cf
feat: get rid of old manual dispatch / kick methods
1egoman Sep 15, 2025
6a0a7fb
feat: include local participant info into useAgentConversation
1egoman Sep 15, 2025
86fab46
feat: remove all useLocalTrack / local participant stuff for now
1egoman Sep 15, 2025
1dd3ada
refactor: rename useAgentConversation => useConversationWith
1egoman Sep 15, 2025
88e33fd
feat: add local track state back in to useConversationWith
1egoman Sep 15, 2025
3f58a07
refactor: rename useAgentEvents -> useEvents
1egoman Sep 15, 2025
2e39baf
fix: drop old / unused event name
1egoman Sep 15, 2025
69ebc7c
fix: rename conversationalState on agent to lifecycleState
1egoman Sep 15, 2025
ec61f64
feat: add room option for useChat / useTextStream / useTrackToggle / …
1egoman Sep 15, 2025
0d35c4c
feat: use room option in useConversationMessages for useTranscriptions
1egoman Sep 15, 2025
fe1c34f
fix: add docs comments
1egoman Sep 15, 2025
0ae0d14
fix: address issue with local participant state not always being reac…
1egoman Sep 15, 2025
405adf8
feat: rename from conversation.begin -> conversation.start
1egoman Sep 17, 2025
c10a7b5
feat: rename agent.lifecycleState -> agent.state
1egoman Sep 17, 2025
434f72f
feat: add automatic agent dispatch version of hook
1egoman Sep 17, 2025
f85bc23
feat: rename credentials -> tokenSource
1egoman Sep 17, 2025
4d5ca76
feat: remove track reference generic logic, at least for now
1egoman Sep 17, 2025
6950566
feat: temporarily add token source
1egoman Sep 17, 2025
e6d5075
feat: get rid of AgentSessionConnectionState alias, just use existing…
1egoman Sep 17, 2025
a9f501d
feat: add useEnsureRoom in a few more places
1egoman Sep 17, 2025
39373a2
fix: revert changes to useTrack
1egoman Sep 17, 2025
d7f4618
fix: address minor type errors
1egoman Sep 18, 2025
805ecad
feat: rename camera -> cameraTrack, microphone -> microphoneTrack
1egoman Sep 19, 2025
2ba203c
feat: migrate to one AgentState value across useAgent + useVoiceAssis…
1egoman Sep 19, 2025
5282502
feat: add isPreConnectBufferEnabled to useAgent to detect if listenin…
1egoman Sep 19, 2025
4c3697f
fix: address typo
1egoman Sep 19, 2025
6008603
feat: get rid of TrackReferencePlaceholder and just use TrackReferenc…
1egoman Sep 19, 2025
974d6fa
fix: adjust comment language
1egoman Sep 19, 2025
b54e428
feat: remove -Instance suffix and rename to useXXXReturn
1egoman Sep 19, 2025
838ec88
refactor: rename isPreConnectBufferEnabled -> isBufferingSpeech
1egoman Sep 22, 2025
14d8e73
fix: update comment to include initializing
1egoman Sep 22, 2025
4a1de69
fix: get rid of useAgent _name param
1egoman Sep 22, 2025
ce14625
feat: rename useConversation hooks to useSession instead
1egoman Sep 25, 2025
1f803e5
feat: introduce new flexible / inflexible token source idea
1egoman Sep 25, 2025
d6ec649
refactor: update tokensource method names
1egoman Sep 25, 2025
2bbeb19
docs: add docs comments back in
1egoman Sep 25, 2025
2d1cabb
feat: add decodeTokenPayload a bit closer to what lukas did
1egoman Sep 25, 2025
cb2ece8
feat: make sandboxId a dedicated parameter on TokenSourceSandboxToken…
1egoman Sep 25, 2025
1fea3bc
feat: flip locking logic around to satisfy review comment
1egoman Sep 25, 2025
3f71305
feat: add some typescript logic to try to ensure that all keys in Tok…
1egoman Sep 25, 2025
0ab57bd
fix: make update method protected
1egoman Sep 25, 2025
d8bd2b0
refactor: rename to TokenSourceFixed / TokenSourceConfigurable
1egoman Sep 26, 2025
146a06a
fix: address issue where cached options not being set was not being c…
1egoman Sep 26, 2025
166c692
refactor: rename TokenSource.generate -> TokenSource.getValue
1egoman Sep 26, 2025
1dff480
feat: convert TokenSource to be stateless again
1egoman Sep 26, 2025
e26fb16
feat: rename getToken to fetch in TokenSource implementation
1egoman Sep 29, 2025
fc7ee8a
refactor: rename subtle to internal, move useSession room out of subt…
1egoman Oct 1, 2025
f37b6ae
fix: run npm run format
1egoman Oct 1, 2025
dd9e32b
fix: address empty object type eslint error
1egoman Oct 1, 2025
99a2c91
fix: address usage of roomConfig
1egoman Oct 1, 2025
8f6328c
feat: add version tags to all new agent sdk related abstractions
1egoman Oct 1, 2025
85304b8
fix: update generated components-react.api.md file
1egoman Oct 1, 2025
90c394e
fix: add seemingly forgotten version tag to UseTextStreamOptions
1egoman Oct 1, 2025
754cee0
refactor: drop tokensource copy and update to point to new livekit-cl…
1egoman Oct 3, 2025
a0c8e8c
feat: add new RoomProvider component
1egoman Oct 3, 2025
bdc6e77
fix: adjust structure of SessionStub in useSession
1egoman Oct 3, 2025
9341a55
feat: update useSession to pass tokenSource / options into new Room c…
1egoman Oct 3, 2025
7073ac6
fix: run npm run format:write
1egoman Oct 3, 2025
afd5619
feat: update useSession to pass token source / room options as two pa…
1egoman Oct 6, 2025
52097c1
Revert "feat: update useSession to pass token source / room options a…
1egoman Oct 7, 2025
5968142
Revert "fix: run npm run format:write"
1egoman Oct 7, 2025
a4c049a
Revert "feat: update useSession to pass tokenSource / options into ne…
1egoman Oct 7, 2025
b3918f9
feat: move tokenFetchOptions / roomConnectOptions into explicit keys …
1egoman Oct 7, 2025
fdd28f2
feat: add session context and use it throughout new agents sdk compon…
1egoman Oct 7, 2025
47cc0dd
fix: run npm run format:write
1egoman Oct 7, 2025
6832031
feat: add new SessionProvider component
1egoman Oct 7, 2025
aad237c
feat: add @livekit/protocol to catalog so that all subpackages are us…
1egoman Oct 7, 2025
bddfe08
feat: add explicit SessionContext to tree
1egoman Oct 7, 2025
46cebf3
chore: commit latest api-extractor data
1egoman Oct 7, 2025
fd7add4
fix: remove SessionContext from external package exports
1egoman Oct 7, 2025
ea42c88
fix: remove tsdoc @link tag because api-extractor throws a warning on it
1egoman Oct 7, 2025
6dd52c1
fix: use emojis in ascii flow diagram to work around api extractor wa…
1egoman Oct 7, 2025
9ee9556
fix: address one more api extractor warning
1egoman Oct 7, 2025
a6eba2b
feat: move token fetch options back into root
1egoman Oct 8, 2025
1a27a6c
fix: remove fixme comment
1egoman Oct 8, 2025
667d556
feat: add / remove events from agents sdk abstractions
1egoman Oct 8, 2025
05debba
refactor: convert to React.useXXX form for hooks
1egoman Oct 9, 2025
dd07946
feat: move useAgentTimeoutIdStore away from zustand and put it at the…
1egoman Oct 9, 2025
b1a35c5
feat: update api-extrator docs based on small api interface changes
1egoman Oct 9, 2025
f3ab908
feat: install events package instead of relying on node eventemitter …
1egoman Oct 9, 2025
e1e22db
fix: remove prepareConnection dependency in useEffect
1egoman Oct 9, 2025
320435e
fix: remove zustand dependency
1egoman Oct 10, 2025
7fdadbc
feat: add missing type reexports from core package
1egoman Oct 10, 2025
78e7abd
fix: remove redundant ../ part in path
1egoman Oct 10, 2025
8c9cba0
fix: add core package rexports to api-extractor docs
1egoman Oct 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
},
"devDependencies": {
"@livekit/components-styles": "workspace:*",
"@livekit/protocol": "^1.38.0",
"@livekit/protocol": "catalog:",
"@microsoft/api-extractor": "^7.36.0",
"@size-limit/file": "^11.0.2",
"@size-limit/webpack": "^11.0.2",
Expand Down
25 changes: 14 additions & 11 deletions packages/core/src/components/chat.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable camelcase */
import type { Participant, Room, ChatMessage, SendTextOptions } from 'livekit-client';
import type { Room, SendTextOptions } from 'livekit-client';
import { compareVersions, RoomEvent } from 'livekit-client';
import { BehaviorSubject, Subject, scan, map, takeUntil, from, filter } from 'rxjs';
import {
Expand All @@ -9,15 +9,10 @@ import {
setupDataMessageHandler,
} from '../observables/dataChannel';
import { log } from '../logger';
import { ChatMessage, ReceivedChatMessage } from '../messages/types';

/** @public */
export type { ChatMessage };

/** @public */
export interface ReceivedChatMessage extends ChatMessage {
from?: Participant;
attributes?: Record<string, string>;
}
export type { ChatMessage, ReceivedChatMessage };

export interface LegacyChatMessage extends ChatMessage {
ignoreLegacy?: boolean;
Expand Down Expand Up @@ -55,7 +50,9 @@ function isIgnorableChatMessage(msg: ReceivedChatMessage | LegacyReceivedChatMes
}

const decodeLegacyMsg = (message: Uint8Array) =>
JSON.parse(new TextDecoder().decode(message)) as LegacyReceivedChatMessage | ReceivedChatMessage;
JSON.parse(new TextDecoder().decode(message)) as
| LegacyReceivedChatMessage
| Exclude<ReceivedChatMessage, 'type'>;

const encodeLegacyMsg = (message: LegacyChatMessage) =>
new TextEncoder().encode(JSON.stringify(message));
Expand Down Expand Up @@ -93,8 +90,9 @@ export function setupChat(room: Room, options?: ChatOptions) {
timestamp,
message: chunk,
from: room.getParticipantByIdentity(participantInfo.identity),
type: 'chatMessage',
// editTimestamp: type === 'update' ? timestamp : undefined,
} as ReceivedChatMessage;
} satisfies ReceivedChatMessage;
}),
);
streamObservable.subscribe({
Expand All @@ -111,7 +109,11 @@ export function setupChat(room: Room, options?: ChatOptions) {
if (isIgnorableChatMessage(parsedMessage)) {
return undefined;
}
const newMessage: ReceivedChatMessage = { ...parsedMessage, from: msg.from };
const newMessage: ReceivedChatMessage = {
...parsedMessage,
type: 'chatMessage',
from: msg.from,
};
return newMessage;
}),
filter((msg) => !!msg),
Expand Down Expand Up @@ -169,6 +171,7 @@ export function setupChat(room: Room, options?: ChatOptions) {

const receivedChatMsg: ReceivedChatMessage = {
...chatMsg,
type: 'chatMessage',
from: room.localParticipant,
attributes: options.attributes,
};
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/components/textStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { RoomEvent, type Room } from 'livekit-client';
import type { TextStreamInfo } from 'livekit-client/dist/src/room/types';
import { from, scan, Subject, type Observable } from 'rxjs';
import { share, tap } from 'rxjs/operators';
import { ParticipantAgentAttributes } from '../helper';

export interface TextStreamData {
text: string;
Expand Down Expand Up @@ -57,7 +58,7 @@ export function setupTextStream(room: Room, topic: string): Observable<TextStrea
const textStreamsSubject = new Subject<TextStreamData[]>();
let textStreams: TextStreamData[] = [];

const segmentAttribute = 'lk.segment_id';
const segmentAttribute = ParticipantAgentAttributes.TranscriptionSegmentId;

// Create shared observable and store in cache
const sharedObservable = textStreamsSubject.pipe(
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/helper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ export {
export { setDifference } from './set-helper';
export { supportsScreenSharing } from './featureDetection';
export * from './transcriptions';
export * from './participant-attributes';
9 changes: 9 additions & 0 deletions packages/core/src/helper/participant-attributes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** An enum of first party livekit attributes generated by the serverside agents sdk */
export enum ParticipantAgentAttributes {
AgentState = 'lk.agent.state',
PublishOnBehalf = 'lk.publish_on_behalf',

TranscriptionFinal = 'lk.transcription_final',
TranscriptionSegmentId = 'lk.segment_id',
TranscribedTrackId = 'lk.transcribed_track_id',
}
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from './helper';
export * from './types';
export * from './sorting';
export * from './track-reference';
export * from './messages';

export * from './components/mediaToggle';
export * from './components/mediaDeviceSelect';
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/messages/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './types';
46 changes: 46 additions & 0 deletions packages/core/src/messages/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import type { Participant, ChatMessage } from 'livekit-client';

/** @public */
export type { ChatMessage };

export type SentMessage = ChatMessage;

type ReceivedMessageWithType<Type extends string, Metadata extends object = object> = {
id: string;
timestamp: number;

type: Type;

from?: Participant;
attributes?: Record<string, string>;
} & Metadata;

/** @public */
export type ReceivedChatMessage = ReceivedMessageWithType<
'chatMessage',
ChatMessage & {
from?: Participant;
attributes?: Record<string, string>;
}
>;

export type ReceivedUserTranscriptionMessage = ReceivedMessageWithType<
'userTranscript',
{
message: string;
}
>;

export type ReceivedAgentTranscriptionMessage = ReceivedMessageWithType<
'agentTranscript',
{
message: string;
}
>;

/** @public */
export type ReceivedMessage =
| ReceivedUserTranscriptionMessage
| ReceivedAgentTranscriptionMessage
| ReceivedChatMessage;
// TODO: images? attachments? rpc?
7 changes: 6 additions & 1 deletion packages/core/src/observables/dataChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ export function setupChatMessageHandler(room: Room) {
const send = async (text: string, options: SendTextOptions): Promise<ReceivedChatMessage> => {
const msg = await room.localParticipant.sendChatMessage(text, options);
await room.localParticipant.sendText(text, options);
return { ...msg, from: room.localParticipant, attachedFiles: options.attachments };
return {
...msg,
type: 'chatMessage',
from: room.localParticipant,
attachedFiles: options.attachments,
};
};

const edit = async (text: string, originalMsg: ChatMessage) => {
Expand Down
Loading