Skip to content

Commit

Permalink
agents protocol proposal (#595)
Browse files Browse the repository at this point in the history
* simulate-job

* generated protobuf

* wip

* job_cost

* Update livekit_agent.proto

* generated protobuf

* Update livekit_agent.proto

* generated protobuf

* Update livekit_agent.proto

* Update livekit_agent.proto

* Update livekit_agent.proto

* generated protobuf

* Update livekit_agent.proto

* renamed to pong

Co-authored-by: David Zhao <[email protected]>

* Update livekit_agent.proto

* Update livekit_agent.proto

* generated protobuf

* remove job_cost & ParticipantPermission

* generated protobuf

* Update livekit_agent.proto

* generated protobuf

* wip

* generated protobuf

* generated protobuf

* Update livekit_agent.proto

* generated protobuf

* generated protobuf

* handler namespace

* generated protobuf

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: David Zhao <[email protected]>
Co-authored-by: David Colburn <[email protected]>
  • Loading branch information
4 people authored Apr 3, 2024
1 parent fc68e8d commit bc6c7ff
Show file tree
Hide file tree
Showing 11 changed files with 1,436 additions and 615 deletions.
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions agent/token.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package agent

import (
"time"

"github.com/livekit/protocol/auth"
"github.com/livekit/protocol/livekit"
)

func BuildAgentToken(apiKey, secret, roomName, participantIdentity, participantName, participantMetadata string, permissions *livekit.ParticipantPermission) (string, error) {
grant := &auth.VideoGrant{
RoomJoin: true,
Agent: true,
Room: roomName,
CanSubscribe: &permissions.CanSubscribe,
CanPublish: &permissions.CanPublish,
CanPublishData: &permissions.CanPublishData,
Hidden: permissions.Hidden,
CanUpdateOwnMetadata: &permissions.CanUpdateMetadata,
}

at := auth.NewAccessToken(apiKey, secret).
AddGrant(grant).
SetIdentity(participantIdentity).
SetName(participantName).
SetKind(livekit.ParticipantInfo_AGENT).
SetValidFor(1 * time.Hour).
SetMetadata(participantMetadata)

return at.ToJWT()
}
Loading

0 comments on commit bc6c7ff

Please sign in to comment.