@meshagent/meshagent-agents 0.43.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 +50 -0
- package/LICENSE +1 -0
- package/README.md +206 -0
- package/dist/browser/agent-messages.d.ts +343 -0
- package/dist/browser/agent-messages.js +1015 -0
- package/dist/browser/change-emitter.d.ts +8 -0
- package/dist/browser/change-emitter.js +20 -0
- package/dist/browser/chat-client.d.ts +225 -0
- package/dist/browser/chat-client.js +642 -0
- package/dist/browser/images-dataset.d.ts +83 -0
- package/dist/browser/images-dataset.js +282 -0
- package/dist/browser/index.d.ts +6 -0
- package/dist/browser/index.js +22 -0
- package/dist/browser/package.json +1 -0
- package/dist/browser/room-shell-toolkit.d.ts +14 -0
- package/dist/browser/room-shell-toolkit.js +274 -0
- package/dist/browser/room-storage-toolkit.d.ts +11 -0
- package/dist/browser/room-storage-toolkit.js +513 -0
- package/dist/browser/thread-storage.d.ts +102 -0
- package/dist/browser/thread-storage.js +476 -0
- package/dist/esm/agent-messages.d.ts +343 -0
- package/dist/esm/agent-messages.js +989 -0
- package/dist/esm/change-emitter.d.ts +8 -0
- package/dist/esm/change-emitter.js +16 -0
- package/dist/esm/chat-client.d.ts +225 -0
- package/dist/esm/chat-client.js +632 -0
- package/dist/esm/images-dataset.d.ts +83 -0
- package/dist/esm/images-dataset.js +274 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/room-shell-toolkit.d.ts +14 -0
- package/dist/esm/room-shell-toolkit.js +270 -0
- package/dist/esm/room-storage-toolkit.d.ts +11 -0
- package/dist/esm/room-storage-toolkit.js +509 -0
- package/dist/esm/thread-storage.d.ts +102 -0
- package/dist/esm/thread-storage.js +465 -0
- package/dist/node/agent-messages.d.ts +343 -0
- package/dist/node/agent-messages.js +1015 -0
- package/dist/node/change-emitter.d.ts +8 -0
- package/dist/node/change-emitter.js +20 -0
- package/dist/node/chat-client.d.ts +225 -0
- package/dist/node/chat-client.js +642 -0
- package/dist/node/images-dataset.d.ts +83 -0
- package/dist/node/images-dataset.js +282 -0
- package/dist/node/index.d.ts +6 -0
- package/dist/node/index.js +22 -0
- package/dist/node/package.json +1 -0
- package/dist/node/room-shell-toolkit.d.ts +14 -0
- package/dist/node/room-shell-toolkit.js +274 -0
- package/dist/node/room-storage-toolkit.d.ts +11 -0
- package/dist/node/room-storage-toolkit.js +513 -0
- package/dist/node/thread-storage.d.ts +102 -0
- package/dist/node/thread-storage.js +476 -0
- package/package.json +57 -0
|
@@ -0,0 +1,1015 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.agentToolCallStartedType = exports.agentToolCallInProgressType = exports.agentToolCallPendingType = 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.agentThreadListType = exports.agentThreadRenameType = exports.agentThreadDeleteType = exports.agentParticipantDisconnectType = exports.agentParticipantConnectType = 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.StartThread = exports.AgentLLMMessage = exports.AgentThreadMessage = exports.AgentMessage = 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.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 = void 0;
|
|
5
|
+
exports.AgentToolCallLogDelta = exports.AgentToolCallArgumentsDelta = exports.AgentToolCallStarted = exports.AgentToolCallInProgress = exports.AgentToolCallPending = exports.AgentFileContentEnded = exports.AgentFileContentDelta = 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.ListThreads = exports.RenameThread = exports.DeleteThread = exports.ParticipantDisconnect = exports.ParticipantConnect = exports.CloseThread = exports.OpenThread = exports.ClearThread = exports.AgentRealtimeAudioCommit = exports.AgentRealtimeAudioChunk = exports.TurnInterrupt = exports.TurnSteer = exports.TurnStart = 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 = void 0;
|
|
7
|
+
exports.agentInputContent = agentInputContent;
|
|
8
|
+
const meshagent_1 = require("@meshagent/meshagent");
|
|
9
|
+
const uuid_1 = require("uuid");
|
|
10
|
+
exports.agentRoomMessageType = "agent-message";
|
|
11
|
+
exports.agentTurnStartType = "meshagent.agent.turn.start";
|
|
12
|
+
exports.agentTurnSteerType = "meshagent.agent.turn.steer";
|
|
13
|
+
exports.agentTurnInterruptType = "meshagent.agent.turn.interrupt";
|
|
14
|
+
exports.agentThreadClearType = "meshagent.agent.thread.clear";
|
|
15
|
+
exports.agentRealtimeAudioChunkType = "meshagent.agent.realtime_audio.chunk";
|
|
16
|
+
exports.agentRealtimeAudioCommitType = "meshagent.agent.realtime_audio.commit";
|
|
17
|
+
exports.agentThreadStartType = "meshagent.agent.thread.start";
|
|
18
|
+
exports.agentThreadStartedType = "meshagent.agent.thread.started";
|
|
19
|
+
exports.agentThreadLoadedType = "meshagent.agent.thread.loaded";
|
|
20
|
+
exports.agentThreadStartRejectedType = "meshagent.agent.thread.start.rejected";
|
|
21
|
+
exports.agentThreadOpenType = "meshagent.agent.thread.open";
|
|
22
|
+
exports.agentThreadCloseType = "meshagent.agent.thread.close";
|
|
23
|
+
exports.agentParticipantConnectType = "meshagent.agent.participant.connect";
|
|
24
|
+
exports.agentParticipantDisconnectType = "meshagent.agent.participant.disconnect";
|
|
25
|
+
exports.agentThreadDeleteType = "meshagent.agent.thread.delete";
|
|
26
|
+
exports.agentThreadRenameType = "meshagent.agent.thread.rename";
|
|
27
|
+
exports.agentThreadListType = "meshagent.agent.thread.list";
|
|
28
|
+
exports.agentThreadListedType = "meshagent.agent.thread.listed";
|
|
29
|
+
exports.agentThreadCreatedType = "meshagent.agent.thread.created";
|
|
30
|
+
exports.agentThreadUpdatedType = "meshagent.agent.thread.updated";
|
|
31
|
+
exports.agentThreadDeletedType = "meshagent.agent.thread.deleted";
|
|
32
|
+
exports.agentCapabilitiesRequestType = "meshagent.agent.capabilities_request";
|
|
33
|
+
exports.agentCapabilitiesResponseType = "meshagent.agent.capabilities_response";
|
|
34
|
+
exports.agentModelsRequestType = "meshagent.agent.models.request";
|
|
35
|
+
exports.agentModelsResponseType = "meshagent.agent.models.response";
|
|
36
|
+
exports.agentModelChangeType = "meshagent.agent.model.change";
|
|
37
|
+
exports.agentModelChangedType = "meshagent.agent.model.changed";
|
|
38
|
+
exports.agentThreadClearedType = "meshagent.agent.thread.cleared";
|
|
39
|
+
exports.agentTurnStartAcceptedType = "meshagent.agent.turn.start.accepted";
|
|
40
|
+
exports.agentTurnStartRejectedType = "meshagent.agent.turn.start.rejected";
|
|
41
|
+
exports.agentTurnInterruptAcceptedType = "meshagent.agent.turn.interrupt.accepted";
|
|
42
|
+
exports.agentTurnInterruptedType = "meshagent.agent.turn.interrupted";
|
|
43
|
+
exports.agentTurnSteerAcceptedType = "meshagent.agent.turn.steer.accepted";
|
|
44
|
+
exports.agentTurnSteeredType = "meshagent.agent.turn.steered";
|
|
45
|
+
exports.agentTurnSteerRejectedType = "meshagent.agent.turn.steer.rejected";
|
|
46
|
+
exports.agentTurnStartedType = "meshagent.agent.turn.started";
|
|
47
|
+
exports.agentTurnEndedType = "meshagent.agent.turn.ended";
|
|
48
|
+
exports.agentReasoningContentStartedType = "meshagent.agent.reasoning_content.started";
|
|
49
|
+
exports.agentReasoningContentDeltaType = "meshagent.agent.reasoning_content.delta";
|
|
50
|
+
exports.agentReasoningContentEndedType = "meshagent.agent.reasoning_content.ended";
|
|
51
|
+
exports.agentTextContentStartedType = "meshagent.agent.text_content.started";
|
|
52
|
+
exports.agentTextContentDeltaType = "meshagent.agent.text_content.delta";
|
|
53
|
+
exports.agentTextContentEndedType = "meshagent.agent.text_content.ended";
|
|
54
|
+
exports.agentFileContentStartedType = "meshagent.agent.file_content.started";
|
|
55
|
+
exports.agentFileContentDeltaType = "meshagent.agent.file_content.delta";
|
|
56
|
+
exports.agentFileContentEndedType = "meshagent.agent.file_content.ended";
|
|
57
|
+
exports.agentToolCallPendingType = "meshagent.agent.tool_call.pending";
|
|
58
|
+
exports.agentToolCallInProgressType = "meshagent.agent.tool_call.in_progress";
|
|
59
|
+
exports.agentToolCallStartedType = "meshagent.agent.tool_call.started";
|
|
60
|
+
exports.agentToolCallArgumentsDeltaType = "meshagent.agent.tool_call.arguments_delta";
|
|
61
|
+
exports.agentToolCallLogDeltaType = "meshagent.agent.tool_call.log_delta";
|
|
62
|
+
exports.agentToolCallEndedType = "meshagent.agent.tool_call.ended";
|
|
63
|
+
exports.agentToolCallApprovalRequestedType = "meshagent.agent.tool_call.approval_requested";
|
|
64
|
+
exports.agentClientToolCallRequestedType = "meshagent.agent.client_tool_call.requested";
|
|
65
|
+
exports.agentClientToolCallCancelledType = "meshagent.agent.client_tool_call.cancelled";
|
|
66
|
+
exports.agentSecretRequestedType = "meshagent.agent.secret.requested";
|
|
67
|
+
exports.agentThreadStatusType = "meshagent.agent.thread.status";
|
|
68
|
+
exports.agentConnectionStatusType = "meshagent.agent.connection.status";
|
|
69
|
+
exports.agentThreadEventType = "meshagent.agent.thread.event";
|
|
70
|
+
exports.agentImageGenerationStartedType = "meshagent.agent.image_generation.started";
|
|
71
|
+
exports.agentImageGenerationPartialType = "meshagent.agent.image_generation.partial";
|
|
72
|
+
exports.agentImageGenerationCompletedType = "meshagent.agent.image_generation.completed";
|
|
73
|
+
exports.agentImageGenerationFailedType = "meshagent.agent.image_generation.failed";
|
|
74
|
+
exports.agentAudioGenerationStartedType = "meshagent.agent.audio_generation.started";
|
|
75
|
+
exports.agentAudioGenerationDeltaType = "meshagent.agent.audio_generation.delta";
|
|
76
|
+
exports.agentAudioGenerationCompletedType = "meshagent.agent.audio_generation.completed";
|
|
77
|
+
exports.agentAudioGenerationFailedType = "meshagent.agent.audio_generation.failed";
|
|
78
|
+
exports.agentAudioTranscriptionStartedType = "meshagent.agent.audio_transcription.started";
|
|
79
|
+
exports.agentAudioTranscriptionDeltaType = "meshagent.agent.audio_transcription.delta";
|
|
80
|
+
exports.agentAudioTranscriptionCompletedType = "meshagent.agent.audio_transcription.completed";
|
|
81
|
+
exports.agentAudioTranscriptionFailedType = "meshagent.agent.audio_transcription.failed";
|
|
82
|
+
exports.agentAudioInputSpeechStartedType = "meshagent.agent.audio_input.speech_started";
|
|
83
|
+
exports.agentAudioInputSpeechEndedType = "meshagent.agent.audio_input.speech_ended";
|
|
84
|
+
exports.agentContextCompactedType = "meshagent.agent.context.compacted";
|
|
85
|
+
exports.agentUsageUpdatedType = "meshagent.agent.usage.updated";
|
|
86
|
+
exports.agentToolApproveType = "meshagent.agent.tool_call.approve";
|
|
87
|
+
exports.agentToolRejectType = "meshagent.agent.tool_call.reject";
|
|
88
|
+
exports.agentSecretResponseType = "meshagent.agent.secret.response";
|
|
89
|
+
exports.agentClientToolCallResponseType = "meshagent.agent.client_tool_call.response";
|
|
90
|
+
const globalScope = globalThis;
|
|
91
|
+
function hasOwn(value, key) {
|
|
92
|
+
return Object.prototype.hasOwnProperty.call(value, key);
|
|
93
|
+
}
|
|
94
|
+
function paramValue(params, prop, jsonKey = prop) {
|
|
95
|
+
if (hasOwn(params, prop)) {
|
|
96
|
+
return params[prop];
|
|
97
|
+
}
|
|
98
|
+
return params[jsonKey];
|
|
99
|
+
}
|
|
100
|
+
function bytesToBase64(bytes) {
|
|
101
|
+
if (globalScope.Buffer != null) {
|
|
102
|
+
return globalScope.Buffer.from(bytes).toString("base64");
|
|
103
|
+
}
|
|
104
|
+
if (globalScope.btoa == null) {
|
|
105
|
+
throw new Error("base64 encoding is not available in this runtime");
|
|
106
|
+
}
|
|
107
|
+
let binary = "";
|
|
108
|
+
for (const byte of bytes) {
|
|
109
|
+
binary += String.fromCharCode(byte);
|
|
110
|
+
}
|
|
111
|
+
return globalScope.btoa(binary);
|
|
112
|
+
}
|
|
113
|
+
function base64ToBytes(value) {
|
|
114
|
+
if (globalScope.Buffer != null) {
|
|
115
|
+
return Uint8Array.from(globalScope.Buffer.from(value, "base64"));
|
|
116
|
+
}
|
|
117
|
+
if (globalScope.atob == null) {
|
|
118
|
+
throw new Error("base64 decoding is not available in this runtime");
|
|
119
|
+
}
|
|
120
|
+
const binary = globalScope.atob(value);
|
|
121
|
+
const bytes = new Uint8Array(binary.length);
|
|
122
|
+
for (let index = 0; index < binary.length; index += 1) {
|
|
123
|
+
bytes[index] = binary.charCodeAt(index);
|
|
124
|
+
}
|
|
125
|
+
return bytes;
|
|
126
|
+
}
|
|
127
|
+
function isRecord(value) {
|
|
128
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
129
|
+
}
|
|
130
|
+
function requiredString(json, key) {
|
|
131
|
+
const value = json[key];
|
|
132
|
+
if (typeof value === "string") {
|
|
133
|
+
return value;
|
|
134
|
+
}
|
|
135
|
+
throw new TypeError(`missing string field '${key}'`);
|
|
136
|
+
}
|
|
137
|
+
function requiredInt(json, key) {
|
|
138
|
+
const value = intOrNull(json[key]);
|
|
139
|
+
if (value !== undefined) {
|
|
140
|
+
return value;
|
|
141
|
+
}
|
|
142
|
+
throw new TypeError(`missing integer field '${key}'`);
|
|
143
|
+
}
|
|
144
|
+
function requiredMap(json, key) {
|
|
145
|
+
const value = dynamicMapOrNull(json[key]);
|
|
146
|
+
if (value != null) {
|
|
147
|
+
return value;
|
|
148
|
+
}
|
|
149
|
+
throw new TypeError(`missing object field '${key}'`);
|
|
150
|
+
}
|
|
151
|
+
function stringOrNull(value) {
|
|
152
|
+
return typeof value === "string" ? value : undefined;
|
|
153
|
+
}
|
|
154
|
+
function intOrNull(value) {
|
|
155
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
156
|
+
return Math.trunc(value);
|
|
157
|
+
}
|
|
158
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
159
|
+
const parsed = Number.parseInt(value, 10);
|
|
160
|
+
return Number.isNaN(parsed) ? undefined : parsed;
|
|
161
|
+
}
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
function numOrNull(value) {
|
|
165
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
166
|
+
return value;
|
|
167
|
+
}
|
|
168
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
169
|
+
const parsed = Number(value);
|
|
170
|
+
return Number.isNaN(parsed) ? undefined : parsed;
|
|
171
|
+
}
|
|
172
|
+
return undefined;
|
|
173
|
+
}
|
|
174
|
+
function bytesOrEmpty(value) {
|
|
175
|
+
if (value instanceof Uint8Array) {
|
|
176
|
+
return value;
|
|
177
|
+
}
|
|
178
|
+
if (Array.isArray(value) && value.every((entry) => typeof entry === "number")) {
|
|
179
|
+
return Uint8Array.from(value);
|
|
180
|
+
}
|
|
181
|
+
if (typeof value === "string" && value.length > 0) {
|
|
182
|
+
return base64ToBytes(value);
|
|
183
|
+
}
|
|
184
|
+
return new Uint8Array();
|
|
185
|
+
}
|
|
186
|
+
function dynamicMapOrNull(value) {
|
|
187
|
+
return isRecord(value) ? { ...value } : undefined;
|
|
188
|
+
}
|
|
189
|
+
function stringMap(value) {
|
|
190
|
+
const map = dynamicMapOrNull(value);
|
|
191
|
+
if (map == null) {
|
|
192
|
+
return {};
|
|
193
|
+
}
|
|
194
|
+
return Object.fromEntries(Object.entries(map).map(([key, entry]) => [key, String(entry)]));
|
|
195
|
+
}
|
|
196
|
+
function doubleMap(value) {
|
|
197
|
+
return doubleMapOrNull(value) ?? {};
|
|
198
|
+
}
|
|
199
|
+
function doubleMapOrNull(value) {
|
|
200
|
+
const map = dynamicMapOrNull(value);
|
|
201
|
+
if (map == null) {
|
|
202
|
+
return undefined;
|
|
203
|
+
}
|
|
204
|
+
return Object.fromEntries(Object.entries(map).map(([key, entry]) => [key, Number(entry)]));
|
|
205
|
+
}
|
|
206
|
+
function stringList(value, fallback = []) {
|
|
207
|
+
return stringListOrNull(value) ?? [...fallback];
|
|
208
|
+
}
|
|
209
|
+
function stringListOrNull(value) {
|
|
210
|
+
if (!Array.isArray(value)) {
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
return value.map((entry) => String(entry));
|
|
214
|
+
}
|
|
215
|
+
function inputContentFromJson(value) {
|
|
216
|
+
const json = dynamicMapOrNull(value);
|
|
217
|
+
if (json == null) {
|
|
218
|
+
throw new TypeError("agent input content must be an object");
|
|
219
|
+
}
|
|
220
|
+
if (json.type === "text") {
|
|
221
|
+
return { type: "text", text: requiredString(json, "text") };
|
|
222
|
+
}
|
|
223
|
+
if (json.type === "file") {
|
|
224
|
+
return { type: "file", url: requiredString(json, "url") };
|
|
225
|
+
}
|
|
226
|
+
throw new TypeError("unsupported agent input content type");
|
|
227
|
+
}
|
|
228
|
+
function inputContentList(value) {
|
|
229
|
+
return inputContentListOrNull(value) ?? [];
|
|
230
|
+
}
|
|
231
|
+
function inputContentListOrNull(value) {
|
|
232
|
+
if (!Array.isArray(value)) {
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
return value.map(inputContentFromJson);
|
|
236
|
+
}
|
|
237
|
+
function objectList(value, fromJson) {
|
|
238
|
+
if (!Array.isArray(value)) {
|
|
239
|
+
return [];
|
|
240
|
+
}
|
|
241
|
+
return value.map((entry) => fromJson(requiredObjectValue(entry)));
|
|
242
|
+
}
|
|
243
|
+
function mapListOrNull(value) {
|
|
244
|
+
if (!Array.isArray(value)) {
|
|
245
|
+
return undefined;
|
|
246
|
+
}
|
|
247
|
+
return value.map(requiredObjectValue);
|
|
248
|
+
}
|
|
249
|
+
function requiredObjectValue(value) {
|
|
250
|
+
const map = dynamicMapOrNull(value);
|
|
251
|
+
if (map == null) {
|
|
252
|
+
throw new TypeError("expected object");
|
|
253
|
+
}
|
|
254
|
+
return map;
|
|
255
|
+
}
|
|
256
|
+
function contentOrNull(value) {
|
|
257
|
+
if (isContent(value)) {
|
|
258
|
+
return value;
|
|
259
|
+
}
|
|
260
|
+
const map = dynamicMapOrNull(value);
|
|
261
|
+
return map == null ? undefined : (0, meshagent_1.unpackContent)((0, meshagent_1.packMessage)(map));
|
|
262
|
+
}
|
|
263
|
+
function isContent(value) {
|
|
264
|
+
return value instanceof meshagent_1.BinaryContent ||
|
|
265
|
+
value instanceof meshagent_1.ControlContent ||
|
|
266
|
+
value instanceof meshagent_1.EmptyContent ||
|
|
267
|
+
value instanceof meshagent_1.ErrorContent ||
|
|
268
|
+
value instanceof meshagent_1.FileContent ||
|
|
269
|
+
value instanceof meshagent_1.JsonContent ||
|
|
270
|
+
value instanceof meshagent_1.LinkContent ||
|
|
271
|
+
value instanceof meshagent_1.TextContent;
|
|
272
|
+
}
|
|
273
|
+
function contentHeader(content) {
|
|
274
|
+
return (0, meshagent_1.unpackMessage)(content.pack())[0];
|
|
275
|
+
}
|
|
276
|
+
function maybeToJson(value) {
|
|
277
|
+
return value != null && typeof value.toJson === "function" ? value.toJson() : value;
|
|
278
|
+
}
|
|
279
|
+
function contentToJson(value) {
|
|
280
|
+
return { ...value };
|
|
281
|
+
}
|
|
282
|
+
function objectOrNull(value, fromJson) {
|
|
283
|
+
const map = dynamicMapOrNull(value);
|
|
284
|
+
return map == null ? undefined : fromJson(map);
|
|
285
|
+
}
|
|
286
|
+
class ToolChoice {
|
|
287
|
+
constructor({ toolkitName, toolName, toolkit_name, tool_name }) {
|
|
288
|
+
this.toolkitName = String(toolkitName ?? toolkit_name);
|
|
289
|
+
this.toolName = String(toolName ?? tool_name);
|
|
290
|
+
}
|
|
291
|
+
static fromJson(json) {
|
|
292
|
+
return new ToolChoice({ toolkitName: requiredString(json, "toolkit_name"), toolName: requiredString(json, "tool_name") });
|
|
293
|
+
}
|
|
294
|
+
toJson() {
|
|
295
|
+
return { toolkit_name: this.toolkitName, tool_name: this.toolName };
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
exports.ToolChoice = ToolChoice;
|
|
299
|
+
class TurnMcpConfig {
|
|
300
|
+
constructor({ servers = [] } = {}) {
|
|
301
|
+
this.servers = mapListOrNull(servers) ?? [];
|
|
302
|
+
}
|
|
303
|
+
static fromJson(json) {
|
|
304
|
+
return new TurnMcpConfig({ servers: mapListOrNull(json.servers) ?? [] });
|
|
305
|
+
}
|
|
306
|
+
toJson() {
|
|
307
|
+
return { servers: this.servers };
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
exports.TurnMcpConfig = TurnMcpConfig;
|
|
311
|
+
class ClientToolkitDescription {
|
|
312
|
+
constructor({ name, title, description, inputSchema, input_schema }) {
|
|
313
|
+
this.name = String(name);
|
|
314
|
+
this.title = stringOrNull(title);
|
|
315
|
+
this.description = stringOrNull(description);
|
|
316
|
+
this.inputSchema = dynamicMapOrNull(inputSchema ?? input_schema) ?? {};
|
|
317
|
+
}
|
|
318
|
+
static fromJson(json) {
|
|
319
|
+
return new ClientToolkitDescription({
|
|
320
|
+
name: requiredString(json, "name"),
|
|
321
|
+
title: stringOrNull(json.title),
|
|
322
|
+
description: stringOrNull(json.description),
|
|
323
|
+
inputSchema: dynamicMapOrNull(json.input_schema ?? json.inputSchema) ?? requiredMap(json, "input_schema"),
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
toJson() {
|
|
327
|
+
return {
|
|
328
|
+
name: this.name,
|
|
329
|
+
...(this.title != null ? { title: this.title } : {}),
|
|
330
|
+
...(this.description != null ? { description: this.description } : {}),
|
|
331
|
+
input_schema: this.inputSchema,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
exports.ClientToolkitDescription = ClientToolkitDescription;
|
|
336
|
+
class TurnToolkitConfig {
|
|
337
|
+
constructor({ clientOptions, client_options } = {}) {
|
|
338
|
+
this.clientOptions = dynamicMapOrNull(clientOptions ?? client_options);
|
|
339
|
+
}
|
|
340
|
+
static fromJson(json) {
|
|
341
|
+
return new TurnToolkitConfig({ clientOptions: dynamicMapOrNull(json.client_options) });
|
|
342
|
+
}
|
|
343
|
+
toJson() {
|
|
344
|
+
return this.clientOptions == null ? {} : { client_options: this.clientOptions };
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
exports.TurnToolkitConfig = TurnToolkitConfig;
|
|
348
|
+
function toolkitsOrNull(value) {
|
|
349
|
+
const map = dynamicMapOrNull(value);
|
|
350
|
+
if (map == null) {
|
|
351
|
+
return undefined;
|
|
352
|
+
}
|
|
353
|
+
return Object.fromEntries(Object.entries(map).map(([key, entry]) => [key, TurnToolkitConfig.fromJson(requiredObjectValue(entry))]));
|
|
354
|
+
}
|
|
355
|
+
function toolkitsToJson(value) {
|
|
356
|
+
return value == null ? undefined : Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, entry.toJson()]));
|
|
357
|
+
}
|
|
358
|
+
function turnMcpConfigOrNull(value) {
|
|
359
|
+
return objectOrNull(value, TurnMcpConfig.fromJson);
|
|
360
|
+
}
|
|
361
|
+
class AgentAudioFormat {
|
|
362
|
+
constructor({ type = "audio/pcm", sampleRate, sample_rate, bitrate } = {}) {
|
|
363
|
+
this.type = String(type);
|
|
364
|
+
this.sampleRate = intOrNull(sampleRate ?? sample_rate);
|
|
365
|
+
this.bitrate = intOrNull(bitrate);
|
|
366
|
+
}
|
|
367
|
+
static fromJson(json) {
|
|
368
|
+
return new AgentAudioFormat({
|
|
369
|
+
type: stringOrNull(json.type) ?? "audio/pcm",
|
|
370
|
+
sampleRate: intOrNull(json.sample_rate),
|
|
371
|
+
bitrate: intOrNull(json.bitrate),
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
toJson() {
|
|
375
|
+
return {
|
|
376
|
+
type: this.type,
|
|
377
|
+
...(this.sampleRate !== undefined ? { sample_rate: this.sampleRate } : {}),
|
|
378
|
+
...(this.bitrate !== undefined ? { bitrate: this.bitrate } : {}),
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
exports.AgentAudioFormat = AgentAudioFormat;
|
|
383
|
+
function audioFormatOrNull(value) {
|
|
384
|
+
return objectOrNull(value, AgentAudioFormat.fromJson);
|
|
385
|
+
}
|
|
386
|
+
function audioFormatOrDefault(value) {
|
|
387
|
+
return audioFormatOrNull(value) ?? new AgentAudioFormat();
|
|
388
|
+
}
|
|
389
|
+
class AgentError {
|
|
390
|
+
constructor({ message, code }) {
|
|
391
|
+
this.message = message;
|
|
392
|
+
this.code = code;
|
|
393
|
+
}
|
|
394
|
+
static fromJson(json) {
|
|
395
|
+
return new AgentError({ message: requiredString(json, "message"), code: stringOrNull(json.code) });
|
|
396
|
+
}
|
|
397
|
+
toJson() {
|
|
398
|
+
return { message: this.message, ...(this.code != null ? { code: this.code } : {}) };
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
exports.AgentError = AgentError;
|
|
402
|
+
class ToolkitToolCapabilities {
|
|
403
|
+
constructor({ name, title, description }) {
|
|
404
|
+
this.name = String(name);
|
|
405
|
+
this.title = stringOrNull(title);
|
|
406
|
+
this.description = stringOrNull(description);
|
|
407
|
+
}
|
|
408
|
+
static fromJson(json) {
|
|
409
|
+
return new ToolkitToolCapabilities({
|
|
410
|
+
name: requiredString(json, "name"),
|
|
411
|
+
title: stringOrNull(json.title),
|
|
412
|
+
description: stringOrNull(json.description),
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
toJson() {
|
|
416
|
+
return {
|
|
417
|
+
name: this.name,
|
|
418
|
+
...(this.title != null ? { title: this.title } : {}),
|
|
419
|
+
...(this.description != null ? { description: this.description } : {}),
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
exports.ToolkitToolCapabilities = ToolkitToolCapabilities;
|
|
424
|
+
class ToolkitCapabilities {
|
|
425
|
+
constructor(params) {
|
|
426
|
+
this.name = String(params.name);
|
|
427
|
+
this.title = stringOrNull(params.title);
|
|
428
|
+
this.description = stringOrNull(params.description);
|
|
429
|
+
this.thumbnailUrl = stringOrNull(params.thumbnailUrl ?? params.thumbnail_url);
|
|
430
|
+
this.rules = stringList(params.rules);
|
|
431
|
+
this.clientOptions = dynamicMapOrNull(params.clientOptions ?? params.client_options);
|
|
432
|
+
this.hidden = params.hidden === true;
|
|
433
|
+
this.tools = Array.isArray(params.tools) ? params.tools.map((entry) => entry instanceof ToolkitToolCapabilities ? entry : ToolkitToolCapabilities.fromJson(requiredObjectValue(entry))) : [];
|
|
434
|
+
}
|
|
435
|
+
static fromJson(json) {
|
|
436
|
+
return new ToolkitCapabilities(json);
|
|
437
|
+
}
|
|
438
|
+
toJson() {
|
|
439
|
+
return {
|
|
440
|
+
name: this.name,
|
|
441
|
+
...(this.title != null ? { title: this.title } : {}),
|
|
442
|
+
...(this.description != null ? { description: this.description } : {}),
|
|
443
|
+
...(this.thumbnailUrl != null ? { thumbnail_url: this.thumbnailUrl } : {}),
|
|
444
|
+
rules: this.rules,
|
|
445
|
+
...(this.clientOptions != null ? { client_options: this.clientOptions } : {}),
|
|
446
|
+
hidden: this.hidden,
|
|
447
|
+
tools: this.tools.map((entry) => entry.toJson()),
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
exports.ToolkitCapabilities = ToolkitCapabilities;
|
|
452
|
+
class AgentModelInfo {
|
|
453
|
+
constructor(params) {
|
|
454
|
+
this.name = String(params.name);
|
|
455
|
+
this.friendlyName = stringOrNull(params.friendlyName ?? params.friendly_name);
|
|
456
|
+
this.description = stringOrNull(params.description);
|
|
457
|
+
this.contextWindow = intOrNull(params.contextWindow ?? params.context_window);
|
|
458
|
+
this.pricing = doubleMapOrNull(params.pricing);
|
|
459
|
+
this.modalities = stringList(params.modalities, ["text"]);
|
|
460
|
+
this.availableVoices = stringList(params.availableVoices ?? params.available_voices);
|
|
461
|
+
this.defaultOutputVoice = stringOrNull(params.defaultOutputVoice ?? params.default_output_voice);
|
|
462
|
+
this.inputFormat = params.inputFormat instanceof AgentAudioFormat ? params.inputFormat : audioFormatOrNull(params.inputFormat ?? params.input_format);
|
|
463
|
+
this.outputFormat = params.outputFormat instanceof AgentAudioFormat ? params.outputFormat : audioFormatOrNull(params.outputFormat ?? params.output_format);
|
|
464
|
+
this.turnDetection = stringOrNull(params.turnDetection ?? params.turn_detection);
|
|
465
|
+
this.realtimeProtocols = stringList(params.realtimeProtocols ?? params.realtime_protocols);
|
|
466
|
+
this.active = params.active === true;
|
|
467
|
+
}
|
|
468
|
+
static fromJson(json) {
|
|
469
|
+
return new AgentModelInfo(json);
|
|
470
|
+
}
|
|
471
|
+
toJson() {
|
|
472
|
+
return {
|
|
473
|
+
name: this.name,
|
|
474
|
+
...(this.friendlyName != null ? { friendly_name: this.friendlyName } : {}),
|
|
475
|
+
...(this.description != null ? { description: this.description } : {}),
|
|
476
|
+
...(this.contextWindow != null ? { context_window: this.contextWindow } : {}),
|
|
477
|
+
...(this.pricing != null ? { pricing: this.pricing } : {}),
|
|
478
|
+
modalities: this.modalities,
|
|
479
|
+
available_voices: this.availableVoices,
|
|
480
|
+
...(this.defaultOutputVoice != null ? { default_output_voice: this.defaultOutputVoice } : {}),
|
|
481
|
+
...(this.inputFormat != null ? { input_format: this.inputFormat.toJson() } : {}),
|
|
482
|
+
...(this.outputFormat != null ? { output_format: this.outputFormat.toJson() } : {}),
|
|
483
|
+
...(this.turnDetection != null ? { turn_detection: this.turnDetection } : {}),
|
|
484
|
+
realtime_protocols: this.realtimeProtocols,
|
|
485
|
+
active: this.active,
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
exports.AgentModelInfo = AgentModelInfo;
|
|
490
|
+
class AgentProviderInfo {
|
|
491
|
+
constructor(params) {
|
|
492
|
+
this.name = String(params.name);
|
|
493
|
+
this.friendlyName = String(params.friendlyName ?? params.friendly_name);
|
|
494
|
+
this.description = stringOrNull(params.description);
|
|
495
|
+
this.defaultModel = String(params.defaultModel ?? params.default_model);
|
|
496
|
+
this.models = Array.isArray(params.models) ? params.models.map((entry) => entry instanceof AgentModelInfo ? entry : AgentModelInfo.fromJson(requiredObjectValue(entry))) : [];
|
|
497
|
+
}
|
|
498
|
+
static fromJson(json) {
|
|
499
|
+
return new AgentProviderInfo(json);
|
|
500
|
+
}
|
|
501
|
+
toJson() {
|
|
502
|
+
return {
|
|
503
|
+
name: this.name,
|
|
504
|
+
friendly_name: this.friendlyName,
|
|
505
|
+
...(this.description != null ? { description: this.description } : {}),
|
|
506
|
+
default_model: this.defaultModel,
|
|
507
|
+
models: this.models.map((entry) => entry.toJson()),
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
exports.AgentProviderInfo = AgentProviderInfo;
|
|
512
|
+
class AgentThreadListEntry {
|
|
513
|
+
constructor(params) {
|
|
514
|
+
this.path = String(params.path);
|
|
515
|
+
this.name = String(params.name ?? "");
|
|
516
|
+
this.createdAt = String(params.createdAt ?? params.created_at ?? "");
|
|
517
|
+
this.modifiedAt = String(params.modifiedAt ?? params.modified_at ?? "");
|
|
518
|
+
}
|
|
519
|
+
static fromJson(json) {
|
|
520
|
+
return new AgentThreadListEntry({
|
|
521
|
+
path: requiredString(json, "path"),
|
|
522
|
+
name: stringOrNull(json.name) ?? "",
|
|
523
|
+
createdAt: stringOrNull(json.created_at) ?? "",
|
|
524
|
+
modifiedAt: stringOrNull(json.modified_at) ?? "",
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
toJson() {
|
|
528
|
+
return {
|
|
529
|
+
path: this.path,
|
|
530
|
+
name: this.name,
|
|
531
|
+
created_at: this.createdAt,
|
|
532
|
+
modified_at: this.modifiedAt,
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
exports.AgentThreadListEntry = AgentThreadListEntry;
|
|
537
|
+
class AgentRealtimeConnectionInfo {
|
|
538
|
+
constructor(params) {
|
|
539
|
+
this.protocol = String(params.protocol);
|
|
540
|
+
this.url = String(params.url);
|
|
541
|
+
this.headers = stringMap(params.headers);
|
|
542
|
+
this.webOnlyProtocol = stringOrNull(params.webOnlyProtocol ?? params.web_only_protocol);
|
|
543
|
+
}
|
|
544
|
+
static fromJson(json) {
|
|
545
|
+
return new AgentRealtimeConnectionInfo({
|
|
546
|
+
protocol: requiredString(json, "protocol"),
|
|
547
|
+
url: requiredString(json, "url"),
|
|
548
|
+
headers: stringMap(json.headers),
|
|
549
|
+
webOnlyProtocol: stringOrNull(json.web_only_protocol),
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
toJson() {
|
|
553
|
+
return {
|
|
554
|
+
protocol: this.protocol,
|
|
555
|
+
url: this.url,
|
|
556
|
+
headers: this.headers,
|
|
557
|
+
...(this.webOnlyProtocol != null ? { web_only_protocol: this.webOnlyProtocol } : {}),
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
exports.AgentRealtimeConnectionInfo = AgentRealtimeConnectionInfo;
|
|
562
|
+
class AgentToolCallLogLine {
|
|
563
|
+
constructor({ source, text }) {
|
|
564
|
+
this.source = String(source);
|
|
565
|
+
this.text = String(text);
|
|
566
|
+
}
|
|
567
|
+
static fromJson(json) {
|
|
568
|
+
return new AgentToolCallLogLine({ source: requiredString(json, "source"), text: requiredString(json, "text") });
|
|
569
|
+
}
|
|
570
|
+
toJson() {
|
|
571
|
+
return { source: this.source, text: this.text };
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
exports.AgentToolCallLogLine = AgentToolCallLogLine;
|
|
575
|
+
class AgentGeneratedImage {
|
|
576
|
+
constructor(params = {}) {
|
|
577
|
+
this.uri = stringOrNull(params.uri);
|
|
578
|
+
this.mimeType = stringOrNull(params.mimeType ?? params.mime_type);
|
|
579
|
+
this.createdAt = stringOrNull(params.createdAt ?? params.created_at);
|
|
580
|
+
this.createdBy = stringOrNull(params.createdBy ?? params.created_by);
|
|
581
|
+
this.width = numOrNull(params.width);
|
|
582
|
+
this.height = numOrNull(params.height);
|
|
583
|
+
this.status = stringOrNull(params.status);
|
|
584
|
+
}
|
|
585
|
+
static fromJson(json) {
|
|
586
|
+
return new AgentGeneratedImage(json);
|
|
587
|
+
}
|
|
588
|
+
toJson() {
|
|
589
|
+
return omitUndefined({
|
|
590
|
+
uri: this.uri,
|
|
591
|
+
mime_type: this.mimeType,
|
|
592
|
+
created_at: this.createdAt,
|
|
593
|
+
created_by: this.createdBy,
|
|
594
|
+
width: this.width,
|
|
595
|
+
height: this.height,
|
|
596
|
+
status: this.status,
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
exports.AgentGeneratedImage = AgentGeneratedImage;
|
|
601
|
+
class AgentGeneratedAudio {
|
|
602
|
+
constructor(params = {}) {
|
|
603
|
+
this.uri = stringOrNull(params.uri);
|
|
604
|
+
this.mimeType = stringOrNull(params.mimeType ?? params.mime_type);
|
|
605
|
+
this.createdAt = stringOrNull(params.createdAt ?? params.created_at);
|
|
606
|
+
this.createdBy = stringOrNull(params.createdBy ?? params.created_by);
|
|
607
|
+
this.status = stringOrNull(params.status);
|
|
608
|
+
this.transcript = stringOrNull(params.transcript);
|
|
609
|
+
}
|
|
610
|
+
static fromJson(json) {
|
|
611
|
+
return new AgentGeneratedAudio(json);
|
|
612
|
+
}
|
|
613
|
+
toJson() {
|
|
614
|
+
return omitUndefined({
|
|
615
|
+
uri: this.uri,
|
|
616
|
+
mime_type: this.mimeType,
|
|
617
|
+
created_at: this.createdAt,
|
|
618
|
+
created_by: this.createdBy,
|
|
619
|
+
status: this.status,
|
|
620
|
+
transcript: this.transcript,
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
exports.AgentGeneratedAudio = AgentGeneratedAudio;
|
|
625
|
+
class AgentContextWindowUsage {
|
|
626
|
+
constructor(params) {
|
|
627
|
+
this.usedTokens = Number(params.usedTokens ?? params.used_tokens);
|
|
628
|
+
this.totalTokens = intOrNull(params.totalTokens ?? params.total_tokens);
|
|
629
|
+
this.compactionMode = stringOrNull(params.compactionMode ?? params.compaction_mode);
|
|
630
|
+
this.compactionThreshold = intOrNull(params.compactionThreshold ?? params.compaction_threshold);
|
|
631
|
+
}
|
|
632
|
+
static fromJson(json) {
|
|
633
|
+
return new AgentContextWindowUsage({
|
|
634
|
+
usedTokens: requiredInt(json, "used_tokens"),
|
|
635
|
+
totalTokens: intOrNull(json.total_tokens),
|
|
636
|
+
compactionMode: stringOrNull(json.compaction_mode),
|
|
637
|
+
compactionThreshold: intOrNull(json.compaction_threshold),
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
toJson() {
|
|
641
|
+
return omitUndefined({
|
|
642
|
+
used_tokens: this.usedTokens,
|
|
643
|
+
total_tokens: this.totalTokens,
|
|
644
|
+
compaction_mode: this.compactionMode,
|
|
645
|
+
compaction_threshold: this.compactionThreshold,
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
exports.AgentContextWindowUsage = AgentContextWindowUsage;
|
|
650
|
+
function omitUndefined(value) {
|
|
651
|
+
return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== undefined));
|
|
652
|
+
}
|
|
653
|
+
class AgentMessage {
|
|
654
|
+
constructor({ type, messageId, message_id, senderName, sender_name }) {
|
|
655
|
+
this.type = String(type);
|
|
656
|
+
const resolvedMessageId = stringOrNull(messageId ?? message_id)?.trim();
|
|
657
|
+
this.messageId = resolvedMessageId == null || resolvedMessageId.length === 0 ? (0, uuid_1.v4)() : resolvedMessageId;
|
|
658
|
+
this.senderName = stringOrNull(senderName ?? sender_name);
|
|
659
|
+
}
|
|
660
|
+
toJson() {
|
|
661
|
+
return {
|
|
662
|
+
type: this.type,
|
|
663
|
+
message_id: this.messageId,
|
|
664
|
+
...(this.senderName != null ? { sender_name: this.senderName } : {}),
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
static fromJson(json) {
|
|
668
|
+
const type = json.type;
|
|
669
|
+
if (typeof type !== "string" || type.trim() === "") {
|
|
670
|
+
throw new TypeError("missing string field 'type'");
|
|
671
|
+
}
|
|
672
|
+
const ctor = messageConstructors[type];
|
|
673
|
+
if (ctor == null) {
|
|
674
|
+
throw new TypeError(`unsupported agent message type '${type}'`);
|
|
675
|
+
}
|
|
676
|
+
return ctor.fromJson(json);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
exports.AgentMessage = AgentMessage;
|
|
680
|
+
class AgentThreadMessage extends AgentMessage {
|
|
681
|
+
constructor(params) {
|
|
682
|
+
super(params);
|
|
683
|
+
this.threadId = String(paramValue(params, "threadId", "thread_id"));
|
|
684
|
+
}
|
|
685
|
+
toJson() {
|
|
686
|
+
return { ...super.toJson(), thread_id: this.threadId };
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
exports.AgentThreadMessage = AgentThreadMessage;
|
|
690
|
+
class AgentLLMMessage extends AgentThreadMessage {
|
|
691
|
+
constructor(params) {
|
|
692
|
+
super(params);
|
|
693
|
+
this.provider = stringOrNull(params.provider);
|
|
694
|
+
this.model = stringOrNull(params.model);
|
|
695
|
+
}
|
|
696
|
+
toJson() {
|
|
697
|
+
return {
|
|
698
|
+
...super.toJson(),
|
|
699
|
+
...(this.provider != null ? { provider: this.provider } : {}),
|
|
700
|
+
...(this.model != null ? { model: this.model } : {}),
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
exports.AgentLLMMessage = AgentLLMMessage;
|
|
705
|
+
const messageConstructors = {};
|
|
706
|
+
function register(type, ctor) {
|
|
707
|
+
messageConstructors[type] = ctor;
|
|
708
|
+
return ctor;
|
|
709
|
+
}
|
|
710
|
+
function makeMessageClass({ type, base = "message", fields = [], }) {
|
|
711
|
+
const Parent = base === "llm" ? AgentLLMMessage : base === "thread" ? AgentThreadMessage : AgentMessage;
|
|
712
|
+
return register(type, class extends Parent {
|
|
713
|
+
constructor(params = {}) {
|
|
714
|
+
super({ ...params, type });
|
|
715
|
+
for (const field of fields) {
|
|
716
|
+
let value = paramValue(params, field.prop, field.json);
|
|
717
|
+
if (value === undefined && field.default != null) {
|
|
718
|
+
value = field.default(params);
|
|
719
|
+
}
|
|
720
|
+
if (value !== undefined && field.from != null) {
|
|
721
|
+
value = field.from(value, params);
|
|
722
|
+
}
|
|
723
|
+
this[field.prop] = value;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
static fromJson(json) {
|
|
727
|
+
const params = {
|
|
728
|
+
messageId: stringOrNull(json.message_id),
|
|
729
|
+
senderName: stringOrNull(json.sender_name),
|
|
730
|
+
};
|
|
731
|
+
if (base !== "message") {
|
|
732
|
+
params.threadId = requiredString(json, "thread_id");
|
|
733
|
+
}
|
|
734
|
+
if (base === "llm") {
|
|
735
|
+
params.provider = stringOrNull(json.provider);
|
|
736
|
+
params.model = stringOrNull(json.model);
|
|
737
|
+
}
|
|
738
|
+
for (const field of fields) {
|
|
739
|
+
if (field.required) {
|
|
740
|
+
if (field.from != null) {
|
|
741
|
+
params[field.prop] = field.from(json[field.json], json);
|
|
742
|
+
}
|
|
743
|
+
else if (typeof json[field.json] === "string") {
|
|
744
|
+
params[field.prop] = requiredString(json, field.json);
|
|
745
|
+
}
|
|
746
|
+
else if (typeof json[field.json] === "number") {
|
|
747
|
+
params[field.prop] = json[field.json];
|
|
748
|
+
}
|
|
749
|
+
else {
|
|
750
|
+
params[field.prop] = requiredMap(json, field.json);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
else if (hasOwn(json, field.json)) {
|
|
754
|
+
params[field.prop] = field.from != null ? field.from(json[field.json], json) : json[field.json];
|
|
755
|
+
}
|
|
756
|
+
else if (field.default != null) {
|
|
757
|
+
params[field.prop] = field.default(json);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
return new this(params);
|
|
761
|
+
}
|
|
762
|
+
toJson() {
|
|
763
|
+
const json = super.toJson();
|
|
764
|
+
for (const field of fields) {
|
|
765
|
+
const value = this[field.prop];
|
|
766
|
+
if (value === undefined && !field.always) {
|
|
767
|
+
continue;
|
|
768
|
+
}
|
|
769
|
+
if (value === undefined) {
|
|
770
|
+
json[field.json] = value;
|
|
771
|
+
}
|
|
772
|
+
else if (field.to != null) {
|
|
773
|
+
const encoded = field.to(value);
|
|
774
|
+
if (encoded !== undefined || field.always) {
|
|
775
|
+
json[field.json] = encoded;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
else {
|
|
779
|
+
json[field.json] = maybeToJson(value);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
return json;
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
const s = (prop, json = snake(prop), required = false) => ({
|
|
787
|
+
prop,
|
|
788
|
+
json,
|
|
789
|
+
required,
|
|
790
|
+
from: (value) => {
|
|
791
|
+
const parsed = stringOrNull(value);
|
|
792
|
+
if (required && parsed == null) {
|
|
793
|
+
throw new TypeError(`missing string field '${json}'`);
|
|
794
|
+
}
|
|
795
|
+
return parsed;
|
|
796
|
+
},
|
|
797
|
+
});
|
|
798
|
+
const i = (prop, json = snake(prop), required = false) => ({
|
|
799
|
+
prop,
|
|
800
|
+
json,
|
|
801
|
+
required,
|
|
802
|
+
from: (value) => {
|
|
803
|
+
const parsed = intOrNull(value);
|
|
804
|
+
if (required && parsed == null) {
|
|
805
|
+
throw new TypeError(`missing integer field '${json}'`);
|
|
806
|
+
}
|
|
807
|
+
return parsed;
|
|
808
|
+
},
|
|
809
|
+
});
|
|
810
|
+
const n = (prop, json = snake(prop)) => ({ prop, json, from: numOrNull });
|
|
811
|
+
const m = (prop, json = snake(prop), required = false) => ({
|
|
812
|
+
prop,
|
|
813
|
+
json,
|
|
814
|
+
required,
|
|
815
|
+
from: (value) => {
|
|
816
|
+
const parsed = dynamicMapOrNull(value);
|
|
817
|
+
if (required && parsed == null) {
|
|
818
|
+
throw new TypeError(`missing object field '${json}'`);
|
|
819
|
+
}
|
|
820
|
+
return parsed;
|
|
821
|
+
},
|
|
822
|
+
});
|
|
823
|
+
const sl = (prop, json = snake(prop), fallback, always = false) => ({
|
|
824
|
+
prop,
|
|
825
|
+
json,
|
|
826
|
+
from: (value) => fallback == null ? stringListOrNull(value) : stringList(value, fallback),
|
|
827
|
+
default: fallback == null ? undefined : () => [...fallback],
|
|
828
|
+
always,
|
|
829
|
+
});
|
|
830
|
+
const obj = (prop, json, fromJson, required = false) => ({
|
|
831
|
+
prop,
|
|
832
|
+
json,
|
|
833
|
+
required,
|
|
834
|
+
from: (value) => {
|
|
835
|
+
const parsed = objectOrNull(value, fromJson);
|
|
836
|
+
if (required && parsed == null) {
|
|
837
|
+
throw new TypeError(`missing object field '${json}'`);
|
|
838
|
+
}
|
|
839
|
+
return parsed;
|
|
840
|
+
},
|
|
841
|
+
to: maybeToJson,
|
|
842
|
+
});
|
|
843
|
+
const objList = (prop, json, fromJson, always = false) => ({
|
|
844
|
+
prop,
|
|
845
|
+
json,
|
|
846
|
+
from: (value) => objectList(value, fromJson),
|
|
847
|
+
default: always ? () => [] : undefined,
|
|
848
|
+
always,
|
|
849
|
+
to: (value) => value.map(maybeToJson),
|
|
850
|
+
});
|
|
851
|
+
const contentList = (prop = "content", optional = false) => ({
|
|
852
|
+
prop,
|
|
853
|
+
json: "content",
|
|
854
|
+
from: optional ? inputContentListOrNull : inputContentList,
|
|
855
|
+
default: optional ? undefined : () => [],
|
|
856
|
+
always: !optional,
|
|
857
|
+
to: (value) => value.map(contentToJson),
|
|
858
|
+
});
|
|
859
|
+
const bytesField = (prop = "data") => ({
|
|
860
|
+
prop,
|
|
861
|
+
json: prop,
|
|
862
|
+
from: bytesOrEmpty,
|
|
863
|
+
default: () => new Uint8Array(),
|
|
864
|
+
to: (value) => value.length > 0 ? bytesToBase64(value) : undefined,
|
|
865
|
+
});
|
|
866
|
+
const audioFormat = (prop, json = snake(prop), requiredDefault = false) => ({
|
|
867
|
+
prop,
|
|
868
|
+
json,
|
|
869
|
+
from: requiredDefault ? audioFormatOrDefault : audioFormatOrNull,
|
|
870
|
+
default: requiredDefault ? () => new AgentAudioFormat() : undefined,
|
|
871
|
+
always: requiredDefault,
|
|
872
|
+
to: maybeToJson,
|
|
873
|
+
});
|
|
874
|
+
function snake(value) {
|
|
875
|
+
return value.replace(/[A-Z]/g, (match) => `_${match.toLowerCase()}`);
|
|
876
|
+
}
|
|
877
|
+
const turnOptions = [
|
|
878
|
+
s("turnId"),
|
|
879
|
+
contentList("content"),
|
|
880
|
+
s("provider"),
|
|
881
|
+
s("model"),
|
|
882
|
+
s("voice"),
|
|
883
|
+
sl("outputModalities"),
|
|
884
|
+
s("instructions"),
|
|
885
|
+
{ prop: "mcp", json: "mcp", from: turnMcpConfigOrNull, to: maybeToJson },
|
|
886
|
+
objList("clientToolkits", "client_toolkits", ClientToolkitDescription.fromJson),
|
|
887
|
+
{ prop: "toolkits", json: "toolkits", from: toolkitsOrNull, to: toolkitsToJson },
|
|
888
|
+
obj("toolChoice", "tool_choice", ToolChoice.fromJson),
|
|
889
|
+
];
|
|
890
|
+
const contentPart = [s("turnId", "turn_id", true), s("itemId", "item_id", true)];
|
|
891
|
+
const responsePart = [...contentPart, s("responseId"), i("contentIndex")];
|
|
892
|
+
const toolState = [
|
|
893
|
+
...contentPart,
|
|
894
|
+
{ prop: "namespace", json: "namespace", from: (value) => stringOrNull(value) ?? "meshagent", default: () => "meshagent", always: true },
|
|
895
|
+
s("callId"),
|
|
896
|
+
s("toolkit", "toolkit", true),
|
|
897
|
+
s("tool", "tool", true),
|
|
898
|
+
m("arguments"),
|
|
899
|
+
i("argumentBytes"),
|
|
900
|
+
];
|
|
901
|
+
const imageGeneration = [
|
|
902
|
+
...contentPart,
|
|
903
|
+
s("callId"),
|
|
904
|
+
{ prop: "toolkit", json: "toolkit", from: (value) => stringOrNull(value) ?? "image_generation", default: () => "image_generation", always: true },
|
|
905
|
+
{ prop: "tool", json: "tool", from: (value) => stringOrNull(value) ?? "image_generation", default: () => "image_generation", always: true },
|
|
906
|
+
m("arguments"),
|
|
907
|
+
];
|
|
908
|
+
exports.StartThread = makeMessageClass({
|
|
909
|
+
type: exports.agentThreadStartType,
|
|
910
|
+
fields: [
|
|
911
|
+
contentList("content", true),
|
|
912
|
+
s("name"),
|
|
913
|
+
s("realtimeProtocol"),
|
|
914
|
+
s("provider"),
|
|
915
|
+
s("model"),
|
|
916
|
+
s("voice"),
|
|
917
|
+
sl("outputModalities"),
|
|
918
|
+
s("instructions"),
|
|
919
|
+
{ prop: "mcp", json: "mcp", from: turnMcpConfigOrNull, to: maybeToJson },
|
|
920
|
+
objList("clientToolkits", "client_toolkits", ClientToolkitDescription.fromJson),
|
|
921
|
+
{ prop: "toolkits", json: "toolkits", from: toolkitsOrNull, to: toolkitsToJson },
|
|
922
|
+
obj("toolChoice", "tool_choice", ToolChoice.fromJson),
|
|
923
|
+
],
|
|
924
|
+
});
|
|
925
|
+
exports.TurnStart = makeMessageClass({ type: exports.agentTurnStartType, base: "thread", fields: turnOptions });
|
|
926
|
+
exports.TurnSteer = makeMessageClass({ type: exports.agentTurnSteerType, base: "thread", fields: [s("turnId", "turn_id", true), contentList("content")] });
|
|
927
|
+
exports.TurnInterrupt = makeMessageClass({ type: exports.agentTurnInterruptType, base: "thread", fields: [s("turnId", "turn_id", true)] });
|
|
928
|
+
exports.AgentRealtimeAudioChunk = makeMessageClass({ type: exports.agentRealtimeAudioChunkType, base: "thread", fields: [bytesField("data"), audioFormat("format", "format", true)] });
|
|
929
|
+
exports.AgentRealtimeAudioCommit = makeMessageClass({ type: exports.agentRealtimeAudioCommitType, base: "thread", fields: [s("turnId"), s("text"), s("status"), s("transcriptionItemId")] });
|
|
930
|
+
exports.ClearThread = makeMessageClass({ type: exports.agentThreadClearType, base: "thread" });
|
|
931
|
+
exports.OpenThread = makeMessageClass({ type: exports.agentThreadOpenType, base: "thread", fields: [{ prop: "load", json: "load", from: (value) => typeof value === "boolean" ? value : undefined }, s("sinceTurn")] });
|
|
932
|
+
exports.CloseThread = makeMessageClass({ type: exports.agentThreadCloseType, base: "thread" });
|
|
933
|
+
exports.ParticipantConnect = makeMessageClass({ type: exports.agentParticipantConnectType, fields: [s("participantId"), s("participantName"), m("attributes")] });
|
|
934
|
+
exports.ParticipantDisconnect = makeMessageClass({ type: exports.agentParticipantDisconnectType, fields: [s("participantId"), s("participantName"), s("reason")] });
|
|
935
|
+
exports.DeleteThread = makeMessageClass({ type: exports.agentThreadDeleteType, base: "thread" });
|
|
936
|
+
exports.RenameThread = makeMessageClass({ type: exports.agentThreadRenameType, base: "thread", fields: [s("name", "name", true)] });
|
|
937
|
+
exports.ListThreads = makeMessageClass({ 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 }] });
|
|
938
|
+
exports.ThreadsListed = makeMessageClass({ type: exports.agentThreadListedType, fields: [s("sourceMessageId", "source_message_id", true), objList("threads", "threads", AgentThreadListEntry.fromJson, true), i("total"), i("offset"), i("limit")] });
|
|
939
|
+
exports.ThreadCreated = makeMessageClass({ type: exports.agentThreadCreatedType, fields: [obj("thread", "thread", AgentThreadListEntry.fromJson, true)] });
|
|
940
|
+
exports.ThreadUpdated = makeMessageClass({ type: exports.agentThreadUpdatedType, fields: [obj("thread", "thread", AgentThreadListEntry.fromJson, true)] });
|
|
941
|
+
exports.ThreadDeleted = makeMessageClass({ type: exports.agentThreadDeletedType, fields: [s("path", "path", true)] });
|
|
942
|
+
exports.CapabilitiesRequest = makeMessageClass({ type: exports.agentCapabilitiesRequestType, base: "thread" });
|
|
943
|
+
exports.CapabilitiesResponse = makeMessageClass({ type: exports.agentCapabilitiesResponseType, base: "thread", fields: [s("sourceMessageId", "source_message_id", true), s("version", "version", true), objList("toolkits", "toolkits", ToolkitCapabilities.fromJson, true)] });
|
|
944
|
+
exports.ModelsRequest = makeMessageClass({ type: exports.agentModelsRequestType });
|
|
945
|
+
exports.ModelsResponse = makeMessageClass({ type: exports.agentModelsResponseType, fields: [s("sourceMessageId", "source_message_id", true), objList("providers", "providers", AgentProviderInfo.fromJson, true)] });
|
|
946
|
+
exports.ChangeModel = makeMessageClass({ type: exports.agentModelChangeType, base: "thread", fields: [s("provider"), s("model"), s("voice")] });
|
|
947
|
+
exports.AgentModelChanged = makeMessageClass({ type: exports.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)] });
|
|
948
|
+
exports.ThreadCleared = makeMessageClass({ type: exports.agentThreadClearedType, base: "thread", fields: [s("sourceMessageId", "source_message_id", true)] });
|
|
949
|
+
exports.TurnStartAccepted = makeMessageClass({ type: exports.agentTurnStartAcceptedType, base: "thread", fields: [s("turnId"), s("sourceMessageId", "source_message_id", true), contentList("content")] });
|
|
950
|
+
exports.TurnStartRejected = makeMessageClass({ type: exports.agentTurnStartRejectedType, base: "thread", fields: [s("sourceMessageId", "source_message_id", true), obj("error", "error", AgentError.fromJson, true)] });
|
|
951
|
+
exports.TurnInterruptAccepted = makeMessageClass({ type: exports.agentTurnInterruptAcceptedType, base: "thread", fields: [s("turnId", "turn_id", true), s("sourceMessageId", "source_message_id", true)] });
|
|
952
|
+
exports.TurnInterrupted = makeMessageClass({ type: exports.agentTurnInterruptedType, base: "thread", fields: [s("turnId", "turn_id", true), s("sourceMessageId", "source_message_id", true)] });
|
|
953
|
+
exports.TurnSteerAccepted = makeMessageClass({ type: exports.agentTurnSteerAcceptedType, base: "thread", fields: [s("turnId", "turn_id", true), s("sourceMessageId", "source_message_id", true), contentList("content")] });
|
|
954
|
+
exports.TurnSteered = makeMessageClass({ type: exports.agentTurnSteeredType, base: "thread", fields: [s("turnId", "turn_id", true), s("sourceMessageId", "source_message_id", true)] });
|
|
955
|
+
exports.TurnSteerRejected = makeMessageClass({ type: exports.agentTurnSteerRejectedType, base: "thread", fields: [s("turnId", "turn_id", true), s("sourceMessageId", "source_message_id", true), obj("error", "error", AgentError.fromJson, true)] });
|
|
956
|
+
exports.TurnStarted = makeMessageClass({ type: exports.agentTurnStartedType, base: "thread", fields: [s("turnId", "turn_id", true), s("sourceMessageId", "source_message_id", true)] });
|
|
957
|
+
exports.TurnEnded = makeMessageClass({ type: exports.agentTurnEndedType, base: "thread", fields: [s("turnId", "turn_id", true), obj("error", "error", AgentError.fromJson)] });
|
|
958
|
+
exports.ThreadStarted = makeMessageClass({ type: exports.agentThreadStartedType, fields: [s("sourceMessageId", "source_message_id", true), s("threadId", "thread_id", true), obj("realtimeConnection", "realtime_connection", AgentRealtimeConnectionInfo.fromJson)] });
|
|
959
|
+
exports.ThreadLoaded = makeMessageClass({ type: exports.agentThreadLoadedType, base: "thread", fields: [s("sourceMessageId"), s("sinceTurn")] });
|
|
960
|
+
exports.ThreadStartRejected = makeMessageClass({ type: exports.agentThreadStartRejectedType, fields: [s("sourceMessageId", "source_message_id", true), obj("error", "error", AgentError.fromJson, true)] });
|
|
961
|
+
exports.AgentReasoningContentStarted = makeMessageClass({ type: exports.agentReasoningContentStartedType, base: "llm", fields: contentPart });
|
|
962
|
+
exports.AgentReasoningContentDelta = makeMessageClass({ type: exports.agentReasoningContentDeltaType, base: "llm", fields: [...contentPart, s("text", "text", true)] });
|
|
963
|
+
exports.AgentReasoningContentEnded = makeMessageClass({ type: exports.agentReasoningContentEndedType, base: "llm", fields: contentPart });
|
|
964
|
+
exports.AgentTextContentStarted = makeMessageClass({ type: exports.agentTextContentStartedType, base: "llm", fields: [...contentPart, s("phase")] });
|
|
965
|
+
exports.AgentTextContentDelta = makeMessageClass({ type: exports.agentTextContentDeltaType, base: "llm", fields: [...contentPart, s("phase"), s("text", "text", true)] });
|
|
966
|
+
exports.AgentTextContentEnded = makeMessageClass({ type: exports.agentTextContentEndedType, base: "llm", fields: [...contentPart, s("phase")] });
|
|
967
|
+
exports.AgentFileContentStarted = makeMessageClass({ type: exports.agentFileContentStartedType, base: "llm", fields: contentPart });
|
|
968
|
+
exports.AgentFileContentDelta = makeMessageClass({ type: exports.agentFileContentDeltaType, base: "llm", fields: [...contentPart, s("url", "url", true)] });
|
|
969
|
+
exports.AgentFileContentEnded = makeMessageClass({ type: exports.agentFileContentEndedType, base: "llm", fields: contentPart });
|
|
970
|
+
exports.AgentToolCallPending = makeMessageClass({ type: exports.agentToolCallPendingType, base: "llm", fields: toolState });
|
|
971
|
+
exports.AgentToolCallInProgress = makeMessageClass({ type: exports.agentToolCallInProgressType, base: "llm", fields: toolState });
|
|
972
|
+
exports.AgentToolCallStarted = makeMessageClass({ type: exports.agentToolCallStartedType, base: "llm", fields: toolState });
|
|
973
|
+
exports.AgentToolCallArgumentsDelta = makeMessageClass({ 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)] });
|
|
974
|
+
exports.AgentToolCallLogDelta = makeMessageClass({ type: exports.agentToolCallLogDeltaType, base: "llm", fields: [...contentPart, { prop: "namespace", json: "namespace", from: (value) => stringOrNull(value) ?? "meshagent", default: () => "meshagent", always: true }, s("callId"), objList("lines", "lines", AgentToolCallLogLine.fromJson, true)] });
|
|
975
|
+
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)] });
|
|
976
|
+
exports.AgentToolCallApprovalRequested = makeMessageClass({ type: exports.agentToolCallApprovalRequestedType, base: "llm", fields: toolState.filter((field) => field.prop !== "argumentBytes") });
|
|
977
|
+
exports.AgentSecretRequested = makeMessageClass({ type: exports.agentSecretRequestedType, base: "llm", fields: [...contentPart, s("requestId", "request_id", true), s("name", "name", true), s("scope")] });
|
|
978
|
+
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)] });
|
|
979
|
+
exports.AgentClientToolCallCancelled = makeMessageClass({ type: exports.agentClientToolCallCancelledType, base: "llm", fields: [...contentPart, s("requestId", "request_id", true), s("reason")] });
|
|
980
|
+
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")] });
|
|
981
|
+
exports.AgentConnectionStatus = makeMessageClass({ type: exports.agentConnectionStatusType, fields: [s("status", "status", true), s("message"), s("reason"), n("retryInSeconds")] });
|
|
982
|
+
exports.AgentThreadEvent = makeMessageClass({ type: exports.agentThreadEventType, base: "llm", fields: [m("event", "event", true)] });
|
|
983
|
+
exports.AgentImageGenerationStarted = makeMessageClass({ type: exports.agentImageGenerationStartedType, base: "llm", fields: imageGeneration });
|
|
984
|
+
exports.AgentImageGenerationPartial = makeMessageClass({ type: exports.agentImageGenerationPartialType, base: "llm", fields: [...imageGeneration, obj("image", "image", AgentGeneratedImage.fromJson), i("partialIndex")] });
|
|
985
|
+
exports.AgentImageGenerationCompleted = makeMessageClass({ type: exports.agentImageGenerationCompletedType, base: "llm", fields: [...imageGeneration, objList("images", "images", AgentGeneratedImage.fromJson, true)] });
|
|
986
|
+
exports.AgentImageGenerationFailed = makeMessageClass({ type: exports.agentImageGenerationFailedType, base: "llm", fields: [...imageGeneration, obj("error", "error", AgentError.fromJson)] });
|
|
987
|
+
exports.AgentAudioGenerationStarted = makeMessageClass({ type: exports.agentAudioGenerationStartedType, base: "llm", fields: responsePart });
|
|
988
|
+
exports.AgentAudioGenerationDelta = makeMessageClass({ type: exports.agentAudioGenerationDeltaType, base: "llm", fields: [...responsePart, bytesField("data"), s("mimeType"), audioFormat("outputFormat")] });
|
|
989
|
+
exports.AgentAudioGenerationCompleted = makeMessageClass({ type: exports.agentAudioGenerationCompletedType, base: "llm", fields: [...responsePart, obj("audio", "audio", AgentGeneratedAudio.fromJson), audioFormat("outputFormat")] });
|
|
990
|
+
exports.AgentAudioGenerationFailed = makeMessageClass({ type: exports.agentAudioGenerationFailedType, base: "llm", fields: [...responsePart, obj("error", "error", AgentError.fromJson)] });
|
|
991
|
+
exports.AgentAudioTranscriptionStarted = makeMessageClass({ type: exports.agentAudioTranscriptionStartedType, base: "llm", fields: [...responsePart, s("role")] });
|
|
992
|
+
exports.AgentAudioTranscriptionDelta = makeMessageClass({ type: exports.agentAudioTranscriptionDeltaType, base: "llm", fields: [...responsePart, s("role"), s("text", "text", true)] });
|
|
993
|
+
exports.AgentAudioTranscriptionCompleted = makeMessageClass({ type: exports.agentAudioTranscriptionCompletedType, base: "llm", fields: [...responsePart, s("role"), s("text")] });
|
|
994
|
+
exports.AgentAudioTranscriptionFailed = makeMessageClass({ type: exports.agentAudioTranscriptionFailedType, base: "llm", fields: [...responsePart, s("role"), obj("error", "error", AgentError.fromJson)] });
|
|
995
|
+
exports.AgentAudioInputSpeechStarted = makeMessageClass({ type: exports.agentAudioInputSpeechStartedType, base: "thread", fields: [s("turnId", "turn_id", true), s("itemId"), i("audioStartMs")] });
|
|
996
|
+
exports.AgentAudioInputSpeechEnded = makeMessageClass({ type: exports.agentAudioInputSpeechEndedType, base: "thread", fields: [s("turnId", "turn_id", true), s("itemId"), i("audioEndMs")] });
|
|
997
|
+
exports.AgentContextCompacted = makeMessageClass({ 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 }] });
|
|
998
|
+
exports.AgentUsageUpdated = makeMessageClass({ type: exports.agentUsageUpdatedType, base: "thread", fields: [s("turnId"), { prop: "usage", json: "usage", from: doubleMap, default: () => ({}), always: true }, obj("contextWindow", "context_window", AgentContextWindowUsage.fromJson, true)] });
|
|
999
|
+
exports.ApproveAgentToolCall = makeMessageClass({ type: exports.agentToolApproveType, base: "thread", fields: [s("turnId", "turn_id", true), s("itemId", "item_id", true)] });
|
|
1000
|
+
exports.RejectAgentToolCall = makeMessageClass({ type: exports.agentToolRejectType, base: "thread", fields: [s("turnId", "turn_id", true), s("itemId", "item_id", true)] });
|
|
1001
|
+
exports.AgentSecretResponse = makeMessageClass({ type: exports.agentSecretResponseType, base: "thread", fields: [s("turnId", "turn_id", true), s("requestId", "request_id", true), s("value"), obj("error", "error", AgentError.fromJson)] });
|
|
1002
|
+
exports.AgentClientToolCallResponse = makeMessageClass({ type: exports.agentClientToolCallResponseType, base: "thread", fields: [s("turnId", "turn_id", true), s("requestId", "request_id", true), { prop: "response", json: "response", from: contentOrNull, to: contentHeader }] });
|
|
1003
|
+
function agentInputContent({ text, attachments }) {
|
|
1004
|
+
const content = [];
|
|
1005
|
+
if (text.trim() !== "") {
|
|
1006
|
+
content.push({ type: "text", text });
|
|
1007
|
+
}
|
|
1008
|
+
for (const attachment of attachments) {
|
|
1009
|
+
const normalized = attachment.trim();
|
|
1010
|
+
if (normalized !== "") {
|
|
1011
|
+
content.push({ type: "file", url: normalized });
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
return content;
|
|
1015
|
+
}
|