@meshagent/meshagent-agents 0.43.1 → 0.43.3
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 +8 -0
- package/dist/browser/agent-messages.d.ts +1 -0
- package/dist/browser/agent-messages.js +11 -6
- package/dist/browser/chat-client.d.ts +33 -9
- package/dist/browser/chat-client.js +416 -84
- package/dist/esm/agent-messages.d.ts +1 -0
- package/dist/esm/agent-messages.js +11 -6
- package/dist/esm/chat-client.d.ts +33 -9
- package/dist/esm/chat-client.js +418 -86
- package/dist/node/agent-messages.d.ts +1 -0
- package/dist/node/agent-messages.js +11 -6
- package/dist/node/chat-client.d.ts +33 -9
- package/dist/node/chat-client.js +416 -84
- package/package.json +2 -2
|
@@ -170,6 +170,7 @@ export declare class AgentProviderInfo {
|
|
|
170
170
|
readonly name: string;
|
|
171
171
|
readonly friendlyName: string;
|
|
172
172
|
readonly description?: string;
|
|
173
|
+
readonly backend?: string;
|
|
173
174
|
readonly defaultModel: string;
|
|
174
175
|
readonly models: AgentModelInfo[];
|
|
175
176
|
constructor(params: JsonMap);
|
|
@@ -476,6 +476,7 @@ export class AgentProviderInfo {
|
|
|
476
476
|
this.name = String(params.name);
|
|
477
477
|
this.friendlyName = String(params.friendlyName ?? params.friendly_name);
|
|
478
478
|
this.description = stringOrNull(params.description);
|
|
479
|
+
this.backend = stringOrNull(params.backend);
|
|
479
480
|
this.defaultModel = String(params.defaultModel ?? params.default_model);
|
|
480
481
|
this.models = Array.isArray(params.models) ? params.models.map((entry) => entry instanceof AgentModelInfo ? entry : AgentModelInfo.fromJson(requiredObjectValue(entry))) : [];
|
|
481
482
|
}
|
|
@@ -487,6 +488,7 @@ export class AgentProviderInfo {
|
|
|
487
488
|
name: this.name,
|
|
488
489
|
friendly_name: this.friendlyName,
|
|
489
490
|
...(this.description != null ? { description: this.description } : {}),
|
|
491
|
+
...(this.backend != null ? { backend: this.backend } : {}),
|
|
490
492
|
default_model: this.defaultModel,
|
|
491
493
|
models: this.models.map((entry) => entry.toJson()),
|
|
492
494
|
};
|
|
@@ -608,11 +610,12 @@ export class AgentContextWindowUsage {
|
|
|
608
610
|
this.compactionThreshold = intOrNull(params.compactionThreshold ?? params.compaction_threshold);
|
|
609
611
|
}
|
|
610
612
|
static fromJson(json) {
|
|
613
|
+
const usedTokens = intOrNull(json.used_tokens ?? json.usedTokens) ?? 0;
|
|
611
614
|
return new AgentContextWindowUsage({
|
|
612
|
-
usedTokens
|
|
613
|
-
totalTokens: intOrNull(json.total_tokens),
|
|
614
|
-
compactionMode: stringOrNull(json.compaction_mode),
|
|
615
|
-
compactionThreshold: intOrNull(json.compaction_threshold),
|
|
615
|
+
usedTokens,
|
|
616
|
+
totalTokens: intOrNull(json.total_tokens ?? json.totalTokens),
|
|
617
|
+
compactionMode: stringOrNull(json.compaction_mode ?? json.compactionMode),
|
|
618
|
+
compactionThreshold: intOrNull(json.compaction_threshold ?? json.compactionThreshold),
|
|
616
619
|
});
|
|
617
620
|
}
|
|
618
621
|
toJson() {
|
|
@@ -852,6 +855,7 @@ const turnOptions = [
|
|
|
852
855
|
s("turnId"),
|
|
853
856
|
contentList("content"),
|
|
854
857
|
s("provider"),
|
|
858
|
+
s("backend"),
|
|
855
859
|
s("model"),
|
|
856
860
|
s("voice"),
|
|
857
861
|
sl("outputModalities"),
|
|
@@ -886,6 +890,7 @@ export const StartThread = makeMessageClass({
|
|
|
886
890
|
s("name"),
|
|
887
891
|
s("realtimeProtocol"),
|
|
888
892
|
s("provider"),
|
|
893
|
+
s("backend"),
|
|
889
894
|
s("model"),
|
|
890
895
|
s("voice"),
|
|
891
896
|
sl("outputModalities"),
|
|
@@ -917,8 +922,8 @@ export const CapabilitiesRequest = makeMessageClass({ type: agentCapabilitiesReq
|
|
|
917
922
|
export const CapabilitiesResponse = makeMessageClass({ type: agentCapabilitiesResponseType, base: "thread", fields: [s("sourceMessageId", "source_message_id", true), s("version", "version", true), objList("toolkits", "toolkits", ToolkitCapabilities.fromJson, true)] });
|
|
918
923
|
export const ModelsRequest = makeMessageClass({ type: agentModelsRequestType });
|
|
919
924
|
export const ModelsResponse = makeMessageClass({ type: agentModelsResponseType, fields: [s("sourceMessageId", "source_message_id", true), objList("providers", "providers", AgentProviderInfo.fromJson, true)] });
|
|
920
|
-
export const ChangeModel = makeMessageClass({ type: agentModelChangeType, base: "thread", fields: [s("provider"), s("model"), s("voice")] });
|
|
921
|
-
export const AgentModelChanged = makeMessageClass({ type: agentModelChangedType, base: "thread", fields: [s("sourceMessageId"), s("provider", "provider", true), s("model", "model", true), s("voice"), audioFormat("inputFormat"), audioFormat("outputFormat"), s("turnDetection"), sl("outputModalities", "output_modalities", ["text"], true), sl("realtimeProtocols", "realtime_protocols", [], true)] });
|
|
925
|
+
export const ChangeModel = makeMessageClass({ type: agentModelChangeType, base: "thread", fields: [s("backend"), s("provider"), s("model"), s("voice")] });
|
|
926
|
+
export const AgentModelChanged = makeMessageClass({ type: agentModelChangedType, base: "thread", fields: [s("sourceMessageId"), s("backend"), s("provider", "provider", true), s("model", "model", true), s("voice"), audioFormat("inputFormat"), audioFormat("outputFormat"), s("turnDetection"), sl("outputModalities", "output_modalities", ["text"], true), sl("realtimeProtocols", "realtime_protocols", [], true), { prop: "supportsAttachments", json: "supports_attachments", from: (value) => value === true, default: () => false }, sl("accepts", "accepts", [], true)] });
|
|
922
927
|
export const ThreadCleared = makeMessageClass({ type: agentThreadClearedType, base: "thread", fields: [s("sourceMessageId", "source_message_id", true)] });
|
|
923
928
|
export const TurnStartAccepted = makeMessageClass({ type: agentTurnStartAcceptedType, base: "thread", fields: [s("turnId"), s("sourceMessageId", "source_message_id", true), contentList("content")] });
|
|
924
929
|
export const TurnStartRejected = makeMessageClass({ type: agentTurnStartRejectedType, base: "thread", fields: [s("sourceMessageId", "source_message_id", true), obj("error", "error", AgentError.fromJson, true)] });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RemoteParticipant } from "@meshagent/meshagent";
|
|
2
2
|
import type { RoomClient, Content } from "@meshagent/meshagent";
|
|
3
|
-
import { AgentMessage, AgentConnectionStatus } from "./agent-messages.js";
|
|
3
|
+
import { AgentMessage, AgentModelChanged, AgentThreadStatus, ModelsResponse, AgentConnectionStatus } 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 {
|
|
@@ -78,6 +78,7 @@ export declare class ChatThreadStartResult {
|
|
|
78
78
|
export declare abstract class BaseChatClient extends ChangeEmitter {
|
|
79
79
|
private readonly sessionsByPath;
|
|
80
80
|
private readonly pendingStartRequests;
|
|
81
|
+
private readonly pendingSessionEventsByPath;
|
|
81
82
|
private readonly eventQueue;
|
|
82
83
|
private _connectionStatus?;
|
|
83
84
|
get events(): AsyncIterable<AgentMessageEvent>;
|
|
@@ -88,16 +89,19 @@ export declare abstract class BaseChatClient extends ChangeEmitter {
|
|
|
88
89
|
agentParticipant(): RemoteParticipant | null;
|
|
89
90
|
localParticipantName(): string | undefined;
|
|
90
91
|
protected cleanParticipantName(value: string | undefined): string | undefined;
|
|
91
|
-
openThread(threadPath: string, { load, sinceTurn, reloadIfOpen }?: {
|
|
92
|
+
openThread(threadPath: string, { load, sinceTurn, reloadIfOpen, drainPendingEvents, }?: {
|
|
92
93
|
load?: boolean;
|
|
93
94
|
sinceTurn?: string;
|
|
94
95
|
reloadIfOpen?: boolean;
|
|
96
|
+
drainPendingEvents?: boolean;
|
|
95
97
|
}): ChatThreadSession;
|
|
96
|
-
|
|
98
|
+
private openSession;
|
|
99
|
+
startThread({ messageId, message, attachments, name, backend, provider, model, voice, outputModalities, realtimeProtocol, senderName, clientToolkits, omitContent, }: {
|
|
97
100
|
messageId?: string;
|
|
98
101
|
message: string;
|
|
99
102
|
attachments: string[];
|
|
100
103
|
name?: string;
|
|
104
|
+
backend?: string;
|
|
101
105
|
provider?: string;
|
|
102
106
|
model?: string;
|
|
103
107
|
voice?: string;
|
|
@@ -111,6 +115,7 @@ export declare abstract class BaseChatClient extends ChangeEmitter {
|
|
|
111
115
|
attachment?: Uint8Array;
|
|
112
116
|
ignoreOffline?: boolean;
|
|
113
117
|
}): Promise<void>;
|
|
118
|
+
private drainPendingSessionEvents;
|
|
114
119
|
handleAgentMessage(message: AgentMessage, { attachment }?: {
|
|
115
120
|
attachment?: Uint8Array;
|
|
116
121
|
}): void;
|
|
@@ -126,9 +131,7 @@ export declare class MessagingChatClient extends BaseChatClient {
|
|
|
126
131
|
readonly room: RoomClient;
|
|
127
132
|
readonly agentName?: string;
|
|
128
133
|
private readonly pendingParticipantWaits;
|
|
129
|
-
private readonly roomAbortController;
|
|
130
134
|
private started;
|
|
131
|
-
private roomPump?;
|
|
132
135
|
constructor({ room, agentName }: {
|
|
133
136
|
room: RoomClient;
|
|
134
137
|
agentName?: string;
|
|
@@ -145,17 +148,24 @@ export declare class MessagingChatClient extends BaseChatClient {
|
|
|
145
148
|
ignoreOffline?: boolean;
|
|
146
149
|
}): Promise<void>;
|
|
147
150
|
private readonly onMessagingChanged;
|
|
148
|
-
private
|
|
149
|
-
private onRoomEvent;
|
|
151
|
+
private readonly onMessagingMessage;
|
|
150
152
|
}
|
|
151
153
|
export declare class ChatThreadSession extends ChangeEmitter {
|
|
152
154
|
private readonly client;
|
|
153
155
|
readonly threadPath: string;
|
|
154
156
|
private readonly _messages;
|
|
157
|
+
private readonly messageIndexes;
|
|
158
|
+
private readonly localAgentMessageIds;
|
|
159
|
+
private readonly pendingLocalInputMessageIds;
|
|
160
|
+
private readonly mergedDeltaMessageIds;
|
|
155
161
|
private readonly pendingInputsById;
|
|
156
162
|
private openState;
|
|
157
163
|
private loadStateValue;
|
|
158
164
|
private lastCompletedTurnIdValue?;
|
|
165
|
+
private activeTurnIdValue?;
|
|
166
|
+
private threadStatusValue?;
|
|
167
|
+
private currentModelValue?;
|
|
168
|
+
private modelsResponseValue?;
|
|
159
169
|
private lastAgentMessageType?;
|
|
160
170
|
private lastAgentMessageAt?;
|
|
161
171
|
constructor({ client, threadPath }: {
|
|
@@ -168,6 +178,10 @@ export declare class ChatThreadSession extends ChangeEmitter {
|
|
|
168
178
|
get loadState(): ChatThreadSessionLoadState;
|
|
169
179
|
get isLoading(): boolean;
|
|
170
180
|
get lastCompletedTurnId(): string | undefined;
|
|
181
|
+
get activeTurnId(): string | undefined;
|
|
182
|
+
get threadStatus(): InstanceType<typeof AgentThreadStatus> | undefined;
|
|
183
|
+
get currentModel(): InstanceType<typeof AgentModelChanged> | undefined;
|
|
184
|
+
get modelsResponse(): InstanceType<typeof ModelsResponse> | undefined;
|
|
171
185
|
open({ load, sinceTurn }?: {
|
|
172
186
|
load?: boolean;
|
|
173
187
|
sinceTurn?: string;
|
|
@@ -176,7 +190,8 @@ export declare class ChatThreadSession extends ChangeEmitter {
|
|
|
176
190
|
requestModels({ ignoreOffline }?: {
|
|
177
191
|
ignoreOffline?: boolean;
|
|
178
192
|
}): Promise<void>;
|
|
179
|
-
changeModel({ provider, model, voice }: {
|
|
193
|
+
changeModel({ backend, provider, model, voice }: {
|
|
194
|
+
backend?: string;
|
|
180
195
|
provider: string;
|
|
181
196
|
model: string;
|
|
182
197
|
voice?: string;
|
|
@@ -187,12 +202,13 @@ export declare class ChatThreadSession extends ChangeEmitter {
|
|
|
187
202
|
requestId: string;
|
|
188
203
|
response: Content;
|
|
189
204
|
}): Promise<void>;
|
|
190
|
-
sendText({ messageId, text, attachments, steer, turnId, provider, model, voice, outputModalities, senderName, clientToolkits, }: {
|
|
205
|
+
sendText({ messageId, text, attachments, steer, turnId, backend, provider, model, voice, outputModalities, senderName, clientToolkits, }: {
|
|
191
206
|
messageId?: string;
|
|
192
207
|
text: string;
|
|
193
208
|
attachments: string[];
|
|
194
209
|
steer?: boolean;
|
|
195
210
|
turnId?: string;
|
|
211
|
+
backend?: string;
|
|
196
212
|
provider?: string;
|
|
197
213
|
model?: string;
|
|
198
214
|
voice?: string;
|
|
@@ -214,6 +230,14 @@ export declare class ChatThreadSession extends ChangeEmitter {
|
|
|
214
230
|
deleteThread(threadPath: string): Promise<void>;
|
|
215
231
|
renameThread(threadPath: string, name: string): Promise<void>;
|
|
216
232
|
addAgentMessage(event: AgentMessageEvent): void;
|
|
233
|
+
private updateSessionState;
|
|
234
|
+
private updatePendingInputsForMessage;
|
|
235
|
+
private appendRenderableMessage;
|
|
236
|
+
private appendMessage;
|
|
237
|
+
private upsertItemMessage;
|
|
238
|
+
private appendOrMergeDelta;
|
|
239
|
+
private indexMessagesFrom;
|
|
240
|
+
private applyActiveModel;
|
|
217
241
|
markClosed({ notify }?: {
|
|
218
242
|
notify?: boolean;
|
|
219
243
|
}): void;
|