@anvia/core 0.12.8 → 0.13.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.
Files changed (62) hide show
  1. package/dist/agent/index.d.ts +11 -11
  2. package/dist/agent/index.js +6 -6
  3. package/dist/{agent-BB9vVH6P.d.ts → agent-CXvjoW0J.d.ts} +7 -7
  4. package/dist/audio-generation/index.d.ts +1 -1
  5. package/dist/{chunk-SHORX7TZ.js → chunk-46IR5ZTN.js} +2 -2
  6. package/dist/{chunk-2STANSN6.js → chunk-7BV5JBJW.js} +4 -4
  7. package/dist/{chunk-QVFOCNF6.js → chunk-7H3TQN3I.js} +99 -10
  8. package/dist/chunk-7H3TQN3I.js.map +1 -0
  9. package/dist/{chunk-EGZCTSEW.js → chunk-HLISYYCB.js} +4 -4
  10. package/dist/{chunk-WRNPY5C6.js → chunk-JT4U4FGG.js} +3 -3
  11. package/dist/{chunk-UDISNNKR.js → chunk-MU3UPROJ.js} +51 -11
  12. package/dist/chunk-MU3UPROJ.js.map +1 -0
  13. package/dist/{chunk-IN5NPAWL.js → chunk-OCYL4AB6.js} +5 -5
  14. package/dist/{chunk-FUJ3POKH.js → chunk-W53PLBOL.js} +2 -2
  15. package/dist/completion/index.d.ts +3 -3
  16. package/dist/completion/index.js +4 -2
  17. package/dist/evals/index.d.ts +8 -8
  18. package/dist/evals/index.js +7 -7
  19. package/dist/extractor/index.d.ts +8 -8
  20. package/dist/extractor/index.js +7 -7
  21. package/dist/guardrails/index.d.ts +1 -1
  22. package/dist/hooks/index.d.ts +3 -3
  23. package/dist/image-generation/index.d.ts +1 -1
  24. package/dist/{index-CM-V4LS3.d.ts → index-ZQAiHW5Q.d.ts} +2 -2
  25. package/dist/index.d.ts +12 -12
  26. package/dist/index.js +10 -8
  27. package/dist/internal/agent.d.ts +8 -8
  28. package/dist/internal/agent.js +5 -5
  29. package/dist/{create-completion-CC8-Ep3w.d.ts → json-C5a6auAm.d.ts} +4 -2
  30. package/dist/loaders/index.d.ts +1 -1
  31. package/dist/mcp/index.d.ts +4 -4
  32. package/dist/memory/index.d.ts +3 -3
  33. package/dist/{middleware-i-jLsLom.d.ts → middleware-Cc_-sosu.d.ts} +3 -3
  34. package/dist/observability/index.d.ts +3 -3
  35. package/dist/pipeline/index.d.ts +8 -8
  36. package/dist/request/index.d.ts +8 -8
  37. package/dist/request/index.js +4 -4
  38. package/dist/skills/index.d.ts +4 -4
  39. package/dist/skills/index.js +2 -2
  40. package/dist/{think-tool-BKDCOJh5.d.ts → think-tool-DvhOlrL8.d.ts} +1 -1
  41. package/dist/tool/index.d.ts +5 -5
  42. package/dist/tool/index.js +2 -2
  43. package/dist/{tool-f2stpvUP.d.ts → tool-6f9bK92X.d.ts} +1 -1
  44. package/dist/transcription/index.d.ts +1 -1
  45. package/dist/{types-5JgWDgaM.d.ts → types-BG3s2WzI.d.ts} +2 -2
  46. package/dist/{types-b6fOVoW1.d.ts → types-BZQlZ4Vs.d.ts} +1 -1
  47. package/dist/{types-Dh7gfoGw.d.ts → types-BaYwqozV.d.ts} +1 -1
  48. package/dist/{types-DmvXANwl.d.ts → types-C708DOhL.d.ts} +1 -1
  49. package/dist/{types-bNDxj4Tt.d.ts → types-CNeDsGjw.d.ts} +1 -1
  50. package/dist/{types-C15r7N_4.d.ts → types-DzdJOf35.d.ts} +17 -6
  51. package/dist/ui/index.d.ts +1 -1
  52. package/dist/ui/index.js +2 -2
  53. package/dist/vector-store/index.d.ts +4 -4
  54. package/package.json +1 -1
  55. package/dist/chunk-QVFOCNF6.js.map +0 -1
  56. package/dist/chunk-UDISNNKR.js.map +0 -1
  57. /package/dist/{chunk-SHORX7TZ.js.map → chunk-46IR5ZTN.js.map} +0 -0
  58. /package/dist/{chunk-2STANSN6.js.map → chunk-7BV5JBJW.js.map} +0 -0
  59. /package/dist/{chunk-EGZCTSEW.js.map → chunk-HLISYYCB.js.map} +0 -0
  60. /package/dist/{chunk-WRNPY5C6.js.map → chunk-JT4U4FGG.js.map} +0 -0
  61. /package/dist/{chunk-IN5NPAWL.js.map → chunk-OCYL4AB6.js.map} +0 -0
  62. /package/dist/{chunk-FUJ3POKH.js.map → chunk-W53PLBOL.js.map} +0 -0
@@ -1,16 +1,16 @@
1
- import { D as DynamicContextOptions, a as DynamicToolOptions, b as AgentEventStore, c as AgentEventStoreOptions, A as Agent } from '../agent-BB9vVH6P.js';
2
- export { d as AgentEventAppendInput, e as AgentEventRecord, f as AgentEventStoreInclude, g as AgentSession, h as AgentToolOptions } from '../agent-BB9vVH6P.js';
1
+ import { D as DynamicContextOptions, a as DynamicToolOptions, b as AgentEventStore, c as AgentEventStoreOptions, A as Agent } from '../agent-CXvjoW0J.js';
2
+ export { d as AgentEventAppendInput, e as AgentEventRecord, f as AgentEventStoreInclude, g as AgentSession, h as AgentToolOptions } from '../agent-CXvjoW0J.js';
3
3
  import { Z as ZodSchema } from '../zod-schema-C7F4clpm.js';
4
- import { C as CompletionModel, e as JsonValue, n as ToolChoice } from '../types-C15r7N_4.js';
4
+ import { C as CompletionModel, f as JsonValue, t as ToolChoice } from '../types-DzdJOf35.js';
5
5
  import { GuardrailPolicyInput } from '../guardrails/index.js';
6
- import { P as PromptHook } from '../types-Dh7gfoGw.js';
7
- import { a as McpServer } from '../types-5JgWDgaM.js';
8
- import { M as MemoryStore, a as MemoryOptions } from '../types-bNDxj4Tt.js';
9
- import { b as AgentObserver, O as ObserveOptions } from '../index-CM-V4LS3.js';
10
- import { a as SkillSet } from '../types-b6fOVoW1.js';
11
- import { k as ToolSearchDocument, l as ToolSet, A as AgentMiddleware, e as ToolMiddleware } from '../middleware-i-jLsLom.js';
12
- import { A as AnyTool, e as ToolApprovalsOptions } from '../tool-f2stpvUP.js';
13
- import { a as VectorSearchIndex } from '../types-DmvXANwl.js';
6
+ import { P as PromptHook } from '../types-BaYwqozV.js';
7
+ import { a as McpServer } from '../types-BG3s2WzI.js';
8
+ import { M as MemoryStore, a as MemoryOptions } from '../types-CNeDsGjw.js';
9
+ import { b as AgentObserver, O as ObserveOptions } from '../index-ZQAiHW5Q.js';
10
+ import { a as SkillSet } from '../types-BZQlZ4Vs.js';
11
+ import { k as ToolSearchDocument, l as ToolSet, A as AgentMiddleware, e as ToolMiddleware } from '../middleware-Cc_-sosu.js';
12
+ import { A as AnyTool, e as ToolApprovalsOptions } from '../tool-6f9bK92X.js';
13
+ import { a as VectorSearchIndex } from '../types-C708DOhL.js';
14
14
  import 'zod';
15
15
  import '@modelcontextprotocol/sdk/client/sse.js';
16
16
  import '@modelcontextprotocol/sdk/client/stdio.js';
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  AgentBuilder
3
- } from "../chunk-WRNPY5C6.js";
4
- import "../chunk-2STANSN6.js";
5
- import "../chunk-EGZCTSEW.js";
3
+ } from "../chunk-JT4U4FGG.js";
4
+ import "../chunk-7BV5JBJW.js";
5
+ import "../chunk-HLISYYCB.js";
6
6
  import "../chunk-YK4WAAS4.js";
7
7
  import "../chunk-XUUY2L2D.js";
8
- import "../chunk-SHORX7TZ.js";
8
+ import "../chunk-46IR5ZTN.js";
9
9
  import "../chunk-IZM6FNCT.js";
10
10
  import "../chunk-NPZDYOE6.js";
11
11
  import "../chunk-MMHG7WAM.js";
12
12
  import "../chunk-M6RPFHG7.js";
13
13
  import "../chunk-JS5MGVNM.js";
14
14
  import "../chunk-OIMLU4SF.js";
15
- import "../chunk-FUJ3POKH.js";
16
- import "../chunk-QVFOCNF6.js";
15
+ import "../chunk-W53PLBOL.js";
16
+ import "../chunk-7H3TQN3I.js";
17
17
  import "../chunk-WQKHFADH.js";
18
18
  import "../chunk-CWUJUSOS.js";
19
19
  export {
@@ -1,11 +1,11 @@
1
- import { C as CompletionModel, M as Message, D as Document, e as JsonValue, n as ToolChoice, J as JsonObject } from './types-C15r7N_4.js';
1
+ import { C as CompletionModel, M as Message, D as Document, f as JsonValue, t as ToolChoice, J as JsonObject } from './types-DzdJOf35.js';
2
2
  import { GuardrailPolicyInput, GuardrailPolicy } from './guardrails/index.js';
3
- import { P as PromptHook } from './types-Dh7gfoGw.js';
4
- import { c as MemoryContext, e as MemoryRegistration, S as SessionOptions } from './types-bNDxj4Tt.js';
5
- import { c as AgentTraceOptions, P as PromptResponse, a as AgentStreamEvent, d as AgentObserverRegistration } from './index-CM-V4LS3.js';
6
- import { e as ToolApprovalsOptions, T as Tool, A as AnyTool, f as ToolCallContext, N as NormalizedToolOutput } from './tool-f2stpvUP.js';
7
- import { A as AgentMiddleware, e as ToolMiddleware, k as ToolSearchDocument, l as ToolSet } from './middleware-i-jLsLom.js';
8
- import { V as VectorFilter, c as VectorSearchResult, a as VectorSearchIndex } from './types-DmvXANwl.js';
3
+ import { P as PromptHook } from './types-BaYwqozV.js';
4
+ import { c as MemoryContext, e as MemoryRegistration, S as SessionOptions } from './types-CNeDsGjw.js';
5
+ import { c as AgentTraceOptions, P as PromptResponse, a as AgentStreamEvent, d as AgentObserverRegistration } from './index-ZQAiHW5Q.js';
6
+ import { e as ToolApprovalsOptions, T as Tool, A as AnyTool, f as ToolCallContext, N as NormalizedToolOutput } from './tool-6f9bK92X.js';
7
+ import { A as AgentMiddleware, e as ToolMiddleware, k as ToolSearchDocument, l as ToolSet } from './middleware-Cc_-sosu.js';
8
+ import { V as VectorFilter, c as VectorSearchResult, a as VectorSearchIndex } from './types-C708DOhL.js';
9
9
 
10
10
  declare class PromptRequest<M extends CompletionModel = CompletionModel> {
11
11
  private readonly agent;
@@ -1,4 +1,4 @@
1
- import { e as JsonValue } from '../types-C15r7N_4.js';
1
+ import { f as JsonValue } from '../types-DzdJOf35.js';
2
2
 
3
3
  type AudioGenerationRequest = {
4
4
  text: string;
@@ -11,7 +11,7 @@ import {
11
11
  import {
12
12
  isToolResultContentArray,
13
13
  serializeToolResultOutput
14
- } from "./chunk-QVFOCNF6.js";
14
+ } from "./chunk-7H3TQN3I.js";
15
15
 
16
16
  // src/tool/errors.ts
17
17
  var ToolCallError = class extends Error {
@@ -225,4 +225,4 @@ export {
225
225
  createToolMiddleware,
226
226
  createThinkTool
227
227
  };
228
- //# sourceMappingURL=chunk-SHORX7TZ.js.map
228
+ //# sourceMappingURL=chunk-46IR5ZTN.js.map
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  PromptRequest
3
- } from "./chunk-EGZCTSEW.js";
3
+ } from "./chunk-HLISYYCB.js";
4
4
  import {
5
5
  isSkillTool
6
6
  } from "./chunk-YK4WAAS4.js";
7
7
  import {
8
8
  ToolSet
9
- } from "./chunk-SHORX7TZ.js";
9
+ } from "./chunk-46IR5ZTN.js";
10
10
  import {
11
11
  createTool
12
12
  } from "./chunk-IZM6FNCT.js";
@@ -15,7 +15,7 @@ import {
15
15
  } from "./chunk-MMHG7WAM.js";
16
16
  import {
17
17
  isStreamingCompletionModel
18
- } from "./chunk-FUJ3POKH.js";
18
+ } from "./chunk-W53PLBOL.js";
19
19
 
20
20
  // src/agent/agent.ts
21
21
  import { z } from "zod";
@@ -204,4 +204,4 @@ export {
204
204
  Agent,
205
205
  AgentSession
206
206
  };
207
- //# sourceMappingURL=chunk-2STANSN6.js.map
207
+ //# sourceMappingURL=chunk-7BV5JBJW.js.map
@@ -1,3 +1,68 @@
1
+ // src/completion/json.ts
2
+ function isJsonValue(value) {
3
+ return isJsonValueWithAncestors(value, /* @__PURE__ */ new WeakSet());
4
+ }
5
+ function isJsonValueWithAncestors(value, ancestors) {
6
+ if (value === null || typeof value === "string" || typeof value === "boolean") {
7
+ return true;
8
+ }
9
+ if (typeof value === "number") {
10
+ return Number.isFinite(value);
11
+ }
12
+ if (typeof value !== "object" || ancestors.has(value)) {
13
+ return false;
14
+ }
15
+ ancestors.add(value);
16
+ try {
17
+ if (Array.isArray(value)) {
18
+ if (!hasOnlyDenseArrayProperties(value)) {
19
+ return false;
20
+ }
21
+ for (let index = 0; index < value.length; index += 1) {
22
+ if (!isJsonValueWithAncestors(value[index], ancestors)) {
23
+ return false;
24
+ }
25
+ }
26
+ return true;
27
+ }
28
+ const prototype = Object.getPrototypeOf(value);
29
+ if (prototype !== Object.prototype && prototype !== null) {
30
+ return false;
31
+ }
32
+ for (const key of Reflect.ownKeys(value)) {
33
+ if (typeof key !== "string") {
34
+ return false;
35
+ }
36
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
37
+ if (descriptor === void 0 || !descriptor.enumerable || !("value" in descriptor) || !isJsonValueWithAncestors(descriptor.value, ancestors)) {
38
+ return false;
39
+ }
40
+ }
41
+ return true;
42
+ } catch {
43
+ return false;
44
+ } finally {
45
+ ancestors.delete(value);
46
+ }
47
+ }
48
+ function hasOnlyDenseArrayProperties(value) {
49
+ const keys = Reflect.ownKeys(value);
50
+ if (keys.length !== value.length + 1 || keys.at(-1) !== "length") {
51
+ return false;
52
+ }
53
+ for (let index = 0; index < value.length; index += 1) {
54
+ const key = String(index);
55
+ if (keys[index] !== key) {
56
+ return false;
57
+ }
58
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
59
+ if (descriptor === void 0 || !descriptor.enumerable || !("value" in descriptor)) {
60
+ return false;
61
+ }
62
+ }
63
+ return true;
64
+ }
65
+
1
66
  // src/completion/types.ts
2
67
  var UserContent = {
3
68
  text(text) {
@@ -147,30 +212,53 @@ function reasoningDisplayText(reasoning) {
147
212
  }).join("");
148
213
  }
149
214
  var Message = {
150
- system(content) {
151
- return { role: "system", content };
215
+ system(content, options = {}) {
216
+ return { role: "system", content, ...messageMetadata(options) };
152
217
  },
153
- user(content) {
218
+ user(content, options = {}) {
154
219
  return {
155
220
  role: "user",
156
- content: typeof content === "string" ? [UserContent.text(content)] : content
221
+ content: typeof content === "string" ? [UserContent.text(content)] : content,
222
+ ...messageMetadata(options)
157
223
  };
158
224
  },
159
- assistant(content, id) {
225
+ assistant(content, idOrOptions) {
160
226
  const normalized = typeof content === "string" ? [AssistantContent.text(content)] : content;
161
- return id === void 0 ? { role: "assistant", content: normalized } : { role: "assistant", id, content: normalized };
227
+ const options = typeof idOrOptions === "string" ? { id: idOrOptions } : idOrOptions ?? {};
228
+ return {
229
+ role: "assistant",
230
+ ...options.id === void 0 ? {} : { id: options.id },
231
+ content: normalized,
232
+ ...messageMetadata(options)
233
+ };
162
234
  },
163
- tool(content) {
235
+ tool(content, options = {}) {
164
236
  return {
165
237
  role: "tool",
166
- content: Array.isArray(content) ? content : [content]
238
+ content: Array.isArray(content) ? content : [content],
239
+ ...messageMetadata(options)
167
240
  };
168
241
  },
169
242
  toolResult(id, output, options = {}) {
170
243
  const content = isToolResultContentArray(output) ? output : serializeToolResultOutput(output);
171
- return Message.tool(ToolContent.toolResult(id, content, options));
244
+ return Message.tool(
245
+ ToolContent.toolResult(id, content, {
246
+ callId: options.callId,
247
+ toolName: options.toolName
248
+ }),
249
+ { metadata: options.metadata }
250
+ );
172
251
  }
173
252
  };
253
+ function messageMetadata(options) {
254
+ if (options.metadata === void 0) {
255
+ return {};
256
+ }
257
+ if (!isJsonValue(options.metadata)) {
258
+ throw new TypeError("Message metadata must be a strict JSON value.");
259
+ }
260
+ return { metadata: options.metadata };
261
+ }
174
262
  var Usage = {
175
263
  empty() {
176
264
  return {
@@ -236,6 +324,7 @@ function requestHasFileDocumentInput(request) {
236
324
  }
237
325
 
238
326
  export {
327
+ isJsonValue,
239
328
  UserContent,
240
329
  ToolContent,
241
330
  serializeToolResultOutput,
@@ -248,4 +337,4 @@ export {
248
337
  assertCompletionRequestSupported,
249
338
  textFromAssistantContent
250
339
  };
251
- //# sourceMappingURL=chunk-QVFOCNF6.js.map
340
+ //# sourceMappingURL=chunk-7H3TQN3I.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/completion/json.ts","../src/completion/types.ts"],"sourcesContent":["import type { JsonValue } from \"./types\";\n\nexport function isJsonValue(value: unknown): value is JsonValue {\n return isJsonValueWithAncestors(value, new WeakSet<object>());\n}\n\nfunction isJsonValueWithAncestors(value: unknown, ancestors: WeakSet<object>): value is JsonValue {\n if (value === null || typeof value === \"string\" || typeof value === \"boolean\") {\n return true;\n }\n if (typeof value === \"number\") {\n return Number.isFinite(value);\n }\n if (typeof value !== \"object\" || ancestors.has(value)) {\n return false;\n }\n\n ancestors.add(value);\n try {\n if (Array.isArray(value)) {\n if (!hasOnlyDenseArrayProperties(value)) {\n return false;\n }\n for (let index = 0; index < value.length; index += 1) {\n if (!isJsonValueWithAncestors(value[index], ancestors)) {\n return false;\n }\n }\n return true;\n }\n\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n return false;\n }\n for (const key of Reflect.ownKeys(value)) {\n if (typeof key !== \"string\") {\n return false;\n }\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (\n descriptor === undefined ||\n !descriptor.enumerable ||\n !(\"value\" in descriptor) ||\n !isJsonValueWithAncestors(descriptor.value, ancestors)\n ) {\n return false;\n }\n }\n return true;\n } catch {\n return false;\n } finally {\n ancestors.delete(value);\n }\n}\n\nfunction hasOnlyDenseArrayProperties(value: unknown[]): boolean {\n const keys = Reflect.ownKeys(value);\n if (keys.length !== value.length + 1 || keys.at(-1) !== \"length\") {\n return false;\n }\n for (let index = 0; index < value.length; index += 1) {\n const key = String(index);\n if (keys[index] !== key) {\n return false;\n }\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (descriptor === undefined || !descriptor.enumerable || !(\"value\" in descriptor)) {\n return false;\n }\n }\n return true;\n}\n","import { isJsonValue } from \"./json\";\n\nexport type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue = JsonPrimitive | JsonObject | JsonValue[];\nexport type JsonObject = { [key: string]: JsonValue | undefined };\n\nexport type Document = {\n id: string;\n text: string;\n additionalProps?: Record<string, string>;\n};\n\nexport type Text = {\n type: \"text\";\n text: string;\n signature?: string;\n};\n\nexport type ImageDetail = \"auto\" | \"low\" | \"high\";\n\nexport type ImageContent = {\n type: \"image\";\n source:\n | {\n type: \"url\";\n url: string;\n }\n | {\n type: \"base64\";\n data: string;\n mediaType: string;\n };\n detail?: ImageDetail;\n};\n\nexport type DocumentContent = {\n type: \"document\";\n source:\n | {\n type: \"url\";\n url: string;\n mediaType: string;\n filename?: string;\n }\n | {\n type: \"base64\";\n data: string;\n mediaType: string;\n filename?: string;\n }\n | {\n type: \"text\";\n text: string;\n mediaType?: string;\n filename?: string;\n };\n};\n\nexport type Reasoning = {\n type: \"reasoning\";\n text: string;\n id?: string;\n content?: ReasoningContent[];\n};\n\nexport type ReasoningContent =\n | {\n type: \"text\";\n text: string;\n signature?: string;\n }\n | {\n type: \"summary\";\n text: string;\n }\n | {\n type: \"encrypted\";\n data: string;\n }\n | {\n type: \"redacted\";\n data: string;\n };\n\nexport type ReasoningContentType = ReasoningContent[\"type\"];\n\nexport type ToolFunction = {\n name: string;\n arguments: JsonValue;\n};\n\nexport type ToolCall = {\n type: \"tool_call\";\n id: string;\n callId?: string;\n function: ToolFunction;\n signature?: string;\n additionalParams?: JsonValue;\n};\n\nexport type ToolResultContent =\n | { type: \"text\"; text: string }\n | { type: \"image\"; data: string; mediaType?: string };\n\nexport type ToolResult = {\n type: \"tool_result\";\n id: string;\n callId?: string;\n toolName?: string;\n content: ToolResultContent[];\n};\n\nexport type MessageOptions = {\n metadata?: JsonValue | undefined;\n};\n\nexport type AssistantMessageOptions = MessageOptions & {\n id?: string | undefined;\n};\n\nexport type ToolResultOptions = {\n callId?: string | undefined;\n toolName?: string | undefined;\n};\n\nexport type ToolResultMessageOptions = ToolResultOptions & MessageOptions;\n\nexport type UserContent = Text | ImageContent | DocumentContent;\nexport type AssistantContent = Text | ToolCall | Reasoning | ImageContent;\nexport type ToolContent = ToolResult;\n\nexport type SystemMessage = {\n role: \"system\";\n content: string;\n metadata?: JsonValue;\n};\n\nexport type UserMessage = {\n role: \"user\";\n content: UserContent[];\n metadata?: JsonValue;\n};\n\nexport type AssistantMessage = {\n role: \"assistant\";\n id?: string;\n content: AssistantContent[];\n metadata?: JsonValue;\n};\n\nexport type ToolMessage = {\n role: \"tool\";\n content: ToolContent[];\n metadata?: JsonValue;\n};\n\nexport type Message = SystemMessage | UserMessage | AssistantMessage | ToolMessage;\n\nexport const UserContent = {\n text(text: string): Text {\n return { type: \"text\", text };\n },\n imageUrl(url: string, options: { detail?: ImageDetail } = {}): ImageContent {\n const image: ImageContent = { type: \"image\", source: { type: \"url\", url } };\n if (options.detail !== undefined) {\n image.detail = options.detail;\n }\n return image;\n },\n imageBase64(\n data: string,\n mediaType: string,\n options: { detail?: ImageDetail } = {},\n ): ImageContent {\n const image: ImageContent = {\n type: \"image\",\n source: { type: \"base64\", data, mediaType },\n };\n if (options.detail !== undefined) {\n image.detail = options.detail;\n }\n return image;\n },\n documentUrl(\n url: string,\n mediaType: string,\n options: { filename?: string | undefined } = {},\n ): DocumentContent {\n return {\n type: \"document\",\n source:\n options.filename === undefined\n ? { type: \"url\", url, mediaType }\n : { type: \"url\", url, mediaType, filename: options.filename },\n };\n },\n documentBase64(\n data: string,\n mediaType: string,\n options: { filename?: string | undefined } = {},\n ): DocumentContent {\n return {\n type: \"document\",\n source:\n options.filename === undefined\n ? { type: \"base64\", data, mediaType }\n : { type: \"base64\", data, mediaType, filename: options.filename },\n };\n },\n documentText(text: string): Text {\n return { type: \"text\", text };\n },\n};\n\nexport const ToolContent = {\n toolResult(\n id: string,\n content: string | ToolResultContent[],\n callIdOrOptions?: string | ToolResultOptions,\n toolName?: string,\n ): ToolResult {\n const normalized =\n typeof content === \"string\" ? [{ type: \"text\" as const, text: content }] : content;\n const options = normalizeToolResultOptions(callIdOrOptions, toolName);\n const result: ToolResult = { type: \"tool_result\", id, content: normalized };\n if (options.callId !== undefined) {\n result.callId = options.callId;\n }\n if (options.toolName !== undefined) {\n result.toolName = options.toolName;\n }\n return result;\n },\n};\n\nfunction normalizeToolResultOptions(\n callIdOrOptions?: string | ToolResultOptions,\n toolName?: string,\n): ToolResultOptions {\n if (callIdOrOptions === undefined) {\n return toolName === undefined ? {} : { toolName };\n }\n if (typeof callIdOrOptions === \"string\") {\n return toolName === undefined\n ? { callId: callIdOrOptions }\n : { callId: callIdOrOptions, toolName };\n }\n return toolName === undefined ? callIdOrOptions : { ...callIdOrOptions, toolName };\n}\n\nexport function serializeToolResultOutput(output: unknown): string {\n if (typeof output === \"string\") {\n return output;\n }\n\n try {\n const serialized = JSON.stringify(output);\n return serialized === undefined ? String(output) : serialized;\n } catch {\n return String(output);\n }\n}\n\nexport function isToolResultContentArray(value: unknown): value is ToolResultContent[] {\n return (\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((item) => {\n if (typeof item !== \"object\" || item === null || !(\"type\" in item)) {\n return false;\n }\n if (item.type === \"text\") {\n return \"text\" in item && typeof item.text === \"string\";\n }\n if (item.type === \"image\") {\n return (\n \"data\" in item &&\n typeof item.data === \"string\" &&\n (!(\"mediaType\" in item) ||\n item.mediaType === undefined ||\n typeof item.mediaType === \"string\")\n );\n }\n return false;\n })\n );\n}\n\nexport const AssistantContent = {\n text(text: string): Text {\n return { type: \"text\", text };\n },\n imageUrl(url: string, options: { detail?: ImageDetail } = {}): ImageContent {\n const image: ImageContent = { type: \"image\", source: { type: \"url\", url } };\n if (options.detail !== undefined) {\n image.detail = options.detail;\n }\n return image;\n },\n imageBase64(\n data: string,\n mediaType: string,\n options: { detail?: ImageDetail } = {},\n ): ImageContent {\n const image: ImageContent = {\n type: \"image\",\n source: { type: \"base64\", data, mediaType },\n };\n if (options.detail !== undefined) {\n image.detail = options.detail;\n }\n return image;\n },\n reasoning(text: string, id?: string): Reasoning {\n return id === undefined ? { type: \"reasoning\", text } : { type: \"reasoning\", text, id };\n },\n reasoningFromContent(content: ReasoningContent[], id?: string): Reasoning {\n const text = reasoningDisplayText(content);\n const reasoning: Reasoning = { type: \"reasoning\", text, content };\n return id === undefined ? reasoning : { ...reasoning, id };\n },\n reasoningSummary(text: string, id?: string): Reasoning {\n return AssistantContent.reasoningFromContent([{ type: \"summary\", text }], id);\n },\n reasoningEncrypted(data: string, id?: string): Reasoning {\n return AssistantContent.reasoningFromContent([{ type: \"encrypted\", data }], id);\n },\n reasoningRedacted(data: string, id?: string): Reasoning {\n return AssistantContent.reasoningFromContent([{ type: \"redacted\", data }], id);\n },\n toolCall(id: string, name: string, args: JsonValue, callId?: string): ToolCall {\n const base: ToolCall = {\n type: \"tool_call\",\n id,\n function: {\n name,\n arguments: args,\n },\n };\n return callId === undefined ? base : { ...base, callId };\n },\n};\n\nexport function reasoningDisplayText(reasoning: Reasoning | ReasoningContent[]): string {\n const content = Array.isArray(reasoning) ? reasoning : reasoning.content;\n if (content === undefined) {\n return Array.isArray(reasoning) ? \"\" : reasoning.text;\n }\n return content\n .flatMap((item) => {\n if (item.type === \"text\" || item.type === \"summary\") {\n return [item.text];\n }\n return [];\n })\n .join(\"\");\n}\n\nexport const Message = {\n system(content: string, options: MessageOptions = {}): Message {\n return { role: \"system\", content, ...messageMetadata(options) };\n },\n user(content: string | UserContent[], options: MessageOptions = {}): Message {\n return {\n role: \"user\",\n content: typeof content === \"string\" ? [UserContent.text(content)] : content,\n ...messageMetadata(options),\n };\n },\n assistant(\n content: string | AssistantContent[],\n idOrOptions?: string | AssistantMessageOptions,\n ): Message {\n const normalized = typeof content === \"string\" ? [AssistantContent.text(content)] : content;\n const options = typeof idOrOptions === \"string\" ? { id: idOrOptions } : (idOrOptions ?? {});\n return {\n role: \"assistant\",\n ...(options.id === undefined ? {} : { id: options.id }),\n content: normalized,\n ...messageMetadata(options),\n };\n },\n tool(content: ToolContent | ToolContent[], options: MessageOptions = {}): Message {\n return {\n role: \"tool\",\n content: Array.isArray(content) ? content : [content],\n ...messageMetadata(options),\n };\n },\n toolResult(id: string, output: unknown, options: ToolResultMessageOptions = {}): Message {\n const content = isToolResultContentArray(output) ? output : serializeToolResultOutput(output);\n return Message.tool(\n ToolContent.toolResult(id, content, {\n callId: options.callId,\n toolName: options.toolName,\n }),\n { metadata: options.metadata },\n );\n },\n};\n\nfunction messageMetadata(options: MessageOptions): { metadata?: JsonValue } {\n if (options.metadata === undefined) {\n return {};\n }\n if (!isJsonValue(options.metadata)) {\n throw new TypeError(\"Message metadata must be a strict JSON value.\");\n }\n return { metadata: options.metadata };\n}\n\nexport type ToolChoice =\n | \"auto\"\n | \"required\"\n | \"none\"\n | {\n type: \"function\";\n name: string;\n };\n\nexport type ToolDefinition = {\n name: string;\n description: string;\n parameters: JsonObject;\n};\n\nexport type Usage = {\n inputTokens: number;\n outputTokens: number;\n totalTokens: number;\n cachedInputTokens: number;\n cacheCreationInputTokens: number;\n};\n\nexport const Usage = {\n empty(): Usage {\n return {\n inputTokens: 0,\n outputTokens: 0,\n totalTokens: 0,\n cachedInputTokens: 0,\n cacheCreationInputTokens: 0,\n };\n },\n add(left: Usage, right: Usage): Usage {\n return {\n inputTokens: left.inputTokens + right.inputTokens,\n outputTokens: left.outputTokens + right.outputTokens,\n totalTokens: left.totalTokens + right.totalTokens,\n cachedInputTokens: left.cachedInputTokens + right.cachedInputTokens,\n cacheCreationInputTokens: left.cacheCreationInputTokens + right.cacheCreationInputTokens,\n };\n },\n};\n\nexport type CompletionRequest<ModelName extends string = string> = {\n model?: ModelName;\n instructions?: string;\n chatHistory: Message[];\n documents: Document[];\n tools: ToolDefinition[];\n temperature?: number;\n maxTokens?: number;\n toolChoice?: ToolChoice;\n additionalParams?: JsonValue;\n outputSchema?: JsonObject;\n};\n\nexport type CompletionResponse<RawResponse = unknown> = {\n choice: AssistantContent[];\n usage: Usage;\n rawResponse: RawResponse;\n messageId?: string;\n};\n\nexport type CompletionModelCapabilities = {\n streaming: boolean;\n tools: boolean;\n toolChoice: boolean;\n imageInput: boolean;\n documentInput: boolean;\n outputSchema: boolean;\n reasoning: boolean;\n};\n\nexport interface CompletionModel<RawResponse = unknown, ModelName extends string = string> {\n readonly provider: string;\n readonly defaultModel: ModelName;\n readonly capabilities: CompletionModelCapabilities;\n traceRequest?(\n request: CompletionRequest<ModelName>,\n options?: { stream?: boolean | undefined },\n ): JsonObject | undefined;\n completion(request: CompletionRequest<ModelName>): Promise<CompletionResponse<RawResponse>>;\n}\n\nexport type CompletionStreamEvent<RawResponse = unknown> =\n | {\n type: \"text_delta\";\n delta: string;\n }\n | {\n type: \"reasoning_delta\";\n delta: string;\n id?: string;\n contentType?: ReasoningContentType;\n signature?: string;\n }\n | {\n type: \"tool_call_delta\";\n id: string;\n callId?: string;\n name?: string;\n argumentsDelta?: string;\n signature?: string;\n }\n | {\n type: \"tool_call\";\n toolCall: ToolCall;\n }\n | {\n type: \"message_id\";\n id: string;\n }\n | {\n type: \"final\";\n response: CompletionResponse<RawResponse>;\n }\n | {\n type: \"error\";\n error: unknown;\n };\n\nexport interface StreamingCompletionModel<RawResponse = unknown, ModelName extends string = string>\n extends CompletionModel<RawResponse, ModelName> {\n streamCompletion(\n request: CompletionRequest<ModelName>,\n ): AsyncIterable<CompletionStreamEvent<RawResponse>>;\n}\n\nexport class CompletionCapabilityError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"CompletionCapabilityError\";\n }\n}\n\nexport function assertCompletionRequestSupported(\n model: CompletionModel,\n request: CompletionRequest,\n options: { streaming?: boolean | undefined } = {},\n): void {\n const modelLabel = `${model.provider}:${request.model ?? model.defaultModel}`;\n const capabilities = model.capabilities;\n\n if (options.streaming === true && !capabilities.streaming) {\n throw new CompletionCapabilityError(`${modelLabel} does not support streaming completions.`);\n }\n\n if (request.tools.length > 0 && !capabilities.tools) {\n throw new CompletionCapabilityError(`${modelLabel} does not support tool definitions.`);\n }\n\n if (request.toolChoice !== undefined && !capabilities.toolChoice) {\n throw new CompletionCapabilityError(`${modelLabel} does not support tool choice.`);\n }\n\n if (request.outputSchema !== undefined && !capabilities.outputSchema) {\n throw new CompletionCapabilityError(`${modelLabel} does not support output schemas.`);\n }\n\n if (!capabilities.imageInput && requestHasImageInput(request)) {\n throw new CompletionCapabilityError(`${modelLabel} does not support image input.`);\n }\n\n if (!capabilities.documentInput && requestHasFileDocumentInput(request)) {\n throw new CompletionCapabilityError(`${modelLabel} does not support document file input.`);\n }\n}\n\nexport function textFromAssistantContent(content: AssistantContent[]): string {\n return content.flatMap((item) => (item.type === \"text\" ? [item.text] : [])).join(\"\\n\");\n}\n\nfunction requestHasImageInput(request: CompletionRequest): boolean {\n return request.chatHistory.some((message) =>\n message.role === \"system\" ? false : message.content.some((content) => content.type === \"image\"),\n );\n}\n\nfunction requestHasFileDocumentInput(request: CompletionRequest): boolean {\n return request.chatHistory.some((message) =>\n message.role === \"user\"\n ? message.content.some(\n (content) => content.type === \"document\" && content.source.type !== \"text\",\n )\n : false,\n );\n}\n"],"mappings":";AAEO,SAAS,YAAY,OAAoC;AAC9D,SAAO,yBAAyB,OAAO,oBAAI,QAAgB,CAAC;AAC9D;AAEA,SAAS,yBAAyB,OAAgB,WAAgD;AAChG,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,OAAO,UAAU,WAAW;AAC7E,WAAO;AAAA,EACT;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,OAAO,SAAS,KAAK;AAAA,EAC9B;AACA,MAAI,OAAO,UAAU,YAAY,UAAU,IAAI,KAAK,GAAG;AACrD,WAAO;AAAA,EACT;AAEA,YAAU,IAAI,KAAK;AACnB,MAAI;AACF,QAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,UAAI,CAAC,4BAA4B,KAAK,GAAG;AACvC,eAAO;AAAA,MACT;AACA,eAAS,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS,GAAG;AACpD,YAAI,CAAC,yBAAyB,MAAM,KAAK,GAAG,SAAS,GAAG;AACtD,iBAAO;AAAA,QACT;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAEA,UAAM,YAAY,OAAO,eAAe,KAAK;AAC7C,QAAI,cAAc,OAAO,aAAa,cAAc,MAAM;AACxD,aAAO;AAAA,IACT;AACA,eAAW,OAAO,QAAQ,QAAQ,KAAK,GAAG;AACxC,UAAI,OAAO,QAAQ,UAAU;AAC3B,eAAO;AAAA,MACT;AACA,YAAM,aAAa,OAAO,yBAAyB,OAAO,GAAG;AAC7D,UACE,eAAe,UACf,CAAC,WAAW,cACZ,EAAE,WAAW,eACb,C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EA,MAAI,CAAC,aAAa,cAAc,qBAAqB,OAAO,GAAG;AAC7D,UAAM,IAAI,0BAA0B,GAAG,UAAU,gCAAgC;AAAA,EACnF;AAEA,MAAI,CAAC,aAAa,iBAAiB,4BAA4B,OAAO,GAAG;AACvE,UAAM,IAAI,0BAA0B,GAAG,UAAU,wCAAwC;AAAA,EAC3F;AACF;AAEO,SAAS,yBAAyB,SAAqC;AAC5E,SAAO,QAAQ,QAAQ,CAAC,SAAU,KAAK,SAAS,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC,CAAE,EAAE,KAAK,IAAI;AACvF;AAEA,SAAS,qBAAqB,SAAqC;AACjE,SAAO,QAAQ,YAAY;AAAA,IAAK,CAAC,YAC/B,QAAQ,SAAS,WAAW,QAAQ,QAAQ,QAAQ,KAAK,CAAC,YAAY,QAAQ,SAAS,OAAO;AAAA,EAChG;AACF;AAEA,SAAS,4BAA4B,SAAqC;AACxE,SAAO,QAAQ,YAAY;AAAA,IAAK,CAAC,YAC/B,QAAQ,SAAS,SACb,QAAQ,QAAQ;AAAA,MACd,CAAC,YAAY,QAAQ,SAAS,cAAc,QAAQ,OAAO,SAAS;AAAA,IACtE,IACA;AAAA,EACN;AACF;","names":[]}
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  parseToolArgs,
6
6
  toolResultContentToText
7
- } from "./chunk-SHORX7TZ.js";
7
+ } from "./chunk-46IR5ZTN.js";
8
8
  import {
9
9
  runControl,
10
10
  toolCallControl
@@ -18,7 +18,7 @@ import {
18
18
  import {
19
19
  CompletionRequestBuilder,
20
20
  isStreamingCompletionModel
21
- } from "./chunk-FUJ3POKH.js";
21
+ } from "./chunk-W53PLBOL.js";
22
22
  import {
23
23
  AssistantContent,
24
24
  Message,
@@ -26,7 +26,7 @@ import {
26
26
  Usage,
27
27
  assertCompletionRequestSupported,
28
28
  textFromAssistantContent
29
- } from "./chunk-QVFOCNF6.js";
29
+ } from "./chunk-7H3TQN3I.js";
30
30
  import {
31
31
  appendGuardrailPolicies,
32
32
  hasEnforcedOutputGuardrails,
@@ -2103,4 +2103,4 @@ export {
2103
2103
  extractRagText,
2104
2104
  PromptRequest
2105
2105
  };
2106
- //# sourceMappingURL=chunk-EGZCTSEW.js.map
2106
+ //# sourceMappingURL=chunk-HLISYYCB.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  Agent,
3
3
  normalizeAgentId
4
- } from "./chunk-2STANSN6.js";
4
+ } from "./chunk-7BV5JBJW.js";
5
5
  import {
6
6
  ToolSet
7
- } from "./chunk-SHORX7TZ.js";
7
+ } from "./chunk-46IR5ZTN.js";
8
8
  import {
9
9
  resolveMemoryOptions
10
10
  } from "./chunk-M6RPFHG7.js";
@@ -212,4 +212,4 @@ var AgentBuilder = class {
212
212
  export {
213
213
  AgentBuilder
214
214
  };
215
- //# sourceMappingURL=chunk-WRNPY5C6.js.map
215
+ //# sourceMappingURL=chunk-JT4U4FGG.js.map
@@ -3,9 +3,10 @@ import {
3
3
  Message,
4
4
  ToolContent,
5
5
  UserContent,
6
+ isJsonValue,
6
7
  reasoningDisplayText,
7
8
  serializeToolResultOutput
8
- } from "./chunk-QVFOCNF6.js";
9
+ } from "./chunk-7H3TQN3I.js";
9
10
 
10
11
  // src/ui/messages.ts
11
12
  function uiMessagesToCoreMessages(messages) {
@@ -14,7 +15,7 @@ function uiMessagesToCoreMessages(messages) {
14
15
  const text = textFromUIParts(message.parts);
15
16
  if (message.role === "system") {
16
17
  if (text.length > 0) {
17
- coreMessages.push(Message.system(text));
18
+ coreMessages.push(Message.system(text, metadataOptions(message.metadata)));
18
19
  }
19
20
  continue;
20
21
  }
@@ -38,7 +39,7 @@ function uiMessagesToCoreMessages(messages) {
38
39
  );
39
40
  }
40
41
  if (content.length > 0) {
41
- coreMessages.push(Message.user(content));
42
+ coreMessages.push(Message.user(content, metadataOptions(message.metadata)));
42
43
  }
43
44
  continue;
44
45
  }
@@ -74,7 +75,12 @@ function uiMessagesToCoreMessages(messages) {
74
75
  }
75
76
  }
76
77
  if (content.length > 0) {
77
- coreMessages.push(Message.assistant(content, message.id));
78
+ coreMessages.push(
79
+ Message.assistant(content, {
80
+ id: message.id,
81
+ ...metadataOptions(message.metadata)
82
+ })
83
+ );
78
84
  }
79
85
  if (toolResults2.length > 0) {
80
86
  coreMessages.push(Message.tool(toolResults2));
@@ -94,7 +100,7 @@ function uiMessagesToCoreMessages(messages) {
94
100
  );
95
101
  }
96
102
  if (toolResults.length > 0) {
97
- coreMessages.push(Message.tool(toolResults));
103
+ coreMessages.push(Message.tool(toolResults, metadataOptions(message.metadata)));
98
104
  }
99
105
  }
100
106
  return coreMessages;
@@ -110,7 +116,8 @@ function coreMessagesToUIMessages(messages) {
110
116
  uiMessages.push({
111
117
  id: createId("msg"),
112
118
  role: "system",
113
- parts: [{ id: createId("part"), type: "text", text: message.content }]
119
+ parts: [{ id: createId("part"), type: "text", text: message.content }],
120
+ ...uiMetadata(message.metadata)
114
121
  });
115
122
  continue;
116
123
  }
@@ -127,7 +134,12 @@ function coreMessagesToUIMessages(messages) {
127
134
  });
128
135
  }
129
136
  }
130
- uiMessages.push({ id: createId("msg"), role: "user", parts: parts2 });
137
+ uiMessages.push({
138
+ id: createId("msg"),
139
+ role: "user",
140
+ parts: parts2,
141
+ ...uiMetadata(message.metadata)
142
+ });
131
143
  continue;
132
144
  }
133
145
  if (message.role === "assistant") {
@@ -172,7 +184,12 @@ function coreMessagesToUIMessages(messages) {
172
184
  });
173
185
  }
174
186
  const messageIndex = uiMessages.length;
175
- uiMessages.push({ id: message.id ?? createId("msg"), role: "assistant", parts: parts2 });
187
+ uiMessages.push({
188
+ id: message.id ?? createId("msg"),
189
+ role: "assistant",
190
+ parts: parts2,
191
+ ...uiMetadata(message.metadata)
192
+ });
176
193
  registerToolPartLocations(parts2, messageIndex, toolPartLocations);
177
194
  continue;
178
195
  }
@@ -189,17 +206,40 @@ function coreMessagesToUIMessages(messages) {
189
206
  if (content.callId !== void 0) {
190
207
  part.callId = content.callId;
191
208
  }
192
- if (mergeToolResultPart(uiMessages, toolPartLocations, part)) {
209
+ if (message.metadata === void 0 && mergeToolResultPart(uiMessages, toolPartLocations, part)) {
193
210
  continue;
194
211
  }
195
212
  parts.push(part);
196
213
  }
197
214
  if (parts.length > 0) {
198
- uiMessages.push({ id: createId("msg"), role: "tool", parts });
215
+ uiMessages.push({
216
+ id: createId("msg"),
217
+ role: "tool",
218
+ parts,
219
+ ...uiMetadata(message.metadata)
220
+ });
199
221
  }
200
222
  }
201
223
  return uiMessages;
202
224
  }
225
+ function metadataOptions(metadata) {
226
+ if (metadata === void 0) {
227
+ return {};
228
+ }
229
+ if (!isJsonValue(metadata)) {
230
+ throw new TypeError("UI message metadata must be a strict JSON value.");
231
+ }
232
+ return { metadata };
233
+ }
234
+ function uiMetadata(metadata) {
235
+ if (metadata === void 0) {
236
+ return {};
237
+ }
238
+ if (!isJsonValue(metadata)) {
239
+ throw new TypeError("Core message metadata must be a strict JSON value.");
240
+ }
241
+ return { metadata };
242
+ }
203
243
  function registerToolPartLocations(parts, messageIndex, toolPartLocations) {
204
244
  for (const [partIndex, part] of parts.entries()) {
205
245
  if (part.type !== "tool") {
@@ -414,4 +454,4 @@ export {
414
454
  uiMessagesToCoreMessages,
415
455
  coreMessagesToUIMessages
416
456
  };
417
- //# sourceMappingURL=chunk-UDISNNKR.js.map
457
+ //# sourceMappingURL=chunk-MU3UPROJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ui/messages.ts"],"sourcesContent":["import { isJsonValue } from \"../completion/json\";\nimport {\n AssistantContent,\n type AssistantContent as AssistantContentType,\n type Message as CoreMessage,\n type DocumentContent,\n type ImageContent,\n type ImageDetail,\n type JsonValue,\n Message,\n reasoningDisplayText,\n serializeToolResultOutput,\n ToolContent,\n type ToolContent as ToolContentType,\n type ToolResultContent,\n UserContent,\n type UserContent as UserContentType,\n} from \"../completion/types\";\nimport type { UIAttachment, UIMessage, UIMessagePart } from \"./types\";\n\ntype UIToolPartLocation = {\n messageIndex: number;\n partIndex: number;\n};\n\ntype UIToolPartLocations = {\n byToolCallId: Map<string, UIToolPartLocation>;\n byCallId: Map<string, UIToolPartLocation>;\n};\n\ntype UIToolMessagePart = Extract<UIMessagePart, { type: \"tool\" }>;\n\nexport function uiMessagesToCoreMessages(messages: UIMessage[]): CoreMessage[] {\n const coreMessages: CoreMessage[] = [];\n\n for (const message of messages) {\n const text = textFromUIParts(message.parts);\n\n if (message.role === \"system\") {\n if (text.length > 0) {\n coreMessages.push(Message.system(text, metadataOptions(message.metadata)));\n }\n continue;\n }\n\n if (message.role === \"user\") {\n const content: UserContentType[] = [];\n for (const part of message.parts) {\n if (part.type === \"text\") {\n content.push(UserContent.text(part.text));\n continue;\n }\n if (part.type === \"attachment\") {\n content.push(attachmentToUserContent(part.attachment));\n continue;\n }\n if (part.type === \"data\" && isUserContent(part.data)) {\n content.push(part.data);\n continue;\n }\n throw new TypeError(\n \"User UI messages can only be converted from text, attachment, or image/document data parts.\",\n );\n }\n if (content.length > 0) {\n coreMessages.push(Message.user(content, metadataOptions(message.metadata)));\n }\n continue;\n }\n\n if (message.role === \"assistant\") {\n const content: AssistantContentType[] = [];\n const toolResults: ToolContentType[] = [];\n for (const part of message.parts) {\n if (part.type === \"text\" && part.text.length > 0) {\n content.push(AssistantContent.text(part.text));\n continue;\n }\n if (part.type === \"reasoning\" && part.text.length > 0) {\n content.push(AssistantContent.reasoning(part.text, part.reasoningId));\n continue;\n }\n if (\n part.type === \"tool\" &&\n (part.state === \"input-streaming\" ||\n part.state === \"input-available\" ||\n part.state === \"output-available\")\n ) {\n content.push(\n AssistantContent.toolCall(\n part.toolCallId,\n part.toolName,\n part.input ?? {},\n part.callId,\n ),\n );\n if (part.state === \"output-available\") {\n toolResults.push(\n ToolContent.toolResult(part.toolCallId, outputToToolResultContent(part.output), {\n callId: part.callId,\n toolName: part.toolName,\n }),\n );\n }\n }\n }\n if (content.length > 0) {\n coreMessages.push(\n Message.assistant(content, {\n id: message.id,\n ...metadataOptions(message.metadata),\n }),\n );\n }\n if (toolResults.length > 0) {\n coreMessages.push(Message.tool(toolResults));\n }\n continue;\n }\n\n const toolResults: ToolContentType[] = [];\n for (const part of message.parts) {\n if (part.type !== \"tool\" || part.state !== \"output-available\") {\n continue;\n }\n toolResults.push(\n ToolContent.toolResult(part.toolCallId, outputToToolResultContent(part.output), {\n callId: part.callId,\n toolName: part.toolName,\n }),\n );\n }\n if (toolResults.length > 0) {\n coreMessages.push(Message.tool(toolResults, metadataOptions(message.metadata)));\n }\n }\n\n return coreMessages;\n}\n\nexport function coreMessagesToUIMessages(messages: CoreMessage[]): UIMessage[] {\n const uiMessages: UIMessage[] = [];\n const toolPartLocations: UIToolPartLocations = {\n byToolCallId: new Map(),\n byCallId: new Map(),\n };\n\n for (const message of messages) {\n if (message.role === \"system\") {\n uiMessages.push({\n id: createId(\"msg\"),\n role: \"system\",\n parts: [{ id: createId(\"part\"), type: \"text\", text: message.content }],\n ...uiMetadata(message.metadata),\n });\n continue;\n }\n\n if (message.role === \"user\") {\n const parts: UIMessagePart[] = [];\n for (const content of message.content) {\n if (content.type === \"text\") {\n parts.push({ id: createId(\"part\"), type: \"text\", text: content.text });\n } else {\n parts.push({\n id: createId(\"part\"),\n type: \"attachment\",\n attachment: userContentToAttachment(content),\n });\n }\n }\n uiMessages.push({\n id: createId(\"msg\"),\n role: \"user\",\n parts,\n ...uiMetadata(message.metadata),\n });\n continue;\n }\n\n if (message.role === \"assistant\") {\n const parts: UIMessagePart[] = [];\n for (const content of message.content) {\n if (content.type === \"text\") {\n parts.push({ id: createId(\"part\"), type: \"text\", text: content.text });\n continue;\n }\n if (content.type === \"reasoning\") {\n const part: UIMessagePart = {\n id: createId(\"part\"),\n type: \"reasoning\",\n text: reasoningDisplayText(content),\n };\n if (content.id !== undefined) {\n part.reasoningId = content.id;\n }\n parts.push(part);\n continue;\n }\n if (content.type === \"tool_call\") {\n const part: UIMessagePart = {\n id: toolPartId(content.id),\n type: \"tool\",\n toolName: content.function.name,\n toolCallId: content.id,\n state: \"input-available\",\n input: content.function.arguments,\n };\n if (content.callId !== undefined) {\n part.callId = content.callId;\n }\n parts.push(part);\n continue;\n }\n parts.push({\n id: createId(\"part\"),\n type: \"data\",\n name: content.type,\n data: content as JsonValue,\n });\n }\n const messageIndex = uiMessages.length;\n uiMessages.push({\n id: message.id ?? createId(\"msg\"),\n role: \"assistant\",\n parts,\n ...uiMetadata(message.metadata),\n });\n registerToolPartLocations(parts, messageIndex, toolPartLocations);\n continue;\n }\n\n const parts: UIMessagePart[] = [];\n for (const content of message.content) {\n const part: UIToolMessagePart = {\n id: toolPartId(content.id),\n type: \"tool\",\n toolName: toolNameForResult(content, uiMessages, toolPartLocations),\n toolCallId: content.id,\n state: \"output-available\",\n output: toolResultContentToJson(content.content),\n };\n if (content.callId !== undefined) {\n part.callId = content.callId;\n }\n if (\n message.metadata === undefined &&\n mergeToolResultPart(uiMessages, toolPartLocations, part)\n ) {\n continue;\n }\n parts.push(part);\n }\n if (parts.length > 0) {\n uiMessages.push({\n id: createId(\"msg\"),\n role: \"tool\",\n parts,\n ...uiMetadata(message.metadata),\n });\n }\n }\n\n return uiMessages;\n}\n\nfunction metadataOptions(metadata: UIMessage[\"metadata\"]): { metadata?: JsonValue } {\n if (metadata === undefined) {\n return {};\n }\n if (!isJsonValue(metadata)) {\n throw new TypeError(\"UI message metadata must be a strict JSON value.\");\n }\n return { metadata };\n}\n\nfunction uiMetadata(metadata: JsonValue | undefined): { metadata?: JsonValue } {\n if (metadata === undefined) {\n return {};\n }\n if (!isJsonValue(metadata)) {\n throw new TypeError(\"Core message metadata must be a strict JSON value.\");\n }\n return { metadata };\n}\n\nfunction registerToolPartLocations(\n parts: UIMessagePart[],\n messageIndex: number,\n toolPartLocations: UIToolPartLocations,\n): void {\n for (const [partIndex, part] of parts.entries()) {\n if (part.type !== \"tool\") {\n continue;\n }\n const location = { messageIndex, partIndex };\n toolPartLocations.byToolCallId.set(part.toolCallId, location);\n if (part.callId !== undefined) {\n toolPartLocations.byCallId.set(part.callId, location);\n }\n }\n}\n\nfunction mergeToolResultPart(\n uiMessages: UIMessage[],\n toolPartLocations: UIToolPartLocations,\n resultPart: UIMessagePart,\n): boolean {\n if (resultPart.type !== \"tool\") {\n return false;\n }\n\n const location = findToolPartLocation(\n resultPart.toolCallId,\n resultPart.callId,\n toolPartLocations,\n );\n if (location === undefined) {\n return false;\n }\n\n const message = uiMessages[location.messageIndex];\n const currentPart = message?.parts[location.partIndex];\n if (message === undefined || currentPart?.type !== \"tool\") {\n return false;\n }\n\n const mergedPart: UIToolMessagePart = {\n ...currentPart,\n toolName: resultPart.toolName === \"tool\" ? currentPart.toolName : resultPart.toolName,\n state: \"output-available\",\n ...(resultPart.output === undefined ? {} : { output: resultPart.output }),\n };\n if (currentPart.callId === undefined && resultPart.callId !== undefined) {\n mergedPart.callId = resultPart.callId;\n toolPartLocations.byCallId.set(resultPart.callId, location);\n }\n\n const nextParts = [...message.parts];\n nextParts[location.partIndex] = mergedPart;\n uiMessages[location.messageIndex] = { ...message, parts: nextParts };\n return true;\n}\n\nfunction findToolPartLocation(\n toolCallId: string,\n callId: string | undefined,\n toolPartLocations: UIToolPartLocations,\n): UIToolPartLocation | undefined {\n return (\n (callId === undefined ? undefined : toolPartLocations.byCallId.get(callId)) ??\n toolPartLocations.byToolCallId.get(toolCallId)\n );\n}\n\nfunction toolNameForResult(\n content: ToolContentType,\n uiMessages: UIMessage[],\n toolPartLocations: UIToolPartLocations,\n): string {\n if (content.toolName !== undefined) {\n return content.toolName;\n }\n\n const location = findToolPartLocation(content.id, content.callId, toolPartLocations);\n const part =\n location === undefined\n ? undefined\n : uiMessages[location.messageIndex]?.parts[location.partIndex];\n return part?.type === \"tool\" ? part.toolName : \"tool\";\n}\n\nexport function isUIMessage(value: unknown): value is UIMessage {\n return (\n isRecord(value) &&\n typeof value.id === \"string\" &&\n isUIMessageRole(value.role) &&\n Array.isArray(value.parts)\n );\n}\n\nexport function isUIMessageArray(value: unknown): value is UIMessage[] {\n return Array.isArray(value) && value.every(isUIMessage);\n}\n\nfunction textFromUIParts(parts: UIMessagePart[]): string {\n return parts.flatMap((part) => (part.type === \"text\" ? [part.text] : [])).join(\"\");\n}\n\nfunction outputToToolResultContent(output: JsonValue | undefined): ToolResultContent[] {\n return [{ type: \"text\", text: serializeToolResultOutput(output ?? null) }];\n}\n\nfunction attachmentToUserContent(attachment: UIAttachment): UserContentType {\n if (attachment.type === \"image\" || isImageFileAttachment(attachment)) {\n if (attachment.url !== undefined) {\n return UserContent.imageUrl(attachment.url, imageOptions(attachment));\n }\n if (attachment.data !== undefined && attachment.mediaType !== undefined) {\n return UserContent.imageBase64(\n attachment.data,\n attachment.mediaType,\n imageOptions(attachment),\n );\n }\n throw new TypeError(\"Image attachments require a url or base64 data with mediaType.\");\n }\n\n if (attachment.text !== undefined) {\n return {\n type: \"document\",\n source: {\n type: \"text\",\n text: attachment.text,\n ...(attachment.mediaType === undefined ? {} : { mediaType: attachment.mediaType }),\n ...(attachment.name === undefined ? {} : { filename: attachment.name }),\n },\n };\n }\n\n const mediaType = attachment.mediaType ?? \"application/octet-stream\";\n if (attachment.url !== undefined) {\n return UserContent.documentUrl(attachment.url, mediaType, documentOptions(attachment));\n }\n if (attachment.data !== undefined) {\n return UserContent.documentBase64(attachment.data, mediaType, documentOptions(attachment));\n }\n\n throw new TypeError(\"Document attachments require a url, base64 data, or text.\");\n}\n\nfunction userContentToAttachment(content: ImageContent | DocumentContent): UIAttachment {\n if (content.type === \"image\") {\n const attachment: UIAttachment = {\n id: createId(\"attachment\"),\n type: \"image\",\n ...(content.detail === undefined ? {} : { detail: content.detail }),\n };\n if (content.source.type === \"url\") {\n attachment.url = content.source.url;\n } else {\n attachment.data = content.source.data;\n attachment.mediaType = content.source.mediaType;\n }\n return attachment;\n }\n\n const attachment: UIAttachment = {\n id: createId(\"attachment\"),\n type: \"document\",\n };\n if (content.source.type === \"url\") {\n attachment.url = content.source.url;\n attachment.mediaType = content.source.mediaType;\n if (content.source.filename !== undefined) {\n attachment.name = content.source.filename;\n }\n } else if (content.source.type === \"base64\") {\n attachment.data = content.source.data;\n attachment.mediaType = content.source.mediaType;\n if (content.source.filename !== undefined) {\n attachment.name = content.source.filename;\n }\n } else {\n attachment.text = content.source.text;\n if (content.source.mediaType !== undefined) {\n attachment.mediaType = content.source.mediaType;\n }\n if (content.source.filename !== undefined) {\n attachment.name = content.source.filename;\n }\n }\n return attachment;\n}\n\nfunction isImageFileAttachment(attachment: UIAttachment): boolean {\n return attachment.type === \"file\" && attachment.mediaType?.startsWith(\"image/\") === true;\n}\n\nfunction imageOptions(attachment: UIAttachment): { detail?: ImageDetail } {\n return attachment.detail === undefined ? {} : { detail: attachment.detail };\n}\n\nfunction documentOptions(attachment: UIAttachment): { filename?: string } {\n return attachment.name === undefined ? {} : { filename: attachment.name };\n}\n\nfunction toolResultContentToJson(content: ToolResultContent[]): JsonValue {\n if (content.length === 1 && content[0]?.type === \"text\") {\n return content[0].text;\n }\n return content as JsonValue;\n}\n\nfunction isUserContent(value: unknown): value is UserContentType {\n if (!isRecord(value)) {\n return false;\n }\n\n if (value.type === \"text\") {\n return typeof value.text === \"string\";\n }\n\n if (value.type === \"image\") {\n return isImageContent(value);\n }\n\n if (value.type === \"document\") {\n return isDocumentContent(value);\n }\n\n return false;\n}\n\nfunction isImageContent(value: Record<string, unknown>): boolean {\n if (!isRecord(value.source)) {\n return false;\n }\n\n if (value.source.type === \"url\") {\n return typeof value.source.url === \"string\";\n }\n\n if (value.source.type === \"base64\") {\n return typeof value.source.data === \"string\" && typeof value.source.mediaType === \"string\";\n }\n\n return false;\n}\n\nfunction isDocumentContent(value: Record<string, unknown>): boolean {\n if (!isRecord(value.source)) {\n return false;\n }\n\n if (value.source.type === \"url\") {\n return typeof value.source.url === \"string\" && typeof value.source.mediaType === \"string\";\n }\n\n if (value.source.type === \"base64\") {\n return typeof value.source.data === \"string\" && typeof value.source.mediaType === \"string\";\n }\n\n if (value.source.type === \"text\") {\n return (\n typeof value.source.text === \"string\" &&\n (value.source.mediaType === undefined || typeof value.source.mediaType === \"string\")\n );\n }\n\n return false;\n}\n\nfunction toolPartId(toolCallId: string): string {\n return `tool_${toolCallId}`;\n}\n\nlet nextId = 0;\n\nfunction createId(prefix: string): string {\n const random = globalThis.crypto?.randomUUID?.();\n if (random !== undefined) {\n return `${prefix}_${random}`;\n }\n nextId += 1;\n return `${prefix}_${nextId.toString(36)}`;\n}\n\nfunction isUIMessageRole(value: unknown): value is UIMessage[\"role\"] {\n return value === \"system\" || value === \"user\" || value === \"assistant\" || value === \"tool\";\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n"],"mappings":";;;;;;;;;;;AAgCO,SAAS,yBAAyB,UAAsC;AAC7E,QAAM,eAA8B,CAAC;AAErC,aAAW,WAAW,UAAU;AAC9B,UAAM,OAAO,gBAAgB,QAAQ,KAAK;AAE1C,QAAI,QAAQ,SAAS,UAAU;AAC7B,UAAI,KAAK,SAAS,GAAG;AACnB,qBAAa,KAAK,QAAQ,OAAO,MAAM,gBAAgB,QAAQ,QAAQ,CAAC,CAAC;AAAA,MAC3E;AACA;AAAA,IACF;AAEA,QAAI,QAAQ,SAAS,QAAQ;AAC3B,YAAM,UAA6B,CAAC;AACpC,iBAAW,QAAQ,QAAQ,OAAO;AAChC,YAAI,KAAK,SAAS,QAAQ;AACxB,kBAAQ,KAAK,YAAY,KAAK,KAAK,IAAI,CAAC;AACxC;AAAA,QACF;AACA,YAAI,KAAK,SAAS,cAAc;AAC9B,kBAAQ,KAAK,wBAAwB,KAAK,UAAU,CAAC;AACrD;AAAA,QACF;AACA,YAAI,KAAK,SAAS,UAAU,cAAc,KAAK,IAAI,GAAG;AACpD,kBAAQ,KAAK,KAAK,IAAI;AACtB;AAAA,QACF;AACA,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AAAA,MACF;AACA,UAAI,QAAQ,SAAS,GAAG;AACtB,q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3B,WAAO;AAAA,EACT;AAEA,MAAI,MAAM,OAAO,SAAS,OAAO;AAC/B,WAAO,OAAO,MAAM,OAAO,QAAQ,YAAY,OAAO,MAAM,OAAO,cAAc;AAAA,EACnF;AAEA,MAAI,MAAM,OAAO,SAAS,UAAU;AAClC,WAAO,OAAO,MAAM,OAAO,SAAS,YAAY,OAAO,MAAM,OAAO,cAAc;AAAA,EACpF;AAEA,MAAI,MAAM,OAAO,SAAS,QAAQ;AAChC,WACE,OAAO,MAAM,OAAO,SAAS,aAC5B,MAAM,OAAO,cAAc,UAAa,OAAO,MAAM,OAAO,cAAc;AAAA,EAE/E;AAEA,SAAO;AACT;AAEA,SAAS,WAAW,YAA4B;AAC9C,SAAO,QAAQ,UAAU;AAC3B;AAEA,IAAI,SAAS;AAEb,SAAS,SAAS,QAAwB;AACxC,QAAM,SAAS,WAAW,QAAQ,aAAa;AAC/C,MAAI,WAAW,QAAW;AACxB,WAAO,GAAG,MAAM,IAAI,MAAM;AAAA,EAC5B;AACA,YAAU;AACV,SAAO,GAAG,MAAM,IAAI,OAAO,SAAS,EAAE,CAAC;AACzC;AAMA,SAAS,SAAS,OAAkD;AAClE,SAAO,OAAO,UAAU,YAAY,UAAU;AAChD;","names":["toolResults","parts","attachment"]}
@@ -1,20 +1,20 @@
1
1
  import {
2
2
  AgentBuilder
3
- } from "./chunk-WRNPY5C6.js";
3
+ } from "./chunk-JT4U4FGG.js";
4
4
  import {
5
5
  extractRagText
6
- } from "./chunk-EGZCTSEW.js";
6
+ } from "./chunk-HLISYYCB.js";
7
7
  import {
8
8
  createTool
9
9
  } from "./chunk-IZM6FNCT.js";
10
10
  import {
11
11
  CompletionRequestBuilder
12
- } from "./chunk-FUJ3POKH.js";
12
+ } from "./chunk-W53PLBOL.js";
13
13
  import {
14
14
  CompletionCapabilityError,
15
15
  Message,
16
16
  Usage
17
- } from "./chunk-QVFOCNF6.js";
17
+ } from "./chunk-7H3TQN3I.js";
18
18
 
19
19
  // src/extractor/extractor.ts
20
20
  var SUBMIT_TOOL_NAME = "submit";
@@ -138,4 +138,4 @@ export {
138
138
  Extractor,
139
139
  ExtractorBuilder
140
140
  };
141
- //# sourceMappingURL=chunk-IN5NPAWL.js.map
141
+ //# sourceMappingURL=chunk-OCYL4AB6.js.map
@@ -2,7 +2,7 @@ import {
2
2
  Message,
3
3
  assertCompletionRequestSupported,
4
4
  textFromAssistantContent
5
- } from "./chunk-QVFOCNF6.js";
5
+ } from "./chunk-7H3TQN3I.js";
6
6
  import {
7
7
  toProviderJsonSchema
8
8
  } from "./chunk-WQKHFADH.js";
@@ -335,4 +335,4 @@ export {
335
335
  formatDocument,
336
336
  CompletionRequestBuilder
337
337
  };
338
- //# sourceMappingURL=chunk-FUJ3POKH.js.map
338
+ //# sourceMappingURL=chunk-W53PLBOL.js.map