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