@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
|
@@ -45,6 +45,11 @@ function serializeServiceSpec(service) {
|
|
|
45
45
|
agents,
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
+
function serializeCreateServiceSpec(service) {
|
|
49
|
+
const payload = serializeServiceSpec(service);
|
|
50
|
+
delete payload.id;
|
|
51
|
+
return payload;
|
|
52
|
+
}
|
|
48
53
|
const globalScope = globalThis;
|
|
49
54
|
function bytesToBase64(bytes) {
|
|
50
55
|
if (globalScope.Buffer) {
|
|
@@ -1261,7 +1266,7 @@ class Meshagent {
|
|
|
1261
1266
|
async createService(projectId, service) {
|
|
1262
1267
|
const data = await this.request(`/accounts/projects/${projectId}/services`, {
|
|
1263
1268
|
method: "POST",
|
|
1264
|
-
json:
|
|
1269
|
+
json: serializeCreateServiceSpec(service),
|
|
1265
1270
|
action: "create service",
|
|
1266
1271
|
});
|
|
1267
1272
|
if (!data || typeof data !== "object" || typeof data.id !== "string") {
|
|
@@ -1272,7 +1277,7 @@ class Meshagent {
|
|
|
1272
1277
|
async createRoomService(projectId, roomName, service) {
|
|
1273
1278
|
const data = await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/services`, {
|
|
1274
1279
|
method: "POST",
|
|
1275
|
-
json:
|
|
1280
|
+
json: serializeCreateServiceSpec(service),
|
|
1276
1281
|
action: "create room service",
|
|
1277
1282
|
});
|
|
1278
1283
|
if (!data || typeof data !== "object" || typeof data.id !== "string") {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -85,7 +85,8 @@ export declare class RoomClient {
|
|
|
85
85
|
private _roomName;
|
|
86
86
|
private _roomUrl;
|
|
87
87
|
private _sessionId;
|
|
88
|
-
private static readonly
|
|
88
|
+
private static readonly RECONNECT_RETRY_BASE_DELAY_MS;
|
|
89
|
+
private static readonly RECONNECT_RETRY_MAX_DELAY_MS;
|
|
89
90
|
private readonly _handleRoomReadyBound;
|
|
90
91
|
private readonly _handleRoomStatusBound;
|
|
91
92
|
private readonly _handleParticipantBound;
|
|
@@ -151,6 +152,7 @@ export declare class RoomClient {
|
|
|
151
152
|
private _completeReconnect;
|
|
152
153
|
private _replaceProtocol;
|
|
153
154
|
private _remainingReconnectTimeout;
|
|
155
|
+
private _reconnectRetryDelay;
|
|
154
156
|
private _attemptInitialProtocolStartup;
|
|
155
157
|
private _attemptReconnect;
|
|
156
158
|
private _formatDuration;
|
package/dist/node/room-client.js
CHANGED
|
@@ -29,6 +29,12 @@ class ProtocolStartupFailure extends Error {
|
|
|
29
29
|
this.reason = reason;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
+
function isRetryableStartupClose({ kind, reason, }) {
|
|
33
|
+
if (kind === protocol_1.ProtocolCloseKind.ERROR) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return (reason ?? "").toLowerCase().includes("1013");
|
|
37
|
+
}
|
|
32
38
|
class RoomClientTerminalState {
|
|
33
39
|
constructor({ requestMessage, toolCallMessage, messageSendMessage, }) {
|
|
34
40
|
this.requestMessage = requestMessage;
|
|
@@ -655,7 +661,8 @@ class RoomClient {
|
|
|
655
661
|
}
|
|
656
662
|
catch (error) {
|
|
657
663
|
if (error instanceof ProtocolStartupFailure) {
|
|
658
|
-
if (error.kind
|
|
664
|
+
if (!isRetryableStartupClose({ kind: error.kind, reason: error.reason })
|
|
665
|
+
|| this._reconnectTimeout === 0) {
|
|
659
666
|
this._setStartupTerminalState({
|
|
660
667
|
closeKind: error.kind,
|
|
661
668
|
closeReason: error.reason,
|
|
@@ -691,7 +698,8 @@ class RoomClient {
|
|
|
691
698
|
}
|
|
692
699
|
const closeKind = this._protocolInstance.closeKind;
|
|
693
700
|
const protocolCloseReason = normalizeCloseReason(this._protocolInstance.closeReason);
|
|
694
|
-
if (closeKind != null
|
|
701
|
+
if (closeKind != null
|
|
702
|
+
&& !isRetryableStartupClose({ kind: closeKind, reason: protocolCloseReason })) {
|
|
695
703
|
this._setStartupTerminalState({
|
|
696
704
|
closeKind,
|
|
697
705
|
closeReason: protocolCloseReason,
|
|
@@ -770,6 +778,9 @@ class RoomClient {
|
|
|
770
778
|
const remaining = deadline - Date.now();
|
|
771
779
|
return remaining <= 0 ? 0 : remaining;
|
|
772
780
|
}
|
|
781
|
+
_reconnectRetryDelay({ retryCount }) {
|
|
782
|
+
return Math.min(RoomClient.RECONNECT_RETRY_MAX_DELAY_MS, RoomClient.RECONNECT_RETRY_BASE_DELAY_MS * (2 ** retryCount));
|
|
783
|
+
}
|
|
773
784
|
async _attemptInitialProtocolStartup({ protocol, remaining, }) {
|
|
774
785
|
void protocol;
|
|
775
786
|
if (remaining == null) {
|
|
@@ -865,11 +876,13 @@ class RoomClient {
|
|
|
865
876
|
};
|
|
866
877
|
const deadline = this._reconnectTimeout == null ? null : Date.now() + this._reconnectTimeout;
|
|
867
878
|
let firstAttempt = true;
|
|
879
|
+
let retryCount = 0;
|
|
868
880
|
while (!this._closing) {
|
|
869
881
|
if (firstAttempt) {
|
|
870
882
|
firstAttempt = false;
|
|
871
883
|
if (this._reconnectTimeout == null) {
|
|
872
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
884
|
+
await new Promise((resolve) => setTimeout(resolve, this._reconnectRetryDelay({ retryCount })));
|
|
885
|
+
retryCount += 1;
|
|
873
886
|
}
|
|
874
887
|
}
|
|
875
888
|
else {
|
|
@@ -877,12 +890,14 @@ class RoomClient {
|
|
|
877
890
|
if (remaining != null && remaining === 0) {
|
|
878
891
|
return this._timedOutRetryResult({ disconnectReason: failureReason });
|
|
879
892
|
}
|
|
893
|
+
const backoffDelay = this._reconnectRetryDelay({ retryCount });
|
|
880
894
|
const delay = remaining == null
|
|
881
|
-
?
|
|
882
|
-
: Math.min(remaining,
|
|
895
|
+
? backoffDelay
|
|
896
|
+
: Math.min(remaining, backoffDelay);
|
|
883
897
|
if (delay > 0) {
|
|
884
898
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
885
899
|
}
|
|
900
|
+
retryCount += 1;
|
|
886
901
|
}
|
|
887
902
|
const remaining = this._remainingReconnectTimeout(deadline);
|
|
888
903
|
if (remaining != null && remaining === 0) {
|
|
@@ -917,7 +932,7 @@ class RoomClient {
|
|
|
917
932
|
if (error instanceof ProtocolStartupFailure) {
|
|
918
933
|
recordFailureReason(error.reason);
|
|
919
934
|
await this._closeProtocol(nextProtocol);
|
|
920
|
-
if (error.kind
|
|
935
|
+
if (!isRetryableStartupClose({ kind: error.kind, reason: error.reason })) {
|
|
921
936
|
return {
|
|
922
937
|
connected: false,
|
|
923
938
|
closeKind: error.kind,
|
|
@@ -1430,4 +1445,5 @@ class RoomClient {
|
|
|
1430
1445
|
}
|
|
1431
1446
|
}
|
|
1432
1447
|
exports.RoomClient = RoomClient;
|
|
1433
|
-
RoomClient.
|
|
1448
|
+
RoomClient.RECONNECT_RETRY_BASE_DELAY_MS = 500;
|
|
1449
|
+
RoomClient.RECONNECT_RETRY_MAX_DELAY_MS = 30000;
|