Skip to content

Commit e402e57

Browse files
authored
feat: ability to set agent & metadata when creating token (#664)
* feat: ability to set agent & metadata when creating token * fix job
1 parent b877d29 commit e402e57

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

cmd/lk/token.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ var (
107107
Name: "grant",
108108
Usage: "Additional `VIDEO_GRANT` fields. It'll be merged with other arguments (JSON formatted)",
109109
},
110+
&cli.StringFlag{
111+
Name: "agent",
112+
Usage: "Agent to dispatch to the room (identified by agent_name)",
113+
},
114+
&cli.StringFlag{
115+
Name: "job-metadata",
116+
Usage: "Metadata attached to job dispatched to the agent (ctx.job.metadata)",
117+
},
110118
},
111119
},
112120
},
@@ -322,6 +330,19 @@ func createToken(ctx context.Context, c *cli.Command) error {
322330

323331
at := accessToken(project.APIKey, project.APISecret, grant, participant)
324332

333+
if grant.RoomJoin {
334+
if agent := c.String("agent"); agent != "" {
335+
jobMetadata := c.String("job-metadata")
336+
at.SetRoomConfig(&livekit.RoomConfiguration{
337+
Agents: []*livekit.RoomAgentDispatch{
338+
{
339+
AgentName: agent,
340+
Metadata: jobMetadata,
341+
},
342+
},
343+
})
344+
}
345+
}
325346
if metadata != "" {
326347
at.SetMetadata(metadata)
327348
}

0 commit comments

Comments
 (0)