-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for explicit agent dispatches
- Loading branch information
Showing
21 changed files
with
197 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
require "livekit/proto/livekit_agent_dispatch_twirp" | ||
require "livekit/auth_mixin" | ||
require 'livekit/utils' | ||
|
||
module LiveKit | ||
# Client for LiveKit's Agent Dispatch Service, which manages agent assignments to rooms | ||
# This client handles creating, deleting, and retrieving agent dispatches | ||
class AgentDispatchServiceClient < Twirp::Client | ||
client_for Proto::SIPService | ||
include AuthMixin | ||
attr_accessor :api_key, :api_secret | ||
|
||
def initialize(base_url, api_key: nil, api_secret: nil) | ||
super(File.join(Utils.to_http_url(base_url), "/twirp")) | ||
@api_key = api_key | ||
@api_secret = api_secret | ||
end | ||
|
||
# Creates a new agent dispatch for a named agent | ||
# @param room_name [String] The room to dispatch the agent to | ||
# @param agent_name [String] The name of the agent to dispatch | ||
# @param metadata [String, nil] Optional metadata to include with the dispatch | ||
# @return [LiveKit::Proto::AgentDispatch] Dispatch that was just created | ||
def create_dispatch( | ||
# room to dispatch agent to | ||
room_name, | ||
# agent to dispatch | ||
agent_name, | ||
# optional, metadata to send along with the job | ||
metadata: nil | ||
) | ||
request = Proto::CreateAgentDispatchRequest.new( | ||
room: room_name, | ||
agent_name: agent_name, | ||
metadata: metadata, | ||
) | ||
self.rpc( | ||
:CreateDispatch, | ||
request, | ||
headers: auth_header(VideoGrant.new(roomAdmin: true, room: room_name)), | ||
) | ||
end | ||
|
||
# Deletes an existing agent dispatch | ||
# @param dispatch_id [String] The ID of the dispatch to delete | ||
# @param room_name [String] The room name associated with the dispatch | ||
# @return [LiveKit::Proto::AgentDispatch] AgentDispatch record that was deleted | ||
def delete_dispatch(dispatch_id, room_name) | ||
request = Proto::DeleteAgentDispatchRequest.new( | ||
dispatch_id: dispatch_id, | ||
room: room_name, | ||
) | ||
self.rpc( | ||
:DeleteDispatch, | ||
request, | ||
headers: auth_header(VideoGrant.new(roomAdmin: true, room: room_name)), | ||
) | ||
end | ||
|
||
# Retrieves a specific agent dispatch by ID | ||
# @param dispatch_id [String] The ID of the dispatch to retrieve | ||
# @param room_name [String] The room name associated with the dispatch | ||
# @return [LiveKit::Proto::AgentDispatch, nil] The agent dispatch if found, nil otherwise | ||
def get_dispatch(dispatch_id, room_name) | ||
request = Proto::ListAgentDispatchRequest.new( | ||
dispatch_id: dispatch_id, | ||
room: room_name, | ||
) | ||
res = self.rpc( | ||
:ListDispatch, | ||
request, | ||
headers: auth_header(VideoGrant.new(roomAdmin: true, room: room_name)), | ||
) | ||
if res.agent_dispatches.size > 0 | ||
return res.agent_dispatches[0] | ||
end | ||
nil | ||
end | ||
|
||
# Lists all agent dispatches for a specific room | ||
# @param room_name [String] The room name to list dispatches for | ||
# @return [Array<LiveKit::Proto::AgentDispatch>] Array of agent dispatches | ||
def list_dispatch(room_name) | ||
request = Proto::ListAgentDispatchRequest.new( | ||
room: room_name, | ||
) | ||
res = self.rpc( | ||
:ListDispatch, | ||
request, | ||
headers: auth_header(VideoGrant.new(roomAdmin: true, room: room_name)), | ||
) | ||
res.agent_dispatches | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module LiveKit | ||
VERSION = "0.7.1" | ||
VERSION = "0.8.0" | ||
end |
Submodule protocol
updated
20 files
+6 −0 | CHANGELOG.md | |
+1 −1 | go.mod | |
+2 −2 | go.sum | |
+195 −161 | livekit/livekit_sip.pb.go | |
+144 −141 | livekit/livekit_sip.twirp.go | |
+1 −1 | logger/slog.go | |
+1 −1 | package.json | |
+6 −0 | packages/javascript/CHANGELOG.md | |
+1 −1 | packages/javascript/package.json | |
+8 −7 | packages/javascript/src/index.d.ts | |
+10 −5 | protobufs/livekit_sip.proto | |
+1 −5 | protobufs/rpc/io.proto | |
+9 −2 | protobufs/rpc/sip.proto | |
+282 −329 | rpc/io.pb.go | |
+89 −91 | rpc/io.psrpc.go | |
+7 −0 | rpc/sip.go | |
+149 −84 | rpc/sip.pb.go | |
+57 −53 | rpc/sip.psrpc.go | |
+9 −14 | utils/guid/id.go | |
+8 −0 | utils/proto.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.