@anvia/client 1.5.0 → 1.7.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/README.md +28 -0
- package/dist/durable-chat.d.ts +51 -0
- package/dist/durable-chat.d.ts.map +1 -0
- package/dist/durable-chat.js +933 -0
- package/dist/durable-chat.js.map +1 -0
- package/dist/durable.d.ts +71 -65
- package/dist/durable.d.ts.map +1 -0
- package/dist/durable.js +213 -253
- package/dist/durable.js.map +1 -1
- package/dist/event-transport-CcP1zaST.js +103 -0
- package/dist/event-transport-CcP1zaST.js.map +1 -0
- package/dist/event-transport-rXxwo4BK.d.ts +88 -0
- package/dist/event-transport-rXxwo4BK.d.ts.map +1 -0
- package/dist/index.d.ts +62 -415
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1968 -2382
- package/dist/index.js.map +1 -1
- package/dist/streams-BXxF27Hp.js +156 -0
- package/dist/streams-BXxF27Hp.js.map +1 -0
- package/dist/transport/index.d.ts +2 -91
- package/dist/transport/index.js +3 -23
- package/dist/types-Bt4tUcST.d.ts +348 -0
- package/dist/types-Bt4tUcST.d.ts.map +1 -0
- package/dist/types-CqJxMo_1.js +466 -0
- package/dist/types-CqJxMo_1.js.map +1 -0
- package/package.json +11 -7
- package/dist/chunk-PD72KNCV.js +0 -150
- package/dist/chunk-PD72KNCV.js.map +0 -1
- package/dist/chunk-RK5U6WVJ.js +0 -127
- package/dist/chunk-RK5U6WVJ.js.map +0 -1
- package/dist/transport/index.js.map +0 -1
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
import { getAssistantGenerationMetadata, isJsonValue } from "@anvia/core/completion";
|
|
2
|
+
// src/messages.ts
|
|
3
|
+
function uiMessagesToMessages(messages) {
|
|
4
|
+
const result = [];
|
|
5
|
+
for (const message of messages) {
|
|
6
|
+
assertMetadata(message.metadata);
|
|
7
|
+
if (message.role === "system") {
|
|
8
|
+
assertOnlyParts(message, [
|
|
9
|
+
"text",
|
|
10
|
+
"data",
|
|
11
|
+
"error"
|
|
12
|
+
]);
|
|
13
|
+
result.push({
|
|
14
|
+
role: "system",
|
|
15
|
+
content: textFromParts(message.parts),
|
|
16
|
+
...metadataField(message.metadata)
|
|
17
|
+
});
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (message.role === "user") {
|
|
21
|
+
assertOnlyParts(message, [
|
|
22
|
+
"text",
|
|
23
|
+
"attachment",
|
|
24
|
+
"data",
|
|
25
|
+
"error"
|
|
26
|
+
]);
|
|
27
|
+
const content = [];
|
|
28
|
+
for (const part of message.parts) if (part.type === "text") content.push(textContent(part.text, part.signature));
|
|
29
|
+
else if (part.type === "attachment") content.push(attachmentToUserContent(part.attachment));
|
|
30
|
+
result.push({
|
|
31
|
+
role: "user",
|
|
32
|
+
content,
|
|
33
|
+
...metadataField(message.metadata)
|
|
34
|
+
});
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (message.role === "assistant") {
|
|
38
|
+
assertOnlyParts(message, [
|
|
39
|
+
"text",
|
|
40
|
+
"reasoning",
|
|
41
|
+
"tool",
|
|
42
|
+
"attachment",
|
|
43
|
+
"source",
|
|
44
|
+
"data",
|
|
45
|
+
"error"
|
|
46
|
+
]);
|
|
47
|
+
const content = [];
|
|
48
|
+
const toolResults = [];
|
|
49
|
+
for (const part of message.parts) if (part.type === "text") content.push(textContent(part.text, part.signature));
|
|
50
|
+
else if (part.type === "reasoning") {
|
|
51
|
+
let reasoning = {
|
|
52
|
+
type: "reasoning",
|
|
53
|
+
text: part.text
|
|
54
|
+
};
|
|
55
|
+
if (part.reasoningId !== void 0) reasoning = {
|
|
56
|
+
...reasoning,
|
|
57
|
+
id: part.reasoningId
|
|
58
|
+
};
|
|
59
|
+
if (part.content !== void 0) reasoning = {
|
|
60
|
+
...reasoning,
|
|
61
|
+
details: part.content
|
|
62
|
+
};
|
|
63
|
+
content.push(reasoning);
|
|
64
|
+
} else if (part.type === "tool") {
|
|
65
|
+
assertReplayableToolPart(part);
|
|
66
|
+
let toolCall = {
|
|
67
|
+
type: "tool-call",
|
|
68
|
+
toolCallId: part.toolCallId,
|
|
69
|
+
toolName: part.toolName,
|
|
70
|
+
input: part.input
|
|
71
|
+
};
|
|
72
|
+
if (part.callId !== void 0) toolCall = {
|
|
73
|
+
...toolCall,
|
|
74
|
+
callId: part.callId
|
|
75
|
+
};
|
|
76
|
+
if (part.signature !== void 0) toolCall = {
|
|
77
|
+
...toolCall,
|
|
78
|
+
signature: part.signature
|
|
79
|
+
};
|
|
80
|
+
content.push(toolCall);
|
|
81
|
+
if (part.state === "output-available" || part.state === "error") toolResults.push(toolResultFromPart(part));
|
|
82
|
+
} else if (part.type === "attachment") content.push(attachmentToAssistantContent(part.attachment));
|
|
83
|
+
let assistant = {
|
|
84
|
+
role: "assistant",
|
|
85
|
+
content,
|
|
86
|
+
...metadataField(message.metadata)
|
|
87
|
+
};
|
|
88
|
+
if (message.modelMessageId !== void 0) assistant = {
|
|
89
|
+
...assistant,
|
|
90
|
+
id: message.modelMessageId
|
|
91
|
+
};
|
|
92
|
+
result.push(assistant);
|
|
93
|
+
if (toolResults.length > 0) result.push({
|
|
94
|
+
role: "tool",
|
|
95
|
+
content: toolResults
|
|
96
|
+
});
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
assertOnlyParts(message, [
|
|
100
|
+
"tool",
|
|
101
|
+
"data",
|
|
102
|
+
"error"
|
|
103
|
+
]);
|
|
104
|
+
const content = [];
|
|
105
|
+
for (const part of message.parts) {
|
|
106
|
+
if (part.type !== "tool") continue;
|
|
107
|
+
assertToolResultPart(part);
|
|
108
|
+
content.push(toolResultFromPart(part));
|
|
109
|
+
}
|
|
110
|
+
result.push({
|
|
111
|
+
role: "tool",
|
|
112
|
+
content,
|
|
113
|
+
...metadataField(message.metadata)
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
function messagesToUIMessages(messages) {
|
|
119
|
+
const result = [];
|
|
120
|
+
const byToolCallId = /* @__PURE__ */ new Map();
|
|
121
|
+
const byCallId = /* @__PURE__ */ new Map();
|
|
122
|
+
for (const message of messages) {
|
|
123
|
+
assertMetadata(message.metadata);
|
|
124
|
+
if (message.role === "system") {
|
|
125
|
+
result.push({
|
|
126
|
+
id: createId("msg"),
|
|
127
|
+
role: "system",
|
|
128
|
+
parts: [{
|
|
129
|
+
id: createId("part"),
|
|
130
|
+
type: "text",
|
|
131
|
+
text: message.content
|
|
132
|
+
}],
|
|
133
|
+
...metadataField(message.metadata)
|
|
134
|
+
});
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (message.role === "user") {
|
|
138
|
+
const parts = (typeof message.content === "string" ? [{
|
|
139
|
+
type: "text",
|
|
140
|
+
text: message.content
|
|
141
|
+
}] : message.content).map((part) => contentToUIMessagePart(part));
|
|
142
|
+
result.push({
|
|
143
|
+
id: createId("msg"),
|
|
144
|
+
role: "user",
|
|
145
|
+
parts,
|
|
146
|
+
...metadataField(message.metadata)
|
|
147
|
+
});
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (message.role === "assistant") {
|
|
151
|
+
const generationMetadata = getAssistantGenerationMetadata(message);
|
|
152
|
+
const parts = (typeof message.content === "string" ? [{
|
|
153
|
+
type: "text",
|
|
154
|
+
text: message.content
|
|
155
|
+
}] : message.content).map(assistantContentToUIMessagePart);
|
|
156
|
+
for (const source of generationMetadata?.sources ?? []) parts.push({
|
|
157
|
+
id: createId("source"),
|
|
158
|
+
type: "source",
|
|
159
|
+
source
|
|
160
|
+
});
|
|
161
|
+
let uiMessage = {
|
|
162
|
+
id: createId("msg"),
|
|
163
|
+
role: "assistant",
|
|
164
|
+
parts,
|
|
165
|
+
...metadataField(message.metadata)
|
|
166
|
+
};
|
|
167
|
+
if (generationMetadata !== void 0) {
|
|
168
|
+
const generation = { usage: generationMetadata.usage };
|
|
169
|
+
if (generationMetadata.contextUsage !== void 0) generation.contextUsage = generationMetadata.contextUsage;
|
|
170
|
+
uiMessage = {
|
|
171
|
+
...uiMessage,
|
|
172
|
+
generation
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
if (message.id !== void 0) uiMessage = {
|
|
176
|
+
...uiMessage,
|
|
177
|
+
modelMessageId: message.id
|
|
178
|
+
};
|
|
179
|
+
const messageIndex = result.length;
|
|
180
|
+
result.push(uiMessage);
|
|
181
|
+
for (const [partIndex, part] of parts.entries()) {
|
|
182
|
+
if (part.type !== "tool") continue;
|
|
183
|
+
const location = {
|
|
184
|
+
messageIndex,
|
|
185
|
+
partIndex
|
|
186
|
+
};
|
|
187
|
+
byToolCallId.set(part.toolCallId, location);
|
|
188
|
+
if (part.callId !== void 0) byCallId.set(part.callId, location);
|
|
189
|
+
}
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
const unmerged = [];
|
|
193
|
+
for (const content of message.content) {
|
|
194
|
+
if (content.type !== "tool-result") continue;
|
|
195
|
+
const location = (content.callId === void 0 ? void 0 : byCallId.get(content.callId)) ?? byToolCallId.get(content.toolCallId);
|
|
196
|
+
const ownerPart = toolPartAt(result, location);
|
|
197
|
+
if (ownerPart === void 0 || ownerPart.state === "input-streaming") throw new TypeError(`Tool result "${content.toolCallId}" requires a matching completed tool call.`);
|
|
198
|
+
const part = toolResultToUIMessagePart(content, ownerPart.toolName, ownerPart.input);
|
|
199
|
+
if (message.metadata === void 0 && location !== void 0) {
|
|
200
|
+
const owner = result[location.messageIndex];
|
|
201
|
+
const existing = owner?.parts[location.partIndex];
|
|
202
|
+
if (owner !== void 0 && existing?.type === "tool") {
|
|
203
|
+
const parts = [...owner.parts];
|
|
204
|
+
parts[location.partIndex] = {
|
|
205
|
+
...existing,
|
|
206
|
+
...part,
|
|
207
|
+
id: existing.id
|
|
208
|
+
};
|
|
209
|
+
result[location.messageIndex] = {
|
|
210
|
+
...owner,
|
|
211
|
+
parts
|
|
212
|
+
};
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
unmerged.push(part);
|
|
217
|
+
}
|
|
218
|
+
if (unmerged.length > 0 || message.metadata !== void 0) result.push({
|
|
219
|
+
id: createId("msg"),
|
|
220
|
+
role: "tool",
|
|
221
|
+
parts: unmerged,
|
|
222
|
+
...metadataField(message.metadata)
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
function contentToUIMessagePart(content) {
|
|
228
|
+
if (content.type === "text") {
|
|
229
|
+
const part = {
|
|
230
|
+
id: createId("part"),
|
|
231
|
+
type: "text",
|
|
232
|
+
text: content.text
|
|
233
|
+
};
|
|
234
|
+
if (content.signature !== void 0) part.signature = content.signature;
|
|
235
|
+
return part;
|
|
236
|
+
}
|
|
237
|
+
return {
|
|
238
|
+
id: createId("part"),
|
|
239
|
+
type: "attachment",
|
|
240
|
+
attachment: contentToAttachment(content)
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
function assistantContentToUIMessagePart(content) {
|
|
244
|
+
if (content.type === "text") return contentToUIMessagePart(content);
|
|
245
|
+
if (content.type === "reasoning") {
|
|
246
|
+
const part = {
|
|
247
|
+
id: createId("part"),
|
|
248
|
+
type: "reasoning",
|
|
249
|
+
text: content.text
|
|
250
|
+
};
|
|
251
|
+
if (content.id !== void 0) part.reasoningId = content.id;
|
|
252
|
+
if (content.details !== void 0) part.content = content.details;
|
|
253
|
+
return part;
|
|
254
|
+
}
|
|
255
|
+
if (content.type === "tool-call") {
|
|
256
|
+
const part = {
|
|
257
|
+
id: toolPartId(content.toolCallId),
|
|
258
|
+
type: "tool",
|
|
259
|
+
toolName: content.toolName,
|
|
260
|
+
toolCallId: content.toolCallId,
|
|
261
|
+
state: "input-available",
|
|
262
|
+
input: content.input
|
|
263
|
+
};
|
|
264
|
+
if (content.callId !== void 0) part.callId = content.callId;
|
|
265
|
+
if (content.signature !== void 0) part.signature = content.signature;
|
|
266
|
+
return part;
|
|
267
|
+
}
|
|
268
|
+
return {
|
|
269
|
+
id: createId("part"),
|
|
270
|
+
type: "attachment",
|
|
271
|
+
attachment: contentToAttachment(content)
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
function textContent(text, signature) {
|
|
275
|
+
return signature === void 0 ? {
|
|
276
|
+
type: "text",
|
|
277
|
+
text
|
|
278
|
+
} : {
|
|
279
|
+
type: "text",
|
|
280
|
+
text,
|
|
281
|
+
signature
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
function toolResultFromPart(part) {
|
|
285
|
+
let result = {
|
|
286
|
+
type: "tool-result",
|
|
287
|
+
toolCallId: part.toolCallId,
|
|
288
|
+
toolName: part.toolName,
|
|
289
|
+
output: toolOutputFromPart(part)
|
|
290
|
+
};
|
|
291
|
+
if (part.callId !== void 0) result = {
|
|
292
|
+
...result,
|
|
293
|
+
callId: part.callId
|
|
294
|
+
};
|
|
295
|
+
return result;
|
|
296
|
+
}
|
|
297
|
+
function toolOutputFromPart(part) {
|
|
298
|
+
if (part.state === "error") return {
|
|
299
|
+
type: "error-text",
|
|
300
|
+
value: part.error.message
|
|
301
|
+
};
|
|
302
|
+
if (part.resultContent !== void 0) return {
|
|
303
|
+
type: "content",
|
|
304
|
+
value: part.resultContent
|
|
305
|
+
};
|
|
306
|
+
const output = part.output;
|
|
307
|
+
return typeof output === "string" ? {
|
|
308
|
+
type: "text",
|
|
309
|
+
value: output
|
|
310
|
+
} : {
|
|
311
|
+
type: "json",
|
|
312
|
+
value: output
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
function attachmentToUserContent(attachment) {
|
|
316
|
+
if (attachment.type === "image" || attachment.mediaType?.startsWith("image/") === true) return attachmentToImageContent(attachment);
|
|
317
|
+
return attachmentToFileContent(attachment);
|
|
318
|
+
}
|
|
319
|
+
function attachmentToAssistantContent(attachment) {
|
|
320
|
+
return attachment.type === "image" || attachment.mediaType?.startsWith("image/") === true ? attachmentToImageContent(attachment) : attachmentToFileContent(attachment);
|
|
321
|
+
}
|
|
322
|
+
function attachmentToImageContent(attachment) {
|
|
323
|
+
let content = {
|
|
324
|
+
type: "image",
|
|
325
|
+
image: attachment.url !== void 0 ? {
|
|
326
|
+
type: "url",
|
|
327
|
+
url: attachment.url
|
|
328
|
+
} : attachment.data !== void 0 ? {
|
|
329
|
+
type: "data",
|
|
330
|
+
data: attachment.data
|
|
331
|
+
} : (() => {
|
|
332
|
+
throw new TypeError("Image attachments require a URL or base64 data.");
|
|
333
|
+
})()
|
|
334
|
+
};
|
|
335
|
+
if (attachment.mediaType !== void 0) content = {
|
|
336
|
+
...content,
|
|
337
|
+
mediaType: attachment.mediaType
|
|
338
|
+
};
|
|
339
|
+
if (attachment.detail !== void 0) content = {
|
|
340
|
+
...content,
|
|
341
|
+
detail: attachment.detail
|
|
342
|
+
};
|
|
343
|
+
return content;
|
|
344
|
+
}
|
|
345
|
+
function attachmentToFileContent(attachment) {
|
|
346
|
+
let content = {
|
|
347
|
+
type: "file",
|
|
348
|
+
data: attachment.url !== void 0 ? {
|
|
349
|
+
type: "url",
|
|
350
|
+
url: attachment.url
|
|
351
|
+
} : attachment.data !== void 0 ? {
|
|
352
|
+
type: "data",
|
|
353
|
+
data: attachment.data
|
|
354
|
+
} : attachment.text !== void 0 ? {
|
|
355
|
+
type: "text",
|
|
356
|
+
text: attachment.text
|
|
357
|
+
} : (() => {
|
|
358
|
+
throw new TypeError("File attachments require a URL, base64 data, or text.");
|
|
359
|
+
})(),
|
|
360
|
+
mediaType: attachment.mediaType ?? "application/octet-stream"
|
|
361
|
+
};
|
|
362
|
+
if (attachment.name !== void 0) content = {
|
|
363
|
+
...content,
|
|
364
|
+
filename: attachment.name
|
|
365
|
+
};
|
|
366
|
+
return content;
|
|
367
|
+
}
|
|
368
|
+
function contentToAttachment(content) {
|
|
369
|
+
const attachment = {
|
|
370
|
+
id: createId("attachment"),
|
|
371
|
+
type: content.type === "image" ? "image" : "file"
|
|
372
|
+
};
|
|
373
|
+
if (content.type === "image") {
|
|
374
|
+
if (content.detail !== void 0) attachment.detail = content.detail;
|
|
375
|
+
if (content.mediaType !== void 0) attachment.mediaType = content.mediaType;
|
|
376
|
+
if (content.image.type === "url") attachment.url = content.image.url;
|
|
377
|
+
else attachment.data = content.image.data;
|
|
378
|
+
return attachment;
|
|
379
|
+
}
|
|
380
|
+
attachment.mediaType = content.mediaType;
|
|
381
|
+
if (content.filename !== void 0) attachment.name = content.filename;
|
|
382
|
+
if (content.data.type === "url") attachment.url = content.data.url;
|
|
383
|
+
else if (content.data.type === "data") attachment.data = content.data.data;
|
|
384
|
+
else attachment.text = content.data.text;
|
|
385
|
+
return attachment;
|
|
386
|
+
}
|
|
387
|
+
function toolResultToUIMessagePart(content, fallbackToolName, input) {
|
|
388
|
+
const output = content.output;
|
|
389
|
+
const common = {
|
|
390
|
+
id: toolPartId(content.toolCallId),
|
|
391
|
+
type: "tool",
|
|
392
|
+
toolName: content.toolName || fallbackToolName,
|
|
393
|
+
toolCallId: content.toolCallId,
|
|
394
|
+
input
|
|
395
|
+
};
|
|
396
|
+
if (content.callId !== void 0) Object.assign(common, { callId: content.callId });
|
|
397
|
+
if (output.type === "error-text" || output.type === "error-json") return {
|
|
398
|
+
...common,
|
|
399
|
+
state: "error",
|
|
400
|
+
error: { message: output.type === "error-text" ? output.value : JSON.stringify(output.value) }
|
|
401
|
+
};
|
|
402
|
+
if (output.type === "execution-denied") return {
|
|
403
|
+
...common,
|
|
404
|
+
state: "error",
|
|
405
|
+
error: { message: output.reason ?? "Tool execution was denied." }
|
|
406
|
+
};
|
|
407
|
+
const part = {
|
|
408
|
+
...common,
|
|
409
|
+
state: "output-available",
|
|
410
|
+
output: toolResultOutput(output)
|
|
411
|
+
};
|
|
412
|
+
if (output.type === "content") part.resultContent = output.value;
|
|
413
|
+
return part;
|
|
414
|
+
}
|
|
415
|
+
function toolResultOutput(output) {
|
|
416
|
+
if (output.type === "text" || output.type === "error-text") return output.value;
|
|
417
|
+
if (output.type === "json" || output.type === "error-json") return output.value;
|
|
418
|
+
if (output.type === "execution-denied") return output.reason ?? "Tool execution was denied.";
|
|
419
|
+
return output.value.length === 1 && output.value[0]?.type === "text" ? output.value[0].text : output.value.map((part) => part.type === "text" ? { ...part } : {
|
|
420
|
+
...part,
|
|
421
|
+
data: { ...part.data }
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
function toolPartAt(messages, location) {
|
|
425
|
+
if (location === void 0) return void 0;
|
|
426
|
+
const part = messages[location.messageIndex]?.parts[location.partIndex];
|
|
427
|
+
return part?.type === "tool" ? part : void 0;
|
|
428
|
+
}
|
|
429
|
+
function assertReplayableToolPart(part) {
|
|
430
|
+
if (part.state === "input-streaming") throw new TypeError(`Tool call "${part.toolCallId}" is still streaming and cannot be converted to a model message.`);
|
|
431
|
+
if (!isJsonValue(part.input)) throw new TypeError(`Tool call "${part.toolCallId}" input must be a strict JSON value.`);
|
|
432
|
+
}
|
|
433
|
+
function assertToolResultPart(part) {
|
|
434
|
+
assertReplayableToolPart(part);
|
|
435
|
+
if (part.state === "input-available") throw new TypeError(`Tool message part "${part.toolCallId}" requires an output or execution error.`);
|
|
436
|
+
}
|
|
437
|
+
function textFromParts(parts) {
|
|
438
|
+
return parts.flatMap((part) => part.type === "text" ? [part.text] : []).join("");
|
|
439
|
+
}
|
|
440
|
+
function assertOnlyParts(message, allowed) {
|
|
441
|
+
for (const part of message.parts) if (!allowed.includes(part.type)) throw new TypeError(`${message.role} UI messages cannot contain ${part.type} parts.`);
|
|
442
|
+
}
|
|
443
|
+
function assertMetadata(metadata) {
|
|
444
|
+
if (metadata !== void 0 && (!isJsonValue(metadata) || Array.isArray(metadata))) throw new TypeError("Message metadata must be a strict JSON object.");
|
|
445
|
+
}
|
|
446
|
+
function metadataField(metadata) {
|
|
447
|
+
return metadata === void 0 ? {} : { metadata };
|
|
448
|
+
}
|
|
449
|
+
function toolPartId(toolCallId) {
|
|
450
|
+
return `tool_${toolCallId}`;
|
|
451
|
+
}
|
|
452
|
+
let nextId = 0;
|
|
453
|
+
function createClientId(prefix) {
|
|
454
|
+
const random = globalThis.crypto?.randomUUID?.();
|
|
455
|
+
if (random !== void 0) return `${prefix}_${random}`;
|
|
456
|
+
nextId += 1;
|
|
457
|
+
return `${prefix}_${nextId.toString(36)}`;
|
|
458
|
+
}
|
|
459
|
+
function createId(prefix) {
|
|
460
|
+
return createClientId(prefix);
|
|
461
|
+
}
|
|
462
|
+
// src/types.ts
|
|
463
|
+
const CLIENT_STREAM_PROTOCOL = "anvia.client.v3";
|
|
464
|
+
export { uiMessagesToMessages as i, createClientId as n, messagesToUIMessages as r, CLIENT_STREAM_PROTOCOL as t };
|
|
465
|
+
|
|
466
|
+
//# sourceMappingURL=types-CqJxMo_1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-CqJxMo_1.js","names":[],"sources":["../src/messages.ts","../src/types.ts"],"sourcesContent":["import type {\n AssistantContentPart,\n FilePart,\n ImagePart,\n JsonObject,\n JsonValue,\n Message,\n ToolCallPart,\n ToolResultOutput,\n ToolResultPart,\n UserContentPart,\n} from \"@anvia/core/completion\";\nimport { getAssistantGenerationMetadata, isJsonValue } from \"@anvia/core/completion\";\nimport type {\n ClientDataMap,\n UIAttachment,\n UIMessage,\n UIMessageGeneration,\n UIMessagePart,\n UIToolMessagePart,\n} from \"./types\";\n\ntype ToolLocation = { messageIndex: number; partIndex: number };\n\nexport function uiMessagesToMessages<\n Metadata extends JsonObject = JsonObject,\n Data extends ClientDataMap = ClientDataMap,\n>(messages: readonly UIMessage<Metadata, Data>[]): Message<Metadata>[] {\n const result: Message<Metadata>[] = [];\n\n for (const message of messages) {\n assertMetadata(message.metadata);\n\n if (message.role === \"system\") {\n assertOnlyParts(message, [\"text\", \"data\", \"error\"]);\n result.push({\n role: \"system\",\n content: textFromParts(message.parts),\n ...metadataField(message.metadata),\n });\n continue;\n }\n\n if (message.role === \"user\") {\n assertOnlyParts(message, [\"text\", \"attachment\", \"data\", \"error\"]);\n const content: UserContentPart[] = [];\n for (const part of message.parts) {\n if (part.type === \"text\") {\n content.push(textContent(part.text, part.signature));\n } else if (part.type === \"attachment\") {\n content.push(attachmentToUserContent(part.attachment));\n }\n }\n result.push({ role: \"user\", content, ...metadataField(message.metadata) });\n continue;\n }\n\n if (message.role === \"assistant\") {\n assertOnlyParts(message, [\n \"text\",\n \"reasoning\",\n \"tool\",\n \"attachment\",\n \"source\",\n \"data\",\n \"error\",\n ]);\n const content: AssistantContentPart[] = [];\n const toolResults: ToolResultPart[] = [];\n for (const part of message.parts) {\n if (part.type === \"text\") {\n content.push(textContent(part.text, part.signature));\n } else if (part.type === \"reasoning\") {\n let reasoning: Extract<AssistantContentPart, { type: \"reasoning\" }> = {\n type: \"reasoning\",\n text: part.text,\n };\n if (part.reasoningId !== undefined) reasoning = { ...reasoning, id: part.reasoningId };\n if (part.content !== undefined) reasoning = { ...reasoning, details: part.content };\n content.push(reasoning);\n } else if (part.type === \"tool\") {\n assertReplayableToolPart(part);\n let toolCall: ToolCallPart = {\n type: \"tool-call\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n input: part.input,\n };\n if (part.callId !== undefined) toolCall = { ...toolCall, callId: part.callId };\n if (part.signature !== undefined) toolCall = { ...toolCall, signature: part.signature };\n content.push(toolCall);\n if (part.state === \"output-available\" || part.state === \"error\") {\n toolResults.push(toolResultFromPart(part));\n }\n } else if (part.type === \"attachment\") {\n content.push(attachmentToAssistantContent(part.attachment));\n }\n }\n\n let assistant: Extract<Message<Metadata>, { role: \"assistant\" }> = {\n role: \"assistant\",\n content,\n ...metadataField(message.metadata),\n };\n if (message.modelMessageId !== undefined) {\n assistant = { ...assistant, id: message.modelMessageId };\n }\n result.push(assistant);\n if (toolResults.length > 0) {\n result.push({ role: \"tool\", content: toolResults });\n }\n continue;\n }\n\n assertOnlyParts(message, [\"tool\", \"data\", \"error\"]);\n const content: ToolResultPart[] = [];\n for (const part of message.parts) {\n if (part.type !== \"tool\") continue;\n assertToolResultPart(part);\n content.push(toolResultFromPart(part));\n }\n result.push({ role: \"tool\", content, ...metadataField(message.metadata) });\n }\n\n return result;\n}\n\nexport function messagesToUIMessages<Metadata extends JsonObject = JsonObject>(\n messages: readonly Message<Metadata>[],\n): UIMessage<Metadata>[] {\n const result: UIMessage<Metadata>[] = [];\n const byToolCallId = new Map<string, ToolLocation>();\n const byCallId = new Map<string, ToolLocation>();\n\n for (const message of messages) {\n assertMetadata(message.metadata);\n\n if (message.role === \"system\") {\n result.push({\n id: createId(\"msg\"),\n role: \"system\",\n parts: [{ id: createId(\"part\"), type: \"text\", text: message.content }],\n ...metadataField(message.metadata),\n });\n continue;\n }\n\n if (message.role === \"user\") {\n const content =\n typeof message.content === \"string\"\n ? ([{ type: \"text\", text: message.content }] satisfies UserContentPart[])\n : message.content;\n const parts: UIMessagePart[] = content.map((part) => contentToUIMessagePart(part));\n result.push({\n id: createId(\"msg\"),\n role: \"user\",\n parts,\n ...metadataField(message.metadata),\n });\n continue;\n }\n\n if (message.role === \"assistant\") {\n const generationMetadata = getAssistantGenerationMetadata(message);\n const content =\n typeof message.content === \"string\"\n ? ([{ type: \"text\", text: message.content }] satisfies AssistantContentPart[])\n : message.content;\n const parts: UIMessagePart[] = content.map(assistantContentToUIMessagePart);\n for (const source of generationMetadata?.sources ?? []) {\n parts.push({ id: createId(\"source\"), type: \"source\", source });\n }\n let uiMessage: UIMessage<Metadata> = {\n id: createId(\"msg\"),\n role: \"assistant\",\n parts,\n ...metadataField(message.metadata),\n };\n if (generationMetadata !== undefined) {\n const generation: UIMessageGeneration = { usage: generationMetadata.usage };\n if (generationMetadata.contextUsage !== undefined) {\n generation.contextUsage = generationMetadata.contextUsage;\n }\n uiMessage = {\n ...uiMessage,\n generation,\n };\n }\n if (message.id !== undefined) uiMessage = { ...uiMessage, modelMessageId: message.id };\n const messageIndex = result.length;\n result.push(uiMessage);\n for (const [partIndex, part] of parts.entries()) {\n if (part.type !== \"tool\") continue;\n const location = { messageIndex, partIndex };\n byToolCallId.set(part.toolCallId, location);\n if (part.callId !== undefined) byCallId.set(part.callId, location);\n }\n continue;\n }\n\n const unmerged: UIToolMessagePart[] = [];\n for (const content of message.content) {\n if (content.type !== \"tool-result\") continue;\n const location =\n (content.callId === undefined ? undefined : byCallId.get(content.callId)) ??\n byToolCallId.get(content.toolCallId);\n const ownerPart = toolPartAt(result, location);\n if (ownerPart === undefined || ownerPart.state === \"input-streaming\") {\n throw new TypeError(\n `Tool result \"${content.toolCallId}\" requires a matching completed tool call.`,\n );\n }\n const part = toolResultToUIMessagePart(content, ownerPart.toolName, ownerPart.input);\n\n if (message.metadata === undefined && location !== undefined) {\n const owner = result[location.messageIndex];\n const existing = owner?.parts[location.partIndex];\n if (owner !== undefined && existing?.type === \"tool\") {\n const parts = [...owner.parts];\n parts[location.partIndex] = { ...existing, ...part, id: existing.id };\n result[location.messageIndex] = { ...owner, parts };\n continue;\n }\n }\n unmerged.push(part);\n }\n if (unmerged.length > 0 || message.metadata !== undefined) {\n result.push({\n id: createId(\"msg\"),\n role: \"tool\",\n parts: unmerged,\n ...metadataField(message.metadata),\n });\n }\n }\n\n return result;\n}\n\nfunction contentToUIMessagePart(content: UserContentPart): UIMessagePart {\n if (content.type === \"text\") {\n const part: Extract<UIMessagePart, { type: \"text\" }> = {\n id: createId(\"part\"),\n type: \"text\",\n text: content.text,\n };\n if (content.signature !== undefined) part.signature = content.signature;\n return part;\n }\n return {\n id: createId(\"part\"),\n type: \"attachment\",\n attachment: contentToAttachment(content),\n };\n}\n\nfunction assistantContentToUIMessagePart(content: AssistantContentPart): UIMessagePart {\n if (content.type === \"text\") return contentToUIMessagePart(content);\n if (content.type === \"reasoning\") {\n const part: Extract<UIMessagePart, { type: \"reasoning\" }> = {\n id: createId(\"part\"),\n type: \"reasoning\",\n text: content.text,\n };\n if (content.id !== undefined) part.reasoningId = content.id;\n if (content.details !== undefined) part.content = content.details;\n return part;\n }\n if (content.type === \"tool-call\") {\n const part: UIToolMessagePart = {\n id: toolPartId(content.toolCallId),\n type: \"tool\",\n toolName: content.toolName,\n toolCallId: content.toolCallId,\n state: \"input-available\",\n input: content.input,\n };\n if (content.callId !== undefined) part.callId = content.callId;\n if (content.signature !== undefined) part.signature = content.signature;\n return part;\n }\n return {\n id: createId(\"part\"),\n type: \"attachment\",\n attachment: contentToAttachment(content),\n };\n}\n\nfunction textContent(text: string, signature?: string): Extract<UserContentPart, { type: \"text\" }> {\n return signature === undefined ? { type: \"text\", text } : { type: \"text\", text, signature };\n}\n\nfunction toolResultFromPart(\n part: Extract<UIToolMessagePart, { state: \"output-available\" | \"error\" }>,\n): ToolResultPart {\n let result: ToolResultPart = {\n type: \"tool-result\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n output: toolOutputFromPart(part),\n };\n if (part.callId !== undefined) result = { ...result, callId: part.callId };\n return result;\n}\n\nfunction toolOutputFromPart(\n part: Extract<UIToolMessagePart, { state: \"output-available\" | \"error\" }>,\n): ToolResultOutput {\n if (part.state === \"error\") {\n return { type: \"error-text\", value: part.error.message };\n }\n if (part.resultContent !== undefined) {\n return { type: \"content\", value: part.resultContent };\n }\n const output = part.output;\n return typeof output === \"string\"\n ? { type: \"text\", value: output }\n : { type: \"json\", value: output };\n}\n\nfunction attachmentToUserContent(attachment: UIAttachment): UserContentPart {\n if (attachment.type === \"image\" || attachment.mediaType?.startsWith(\"image/\") === true) {\n return attachmentToImageContent(attachment);\n }\n return attachmentToFileContent(attachment);\n}\n\nfunction attachmentToAssistantContent(attachment: UIAttachment): AssistantContentPart {\n return attachment.type === \"image\" || attachment.mediaType?.startsWith(\"image/\") === true\n ? attachmentToImageContent(attachment)\n : attachmentToFileContent(attachment);\n}\n\nfunction attachmentToImageContent(attachment: UIAttachment): ImagePart {\n const image: ImagePart[\"image\"] =\n attachment.url !== undefined\n ? { type: \"url\", url: attachment.url }\n : attachment.data !== undefined\n ? { type: \"data\", data: attachment.data }\n : (() => {\n throw new TypeError(\"Image attachments require a URL or base64 data.\");\n })();\n let content: ImagePart = {\n type: \"image\",\n image,\n };\n if (attachment.mediaType !== undefined) content = { ...content, mediaType: attachment.mediaType };\n if (attachment.detail !== undefined) content = { ...content, detail: attachment.detail };\n return content;\n}\n\nfunction attachmentToFileContent(attachment: UIAttachment): FilePart {\n const data: FilePart[\"data\"] =\n attachment.url !== undefined\n ? { type: \"url\", url: attachment.url }\n : attachment.data !== undefined\n ? { type: \"data\", data: attachment.data }\n : attachment.text !== undefined\n ? { type: \"text\", text: attachment.text }\n : (() => {\n throw new TypeError(\"File attachments require a URL, base64 data, or text.\");\n })();\n let content: FilePart = {\n type: \"file\",\n data,\n mediaType: attachment.mediaType ?? \"application/octet-stream\",\n };\n if (attachment.name !== undefined) content = { ...content, filename: attachment.name };\n return content;\n}\n\nfunction contentToAttachment(content: ImagePart | FilePart): UIAttachment {\n const attachment: UIAttachment = {\n id: createId(\"attachment\"),\n type: content.type === \"image\" ? \"image\" : \"file\",\n };\n if (content.type === \"image\") {\n if (content.detail !== undefined) attachment.detail = content.detail;\n if (content.mediaType !== undefined) attachment.mediaType = content.mediaType;\n if (content.image.type === \"url\") attachment.url = content.image.url;\n else attachment.data = content.image.data;\n return attachment;\n }\n attachment.mediaType = content.mediaType;\n if (content.filename !== undefined) attachment.name = content.filename;\n if (content.data.type === \"url\") attachment.url = content.data.url;\n else if (content.data.type === \"data\") attachment.data = content.data.data;\n else attachment.text = content.data.text;\n return attachment;\n}\n\nfunction toolResultToUIMessagePart(\n content: ToolResultPart,\n fallbackToolName: string,\n input: JsonValue,\n): UIToolMessagePart {\n const output = content.output;\n const common = {\n id: toolPartId(content.toolCallId),\n type: \"tool\" as const,\n toolName: content.toolName || fallbackToolName,\n toolCallId: content.toolCallId,\n input,\n };\n if (content.callId !== undefined) Object.assign(common, { callId: content.callId });\n if (output.type === \"error-text\" || output.type === \"error-json\") {\n return {\n ...common,\n state: \"error\",\n error: {\n message: output.type === \"error-text\" ? output.value : JSON.stringify(output.value),\n },\n };\n }\n if (output.type === \"execution-denied\") {\n return {\n ...common,\n state: \"error\",\n error: { message: output.reason ?? \"Tool execution was denied.\" },\n };\n }\n const part: UIToolMessagePart = {\n ...common,\n state: \"output-available\",\n output: toolResultOutput(output),\n };\n if (output.type === \"content\") part.resultContent = output.value;\n return part;\n}\n\nfunction toolResultOutput(output: ToolResultOutput): JsonValue {\n if (output.type === \"text\" || output.type === \"error-text\") return output.value;\n if (output.type === \"json\" || output.type === \"error-json\") return output.value;\n if (output.type === \"execution-denied\") return output.reason ?? \"Tool execution was denied.\";\n return output.value.length === 1 && output.value[0]?.type === \"text\"\n ? output.value[0].text\n : output.value.map((part) =>\n part.type === \"text\" ? { ...part } : { ...part, data: { ...part.data } },\n );\n}\n\nfunction toolPartAt(\n messages: readonly UIMessage[],\n location: ToolLocation | undefined,\n): UIToolMessagePart | undefined {\n if (location === undefined) return undefined;\n const part = messages[location.messageIndex]?.parts[location.partIndex];\n return part?.type === \"tool\" ? part : undefined;\n}\n\nfunction assertReplayableToolPart(\n part: UIToolMessagePart,\n): asserts part is Exclude<UIToolMessagePart, { state: \"input-streaming\" }> {\n if (part.state === \"input-streaming\") {\n throw new TypeError(\n `Tool call \"${part.toolCallId}\" is still streaming and cannot be converted to a model message.`,\n );\n }\n if (!isJsonValue(part.input)) {\n throw new TypeError(`Tool call \"${part.toolCallId}\" input must be a strict JSON value.`);\n }\n}\n\nfunction assertToolResultPart(\n part: UIToolMessagePart,\n): asserts part is Extract<UIToolMessagePart, { state: \"output-available\" | \"error\" }> {\n assertReplayableToolPart(part);\n if (part.state === \"input-available\") {\n throw new TypeError(\n `Tool message part \"${part.toolCallId}\" requires an output or execution error.`,\n );\n }\n}\n\nfunction textFromParts(parts: readonly UIMessagePart[]): string {\n return parts.flatMap((part) => (part.type === \"text\" ? [part.text] : [])).join(\"\");\n}\n\nfunction assertOnlyParts(\n message: UIMessage<JsonObject, ClientDataMap>,\n allowed: readonly UIMessagePart[\"type\"][],\n): void {\n for (const part of message.parts) {\n if (!allowed.includes(part.type)) {\n throw new TypeError(`${message.role} UI messages cannot contain ${part.type} parts.`);\n }\n }\n}\n\nfunction assertMetadata(metadata: JsonObject | undefined): void {\n if (metadata !== undefined && (!isJsonValue(metadata) || Array.isArray(metadata))) {\n throw new TypeError(\"Message metadata must be a strict JSON object.\");\n }\n}\n\nfunction metadataField<Metadata extends JsonObject>(\n metadata: Metadata | undefined,\n): { metadata?: Metadata } {\n return metadata === undefined ? {} : { metadata };\n}\n\nfunction toolPartId(toolCallId: string): string {\n return `tool_${toolCallId}`;\n}\n\nlet nextId = 0;\n\nexport function createClientId(prefix: string): string {\n const random = globalThis.crypto?.randomUUID?.();\n if (random !== undefined) return `${prefix}_${random}`;\n nextId += 1;\n return `${prefix}_${nextId.toString(36)}`;\n}\n\nfunction createId(prefix: string): string {\n return createClientId(prefix);\n}\n","import type {\n AgentInteractionRequest,\n AgentInteractionResponse,\n} from \"@anvia/core/agent/interactions\";\nimport type {\n CompletionSource,\n ContextUsage,\n ImageDetail,\n JsonObject,\n JsonValue,\n Message,\n ProviderToolCall,\n ReasoningContentType,\n ReasoningDetail,\n ToolResultContentPart,\n Usage,\n} from \"@anvia/core/completion\";\nimport type { GuardrailDecisionRecord } from \"@anvia/core/guardrails\";\nimport type { MemoryCompactionInfo } from \"@anvia/core/memory\";\n\nexport const CLIENT_STREAM_PROTOCOL = \"anvia.client.v3\" as const;\n\nexport type ClientDataMap = Record<string, JsonValue>;\nexport type ClientMetadata = JsonObject;\n\nexport type ClientDataSchema<T extends JsonValue = JsonValue> = {\n safeParse(value: unknown): { success: true; data: T } | { success: false; error?: unknown };\n};\n\nexport type ClientDataSchemas<TData extends ClientDataMap> = {\n [Name in keyof TData]: ClientDataSchema<TData[Name]>;\n};\n\nexport type ClientMetadataSchema<TMetadata extends JsonObject = JsonObject> =\n ClientDataSchema<TMetadata>;\n\nexport type UIMessageRole = \"system\" | \"user\" | \"assistant\" | \"tool\";\n\nexport type ClientStreamError = {\n name?: string;\n message: string;\n code?: string;\n retryable?: boolean;\n details?: JsonValue;\n};\n\nexport type UIError = ClientStreamError;\n\nexport type UIMessageGeneration = {\n runId?: string;\n status?: \"completed\" | \"blocked\" | \"suspended\" | \"cancelled\" | \"error\";\n usage?: Usage;\n contextUsage?: ContextUsage;\n trace?: { observer: string; traceId?: string; observationId?: string };\n memoryCompaction?: MemoryCompactionInfo;\n};\n\nexport type UIMessage<\n Metadata extends JsonObject = JsonObject,\n Data extends ClientDataMap = ClientDataMap,\n> = Readonly<{\n id: string;\n role: UIMessageRole;\n parts: readonly UIMessagePart<Data>[];\n modelMessageId?: string;\n metadata?: Metadata;\n generation?: UIMessageGeneration;\n}>;\n\nexport type UIAttachment = {\n id: string;\n type: \"image\" | \"document\" | \"file\";\n name?: string;\n mediaType?: string;\n url?: string;\n data?: string;\n text?: string;\n detail?: ImageDetail;\n metadata?: JsonValue;\n};\n\nexport type CreateUIAttachment = Omit<UIAttachment, \"id\"> & {\n id?: string;\n};\n\ntype UIDataPart<Data extends ClientDataMap> = {\n [Name in keyof Data & string]: {\n id: string;\n type: \"data\";\n name: Name;\n data: Data[Name];\n };\n}[keyof Data & string];\n\ntype UIToolMessagePartBase = {\n id: string;\n type: \"tool\";\n toolName: string;\n toolCallId: string;\n callId?: string;\n internalCallId?: string;\n turn?: number;\n signature?: string;\n};\n\nexport type UIToolMessagePart =\n | (UIToolMessagePartBase & {\n state: \"input-streaming\";\n input: string;\n })\n | (UIToolMessagePartBase & {\n state: \"input-available\";\n input: JsonValue;\n })\n | (UIToolMessagePartBase & {\n state: \"output-available\";\n input: JsonValue;\n output: JsonValue;\n resultContent?: readonly ToolResultContentPart[];\n })\n | (UIToolMessagePartBase & {\n state: \"error\";\n input: JsonValue;\n error: UIError;\n });\n\nexport type UIMessagePart<Data extends ClientDataMap = ClientDataMap> =\n | {\n id: string;\n type: \"text\";\n text: string;\n signature?: string;\n }\n | {\n id: string;\n type: \"reasoning\";\n text: string;\n reasoningId?: string;\n content?: readonly ReasoningDetail[];\n }\n | UIToolMessagePart\n | {\n id: string;\n type: \"source\";\n source: CompletionSource;\n }\n | UIDataPart<Data>\n | {\n id: string;\n type: \"attachment\";\n attachment: UIAttachment;\n }\n | {\n id: string;\n type: \"error\";\n error: UIError;\n };\n\nexport type ClientStreamCursor = {\n streamId: string;\n after: number;\n};\n\nexport type ClientStreamRequest<Metadata extends JsonObject = JsonObject> =\n | {\n type: \"messages\";\n messages: readonly Message[];\n metadata?: Metadata;\n resume?: ClientStreamCursor;\n }\n | {\n type: \"interaction_response\";\n interactionId: string;\n response: AgentInteractionResponse;\n metadata?: Metadata;\n resume?: ClientStreamCursor;\n };\n\nexport type ClientCompletionRequest<Metadata extends JsonObject = JsonObject> = {\n prompt: string;\n metadata?: Metadata;\n};\n\nexport type ClientStreamScope = {\n agentId?: string;\n agentName?: string;\n parentRunId?: string;\n parentToolName?: string;\n parentToolCallId?: string;\n parentInternalToolCallId?: string;\n};\n\nexport type ClientInteraction = Readonly<{\n request: AgentInteractionRequest;\n runId: string;\n status: \"pending\" | \"responded\" | \"cancelled\";\n}>;\n\ntype ClientStreamEventBase = {\n runId: string;\n turn?: number;\n scope?: ClientStreamScope;\n};\n\ntype ClientDataEvent<TData extends ClientDataMap> = {\n [Name in keyof TData & string]: {\n type: \"data\";\n name: Name;\n data: TData[Name];\n transient?: boolean;\n };\n}[keyof TData & string];\n\ntype ClientStandardStreamEvent<Metadata extends JsonObject, Data extends ClientDataMap> =\n | {\n type: \"run_start\";\n source: \"completion\" | \"agent\";\n metadata?: Metadata;\n }\n | { type: \"turn_start\" }\n | {\n type: \"generation_start\";\n model?: { provider: string; modelId: string };\n }\n | {\n /** Discards an unfinished generation attempt while retaining message identity. */\n type: \"message_reset\";\n messageId: string;\n }\n | {\n type: \"message_start\";\n messageId: string;\n role: \"assistant\";\n metadata?: Metadata;\n }\n | {\n type: \"text_start\";\n messageId: string;\n partId: string;\n }\n | {\n type: \"text_delta\";\n messageId: string;\n partId: string;\n delta: string;\n }\n | {\n type: \"text_end\";\n messageId: string;\n partId: string;\n text?: string;\n signature?: string;\n }\n | {\n type: \"reasoning_start\";\n messageId: string;\n partId: string;\n reasoningId?: string;\n }\n | {\n type: \"reasoning_delta\";\n messageId: string;\n partId: string;\n delta: string;\n contentType?: ReasoningContentType;\n signature?: string;\n }\n | {\n type: \"reasoning_end\";\n messageId: string;\n partId: string;\n text?: string;\n content?: readonly ReasoningDetail[];\n }\n | {\n type: \"tool_call_start\";\n messageId: string;\n partId: string;\n toolCallId: string;\n callId?: string;\n toolName?: string;\n }\n | {\n type: \"tool_call_delta\";\n messageId: string;\n partId: string;\n toolCallId: string;\n callId?: string;\n toolName?: string;\n delta: string;\n mode: \"append\" | \"replace\";\n signature?: string;\n }\n | {\n type: \"tool_call_end\";\n messageId: string;\n partId: string;\n toolCallId: string;\n callId?: string;\n toolName: string;\n input: JsonValue;\n signature?: string;\n }\n | {\n type: \"tool_result\";\n messageId: string;\n partId: string;\n toolCallId: string;\n callId?: string;\n internalCallId?: string;\n toolName: string;\n input: JsonValue;\n result:\n | { status: \"success\"; output: JsonValue; content?: readonly ToolResultContentPart[] }\n | { status: \"error\"; error: ClientStreamError };\n }\n | { type: \"source\"; messageId: string; partId: string; source: CompletionSource }\n | {\n type: \"attachment\";\n messageId: string;\n partId: string;\n attachment: UIAttachment;\n }\n | { type: \"provider_tool_call\"; toolCall: ProviderToolCall }\n | { type: \"interaction\"; interaction: AgentInteractionRequest }\n | { type: \"guardrail_decision\"; decision: GuardrailDecisionRecord }\n | ({ type: \"memory_compaction\" } & MemoryCompactionInfo)\n | {\n type: \"message_end\";\n messageId: string;\n modelMessageId?: string;\n /** Authoritative model-authored parts after provider normalization and guardrails. */\n parts?: readonly UIMessagePart<Data>[];\n usage?: Usage;\n contextUsage?: ContextUsage;\n metadata?: Metadata;\n }\n | {\n type: \"turn_end\";\n usage?: Usage;\n contextUsage?: ContextUsage;\n firstDeltaMs?: number;\n }\n | {\n type: \"run_end\";\n status: \"completed\" | \"blocked\" | \"suspended\" | \"cancelled\" | \"error\";\n text?: string;\n output?: JsonValue;\n usage?: Usage;\n contextUsage?: ContextUsage;\n trace?: { observer: string; traceId?: string; observationId?: string };\n memoryCompaction?: MemoryCompactionInfo;\n metadata?: Metadata;\n }\n | { type: \"error\"; error: ClientStreamError; usage?: Usage };\n\nexport type ClientStreamEvent<\n Metadata extends JsonObject = JsonObject,\n Data extends ClientDataMap = ClientDataMap,\n> = ClientStreamEventBase & (ClientStandardStreamEvent<Metadata, Data> | ClientDataEvent<Data>);\n\nexport type ClientStream<\n Metadata extends JsonObject = JsonObject,\n Data extends ClientDataMap = ClientDataMap,\n> = AsyncIterable<ClientStreamEvent<Metadata, Data>>;\n\nexport type ClientStreamFrame<\n Metadata extends JsonObject = JsonObject,\n Data extends ClientDataMap = ClientDataMap,\n> =\n | {\n type: \"stream_start\";\n protocol: typeof CLIENT_STREAM_PROTOCOL;\n streamId: string;\n eventId: 0;\n resumable: boolean;\n }\n | {\n type: \"stream_event\";\n streamId: string;\n eventId: number;\n event: ClientStreamEvent<Metadata, Data>;\n }\n | {\n type: \"stream_end\";\n streamId: string;\n eventId: number;\n status: \"completed\" | \"error\" | \"missing\";\n };\n\nexport type ClientTransportSendOptions<TRequest> = {\n request: TRequest;\n abortSignal?: AbortSignal;\n headers?: HeadersInit;\n resume?: ClientStreamCursor;\n};\n\nexport type ClientTransport<\n TRequest = ClientStreamRequest,\n Data extends ClientDataMap = ClientDataMap,\n Metadata extends JsonObject = JsonObject,\n> = {\n readonly _types?: { metadata: Metadata; data: Data };\n send(\n options: ClientTransportSendOptions<TRequest>,\n ): AsyncIterable<ClientStreamFrame<Metadata, Data>>;\n};\n\nexport type ClientErrorMapper = (error: unknown) => ClientStreamError;\n\nexport type ClientOutputMapper = (output: unknown) => JsonValue | undefined;\n"],"mappings":";;AAwBA,SAAgB,qBAGd,UAAqE;CACrE,MAAM,SAA8B,CAAC;CAErC,KAAK,MAAM,WAAW,UAAU;EAC9B,eAAe,QAAQ,QAAQ;EAE/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KAAK,UAAU,mBACjB,MAAM,IAAI,UACR,sBAAsB,KAAK,WAAW,yCACxC;AAEJ;AAEA,SAAS,cAAc,OAAyC;CAC9D,OAAO,MAAM,SAAS,SAAU,KAAK,SAAS,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC,CAAE,CAAC,CAAC,KAAK,EAAE;AACnF;AAEA,SAAS,gBACP,SACA,SACM;CACN,KAAK,MAAM,QAAQ,QAAQ,OACzB,IAAI,CAAC,QAAQ,SAAS,KAAK,IAAI,GAC7B,MAAM,IAAI,UAAU,GAAG,QAAQ,KAAK,8BAA8B,KAAK,KAAK,QAAQ;AAG1F;AAEA,SAAS,eAAe,UAAwC;CAC9D,IAAI,aAAa,KAAA,MAAc,CAAC,YAAY,QAAQ,KAAK,MAAM,QAAQ,QAAQ,IAC7E,MAAM,IAAI,UAAU,gDAAgD;AAExE;AAEA,SAAS,cACP,UACyB;CACzB,OAAO,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS;AAClD;AAEA,SAAS,WAAW,YAA4B;CAC9C,OAAO,QAAQ;AACjB;AAEA,IAAI,SAAS;AAEb,SAAgB,eAAe,QAAwB;CACrD,MAAM,SAAS,WAAW,QAAQ,aAAa;CAC/C,IAAI,WAAW,KAAA,GAAW,OAAO,GAAG,OAAO,GAAG;CAC9C,UAAU;CACV,OAAO,GAAG,OAAO,GAAG,OAAO,SAAS,EAAE;AACxC;AAEA,SAAS,SAAS,QAAwB;CACxC,OAAO,eAAe,MAAM;AAC9B;;AChfA,MAAa,yBAAyB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anvia/client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Framework-neutral client protocol, transports, and UI message state for Anvia.",
|
|
5
5
|
"author": "anvia",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,19 +30,23 @@
|
|
|
30
30
|
"./durable": {
|
|
31
31
|
"types": "./dist/durable.d.ts",
|
|
32
32
|
"import": "./dist/durable.js"
|
|
33
|
+
},
|
|
34
|
+
"./durable-chat": {
|
|
35
|
+
"types": "./dist/durable-chat.d.ts",
|
|
36
|
+
"import": "./dist/durable-chat.js"
|
|
33
37
|
}
|
|
34
38
|
},
|
|
35
39
|
"devDependencies": {
|
|
36
40
|
"@types/node": "^24.9.1",
|
|
37
|
-
"
|
|
41
|
+
"tsdown": "^0.23.4",
|
|
38
42
|
"typescript": "^5.9.3",
|
|
39
43
|
"vitest": "^4.1.11",
|
|
40
|
-
"@anvia/core": "1.
|
|
41
|
-
"@anvia/durable": "0.
|
|
44
|
+
"@anvia/core": "1.17.3",
|
|
45
|
+
"@anvia/durable": "0.13.0"
|
|
42
46
|
},
|
|
43
47
|
"peerDependencies": {
|
|
44
|
-
"@anvia/durable": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0",
|
|
45
|
-
"@anvia/core": "^1.
|
|
48
|
+
"@anvia/durable": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0",
|
|
49
|
+
"@anvia/core": "^1.17.3"
|
|
46
50
|
},
|
|
47
51
|
"peerDependenciesMeta": {
|
|
48
52
|
"@anvia/durable": {
|
|
@@ -50,7 +54,7 @@
|
|
|
50
54
|
}
|
|
51
55
|
},
|
|
52
56
|
"scripts": {
|
|
53
|
-
"build": "
|
|
57
|
+
"build": "tsdown src/index.ts src/transport/index.ts src/durable.ts src/durable-chat.ts --format esm --dts --sourcemap --clean --no-fixed-extension",
|
|
54
58
|
"coverage": "vitest run --coverage",
|
|
55
59
|
"test": "vitest run",
|
|
56
60
|
"typecheck": "tsc --noEmit"
|