Skip to content

Commit 88b7698

Browse files
authored
[Components] livekit - new components (#16839)
1 parent 2c64fe8 commit 88b7698

File tree

11 files changed

+552
-92
lines changed

11 files changed

+552
-92
lines changed

components/livekit/actions/create-ingress-from-url/create-ingress-from-url.mjs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,22 @@ export default {
55
key: "livekit-create-ingress-from-url",
66
name: "Create Ingress From URL",
77
description: "Create a new ingress from url in LiveKit. [See the documentation](https://docs.livekit.io/home/ingress/overview/#url-input-example).",
8-
version: "0.0.1",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
app,
12-
name: {
13-
type: "string",
14-
label: "Ingress Name",
15-
description: "The name of the ingress",
16-
optional: true,
17-
},
1812
roomName: {
1913
description: "The name of the room to send media to",
2014
propDefinition: [
2115
app,
2216
"room",
2317
],
2418
},
19+
url: {
20+
type: "string",
21+
label: "URL",
22+
description: "URL of the media to pull for ingresses of type URL",
23+
},
2524
participantIdentity: {
2625
type: "string",
2726
label: "Participant Identity",
@@ -39,6 +38,12 @@ export default {
3938
description: "Metadata to attach to the participant",
4039
optional: true,
4140
},
41+
name: {
42+
type: "string",
43+
label: "Ingress Name",
44+
description: "The name of the ingress",
45+
optional: true,
46+
},
4247
bypassTranscoding: {
4348
type: "boolean",
4449
label: "Bypass Transcoding",
@@ -51,11 +56,6 @@ export default {
5156
description: "Whether to enable transcoding or forward the input media directly. Transcoding is required for all input types except WHIP. For WHIP, the default is to not transcode.",
5257
optional: true,
5358
},
54-
url: {
55-
type: "string",
56-
label: "URL",
57-
description: "URL of the media to pull for ingresses of type URL",
58-
},
5959
},
6060
async run({ $ }) {
6161
const {

components/livekit/actions/create-room/create-room.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "livekit-create-room",
55
name: "Create Room",
66
description: "Create a new room in LiveKit. [See the documentation](https://docs.livekit.io/home/server/managing-rooms/#create-a-room).",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
app,

components/livekit/actions/delete-room/delete-room.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "livekit-delete-room",
55
name: "Delete Room",
66
description: "Delete a room in LiveKit. [See the documentation](https://docs.livekit.io/home/server/managing-rooms/#delete-a-room)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
app,
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
import app from "../../livekit.app.mjs";
2+
3+
export default {
4+
key: "livekit-generate-access-token",
5+
name: "Generate Access Token",
6+
description: "Generate an access token for a participant to join a LiveKit room. [See the documentation](https://github.com/livekit/node-sdks/tree/main/packages/livekit-server-sdk).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
room: {
12+
description: "The name of the room to join",
13+
optional: true,
14+
propDefinition: [
15+
app,
16+
"room",
17+
],
18+
},
19+
ttl: {
20+
type: "integer",
21+
label: "Token TTL (seconds)",
22+
description: "How long the access token should be valid for (in seconds)",
23+
optional: true,
24+
},
25+
name: {
26+
type: "string",
27+
label: "Participant Name",
28+
description: "Display name for the participant",
29+
optional: true,
30+
},
31+
identity: {
32+
type: "string",
33+
label: "Participant Identity",
34+
description: "Unique identity for the participant joining the call",
35+
},
36+
metadata: {
37+
type: "string",
38+
label: "Participant Metadata",
39+
description: "Optional metadata to attach to the participant",
40+
optional: true,
41+
},
42+
canPublish: {
43+
type: "boolean",
44+
label: "Can Publish",
45+
description: "Whether the participant can publish audio/video tracks",
46+
optional: true,
47+
},
48+
canSubscribe: {
49+
type: "boolean",
50+
label: "Can Subscribe",
51+
description: "Whether the participant can subscribe to other participants' tracks",
52+
optional: true,
53+
},
54+
canPublishData: {
55+
type: "boolean",
56+
label: "Can Publish Data",
57+
description: "Whether the participant can publish data messages",
58+
optional: true,
59+
},
60+
hidden: {
61+
type: "boolean",
62+
label: "Hidden Participant",
63+
description: "Whether the participant should be hidden from other participants",
64+
optional: true,
65+
},
66+
roomCreate: {
67+
type: "boolean",
68+
label: "Room Create Permission",
69+
description: "Permission to create rooms",
70+
optional: true,
71+
},
72+
roomList: {
73+
type: "boolean",
74+
label: "Room List Permission",
75+
description: "Permission to list rooms",
76+
optional: true,
77+
},
78+
roomRecord: {
79+
type: "boolean",
80+
label: "Room Record Permission",
81+
description: "Permission to start a recording",
82+
optional: true,
83+
},
84+
roomAdmin: {
85+
type: "boolean",
86+
label: "Room Admin Permission",
87+
description: "Permission to control the specific room",
88+
optional: true,
89+
},
90+
ingressAdmin: {
91+
type: "boolean",
92+
label: "Ingress Admin Permission",
93+
description: "Permission to control ingress, not specific to any room or ingress",
94+
optional: true,
95+
},
96+
canUpdateOwnMetadata: {
97+
type: "boolean",
98+
label: "Can Update Own Metadata",
99+
description: "Allow participant to update its own metadata",
100+
optional: true,
101+
},
102+
recorder: {
103+
type: "boolean",
104+
label: "Recorder",
105+
description: "Participant is recording the room, allows room to indicate it's being recorded",
106+
optional: true,
107+
},
108+
agent: {
109+
type: "boolean",
110+
label: "Agent",
111+
description: "Participant allowed to connect to LiveKit as Agent Framework worker",
112+
optional: true,
113+
},
114+
canSubscribeMetrics: {
115+
type: "boolean",
116+
label: "Can Subscribe Metrics",
117+
description: "Allow participant to subscribe to metrics",
118+
optional: true,
119+
},
120+
destinationRoom: {
121+
type: "string",
122+
label: "Destination Room",
123+
description: "Destination room which this participant can forward to",
124+
optional: true,
125+
},
126+
createRoomIfNotExists: {
127+
type: "boolean",
128+
label: "Create Room If Not Exists",
129+
description: "Whether to create the room if it doesn't exist",
130+
optional: true,
131+
},
132+
},
133+
async run({ $ }) {
134+
const {
135+
app,
136+
ttl,
137+
identity,
138+
name,
139+
metadata,
140+
room,
141+
createRoomIfNotExists,
142+
canPublish,
143+
canSubscribe,
144+
canPublishData,
145+
hidden,
146+
roomCreate,
147+
roomList,
148+
roomRecord,
149+
roomAdmin,
150+
ingressAdmin,
151+
canUpdateOwnMetadata,
152+
recorder,
153+
agent,
154+
canSubscribeMetrics,
155+
destinationRoom,
156+
} = this;
157+
158+
// Create room if it doesn't exist and option is enabled
159+
if (createRoomIfNotExists) {
160+
await app.createRoom({
161+
name: room,
162+
});
163+
}
164+
165+
// Create access token for the participant
166+
const response = await app.createAccessToken({
167+
identity,
168+
name,
169+
metadata,
170+
ttl,
171+
grant: {
172+
roomJoin: true,
173+
room,
174+
roomCreate,
175+
roomList,
176+
roomRecord,
177+
roomAdmin,
178+
ingressAdmin,
179+
canPublish,
180+
canSubscribe,
181+
canPublishData,
182+
canUpdateOwnMetadata,
183+
hidden,
184+
recorder,
185+
agent,
186+
canSubscribeMetrics,
187+
destinationRoom,
188+
},
189+
});
190+
191+
$.export("$summary", "Successfully generated access token for participant to join the call.");
192+
193+
return response;
194+
},
195+
};

components/livekit/actions/list-rooms/list-rooms.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "livekit-list-rooms",
55
name: "List Rooms",
66
description: "List all rooms with LiveKit. [See the documentation](https://docs.livekit.io/home/server/managing-rooms/#list-rooms).",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
app,
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import app from "../../livekit.app.mjs";
2+
3+
export default {
4+
key: "livekit-remove-participants",
5+
name: "Remove Participants",
6+
description: "Remove specific participants from a LiveKit room. [See the documentation](https://github.com/livekit/node-sdks/tree/main/packages/livekit-server-sdk).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
room: {
12+
propDefinition: [
13+
app,
14+
"room",
15+
],
16+
},
17+
identities: {
18+
type: "string[]",
19+
label: "Participant Identities",
20+
description: "Identities of participants to remove from the room",
21+
propDefinition: [
22+
app,
23+
"identity",
24+
({ room }) => ({
25+
room,
26+
}),
27+
],
28+
},
29+
},
30+
async run({ $ }) {
31+
const {
32+
app,
33+
room,
34+
identities,
35+
} = this;
36+
37+
const results = await Promise.all(
38+
identities.map(async (identity) => {
39+
await app.removeParticipant(room, identity);
40+
return identity;
41+
}),
42+
);
43+
44+
$.export("$summary", `Successfully removed \`${identities.length}\` participant(s) from room: \`${room}\``);
45+
46+
return {
47+
room,
48+
removedParticipants: results,
49+
};
50+
},
51+
};

components/livekit/common/constants.mjs

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)