@meshagent/meshagent 0.39.2 → 0.39.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +134 -21
- package/dist/browser/entrypoint.d.ts +1426 -1464
- package/dist/browser/meshagent-client.js +7 -2
- package/dist/browser/package.json +1 -0
- package/dist/esm/agent-client.js +18 -12
- package/dist/esm/agent.js +26 -18
- package/dist/esm/api_keys.js +21 -11
- package/dist/esm/client.js +13 -7
- package/dist/esm/completer.js +5 -1
- package/dist/esm/containers-client.js +85 -80
- package/dist/esm/datasets-client.js +105 -95
- package/dist/esm/developer-client.js +15 -11
- package/dist/esm/document.js +20 -11
- package/dist/esm/entrypoint.d.ts +1426 -1464
- package/dist/esm/entrypoint.js +12 -1
- package/dist/esm/event-emitter.js +5 -1
- package/dist/esm/helpers.js +23 -15
- package/dist/esm/index.js +49 -33
- package/dist/esm/lk-client.js +12 -7
- package/dist/esm/lk-protocol.js +8 -4
- package/dist/esm/memory-client.js +11 -7
- package/dist/esm/meshagent-client.js +88 -79
- package/dist/esm/messaging-client.js +37 -33
- package/dist/esm/package.json +1 -0
- package/dist/esm/participant-token.js +62 -34
- package/dist/esm/participant.js +9 -3
- package/dist/esm/protocol.js +43 -29
- package/dist/esm/queues-client.js +17 -12
- package/dist/esm/requirement.js +11 -4
- package/dist/esm/response.js +34 -22
- package/dist/esm/room-client.js +134 -129
- package/dist/esm/room-event.js +21 -9
- package/dist/esm/room-server-client.js +18 -13
- package/dist/esm/runtime.js +10 -1
- package/dist/esm/schema.js +18 -9
- package/dist/esm/secrets-client.js +35 -31
- package/dist/esm/services-client.js +13 -9
- package/dist/esm/storage-client.js +38 -32
- package/dist/esm/stream-controller.js +5 -1
- package/dist/esm/sync-client.js +42 -38
- package/dist/esm/tool-content-type.js +5 -1
- package/dist/esm/utils.js +20 -10
- package/dist/esm/version.js +4 -1
- package/dist/node/entrypoint.d.ts +1426 -1464
- package/dist/node/meshagent-client.js +7 -2
- package/dist/node/package.json +1 -0
- package/package.json +1 -1
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessagingClient = void 0;
|
|
4
|
+
const completer_1 = require("./completer");
|
|
5
|
+
const event_emitter_1 = require("./event-emitter");
|
|
6
|
+
const participant_1 = require("./participant");
|
|
7
|
+
const response_1 = require("./response");
|
|
8
|
+
const room_event_1 = require("./room-event");
|
|
9
|
+
const room_server_client_1 = require("./room-server-client");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
8
11
|
const globalScope = globalThis;
|
|
9
12
|
function bytesToBase64(bytes) {
|
|
10
13
|
if (globalScope.Buffer != null) {
|
|
@@ -19,7 +22,7 @@ function bytesToBase64(bytes) {
|
|
|
19
22
|
}
|
|
20
23
|
return globalScope.btoa(binary);
|
|
21
24
|
}
|
|
22
|
-
|
|
25
|
+
class MessagingClient extends event_emitter_1.EventEmitter {
|
|
23
26
|
constructor({ room }) {
|
|
24
27
|
super();
|
|
25
28
|
this._messageHandler = this._handleMessageSend.bind(this);
|
|
@@ -60,14 +63,14 @@ export class MessagingClient extends EventEmitter {
|
|
|
60
63
|
await this.client.invoke({
|
|
61
64
|
toolkit: "messaging",
|
|
62
65
|
tool: operation,
|
|
63
|
-
input: new JsonContent({ json: input }),
|
|
66
|
+
input: new response_1.JsonContent({ json: input }),
|
|
64
67
|
});
|
|
65
68
|
}
|
|
66
69
|
_invokeNowait({ operation, input, }) {
|
|
67
70
|
this.client.invokeNowait({
|
|
68
71
|
toolkit: "messaging",
|
|
69
72
|
tool: operation,
|
|
70
|
-
input: new JsonContent({ json: input }),
|
|
73
|
+
input: new response_1.JsonContent({ json: input }),
|
|
71
74
|
});
|
|
72
75
|
}
|
|
73
76
|
start() {
|
|
@@ -101,7 +104,7 @@ export class MessagingClient extends EventEmitter {
|
|
|
101
104
|
if (this._messageQueueClosed) {
|
|
102
105
|
return null;
|
|
103
106
|
}
|
|
104
|
-
this._messageQueued ?? (this._messageQueued = new Completer());
|
|
107
|
+
this._messageQueued ?? (this._messageQueued = new completer_1.Completer());
|
|
105
108
|
await this._messageQueued.fut;
|
|
106
109
|
}
|
|
107
110
|
}
|
|
@@ -114,7 +117,7 @@ export class MessagingClient extends EventEmitter {
|
|
|
114
117
|
}
|
|
115
118
|
_queueMessage(message) {
|
|
116
119
|
if (this._messageQueueClosed) {
|
|
117
|
-
throw new RoomServerException("Cannot send messages because messaging has been stopped");
|
|
120
|
+
throw new room_server_client_1.RoomServerException("Cannot send messages because messaging has been stopped");
|
|
118
121
|
}
|
|
119
122
|
this._messageQueue.push(message);
|
|
120
123
|
this._wakeMessageQueue();
|
|
@@ -170,7 +173,7 @@ export class MessagingClient extends EventEmitter {
|
|
|
170
173
|
return participant;
|
|
171
174
|
}
|
|
172
175
|
_markParticipantOffline(participant) {
|
|
173
|
-
if (!(participant instanceof RemoteParticipant)) {
|
|
176
|
+
if (!(participant instanceof participant_1.RemoteParticipant)) {
|
|
174
177
|
return;
|
|
175
178
|
}
|
|
176
179
|
participant._setOnline(false);
|
|
@@ -182,7 +185,7 @@ export class MessagingClient extends EventEmitter {
|
|
|
182
185
|
if (to == null) {
|
|
183
186
|
return null;
|
|
184
187
|
}
|
|
185
|
-
if (!(to instanceof RemoteParticipant)) {
|
|
188
|
+
if (!(to instanceof participant_1.RemoteParticipant)) {
|
|
186
189
|
return to;
|
|
187
190
|
}
|
|
188
191
|
if (to.online === false) {
|
|
@@ -216,12 +219,12 @@ export class MessagingClient extends EventEmitter {
|
|
|
216
219
|
}
|
|
217
220
|
}
|
|
218
221
|
catch (error) {
|
|
219
|
-
if (error instanceof RoomServerException) {
|
|
222
|
+
if (error instanceof room_server_client_1.RoomServerException) {
|
|
220
223
|
this._dropQueuedMessage({ message, error });
|
|
221
224
|
this._drainQueuedMessages({ error });
|
|
222
225
|
}
|
|
223
226
|
else {
|
|
224
|
-
const wrapped = new RoomServerException(String(error));
|
|
227
|
+
const wrapped = new room_server_client_1.RoomServerException(String(error));
|
|
225
228
|
this._dropQueuedMessage({ message, error: wrapped });
|
|
226
229
|
this._drainQueuedMessages({ error: wrapped });
|
|
227
230
|
}
|
|
@@ -231,7 +234,7 @@ export class MessagingClient extends EventEmitter {
|
|
|
231
234
|
if (resolvedTo == null) {
|
|
232
235
|
this._dropQueuedMessage({
|
|
233
236
|
message,
|
|
234
|
-
error: new RoomServerException("the participant was not found"),
|
|
237
|
+
error: new room_server_client_1.RoomServerException("the participant was not found"),
|
|
235
238
|
});
|
|
236
239
|
continue;
|
|
237
240
|
}
|
|
@@ -250,7 +253,7 @@ export class MessagingClient extends EventEmitter {
|
|
|
250
253
|
}
|
|
251
254
|
}
|
|
252
255
|
catch (error) {
|
|
253
|
-
if (error instanceof RoomServerException) {
|
|
256
|
+
if (error instanceof room_server_client_1.RoomServerException) {
|
|
254
257
|
const wrapped = this.client._coerceMessageSendError(error);
|
|
255
258
|
if (wrapped.message === "the participant was not found") {
|
|
256
259
|
this._markParticipantOffline(message.to);
|
|
@@ -268,7 +271,7 @@ export class MessagingClient extends EventEmitter {
|
|
|
268
271
|
}
|
|
269
272
|
async sendMessage({ to, type, message, attachment, ignoreOffline = false, }) {
|
|
270
273
|
if (this._sendTask == null) {
|
|
271
|
-
throw new RoomServerException("Cannot send messages because messaging has not been started");
|
|
274
|
+
throw new room_server_client_1.RoomServerException("Cannot send messages because messaging has not been started");
|
|
272
275
|
}
|
|
273
276
|
const queued = {
|
|
274
277
|
to,
|
|
@@ -276,7 +279,7 @@ export class MessagingClient extends EventEmitter {
|
|
|
276
279
|
message,
|
|
277
280
|
attachment,
|
|
278
281
|
dropIfOffline: ignoreOffline,
|
|
279
|
-
completer: ignoreOffline ? undefined : new Completer(),
|
|
282
|
+
completer: ignoreOffline ? undefined : new completer_1.Completer(),
|
|
280
283
|
};
|
|
281
284
|
this._queueMessage(queued);
|
|
282
285
|
if (queued.completer != null) {
|
|
@@ -308,7 +311,7 @@ export class MessagingClient extends EventEmitter {
|
|
|
308
311
|
}
|
|
309
312
|
async broadcastMessage({ type, message, attachment, }) {
|
|
310
313
|
if (this._sendTask == null) {
|
|
311
|
-
throw new RoomServerException("Cannot send messages because messaging has not been started");
|
|
314
|
+
throw new room_server_client_1.RoomServerException("Cannot send messages because messaging has not been started");
|
|
312
315
|
}
|
|
313
316
|
await this.client._waitUntilConnectedForMessages();
|
|
314
317
|
if (this._desiredEnabled) {
|
|
@@ -321,7 +324,7 @@ export class MessagingClient extends EventEmitter {
|
|
|
321
324
|
});
|
|
322
325
|
}
|
|
323
326
|
catch (error) {
|
|
324
|
-
if (error instanceof RoomServerException) {
|
|
327
|
+
if (error instanceof room_server_client_1.RoomServerException) {
|
|
325
328
|
throw this.client._coerceMessageSendError(error);
|
|
326
329
|
}
|
|
327
330
|
throw error;
|
|
@@ -345,10 +348,10 @@ export class MessagingClient extends EventEmitter {
|
|
|
345
348
|
if (!this.client.isActiveProtocol(protocol)) {
|
|
346
349
|
return;
|
|
347
350
|
}
|
|
348
|
-
const headerStr = splitMessageHeader(bytes);
|
|
349
|
-
const payload = splitMessagePayload(bytes);
|
|
351
|
+
const headerStr = (0, utils_1.splitMessageHeader)(bytes);
|
|
352
|
+
const payload = (0, utils_1.splitMessagePayload)(bytes);
|
|
350
353
|
const header = JSON.parse(headerStr);
|
|
351
|
-
const message = new RoomMessage({
|
|
354
|
+
const message = new room_event_1.RoomMessage({
|
|
352
355
|
fromParticipantId: header["from_participant_id"],
|
|
353
356
|
type: header["type"],
|
|
354
357
|
message: header["message"],
|
|
@@ -370,16 +373,16 @@ export class MessagingClient extends EventEmitter {
|
|
|
370
373
|
default:
|
|
371
374
|
break;
|
|
372
375
|
}
|
|
373
|
-
const event = new RoomMessageEvent({ message });
|
|
376
|
+
const event = new room_event_1.RoomMessageEvent({ message });
|
|
374
377
|
this.client.emit(event);
|
|
375
378
|
this.emit("message", event);
|
|
376
379
|
}
|
|
377
380
|
_onParticipantEnabled(message) {
|
|
378
381
|
const data = message.message;
|
|
379
|
-
const participant = new RemoteParticipant(this.client, data.id, data.role, true);
|
|
382
|
+
const participant = new participant_1.RemoteParticipant(this.client, data.id, data.role, true);
|
|
380
383
|
participant._setAttributes(data.attributes ?? {});
|
|
381
384
|
this._participants[data.id] = participant;
|
|
382
|
-
this.emit("participant_added", new RoomMessageEvent({ message }));
|
|
385
|
+
this.emit("participant_added", new room_event_1.RoomMessageEvent({ message }));
|
|
383
386
|
}
|
|
384
387
|
_onParticipantAttributes(message) {
|
|
385
388
|
const participant = this._participants[message.fromParticipantId];
|
|
@@ -387,12 +390,12 @@ export class MessagingClient extends EventEmitter {
|
|
|
387
390
|
return;
|
|
388
391
|
}
|
|
389
392
|
participant._setAttributes(message.message["attributes"]);
|
|
390
|
-
this.emit("participant_attributes_updated", new RoomMessageEvent({ message }));
|
|
393
|
+
this.emit("participant_attributes_updated", new room_event_1.RoomMessageEvent({ message }));
|
|
391
394
|
}
|
|
392
395
|
_onParticipantDisabled(message) {
|
|
393
396
|
const removed = this._removeParticipant(String(message.message["id"]));
|
|
394
397
|
if (removed != null) {
|
|
395
|
-
this.emit("participant_removed", new RoomMessageEvent({ message }));
|
|
398
|
+
this.emit("participant_removed", new room_event_1.RoomMessageEvent({ message }));
|
|
396
399
|
}
|
|
397
400
|
}
|
|
398
401
|
_onMessagingEnabled(message) {
|
|
@@ -402,7 +405,7 @@ export class MessagingClient extends EventEmitter {
|
|
|
402
405
|
}
|
|
403
406
|
const participants = message.message["participants"];
|
|
404
407
|
for (const data of participants) {
|
|
405
|
-
const participant = new RemoteParticipant(this.client, data.id, data.role, true);
|
|
408
|
+
const participant = new participant_1.RemoteParticipant(this.client, data.id, data.role, true);
|
|
406
409
|
participant._setAttributes(data.attributes ?? {});
|
|
407
410
|
this._participants[data.id] = participant;
|
|
408
411
|
}
|
|
@@ -412,10 +415,10 @@ export class MessagingClient extends EventEmitter {
|
|
|
412
415
|
this._clearCurrentConnectionState();
|
|
413
416
|
return;
|
|
414
417
|
}
|
|
415
|
-
this.emit("messaging_enabled", new RoomMessageEvent({ message }));
|
|
418
|
+
this.emit("messaging_enabled", new room_event_1.RoomMessageEvent({ message }));
|
|
416
419
|
}
|
|
417
420
|
dispose() {
|
|
418
|
-
const error = new RoomServerException("messaging client disposed");
|
|
421
|
+
const error = new room_server_client_1.RoomServerException("messaging client disposed");
|
|
419
422
|
this._messageQueueClosed = true;
|
|
420
423
|
this._wakeMessageQueue();
|
|
421
424
|
this._drainQueuedMessages({ error });
|
|
@@ -425,3 +428,4 @@ export class MessagingClient extends EventEmitter {
|
|
|
425
428
|
super.dispose();
|
|
426
429
|
}
|
|
427
430
|
}
|
|
431
|
+
exports.MessagingClient = MessagingClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ParticipantToken = exports.ParticipantGrant = exports.ApiScope = exports.LLMGrant = exports.ServicesGrant = exports.TunnelsGrant = exports.SecretsGrant = exports.OAuthEndpoint = exports.AdminGrant = exports.DeveloperGrant = exports.ContainersGrant = exports.ContainerRegistryGrant = exports.StorageGrant = exports.StoragePathGrant = exports.SyncGrant = exports.SyncPathGrant = exports.MemoryGrant = exports.MemoryEntryGrant = exports.MemoryPermissions = exports.DatasetGrant = exports.TableGrant = exports.MessagingGrant = exports.QueuesGrant = exports.LivekitGrant = exports.AgentsGrant = void 0;
|
|
4
|
+
const jose_1 = require("jose");
|
|
5
|
+
const api_keys_1 = require("./api_keys");
|
|
6
|
+
const version_1 = require("./version");
|
|
4
7
|
function matchesGrantPattern(patterns, value, allowIfUnset) {
|
|
5
8
|
if (!patterns) {
|
|
6
9
|
return allowIfUnset;
|
|
@@ -34,7 +37,7 @@ function asStringList(value) {
|
|
|
34
37
|
? value
|
|
35
38
|
: undefined;
|
|
36
39
|
}
|
|
37
|
-
|
|
40
|
+
class AgentsGrant {
|
|
38
41
|
constructor({ registerAgent, registerPublicToolkit, registerPrivateToolkit, call, useAgents, useTools, allowedToolkits, } = {}) {
|
|
39
42
|
this.registerAgent = registerAgent ?? true;
|
|
40
43
|
this.registerPublicToolkit = registerPublicToolkit ?? true;
|
|
@@ -84,7 +87,8 @@ export class AgentsGrant {
|
|
|
84
87
|
});
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
|
-
|
|
90
|
+
exports.AgentsGrant = AgentsGrant;
|
|
91
|
+
class LivekitGrant {
|
|
88
92
|
constructor({ breakoutRooms } = {}) {
|
|
89
93
|
this.breakoutRooms = breakoutRooms;
|
|
90
94
|
}
|
|
@@ -107,7 +111,8 @@ export class LivekitGrant {
|
|
|
107
111
|
});
|
|
108
112
|
}
|
|
109
113
|
}
|
|
110
|
-
|
|
114
|
+
exports.LivekitGrant = LivekitGrant;
|
|
115
|
+
class QueuesGrant {
|
|
111
116
|
constructor({ send, receive, list, } = {}) {
|
|
112
117
|
this.send = send;
|
|
113
118
|
this.receive = receive;
|
|
@@ -143,7 +148,8 @@ export class QueuesGrant {
|
|
|
143
148
|
});
|
|
144
149
|
}
|
|
145
150
|
}
|
|
146
|
-
|
|
151
|
+
exports.QueuesGrant = QueuesGrant;
|
|
152
|
+
class MessagingGrant {
|
|
147
153
|
constructor({ broadcast, list, send, } = {}) {
|
|
148
154
|
this.broadcast = broadcast ?? true;
|
|
149
155
|
this.list = list ?? true;
|
|
@@ -173,7 +179,8 @@ export class MessagingGrant {
|
|
|
173
179
|
});
|
|
174
180
|
}
|
|
175
181
|
}
|
|
176
|
-
|
|
182
|
+
exports.MessagingGrant = MessagingGrant;
|
|
183
|
+
class TableGrant {
|
|
177
184
|
constructor({ name, namespace, write, read, alter, }) {
|
|
178
185
|
this.name = name;
|
|
179
186
|
this.namespace = namespace;
|
|
@@ -212,7 +219,8 @@ export class TableGrant {
|
|
|
212
219
|
});
|
|
213
220
|
}
|
|
214
221
|
}
|
|
215
|
-
|
|
222
|
+
exports.TableGrant = TableGrant;
|
|
223
|
+
class DatasetGrant {
|
|
216
224
|
constructor({ tables, listTables, } = {}) {
|
|
217
225
|
this.tables = tables;
|
|
218
226
|
this.listTables = listTables ?? true;
|
|
@@ -288,7 +296,8 @@ export class DatasetGrant {
|
|
|
288
296
|
});
|
|
289
297
|
}
|
|
290
298
|
}
|
|
291
|
-
|
|
299
|
+
exports.DatasetGrant = DatasetGrant;
|
|
300
|
+
class MemoryPermissions {
|
|
292
301
|
constructor({ create, drop, inspect, query, upsert, ingest, recall, optimize, } = {}) {
|
|
293
302
|
this.create = create ?? true;
|
|
294
303
|
this.drop = drop ?? true;
|
|
@@ -343,7 +352,8 @@ export class MemoryPermissions {
|
|
|
343
352
|
});
|
|
344
353
|
}
|
|
345
354
|
}
|
|
346
|
-
|
|
355
|
+
exports.MemoryPermissions = MemoryPermissions;
|
|
356
|
+
class MemoryEntryGrant {
|
|
347
357
|
constructor({ name, namespace, permissions, }) {
|
|
348
358
|
this.name = name;
|
|
349
359
|
this.namespace = namespace;
|
|
@@ -370,7 +380,8 @@ export class MemoryEntryGrant {
|
|
|
370
380
|
});
|
|
371
381
|
}
|
|
372
382
|
}
|
|
373
|
-
|
|
383
|
+
exports.MemoryEntryGrant = MemoryEntryGrant;
|
|
384
|
+
class MemoryGrant {
|
|
374
385
|
constructor({ list, memories, } = {}) {
|
|
375
386
|
this.list = list ?? true;
|
|
376
387
|
this.memories = memories;
|
|
@@ -454,7 +465,8 @@ export class MemoryGrant {
|
|
|
454
465
|
});
|
|
455
466
|
}
|
|
456
467
|
}
|
|
457
|
-
|
|
468
|
+
exports.MemoryGrant = MemoryGrant;
|
|
469
|
+
class SyncPathGrant {
|
|
458
470
|
constructor({ path, readOnly }) {
|
|
459
471
|
this.path = path;
|
|
460
472
|
this.readOnly = readOnly ?? false;
|
|
@@ -478,7 +490,8 @@ export class SyncPathGrant {
|
|
|
478
490
|
});
|
|
479
491
|
}
|
|
480
492
|
}
|
|
481
|
-
|
|
493
|
+
exports.SyncPathGrant = SyncPathGrant;
|
|
494
|
+
class SyncGrant {
|
|
482
495
|
constructor({ paths } = {}) {
|
|
483
496
|
this.paths = paths;
|
|
484
497
|
}
|
|
@@ -522,7 +535,8 @@ export class SyncGrant {
|
|
|
522
535
|
});
|
|
523
536
|
}
|
|
524
537
|
}
|
|
525
|
-
|
|
538
|
+
exports.SyncGrant = SyncGrant;
|
|
539
|
+
class StoragePathGrant {
|
|
526
540
|
constructor({ path, readOnly }) {
|
|
527
541
|
this.path = path;
|
|
528
542
|
this.readOnly = readOnly ?? false;
|
|
@@ -546,7 +560,8 @@ export class StoragePathGrant {
|
|
|
546
560
|
});
|
|
547
561
|
}
|
|
548
562
|
}
|
|
549
|
-
|
|
563
|
+
exports.StoragePathGrant = StoragePathGrant;
|
|
564
|
+
class StorageGrant {
|
|
550
565
|
constructor({ paths } = {}) {
|
|
551
566
|
this.paths = paths;
|
|
552
567
|
}
|
|
@@ -585,7 +600,8 @@ export class StorageGrant {
|
|
|
585
600
|
});
|
|
586
601
|
}
|
|
587
602
|
}
|
|
588
|
-
|
|
603
|
+
exports.StorageGrant = StorageGrant;
|
|
604
|
+
class ContainerRegistryGrant {
|
|
589
605
|
constructor({ list, pull, run, write, } = {}) {
|
|
590
606
|
this.list = list;
|
|
591
607
|
this.pull = pull;
|
|
@@ -640,7 +656,8 @@ export class ContainerRegistryGrant {
|
|
|
640
656
|
});
|
|
641
657
|
}
|
|
642
658
|
}
|
|
643
|
-
|
|
659
|
+
exports.ContainerRegistryGrant = ContainerRegistryGrant;
|
|
660
|
+
class ContainersGrant {
|
|
644
661
|
constructor({ logs, pull, run, registry, useContainers, } = {}) {
|
|
645
662
|
this.logs = logs ?? true;
|
|
646
663
|
this.pull = pull;
|
|
@@ -710,7 +727,8 @@ export class ContainersGrant {
|
|
|
710
727
|
});
|
|
711
728
|
}
|
|
712
729
|
}
|
|
713
|
-
|
|
730
|
+
exports.ContainersGrant = ContainersGrant;
|
|
731
|
+
class DeveloperGrant {
|
|
714
732
|
constructor({ logs } = {}) {
|
|
715
733
|
this.logs = logs ?? true;
|
|
716
734
|
}
|
|
@@ -730,7 +748,8 @@ export class DeveloperGrant {
|
|
|
730
748
|
});
|
|
731
749
|
}
|
|
732
750
|
}
|
|
733
|
-
|
|
751
|
+
exports.DeveloperGrant = DeveloperGrant;
|
|
752
|
+
class AdminGrant {
|
|
734
753
|
constructor({ config } = {}) {
|
|
735
754
|
this.config = config ?? true;
|
|
736
755
|
}
|
|
@@ -750,7 +769,8 @@ export class AdminGrant {
|
|
|
750
769
|
});
|
|
751
770
|
}
|
|
752
771
|
}
|
|
753
|
-
|
|
772
|
+
exports.AdminGrant = AdminGrant;
|
|
773
|
+
class OAuthEndpoint {
|
|
754
774
|
constructor({ endpoint, clientId }) {
|
|
755
775
|
this.endpoint = endpoint;
|
|
756
776
|
this.clientId = clientId;
|
|
@@ -775,7 +795,8 @@ export class OAuthEndpoint {
|
|
|
775
795
|
});
|
|
776
796
|
}
|
|
777
797
|
}
|
|
778
|
-
|
|
798
|
+
exports.OAuthEndpoint = OAuthEndpoint;
|
|
799
|
+
class SecretsGrant {
|
|
779
800
|
constructor({ requestOauthToken } = {}) {
|
|
780
801
|
this.requestOauthToken = requestOauthToken;
|
|
781
802
|
}
|
|
@@ -817,7 +838,8 @@ export class SecretsGrant {
|
|
|
817
838
|
});
|
|
818
839
|
}
|
|
819
840
|
}
|
|
820
|
-
|
|
841
|
+
exports.SecretsGrant = SecretsGrant;
|
|
842
|
+
class TunnelsGrant {
|
|
821
843
|
constructor({ ports } = {}) {
|
|
822
844
|
this.ports = ports;
|
|
823
845
|
}
|
|
@@ -837,7 +859,8 @@ export class TunnelsGrant {
|
|
|
837
859
|
});
|
|
838
860
|
}
|
|
839
861
|
}
|
|
840
|
-
|
|
862
|
+
exports.TunnelsGrant = TunnelsGrant;
|
|
863
|
+
class ServicesGrant {
|
|
841
864
|
constructor({ list } = {}) {
|
|
842
865
|
this.list = list ?? true;
|
|
843
866
|
}
|
|
@@ -857,7 +880,8 @@ export class ServicesGrant {
|
|
|
857
880
|
});
|
|
858
881
|
}
|
|
859
882
|
}
|
|
860
|
-
|
|
883
|
+
exports.ServicesGrant = ServicesGrant;
|
|
884
|
+
class LLMGrant {
|
|
861
885
|
constructor({ models } = {}) {
|
|
862
886
|
this.models = models;
|
|
863
887
|
}
|
|
@@ -896,7 +920,8 @@ export class LLMGrant {
|
|
|
896
920
|
});
|
|
897
921
|
}
|
|
898
922
|
}
|
|
899
|
-
|
|
923
|
+
exports.LLMGrant = LLMGrant;
|
|
924
|
+
class ApiScope {
|
|
900
925
|
constructor({ livekit, queues, messaging, dataset, memory, sync, storage, containers, developer, agents, llm, admin, secrets, tunnels, services, } = {}) {
|
|
901
926
|
this.livekit = livekit;
|
|
902
927
|
this.queues = queues;
|
|
@@ -1040,7 +1065,8 @@ export class ApiScope {
|
|
|
1040
1065
|
});
|
|
1041
1066
|
}
|
|
1042
1067
|
}
|
|
1043
|
-
|
|
1068
|
+
exports.ApiScope = ApiScope;
|
|
1069
|
+
class ParticipantGrant {
|
|
1044
1070
|
constructor({ name, scope }) {
|
|
1045
1071
|
this.name = name;
|
|
1046
1072
|
this.scope = scope;
|
|
@@ -1069,6 +1095,7 @@ export class ParticipantGrant {
|
|
|
1069
1095
|
});
|
|
1070
1096
|
}
|
|
1071
1097
|
}
|
|
1098
|
+
exports.ParticipantGrant = ParticipantGrant;
|
|
1072
1099
|
function compareSemver(a, b) {
|
|
1073
1100
|
const pa = a.split(".").map((value) => parseInt(value, 10));
|
|
1074
1101
|
const pb = b.split(".").map((value) => parseInt(value, 10));
|
|
@@ -1081,12 +1108,12 @@ function compareSemver(a, b) {
|
|
|
1081
1108
|
}
|
|
1082
1109
|
return 0;
|
|
1083
1110
|
}
|
|
1084
|
-
|
|
1111
|
+
class ParticipantToken {
|
|
1085
1112
|
constructor({ name, projectId, apiKeyId, version, extra, grants, }) {
|
|
1086
1113
|
this.name = name;
|
|
1087
1114
|
this.projectId = projectId;
|
|
1088
1115
|
this.apiKeyId = apiKeyId;
|
|
1089
|
-
this.version = version ?? __version__;
|
|
1116
|
+
this.version = version ?? version_1.__version__;
|
|
1090
1117
|
this.extra = extra ?? {};
|
|
1091
1118
|
this.grants = grants ?? [];
|
|
1092
1119
|
}
|
|
@@ -1170,7 +1197,7 @@ export class ParticipantToken {
|
|
|
1170
1197
|
const resolvedApiKey = apiKey ?? getEnvValue("MESHAGENT_API_KEY");
|
|
1171
1198
|
let resolvedSecret = token;
|
|
1172
1199
|
if (resolvedApiKey !== undefined) {
|
|
1173
|
-
const parsed = parseApiKey(resolvedApiKey);
|
|
1200
|
+
const parsed = (0, api_keys_1.parseApiKey)(resolvedApiKey);
|
|
1174
1201
|
resolvedSecret = parsed.secret;
|
|
1175
1202
|
payload["kid"] = parsed.id;
|
|
1176
1203
|
payload["sub"] = parsed.projectId;
|
|
@@ -1188,7 +1215,7 @@ export class ParticipantToken {
|
|
|
1188
1215
|
payload.exp = Math.floor(expiration.getTime() / 1000);
|
|
1189
1216
|
}
|
|
1190
1217
|
const secretKey = new TextEncoder().encode(resolvedSecret);
|
|
1191
|
-
return await new SignJWT(payload)
|
|
1218
|
+
return await new jose_1.SignJWT(payload)
|
|
1192
1219
|
.setProtectedHeader({ alg: "HS256", typ: "JWT" })
|
|
1193
1220
|
.sign(secretKey);
|
|
1194
1221
|
}
|
|
@@ -1205,7 +1232,7 @@ export class ParticipantToken {
|
|
|
1205
1232
|
delete data.sub;
|
|
1206
1233
|
const apiKeyId = typeof data.kid === "string" ? data.kid : undefined;
|
|
1207
1234
|
delete data.kid;
|
|
1208
|
-
const version = typeof data.version === "string" ? data.version : __version__;
|
|
1235
|
+
const version = typeof data.version === "string" ? data.version : version_1.__version__;
|
|
1209
1236
|
delete data.version;
|
|
1210
1237
|
return new ParticipantToken({
|
|
1211
1238
|
name,
|
|
@@ -1224,16 +1251,17 @@ export class ParticipantToken {
|
|
|
1224
1251
|
throw new Error("Failed to verify JWT: no token provided");
|
|
1225
1252
|
}
|
|
1226
1253
|
const secretKey = new TextEncoder().encode(verificationToken);
|
|
1227
|
-
const { payload } = await jwtVerify(jwtStr, secretKey, {
|
|
1254
|
+
const { payload } = await (0, jose_1.jwtVerify)(jwtStr, secretKey, {
|
|
1228
1255
|
algorithms: ["HS256"],
|
|
1229
1256
|
});
|
|
1230
1257
|
return ParticipantToken.fromJson(payload);
|
|
1231
1258
|
}
|
|
1232
1259
|
try {
|
|
1233
|
-
return ParticipantToken.fromJson(decodeJwt(jwtStr));
|
|
1260
|
+
return ParticipantToken.fromJson((0, jose_1.decodeJwt)(jwtStr));
|
|
1234
1261
|
}
|
|
1235
1262
|
catch {
|
|
1236
1263
|
throw new Error("Failed to decode JWT");
|
|
1237
1264
|
}
|
|
1238
1265
|
}
|
|
1239
1266
|
}
|
|
1267
|
+
exports.ParticipantToken = ParticipantToken;
|
package/dist/esm/participant.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalParticipant = exports.RemoteParticipant = exports.Participant = void 0;
|
|
4
|
+
class Participant {
|
|
2
5
|
constructor(client, id) {
|
|
3
6
|
this._attributes = {};
|
|
4
7
|
this._connections = [];
|
|
@@ -27,7 +30,8 @@ export class Participant {
|
|
|
27
30
|
return { ...this._attributes };
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
|
-
|
|
33
|
+
exports.Participant = Participant;
|
|
34
|
+
class RemoteParticipant extends Participant {
|
|
31
35
|
constructor(client, id, role, online) {
|
|
32
36
|
super(client, id);
|
|
33
37
|
this.role = role;
|
|
@@ -37,7 +41,8 @@ export class RemoteParticipant extends Participant {
|
|
|
37
41
|
this.online = online;
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
|
-
|
|
44
|
+
exports.RemoteParticipant = RemoteParticipant;
|
|
45
|
+
class LocalParticipant extends Participant {
|
|
41
46
|
constructor(client, id) {
|
|
42
47
|
super(client, id);
|
|
43
48
|
}
|
|
@@ -46,3 +51,4 @@ export class LocalParticipant extends Participant {
|
|
|
46
51
|
this.client._sendLocalAttributesNowait({ [name]: value });
|
|
47
52
|
}
|
|
48
53
|
}
|
|
54
|
+
exports.LocalParticipant = LocalParticipant;
|