@meshagent/meshagent 0.37.1 → 0.38.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 +6 -0
- package/dist/browser/agent.js +74 -10
- package/dist/browser/developer-client.js +3 -0
- package/dist/browser/helpers.d.ts +2 -2
- package/dist/browser/helpers.js +1 -1
- package/dist/browser/meshagent-client.d.ts +25 -0
- package/dist/browser/meshagent-client.js +65 -0
- package/dist/browser/messaging-client.d.ts +29 -16
- package/dist/browser/messaging-client.js +256 -154
- package/dist/browser/participant.d.ts +7 -2
- package/dist/browser/participant.js +9 -9
- package/dist/browser/protocol.d.ts +85 -28
- package/dist/browser/protocol.js +356 -119
- package/dist/browser/room-client.d.ts +165 -29
- package/dist/browser/room-client.js +1114 -74
- package/dist/browser/room-event.d.ts +11 -0
- package/dist/browser/room-event.js +21 -1
- package/dist/browser/room-server-client.d.ts +2 -0
- package/dist/browser/room-server-client.js +6 -0
- package/dist/browser/runtime.d.ts +1 -1
- package/dist/browser/runtime.js +3 -1
- package/dist/browser/secrets-client.js +6 -2
- package/dist/browser/storage-client.d.ts +1 -0
- package/dist/browser/storage-client.js +9 -0
- package/dist/browser/sync-client.d.ts +16 -14
- package/dist/browser/sync-client.js +195 -116
- package/dist/esm/agent.js +74 -10
- package/dist/esm/developer-client.js +3 -0
- package/dist/esm/helpers.d.ts +2 -2
- package/dist/esm/helpers.js +1 -1
- package/dist/esm/meshagent-client.d.ts +25 -0
- package/dist/esm/meshagent-client.js +65 -0
- package/dist/esm/messaging-client.d.ts +29 -16
- package/dist/esm/messaging-client.js +256 -154
- package/dist/esm/participant.d.ts +7 -2
- package/dist/esm/participant.js +9 -9
- package/dist/esm/protocol.d.ts +85 -28
- package/dist/esm/protocol.js +352 -118
- package/dist/esm/room-client.d.ts +165 -29
- package/dist/esm/room-client.js +1112 -73
- package/dist/esm/room-event.d.ts +11 -0
- package/dist/esm/room-event.js +19 -0
- package/dist/esm/room-server-client.d.ts +2 -0
- package/dist/esm/room-server-client.js +7 -1
- package/dist/esm/runtime.d.ts +1 -1
- package/dist/esm/runtime.js +1 -1
- package/dist/esm/secrets-client.js +6 -2
- package/dist/esm/storage-client.d.ts +1 -0
- package/dist/esm/storage-client.js +9 -0
- package/dist/esm/sync-client.d.ts +16 -14
- package/dist/esm/sync-client.js +196 -117
- package/dist/node/agent.js +74 -10
- package/dist/node/developer-client.js +3 -0
- package/dist/node/helpers.d.ts +2 -2
- package/dist/node/helpers.js +1 -1
- package/dist/node/meshagent-client.d.ts +25 -0
- package/dist/node/meshagent-client.js +65 -0
- package/dist/node/messaging-client.d.ts +29 -16
- package/dist/node/messaging-client.js +256 -154
- package/dist/node/participant.d.ts +7 -2
- package/dist/node/participant.js +9 -9
- package/dist/node/protocol.d.ts +85 -28
- package/dist/node/protocol.js +356 -119
- package/dist/node/room-client.d.ts +165 -29
- package/dist/node/room-client.js +1114 -74
- package/dist/node/room-event.d.ts +11 -0
- package/dist/node/room-event.js +21 -1
- package/dist/node/room-server-client.d.ts +2 -0
- package/dist/node/room-server-client.js +6 -0
- package/dist/node/runtime.d.ts +1 -1
- package/dist/node/runtime.js +3 -1
- package/dist/node/secrets-client.js +6 -2
- package/dist/node/storage-client.d.ts +1 -0
- package/dist/node/storage-client.js +9 -0
- package/dist/node/sync-client.d.ts +16 -14
- package/dist/node/sync-client.js +195 -116
- package/package.json +6 -3
|
@@ -1,23 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LocalParticipant } from "./participant";
|
|
3
|
-
import { SyncClient } from "./sync-client";
|
|
1
|
+
import { DatabaseClient } from "./database-client";
|
|
4
2
|
import { DeveloperClient } from "./developer-client";
|
|
5
|
-
import {
|
|
3
|
+
import { type EventHandler, type EventName } from "./event-emitter";
|
|
6
4
|
import { MessagingClient } from "./messaging-client";
|
|
5
|
+
import { MemoryClient } from "./memory-client";
|
|
6
|
+
import { LocalParticipant } from "./participant";
|
|
7
|
+
import { Protocol, ProtocolCloseKind, ProtocolFactory, type MessageHandler } from "./protocol";
|
|
7
8
|
import { QueuesClient } from "./queues-client";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
9
|
+
import { Content } from "./response";
|
|
10
|
+
import { RoomEvent } from "./room-event";
|
|
11
|
+
import { RoomServerException } from "./room-server-client";
|
|
10
12
|
import { SecretsClient } from "./secrets-client";
|
|
11
|
-
import { ContainersClient } from "./containers-client";
|
|
12
|
-
import { MemoryClient } from "./memory-client";
|
|
13
13
|
import { ServicesClient } from "./services-client";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
14
|
+
import { StorageClient } from "./storage-client";
|
|
15
|
+
import { SyncClient } from "./sync-client";
|
|
16
|
+
import { AgentsClient, ToolkitDescription } from "./agent-client";
|
|
17
|
+
import { ContainersClient } from "./containers-client";
|
|
16
18
|
interface RequestHeader {
|
|
17
|
-
[key: string]:
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
export declare class RoomProtocolProxy {
|
|
22
|
+
private readonly _room;
|
|
23
|
+
private readonly _handlers;
|
|
24
|
+
constructor({ room }: {
|
|
25
|
+
room: RoomClient;
|
|
26
|
+
});
|
|
27
|
+
_bind(protocol: Protocol): void;
|
|
28
|
+
_unbind(protocol: Protocol): void;
|
|
29
|
+
addHandler(type: string, handler: MessageHandler): void;
|
|
30
|
+
removeHandler(type: string, handler: MessageHandler): void;
|
|
31
|
+
getHandler(type: string): MessageHandler | undefined;
|
|
32
|
+
send(type: string, data: Uint8Array, { id }?: {
|
|
33
|
+
id?: number;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
sendNowait(type: string, data: Uint8Array, { id }?: {
|
|
36
|
+
id?: number;
|
|
37
|
+
}): number;
|
|
38
|
+
getNextMessageId(): number;
|
|
39
|
+
get done(): Promise<unknown>;
|
|
40
|
+
waitForClose(): Promise<void>;
|
|
41
|
+
get closeKind(): ProtocolCloseKind | null;
|
|
42
|
+
get closeReason(): string | null;
|
|
43
|
+
get isOpen(): boolean;
|
|
44
|
+
get isClosed(): boolean;
|
|
45
|
+
get token(): string | null;
|
|
46
|
+
get url(): string | null;
|
|
18
47
|
}
|
|
19
48
|
export declare class RoomClient {
|
|
20
|
-
protocol:
|
|
49
|
+
readonly protocol: RoomProtocolProxy;
|
|
21
50
|
readonly sync: SyncClient;
|
|
22
51
|
readonly storage: StorageClient;
|
|
23
52
|
readonly developer: DeveloperClient;
|
|
@@ -29,26 +58,133 @@ export declare class RoomClient {
|
|
|
29
58
|
readonly containers: ContainersClient;
|
|
30
59
|
readonly memory: MemoryClient;
|
|
31
60
|
readonly services: ServicesClient;
|
|
32
|
-
|
|
33
|
-
|
|
61
|
+
_protocolInstance: Protocol;
|
|
62
|
+
_entered: boolean;
|
|
63
|
+
_allowDisconnectedRequests: boolean;
|
|
64
|
+
private readonly _protocolFactory;
|
|
65
|
+
private readonly _reconnectTimeout;
|
|
66
|
+
private readonly _eventsController;
|
|
67
|
+
private readonly _eventEmitter;
|
|
68
|
+
private readonly _pendingRequests;
|
|
69
|
+
private readonly _toolCallStreams;
|
|
70
|
+
private readonly _ignoredResponseLabels;
|
|
71
|
+
private readonly _ready;
|
|
72
|
+
private readonly _roomClosed;
|
|
73
|
+
private _connectionReady;
|
|
74
|
+
private _localParticipantReady;
|
|
75
|
+
private _connected;
|
|
76
|
+
private _closing;
|
|
34
77
|
private _localParticipant;
|
|
35
|
-
private
|
|
36
|
-
private
|
|
37
|
-
|
|
38
|
-
|
|
78
|
+
private _lifecycleTask;
|
|
79
|
+
private _terminalState;
|
|
80
|
+
private _closeKind;
|
|
81
|
+
private _closeReason;
|
|
82
|
+
private _doneHandler?;
|
|
83
|
+
private _errorHandler?;
|
|
84
|
+
private _terminalCallbacksInvoked;
|
|
85
|
+
private _roomName;
|
|
86
|
+
private _roomUrl;
|
|
87
|
+
private _sessionId;
|
|
88
|
+
private static readonly RECONNECT_RETRY_INTERVAL_MS;
|
|
89
|
+
private readonly _handleRoomReadyBound;
|
|
90
|
+
private readonly _handleRoomStatusBound;
|
|
91
|
+
private readonly _handleParticipantBound;
|
|
92
|
+
private readonly _handleResponseBound;
|
|
93
|
+
private readonly _handleToolCallResponseChunkBound;
|
|
94
|
+
constructor({ protocolFactory, reconnectTimeout, }?: {
|
|
95
|
+
protocolFactory?: ProtocolFactory | null;
|
|
96
|
+
reconnectTimeout?: number | null;
|
|
39
97
|
});
|
|
40
98
|
get localParticipant(): LocalParticipant | null;
|
|
41
|
-
get ready(): Promise<
|
|
42
|
-
|
|
99
|
+
get ready(): Promise<void>;
|
|
100
|
+
get isConnected(): boolean;
|
|
101
|
+
get isClosed(): boolean;
|
|
102
|
+
get isClosing(): boolean;
|
|
103
|
+
get closeKind(): ProtocolCloseKind | null;
|
|
104
|
+
get closeReason(): string | null;
|
|
105
|
+
get roomName(): string | null;
|
|
106
|
+
get roomUrl(): string | null;
|
|
107
|
+
get sessionId(): string | null;
|
|
108
|
+
isActiveProtocol(protocol: Protocol): boolean;
|
|
109
|
+
on(eventName: EventName, callback: EventHandler<RoomEvent>): void;
|
|
110
|
+
off(eventName: EventName, callback: EventHandler<RoomEvent>): void;
|
|
111
|
+
emit(event: RoomEvent): void;
|
|
112
|
+
listen(): AsyncIterable<RoomEvent>;
|
|
113
|
+
waitForClose(): Promise<void>;
|
|
114
|
+
waitUntilConnected(): Promise<void>;
|
|
115
|
+
_waitUntilConnectedForMessages(): Promise<void>;
|
|
116
|
+
private _markConnected;
|
|
117
|
+
private _markDisconnected;
|
|
118
|
+
private _completeRoomClosed;
|
|
119
|
+
private _invokeTerminalCallbacks;
|
|
120
|
+
private _formatClosedMessage;
|
|
121
|
+
private _connectionFailureReason;
|
|
122
|
+
private _protocolTerminalState;
|
|
123
|
+
private _clientClosedTerminalState;
|
|
124
|
+
private _unexpectedCloseTerminalState;
|
|
125
|
+
private _setStartupTerminalState;
|
|
126
|
+
private _setTerminalState;
|
|
127
|
+
_raiseIfTerminal(): void;
|
|
128
|
+
_raiseIfTerminalForMessages(): void;
|
|
129
|
+
_disconnectedError({ baseMessage }: {
|
|
130
|
+
baseMessage: string;
|
|
131
|
+
}): RoomServerException;
|
|
132
|
+
_messageDisconnectedError({ baseMessage, }: {
|
|
133
|
+
baseMessage: string;
|
|
134
|
+
}): RoomServerException;
|
|
135
|
+
private _startupException;
|
|
136
|
+
private _finalizeInitialStartupRetryFailure;
|
|
137
|
+
_coerceMessageSendError(error: RoomServerException): RoomServerException;
|
|
138
|
+
_messageStopError(): RoomServerException;
|
|
139
|
+
private _failPendingRequests;
|
|
140
|
+
private _failToolCallStreams;
|
|
141
|
+
private _failPendingWork;
|
|
142
|
+
private _openProtocol;
|
|
143
|
+
start({ onDone, onError, }?: {
|
|
43
144
|
onDone?: () => void;
|
|
44
|
-
onError?: (error:
|
|
145
|
+
onError?: (error: unknown) => void;
|
|
45
146
|
}): Promise<void>;
|
|
147
|
+
private _completeReconnect;
|
|
148
|
+
private _replaceProtocol;
|
|
149
|
+
private _remainingReconnectTimeout;
|
|
150
|
+
private _attemptInitialProtocolStartup;
|
|
151
|
+
private _attemptReconnect;
|
|
152
|
+
private _formatDuration;
|
|
153
|
+
private _reconnectTimeoutReason;
|
|
154
|
+
private _timedOutRetryResult;
|
|
155
|
+
private _closeAfterUnexpectedDisconnect;
|
|
156
|
+
private _closeProtocol;
|
|
157
|
+
private _retryProtocolConnection;
|
|
158
|
+
private _reconnect;
|
|
159
|
+
private _connectionLifecycle;
|
|
46
160
|
dispose(): void;
|
|
161
|
+
_sendProtocolNowait({ type, data, label, messageId, expectResponse, }: {
|
|
162
|
+
type: string;
|
|
163
|
+
data: Uint8Array;
|
|
164
|
+
label: string;
|
|
165
|
+
messageId?: number;
|
|
166
|
+
expectResponse?: boolean;
|
|
167
|
+
}): number | null;
|
|
168
|
+
_sendRoomRequestNowait(type: string, request: Record<string, unknown>, { data, label, expectResponse, }: {
|
|
169
|
+
data?: Uint8Array;
|
|
170
|
+
label: string;
|
|
171
|
+
expectResponse?: boolean;
|
|
172
|
+
}): number | null;
|
|
173
|
+
invokeNowait({ toolkit, tool, input, participantId, onBehalfOfId, callerContext, }: {
|
|
174
|
+
toolkit: string;
|
|
175
|
+
tool: string;
|
|
176
|
+
input?: Content;
|
|
177
|
+
participantId?: string;
|
|
178
|
+
onBehalfOfId?: string;
|
|
179
|
+
callerContext?: Record<string, unknown>;
|
|
180
|
+
}): void;
|
|
181
|
+
_sendLocalAttributesNowait(attributes: Record<string, unknown>): void;
|
|
182
|
+
_resendLocalAttributesNowait(): void;
|
|
47
183
|
sendRequest(type: string, request: RequestHeader, data?: Uint8Array): Promise<Content>;
|
|
48
184
|
call(params: {
|
|
49
185
|
name: string;
|
|
50
186
|
url: string;
|
|
51
|
-
arguments: Record<string,
|
|
187
|
+
arguments: Record<string, unknown>;
|
|
52
188
|
}): Promise<void>;
|
|
53
189
|
listToolkits(params?: {
|
|
54
190
|
participantId?: string;
|
|
@@ -58,11 +194,11 @@ export declare class RoomClient {
|
|
|
58
194
|
invoke(params: {
|
|
59
195
|
toolkit: string;
|
|
60
196
|
tool: string;
|
|
61
|
-
arguments?: Record<string,
|
|
62
|
-
input?: Record<string,
|
|
197
|
+
arguments?: Record<string, unknown>;
|
|
198
|
+
input?: Record<string, unknown> | Content;
|
|
63
199
|
participantId?: string;
|
|
64
200
|
onBehalfOfId?: string;
|
|
65
|
-
callerContext?: Record<string,
|
|
201
|
+
callerContext?: Record<string, unknown>;
|
|
66
202
|
}): Promise<Content>;
|
|
67
203
|
invokeWithStreamInput(params: {
|
|
68
204
|
toolkit: string;
|
|
@@ -70,7 +206,7 @@ export declare class RoomClient {
|
|
|
70
206
|
input: AsyncIterable<Content>;
|
|
71
207
|
participantId?: string;
|
|
72
208
|
onBehalfOfId?: string;
|
|
73
|
-
callerContext?: Record<string,
|
|
209
|
+
callerContext?: Record<string, unknown>;
|
|
74
210
|
}): Promise<Content>;
|
|
75
211
|
invokeStream(params: {
|
|
76
212
|
toolkit: string;
|
|
@@ -78,17 +214,17 @@ export declare class RoomClient {
|
|
|
78
214
|
input: AsyncIterable<Content>;
|
|
79
215
|
participantId?: string;
|
|
80
216
|
onBehalfOfId?: string;
|
|
81
|
-
callerContext?: Record<string,
|
|
217
|
+
callerContext?: Record<string, unknown>;
|
|
82
218
|
}): Promise<AsyncIterable<Content>>;
|
|
83
219
|
private _sendToolCallRequestChunk;
|
|
84
220
|
private _streamInvokeToolRequestChunks;
|
|
85
221
|
private _decodeToolCallContent;
|
|
86
222
|
private _handleToolCallResponseChunk;
|
|
87
223
|
private _handleResponse;
|
|
224
|
+
private _handleRoomStatus;
|
|
88
225
|
private _handleRoomReady;
|
|
89
226
|
private _onParticipantInit;
|
|
90
227
|
private _handleParticipant;
|
|
91
|
-
|
|
92
|
-
listen(): AsyncIterable<RoomEvent>;
|
|
228
|
+
private _emitStatus;
|
|
93
229
|
}
|
|
94
230
|
export {};
|