@meshagent/meshagent-agents 0.47.1 → 0.49.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 +18 -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 +93 -33
- package/dist/browser/chat-client.js +483 -206
- 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 +93 -33
- package/dist/esm/chat-client.js +478 -206
- 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 +93 -33
- package/dist/node/chat-client.js +483 -206
- 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,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
6
|
-
exports.AgentClientToolCallResponse = exports.AgentSecretResponse = exports.RejectAgentToolCall = exports.ApproveAgentToolCall = exports.AgentUsageUpdated = exports.AgentContextCompacted = exports.AgentAudioInputSpeechEnded = exports.AgentAudioInputSpeechStarted = exports.AgentAudioTranscriptionFailed = exports.AgentAudioTranscriptionCompleted = exports.AgentAudioTranscriptionDelta = exports.AgentAudioTranscriptionStarted = exports.AgentAudioGenerationFailed = exports.AgentAudioGenerationCompleted = exports.AgentAudioGenerationDelta = exports.AgentAudioGenerationStarted = exports.AgentImageGenerationFailed = exports.AgentImageGenerationCompleted = exports.AgentImageGenerationPartial = exports.AgentImageGenerationStarted = exports.AgentThreadEvent = exports.AgentConnectionStatus = exports.AgentThreadStatus = exports.AgentClientToolCallCancelled = exports.AgentClientToolCallRequested = exports.AgentSecretRequested = exports.AgentToolCallApprovalRequested = exports.AgentToolCallEnded = exports.AgentToolCallLogDelta = exports.AgentToolCallArgumentsDelta = exports.AgentToolCallStarted = exports.AgentToolCallInProgress = void 0;
|
|
3
|
+
exports.agentFileContentEndedType = exports.agentFileContentDeltaType = exports.agentFileContentStartedType = exports.agentTextContentEndedType = exports.agentTextContentDeltaType = exports.agentTextContentStartedType = exports.agentReasoningContentEndedType = exports.agentReasoningContentDeltaType = exports.agentReasoningContentStartedType = exports.agentTurnEndedType = exports.agentTurnStartedType = exports.agentTurnSteerRejectedType = exports.agentTurnSteeredType = exports.agentTurnSteerAcceptedType = exports.agentTurnInterruptedType = exports.agentTurnInterruptAcceptedType = exports.agentTurnStartRejectedType = exports.agentTurnStartAcceptedType = exports.agentThreadClearedType = exports.agentModelChangedType = exports.agentModelChangeType = exports.agentModelsResponseType = exports.agentModelsRequestType = exports.agentCapabilitiesResponseType = exports.agentCapabilitiesRequestType = exports.agentThreadDeletedType = exports.agentThreadUpdatedType = exports.agentThreadCreatedType = exports.agentThreadListedType = exports.agentThreadUnwatchType = exports.agentThreadWatchType = exports.agentThreadListType = exports.agentThreadRenameType = exports.agentThreadDeleteType = exports.agentParticipantDisconnectType = exports.agentParticipantConnectType = exports.agentMessagesInjectType = exports.agentThreadCloseType = exports.agentThreadOpenType = exports.agentThreadStartRejectedType = exports.agentThreadLoadedType = exports.agentThreadStartedType = exports.agentThreadStartType = exports.agentRealtimeAudioCommitType = exports.agentRealtimeAudioChunkType = exports.agentThreadClearType = exports.agentTurnInterruptType = exports.agentTurnSteerType = exports.agentTurnStartType = exports.agentRoomMessageType = void 0;
|
|
4
|
+
exports.AgentContextWindowUsage = exports.AgentGeneratedAudio = exports.AgentGeneratedImage = exports.AgentToolCallLogLine = exports.AgentRealtimeConnectionInfo = exports.AgentThreadListEntry = exports.AgentProviderInfo = exports.AgentModelInfo = exports.ToolkitCapabilities = exports.ToolkitToolCapabilities = exports.AgentError = exports.AgentAudioFormat = exports.TurnToolkitConfig = exports.ClientToolkitDescription = exports.TurnMcpConfig = exports.ToolChoice = exports.AgentFileContent = exports.agentClientToolCallResponseType = exports.agentSecretResponseType = exports.agentToolRejectType = exports.agentToolApproveType = exports.agentUsageUpdatedType = exports.agentContextCompactedType = exports.agentAudioInputSpeechEndedType = exports.agentAudioInputSpeechStartedType = exports.agentAudioTranscriptionFailedType = exports.agentAudioTranscriptionCompletedType = exports.agentAudioTranscriptionDeltaType = exports.agentAudioTranscriptionStartedType = exports.agentAudioGenerationFailedType = exports.agentAudioGenerationCompletedType = exports.agentAudioGenerationDeltaType = exports.agentAudioGenerationStartedType = exports.agentImageGenerationFailedType = exports.agentImageGenerationCompletedType = exports.agentImageGenerationPartialType = exports.agentImageGenerationStartedType = exports.agentThreadEventType = exports.agentConnectionStatusType = exports.agentThreadStatusType = exports.agentSecretRequestedType = exports.agentClientToolCallCancelledType = exports.agentClientToolCallRequestedType = exports.agentToolCallApprovalRequestedType = exports.agentToolCallEndedType = exports.agentToolCallLogDeltaType = exports.agentToolCallArgumentsDeltaType = exports.agentToolCallStartedType = exports.agentToolCallInProgressType = exports.agentToolCallPendingType = void 0;
|
|
5
|
+
exports.AgentFileContentStarted = exports.AgentTextContentEnded = exports.AgentTextContentDelta = exports.AgentTextContentStarted = exports.AgentReasoningContentEnded = exports.AgentReasoningContentDelta = exports.AgentReasoningContentStarted = exports.ThreadStartRejected = exports.ThreadLoaded = exports.ThreadStarted = exports.TurnEnded = exports.TurnStarted = exports.TurnSteerRejected = exports.TurnSteered = exports.TurnSteerAccepted = exports.TurnInterrupted = exports.TurnInterruptAccepted = exports.TurnStartRejected = exports.TurnStartAccepted = exports.ThreadCleared = exports.AgentModelChanged = exports.ChangeModel = exports.ModelsResponse = exports.ModelsRequest = exports.CapabilitiesResponse = exports.CapabilitiesRequest = exports.ThreadDeleted = exports.ThreadUpdated = exports.ThreadCreated = exports.ThreadsListed = exports.UnwatchThreads = exports.WatchThreads = exports.ListThreads = exports.RenameThread = exports.DeleteThread = exports.ParticipantDisconnect = exports.ParticipantConnect = exports.InjectMessages = exports.CloseThread = exports.OpenThread = exports.ClearThread = exports.AgentRealtimeAudioCommit = exports.AgentRealtimeAudioChunk = exports.TurnInterrupt = exports.TurnSteer = exports.TurnStart = exports.StartThread = exports.AgentLLMMessage = exports.AgentThreadMessage = exports.AgentMessage = void 0;
|
|
6
|
+
exports.AgentClientToolCallResponse = exports.AgentSecretResponse = exports.RejectAgentToolCall = exports.ApproveAgentToolCall = exports.AgentUsageUpdated = exports.AgentContextCompacted = exports.AgentAudioInputSpeechEnded = exports.AgentAudioInputSpeechStarted = exports.AgentAudioTranscriptionFailed = exports.AgentAudioTranscriptionCompleted = exports.AgentAudioTranscriptionDelta = exports.AgentAudioTranscriptionStarted = exports.AgentAudioGenerationFailed = exports.AgentAudioGenerationCompleted = exports.AgentAudioGenerationDelta = exports.AgentAudioGenerationStarted = exports.AgentImageGenerationFailed = exports.AgentImageGenerationCompleted = exports.AgentImageGenerationPartial = exports.AgentImageGenerationStarted = exports.AgentThreadEvent = exports.AgentConnectionStatus = exports.AgentThreadStatus = exports.AgentClientToolCallCancelled = exports.AgentClientToolCallRequested = exports.AgentSecretRequested = exports.AgentToolCallApprovalRequested = exports.AgentToolCallEnded = exports.AgentToolCallLogDelta = exports.AgentToolCallArgumentsDelta = exports.AgentToolCallStarted = exports.AgentToolCallInProgress = exports.AgentToolCallPending = exports.AgentFileContentEnded = exports.AgentFileContentDelta = void 0;
|
|
7
7
|
exports.agentInputContent = agentInputContent;
|
|
8
8
|
const meshagent_1 = require("@meshagent/meshagent");
|
|
9
9
|
const uuid_1 = require("uuid");
|
|
@@ -20,6 +20,7 @@ exports.agentThreadLoadedType = "meshagent.agent.thread.loaded";
|
|
|
20
20
|
exports.agentThreadStartRejectedType = "meshagent.agent.thread.start.rejected";
|
|
21
21
|
exports.agentThreadOpenType = "meshagent.agent.thread.open";
|
|
22
22
|
exports.agentThreadCloseType = "meshagent.agent.thread.close";
|
|
23
|
+
exports.agentMessagesInjectType = "meshagent.agent.messages.inject";
|
|
23
24
|
exports.agentParticipantConnectType = "meshagent.agent.participant.connect";
|
|
24
25
|
exports.agentParticipantDisconnectType = "meshagent.agent.participant.disconnect";
|
|
25
26
|
exports.agentThreadDeleteType = "meshagent.agent.thread.delete";
|
|
@@ -89,6 +90,34 @@ exports.agentToolApproveType = "meshagent.agent.tool_call.approve";
|
|
|
89
90
|
exports.agentToolRejectType = "meshagent.agent.tool_call.reject";
|
|
90
91
|
exports.agentSecretResponseType = "meshagent.agent.secret.response";
|
|
91
92
|
exports.agentClientToolCallResponseType = "meshagent.agent.client_tool_call.response";
|
|
93
|
+
class AgentFileContent {
|
|
94
|
+
constructor({ url, name }) {
|
|
95
|
+
this.type = "file";
|
|
96
|
+
this.url = url;
|
|
97
|
+
this.name = name;
|
|
98
|
+
}
|
|
99
|
+
static fromJson(json) {
|
|
100
|
+
return new AgentFileContent({
|
|
101
|
+
url: requiredString(json, "url"),
|
|
102
|
+
name: stringOrNull(json.name),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
toJson() {
|
|
106
|
+
return {
|
|
107
|
+
type: this.type,
|
|
108
|
+
url: this.url,
|
|
109
|
+
...(this.name != null ? { name: this.name } : {}),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
formatWith(values) {
|
|
113
|
+
const format = (value) => value.replace(/\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (token, key) => values[key] ?? token);
|
|
114
|
+
return new AgentFileContent({
|
|
115
|
+
url: format(this.url),
|
|
116
|
+
name: this.name == null ? undefined : format(this.name),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.AgentFileContent = AgentFileContent;
|
|
92
121
|
const globalScope = globalThis;
|
|
93
122
|
function hasOwn(value, key) {
|
|
94
123
|
return Object.prototype.hasOwnProperty.call(value, key);
|
|
@@ -136,13 +165,6 @@ function requiredString(json, key) {
|
|
|
136
165
|
}
|
|
137
166
|
throw new TypeError(`missing string field '${key}'`);
|
|
138
167
|
}
|
|
139
|
-
function requiredInt(json, key) {
|
|
140
|
-
const value = intOrNull(json[key]);
|
|
141
|
-
if (value !== undefined) {
|
|
142
|
-
return value;
|
|
143
|
-
}
|
|
144
|
-
throw new TypeError(`missing integer field '${key}'`);
|
|
145
|
-
}
|
|
146
168
|
function requiredMap(json, key) {
|
|
147
169
|
const value = dynamicMapOrNull(json[key]);
|
|
148
170
|
if (value != null) {
|
|
@@ -223,7 +245,7 @@ function inputContentFromJson(value) {
|
|
|
223
245
|
return { type: "text", text: requiredString(json, "text") };
|
|
224
246
|
}
|
|
225
247
|
if (json.type === "file") {
|
|
226
|
-
return
|
|
248
|
+
return AgentFileContent.fromJson(json);
|
|
227
249
|
}
|
|
228
250
|
throw new TypeError("unsupported agent input content type");
|
|
229
251
|
}
|
|
@@ -240,7 +262,17 @@ function objectList(value, fromJson) {
|
|
|
240
262
|
if (!Array.isArray(value)) {
|
|
241
263
|
return [];
|
|
242
264
|
}
|
|
243
|
-
return value.map((entry) =>
|
|
265
|
+
return value.map((entry) => (entry != null && typeof entry === "object" && typeof entry.toJson === "function"
|
|
266
|
+
? entry
|
|
267
|
+
: fromJson(requiredObjectValue(entry))));
|
|
268
|
+
}
|
|
269
|
+
function agentMessageList(value) {
|
|
270
|
+
if (!Array.isArray(value)) {
|
|
271
|
+
return [];
|
|
272
|
+
}
|
|
273
|
+
return value.map((entry) => (entry instanceof AgentMessage
|
|
274
|
+
? entry
|
|
275
|
+
: AgentMessage.fromJson(requiredObjectValue(entry))));
|
|
244
276
|
}
|
|
245
277
|
function mapListOrNull(value) {
|
|
246
278
|
if (!Array.isArray(value)) {
|
|
@@ -279,16 +311,19 @@ function maybeToJson(value) {
|
|
|
279
311
|
return value != null && typeof value.toJson === "function" ? value.toJson() : value;
|
|
280
312
|
}
|
|
281
313
|
function contentToJson(value) {
|
|
282
|
-
return { ...value };
|
|
314
|
+
return value instanceof AgentFileContent ? value.toJson() : { ...value };
|
|
283
315
|
}
|
|
284
316
|
function objectOrNull(value, fromJson) {
|
|
317
|
+
if (value != null && typeof value === "object" && typeof value.toJson === "function") {
|
|
318
|
+
return value;
|
|
319
|
+
}
|
|
285
320
|
const map = dynamicMapOrNull(value);
|
|
286
321
|
return map == null ? undefined : fromJson(map);
|
|
287
322
|
}
|
|
288
323
|
class ToolChoice {
|
|
289
|
-
constructor({ toolkitName, toolName
|
|
290
|
-
this.toolkitName =
|
|
291
|
-
this.toolName =
|
|
324
|
+
constructor({ toolkitName, toolName }) {
|
|
325
|
+
this.toolkitName = toolkitName;
|
|
326
|
+
this.toolName = toolName;
|
|
292
327
|
}
|
|
293
328
|
static fromJson(json) {
|
|
294
329
|
return new ToolChoice({ toolkitName: requiredString(json, "toolkit_name"), toolName: requiredString(json, "tool_name") });
|
|
@@ -300,7 +335,7 @@ class ToolChoice {
|
|
|
300
335
|
exports.ToolChoice = ToolChoice;
|
|
301
336
|
class TurnMcpConfig {
|
|
302
337
|
constructor({ servers = [] } = {}) {
|
|
303
|
-
this.servers =
|
|
338
|
+
this.servers = servers;
|
|
304
339
|
}
|
|
305
340
|
static fromJson(json) {
|
|
306
341
|
return new TurnMcpConfig({ servers: mapListOrNull(json.servers) ?? [] });
|
|
@@ -311,18 +346,18 @@ class TurnMcpConfig {
|
|
|
311
346
|
}
|
|
312
347
|
exports.TurnMcpConfig = TurnMcpConfig;
|
|
313
348
|
class ClientToolkitDescription {
|
|
314
|
-
constructor({ name, title, description, inputSchema
|
|
315
|
-
this.name =
|
|
316
|
-
this.title =
|
|
317
|
-
this.description =
|
|
318
|
-
this.inputSchema =
|
|
349
|
+
constructor({ name, title, description, inputSchema }) {
|
|
350
|
+
this.name = name;
|
|
351
|
+
this.title = title;
|
|
352
|
+
this.description = description;
|
|
353
|
+
this.inputSchema = inputSchema;
|
|
319
354
|
}
|
|
320
355
|
static fromJson(json) {
|
|
321
356
|
return new ClientToolkitDescription({
|
|
322
357
|
name: requiredString(json, "name"),
|
|
323
358
|
title: stringOrNull(json.title),
|
|
324
359
|
description: stringOrNull(json.description),
|
|
325
|
-
inputSchema:
|
|
360
|
+
inputSchema: requiredMap(json, "input_schema"),
|
|
326
361
|
});
|
|
327
362
|
}
|
|
328
363
|
toJson() {
|
|
@@ -336,8 +371,8 @@ class ClientToolkitDescription {
|
|
|
336
371
|
}
|
|
337
372
|
exports.ClientToolkitDescription = ClientToolkitDescription;
|
|
338
373
|
class TurnToolkitConfig {
|
|
339
|
-
constructor({ clientOptions
|
|
340
|
-
this.clientOptions =
|
|
374
|
+
constructor({ clientOptions } = {}) {
|
|
375
|
+
this.clientOptions = clientOptions;
|
|
341
376
|
}
|
|
342
377
|
static fromJson(json) {
|
|
343
378
|
return new TurnToolkitConfig({ clientOptions: dynamicMapOrNull(json.client_options) });
|
|
@@ -361,15 +396,15 @@ function turnMcpConfigOrNull(value) {
|
|
|
361
396
|
return objectOrNull(value, TurnMcpConfig.fromJson);
|
|
362
397
|
}
|
|
363
398
|
class AgentAudioFormat {
|
|
364
|
-
constructor({ type = "audio/pcm", sampleRate
|
|
365
|
-
this.type =
|
|
366
|
-
this.sampleRate =
|
|
367
|
-
this.bitrate =
|
|
399
|
+
constructor({ type = "audio/pcm", sampleRate = 24000, bitrate } = {}) {
|
|
400
|
+
this.type = type;
|
|
401
|
+
this.sampleRate = sampleRate ?? undefined;
|
|
402
|
+
this.bitrate = bitrate;
|
|
368
403
|
}
|
|
369
404
|
static fromJson(json) {
|
|
370
405
|
return new AgentAudioFormat({
|
|
371
406
|
type: stringOrNull(json.type) ?? "audio/pcm",
|
|
372
|
-
sampleRate: intOrNull(json.sample_rate),
|
|
407
|
+
sampleRate: intOrNull(json.sample_rate) ?? null,
|
|
373
408
|
bitrate: intOrNull(json.bitrate),
|
|
374
409
|
});
|
|
375
410
|
}
|
|
@@ -403,9 +438,9 @@ class AgentError {
|
|
|
403
438
|
exports.AgentError = AgentError;
|
|
404
439
|
class ToolkitToolCapabilities {
|
|
405
440
|
constructor({ name, title, description }) {
|
|
406
|
-
this.name =
|
|
407
|
-
this.title =
|
|
408
|
-
this.description =
|
|
441
|
+
this.name = name;
|
|
442
|
+
this.title = title;
|
|
443
|
+
this.description = description;
|
|
409
444
|
}
|
|
410
445
|
static fromJson(json) {
|
|
411
446
|
return new ToolkitToolCapabilities({
|
|
@@ -424,25 +459,31 @@ class ToolkitToolCapabilities {
|
|
|
424
459
|
}
|
|
425
460
|
exports.ToolkitToolCapabilities = ToolkitToolCapabilities;
|
|
426
461
|
class ToolkitCapabilities {
|
|
427
|
-
constructor(
|
|
428
|
-
this.name =
|
|
429
|
-
this.title =
|
|
430
|
-
this.description =
|
|
431
|
-
this.
|
|
432
|
-
this.
|
|
433
|
-
this.
|
|
434
|
-
this.
|
|
435
|
-
this.tools = Array.isArray(params.tools) ? params.tools.map((entry) => entry instanceof ToolkitToolCapabilities ? entry : ToolkitToolCapabilities.fromJson(requiredObjectValue(entry))) : [];
|
|
462
|
+
constructor({ name, title, description, rules = [], clientOptions, hidden = false, tools = [] }) {
|
|
463
|
+
this.name = name;
|
|
464
|
+
this.title = title;
|
|
465
|
+
this.description = description;
|
|
466
|
+
this.rules = rules;
|
|
467
|
+
this.clientOptions = clientOptions;
|
|
468
|
+
this.hidden = hidden;
|
|
469
|
+
this.tools = tools;
|
|
436
470
|
}
|
|
437
471
|
static fromJson(json) {
|
|
438
|
-
return new ToolkitCapabilities(
|
|
472
|
+
return new ToolkitCapabilities({
|
|
473
|
+
name: requiredString(json, "name"),
|
|
474
|
+
title: stringOrNull(json.title),
|
|
475
|
+
description: stringOrNull(json.description),
|
|
476
|
+
rules: stringList(json.rules),
|
|
477
|
+
clientOptions: dynamicMapOrNull(json.client_options),
|
|
478
|
+
hidden: json.hidden === true,
|
|
479
|
+
tools: objectList(json.tools, ToolkitToolCapabilities.fromJson),
|
|
480
|
+
});
|
|
439
481
|
}
|
|
440
482
|
toJson() {
|
|
441
483
|
return {
|
|
442
484
|
name: this.name,
|
|
443
485
|
...(this.title != null ? { title: this.title } : {}),
|
|
444
486
|
...(this.description != null ? { description: this.description } : {}),
|
|
445
|
-
...(this.thumbnailUrl != null ? { thumbnail_url: this.thumbnailUrl } : {}),
|
|
446
487
|
rules: this.rules,
|
|
447
488
|
...(this.clientOptions != null ? { client_options: this.clientOptions } : {}),
|
|
448
489
|
hidden: this.hidden,
|
|
@@ -452,23 +493,41 @@ class ToolkitCapabilities {
|
|
|
452
493
|
}
|
|
453
494
|
exports.ToolkitCapabilities = ToolkitCapabilities;
|
|
454
495
|
class AgentModelInfo {
|
|
455
|
-
constructor(
|
|
456
|
-
this.name =
|
|
457
|
-
this.friendlyName =
|
|
458
|
-
this.description =
|
|
459
|
-
this.contextWindow =
|
|
460
|
-
this.pricing =
|
|
461
|
-
this.modalities =
|
|
462
|
-
this.availableVoices =
|
|
463
|
-
this.defaultOutputVoice =
|
|
464
|
-
this.inputFormat =
|
|
465
|
-
this.outputFormat =
|
|
466
|
-
this.turnDetection =
|
|
467
|
-
this.realtimeProtocols =
|
|
468
|
-
this.
|
|
496
|
+
constructor({ name, friendlyName, description, contextWindow, pricing, modalities = ["text"], availableVoices = [], defaultOutputVoice, inputFormat, outputFormat, turnDetection, realtimeProtocols = [], supportsAttachments = false, accepts = [], active = false }) {
|
|
497
|
+
this.name = name;
|
|
498
|
+
this.friendlyName = friendlyName;
|
|
499
|
+
this.description = description;
|
|
500
|
+
this.contextWindow = contextWindow;
|
|
501
|
+
this.pricing = pricing;
|
|
502
|
+
this.modalities = modalities;
|
|
503
|
+
this.availableVoices = availableVoices;
|
|
504
|
+
this.defaultOutputVoice = defaultOutputVoice;
|
|
505
|
+
this.inputFormat = inputFormat;
|
|
506
|
+
this.outputFormat = outputFormat;
|
|
507
|
+
this.turnDetection = turnDetection;
|
|
508
|
+
this.realtimeProtocols = realtimeProtocols;
|
|
509
|
+
this.supportsAttachments = supportsAttachments;
|
|
510
|
+
this.accepts = accepts;
|
|
511
|
+
this.active = active;
|
|
469
512
|
}
|
|
470
513
|
static fromJson(json) {
|
|
471
|
-
return new AgentModelInfo(
|
|
514
|
+
return new AgentModelInfo({
|
|
515
|
+
name: requiredString(json, "name"),
|
|
516
|
+
friendlyName: stringOrNull(json.friendly_name),
|
|
517
|
+
description: stringOrNull(json.description),
|
|
518
|
+
contextWindow: intOrNull(json.context_window),
|
|
519
|
+
pricing: doubleMapOrNull(json.pricing),
|
|
520
|
+
modalities: stringList(json.modalities, ["text"]),
|
|
521
|
+
availableVoices: stringList(json.available_voices),
|
|
522
|
+
defaultOutputVoice: stringOrNull(json.default_output_voice),
|
|
523
|
+
inputFormat: audioFormatOrNull(json.input_format),
|
|
524
|
+
outputFormat: audioFormatOrNull(json.output_format),
|
|
525
|
+
turnDetection: stringOrNull(json.turn_detection),
|
|
526
|
+
realtimeProtocols: stringList(json.realtime_protocols),
|
|
527
|
+
supportsAttachments: json.supports_attachments === true,
|
|
528
|
+
accepts: stringList(json.accepts),
|
|
529
|
+
active: json.active === true,
|
|
530
|
+
});
|
|
472
531
|
}
|
|
473
532
|
toJson() {
|
|
474
533
|
return {
|
|
@@ -484,22 +543,31 @@ class AgentModelInfo {
|
|
|
484
543
|
...(this.outputFormat != null ? { output_format: this.outputFormat.toJson() } : {}),
|
|
485
544
|
...(this.turnDetection != null ? { turn_detection: this.turnDetection } : {}),
|
|
486
545
|
realtime_protocols: this.realtimeProtocols,
|
|
546
|
+
supports_attachments: this.supportsAttachments,
|
|
547
|
+
accepts: this.accepts,
|
|
487
548
|
active: this.active,
|
|
488
549
|
};
|
|
489
550
|
}
|
|
490
551
|
}
|
|
491
552
|
exports.AgentModelInfo = AgentModelInfo;
|
|
492
553
|
class AgentProviderInfo {
|
|
493
|
-
constructor(
|
|
494
|
-
this.name =
|
|
495
|
-
this.friendlyName =
|
|
496
|
-
this.description =
|
|
497
|
-
this.backend =
|
|
498
|
-
this.defaultModel =
|
|
499
|
-
this.models =
|
|
554
|
+
constructor({ name, friendlyName, description, backend, defaultModel, models = [] }) {
|
|
555
|
+
this.name = name;
|
|
556
|
+
this.friendlyName = friendlyName;
|
|
557
|
+
this.description = description;
|
|
558
|
+
this.backend = backend;
|
|
559
|
+
this.defaultModel = defaultModel;
|
|
560
|
+
this.models = models;
|
|
500
561
|
}
|
|
501
562
|
static fromJson(json) {
|
|
502
|
-
return new AgentProviderInfo(
|
|
563
|
+
return new AgentProviderInfo({
|
|
564
|
+
name: requiredString(json, "name"),
|
|
565
|
+
friendlyName: requiredString(json, "friendly_name"),
|
|
566
|
+
description: stringOrNull(json.description),
|
|
567
|
+
backend: stringOrNull(json.backend),
|
|
568
|
+
defaultModel: requiredString(json, "default_model"),
|
|
569
|
+
models: objectList(json.models, AgentModelInfo.fromJson),
|
|
570
|
+
});
|
|
503
571
|
}
|
|
504
572
|
toJson() {
|
|
505
573
|
return {
|
|
@@ -514,16 +582,16 @@ class AgentProviderInfo {
|
|
|
514
582
|
}
|
|
515
583
|
exports.AgentProviderInfo = AgentProviderInfo;
|
|
516
584
|
class AgentThreadListEntry {
|
|
517
|
-
constructor(
|
|
518
|
-
this.path =
|
|
519
|
-
this.name =
|
|
520
|
-
this.createdAt =
|
|
521
|
-
this.modifiedAt =
|
|
585
|
+
constructor({ path, name, createdAt, modifiedAt }) {
|
|
586
|
+
this.path = path;
|
|
587
|
+
this.name = name;
|
|
588
|
+
this.createdAt = createdAt;
|
|
589
|
+
this.modifiedAt = modifiedAt;
|
|
522
590
|
}
|
|
523
591
|
static fromJson(json) {
|
|
524
592
|
return new AgentThreadListEntry({
|
|
525
593
|
path: requiredString(json, "path"),
|
|
526
|
-
name:
|
|
594
|
+
name: requiredString(json, "name"),
|
|
527
595
|
createdAt: stringOrNull(json.created_at) ?? "",
|
|
528
596
|
modifiedAt: stringOrNull(json.modified_at) ?? "",
|
|
529
597
|
});
|
|
@@ -539,11 +607,11 @@ class AgentThreadListEntry {
|
|
|
539
607
|
}
|
|
540
608
|
exports.AgentThreadListEntry = AgentThreadListEntry;
|
|
541
609
|
class AgentRealtimeConnectionInfo {
|
|
542
|
-
constructor(
|
|
543
|
-
this.protocol =
|
|
544
|
-
this.url =
|
|
545
|
-
this.headers =
|
|
546
|
-
this.webOnlyProtocol =
|
|
610
|
+
constructor({ protocol, url, headers = {}, webOnlyProtocol }) {
|
|
611
|
+
this.protocol = protocol;
|
|
612
|
+
this.url = url;
|
|
613
|
+
this.headers = headers;
|
|
614
|
+
this.webOnlyProtocol = webOnlyProtocol;
|
|
547
615
|
}
|
|
548
616
|
static fromJson(json) {
|
|
549
617
|
return new AgentRealtimeConnectionInfo({
|
|
@@ -565,8 +633,8 @@ class AgentRealtimeConnectionInfo {
|
|
|
565
633
|
exports.AgentRealtimeConnectionInfo = AgentRealtimeConnectionInfo;
|
|
566
634
|
class AgentToolCallLogLine {
|
|
567
635
|
constructor({ source, text }) {
|
|
568
|
-
this.source =
|
|
569
|
-
this.text =
|
|
636
|
+
this.source = source;
|
|
637
|
+
this.text = text;
|
|
570
638
|
}
|
|
571
639
|
static fromJson(json) {
|
|
572
640
|
return new AgentToolCallLogLine({ source: requiredString(json, "source"), text: requiredString(json, "text") });
|
|
@@ -577,17 +645,25 @@ class AgentToolCallLogLine {
|
|
|
577
645
|
}
|
|
578
646
|
exports.AgentToolCallLogLine = AgentToolCallLogLine;
|
|
579
647
|
class AgentGeneratedImage {
|
|
580
|
-
constructor(
|
|
581
|
-
this.uri =
|
|
582
|
-
this.mimeType =
|
|
583
|
-
this.createdAt =
|
|
584
|
-
this.createdBy =
|
|
585
|
-
this.width =
|
|
586
|
-
this.height =
|
|
587
|
-
this.status =
|
|
648
|
+
constructor({ uri, mimeType, createdAt, createdBy, width, height, status } = {}) {
|
|
649
|
+
this.uri = uri;
|
|
650
|
+
this.mimeType = mimeType;
|
|
651
|
+
this.createdAt = createdAt;
|
|
652
|
+
this.createdBy = createdBy;
|
|
653
|
+
this.width = width;
|
|
654
|
+
this.height = height;
|
|
655
|
+
this.status = status;
|
|
588
656
|
}
|
|
589
657
|
static fromJson(json) {
|
|
590
|
-
return new AgentGeneratedImage(
|
|
658
|
+
return new AgentGeneratedImage({
|
|
659
|
+
uri: stringOrNull(json.uri),
|
|
660
|
+
mimeType: stringOrNull(json.mime_type),
|
|
661
|
+
createdAt: stringOrNull(json.created_at),
|
|
662
|
+
createdBy: stringOrNull(json.created_by),
|
|
663
|
+
width: numOrNull(json.width),
|
|
664
|
+
height: numOrNull(json.height),
|
|
665
|
+
status: stringOrNull(json.status),
|
|
666
|
+
});
|
|
591
667
|
}
|
|
592
668
|
toJson() {
|
|
593
669
|
return omitUndefined({
|
|
@@ -603,16 +679,23 @@ class AgentGeneratedImage {
|
|
|
603
679
|
}
|
|
604
680
|
exports.AgentGeneratedImage = AgentGeneratedImage;
|
|
605
681
|
class AgentGeneratedAudio {
|
|
606
|
-
constructor(
|
|
607
|
-
this.uri =
|
|
608
|
-
this.mimeType =
|
|
609
|
-
this.createdAt =
|
|
610
|
-
this.createdBy =
|
|
611
|
-
this.status =
|
|
612
|
-
this.transcript =
|
|
682
|
+
constructor({ uri, mimeType, createdAt, createdBy, status, transcript } = {}) {
|
|
683
|
+
this.uri = uri;
|
|
684
|
+
this.mimeType = mimeType;
|
|
685
|
+
this.createdAt = createdAt;
|
|
686
|
+
this.createdBy = createdBy;
|
|
687
|
+
this.status = status;
|
|
688
|
+
this.transcript = transcript;
|
|
613
689
|
}
|
|
614
690
|
static fromJson(json) {
|
|
615
|
-
return new AgentGeneratedAudio(
|
|
691
|
+
return new AgentGeneratedAudio({
|
|
692
|
+
uri: stringOrNull(json.uri),
|
|
693
|
+
mimeType: stringOrNull(json.mime_type),
|
|
694
|
+
createdAt: stringOrNull(json.created_at),
|
|
695
|
+
createdBy: stringOrNull(json.created_by),
|
|
696
|
+
status: stringOrNull(json.status),
|
|
697
|
+
transcript: stringOrNull(json.transcript),
|
|
698
|
+
});
|
|
616
699
|
}
|
|
617
700
|
toJson() {
|
|
618
701
|
return omitUndefined({
|
|
@@ -627,11 +710,11 @@ class AgentGeneratedAudio {
|
|
|
627
710
|
}
|
|
628
711
|
exports.AgentGeneratedAudio = AgentGeneratedAudio;
|
|
629
712
|
class AgentContextWindowUsage {
|
|
630
|
-
constructor(
|
|
631
|
-
this.usedTokens =
|
|
632
|
-
this.totalTokens =
|
|
633
|
-
this.compactionMode =
|
|
634
|
-
this.compactionThreshold =
|
|
713
|
+
constructor({ usedTokens, totalTokens, compactionMode, compactionThreshold }) {
|
|
714
|
+
this.usedTokens = usedTokens;
|
|
715
|
+
this.totalTokens = totalTokens;
|
|
716
|
+
this.compactionMode = compactionMode;
|
|
717
|
+
this.compactionThreshold = compactionThreshold;
|
|
635
718
|
}
|
|
636
719
|
static fromJson(json) {
|
|
637
720
|
const usedTokens = intOrNull(json.used_tokens ?? json.usedTokens) ?? 0;
|
|
@@ -661,19 +744,22 @@ class AgentMessage {
|
|
|
661
744
|
const resolvedMessageId = stringOrNull(messageId ?? message_id)?.trim();
|
|
662
745
|
this.messageId = resolvedMessageId == null || resolvedMessageId.length === 0 ? (0, uuid_1.v4)() : resolvedMessageId;
|
|
663
746
|
this.senderName = stringOrNull(senderName ?? sender_name);
|
|
664
|
-
|
|
747
|
+
const createdAtValue = createdAt ?? created_at;
|
|
748
|
+
const parsedCreatedAt = createdAtValue instanceof Date ? createdAtValue : new Date(String(createdAtValue ?? ""));
|
|
749
|
+
this.createdAtUtc = Number.isNaN(parsedCreatedAt.getTime()) ? new Date() : parsedCreatedAt;
|
|
665
750
|
this.metadata = dynamicMapOrNull(metadata) ?? {};
|
|
666
751
|
}
|
|
667
752
|
toJson() {
|
|
668
753
|
return {
|
|
669
754
|
type: this.type,
|
|
670
755
|
message_id: this.messageId,
|
|
671
|
-
created_at: this.
|
|
756
|
+
created_at: this.createdAtUtc.toISOString(),
|
|
672
757
|
...(Object.keys(this.metadata).length > 0 ? { metadata: this.metadata } : {}),
|
|
673
758
|
...(this.senderName != null ? { sender_name: this.senderName } : {}),
|
|
674
759
|
};
|
|
675
760
|
}
|
|
676
761
|
static fromJson(json) {
|
|
762
|
+
json = normalizeAgentMessageJson(json);
|
|
677
763
|
const type = json.type;
|
|
678
764
|
if (typeof type !== "string" || type.trim() === "") {
|
|
679
765
|
throw new TypeError("missing string field 'type'");
|
|
@@ -716,9 +802,55 @@ function register(type, ctor) {
|
|
|
716
802
|
messageConstructors[type] = ctor;
|
|
717
803
|
return ctor;
|
|
718
804
|
}
|
|
719
|
-
|
|
805
|
+
const agentMessageTypesWithRequiredItemId = new Set([
|
|
806
|
+
exports.agentReasoningContentStartedType,
|
|
807
|
+
exports.agentReasoningContentDeltaType,
|
|
808
|
+
exports.agentReasoningContentEndedType,
|
|
809
|
+
exports.agentTextContentStartedType,
|
|
810
|
+
exports.agentTextContentDeltaType,
|
|
811
|
+
exports.agentTextContentEndedType,
|
|
812
|
+
exports.agentFileContentStartedType,
|
|
813
|
+
exports.agentFileContentDeltaType,
|
|
814
|
+
exports.agentFileContentEndedType,
|
|
815
|
+
exports.agentToolCallPendingType,
|
|
816
|
+
exports.agentToolCallInProgressType,
|
|
817
|
+
exports.agentToolCallStartedType,
|
|
818
|
+
exports.agentToolCallArgumentsDeltaType,
|
|
819
|
+
exports.agentToolCallLogDeltaType,
|
|
820
|
+
exports.agentToolCallEndedType,
|
|
821
|
+
exports.agentToolCallApprovalRequestedType,
|
|
822
|
+
exports.agentImageGenerationStartedType,
|
|
823
|
+
exports.agentImageGenerationPartialType,
|
|
824
|
+
exports.agentImageGenerationCompletedType,
|
|
825
|
+
exports.agentImageGenerationFailedType,
|
|
826
|
+
]);
|
|
827
|
+
function normalizeAgentMessageJson(json) {
|
|
828
|
+
const type = stringOrNull(json.type);
|
|
829
|
+
if (type == null || !agentMessageTypesWithRequiredItemId.has(type) || normalizedString(json.item_id) != null) {
|
|
830
|
+
return json;
|
|
831
|
+
}
|
|
832
|
+
const itemId = fallbackItemId(json, type);
|
|
833
|
+
return itemId == null ? json : { ...json, item_id: itemId };
|
|
834
|
+
}
|
|
835
|
+
function fallbackItemId(json, type) {
|
|
836
|
+
const direct = normalizedString(json.itemId)
|
|
837
|
+
?? normalizedString(json.id)
|
|
838
|
+
?? normalizedString(json.call_id)
|
|
839
|
+
?? normalizedString(json.request_id)
|
|
840
|
+
?? normalizedString(json.message_id);
|
|
841
|
+
if (direct != null) {
|
|
842
|
+
return direct;
|
|
843
|
+
}
|
|
844
|
+
const turnId = normalizedString(json.turn_id) ?? normalizedString(json.turnId);
|
|
845
|
+
return turnId == null ? undefined : `${turnId}:${type}`;
|
|
846
|
+
}
|
|
847
|
+
function normalizedString(value) {
|
|
848
|
+
const normalized = stringOrNull(value)?.trim();
|
|
849
|
+
return normalized === "" ? undefined : normalized;
|
|
850
|
+
}
|
|
851
|
+
function makeMessageClass(className, { type, base = "message", fields = [], }) {
|
|
720
852
|
const Parent = base === "llm" ? AgentLLMMessage : base === "thread" ? AgentThreadMessage : AgentMessage;
|
|
721
|
-
|
|
853
|
+
const GeneratedMessage = class extends Parent {
|
|
722
854
|
constructor(params = {}) {
|
|
723
855
|
super({ ...params, type });
|
|
724
856
|
for (const field of fields) {
|
|
@@ -782,7 +914,9 @@ function makeMessageClass({ type, base = "message", fields = [], }) {
|
|
|
782
914
|
}
|
|
783
915
|
return json;
|
|
784
916
|
}
|
|
785
|
-
}
|
|
917
|
+
};
|
|
918
|
+
Object.defineProperty(GeneratedMessage, "name", { value: className });
|
|
919
|
+
return register(type, GeneratedMessage);
|
|
786
920
|
}
|
|
787
921
|
const s = (prop, json = snake(prop), required = false) => ({
|
|
788
922
|
prop,
|
|
@@ -907,7 +1041,7 @@ const imageGeneration = [
|
|
|
907
1041
|
{ prop: "tool", json: "tool", from: (value) => stringOrNull(value) ?? "image_generation", default: () => "image_generation", always: true },
|
|
908
1042
|
m("arguments"),
|
|
909
1043
|
];
|
|
910
|
-
exports.StartThread = makeMessageClass({
|
|
1044
|
+
exports.StartThread = makeMessageClass("StartThread", {
|
|
911
1045
|
type: exports.agentThreadStartType,
|
|
912
1046
|
fields: [
|
|
913
1047
|
contentList("content", true),
|
|
@@ -925,96 +1059,114 @@ exports.StartThread = makeMessageClass({
|
|
|
925
1059
|
obj("toolChoice", "tool_choice", ToolChoice.fromJson),
|
|
926
1060
|
],
|
|
927
1061
|
});
|
|
928
|
-
exports.TurnStart = makeMessageClass({ type: exports.agentTurnStartType, base: "thread", fields: turnOptions });
|
|
929
|
-
exports.TurnSteer = makeMessageClass({ type: exports.agentTurnSteerType, base: "thread", fields: [s("turnId", "turn_id", true), contentList("content")] });
|
|
930
|
-
exports.TurnInterrupt = makeMessageClass({ type: exports.agentTurnInterruptType, base: "thread", fields: [s("turnId", "turn_id", true)] });
|
|
931
|
-
exports.AgentRealtimeAudioChunk = makeMessageClass({ type: exports.agentRealtimeAudioChunkType, base: "thread", fields: [bytesField("data"), audioFormat("format", "format", true)] });
|
|
932
|
-
exports.AgentRealtimeAudioCommit = makeMessageClass({ type: exports.agentRealtimeAudioCommitType, base: "thread", fields: [s("turnId"), s("text"), s("status"), s("transcriptionItemId")] });
|
|
933
|
-
exports.ClearThread = makeMessageClass({ type: exports.agentThreadClearType, base: "thread" });
|
|
934
|
-
exports.OpenThread = makeMessageClass({ type: exports.agentThreadOpenType, base: "thread", fields: [{ prop: "load", json: "load", from: (value) => typeof value === "boolean" ? value : undefined }, s("sinceTurn")] });
|
|
935
|
-
exports.CloseThread = makeMessageClass({ type: exports.agentThreadCloseType, base: "thread" });
|
|
936
|
-
exports.
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
exports.
|
|
949
|
-
exports.
|
|
950
|
-
exports.
|
|
951
|
-
exports.
|
|
952
|
-
exports.
|
|
953
|
-
exports.
|
|
954
|
-
exports.
|
|
955
|
-
exports.
|
|
956
|
-
exports.
|
|
957
|
-
exports.
|
|
958
|
-
exports.
|
|
959
|
-
exports.
|
|
960
|
-
exports.
|
|
961
|
-
exports.
|
|
962
|
-
exports.
|
|
963
|
-
exports.
|
|
964
|
-
exports.
|
|
965
|
-
exports.
|
|
966
|
-
exports.
|
|
967
|
-
exports.
|
|
968
|
-
exports.
|
|
969
|
-
exports.
|
|
970
|
-
exports.
|
|
971
|
-
exports.
|
|
972
|
-
exports.
|
|
973
|
-
exports.
|
|
974
|
-
exports.
|
|
975
|
-
exports.
|
|
976
|
-
exports.
|
|
977
|
-
exports.
|
|
978
|
-
exports.
|
|
979
|
-
exports.
|
|
980
|
-
exports.
|
|
981
|
-
exports.
|
|
982
|
-
exports.
|
|
983
|
-
exports.
|
|
984
|
-
exports.
|
|
985
|
-
exports.
|
|
986
|
-
exports.
|
|
987
|
-
exports.
|
|
988
|
-
exports.
|
|
989
|
-
exports.
|
|
990
|
-
exports.
|
|
991
|
-
exports.
|
|
992
|
-
exports.
|
|
993
|
-
exports.
|
|
994
|
-
exports.
|
|
995
|
-
exports.
|
|
996
|
-
exports.
|
|
997
|
-
exports.
|
|
998
|
-
exports.
|
|
999
|
-
exports.
|
|
1000
|
-
exports.
|
|
1001
|
-
exports.
|
|
1002
|
-
exports.
|
|
1003
|
-
exports.
|
|
1004
|
-
exports.
|
|
1005
|
-
exports.
|
|
1006
|
-
exports.
|
|
1007
|
-
exports.
|
|
1008
|
-
|
|
1062
|
+
exports.TurnStart = makeMessageClass("TurnStart", { type: exports.agentTurnStartType, base: "thread", fields: turnOptions });
|
|
1063
|
+
exports.TurnSteer = makeMessageClass("TurnSteer", { type: exports.agentTurnSteerType, base: "thread", fields: [s("turnId", "turn_id", true), contentList("content")] });
|
|
1064
|
+
exports.TurnInterrupt = makeMessageClass("TurnInterrupt", { type: exports.agentTurnInterruptType, base: "thread", fields: [s("turnId", "turn_id", true)] });
|
|
1065
|
+
exports.AgentRealtimeAudioChunk = makeMessageClass("AgentRealtimeAudioChunk", { type: exports.agentRealtimeAudioChunkType, base: "thread", fields: [bytesField("data"), audioFormat("format", "format", true)] });
|
|
1066
|
+
exports.AgentRealtimeAudioCommit = makeMessageClass("AgentRealtimeAudioCommit", { type: exports.agentRealtimeAudioCommitType, base: "thread", fields: [s("turnId"), s("text"), s("status"), s("transcriptionItemId")] });
|
|
1067
|
+
exports.ClearThread = makeMessageClass("ClearThread", { type: exports.agentThreadClearType, base: "thread" });
|
|
1068
|
+
exports.OpenThread = makeMessageClass("OpenThread", { type: exports.agentThreadOpenType, base: "thread", fields: [s("backend"), { prop: "load", json: "load", from: (value) => typeof value === "boolean" ? value : undefined }, s("sinceTurn")] });
|
|
1069
|
+
exports.CloseThread = makeMessageClass("CloseThread", { type: exports.agentThreadCloseType, base: "thread" });
|
|
1070
|
+
exports.InjectMessages = makeMessageClass("InjectMessages", {
|
|
1071
|
+
type: exports.agentMessagesInjectType,
|
|
1072
|
+
base: "thread",
|
|
1073
|
+
fields: [{
|
|
1074
|
+
prop: "messages",
|
|
1075
|
+
json: "messages",
|
|
1076
|
+
from: agentMessageList,
|
|
1077
|
+
default: () => [],
|
|
1078
|
+
always: true,
|
|
1079
|
+
to: (messages) => messages.map((message) => message.toJson()),
|
|
1080
|
+
}],
|
|
1081
|
+
});
|
|
1082
|
+
exports.ParticipantConnect = makeMessageClass("ParticipantConnect", { type: exports.agentParticipantConnectType, fields: [s("participantId", "participant_id", true)] });
|
|
1083
|
+
exports.ParticipantDisconnect = makeMessageClass("ParticipantDisconnect", { type: exports.agentParticipantDisconnectType, fields: [s("participantId", "participant_id", true)] });
|
|
1084
|
+
exports.DeleteThread = makeMessageClass("DeleteThread", { type: exports.agentThreadDeleteType, base: "thread" });
|
|
1085
|
+
exports.RenameThread = makeMessageClass("RenameThread", { type: exports.agentThreadRenameType, base: "thread", fields: [s("name", "name", true)] });
|
|
1086
|
+
exports.ListThreads = makeMessageClass("ListThreads", { type: exports.agentThreadListType, fields: [{ prop: "limit", json: "limit", from: (value) => intOrNull(value) ?? 200, default: () => 200, always: true }, { prop: "offset", json: "offset", from: (value) => intOrNull(value) ?? 0, default: () => 0, always: true }] });
|
|
1087
|
+
exports.WatchThreads = makeMessageClass("WatchThreads", { type: exports.agentThreadWatchType });
|
|
1088
|
+
exports.UnwatchThreads = makeMessageClass("UnwatchThreads", { type: exports.agentThreadUnwatchType });
|
|
1089
|
+
exports.ThreadsListed = makeMessageClass("ThreadsListed", { type: exports.agentThreadListedType, fields: [s("sourceMessageId", "source_message_id", true), { prop: "threads", json: "threads", from: (value) => objectList(value, AgentThreadListEntry.fromJson), default: () => [], always: true, to: (value) => value.map(maybeToJson) }, { prop: "total", json: "total", from: intOrNull, default: (params) => Array.isArray(params.threads) ? params.threads.length : 0, always: true }, { prop: "offset", json: "offset", from: (value) => intOrNull(value) ?? 0, default: () => 0, always: true }, { prop: "limit", json: "limit", from: intOrNull, default: (params) => Array.isArray(params.threads) ? params.threads.length : 0, always: true }] });
|
|
1090
|
+
exports.ThreadCreated = makeMessageClass("ThreadCreated", { type: exports.agentThreadCreatedType, fields: [obj("thread", "thread", AgentThreadListEntry.fromJson, true)] });
|
|
1091
|
+
exports.ThreadUpdated = makeMessageClass("ThreadUpdated", { type: exports.agentThreadUpdatedType, fields: [obj("thread", "thread", AgentThreadListEntry.fromJson, true)] });
|
|
1092
|
+
exports.ThreadDeleted = makeMessageClass("ThreadDeleted", { type: exports.agentThreadDeletedType, fields: [s("path", "path", true)] });
|
|
1093
|
+
exports.CapabilitiesRequest = makeMessageClass("CapabilitiesRequest", { type: exports.agentCapabilitiesRequestType, base: "thread" });
|
|
1094
|
+
exports.CapabilitiesResponse = makeMessageClass("CapabilitiesResponse", { type: exports.agentCapabilitiesResponseType, base: "thread", fields: [s("sourceMessageId", "source_message_id", true), s("version", "version", true), { prop: "toolkits", json: "toolkits", from: (value) => objectList(value, ToolkitCapabilities.fromJson), default: () => [], always: true, to: (value) => value.map(maybeToJson) }] });
|
|
1095
|
+
exports.ModelsRequest = makeMessageClass("ModelsRequest", { type: exports.agentModelsRequestType });
|
|
1096
|
+
exports.ModelsResponse = makeMessageClass("ModelsResponse", { type: exports.agentModelsResponseType, fields: [s("sourceMessageId", "source_message_id", true), { prop: "providers", json: "providers", from: (value) => objectList(value, AgentProviderInfo.fromJson), default: () => [], always: true, to: (value) => value.map(maybeToJson) }] });
|
|
1097
|
+
exports.ChangeModel = makeMessageClass("ChangeModel", { type: exports.agentModelChangeType, base: "thread", fields: [s("backend"), s("provider"), s("model"), s("voice")] });
|
|
1098
|
+
exports.AgentModelChanged = makeMessageClass("AgentModelChanged", { type: exports.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)] });
|
|
1099
|
+
exports.ThreadCleared = makeMessageClass("ThreadCleared", { type: exports.agentThreadClearedType, base: "thread", fields: [s("sourceMessageId", "source_message_id", true)] });
|
|
1100
|
+
exports.TurnStartAccepted = makeMessageClass("TurnStartAccepted", { type: exports.agentTurnStartAcceptedType, base: "thread", fields: [s("turnId"), s("sourceMessageId", "source_message_id", true), contentList("content")] });
|
|
1101
|
+
exports.TurnStartRejected = makeMessageClass("TurnStartRejected", { type: exports.agentTurnStartRejectedType, base: "thread", fields: [s("sourceMessageId", "source_message_id", true), obj("error", "error", AgentError.fromJson, true)] });
|
|
1102
|
+
exports.TurnInterruptAccepted = makeMessageClass("TurnInterruptAccepted", { type: exports.agentTurnInterruptAcceptedType, base: "thread", fields: [s("turnId", "turn_id", true), s("sourceMessageId", "source_message_id", true)] });
|
|
1103
|
+
exports.TurnInterrupted = makeMessageClass("TurnInterrupted", { type: exports.agentTurnInterruptedType, base: "thread", fields: [s("turnId", "turn_id", true), s("sourceMessageId", "source_message_id", true)] });
|
|
1104
|
+
exports.TurnSteerAccepted = makeMessageClass("TurnSteerAccepted", { type: exports.agentTurnSteerAcceptedType, base: "thread", fields: [s("turnId", "turn_id", true), s("sourceMessageId", "source_message_id", true), contentList("content")] });
|
|
1105
|
+
exports.TurnSteered = makeMessageClass("TurnSteered", { type: exports.agentTurnSteeredType, base: "thread", fields: [s("turnId", "turn_id", true), s("sourceMessageId", "source_message_id", true)] });
|
|
1106
|
+
exports.TurnSteerRejected = makeMessageClass("TurnSteerRejected", { type: exports.agentTurnSteerRejectedType, base: "thread", fields: [s("turnId", "turn_id", true), s("sourceMessageId", "source_message_id", true), obj("error", "error", AgentError.fromJson, true)] });
|
|
1107
|
+
exports.TurnStarted = makeMessageClass("TurnStarted", { type: exports.agentTurnStartedType, base: "thread", fields: [s("turnId", "turn_id", true), s("sourceMessageId", "source_message_id", true)] });
|
|
1108
|
+
exports.TurnEnded = makeMessageClass("TurnEnded", { type: exports.agentTurnEndedType, base: "thread", fields: [s("turnId", "turn_id", true), obj("error", "error", AgentError.fromJson)] });
|
|
1109
|
+
exports.ThreadStarted = makeMessageClass("ThreadStarted", { type: exports.agentThreadStartedType, fields: [s("sourceMessageId", "source_message_id", true), s("threadId", "thread_id", true), obj("realtimeConnection", "realtime_connection", AgentRealtimeConnectionInfo.fromJson)] });
|
|
1110
|
+
exports.ThreadLoaded = makeMessageClass("ThreadLoaded", { type: exports.agentThreadLoadedType, base: "thread", fields: [s("sourceMessageId"), s("sinceTurn")] });
|
|
1111
|
+
exports.ThreadStartRejected = makeMessageClass("ThreadStartRejected", { type: exports.agentThreadStartRejectedType, fields: [s("sourceMessageId", "source_message_id", true), obj("error", "error", AgentError.fromJson, true)] });
|
|
1112
|
+
exports.AgentReasoningContentStarted = makeMessageClass("AgentReasoningContentStarted", { type: exports.agentReasoningContentStartedType, base: "llm", fields: contentPart });
|
|
1113
|
+
exports.AgentReasoningContentDelta = makeMessageClass("AgentReasoningContentDelta", { type: exports.agentReasoningContentDeltaType, base: "llm", fields: [...contentPart, s("text", "text", true)] });
|
|
1114
|
+
exports.AgentReasoningContentEnded = makeMessageClass("AgentReasoningContentEnded", { type: exports.agentReasoningContentEndedType, base: "llm", fields: contentPart });
|
|
1115
|
+
exports.AgentTextContentStarted = makeMessageClass("AgentTextContentStarted", { type: exports.agentTextContentStartedType, base: "llm", fields: [...contentPart, s("phase")] });
|
|
1116
|
+
exports.AgentTextContentDelta = makeMessageClass("AgentTextContentDelta", { type: exports.agentTextContentDeltaType, base: "llm", fields: [...contentPart, s("phase"), s("text", "text", true)] });
|
|
1117
|
+
exports.AgentTextContentEnded = makeMessageClass("AgentTextContentEnded", { type: exports.agentTextContentEndedType, base: "llm", fields: [...contentPart, s("phase")] });
|
|
1118
|
+
exports.AgentFileContentStarted = makeMessageClass("AgentFileContentStarted", { type: exports.agentFileContentStartedType, base: "llm", fields: contentPart });
|
|
1119
|
+
exports.AgentFileContentDelta = makeMessageClass("AgentFileContentDelta", { type: exports.agentFileContentDeltaType, base: "llm", fields: [...contentPart, s("url", "url", true)] });
|
|
1120
|
+
exports.AgentFileContentEnded = makeMessageClass("AgentFileContentEnded", { type: exports.agentFileContentEndedType, base: "llm", fields: contentPart });
|
|
1121
|
+
exports.AgentToolCallPending = makeMessageClass("AgentToolCallPending", { type: exports.agentToolCallPendingType, base: "llm", fields: toolState });
|
|
1122
|
+
exports.AgentToolCallInProgress = makeMessageClass("AgentToolCallInProgress", { type: exports.agentToolCallInProgressType, base: "llm", fields: toolState });
|
|
1123
|
+
exports.AgentToolCallStarted = makeMessageClass("AgentToolCallStarted", { type: exports.agentToolCallStartedType, base: "llm", fields: toolState });
|
|
1124
|
+
exports.AgentToolCallArgumentsDelta = makeMessageClass("AgentToolCallArgumentsDelta", { type: exports.agentToolCallArgumentsDeltaType, base: "llm", fields: [...contentPart, { prop: "namespace", json: "namespace", from: (value) => stringOrNull(value) ?? "meshagent", default: () => "meshagent", always: true }, s("callId"), s("delta", "delta", true)] });
|
|
1125
|
+
exports.AgentToolCallLogDelta = makeMessageClass("AgentToolCallLogDelta", { type: exports.agentToolCallLogDeltaType, base: "llm", fields: [...contentPart, { prop: "namespace", json: "namespace", from: (value) => stringOrNull(value) ?? "meshagent", default: () => "meshagent", always: true }, s("callId"), { prop: "lines", json: "lines", from: (value) => objectList(value, AgentToolCallLogLine.fromJson), default: () => [], always: true, to: (value) => value.map(maybeToJson) }] });
|
|
1126
|
+
exports.AgentToolCallEnded = makeMessageClass("AgentToolCallEnded", { 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)] });
|
|
1127
|
+
exports.AgentToolCallApprovalRequested = makeMessageClass("AgentToolCallApprovalRequested", { type: exports.agentToolCallApprovalRequestedType, base: "llm", fields: toolState.filter((field) => field.prop !== "argumentBytes") });
|
|
1128
|
+
exports.AgentSecretRequested = makeMessageClass("AgentSecretRequested", { type: exports.agentSecretRequestedType, base: "llm", fields: [s("turnId", "turn_id", true), s("requestId", "request_id", true), s("secretName", "secret_name", true), s("prompt"), m("oauth"), s("challenge")] });
|
|
1129
|
+
exports.AgentClientToolCallRequested = makeMessageClass("AgentClientToolCallRequested", { type: exports.agentClientToolCallRequestedType, base: "llm", fields: [s("turnId", "turn_id", true), s("requestId", "request_id", true), s("targetParticipantId"), s("toolkit", "toolkit", true), s("tool", "tool", true), { prop: "arguments", json: "arguments", from: (value) => dynamicMapOrNull(value) ?? {}, default: () => ({}), always: true }] });
|
|
1130
|
+
exports.AgentClientToolCallCancelled = makeMessageClass("AgentClientToolCallCancelled", { type: exports.agentClientToolCallCancelledType, base: "llm", fields: [s("turnId", "turn_id", true), s("requestId", "request_id", true), s("targetParticipantId"), s("toolkit", "toolkit", true), s("tool", "tool", true), s("reason")] });
|
|
1131
|
+
exports.AgentThreadStatus = makeMessageClass("AgentThreadStatus", { type: exports.agentThreadStatusType, base: "thread", fields: [s("status"), s("mode"), s("startedAt"), s("turnId"), s("pendingItemId"), i("totalBytes"), i("linesAdded"), i("linesRemoved")] });
|
|
1132
|
+
exports.AgentConnectionStatus = makeMessageClass("AgentConnectionStatus", { type: exports.agentConnectionStatusType, fields: [s("status", "status", true), s("message"), s("reason"), n("retryInSeconds"), s("participantId")] });
|
|
1133
|
+
exports.AgentThreadEvent = makeMessageClass("AgentThreadEvent", { type: exports.agentThreadEventType, base: "llm", fields: [m("event", "event", true)] });
|
|
1134
|
+
exports.AgentImageGenerationStarted = makeMessageClass("AgentImageGenerationStarted", { type: exports.agentImageGenerationStartedType, base: "llm", fields: imageGeneration });
|
|
1135
|
+
exports.AgentImageGenerationPartial = makeMessageClass("AgentImageGenerationPartial", { type: exports.agentImageGenerationPartialType, base: "llm", fields: [...imageGeneration, obj("image", "image", AgentGeneratedImage.fromJson), i("partialIndex")] });
|
|
1136
|
+
exports.AgentImageGenerationCompleted = makeMessageClass("AgentImageGenerationCompleted", { type: exports.agentImageGenerationCompletedType, base: "llm", fields: [...imageGeneration, objList("images", "images", AgentGeneratedImage.fromJson, true)] });
|
|
1137
|
+
exports.AgentImageGenerationFailed = makeMessageClass("AgentImageGenerationFailed", { type: exports.agentImageGenerationFailedType, base: "llm", fields: [...imageGeneration, obj("error", "error", AgentError.fromJson)] });
|
|
1138
|
+
exports.AgentAudioGenerationStarted = makeMessageClass("AgentAudioGenerationStarted", { type: exports.agentAudioGenerationStartedType, base: "llm", fields: responsePart });
|
|
1139
|
+
exports.AgentAudioGenerationDelta = makeMessageClass("AgentAudioGenerationDelta", { type: exports.agentAudioGenerationDeltaType, base: "llm", fields: [...responsePart, bytesField("data"), s("mimeType"), audioFormat("outputFormat")] });
|
|
1140
|
+
exports.AgentAudioGenerationCompleted = makeMessageClass("AgentAudioGenerationCompleted", { type: exports.agentAudioGenerationCompletedType, base: "llm", fields: [...responsePart, obj("audio", "audio", AgentGeneratedAudio.fromJson), audioFormat("outputFormat")] });
|
|
1141
|
+
exports.AgentAudioGenerationFailed = makeMessageClass("AgentAudioGenerationFailed", { type: exports.agentAudioGenerationFailedType, base: "llm", fields: [...responsePart, obj("error", "error", AgentError.fromJson)] });
|
|
1142
|
+
exports.AgentAudioTranscriptionStarted = makeMessageClass("AgentAudioTranscriptionStarted", { type: exports.agentAudioTranscriptionStartedType, base: "llm", fields: [...responsePart, s("role")] });
|
|
1143
|
+
exports.AgentAudioTranscriptionDelta = makeMessageClass("AgentAudioTranscriptionDelta", { type: exports.agentAudioTranscriptionDeltaType, base: "llm", fields: [...responsePart, s("role"), s("text", "text", true)] });
|
|
1144
|
+
exports.AgentAudioTranscriptionCompleted = makeMessageClass("AgentAudioTranscriptionCompleted", { type: exports.agentAudioTranscriptionCompletedType, base: "llm", fields: [...responsePart, s("role"), s("text")] });
|
|
1145
|
+
exports.AgentAudioTranscriptionFailed = makeMessageClass("AgentAudioTranscriptionFailed", { type: exports.agentAudioTranscriptionFailedType, base: "llm", fields: [...responsePart, s("role"), obj("error", "error", AgentError.fromJson)] });
|
|
1146
|
+
exports.AgentAudioInputSpeechStarted = makeMessageClass("AgentAudioInputSpeechStarted", { type: exports.agentAudioInputSpeechStartedType, base: "thread", fields: [s("turnId", "turn_id", true), s("itemId"), i("audioStartMs")] });
|
|
1147
|
+
exports.AgentAudioInputSpeechEnded = makeMessageClass("AgentAudioInputSpeechEnded", { type: exports.agentAudioInputSpeechEndedType, base: "thread", fields: [s("turnId", "turn_id", true), s("itemId"), i("audioEndMs")] });
|
|
1148
|
+
exports.AgentContextCompacted = makeMessageClass("AgentContextCompacted", { type: exports.agentContextCompactedType, base: "thread", fields: [s("checkpointId", "checkpoint_id", true), s("path", "path", true), i("throughSequence", "through_sequence", true), s("createdAt"), { prop: "messages", json: "messages", from: mapListOrNull }] });
|
|
1149
|
+
exports.AgentUsageUpdated = makeMessageClass("AgentUsageUpdated", { type: exports.agentUsageUpdatedType, base: "thread", fields: [s("turnId"), { prop: "usage", json: "usage", from: doubleMap, default: () => ({}), always: true }, obj("contextWindow", "context_window", AgentContextWindowUsage.fromJson, true)] });
|
|
1150
|
+
exports.ApproveAgentToolCall = makeMessageClass("ApproveAgentToolCall", { type: exports.agentToolApproveType, base: "thread", fields: [s("turnId", "turn_id", true), s("itemId", "item_id", true)] });
|
|
1151
|
+
exports.RejectAgentToolCall = makeMessageClass("RejectAgentToolCall", { type: exports.agentToolRejectType, base: "thread", fields: [s("turnId", "turn_id", true), s("itemId", "item_id", true)] });
|
|
1152
|
+
exports.AgentSecretResponse = makeMessageClass("AgentSecretResponse", { type: exports.agentSecretResponseType, base: "thread", fields: [s("turnId", "turn_id", true), s("requestId", "request_id", true), s("value"), s("authorizationCode"), s("redirectUri"), s("error")] });
|
|
1153
|
+
exports.AgentClientToolCallResponse = makeMessageClass("AgentClientToolCallResponse", { type: exports.agentClientToolCallResponseType, base: "thread", fields: [s("turnId", "turn_id", true), s("requestId", "request_id", true), { prop: "response", json: "response", required: true, from: (value) => { const content = contentOrNull(value); if (content == null)
|
|
1154
|
+
throw new TypeError("missing content field 'response'"); return content; }, to: contentHeader }] });
|
|
1155
|
+
function agentInputContent({ text, attachments, }) {
|
|
1009
1156
|
const content = [];
|
|
1010
1157
|
if (text.trim() !== "") {
|
|
1011
1158
|
content.push({ type: "text", text });
|
|
1012
1159
|
}
|
|
1013
1160
|
for (const attachment of attachments) {
|
|
1014
|
-
const
|
|
1015
|
-
if (
|
|
1016
|
-
|
|
1161
|
+
const url = attachment.url.trim();
|
|
1162
|
+
if (url === "") {
|
|
1163
|
+
continue;
|
|
1017
1164
|
}
|
|
1165
|
+
const name = attachment.name?.trim();
|
|
1166
|
+
content.push(new AgentFileContent({
|
|
1167
|
+
url,
|
|
1168
|
+
name: name == null || name === "" ? undefined : name,
|
|
1169
|
+
}));
|
|
1018
1170
|
}
|
|
1019
1171
|
return content;
|
|
1020
1172
|
}
|