@anvia/core 0.12.7 → 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 (68) hide show
  1. package/dist/agent/index.d.ts +11 -11
  2. package/dist/agent/index.js +8 -8
  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-YZLOFKTT.js → chunk-46IR5ZTN.js} +6 -6
  6. package/dist/{chunk-N3I6HH2J.js → chunk-7BV5JBJW.js} +5 -5
  7. package/dist/{chunk-QVFOCNF6.js → chunk-7H3TQN3I.js} +99 -10
  8. package/dist/chunk-7H3TQN3I.js.map +1 -0
  9. package/dist/{chunk-J3ROUB3P.js → chunk-HF4KHHNM.js} +2 -2
  10. package/dist/{chunk-5MUPA66B.js → chunk-HLISYYCB.js} +11 -8
  11. package/dist/chunk-HLISYYCB.js.map +1 -0
  12. package/dist/{chunk-QKA6OQTH.js → chunk-IZM6FNCT.js} +4 -4
  13. package/dist/{chunk-JJ3JGL5D.js → chunk-JT4U4FGG.js} +3 -3
  14. package/dist/{chunk-WEOG3JCT.js → chunk-MU3UPROJ.js} +76 -40
  15. package/dist/chunk-MU3UPROJ.js.map +1 -0
  16. package/dist/{chunk-TD6A4RYQ.js → chunk-OCYL4AB6.js} +6 -6
  17. package/dist/{chunk-FUJ3POKH.js → chunk-W53PLBOL.js} +2 -2
  18. package/dist/completion/index.d.ts +3 -3
  19. package/dist/completion/index.js +4 -2
  20. package/dist/evals/index.d.ts +8 -8
  21. package/dist/evals/index.js +9 -9
  22. package/dist/extractor/index.d.ts +8 -8
  23. package/dist/extractor/index.js +9 -9
  24. package/dist/guardrails/index.d.ts +1 -1
  25. package/dist/hooks/index.d.ts +3 -3
  26. package/dist/image-generation/index.d.ts +1 -1
  27. package/dist/{index-CM-V4LS3.d.ts → index-ZQAiHW5Q.d.ts} +2 -2
  28. package/dist/index.d.ts +12 -12
  29. package/dist/index.js +14 -12
  30. package/dist/internal/agent.d.ts +8 -8
  31. package/dist/internal/agent.js +7 -7
  32. package/dist/{create-completion-CC8-Ep3w.d.ts → json-C5a6auAm.d.ts} +4 -2
  33. package/dist/loaders/index.d.ts +1 -1
  34. package/dist/mcp/index.d.ts +4 -4
  35. package/dist/memory/index.d.ts +3 -3
  36. package/dist/{middleware-i-jLsLom.d.ts → middleware-Cc_-sosu.d.ts} +3 -3
  37. package/dist/observability/index.d.ts +3 -3
  38. package/dist/pipeline/index.d.ts +8 -8
  39. package/dist/request/index.d.ts +8 -8
  40. package/dist/request/index.js +6 -6
  41. package/dist/skills/index.d.ts +4 -4
  42. package/dist/skills/index.js +5 -5
  43. package/dist/{think-tool-BKDCOJh5.d.ts → think-tool-DvhOlrL8.d.ts} +1 -1
  44. package/dist/tool/index.d.ts +5 -5
  45. package/dist/tool/index.js +5 -5
  46. package/dist/{tool-f2stpvUP.d.ts → tool-6f9bK92X.d.ts} +1 -1
  47. package/dist/transcription/index.d.ts +1 -1
  48. package/dist/{types-5JgWDgaM.d.ts → types-BG3s2WzI.d.ts} +2 -2
  49. package/dist/{types-b6fOVoW1.d.ts → types-BZQlZ4Vs.d.ts} +1 -1
  50. package/dist/{types-Dh7gfoGw.d.ts → types-BaYwqozV.d.ts} +1 -1
  51. package/dist/{types-DmvXANwl.d.ts → types-C708DOhL.d.ts} +1 -1
  52. package/dist/{types-bNDxj4Tt.d.ts → types-CNeDsGjw.d.ts} +1 -1
  53. package/dist/{types-C15r7N_4.d.ts → types-DzdJOf35.d.ts} +17 -6
  54. package/dist/ui/index.d.ts +1 -1
  55. package/dist/ui/index.js +2 -2
  56. package/dist/vector-store/index.d.ts +4 -4
  57. package/dist/vector-store/index.js +2 -2
  58. package/package.json +1 -1
  59. package/dist/chunk-5MUPA66B.js.map +0 -1
  60. package/dist/chunk-QVFOCNF6.js.map +0 -1
  61. package/dist/chunk-WEOG3JCT.js.map +0 -1
  62. /package/dist/{chunk-YZLOFKTT.js.map → chunk-46IR5ZTN.js.map} +0 -0
  63. /package/dist/{chunk-N3I6HH2J.js.map → chunk-7BV5JBJW.js.map} +0 -0
  64. /package/dist/{chunk-J3ROUB3P.js.map → chunk-HF4KHHNM.js.map} +0 -0
  65. /package/dist/{chunk-QKA6OQTH.js.map → chunk-IZM6FNCT.js.map} +0 -0
  66. /package/dist/{chunk-JJ3JGL5D.js.map → chunk-JT4U4FGG.js.map} +0 -0
  67. /package/dist/{chunk-TD6A4RYQ.js.map → chunk-OCYL4AB6.js.map} +0 -0
  68. /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,20 +1,20 @@
1
1
  import {
2
2
  AgentBuilder
3
- } from "../chunk-JJ3JGL5D.js";
4
- import "../chunk-N3I6HH2J.js";
5
- import "../chunk-5MUPA66B.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-YZLOFKTT.js";
9
- import "../chunk-QKA6OQTH.js";
8
+ import "../chunk-46IR5ZTN.js";
9
+ import "../chunk-IZM6FNCT.js";
10
10
  import "../chunk-NPZDYOE6.js";
11
11
  import "../chunk-MMHG7WAM.js";
12
12
  import "../chunk-M6RPFHG7.js";
13
- import "../chunk-FUJ3POKH.js";
14
- import "../chunk-QVFOCNF6.js";
15
- import "../chunk-WQKHFADH.js";
16
13
  import "../chunk-JS5MGVNM.js";
17
14
  import "../chunk-OIMLU4SF.js";
15
+ import "../chunk-W53PLBOL.js";
16
+ import "../chunk-7H3TQN3I.js";
17
+ import "../chunk-WQKHFADH.js";
18
18
  import "../chunk-CWUJUSOS.js";
19
19
  export {
20
20
  AgentBuilder
@@ -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;
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  InMemoryVectorStore,
3
3
  createTool
4
- } from "./chunk-QKA6OQTH.js";
4
+ } from "./chunk-IZM6FNCT.js";
5
5
  import {
6
6
  compact
7
7
  } from "./chunk-MMHG7WAM.js";
8
- import {
9
- isToolResultContentArray,
10
- serializeToolResultOutput
11
- } from "./chunk-QVFOCNF6.js";
12
8
  import {
13
9
  embedDocuments
14
10
  } from "./chunk-JS5MGVNM.js";
11
+ import {
12
+ isToolResultContentArray,
13
+ serializeToolResultOutput
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-YZLOFKTT.js.map
228
+ //# sourceMappingURL=chunk-46IR5ZTN.js.map
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  PromptRequest
3
- } from "./chunk-5MUPA66B.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-YZLOFKTT.js";
9
+ } from "./chunk-46IR5ZTN.js";
10
10
  import {
11
11
  createTool
12
- } from "./chunk-QKA6OQTH.js";
12
+ } from "./chunk-IZM6FNCT.js";
13
13
  import {
14
14
  compact
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-N3I6HH2J.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;AAE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,SAAS,SACb,QAAQ,QAAQ;AAAA,MACd,CAAC,YAAY,QAAQ,SAAS,cAAc,QAAQ,OAAO,SAAS;AAAA,IACtE,IACA;AAAA,EACN;AACF;","names":[]}
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-YK4WAAS4.js";
4
4
  import {
5
5
  createTool
6
- } from "./chunk-QKA6OQTH.js";
6
+ } from "./chunk-IZM6FNCT.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-MMHG7WAM.js";
@@ -395,4 +395,4 @@ export {
395
395
  SkillValidationError,
396
396
  skill
397
397
  };
398
- //# sourceMappingURL=chunk-J3ROUB3P.js.map
398
+ //# sourceMappingURL=chunk-HF4KHHNM.js.map
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  parseToolArgs,
6
6
  toolResultContentToText
7
- } from "./chunk-YZLOFKTT.js";
7
+ } from "./chunk-46IR5ZTN.js";
8
8
  import {
9
9
  runControl,
10
10
  toolCallControl
@@ -12,10 +12,13 @@ import {
12
12
  import {
13
13
  compact
14
14
  } from "./chunk-MMHG7WAM.js";
15
+ import {
16
+ mapWithConcurrency
17
+ } from "./chunk-OIMLU4SF.js";
15
18
  import {
16
19
  CompletionRequestBuilder,
17
20
  isStreamingCompletionModel
18
- } from "./chunk-FUJ3POKH.js";
21
+ } from "./chunk-W53PLBOL.js";
19
22
  import {
20
23
  AssistantContent,
21
24
  Message,
@@ -23,10 +26,7 @@ import {
23
26
  Usage,
24
27
  assertCompletionRequestSupported,
25
28
  textFromAssistantContent
26
- } from "./chunk-QVFOCNF6.js";
27
- import {
28
- mapWithConcurrency
29
- } from "./chunk-OIMLU4SF.js";
29
+ } from "./chunk-7H3TQN3I.js";
30
30
  import {
31
31
  appendGuardrailPolicies,
32
32
  hasEnforcedOutputGuardrails,
@@ -788,7 +788,10 @@ var ToolCallExecutor = class {
788
788
  resultPayload.toolCallId = toolCall.callId;
789
789
  }
790
790
  onResult?.(resultPayload);
791
- return ToolContent.toolResult(toolCall.id, output, toolCall.callId);
791
+ return ToolContent.toolResult(toolCall.id, output, {
792
+ callId: toolCall.callId,
793
+ toolName: toolCall.function.name
794
+ });
792
795
  });
793
796
  }
794
797
  async runApprovedToolCall(toolCall, hookArgs, effectiveArgs, originalArgs, toolObservers, observation, onStreamEvent, applyInputMiddleware = true) {
@@ -2100,4 +2103,4 @@ export {
2100
2103
  extractRagText,
2101
2104
  PromptRequest
2102
2105
  };
2103
- //# sourceMappingURL=chunk-5MUPA66B.js.map
2106
+ //# sourceMappingURL=chunk-HLISYYCB.js.map