@meshagent/meshagent-agents 0.47.0 → 0.48.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/README.md +28 -5
- package/dist/browser/agent-messages.d.ts +1448 -107
- package/dist/browser/agent-messages.js +345 -193
- package/dist/browser/chat-client.d.ts +129 -35
- package/dist/browser/chat-client.js +631 -203
- package/dist/browser/images-dataset.d.ts +1 -1
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.js +8 -0
- package/dist/browser/thread-storage.d.ts +1 -1
- package/dist/esm/agent-messages.d.ts +1448 -107
- package/dist/esm/agent-messages.js +340 -189
- package/dist/esm/chat-client.d.ts +129 -35
- package/dist/esm/chat-client.js +623 -203
- package/dist/esm/images-dataset.d.ts +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/thread-storage.d.ts +1 -1
- package/dist/node/agent-messages.d.ts +1448 -107
- package/dist/node/agent-messages.js +345 -193
- package/dist/node/chat-client.d.ts +129 -35
- package/dist/node/chat-client.js +631 -203
- package/dist/node/images-dataset.d.ts +1 -1
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.js +8 -0
- package/dist/node/thread-storage.d.ts +1 -1
- package/package.json +7 -3
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { RemoteParticipant } from "@meshagent/meshagent";
|
|
1
|
+
import { MessagingStream, RemoteParticipant } from "@meshagent/meshagent";
|
|
2
2
|
import type { RoomClient, Content } from "@meshagent/meshagent";
|
|
3
|
-
import { AgentMessage,
|
|
4
|
-
import type { AgentPayload,
|
|
3
|
+
import { AgentMessage, AgentFileContent, ThreadCreated, AgentConnectionStatus } from "./agent-messages.js";
|
|
4
|
+
import type { AgentPayload, ClientToolkitDescription } from "./agent-messages.js";
|
|
5
5
|
import { ChangeEmitter } from "./change-emitter.js";
|
|
6
|
+
type JsonMap = Record<string, any>;
|
|
6
7
|
export declare class AgentMessageEvent {
|
|
7
|
-
|
|
8
|
+
private messageValue;
|
|
9
|
+
private readonly listeners;
|
|
8
10
|
readonly createdAt: Date;
|
|
9
11
|
readonly attachment?: Uint8Array;
|
|
10
12
|
constructor({ message, createdAt, attachment }: {
|
|
@@ -12,7 +14,11 @@ export declare class AgentMessageEvent {
|
|
|
12
14
|
createdAt?: Date;
|
|
13
15
|
attachment?: Uint8Array;
|
|
14
16
|
});
|
|
17
|
+
get message(): AgentMessage;
|
|
15
18
|
get payload(): AgentPayload;
|
|
19
|
+
addEventListener(listener: () => void): void;
|
|
20
|
+
removeEventListener(listener: () => void): void;
|
|
21
|
+
replaceMessage(message: AgentMessage): void;
|
|
16
22
|
}
|
|
17
23
|
export declare class PendingAgentInput {
|
|
18
24
|
readonly messageId: string;
|
|
@@ -77,12 +83,28 @@ export declare class ChatThreadStartResult {
|
|
|
77
83
|
realtimeConnection?: JsonMap;
|
|
78
84
|
});
|
|
79
85
|
}
|
|
86
|
+
export declare class PendingThreadStartCandidate {
|
|
87
|
+
readonly messageId: string;
|
|
88
|
+
readonly senderName?: string;
|
|
89
|
+
constructor({ messageId, senderName }: {
|
|
90
|
+
messageId: string;
|
|
91
|
+
senderName: string | undefined;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
export type ThreadCreatedPendingStartMatcher = (message: InstanceType<typeof ThreadCreated>, candidates: PendingThreadStartCandidate[]) => string | undefined;
|
|
80
95
|
export declare abstract class BaseChatClient extends ChangeEmitter {
|
|
96
|
+
readonly threadCreatedPendingStartMatcher?: ThreadCreatedPendingStartMatcher;
|
|
97
|
+
readonly deduplicateClientToolRequests: boolean;
|
|
81
98
|
private readonly sessionsByPath;
|
|
82
99
|
private readonly pendingStartRequests;
|
|
83
100
|
private readonly pendingSessionEventsByPath;
|
|
84
101
|
private readonly eventQueue;
|
|
102
|
+
private readonly claimedClientToolRequests;
|
|
85
103
|
private _connectionStatus?;
|
|
104
|
+
constructor({ threadCreatedPendingStartMatcher, deduplicateClientToolRequests, }?: {
|
|
105
|
+
threadCreatedPendingStartMatcher?: ThreadCreatedPendingStartMatcher;
|
|
106
|
+
deduplicateClientToolRequests?: boolean;
|
|
107
|
+
});
|
|
86
108
|
get events(): AsyncIterable<AgentMessageEvent>;
|
|
87
109
|
get connectionStatus(): InstanceType<typeof AgentConnectionStatus> | undefined;
|
|
88
110
|
get sessions(): ChatThreadSession[];
|
|
@@ -91,19 +113,17 @@ export declare abstract class BaseChatClient extends ChangeEmitter {
|
|
|
91
113
|
agentParticipant(): RemoteParticipant | null;
|
|
92
114
|
localParticipantName(): string | undefined;
|
|
93
115
|
localParticipantId(): string | undefined;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
openThread(threadPath: string, { load, sinceTurn, reloadIfOpen, drainPendingEvents, }?: {
|
|
116
|
+
private clientToolRequestKey;
|
|
117
|
+
openThread(threadPath: string, { load, sinceTurn, reloadIfOpen, }?: {
|
|
97
118
|
load?: boolean;
|
|
98
119
|
sinceTurn?: string;
|
|
99
120
|
reloadIfOpen?: boolean;
|
|
100
|
-
drainPendingEvents?: boolean;
|
|
101
121
|
}): ChatThreadSession;
|
|
102
122
|
private openSession;
|
|
103
|
-
startThread({ messageId, message, attachments, name, backend, provider, model, voice, outputModalities, realtimeProtocol, senderName, clientToolkits,
|
|
123
|
+
startThread({ messageId, message, attachments, name, backend, provider, model, voice, outputModalities, realtimeProtocol, senderName, clientToolkits, omitContent, }: {
|
|
104
124
|
messageId?: string;
|
|
105
125
|
message: string;
|
|
106
|
-
attachments:
|
|
126
|
+
attachments: AgentFileContent[];
|
|
107
127
|
name?: string;
|
|
108
128
|
backend?: string;
|
|
109
129
|
provider?: string;
|
|
@@ -113,7 +133,6 @@ export declare abstract class BaseChatClient extends ChangeEmitter {
|
|
|
113
133
|
realtimeProtocol?: string;
|
|
114
134
|
senderName?: string;
|
|
115
135
|
clientToolkits?: ClientToolkitDescription[];
|
|
116
|
-
toolChoice?: ToolChoice;
|
|
117
136
|
omitContent?: boolean;
|
|
118
137
|
}): Promise<ChatThreadStartResult>;
|
|
119
138
|
private resolvedStartThreadMessage;
|
|
@@ -125,6 +144,7 @@ export declare abstract class BaseChatClient extends ChangeEmitter {
|
|
|
125
144
|
createdAt?: Date;
|
|
126
145
|
attachment?: Uint8Array;
|
|
127
146
|
}): void;
|
|
147
|
+
private acknowledgePendingStartFromThreadCreated;
|
|
128
148
|
emitConnectionStatus({ status, message, reason, retryDelay, }: {
|
|
129
149
|
status: string;
|
|
130
150
|
message?: string;
|
|
@@ -133,7 +153,30 @@ export declare abstract class BaseChatClient extends ChangeEmitter {
|
|
|
133
153
|
}): void;
|
|
134
154
|
removeThreadSession(threadPath: string): void;
|
|
135
155
|
}
|
|
136
|
-
export declare
|
|
156
|
+
export declare const messagingChatThreadSubscribeType = "meshagent.chat.thread.subscribe";
|
|
157
|
+
export declare const messagingChatThreadListSubscribeType = "meshagent.chat.thread_list.subscribe";
|
|
158
|
+
export declare class ThreadSubscribe {
|
|
159
|
+
readonly threadId: string;
|
|
160
|
+
readonly stream: MessagingStream;
|
|
161
|
+
constructor({ threadId, stream }: {
|
|
162
|
+
threadId: string;
|
|
163
|
+
stream: MessagingStream;
|
|
164
|
+
});
|
|
165
|
+
get closed(): boolean;
|
|
166
|
+
send(message: AgentMessage, { attachment }?: {
|
|
167
|
+
attachment?: Uint8Array;
|
|
168
|
+
}): Promise<void>;
|
|
169
|
+
close(): Promise<void>;
|
|
170
|
+
}
|
|
171
|
+
export declare class ThreadListSubscribe {
|
|
172
|
+
readonly stream: MessagingStream;
|
|
173
|
+
constructor({ stream }: {
|
|
174
|
+
stream: MessagingStream;
|
|
175
|
+
});
|
|
176
|
+
get closed(): boolean;
|
|
177
|
+
close(): Promise<void>;
|
|
178
|
+
}
|
|
179
|
+
export declare class BaseMessagingChatClient extends BaseChatClient {
|
|
137
180
|
readonly room: RoomClient;
|
|
138
181
|
readonly agentName?: string;
|
|
139
182
|
private readonly pendingParticipantWaits;
|
|
@@ -143,9 +186,11 @@ export declare class MessagingChatClient extends BaseChatClient {
|
|
|
143
186
|
private waitingForParticipant;
|
|
144
187
|
private roomAbortController?;
|
|
145
188
|
private messagingListenersAttached;
|
|
146
|
-
constructor({ room, agentName }: {
|
|
189
|
+
constructor({ room, agentName, threadCreatedPendingStartMatcher, deduplicateClientToolRequests, }: {
|
|
147
190
|
room: RoomClient;
|
|
148
191
|
agentName?: string;
|
|
192
|
+
threadCreatedPendingStartMatcher?: ThreadCreatedPendingStartMatcher;
|
|
193
|
+
deduplicateClientToolRequests?: boolean;
|
|
149
194
|
});
|
|
150
195
|
localParticipantName(): string | undefined;
|
|
151
196
|
localParticipantId(): string | undefined;
|
|
@@ -154,8 +199,10 @@ export declare class MessagingChatClient extends BaseChatClient {
|
|
|
154
199
|
private attachMessagingListeners;
|
|
155
200
|
private detachMessagingListeners;
|
|
156
201
|
agentParticipant(): RemoteParticipant | null;
|
|
157
|
-
waitForAgentParticipant({ waitKey }?: {
|
|
202
|
+
waitForAgentParticipant({ waitKey, signal, timeoutMs, }?: {
|
|
158
203
|
waitKey?: string;
|
|
204
|
+
signal?: AbortSignal;
|
|
205
|
+
timeoutMs?: number;
|
|
159
206
|
}): Promise<RemoteParticipant>;
|
|
160
207
|
sendAgentMessage(message: AgentMessage, { attachment }?: {
|
|
161
208
|
attachment?: Uint8Array;
|
|
@@ -167,6 +214,63 @@ export declare class MessagingChatClient extends BaseChatClient {
|
|
|
167
214
|
private reopenOpenSessions;
|
|
168
215
|
private readonly onMessagingMessage;
|
|
169
216
|
}
|
|
217
|
+
export declare class WebSocketChatClient extends BaseChatClient {
|
|
218
|
+
readonly url: URL;
|
|
219
|
+
readonly token: string;
|
|
220
|
+
readonly participantName?: string;
|
|
221
|
+
readonly protocols: string[];
|
|
222
|
+
readonly reconnect: boolean;
|
|
223
|
+
readonly reconnectInitialDelay: number;
|
|
224
|
+
readonly reconnectMaxDelay: number;
|
|
225
|
+
private webSocket?;
|
|
226
|
+
private receiveError?;
|
|
227
|
+
private closeCode?;
|
|
228
|
+
private closeReason?;
|
|
229
|
+
private started;
|
|
230
|
+
private stopping;
|
|
231
|
+
private connecting;
|
|
232
|
+
private reconnectAttempts;
|
|
233
|
+
private reconnectTimer?;
|
|
234
|
+
private assignedParticipantId?;
|
|
235
|
+
constructor({ url, token, participantName, protocols, reconnect, reconnectInitialDelay, reconnectMaxDelay, }: {
|
|
236
|
+
url: URL;
|
|
237
|
+
token: string;
|
|
238
|
+
participantName?: string;
|
|
239
|
+
protocols?: string[];
|
|
240
|
+
reconnect?: boolean;
|
|
241
|
+
reconnectInitialDelay?: number;
|
|
242
|
+
reconnectMaxDelay?: number;
|
|
243
|
+
});
|
|
244
|
+
get isConnected(): boolean;
|
|
245
|
+
localParticipantName(): string | undefined;
|
|
246
|
+
localParticipantId(): string | undefined;
|
|
247
|
+
start(): Promise<void>;
|
|
248
|
+
private connect;
|
|
249
|
+
stop(): Promise<void>;
|
|
250
|
+
sendAgentMessage(message: AgentMessage, { attachment }?: {
|
|
251
|
+
attachment?: Uint8Array;
|
|
252
|
+
}): Promise<void>;
|
|
253
|
+
private readonly onMessage;
|
|
254
|
+
private readonly onSocketError;
|
|
255
|
+
private readonly onSocketClose;
|
|
256
|
+
private detachSocketListeners;
|
|
257
|
+
private scheduleReconnect;
|
|
258
|
+
private nextReconnectDelay;
|
|
259
|
+
private reopenOpenSessions;
|
|
260
|
+
private resolvedProtocols;
|
|
261
|
+
private closedMessage;
|
|
262
|
+
}
|
|
263
|
+
export declare class MessagingChatClient extends BaseMessagingChatClient {
|
|
264
|
+
private readonly threadSubscriptions;
|
|
265
|
+
private threadListSubscription?;
|
|
266
|
+
private readonly streamTasks;
|
|
267
|
+
stop(): Promise<void>;
|
|
268
|
+
private supportsThreadSubscriptions;
|
|
269
|
+
private trackStream;
|
|
270
|
+
sendAgentMessage(message: AgentMessage, { attachment }?: {
|
|
271
|
+
attachment?: Uint8Array;
|
|
272
|
+
}): Promise<void>;
|
|
273
|
+
}
|
|
170
274
|
export declare class ChatThreadSession extends ChangeEmitter {
|
|
171
275
|
private readonly client;
|
|
172
276
|
readonly threadPath: string;
|
|
@@ -181,26 +285,15 @@ export declare class ChatThreadSession extends ChangeEmitter {
|
|
|
181
285
|
private openState;
|
|
182
286
|
private loadStateValue;
|
|
183
287
|
private lastCompletedTurnIdValue?;
|
|
184
|
-
private activeTurnIdValue?;
|
|
185
|
-
private threadStatusValue?;
|
|
186
|
-
private currentModelValue?;
|
|
187
|
-
private modelsResponseValue?;
|
|
188
288
|
private lastAgentMessageType?;
|
|
189
289
|
private lastAgentMessageAt?;
|
|
190
|
-
constructor(
|
|
191
|
-
client: BaseChatClient;
|
|
192
|
-
threadPath: string;
|
|
193
|
-
});
|
|
290
|
+
private constructor();
|
|
194
291
|
get messages(): AgentMessageEvent[];
|
|
195
292
|
get pendingInputs(): PendingAgentInput[];
|
|
196
293
|
get isOpen(): boolean;
|
|
197
294
|
get loadState(): ChatThreadSessionLoadState;
|
|
198
295
|
get isLoading(): boolean;
|
|
199
296
|
get lastCompletedTurnId(): string | undefined;
|
|
200
|
-
get activeTurnId(): string | undefined;
|
|
201
|
-
get threadStatus(): InstanceType<typeof AgentThreadStatus> | undefined;
|
|
202
|
-
get currentModel(): InstanceType<typeof AgentModelChanged> | undefined;
|
|
203
|
-
get modelsResponse(): InstanceType<typeof ModelsResponse> | undefined;
|
|
204
297
|
open({ load, sinceTurn }?: {
|
|
205
298
|
load?: boolean;
|
|
206
299
|
sinceTurn?: string;
|
|
@@ -220,10 +313,15 @@ export declare class ChatThreadSession extends ChangeEmitter {
|
|
|
220
313
|
requestId: string;
|
|
221
314
|
response: Content;
|
|
222
315
|
}): Promise<void>;
|
|
223
|
-
|
|
316
|
+
claimClientToolCall(requestId: string): boolean;
|
|
317
|
+
finishClientToolCall(requestId: string, { responseSent }: {
|
|
318
|
+
responseSent: boolean;
|
|
319
|
+
}): void;
|
|
320
|
+
injectMessages(messages: readonly AgentMessage[]): Promise<void>;
|
|
321
|
+
sendText({ messageId, text, attachments, steer, turnId, backend, provider, model, voice, outputModalities, senderName, clientToolkits, }: {
|
|
224
322
|
messageId?: string;
|
|
225
323
|
text: string;
|
|
226
|
-
attachments:
|
|
324
|
+
attachments: AgentFileContent[];
|
|
227
325
|
steer?: boolean;
|
|
228
326
|
turnId?: string;
|
|
229
327
|
backend?: string;
|
|
@@ -233,14 +331,14 @@ export declare class ChatThreadSession extends ChangeEmitter {
|
|
|
233
331
|
outputModalities?: string[];
|
|
234
332
|
senderName?: string;
|
|
235
333
|
clientToolkits?: ClientToolkitDescription[];
|
|
236
|
-
toolChoice?: ToolChoice;
|
|
237
334
|
}): Promise<string>;
|
|
238
335
|
sendRealtimeAudioChunk({ chunk, format }: {
|
|
239
336
|
chunk: Uint8Array;
|
|
240
337
|
format: JsonMap;
|
|
241
338
|
}): Promise<void>;
|
|
242
|
-
commitRealtimeAudio({ turnId, provider, model, voice, outputModalities, }: {
|
|
339
|
+
commitRealtimeAudio({ turnId, backend, provider, model, voice, outputModalities, }: {
|
|
243
340
|
turnId: string;
|
|
341
|
+
backend?: string;
|
|
244
342
|
provider?: string;
|
|
245
343
|
model?: string;
|
|
246
344
|
voice?: string;
|
|
@@ -253,16 +351,12 @@ export declare class ChatThreadSession extends ChangeEmitter {
|
|
|
253
351
|
private updatePendingInputsForMessage;
|
|
254
352
|
private appendRenderableMessage;
|
|
255
353
|
private appendMessage;
|
|
256
|
-
private upsertItemMessage;
|
|
257
354
|
private appendOrMergeDelta;
|
|
258
355
|
private indexMessagesFrom;
|
|
259
|
-
private applyActiveModel;
|
|
260
|
-
markClosed({ notify }?: {
|
|
261
|
-
notify?: boolean;
|
|
262
|
-
}): void;
|
|
263
356
|
private loadingStateForOpen;
|
|
264
357
|
private failedLoadState;
|
|
265
358
|
private setLoadState;
|
|
266
359
|
private markPending;
|
|
267
360
|
private updatePending;
|
|
268
361
|
}
|
|
362
|
+
export {};
|