@meshagent/meshagent 0.39.3 → 0.39.5
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/browser/room-client.d.ts +3 -1
- package/dist/browser/room-client.js +23 -7
- 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.d.ts +3 -1
- package/dist/esm/room-client.js +154 -133
- 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/dist/node/room-client.d.ts +3 -1
- package/dist/node/room-client.js +23 -7
- package/package.json +1 -1
package/dist/esm/room-client.js
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RoomClient = exports.RoomProtocolProxy = void 0;
|
|
4
|
+
const completer_1 = require("./completer");
|
|
5
|
+
const datasets_client_1 = require("./datasets-client");
|
|
6
|
+
const developer_client_1 = require("./developer-client");
|
|
7
|
+
const event_emitter_1 = require("./event-emitter");
|
|
8
|
+
const messaging_client_1 = require("./messaging-client");
|
|
9
|
+
const memory_client_1 = require("./memory-client");
|
|
10
|
+
const participant_1 = require("./participant");
|
|
11
|
+
const protocol_1 = require("./protocol");
|
|
12
|
+
const queues_client_1 = require("./queues-client");
|
|
13
|
+
const response_1 = require("./response");
|
|
14
|
+
const room_event_1 = require("./room-event");
|
|
15
|
+
const room_server_client_1 = require("./room-server-client");
|
|
16
|
+
const secrets_client_1 = require("./secrets-client");
|
|
17
|
+
const services_client_1 = require("./services-client");
|
|
18
|
+
const storage_client_1 = require("./storage-client");
|
|
19
|
+
const stream_controller_1 = require("./stream-controller");
|
|
20
|
+
const sync_client_1 = require("./sync-client");
|
|
21
|
+
const utils_1 = require("./utils");
|
|
22
|
+
const agent_client_1 = require("./agent-client");
|
|
23
|
+
const containers_client_1 = require("./containers-client");
|
|
21
24
|
class ProtocolStartupFailure extends Error {
|
|
22
25
|
constructor({ kind, reason }) {
|
|
23
26
|
super(reason ?? kind);
|
|
@@ -26,6 +29,12 @@ class ProtocolStartupFailure extends Error {
|
|
|
26
29
|
this.reason = reason;
|
|
27
30
|
}
|
|
28
31
|
}
|
|
32
|
+
function isRetryableStartupClose({ kind, reason, }) {
|
|
33
|
+
if (kind === protocol_1.ProtocolCloseKind.ERROR) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return (reason ?? "").toLowerCase().includes("1013");
|
|
37
|
+
}
|
|
29
38
|
class RoomClientTerminalState {
|
|
30
39
|
constructor({ requestMessage, toolCallMessage, messageSendMessage, }) {
|
|
31
40
|
this.requestMessage = requestMessage;
|
|
@@ -33,16 +42,16 @@ class RoomClientTerminalState {
|
|
|
33
42
|
this.messageSendMessage = messageSendMessage;
|
|
34
43
|
}
|
|
35
44
|
requestError() {
|
|
36
|
-
return new RoomServerException(this.requestMessage);
|
|
45
|
+
return new room_server_client_1.RoomServerException(this.requestMessage);
|
|
37
46
|
}
|
|
38
47
|
toolCallError() {
|
|
39
|
-
return new RoomServerException(this.toolCallMessage);
|
|
48
|
+
return new room_server_client_1.RoomServerException(this.toolCallMessage);
|
|
40
49
|
}
|
|
41
50
|
messageSendError() {
|
|
42
|
-
return new RoomServerException(this.messageSendMessage);
|
|
51
|
+
return new room_server_client_1.RoomServerException(this.messageSendMessage);
|
|
43
52
|
}
|
|
44
53
|
}
|
|
45
|
-
class RoomConnectionStatusException extends RoomServerException {
|
|
54
|
+
class RoomConnectionStatusException extends room_server_client_1.RoomServerException {
|
|
46
55
|
constructor({ statusCode, statusText, }) {
|
|
47
56
|
const normalizedStatusText = statusText?.trim();
|
|
48
57
|
super(normalizedStatusText == null || normalizedStatusText.length === 0
|
|
@@ -60,19 +69,19 @@ function normalizeCloseReason(reason) {
|
|
|
60
69
|
return normalized.length === 0 ? null : normalized;
|
|
61
70
|
}
|
|
62
71
|
function wrapRoomConnectionError(error) {
|
|
63
|
-
if (error instanceof RoomServerException) {
|
|
72
|
+
if (error instanceof room_server_client_1.RoomServerException) {
|
|
64
73
|
return error;
|
|
65
74
|
}
|
|
66
|
-
if (error instanceof ProtocolHandshakeException) {
|
|
75
|
+
if (error instanceof protocol_1.ProtocolHandshakeException) {
|
|
67
76
|
return new RoomConnectionStatusException({
|
|
68
77
|
statusCode: error.statusCode,
|
|
69
78
|
statusText: error.statusText,
|
|
70
79
|
});
|
|
71
80
|
}
|
|
72
|
-
if (error instanceof ProtocolCloseException) {
|
|
73
|
-
return new RoomServerException(normalizeCloseReason(error.reason) ?? `room connection closed with status ${error.closeCode}`);
|
|
81
|
+
if (error instanceof protocol_1.ProtocolCloseException) {
|
|
82
|
+
return new room_server_client_1.RoomServerException(normalizeCloseReason(error.reason) ?? `room connection closed with status ${error.closeCode}`);
|
|
74
83
|
}
|
|
75
|
-
return new RoomServerException(`room connection error: ${String(error)}`);
|
|
84
|
+
return new room_server_client_1.RoomServerException(`room connection error: ${String(error)}`);
|
|
76
85
|
}
|
|
77
86
|
function nonRetryableConnectFailureReason(error) {
|
|
78
87
|
if (error instanceof RoomConnectionStatusException
|
|
@@ -82,7 +91,7 @@ function nonRetryableConnectFailureReason(error) {
|
|
|
82
91
|
return null;
|
|
83
92
|
}
|
|
84
93
|
function roomClosedBeforeReadyError(protocol) {
|
|
85
|
-
return new RoomServerException(normalizeCloseReason(protocol.closeReason) ?? "room connection closed before request completed");
|
|
94
|
+
return new room_server_client_1.RoomServerException(normalizeCloseReason(protocol.closeReason) ?? "room connection closed before request completed");
|
|
86
95
|
}
|
|
87
96
|
function getEnvironmentValue(name) {
|
|
88
97
|
if (typeof process === "undefined") {
|
|
@@ -109,12 +118,12 @@ function createProtocolFactoryFromEnvironment() {
|
|
|
109
118
|
if (roomName == null || roomName.trim().length === 0 || token == null || token.trim().length === 0) {
|
|
110
119
|
throw new Error("protocolFactory must be configured or MESHAGENT_ROOM and MESHAGENT_TOKEN must be set in the environment");
|
|
111
120
|
}
|
|
112
|
-
return WebSocketClientProtocol.createFactory({
|
|
121
|
+
return protocol_1.WebSocketClientProtocol.createFactory({
|
|
113
122
|
url: websocketRoomUrlFromEnvironment(roomName),
|
|
114
123
|
token,
|
|
115
124
|
});
|
|
116
125
|
}
|
|
117
|
-
|
|
126
|
+
class RoomProtocolProxy {
|
|
118
127
|
constructor({ room }) {
|
|
119
128
|
this._handlers = new Map();
|
|
120
129
|
this._room = room;
|
|
@@ -198,19 +207,20 @@ export class RoomProtocolProxy {
|
|
|
198
207
|
return this._room._protocolInstance.url;
|
|
199
208
|
}
|
|
200
209
|
}
|
|
201
|
-
|
|
210
|
+
exports.RoomProtocolProxy = RoomProtocolProxy;
|
|
211
|
+
class RoomClient {
|
|
202
212
|
constructor({ protocolFactory = null, reconnectTimeout = null, oauthTokenRequestHandler, secretRequestHandler, } = {}) {
|
|
203
213
|
this._entered = false;
|
|
204
214
|
this._allowDisconnectedRequests = false;
|
|
205
|
-
this._eventsController = new StreamController();
|
|
206
|
-
this._eventEmitter = new EventEmitter();
|
|
215
|
+
this._eventsController = new stream_controller_1.StreamController();
|
|
216
|
+
this._eventEmitter = new event_emitter_1.EventEmitter();
|
|
207
217
|
this._pendingRequests = new Map();
|
|
208
218
|
this._toolCallStreams = new Map();
|
|
209
219
|
this._ignoredResponseLabels = new Map();
|
|
210
|
-
this._ready = new Completer();
|
|
211
|
-
this._roomClosed = new Completer();
|
|
212
|
-
this._connectionReady = new Completer();
|
|
213
|
-
this._localParticipantReady = new Completer();
|
|
220
|
+
this._ready = new completer_1.Completer();
|
|
221
|
+
this._roomClosed = new completer_1.Completer();
|
|
222
|
+
this._connectionReady = new completer_1.Completer();
|
|
223
|
+
this._localParticipantReady = new completer_1.Completer();
|
|
214
224
|
this._connected = false;
|
|
215
225
|
this._closing = false;
|
|
216
226
|
this._localParticipant = null;
|
|
@@ -239,21 +249,21 @@ export class RoomClient {
|
|
|
239
249
|
this.protocol.addHandler("connected", this._handleParticipantBound);
|
|
240
250
|
this.protocol.addHandler("__response__", this._handleResponseBound);
|
|
241
251
|
this.protocol.addHandler("room.tool_call_response_chunk", this._handleToolCallResponseChunkBound);
|
|
242
|
-
this.sync = new SyncClient({ room: this });
|
|
243
|
-
this.storage = new StorageClient({ room: this });
|
|
244
|
-
this.developer = new DeveloperClient({ room: this });
|
|
245
|
-
this.messaging = new MessagingClient({ room: this });
|
|
246
|
-
this.queues = new QueuesClient({ room: this });
|
|
247
|
-
this.datasets = new DatasetsClient({ room: this });
|
|
248
|
-
this.agents = new AgentsClient({ room: this });
|
|
249
|
-
this.secrets = new SecretsClient({
|
|
252
|
+
this.sync = new sync_client_1.SyncClient({ room: this });
|
|
253
|
+
this.storage = new storage_client_1.StorageClient({ room: this });
|
|
254
|
+
this.developer = new developer_client_1.DeveloperClient({ room: this });
|
|
255
|
+
this.messaging = new messaging_client_1.MessagingClient({ room: this });
|
|
256
|
+
this.queues = new queues_client_1.QueuesClient({ room: this });
|
|
257
|
+
this.datasets = new datasets_client_1.DatasetsClient({ room: this });
|
|
258
|
+
this.agents = new agent_client_1.AgentsClient({ room: this });
|
|
259
|
+
this.secrets = new secrets_client_1.SecretsClient({
|
|
250
260
|
room: this,
|
|
251
261
|
oauthTokenRequestHandler,
|
|
252
262
|
secretRequestHandler,
|
|
253
263
|
});
|
|
254
|
-
this.containers = new ContainersClient({ room: this });
|
|
255
|
-
this.memory = new MemoryClient({ room: this });
|
|
256
|
-
this.services = new ServicesClient({ room: this });
|
|
264
|
+
this.containers = new containers_client_1.ContainersClient({ room: this });
|
|
265
|
+
this.memory = new memory_client_1.MemoryClient({ room: this });
|
|
266
|
+
this.services = new services_client_1.ServicesClient({ room: this });
|
|
257
267
|
}
|
|
258
268
|
get localParticipant() {
|
|
259
269
|
return this._localParticipant;
|
|
@@ -430,7 +440,7 @@ export class RoomClient {
|
|
|
430
440
|
return `${baseMessage}: ${normalized}`;
|
|
431
441
|
}
|
|
432
442
|
_connectionFailureReason(error) {
|
|
433
|
-
if (error instanceof RoomServerException) {
|
|
443
|
+
if (error instanceof room_server_client_1.RoomServerException) {
|
|
434
444
|
return normalizeCloseReason(error.message);
|
|
435
445
|
}
|
|
436
446
|
return normalizeCloseReason(String(error));
|
|
@@ -478,12 +488,12 @@ export class RoomClient {
|
|
|
478
488
|
const normalizedCloseReason = normalizeCloseReason(closeReason);
|
|
479
489
|
this._closeKind = closeKind;
|
|
480
490
|
this._closeReason = normalizedCloseReason;
|
|
481
|
-
if (closeKind === ProtocolCloseKind.ERROR) {
|
|
491
|
+
if (closeKind === protocol_1.ProtocolCloseKind.ERROR) {
|
|
482
492
|
this._setTerminalState({
|
|
483
493
|
state: this._unexpectedCloseTerminalState({ closeReason: normalizedCloseReason }),
|
|
484
494
|
});
|
|
485
495
|
}
|
|
486
|
-
else if (closeKind === ProtocolCloseKind.CLIENT) {
|
|
496
|
+
else if (closeKind === protocol_1.ProtocolCloseKind.CLIENT) {
|
|
487
497
|
this._setTerminalState({ state: this._clientClosedTerminalState() });
|
|
488
498
|
}
|
|
489
499
|
else {
|
|
@@ -515,22 +525,22 @@ export class RoomClient {
|
|
|
515
525
|
}
|
|
516
526
|
}
|
|
517
527
|
_disconnectedError({ baseMessage }) {
|
|
518
|
-
return new RoomServerException(this._formatClosedMessage({
|
|
528
|
+
return new room_server_client_1.RoomServerException(this._formatClosedMessage({
|
|
519
529
|
baseMessage,
|
|
520
530
|
}));
|
|
521
531
|
}
|
|
522
532
|
_messageDisconnectedError({ baseMessage, }) {
|
|
523
|
-
return new RoomServerException(this._formatClosedMessage({
|
|
533
|
+
return new room_server_client_1.RoomServerException(this._formatClosedMessage({
|
|
524
534
|
baseMessage,
|
|
525
535
|
}));
|
|
526
536
|
}
|
|
527
537
|
_startupException({ closeKind, closeReason, protocol, }) {
|
|
528
|
-
const baseMessage = closeKind === ProtocolCloseKind.ERROR
|
|
538
|
+
const baseMessage = closeKind === protocol_1.ProtocolCloseKind.ERROR
|
|
529
539
|
? "room connection unexpectedly closed before the room became ready"
|
|
530
|
-
: closeKind === ProtocolCloseKind.CLIENT
|
|
540
|
+
: closeKind === protocol_1.ProtocolCloseKind.CLIENT
|
|
531
541
|
? "room client was closed before the room became ready"
|
|
532
542
|
: "room connection closed before the room became ready";
|
|
533
|
-
return new RoomServerException(this._formatClosedMessage({
|
|
543
|
+
return new room_server_client_1.RoomServerException(this._formatClosedMessage({
|
|
534
544
|
baseMessage,
|
|
535
545
|
protocol,
|
|
536
546
|
closeReason,
|
|
@@ -566,7 +576,7 @@ export class RoomClient {
|
|
|
566
576
|
if (this._closing && this._terminalState != null) {
|
|
567
577
|
return this._terminalState.messageSendError();
|
|
568
578
|
}
|
|
569
|
-
return new RoomServerException("Cannot send messages because messaging has been stopped");
|
|
579
|
+
return new room_server_client_1.RoomServerException("Cannot send messages because messaging has been stopped");
|
|
570
580
|
}
|
|
571
581
|
_failPendingRequests(error) {
|
|
572
582
|
if (this._pendingRequests.size === 0) {
|
|
@@ -587,7 +597,7 @@ export class RoomClient {
|
|
|
587
597
|
const streams = [...this._toolCallStreams.values()];
|
|
588
598
|
this._toolCallStreams.clear();
|
|
589
599
|
for (const stream of streams) {
|
|
590
|
-
stream.add(new ErrorContent({ text: error.message }));
|
|
600
|
+
stream.add(new response_1.ErrorContent({ text: error.message }));
|
|
591
601
|
stream.close();
|
|
592
602
|
}
|
|
593
603
|
}
|
|
@@ -597,8 +607,8 @@ export class RoomClient {
|
|
|
597
607
|
}
|
|
598
608
|
async _openProtocol({ initial }) {
|
|
599
609
|
const protocol = this._protocolInstance;
|
|
600
|
-
this._connectionReady = new Completer();
|
|
601
|
-
this._localParticipantReady = new Completer();
|
|
610
|
+
this._connectionReady = new completer_1.Completer();
|
|
611
|
+
this._localParticipantReady = new completer_1.Completer();
|
|
602
612
|
protocol.start({
|
|
603
613
|
onDone: () => {
|
|
604
614
|
const error = roomClosedBeforeReadyError(protocol);
|
|
@@ -629,8 +639,8 @@ export class RoomClient {
|
|
|
629
639
|
await Promise.all([this._connectionReady.fut, this._localParticipantReady.fut]);
|
|
630
640
|
}
|
|
631
641
|
catch (error) {
|
|
632
|
-
const kind = protocol.closeKind ?? ProtocolCloseKind.ERROR;
|
|
633
|
-
if (!initial && kind !== ProtocolCloseKind.ERROR) {
|
|
642
|
+
const kind = protocol.closeKind ?? protocol_1.ProtocolCloseKind.ERROR;
|
|
643
|
+
if (!initial && kind !== protocol_1.ProtocolCloseKind.ERROR) {
|
|
634
644
|
throw new ProtocolStartupFailure({
|
|
635
645
|
kind,
|
|
636
646
|
reason: normalizeCloseReason(protocol.closeReason),
|
|
@@ -641,7 +651,7 @@ export class RoomClient {
|
|
|
641
651
|
}
|
|
642
652
|
async start({ onDone, onError, } = {}) {
|
|
643
653
|
if (this._entered) {
|
|
644
|
-
throw new RoomServerException("room client already started");
|
|
654
|
+
throw new room_server_client_1.RoomServerException("room client already started");
|
|
645
655
|
}
|
|
646
656
|
this._doneHandler = onDone;
|
|
647
657
|
this._errorHandler = onError;
|
|
@@ -651,7 +661,8 @@ export class RoomClient {
|
|
|
651
661
|
}
|
|
652
662
|
catch (error) {
|
|
653
663
|
if (error instanceof ProtocolStartupFailure) {
|
|
654
|
-
if (error.kind
|
|
664
|
+
if (!isRetryableStartupClose({ kind: error.kind, reason: error.reason })
|
|
665
|
+
|| this._reconnectTimeout === 0) {
|
|
655
666
|
this._setStartupTerminalState({
|
|
656
667
|
closeKind: error.kind,
|
|
657
668
|
closeReason: error.reason,
|
|
@@ -680,14 +691,15 @@ export class RoomClient {
|
|
|
680
691
|
this._finalizeInitialStartupRetryFailure({
|
|
681
692
|
retryResult: {
|
|
682
693
|
connected: false,
|
|
683
|
-
closeKind: ProtocolCloseKind.ERROR,
|
|
694
|
+
closeKind: protocol_1.ProtocolCloseKind.ERROR,
|
|
684
695
|
closeReason: nonRetryableCloseReason,
|
|
685
696
|
},
|
|
686
697
|
});
|
|
687
698
|
}
|
|
688
699
|
const closeKind = this._protocolInstance.closeKind;
|
|
689
700
|
const protocolCloseReason = normalizeCloseReason(this._protocolInstance.closeReason);
|
|
690
|
-
if (closeKind != null
|
|
701
|
+
if (closeKind != null
|
|
702
|
+
&& !isRetryableStartupClose({ kind: closeKind, reason: protocolCloseReason })) {
|
|
691
703
|
this._setStartupTerminalState({
|
|
692
704
|
closeKind,
|
|
693
705
|
closeReason: protocolCloseReason,
|
|
@@ -702,12 +714,12 @@ export class RoomClient {
|
|
|
702
714
|
const closeReason = this._connectionFailureReason(error);
|
|
703
715
|
if (this._reconnectTimeout === 0) {
|
|
704
716
|
this._setStartupTerminalState({
|
|
705
|
-
closeKind: ProtocolCloseKind.ERROR,
|
|
717
|
+
closeKind: protocol_1.ProtocolCloseKind.ERROR,
|
|
706
718
|
closeReason,
|
|
707
719
|
protocol: this._protocolInstance,
|
|
708
720
|
});
|
|
709
721
|
throw this._startupException({
|
|
710
|
-
closeKind: ProtocolCloseKind.ERROR,
|
|
722
|
+
closeKind: protocol_1.ProtocolCloseKind.ERROR,
|
|
711
723
|
closeReason,
|
|
712
724
|
protocol: this._protocolInstance,
|
|
713
725
|
});
|
|
@@ -766,6 +778,9 @@ export class RoomClient {
|
|
|
766
778
|
const remaining = deadline - Date.now();
|
|
767
779
|
return remaining <= 0 ? 0 : remaining;
|
|
768
780
|
}
|
|
781
|
+
_reconnectRetryDelay({ retryCount }) {
|
|
782
|
+
return Math.min(RoomClient.RECONNECT_RETRY_MAX_DELAY_MS, RoomClient.RECONNECT_RETRY_BASE_DELAY_MS * (2 ** retryCount));
|
|
783
|
+
}
|
|
769
784
|
async _attemptInitialProtocolStartup({ protocol, remaining, }) {
|
|
770
785
|
void protocol;
|
|
771
786
|
if (remaining == null) {
|
|
@@ -831,14 +846,14 @@ export class RoomClient {
|
|
|
831
846
|
}
|
|
832
847
|
return {
|
|
833
848
|
connected: false,
|
|
834
|
-
closeKind: ProtocolCloseKind.ERROR,
|
|
849
|
+
closeKind: protocol_1.ProtocolCloseKind.ERROR,
|
|
835
850
|
closeReason: this._reconnectTimeoutReason({ disconnectReason }),
|
|
836
851
|
};
|
|
837
852
|
}
|
|
838
853
|
async _closeAfterUnexpectedDisconnect({ closeReason, }) {
|
|
839
854
|
const normalized = normalizeCloseReason(closeReason);
|
|
840
855
|
const state = this._unexpectedCloseTerminalState({ closeReason: normalized });
|
|
841
|
-
this._closeKind = ProtocolCloseKind.ERROR;
|
|
856
|
+
this._closeKind = protocol_1.ProtocolCloseKind.ERROR;
|
|
842
857
|
this._closeReason = normalized;
|
|
843
858
|
this._setTerminalState({ state });
|
|
844
859
|
this._completeRoomClosed();
|
|
@@ -861,11 +876,13 @@ export class RoomClient {
|
|
|
861
876
|
};
|
|
862
877
|
const deadline = this._reconnectTimeout == null ? null : Date.now() + this._reconnectTimeout;
|
|
863
878
|
let firstAttempt = true;
|
|
879
|
+
let retryCount = 0;
|
|
864
880
|
while (!this._closing) {
|
|
865
881
|
if (firstAttempt) {
|
|
866
882
|
firstAttempt = false;
|
|
867
883
|
if (this._reconnectTimeout == null) {
|
|
868
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
884
|
+
await new Promise((resolve) => setTimeout(resolve, this._reconnectRetryDelay({ retryCount })));
|
|
885
|
+
retryCount += 1;
|
|
869
886
|
}
|
|
870
887
|
}
|
|
871
888
|
else {
|
|
@@ -873,12 +890,14 @@ export class RoomClient {
|
|
|
873
890
|
if (remaining != null && remaining === 0) {
|
|
874
891
|
return this._timedOutRetryResult({ disconnectReason: failureReason });
|
|
875
892
|
}
|
|
893
|
+
const backoffDelay = this._reconnectRetryDelay({ retryCount });
|
|
876
894
|
const delay = remaining == null
|
|
877
|
-
?
|
|
878
|
-
: Math.min(remaining,
|
|
895
|
+
? backoffDelay
|
|
896
|
+
: Math.min(remaining, backoffDelay);
|
|
879
897
|
if (delay > 0) {
|
|
880
898
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
881
899
|
}
|
|
900
|
+
retryCount += 1;
|
|
882
901
|
}
|
|
883
902
|
const remaining = this._remainingReconnectTimeout(deadline);
|
|
884
903
|
if (remaining != null && remaining === 0) {
|
|
@@ -889,10 +908,10 @@ export class RoomClient {
|
|
|
889
908
|
nextProtocol = this._protocolFactory();
|
|
890
909
|
}
|
|
891
910
|
catch (error) {
|
|
892
|
-
if (error instanceof ProtocolReconnectUnsupportedException) {
|
|
911
|
+
if (error instanceof protocol_1.ProtocolReconnectUnsupportedException) {
|
|
893
912
|
return {
|
|
894
913
|
connected: false,
|
|
895
|
-
closeKind: ProtocolCloseKind.ERROR,
|
|
914
|
+
closeKind: protocol_1.ProtocolCloseKind.ERROR,
|
|
896
915
|
closeReason: failureReason,
|
|
897
916
|
};
|
|
898
917
|
}
|
|
@@ -913,7 +932,7 @@ export class RoomClient {
|
|
|
913
932
|
if (error instanceof ProtocolStartupFailure) {
|
|
914
933
|
recordFailureReason(error.reason);
|
|
915
934
|
await this._closeProtocol(nextProtocol);
|
|
916
|
-
if (error.kind
|
|
935
|
+
if (!isRetryableStartupClose({ kind: error.kind, reason: error.reason })) {
|
|
917
936
|
return {
|
|
918
937
|
connected: false,
|
|
919
938
|
closeKind: error.kind,
|
|
@@ -927,7 +946,7 @@ export class RoomClient {
|
|
|
927
946
|
await this._closeProtocol(nextProtocol);
|
|
928
947
|
return {
|
|
929
948
|
connected: false,
|
|
930
|
-
closeKind: ProtocolCloseKind.ERROR,
|
|
949
|
+
closeKind: protocol_1.ProtocolCloseKind.ERROR,
|
|
931
950
|
closeReason: nonRetryableCloseReason,
|
|
932
951
|
};
|
|
933
952
|
}
|
|
@@ -940,7 +959,7 @@ export class RoomClient {
|
|
|
940
959
|
}
|
|
941
960
|
return {
|
|
942
961
|
connected: false,
|
|
943
|
-
closeKind: ProtocolCloseKind.CLIENT,
|
|
962
|
+
closeKind: protocol_1.ProtocolCloseKind.CLIENT,
|
|
944
963
|
closeReason: this.closeReason,
|
|
945
964
|
};
|
|
946
965
|
}
|
|
@@ -959,7 +978,7 @@ export class RoomClient {
|
|
|
959
978
|
return true;
|
|
960
979
|
}
|
|
961
980
|
const closeKind = retryResult.closeKind ?? null;
|
|
962
|
-
if (closeKind === ProtocolCloseKind.ERROR) {
|
|
981
|
+
if (closeKind === protocol_1.ProtocolCloseKind.ERROR) {
|
|
963
982
|
const closeReason = retryResult.closeReason ?? null;
|
|
964
983
|
if (closeReason != null && closeReason.startsWith("room reconnect timed out after")) {
|
|
965
984
|
console.warn(`${closeReason}; closing room client`);
|
|
@@ -982,14 +1001,14 @@ export class RoomClient {
|
|
|
982
1001
|
while (true) {
|
|
983
1002
|
const protocol = this._protocolInstance;
|
|
984
1003
|
await protocol.done;
|
|
985
|
-
const closeKind = protocol.closeKind ?? ProtocolCloseKind.ERROR;
|
|
1004
|
+
const closeKind = protocol.closeKind ?? protocol_1.ProtocolCloseKind.ERROR;
|
|
986
1005
|
const closeReason = normalizeCloseReason(protocol.closeReason);
|
|
987
1006
|
const state = this._protocolTerminalState({ protocol });
|
|
988
1007
|
if (this._closing) {
|
|
989
1008
|
this._completeRoomClosed();
|
|
990
1009
|
return;
|
|
991
1010
|
}
|
|
992
|
-
if (closeKind !== ProtocolCloseKind.ERROR) {
|
|
1011
|
+
if (closeKind !== protocol_1.ProtocolCloseKind.ERROR) {
|
|
993
1012
|
this._setTerminalState({ state });
|
|
994
1013
|
}
|
|
995
1014
|
this._markDisconnected({ reason: closeReason, kind: closeKind });
|
|
@@ -1001,7 +1020,7 @@ export class RoomClient {
|
|
|
1001
1020
|
this.messaging._onRoomDisconnect({ reason: closeReason });
|
|
1002
1021
|
await this._failPendingWork({ state });
|
|
1003
1022
|
await this._closeProtocol(protocol);
|
|
1004
|
-
if (closeKind === ProtocolCloseKind.ERROR) {
|
|
1023
|
+
if (closeKind === protocol_1.ProtocolCloseKind.ERROR) {
|
|
1005
1024
|
if (this._reconnectTimeout === 0) {
|
|
1006
1025
|
if (closeReason == null) {
|
|
1007
1026
|
console.warn("room connection lost; automatic reconnect disabled");
|
|
@@ -1034,7 +1053,7 @@ export class RoomClient {
|
|
|
1034
1053
|
this._closing = true;
|
|
1035
1054
|
this._markDisconnected({
|
|
1036
1055
|
reason: this.closeReason,
|
|
1037
|
-
kind: this.closeKind ?? ProtocolCloseKind.CLIENT,
|
|
1056
|
+
kind: this.closeKind ?? protocol_1.ProtocolCloseKind.CLIENT,
|
|
1038
1057
|
});
|
|
1039
1058
|
const closingState = this._clientClosedTerminalState();
|
|
1040
1059
|
this._setTerminalState({ state: closingState });
|
|
@@ -1044,7 +1063,7 @@ export class RoomClient {
|
|
|
1044
1063
|
void this.messaging.stop();
|
|
1045
1064
|
this._protocolInstance.dispose();
|
|
1046
1065
|
this._entered = false;
|
|
1047
|
-
this._closeKind = ProtocolCloseKind.CLIENT;
|
|
1066
|
+
this._closeKind = protocol_1.ProtocolCloseKind.CLIENT;
|
|
1048
1067
|
this._completeRoomClosed();
|
|
1049
1068
|
this._invokeTerminalCallbacks({ useErrorCallback: false });
|
|
1050
1069
|
this._localParticipant = null;
|
|
@@ -1084,14 +1103,14 @@ export class RoomClient {
|
|
|
1084
1103
|
_sendRoomRequestNowait(type, request, { data, label, expectResponse = false, }) {
|
|
1085
1104
|
return this._sendProtocolNowait({
|
|
1086
1105
|
type,
|
|
1087
|
-
data: packMessage(request, data),
|
|
1106
|
+
data: (0, utils_1.packMessage)(request, data),
|
|
1088
1107
|
label,
|
|
1089
1108
|
expectResponse,
|
|
1090
1109
|
});
|
|
1091
1110
|
}
|
|
1092
1111
|
invokeNowait({ toolkit, tool, input, participantId, onBehalfOfId, callerContext, }) {
|
|
1093
|
-
const resolvedInput = input ?? new EmptyContent();
|
|
1094
|
-
const packedInput = unpackMessage(resolvedInput.pack());
|
|
1112
|
+
const resolvedInput = input ?? new response_1.EmptyContent();
|
|
1113
|
+
const packedInput = (0, utils_1.unpackMessage)(resolvedInput.pack());
|
|
1095
1114
|
const request = {
|
|
1096
1115
|
toolkit,
|
|
1097
1116
|
tool,
|
|
@@ -1110,7 +1129,7 @@ export class RoomClient {
|
|
|
1110
1129
|
_sendLocalAttributesNowait(attributes) {
|
|
1111
1130
|
this._sendProtocolNowait({
|
|
1112
1131
|
type: "set_attributes",
|
|
1113
|
-
data: packMessage(attributes),
|
|
1132
|
+
data: (0, utils_1.packMessage)(attributes),
|
|
1114
1133
|
label: "local participant attribute update",
|
|
1115
1134
|
});
|
|
1116
1135
|
}
|
|
@@ -1131,10 +1150,10 @@ export class RoomClient {
|
|
|
1131
1150
|
throw this._disconnectedError({ baseMessage: "room connection is disconnected" });
|
|
1132
1151
|
}
|
|
1133
1152
|
const requestId = this._protocolInstance.getNextMessageId();
|
|
1134
|
-
const completer = new Completer();
|
|
1153
|
+
const completer = new completer_1.Completer();
|
|
1135
1154
|
this._pendingRequests.set(requestId, completer);
|
|
1136
1155
|
try {
|
|
1137
|
-
await this._protocolInstance.send(type, packMessage(request, data), requestId);
|
|
1156
|
+
await this._protocolInstance.send(type, (0, utils_1.packMessage)(request, data), requestId);
|
|
1138
1157
|
return await completer.fut;
|
|
1139
1158
|
}
|
|
1140
1159
|
catch (error) {
|
|
@@ -1157,39 +1176,39 @@ export class RoomClient {
|
|
|
1157
1176
|
request["timeout"] = params.timeout;
|
|
1158
1177
|
}
|
|
1159
1178
|
const result = await this.sendRequest("room.list_toolkits", request);
|
|
1160
|
-
if (!(result instanceof JsonContent)) {
|
|
1161
|
-
throw new RoomServerException("unexpected return type from room.list_toolkits");
|
|
1179
|
+
if (!(result instanceof response_1.JsonContent)) {
|
|
1180
|
+
throw new room_server_client_1.RoomServerException("unexpected return type from room.list_toolkits");
|
|
1162
1181
|
}
|
|
1163
1182
|
const tools = result.json["tools"];
|
|
1164
1183
|
if (typeof tools !== "object" || tools === null || Array.isArray(tools)) {
|
|
1165
|
-
throw new RoomServerException("unexpected return type from room.list_toolkits");
|
|
1184
|
+
throw new room_server_client_1.RoomServerException("unexpected return type from room.list_toolkits");
|
|
1166
1185
|
}
|
|
1167
1186
|
const toolkits = [];
|
|
1168
1187
|
for (const [name, data] of Object.entries(tools)) {
|
|
1169
1188
|
if (typeof data !== "object" || data === null || Array.isArray(data)) {
|
|
1170
|
-
throw new RoomServerException("unexpected toolkit description from room.list_toolkits");
|
|
1189
|
+
throw new room_server_client_1.RoomServerException("unexpected toolkit description from room.list_toolkits");
|
|
1171
1190
|
}
|
|
1172
|
-
toolkits.push(ToolkitDescription.fromJson(data, { name }));
|
|
1191
|
+
toolkits.push(agent_client_1.ToolkitDescription.fromJson(data, { name }));
|
|
1173
1192
|
}
|
|
1174
1193
|
return toolkits;
|
|
1175
1194
|
}
|
|
1176
1195
|
async invoke(params) {
|
|
1177
|
-
const input = params.input ?? params.arguments ?? new EmptyContent();
|
|
1196
|
+
const input = params.input ?? params.arguments ?? new response_1.EmptyContent();
|
|
1178
1197
|
const request = {
|
|
1179
1198
|
toolkit: params.toolkit,
|
|
1180
1199
|
tool: params.tool,
|
|
1181
1200
|
};
|
|
1182
1201
|
let requestData;
|
|
1183
|
-
if (input instanceof BinaryContent ||
|
|
1184
|
-
input instanceof EmptyContent ||
|
|
1185
|
-
input instanceof ErrorContent ||
|
|
1186
|
-
input instanceof FileContent ||
|
|
1187
|
-
input instanceof JsonContent ||
|
|
1188
|
-
input instanceof LinkContent ||
|
|
1189
|
-
input instanceof TextContent) {
|
|
1202
|
+
if (input instanceof response_1.BinaryContent ||
|
|
1203
|
+
input instanceof response_1.EmptyContent ||
|
|
1204
|
+
input instanceof response_1.ErrorContent ||
|
|
1205
|
+
input instanceof response_1.FileContent ||
|
|
1206
|
+
input instanceof response_1.JsonContent ||
|
|
1207
|
+
input instanceof response_1.LinkContent ||
|
|
1208
|
+
input instanceof response_1.TextContent) {
|
|
1190
1209
|
const packed = input.pack();
|
|
1191
|
-
request["arguments"] = JSON.parse(splitMessageHeader(packed));
|
|
1192
|
-
const payload = splitMessagePayload(packed);
|
|
1210
|
+
request["arguments"] = JSON.parse((0, utils_1.splitMessageHeader)(packed));
|
|
1211
|
+
const payload = (0, utils_1.splitMessagePayload)(packed);
|
|
1193
1212
|
if (payload.length > 0) {
|
|
1194
1213
|
requestData = payload;
|
|
1195
1214
|
}
|
|
@@ -1201,7 +1220,7 @@ export class RoomClient {
|
|
|
1201
1220
|
};
|
|
1202
1221
|
}
|
|
1203
1222
|
else {
|
|
1204
|
-
throw new RoomServerException("invoke input must be a content value or JSON object");
|
|
1223
|
+
throw new room_server_client_1.RoomServerException("invoke input must be a content value or JSON object");
|
|
1205
1224
|
}
|
|
1206
1225
|
if (params.participantId != null) {
|
|
1207
1226
|
request["participant_id"] = params.participantId;
|
|
@@ -1235,8 +1254,8 @@ export class RoomClient {
|
|
|
1235
1254
|
try {
|
|
1236
1255
|
const response = await this.sendRequest("room.invoke_tool", request);
|
|
1237
1256
|
await requestTask;
|
|
1238
|
-
if (response instanceof ControlContent && response.method === "open") {
|
|
1239
|
-
throw new RoomServerException(`unexpected return type from ${params.toolkit}.${params.tool}`);
|
|
1257
|
+
if (response instanceof response_1.ControlContent && response.method === "open") {
|
|
1258
|
+
throw new room_server_client_1.RoomServerException(`unexpected return type from ${params.toolkit}.${params.tool}`);
|
|
1240
1259
|
}
|
|
1241
1260
|
return response;
|
|
1242
1261
|
}
|
|
@@ -1247,7 +1266,7 @@ export class RoomClient {
|
|
|
1247
1266
|
}
|
|
1248
1267
|
async invokeStream(params) {
|
|
1249
1268
|
const toolCallId = `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
1250
|
-
const controller = new StreamController();
|
|
1269
|
+
const controller = new stream_controller_1.StreamController();
|
|
1251
1270
|
const responseIterator = controller.stream[Symbol.asyncIterator]();
|
|
1252
1271
|
this._toolCallStreams.set(toolCallId, controller);
|
|
1253
1272
|
const request = {
|
|
@@ -1271,15 +1290,15 @@ export class RoomClient {
|
|
|
1271
1290
|
if (stream == null) {
|
|
1272
1291
|
return;
|
|
1273
1292
|
}
|
|
1274
|
-
stream.add(new ErrorContent({ text: `request stream failed: ${String(error)}` }));
|
|
1293
|
+
stream.add(new response_1.ErrorContent({ text: `request stream failed: ${String(error)}` }));
|
|
1275
1294
|
stream.close();
|
|
1276
1295
|
this._toolCallStreams.delete(toolCallId);
|
|
1277
1296
|
});
|
|
1278
1297
|
const response = await this.sendRequest("room.invoke_tool", request);
|
|
1279
|
-
if (!(response instanceof ControlContent) || response.method !== "open") {
|
|
1298
|
+
if (!(response instanceof response_1.ControlContent) || response.method !== "open") {
|
|
1280
1299
|
this._toolCallStreams.delete(toolCallId);
|
|
1281
1300
|
controller.close();
|
|
1282
|
-
throw new RoomServerException(`unexpected return type from ${params.toolkit}.${params.tool}`);
|
|
1301
|
+
throw new room_server_client_1.RoomServerException(`unexpected return type from ${params.toolkit}.${params.tool}`);
|
|
1283
1302
|
}
|
|
1284
1303
|
return {
|
|
1285
1304
|
[Symbol.asyncIterator]() {
|
|
@@ -1291,9 +1310,9 @@ export class RoomClient {
|
|
|
1291
1310
|
const packed = chunk.pack();
|
|
1292
1311
|
const request = {
|
|
1293
1312
|
tool_call_id: toolCallId,
|
|
1294
|
-
chunk: JSON.parse(splitMessageHeader(packed)),
|
|
1313
|
+
chunk: JSON.parse((0, utils_1.splitMessageHeader)(packed)),
|
|
1295
1314
|
};
|
|
1296
|
-
const payload = splitMessagePayload(packed);
|
|
1315
|
+
const payload = (0, utils_1.splitMessagePayload)(packed);
|
|
1297
1316
|
await this.sendRequest("room.tool_call_request_chunk", request, payload.length > 0 ? payload : undefined);
|
|
1298
1317
|
}
|
|
1299
1318
|
async _streamInvokeToolRequestChunks(toolCallId, input) {
|
|
@@ -1304,7 +1323,7 @@ export class RoomClient {
|
|
|
1304
1323
|
}
|
|
1305
1324
|
}
|
|
1306
1325
|
finally {
|
|
1307
|
-
await this._sendToolCallRequestChunk(toolCallId, new ControlContent({ method: "close" }));
|
|
1326
|
+
await this._sendToolCallRequestChunk(toolCallId, new response_1.ControlContent({ method: "close" }));
|
|
1308
1327
|
}
|
|
1309
1328
|
}
|
|
1310
1329
|
_decodeToolCallContent(params) {
|
|
@@ -1312,17 +1331,17 @@ export class RoomClient {
|
|
|
1312
1331
|
if (typeof chunk === "object" && chunk !== null && !Array.isArray(chunk)) {
|
|
1313
1332
|
const chunkMap = chunk;
|
|
1314
1333
|
if (typeof chunkMap["type"] === "string") {
|
|
1315
|
-
return unpackContent(packMessage(chunkMap, params.payload.length > 0 ? params.payload : undefined));
|
|
1334
|
+
return (0, response_1.unpackContent)((0, utils_1.packMessage)(chunkMap, params.payload.length > 0 ? params.payload : undefined));
|
|
1316
1335
|
}
|
|
1317
|
-
return new JsonContent({ json: chunkMap });
|
|
1336
|
+
return new response_1.JsonContent({ json: chunkMap });
|
|
1318
1337
|
}
|
|
1319
|
-
return new JsonContent({ json: { chunk } });
|
|
1338
|
+
return new response_1.JsonContent({ json: { chunk } });
|
|
1320
1339
|
}
|
|
1321
1340
|
async _handleToolCallResponseChunk(protocol, _messageId, _type, data) {
|
|
1322
1341
|
if (!this.isActiveProtocol(protocol)) {
|
|
1323
1342
|
return;
|
|
1324
1343
|
}
|
|
1325
|
-
const [header, payload] = unpackMessage(data);
|
|
1344
|
+
const [header, payload] = (0, utils_1.unpackMessage)(data);
|
|
1326
1345
|
const toolCallId = header["tool_call_id"];
|
|
1327
1346
|
if (typeof toolCallId !== "string" || toolCallId.length === 0) {
|
|
1328
1347
|
return;
|
|
@@ -1333,7 +1352,7 @@ export class RoomClient {
|
|
|
1333
1352
|
}
|
|
1334
1353
|
const content = this._decodeToolCallContent({ header, payload });
|
|
1335
1354
|
stream.add(content);
|
|
1336
|
-
if (content instanceof ControlContent && content.method === "close") {
|
|
1355
|
+
if (content instanceof response_1.ControlContent && content.method === "close") {
|
|
1337
1356
|
stream.close();
|
|
1338
1357
|
this._toolCallStreams.delete(toolCallId);
|
|
1339
1358
|
}
|
|
@@ -1342,12 +1361,12 @@ export class RoomClient {
|
|
|
1342
1361
|
if (!this.isActiveProtocol(protocol)) {
|
|
1343
1362
|
return;
|
|
1344
1363
|
}
|
|
1345
|
-
const response = unpackContent(data);
|
|
1364
|
+
const response = (0, response_1.unpackContent)(data);
|
|
1346
1365
|
const pending = this._pendingRequests.get(messageId);
|
|
1347
1366
|
if (pending != null) {
|
|
1348
1367
|
this._pendingRequests.delete(messageId);
|
|
1349
|
-
if (response instanceof ErrorContent) {
|
|
1350
|
-
pending.completeError(new RoomServerException(response.text, response.code));
|
|
1368
|
+
if (response instanceof response_1.ErrorContent) {
|
|
1369
|
+
pending.completeError(new room_server_client_1.RoomServerException(response.text, response.code));
|
|
1351
1370
|
}
|
|
1352
1371
|
else {
|
|
1353
1372
|
pending.complete(response);
|
|
@@ -1357,7 +1376,7 @@ export class RoomClient {
|
|
|
1357
1376
|
const ignoredLabel = this._ignoredResponseLabels.get(messageId);
|
|
1358
1377
|
if (ignoredLabel != null) {
|
|
1359
1378
|
this._ignoredResponseLabels.delete(messageId);
|
|
1360
|
-
if (response instanceof ErrorContent) {
|
|
1379
|
+
if (response instanceof response_1.ErrorContent) {
|
|
1361
1380
|
console.warn(`one-way room request failed for ${ignoredLabel}: ${response.text}`);
|
|
1362
1381
|
}
|
|
1363
1382
|
}
|
|
@@ -1366,14 +1385,14 @@ export class RoomClient {
|
|
|
1366
1385
|
if (!this.isActiveProtocol(protocol)) {
|
|
1367
1386
|
return;
|
|
1368
1387
|
}
|
|
1369
|
-
const [payload] = unpackMessage(data);
|
|
1370
|
-
this.emit(RoomStatusEvent.fromJson(payload));
|
|
1388
|
+
const [payload] = (0, utils_1.unpackMessage)(data);
|
|
1389
|
+
this.emit(room_event_1.RoomStatusEvent.fromJson(payload));
|
|
1371
1390
|
}
|
|
1372
1391
|
async _handleRoomReady(protocol, _messageId, _type, data) {
|
|
1373
1392
|
if (!this.isActiveProtocol(protocol)) {
|
|
1374
1393
|
return;
|
|
1375
1394
|
}
|
|
1376
|
-
const [message] = unpackMessage(data);
|
|
1395
|
+
const [message] = (0, utils_1.unpackMessage)(data);
|
|
1377
1396
|
this._roomName = typeof message["room_name"] === "string" ? message["room_name"] : null;
|
|
1378
1397
|
this._roomUrl = typeof message["room_url"] === "string" ? message["room_url"] : null;
|
|
1379
1398
|
this._sessionId = typeof message["session_id"] === "string" ? message["session_id"] : null;
|
|
@@ -1386,7 +1405,7 @@ export class RoomClient {
|
|
|
1386
1405
|
}
|
|
1387
1406
|
_onParticipantInit(participantId, attributes) {
|
|
1388
1407
|
if (this._localParticipant == null) {
|
|
1389
|
-
this._localParticipant = new LocalParticipant(this, participantId);
|
|
1408
|
+
this._localParticipant = new participant_1.LocalParticipant(this, participantId);
|
|
1390
1409
|
this._localParticipant._setAttributes(attributes);
|
|
1391
1410
|
}
|
|
1392
1411
|
else {
|
|
@@ -1404,7 +1423,7 @@ export class RoomClient {
|
|
|
1404
1423
|
if (!this.isActiveProtocol(protocol)) {
|
|
1405
1424
|
return;
|
|
1406
1425
|
}
|
|
1407
|
-
const [message] = unpackMessage(data);
|
|
1426
|
+
const [message] = (0, utils_1.unpackMessage)(data);
|
|
1408
1427
|
switch (message["type"]) {
|
|
1409
1428
|
case "init": {
|
|
1410
1429
|
const participantId = message["participantId"];
|
|
@@ -1422,7 +1441,9 @@ export class RoomClient {
|
|
|
1422
1441
|
}
|
|
1423
1442
|
}
|
|
1424
1443
|
_emitStatus({ status, message, }) {
|
|
1425
|
-
this.emit(new RoomStatusEvent({ status, message }));
|
|
1444
|
+
this.emit(new room_event_1.RoomStatusEvent({ status, message }));
|
|
1426
1445
|
}
|
|
1427
1446
|
}
|
|
1428
|
-
RoomClient
|
|
1447
|
+
exports.RoomClient = RoomClient;
|
|
1448
|
+
RoomClient.RECONNECT_RETRY_BASE_DELAY_MS = 500;
|
|
1449
|
+
RoomClient.RECONNECT_RETRY_MAX_DELAY_MS = 30000;
|