@meshagent/meshagent-agents 0.46.4 → 0.47.1

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.
@@ -1,6 +1,6 @@
1
1
  import { Completer, } from "@meshagent/meshagent";
2
2
  import { v4 as uuidv4 } from "uuid";
3
- import { AgentMessage as AgentMessageFactory, AgentAudioGenerationDelta, AgentAudioTranscriptionDelta, AgentRealtimeAudioChunk, AgentRealtimeAudioCommit, AgentFileContentDelta, AgentModelChanged, AgentReasoningContentDelta, AgentTextContentDelta, AgentThreadStatus, AgentToolCallArgumentsDelta, AgentToolCallLogDelta, ChangeModel, CloseThread, DeleteThread, ModelsResponse, ModelsRequest, OpenThread, RenameThread, StartThread, AgentConnectionStatus, TurnInterrupt, TurnStart, TurnSteer, AgentClientToolCallRequested, AgentClientToolCallResponse, agentInputContent, agentAudioGenerationDeltaType, agentAudioTranscriptionDeltaType, agentFileContentDeltaType, agentImageGenerationCompletedType, agentImageGenerationPartialType, agentModelChangedType, agentModelsResponseType, agentReasoningContentDeltaType, agentRoomMessageType, agentTextContentDeltaType, agentThreadClearedType, agentThreadCreatedType, agentThreadDeletedType, agentThreadLoadedType, agentThreadListedType, agentThreadUpdatedType, agentConnectionStatusType, agentThreadStatusType, agentThreadStartType, agentThreadStartRejectedType, agentThreadStartedType, agentToolCallArgumentsDeltaType, agentToolCallLogDeltaType, agentToolCallEndedType, agentToolCallInProgressType, agentToolCallPendingType, agentToolCallStartedType, agentSecretRequestedType, agentTurnEndedType, agentTurnInterruptAcceptedType, agentTurnInterruptedType, agentTurnStartAcceptedType, agentTurnStartRejectedType, agentTurnStartType, agentTurnStartedType, agentTurnSteerAcceptedType, agentTurnSteerRejectedType, agentTurnSteerType, agentTurnSteeredType, agentUsageUpdatedType, } from "./agent-messages.js";
3
+ import { AgentMessage as AgentMessageFactory, AgentAudioGenerationDelta, AgentAudioTranscriptionDelta, AgentRealtimeAudioChunk, AgentRealtimeAudioCommit, AgentFileContentDelta, AgentModelChanged, AgentReasoningContentDelta, AgentTextContentDelta, AgentThreadStatus, AgentToolCallArgumentsDelta, AgentToolCallLogDelta, ChangeModel, CloseThread, DeleteThread, ModelsResponse, ModelsRequest, OpenThread, RenameThread, StartThread, AgentConnectionStatus, TurnInterrupt, TurnStart, TurnSteer, AgentClientToolCallRequested, AgentClientToolCallResponse, agentInputContent, agentAudioGenerationDeltaType, agentAudioTranscriptionDeltaType, agentFileContentDeltaType, agentImageGenerationCompletedType, agentImageGenerationPartialType, agentModelChangedType, agentModelsResponseType, agentReasoningContentDeltaType, agentRoomMessageType, agentTextContentDeltaType, agentThreadClearedType, agentThreadCreatedType, agentThreadDeletedType, agentThreadLoadedType, agentThreadListedType, agentThreadCloseType, agentThreadOpenType, agentThreadUnwatchType, agentThreadUpdatedType, agentThreadWatchType, agentConnectionStatusType, agentThreadStatusType, agentThreadStartType, agentThreadStartRejectedType, agentThreadStartedType, agentToolCallArgumentsDeltaType, agentToolCallLogDeltaType, agentToolCallEndedType, agentToolCallInProgressType, agentToolCallPendingType, agentToolCallStartedType, agentSecretRequestedType, agentTurnEndedType, agentTurnInterruptAcceptedType, agentTurnInterruptedType, agentTurnStartAcceptedType, agentTurnStartRejectedType, agentTurnStartType, agentTurnStartedType, agentTurnSteerAcceptedType, agentTurnSteerRejectedType, agentTurnSteerType, agentTurnSteeredType, agentUsageUpdatedType, } from "./agent-messages.js";
4
4
  import { ChangeEmitter } from "./change-emitter.js";
5
5
  export class AgentMessageEvent {
6
6
  constructor({ message, createdAt, attachment }) {
@@ -168,6 +168,13 @@ export class BaseChatClient extends ChangeEmitter {
168
168
  localParticipantName() {
169
169
  return undefined;
170
170
  }
171
+ localParticipantId() {
172
+ return undefined;
173
+ }
174
+ isClientToolCallForLocalParticipant(request) {
175
+ const targetParticipantId = request.targetParticipantId?.trim();
176
+ return targetParticipantId == null || targetParticipantId === "" || targetParticipantId === this.localParticipantId();
177
+ }
171
178
  cleanParticipantName(value) {
172
179
  return nonEmptyTrimmed(value);
173
180
  }
@@ -273,6 +280,10 @@ export class BaseChatClient extends ChangeEmitter {
273
280
  }
274
281
  }
275
282
  handleAgentMessage(message, { createdAt, attachment } = {}) {
283
+ if (message instanceof AgentClientToolCallRequested &&
284
+ !this.isClientToolCallForLocalParticipant(message)) {
285
+ return;
286
+ }
276
287
  if (message.type === agentConnectionStatusType) {
277
288
  this._connectionStatus = message;
278
289
  }
@@ -324,7 +335,39 @@ export class BaseChatClient extends ChangeEmitter {
324
335
  }
325
336
  }
326
337
  }
327
- export class MessagingChatClient extends BaseChatClient {
338
+ export const messagingChatThreadSubscribeType = "meshagent.chat.thread.subscribe";
339
+ export const messagingChatThreadListSubscribeType = "meshagent.chat.thread_list.subscribe";
340
+ export class ThreadSubscribe {
341
+ constructor({ threadId, stream }) {
342
+ this.threadId = threadId;
343
+ this.stream = stream;
344
+ }
345
+ get closed() {
346
+ return this.stream.closed;
347
+ }
348
+ async send(message, { attachment } = {}) {
349
+ await this.stream.sendMessage({
350
+ type: agentRoomMessageType,
351
+ message: message.toJson(),
352
+ attachment,
353
+ });
354
+ }
355
+ async close() {
356
+ await this.stream.close();
357
+ }
358
+ }
359
+ export class ThreadListSubscribe {
360
+ constructor({ stream }) {
361
+ this.stream = stream;
362
+ }
363
+ get closed() {
364
+ return this.stream.closed;
365
+ }
366
+ async close() {
367
+ await this.stream.close();
368
+ }
369
+ }
370
+ export class BaseMessagingChatClient extends BaseChatClient {
328
371
  constructor({ room, agentName }) {
329
372
  super();
330
373
  this.pendingParticipantWaits = new Map();
@@ -412,6 +455,9 @@ export class MessagingChatClient extends BaseChatClient {
412
455
  const name = this.room.localParticipant?.getAttribute("name");
413
456
  return typeof name === "string" ? this.cleanParticipantName(name) : undefined;
414
457
  }
458
+ localParticipantId() {
459
+ return this.room.localParticipant?.id;
460
+ }
415
461
  async start() {
416
462
  if (this.started) {
417
463
  return;
@@ -538,6 +584,122 @@ export class MessagingChatClient extends BaseChatClient {
538
584
  }
539
585
  }
540
586
  }
587
+ export class MessagingChatClient extends BaseMessagingChatClient {
588
+ constructor() {
589
+ super(...arguments);
590
+ this.threadSubscriptions = new Map();
591
+ this.streamTasks = new Set();
592
+ }
593
+ async stop() {
594
+ const subscriptions = [
595
+ ...this.threadSubscriptions.values(),
596
+ ];
597
+ if (this.threadListSubscription != null) {
598
+ subscriptions.push(this.threadListSubscription);
599
+ }
600
+ this.threadSubscriptions.clear();
601
+ this.threadListSubscription = undefined;
602
+ await Promise.all(subscriptions.map(async (subscription) => subscription.close()));
603
+ await Promise.all(this.streamTasks);
604
+ await super.stop();
605
+ }
606
+ supportsThreadSubscriptions(participant) {
607
+ return participant.getAttribute("supports_messaging_streams") === true;
608
+ }
609
+ trackStream(subscription) {
610
+ const task = (async () => {
611
+ try {
612
+ for await (const event of subscription.stream) {
613
+ if (event.kind !== "message" || event.message.type !== agentRoomMessageType) {
614
+ continue;
615
+ }
616
+ const raw = event.message.message;
617
+ if (typeof raw["type"] !== "string") {
618
+ continue;
619
+ }
620
+ this.handleAgentMessage(AgentMessageFactory.fromJson(raw), {
621
+ createdAt: dateOrNull(raw["created_at"]),
622
+ attachment: event.message.attachment,
623
+ });
624
+ }
625
+ }
626
+ finally {
627
+ if (subscription instanceof ThreadSubscribe) {
628
+ if (this.threadSubscriptions.get(subscription.threadId) === subscription) {
629
+ this.threadSubscriptions.delete(subscription.threadId);
630
+ }
631
+ }
632
+ else if (this.threadListSubscription === subscription) {
633
+ this.threadListSubscription = undefined;
634
+ }
635
+ }
636
+ })();
637
+ this.streamTasks.add(task);
638
+ void task.finally(() => this.streamTasks.delete(task));
639
+ }
640
+ async sendAgentMessage(message, { attachment } = {}) {
641
+ await this.start();
642
+ const participant = this.agentParticipant();
643
+ if (participant == null) {
644
+ throw new Error("Agent messaging participant is not available.");
645
+ }
646
+ if (!this.supportsThreadSubscriptions(participant)) {
647
+ await super.sendAgentMessage(message, { attachment });
648
+ return;
649
+ }
650
+ if (message.type === agentThreadOpenType) {
651
+ const previous = this.threadSubscriptions.get(message.threadId);
652
+ if (previous != null) {
653
+ await previous.close();
654
+ }
655
+ const stream = await this.room.messaging.stream({
656
+ to: participant,
657
+ type: messagingChatThreadSubscribeType,
658
+ message: message.toJson(),
659
+ attachment,
660
+ });
661
+ const subscription = new ThreadSubscribe({ threadId: message.threadId, stream });
662
+ this.threadSubscriptions.set(message.threadId, subscription);
663
+ this.trackStream(subscription);
664
+ return;
665
+ }
666
+ if (message.type === agentThreadCloseType) {
667
+ const subscription = this.threadSubscriptions.get(message.threadId);
668
+ if (subscription != null) {
669
+ this.threadSubscriptions.delete(message.threadId);
670
+ await subscription.close();
671
+ return;
672
+ }
673
+ }
674
+ if (message.type === agentThreadWatchType) {
675
+ await this.threadListSubscription?.close();
676
+ const stream = await this.room.messaging.stream({
677
+ to: participant,
678
+ type: messagingChatThreadListSubscribeType,
679
+ message: message.toJson(),
680
+ attachment,
681
+ });
682
+ const subscription = new ThreadListSubscribe({ stream });
683
+ this.threadListSubscription = subscription;
684
+ this.trackStream(subscription);
685
+ return;
686
+ }
687
+ if (message.type === agentThreadUnwatchType && this.threadListSubscription != null) {
688
+ const subscription = this.threadListSubscription;
689
+ this.threadListSubscription = undefined;
690
+ await subscription.close();
691
+ return;
692
+ }
693
+ if ("threadId" in message && typeof message.threadId === "string") {
694
+ const subscription = this.threadSubscriptions.get(message.threadId);
695
+ if (subscription != null) {
696
+ await subscription.send(message, { attachment });
697
+ return;
698
+ }
699
+ }
700
+ await super.sendAgentMessage(message, { attachment });
701
+ }
702
+ }
541
703
  function isThreadListMessage(message) {
542
704
  return message.type === agentThreadListedType
543
705
  || message.type === agentThreadCreatedType
@@ -551,6 +713,8 @@ export class ChatThreadSession extends ChangeEmitter {
551
713
  this.messageIndexes = new Map();
552
714
  this.localAgentMessageIds = new Set();
553
715
  this.pendingLocalInputMessageIds = new Set();
716
+ this.resolvedInputMessageIds = new Set();
717
+ this.completedTurnIds = new Set();
554
718
  this.mergedDeltaMessageIds = new Set();
555
719
  this.pendingInputsById = new Map();
556
720
  this.openState = false;
@@ -629,6 +793,8 @@ export class ChatThreadSession extends ChangeEmitter {
629
793
  this.messageIndexes.clear();
630
794
  this.localAgentMessageIds.clear();
631
795
  this.pendingLocalInputMessageIds.clear();
796
+ this.resolvedInputMessageIds.clear();
797
+ this.completedTurnIds.clear();
632
798
  this.mergedDeltaMessageIds.clear();
633
799
  this.pendingInputsById.clear();
634
800
  this.lastCompletedTurnIdValue = undefined;
@@ -780,15 +946,19 @@ export class ChatThreadSession extends ChangeEmitter {
780
946
  return;
781
947
  }
782
948
  if (message.type === agentThreadStatusType && message instanceof AgentThreadStatus) {
783
- this.threadStatusValue = message;
784
949
  const mode = normalizedString(message.mode);
785
950
  const status = normalizedString(message.status);
786
951
  const turnId = normalizedString(message.turnId);
787
- if (status != null && mode === "steerable" && turnId != null) {
788
- this.activeTurnIdValue = turnId;
952
+ if (status == null) {
953
+ this.threadStatusValue = undefined;
954
+ if (turnId != null && this.activeTurnIdValue === turnId) {
955
+ this.activeTurnIdValue = undefined;
956
+ }
957
+ return;
789
958
  }
790
- else if (status == null && turnId != null && this.activeTurnIdValue === turnId) {
791
- this.activeTurnIdValue = undefined;
959
+ this.threadStatusValue = message;
960
+ if (mode === "steerable" && turnId != null) {
961
+ this.activeTurnIdValue = turnId;
792
962
  }
793
963
  return;
794
964
  }
@@ -816,21 +986,29 @@ export class ChatThreadSession extends ChangeEmitter {
816
986
  updatePendingInputsForMessage(message, createdAt) {
817
987
  const type = message.type;
818
988
  const messageId = message.messageId;
819
- const sourceMessageId = sourceMessageIdFor(message);
989
+ const sourceMessageId = normalizedString(sourceMessageIdFor(message));
820
990
  if (type === agentThreadStartType || type === agentTurnStartType || type === agentTurnSteerType) {
821
991
  const normalizedMessageId = messageId.trim();
822
992
  if (normalizedMessageId !== "") {
993
+ const wasPending = this.pendingInputsById.has(normalizedMessageId);
994
+ const turnId = type === agentTurnStartType || type === agentTurnSteerType
995
+ ? normalizedString(threadMessageValue(message, "turnId"))
996
+ : undefined;
997
+ const wasAlreadyResolved = !wasPending && (this.resolvedInputMessageIds.has(normalizedMessageId) ||
998
+ (turnId != null && this.completedTurnIds.has(turnId)));
823
999
  this.localAgentMessageIds.add(normalizedMessageId);
824
1000
  this.pendingLocalInputMessageIds.add(normalizedMessageId);
825
- this.markPending(new PendingAgentInput({
826
- messageId: normalizedMessageId,
827
- messageType: type,
828
- threadPath: this.threadPath,
829
- payload: message,
830
- createdAt,
831
- awaitingAcceptance: true,
832
- awaitingApplication: true,
833
- }));
1001
+ if (!wasAlreadyResolved) {
1002
+ this.markPending(new PendingAgentInput({
1003
+ messageId: normalizedMessageId,
1004
+ messageType: type,
1005
+ threadPath: this.threadPath,
1006
+ payload: message,
1007
+ createdAt,
1008
+ awaitingAcceptance: true,
1009
+ awaitingApplication: true,
1010
+ }));
1011
+ }
834
1012
  }
835
1013
  }
836
1014
  else if (type === agentThreadStartRejectedType) {
@@ -843,12 +1021,14 @@ export class ChatThreadSession extends ChangeEmitter {
843
1021
  }
844
1022
  else if (type === agentTurnStartedType || type === agentTurnSteeredType) {
845
1023
  if (sourceMessageId != null) {
1024
+ this.resolvedInputMessageIds.add(sourceMessageId);
846
1025
  this.pendingInputsById.delete(sourceMessageId);
847
1026
  this.pendingLocalInputMessageIds.delete(sourceMessageId);
848
1027
  }
849
1028
  }
850
1029
  else if (type === agentTurnStartRejectedType || type === agentTurnSteerRejectedType) {
851
1030
  if (sourceMessageId != null) {
1031
+ this.resolvedInputMessageIds.add(sourceMessageId);
852
1032
  this.pendingInputsById.delete(sourceMessageId);
853
1033
  this.pendingLocalInputMessageIds.delete(sourceMessageId);
854
1034
  }
@@ -856,6 +1036,15 @@ export class ChatThreadSession extends ChangeEmitter {
856
1036
  else if (type === agentTurnEndedType || type === agentThreadClearedType) {
857
1037
  this.pendingInputsById.clear();
858
1038
  this.pendingLocalInputMessageIds.clear();
1039
+ if (type === agentTurnEndedType) {
1040
+ const turnId = normalizedString(threadMessageValue(message, "turnId"));
1041
+ if (turnId != null)
1042
+ this.completedTurnIds.add(turnId);
1043
+ }
1044
+ else if (type === agentThreadClearedType) {
1045
+ this.resolvedInputMessageIds.clear();
1046
+ this.completedTurnIds.clear();
1047
+ }
859
1048
  }
860
1049
  }
861
1050
  appendRenderableMessage(event) {
@@ -747,26 +747,16 @@ function makeMessageClass({ type, base = "message", fields = [], }) {
747
747
  params.model = stringOrNull(json.model);
748
748
  }
749
749
  for (const field of fields) {
750
- if (field.required) {
751
- if (field.from != null) {
752
- params[field.prop] = field.from(json[field.json], json);
750
+ if (!hasOwn(json, field.json)) {
751
+ if (field.required) {
752
+ if (field.from != null) {
753
+ field.from(undefined, json);
754
+ }
755
+ throw new TypeError(`missing required field '${field.json}'`);
753
756
  }
754
- else if (typeof json[field.json] === "string") {
755
- params[field.prop] = requiredString(json, field.json);
756
- }
757
- else if (typeof json[field.json] === "number") {
758
- params[field.prop] = json[field.json];
759
- }
760
- else {
761
- params[field.prop] = requiredMap(json, field.json);
762
- }
763
- }
764
- else if (hasOwn(json, field.json)) {
765
- params[field.prop] = field.from != null ? field.from(json[field.json], json) : json[field.json];
766
- }
767
- else if (field.default != null) {
768
- params[field.prop] = field.default(json);
757
+ continue;
769
758
  }
759
+ params[field.prop] = json[field.json];
770
760
  }
771
761
  return new this(params);
772
762
  }
@@ -990,10 +980,10 @@ exports.AgentToolCallLogDelta = makeMessageClass({ type: exports.agentToolCallLo
990
980
  exports.AgentToolCallEnded = makeMessageClass({ type: exports.agentToolCallEndedType, base: "llm", fields: [...contentPart, { prop: "namespace", json: "namespace", from: (value) => stringOrNull(value) ?? "meshagent", default: () => "meshagent", always: true }, s("callId"), s("toolkit"), s("tool"), { prop: "result", json: "result", from: contentOrNull, to: contentHeader }, obj("error", "error", AgentError.fromJson)] });
991
981
  exports.AgentToolCallApprovalRequested = makeMessageClass({ type: exports.agentToolCallApprovalRequestedType, base: "llm", fields: toolState.filter((field) => field.prop !== "argumentBytes") });
992
982
  exports.AgentSecretRequested = makeMessageClass({ type: exports.agentSecretRequestedType, base: "llm", fields: [...contentPart, s("requestId", "request_id", true), s("name", "name", true), s("scope")] });
993
- exports.AgentClientToolCallRequested = makeMessageClass({ type: exports.agentClientToolCallRequestedType, base: "llm", fields: [...contentPart, s("requestId", "request_id", true), s("toolkit", "toolkit", true), s("tool", "tool", true), m("arguments", "arguments", true)] });
994
- exports.AgentClientToolCallCancelled = makeMessageClass({ type: exports.agentClientToolCallCancelledType, base: "llm", fields: [...contentPart, s("requestId", "request_id", true), s("reason")] });
983
+ exports.AgentClientToolCallRequested = makeMessageClass({ type: exports.agentClientToolCallRequestedType, base: "llm", fields: [...contentPart, s("requestId", "request_id", true), s("targetParticipantId"), s("toolkit", "toolkit", true), s("tool", "tool", true), m("arguments", "arguments", true)] });
984
+ exports.AgentClientToolCallCancelled = makeMessageClass({ type: exports.agentClientToolCallCancelledType, base: "llm", fields: [...contentPart, s("requestId", "request_id", true), s("targetParticipantId"), s("reason")] });
995
985
  exports.AgentThreadStatus = makeMessageClass({ type: exports.agentThreadStatusType, base: "thread", fields: [s("status"), s("mode"), s("startedAt"), s("turnId"), s("pendingItemId"), i("totalBytes"), i("linesAdded"), i("linesRemoved")] });
996
- exports.AgentConnectionStatus = makeMessageClass({ type: exports.agentConnectionStatusType, fields: [s("status", "status", true), s("message"), s("reason"), n("retryInSeconds")] });
986
+ exports.AgentConnectionStatus = makeMessageClass({ type: exports.agentConnectionStatusType, fields: [s("status", "status", true), s("message"), s("reason"), n("retryInSeconds"), s("participantId")] });
997
987
  exports.AgentThreadEvent = makeMessageClass({ type: exports.agentThreadEventType, base: "llm", fields: [m("event", "event", true)] });
998
988
  exports.AgentImageGenerationStarted = makeMessageClass({ type: exports.agentImageGenerationStartedType, base: "llm", fields: imageGeneration });
999
989
  exports.AgentImageGenerationPartial = makeMessageClass({ type: exports.agentImageGenerationPartialType, base: "llm", fields: [...imageGeneration, obj("image", "image", AgentGeneratedImage.fromJson), i("partialIndex")] });
@@ -1,6 +1,6 @@
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, AgentModelChanged, AgentThreadStatus, ModelsResponse, ToolChoice, AgentConnectionStatus } from "./agent-messages.js";
3
+ import { AgentMessage, AgentModelChanged, AgentThreadStatus, ModelsResponse, ToolChoice, AgentConnectionStatus, AgentClientToolCallRequested } from "./agent-messages.js";
4
4
  import type { AgentPayload, JsonMap, ClientToolkitDescription } from "./agent-messages.js";
5
5
  import { ChangeEmitter } from "./change-emitter.js";
6
6
  export declare class AgentMessageEvent {
@@ -90,6 +90,8 @@ export declare abstract class BaseChatClient extends ChangeEmitter {
90
90
  stop(): Promise<void>;
91
91
  agentParticipant(): RemoteParticipant | null;
92
92
  localParticipantName(): string | undefined;
93
+ localParticipantId(): string | undefined;
94
+ isClientToolCallForLocalParticipant(request: InstanceType<typeof AgentClientToolCallRequested>): boolean;
93
95
  protected cleanParticipantName(value: string | undefined): string | undefined;
94
96
  openThread(threadPath: string, { load, sinceTurn, reloadIfOpen, drainPendingEvents, }?: {
95
97
  load?: boolean;
@@ -131,7 +133,30 @@ export declare abstract class BaseChatClient extends ChangeEmitter {
131
133
  }): void;
132
134
  removeThreadSession(threadPath: string): void;
133
135
  }
134
- export declare class MessagingChatClient extends BaseChatClient {
136
+ export declare const messagingChatThreadSubscribeType = "meshagent.chat.thread.subscribe";
137
+ export declare const messagingChatThreadListSubscribeType = "meshagent.chat.thread_list.subscribe";
138
+ export declare class ThreadSubscribe {
139
+ readonly threadId: string;
140
+ readonly stream: MessagingStream;
141
+ constructor({ threadId, stream }: {
142
+ threadId: string;
143
+ stream: MessagingStream;
144
+ });
145
+ get closed(): boolean;
146
+ send(message: AgentMessage, { attachment }?: {
147
+ attachment?: Uint8Array;
148
+ }): Promise<void>;
149
+ close(): Promise<void>;
150
+ }
151
+ export declare class ThreadListSubscribe {
152
+ readonly stream: MessagingStream;
153
+ constructor({ stream }: {
154
+ stream: MessagingStream;
155
+ });
156
+ get closed(): boolean;
157
+ close(): Promise<void>;
158
+ }
159
+ export declare class BaseMessagingChatClient extends BaseChatClient {
135
160
  readonly room: RoomClient;
136
161
  readonly agentName?: string;
137
162
  private readonly pendingParticipantWaits;
@@ -146,6 +171,7 @@ export declare class MessagingChatClient extends BaseChatClient {
146
171
  agentName?: string;
147
172
  });
148
173
  localParticipantName(): string | undefined;
174
+ localParticipantId(): string | undefined;
149
175
  start(): Promise<void>;
150
176
  stop(): Promise<void>;
151
177
  private attachMessagingListeners;
@@ -164,6 +190,17 @@ export declare class MessagingChatClient extends BaseChatClient {
164
190
  private reopenOpenSessions;
165
191
  private readonly onMessagingMessage;
166
192
  }
193
+ export declare class MessagingChatClient extends BaseMessagingChatClient {
194
+ private readonly threadSubscriptions;
195
+ private threadListSubscription?;
196
+ private readonly streamTasks;
197
+ stop(): Promise<void>;
198
+ private supportsThreadSubscriptions;
199
+ private trackStream;
200
+ sendAgentMessage(message: AgentMessage, { attachment }?: {
201
+ attachment?: Uint8Array;
202
+ }): Promise<void>;
203
+ }
167
204
  export declare class ChatThreadSession extends ChangeEmitter {
168
205
  private readonly client;
169
206
  readonly threadPath: string;
@@ -171,6 +208,8 @@ export declare class ChatThreadSession extends ChangeEmitter {
171
208
  private readonly messageIndexes;
172
209
  private readonly localAgentMessageIds;
173
210
  private readonly pendingLocalInputMessageIds;
211
+ private readonly resolvedInputMessageIds;
212
+ private readonly completedTurnIds;
174
213
  private readonly mergedDeltaMessageIds;
175
214
  private readonly pendingInputsById;
176
215
  private openState;