Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions Sources/LiveKit/Token/TokenSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public struct TokenRequestOptions: Sendable, Equatable {
public let agentName: String?
/// Metadata passed to the agent job
public let agentMetadata: String?
/// Optional deployment to target. Leave empty to target the production deployment.
public let agentDeployment: String?

public init(
roomName: String? = nil,
Expand All @@ -69,6 +71,7 @@ public struct TokenRequestOptions: Sendable, Equatable {
participantAttributes: [String: String]? = nil,
agentName: String? = nil,
agentMetadata: String? = nil,
agentDeployment: String? = nil,
) {
self.roomName = roomName
self.participantName = participantName
Expand All @@ -77,11 +80,12 @@ public struct TokenRequestOptions: Sendable, Equatable {
self.participantAttributes = participantAttributes
self.agentName = agentName
self.agentMetadata = agentMetadata
self.agentDeployment = agentDeployment
}

func toRequest() -> TokenSourceRequest {
let agents: [RoomAgentDispatch]? = if agentName != nil || agentMetadata != nil {
[RoomAgentDispatch(agentName: agentName, metadata: agentMetadata)]
let agents: [RoomAgentDispatch]? = if agentName != nil || agentMetadata != nil || agentDeployment != nil {
[RoomAgentDispatch(agentName: agentName, metadata: agentMetadata, deployment: agentDeployment)]
} else {
nil
}
Expand Down
6 changes: 6 additions & 0 deletions Sources/LiveKit/Types/RoomConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,22 @@ public struct RoomAgentDispatch: Encodable, Sendable, Equatable {
/// Metadata for the agent
public let metadata: String?

/// Optional deployment to target. Leave empty to target the production deployment.
public let deployment: String?

enum CodingKeys: String, CodingKey {
case agentName = "agent_name"
case metadata
case deployment
}

public init(
agentName: String? = nil,
metadata: String? = nil,
deployment: String? = nil,
) {
self.agentName = agentName
self.metadata = metadata
self.deployment = deployment
}
}
Loading