From 689a0fe629d800fd034a3fe309f1d05668f39ea2 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 14 Oct 2024 22:15:43 -0700 Subject: [PATCH] feat: allow Agents to pass through initial attributes (#852) * feat: allow Agents to pass through initial attributes * changeset --- .changeset/afraid-fans-care.md | 5 +++++ agent/token.go | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .changeset/afraid-fans-care.md diff --git a/.changeset/afraid-fans-care.md b/.changeset/afraid-fans-care.md new file mode 100644 index 00000000..734a0b40 --- /dev/null +++ b/.changeset/afraid-fans-care.md @@ -0,0 +1,5 @@ +--- +"github.com/livekit/protocol": minor +--- + +allow Agents to pass through initial attributes diff --git a/agent/token.go b/agent/token.go index ff6822f7..6bc6bfce 100644 --- a/agent/token.go +++ b/agent/token.go @@ -7,7 +7,11 @@ import ( "github.com/livekit/protocol/livekit" ) -func BuildAgentToken(apiKey, secret, roomName, participantIdentity, participantName, participantMetadata string, permissions *livekit.ParticipantPermission) (string, error) { +func BuildAgentToken( + apiKey, secret, roomName, participantIdentity, participantName, participantMetadata string, + participantAttributes map[string]string, + permissions *livekit.ParticipantPermission, +) (string, error) { grant := &auth.VideoGrant{ RoomJoin: true, Agent: true, @@ -26,7 +30,8 @@ func BuildAgentToken(apiKey, secret, roomName, participantIdentity, participantN SetName(participantName). SetKind(livekit.ParticipantInfo_AGENT). SetValidFor(1 * time.Hour). - SetMetadata(participantMetadata) + SetMetadata(participantMetadata). + SetAttributes(participantAttributes) return at.ToJWT() }