@anvia/core 0.11.1-preview.20260628T094557.2ab9488 → 0.11.1

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 (52) hide show
  1. package/dist/agent/index.d.ts +24 -24
  2. package/dist/agent/index.js +5 -5
  3. package/dist/{agent-DLTzn7ra.d.ts → agent-DoF-xWGj.d.ts} +6 -4
  4. package/dist/{chunk-ZT2YH2GA.js → chunk-246MPVBE.js} +2 -2
  5. package/dist/{chunk-2VHGGLVM.js → chunk-AREAH2X5.js} +1 -1
  6. package/dist/chunk-AREAH2X5.js.map +1 -0
  7. package/dist/{chunk-IA47SXLS.js → chunk-BVGDCFQW.js} +3 -3
  8. package/dist/{chunk-Y7OAD3DF.js → chunk-IFQVPV32.js} +232 -162
  9. package/dist/chunk-IFQVPV32.js.map +1 -0
  10. package/dist/{chunk-YV7CDQYS.js → chunk-M4T4ID34.js} +3 -3
  11. package/dist/chunk-M4T4ID34.js.map +1 -0
  12. package/dist/{chunk-66IJDP6L.js → chunk-T22FYPE2.js} +2 -2
  13. package/dist/chunk-T22FYPE2.js.map +1 -0
  14. package/dist/{chunk-AJOVBRZQ.js → chunk-VJ7AZVLS.js} +4 -4
  15. package/dist/chunk-VJ7AZVLS.js.map +1 -0
  16. package/dist/{chunk-FTO3W4UP.js → chunk-W4DZU6IW.js} +1 -1
  17. package/dist/chunk-W4DZU6IW.js.map +1 -0
  18. package/dist/embeddings/index.js +1 -1
  19. package/dist/evals/index.d.ts +4 -4
  20. package/dist/evals/index.js +6 -6
  21. package/dist/evals/index.js.map +1 -1
  22. package/dist/extractor/index.d.ts +4 -4
  23. package/dist/extractor/index.js +6 -6
  24. package/dist/index.d.ts +4 -4
  25. package/dist/index.js +7 -7
  26. package/dist/internal/agent.d.ts +4 -4
  27. package/dist/internal/agent.js +4 -4
  28. package/dist/mcp/index.js.map +1 -1
  29. package/dist/{middleware-B1JD4UmI.d.ts → middleware-D7nRBusA.d.ts} +1 -1
  30. package/dist/observability/index.js.map +1 -1
  31. package/dist/pipeline/index.d.ts +4 -4
  32. package/dist/skills/index.js +4 -4
  33. package/dist/tool/index.d.ts +2 -2
  34. package/dist/tool/index.js +3 -3
  35. package/dist/transcription/index.d.ts +1 -0
  36. package/dist/transcription/index.js +1 -1
  37. package/dist/transcription/index.js.map +1 -1
  38. package/dist/types-B0cuzkjP.d.ts +79 -0
  39. package/dist/ui/index.d.ts +3 -3
  40. package/dist/ui/index.js +1 -1
  41. package/dist/vector-store/index.d.ts +3 -76
  42. package/dist/vector-store/index.js +2 -2
  43. package/package.json +2 -2
  44. package/dist/chunk-2VHGGLVM.js.map +0 -1
  45. package/dist/chunk-66IJDP6L.js.map +0 -1
  46. package/dist/chunk-AJOVBRZQ.js.map +0 -1
  47. package/dist/chunk-FTO3W4UP.js.map +0 -1
  48. package/dist/chunk-Y7OAD3DF.js.map +0 -1
  49. package/dist/chunk-YV7CDQYS.js.map +0 -1
  50. /package/dist/{chunk-ZT2YH2GA.js.map → chunk-246MPVBE.js.map} +0 -0
  51. /package/dist/{chunk-IA47SXLS.js.map → chunk-BVGDCFQW.js.map} +0 -0
  52. /package/dist/{request-types-C2ArxcON.d.ts → types-C2ArxcON.d.ts} +0 -0
@@ -1,23 +1,39 @@
1
- import { A as AnyTool, e as ToolApprovalsOptions, d as ToolApprovalRequest } from '../tool-Hlcb459D.js';
1
+ import { D as DynamicContextOptions, d as DynamicToolOptions, P as PromptHook, e as AgentEventStore, f as AgentEventStoreOptions, A as Agent } from '../agent-DoF-xWGj.js';
2
+ export { g as AgentEventAppendInput, h as AgentEventRecord, i as AgentEventStoreInclude, C as CompletionCallHookArgs, j as CompletionErrorHookArgs, k as CompletionResponseHookArgs, H as HookAction, l as HookResult, R as RunControl, m as RunEndHookArgs, n as RunErrorHookArgs, o as RunStartHookArgs, T as ToolApprovalRequestOptions, p as ToolCallControl, q as ToolCallHookAction, u as ToolCallHookArgs, v as ToolCallHookResult, w as ToolErrorHookArgs, x as ToolHookArgs, y as ToolResultHookArgs, z as TurnEndHookArgs, B as TurnStartHookArgs, c as cancelPrompt, a as createHook, r as requestToolApproval, b as runControl, s as skipTool, t as toolCallControl } from '../agent-DoF-xWGj.js';
3
+ import { M as Message, C as CompletionModel, e as JsonValue, o as ToolChoice } from '../types-CP3iyh6j.js';
4
+ import { d as ToolApprovalRequest, A as AnyTool, e as ToolApprovalsOptions } from '../tool-Hlcb459D.js';
2
5
  export { b as ToolApprovalDecision } from '../tool-Hlcb459D.js';
3
- import { k as ToolSearchDocument, l as ToolSet, A as AgentMiddleware, e as ToolMiddleware } from '../middleware-B1JD4UmI.js';
4
- export { C as CompletionRequestMiddlewareArgs, a as CompletionRequestMiddlewareResult, b as CompletionResponseMiddlewareArgs, c as CompletionResponseMiddlewareResult, T as ToolInputMiddlewareArgs, d as ToolInputMiddlewareResult, f as ToolOutputMiddlewareArgs, g as ToolOutputMiddlewareResult, h as ToolResultMiddlewareArgs, i as createMiddleware, j as createToolMiddleware } from '../middleware-B1JD4UmI.js';
5
- import { D as DynamicContextOptions, d as DynamicToolOptions, P as PromptHook, e as AgentEventStore, f as AgentEventStoreOptions, A as Agent } from '../agent-DLTzn7ra.js';
6
- export { g as AgentEventAppendInput, h as AgentEventRecord, i as AgentEventStoreInclude, C as CompletionCallHookArgs, j as CompletionErrorHookArgs, k as CompletionResponseHookArgs, H as HookAction, l as HookResult, R as RunControl, m as RunEndHookArgs, n as RunErrorHookArgs, o as RunStartHookArgs, T as ToolApprovalRequestOptions, p as ToolCallControl, q as ToolCallHookAction, u as ToolCallHookArgs, v as ToolCallHookResult, w as ToolErrorHookArgs, x as ToolHookArgs, y as ToolResultHookArgs, z as TurnEndHookArgs, B as TurnStartHookArgs, c as cancelPrompt, a as createHook, r as requestToolApproval, b as runControl, s as skipTool, t as toolCallControl } from '../agent-DLTzn7ra.js';
6
+ export { A as AgentChildStreamEvent, a as AgentStreamEvent, P as PromptResponse } from '../types-C2ArxcON.js';
7
+ import { k as ToolSearchDocument, l as ToolSet, A as AgentMiddleware, e as ToolMiddleware } from '../middleware-D7nRBusA.js';
8
+ export { C as CompletionRequestMiddlewareArgs, a as CompletionRequestMiddlewareResult, b as CompletionResponseMiddlewareArgs, c as CompletionResponseMiddlewareResult, T as ToolInputMiddlewareArgs, d as ToolInputMiddlewareResult, f as ToolOutputMiddlewareArgs, g as ToolOutputMiddlewareResult, h as ToolResultMiddlewareArgs, i as createMiddleware, j as createToolMiddleware } from '../middleware-D7nRBusA.js';
7
9
  import { Z as ZodSchema } from '../zod-schema-C7F4clpm.js';
8
- import { C as CompletionModel, e as JsonValue, o as ToolChoice, M as Message } from '../types-CP3iyh6j.js';
9
10
  import { a as McpServer } from '../types-CiFIAGqq.js';
10
11
  import { MemoryStore, MemoryOptions } from '../memory/index.js';
11
12
  import { AgentObserver, ObserveOptions } from '../observability/index.js';
12
13
  import { a as SkillSet } from '../types-DrkBkjzk.js';
13
- import { VectorSearchIndex } from '../vector-store/index.js';
14
- export { A as AgentChildStreamEvent, a as AgentStreamEvent, P as PromptResponse } from '../request-types-C2ArxcON.js';
14
+ import { a as VectorSearchIndex } from '../types-B0cuzkjP.js';
15
15
  import '../types-IB2e9u5M.js';
16
16
  import 'zod';
17
17
  import '@modelcontextprotocol/sdk/client/sse.js';
18
18
  import '@modelcontextprotocol/sdk/client/stdio.js';
19
19
  import '@modelcontextprotocol/sdk/client/streamableHttp.js';
20
20
 
21
+ declare class MaxTurnsError extends Error {
22
+ readonly maxTurns: number;
23
+ readonly chatHistory: Message[];
24
+ readonly prompt: Message;
25
+ constructor(maxTurns: number, chatHistory: Message[], prompt: Message);
26
+ }
27
+ declare class PromptCancelledError extends Error {
28
+ readonly chatHistory: Message[];
29
+ readonly reason: string;
30
+ constructor(chatHistory: Message[], reason: string);
31
+ }
32
+ declare class ToolApprovalRequiredError extends Error {
33
+ readonly request: ToolApprovalRequest;
34
+ constructor(request: ToolApprovalRequest);
35
+ }
36
+
21
37
  declare class AgentBuilder<M extends CompletionModel = CompletionModel> {
22
38
  private readonly completionModel;
23
39
  private readonly agentId;
@@ -78,20 +94,4 @@ declare class AgentBuilder<M extends CompletionModel = CompletionModel> {
78
94
  private buildInstructions;
79
95
  }
80
96
 
81
- declare class MaxTurnsError extends Error {
82
- readonly maxTurns: number;
83
- readonly chatHistory: Message[];
84
- readonly prompt: Message;
85
- constructor(maxTurns: number, chatHistory: Message[], prompt: Message);
86
- }
87
- declare class PromptCancelledError extends Error {
88
- readonly chatHistory: Message[];
89
- readonly reason: string;
90
- constructor(chatHistory: Message[], reason: string);
91
- }
92
- declare class ToolApprovalRequiredError extends Error {
93
- readonly request: ToolApprovalRequest;
94
- constructor(request: ToolApprovalRequest);
95
- }
96
-
97
97
  export { AgentBuilder, AgentEventStore, AgentEventStoreOptions, AgentMiddleware, MaxTurnsError, PromptCancelledError, PromptHook, ToolApprovalRequest, ToolApprovalRequiredError, ToolApprovalsOptions, ToolMiddleware };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AgentBuilder
3
- } from "../chunk-YV7CDQYS.js";
3
+ } from "../chunk-M4T4ID34.js";
4
4
  import {
5
5
  MaxTurnsError,
6
6
  PromptCancelledError,
@@ -11,20 +11,20 @@ import {
11
11
  runControl,
12
12
  skipTool,
13
13
  toolCallControl
14
- } from "../chunk-Y7OAD3DF.js";
14
+ } from "../chunk-IFQVPV32.js";
15
15
  import "../chunk-XUUY2L2D.js";
16
16
  import "../chunk-XXT2UCAR.js";
17
17
  import "../chunk-YK4WAAS4.js";
18
18
  import {
19
19
  createMiddleware,
20
20
  createToolMiddleware
21
- } from "../chunk-IA47SXLS.js";
22
- import "../chunk-66IJDP6L.js";
21
+ } from "../chunk-BVGDCFQW.js";
22
+ import "../chunk-T22FYPE2.js";
23
23
  import "../chunk-MMHG7WAM.js";
24
24
  import "../chunk-5G3VME2D.js";
25
25
  import "../chunk-WJO6NVE2.js";
26
26
  import "../chunk-WQKHFADH.js";
27
- import "../chunk-FTO3W4UP.js";
27
+ import "../chunk-W4DZU6IW.js";
28
28
  import "../chunk-OIMLU4SF.js";
29
29
  export {
30
30
  AgentBuilder,
@@ -1,10 +1,10 @@
1
1
  import { M as Message, U as Usage, c as CompletionResponse, k as ToolResultContent, C as CompletionModel, D as Document, e as JsonValue, o as ToolChoice, J as JsonObject } from './types-CP3iyh6j.js';
2
2
  import { MemoryContext, MemoryRegistration, SessionOptions } from './memory/index.js';
3
3
  import { AgentTraceOptions, AgentObserverRegistration } from './observability/index.js';
4
- import { A as AgentMiddleware, e as ToolMiddleware, l as ToolSet, k as ToolSearchDocument } from './middleware-B1JD4UmI.js';
5
4
  import { e as ToolApprovalsOptions, T as Tool, A as AnyTool, f as ToolCallContext, N as NormalizedToolOutput } from './tool-Hlcb459D.js';
6
- import { VectorFilter, VectorSearchResult, VectorSearchIndex } from './vector-store/index.js';
7
- import { P as PromptResponse, a as AgentStreamEvent } from './request-types-C2ArxcON.js';
5
+ import { A as AgentMiddleware, e as ToolMiddleware, k as ToolSearchDocument, l as ToolSet } from './middleware-D7nRBusA.js';
6
+ import { V as VectorFilter, c as VectorSearchResult, a as VectorSearchIndex } from './types-B0cuzkjP.js';
7
+ import { P as PromptResponse, a as AgentStreamEvent } from './types-C2ArxcON.js';
8
8
 
9
9
  type HookAction = {
10
10
  type: "continue";
@@ -180,6 +180,7 @@ declare class PromptRequest<M extends CompletionModel = CompletionModel> {
180
180
  private runCompletionResponseHook;
181
181
  private runCompletionErrorHook;
182
182
  private activeMiddlewares;
183
+ private shouldBufferStreamResponseEvents;
183
184
  private drainSteeringMessages;
184
185
  private startRun;
185
186
  private isTerminal;
@@ -213,7 +214,6 @@ type AgentOptions<M extends CompletionModel = CompletionModel> = {
213
214
  memory?: MemoryRegistration | undefined;
214
215
  eventStore?: AgentEventStoreRegistration | undefined;
215
216
  };
216
- declare const DEFAULT_MAX_TURNS = 20;
217
217
  type AgentToolOptions = {
218
218
  name: string;
219
219
  description?: string | undefined;
@@ -265,6 +265,8 @@ type DynamicToolRegistration = {
265
265
  index: VectorSearchIndex<ToolSearchDocument>;
266
266
  options: DynamicToolOptions;
267
267
  };
268
+
269
+ declare const DEFAULT_MAX_TURNS = 20;
268
270
  declare class Agent<M extends CompletionModel = CompletionModel> {
269
271
  readonly id: string;
270
272
  readonly name: string | undefined;
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-YK4WAAS4.js";
4
4
  import {
5
5
  createTool
6
- } from "./chunk-66IJDP6L.js";
6
+ } from "./chunk-T22FYPE2.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-ZT2YH2GA.js.map
398
+ //# sourceMappingURL=chunk-246MPVBE.js.map
@@ -498,4 +498,4 @@ export {
498
498
  completionStreamToUIStream,
499
499
  agentStreamToUIStream
500
500
  };
501
- //# sourceMappingURL=chunk-2VHGGLVM.js.map
501
+ //# sourceMappingURL=chunk-AREAH2X5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ui/messages.ts","../src/ui/index.ts"],"sourcesContent":["import {\n AssistantContent,\n type AssistantContent as AssistantContentType,\n type Message as CoreMessage,\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 { UIMessage, UIMessagePart } from \"./types\";\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));\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 === \"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 parts or image/document data parts.\",\n );\n }\n if (content.length > 0) {\n coreMessages.push(Message.user(content));\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(\n part.toolCallId,\n outputToToolResultContent(part.output),\n part.callId,\n ),\n );\n }\n }\n }\n if (content.length > 0) {\n coreMessages.push(Message.assistant(content, message.id));\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(\n part.toolCallId,\n outputToToolResultContent(part.output),\n part.callId,\n ),\n );\n }\n if (toolResults.length > 0) {\n coreMessages.push(Message.tool(toolResults));\n }\n }\n\n return coreMessages;\n}\n\nexport function coreMessagesToUIMessages(messages: CoreMessage[]): UIMessage[] {\n const uiMessages: UIMessage[] = [];\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 });\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: \"data\",\n name: content.type,\n data: content as JsonValue,\n });\n }\n }\n uiMessages.push({ id: createId(\"msg\"), role: \"user\", parts });\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 uiMessages.push({ id: message.id ?? createId(\"msg\"), role: \"assistant\", parts });\n continue;\n }\n\n const parts: UIMessagePart[] = [];\n for (const content of message.content) {\n const part: UIMessagePart = {\n id: toolPartId(content.id),\n type: \"tool\",\n toolName: \"tool\",\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 parts.push(part);\n }\n uiMessages.push({ id: createId(\"msg\"), role: \"tool\", parts });\n }\n\n return uiMessages;\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 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","import {\n type Message as CoreMessage,\n type CreateCompletionStreamOptions,\n createCompletionStream,\n type JsonValue,\n serializeToolResultOutput,\n textFromAssistantContent,\n} from \"../completion\";\nimport type { CompletionStreamEvent, StreamingCompletionModel } from \"../completion/types\";\nimport type { AgentStreamEvent } from \"../request/types\";\nimport { uiMessagesToCoreMessages } from \"./messages\";\nimport type { UIError, UIMessage, UIStreamEvent } from \"./types\";\n\nexport {\n coreMessagesToUIMessages,\n uiMessagesToCoreMessages,\n} from \"./messages\";\nexport type {\n UIError,\n UIMessage,\n UIMessagePart,\n UIMessageRole,\n UIStreamEvent,\n UIStreamRequest,\n} from \"./types\";\n\nexport type CreateCompletionUIStreamOptions = Omit<\n CreateCompletionStreamOptions,\n \"input\" | \"messages\"\n> & {\n messages: UIMessage[];\n};\n\nexport type AgentLike = {\n prompt(prompt: string | CoreMessage | CoreMessage[]): {\n stream(): AsyncIterable<AgentStreamEvent>;\n };\n};\n\nexport type CreateAgentUIStreamOptions = {\n messages: UIMessage[];\n};\n\nexport async function* createCompletionUIStream<Model extends StreamingCompletionModel>(\n model: Model,\n options: CreateCompletionUIStreamOptions,\n): AsyncIterable<UIStreamEvent> {\n const { messages, ...completionOptions } = options;\n yield* completionStreamToUIStream(\n createCompletionStream(model, {\n ...completionOptions,\n messages: uiMessagesToCoreMessages(messages),\n }),\n );\n}\n\nexport async function* createAgentUIStream(\n agent: AgentLike,\n options: CreateAgentUIStreamOptions,\n): AsyncIterable<UIStreamEvent> {\n yield* agentStreamToUIStream(agent.prompt(uiMessagesToCoreMessages(options.messages)).stream());\n}\n\nexport async function* completionStreamToUIStream(\n events: AsyncIterable<CompletionStreamEvent>,\n options: { messageId?: string | undefined } = {},\n): AsyncIterable<UIStreamEvent> {\n const messageId = options.messageId ?? createId(\"msg\");\n let accumulatedText = \"\";\n yield messageStart(messageId);\n\n for await (const event of events) {\n if (event.type === \"text_delta\") {\n accumulatedText += event.delta;\n yield {\n type: \"text_delta\",\n messageId,\n partId: textPartId(messageId),\n delta: event.delta,\n };\n continue;\n }\n\n if (event.type === \"reasoning_delta\") {\n const partId = reasoningPartId(messageId, event.id);\n yield {\n type: \"reasoning_delta\",\n messageId,\n partId,\n delta: event.delta,\n };\n continue;\n }\n\n if (event.type === \"tool_call_delta\") {\n const partId = toolPartId(event.id);\n yield {\n type: \"tool_update\",\n messageId,\n partId,\n part: {\n id: partId,\n type: \"tool\",\n toolName: event.name ?? \"\",\n toolCallId: event.id,\n ...(event.callId === undefined ? {} : { callId: event.callId }),\n state: \"input-streaming\",\n ...(event.argumentsDelta === undefined ? {} : { input: event.argumentsDelta }),\n },\n };\n continue;\n }\n\n if (event.type === \"tool_call\") {\n yield {\n type: \"tool_update\",\n messageId,\n partId: toolPartId(event.toolCall.id),\n part: {\n id: toolPartId(event.toolCall.id),\n type: \"tool\",\n toolName: event.toolCall.function.name,\n toolCallId: event.toolCall.id,\n ...(event.toolCall.callId === undefined ? {} : { callId: event.toolCall.callId }),\n state: \"input-available\",\n input: event.toolCall.function.arguments,\n },\n };\n continue;\n }\n\n if (event.type === \"final\") {\n const finalText = textFromAssistantContent(event.response.choice);\n const missingText = missingTextDelta(accumulatedText, finalText);\n if (missingText !== undefined) {\n accumulatedText += missingText;\n yield {\n type: \"text_delta\",\n messageId,\n partId: textPartId(messageId),\n delta: missingText,\n };\n }\n const endEvent: UIStreamEvent = {\n type: \"message_end\",\n messageId,\n usage: event.response.usage,\n };\n if (event.response.messageId !== undefined) {\n endEvent.metadata = { providerMessageId: event.response.messageId };\n }\n yield endEvent;\n continue;\n }\n\n if (event.type === \"error\") {\n yield { type: \"error\", error: uiError(event.error) };\n }\n }\n}\n\nexport async function* agentStreamToUIStream(\n events: AsyncIterable<AgentStreamEvent>,\n options: { messageId?: string | undefined } = {},\n): AsyncIterable<UIStreamEvent> {\n const messageId = options.messageId ?? createId(\"msg\");\n let accumulatedText = \"\";\n yield messageStart(messageId);\n\n for await (const event of events) {\n if (event.type === \"text_delta\") {\n accumulatedText += event.delta;\n yield {\n type: \"text_delta\",\n messageId,\n partId: textPartId(messageId),\n delta: event.delta,\n };\n continue;\n }\n\n if (event.type === \"reasoning_delta\") {\n yield {\n type: \"reasoning_delta\",\n messageId,\n partId: reasoningPartId(messageId, event.id),\n delta: event.delta,\n };\n continue;\n }\n\n if (event.type === \"tool_call\") {\n yield {\n type: \"tool_update\",\n messageId,\n partId: toolPartId(event.toolCall.id),\n part: {\n id: toolPartId(event.toolCall.id),\n type: \"tool\",\n toolName: event.toolCall.function.name,\n toolCallId: event.toolCall.id,\n ...(event.toolCall.callId === undefined ? {} : { callId: event.toolCall.callId }),\n state: \"input-available\",\n input: event.toolCall.function.arguments,\n },\n };\n continue;\n }\n\n if (event.type === \"tool_result\") {\n const toolCallId = event.internalCallId;\n yield {\n type: \"tool_update\",\n messageId,\n partId: toolPartId(toolCallId),\n part: {\n id: toolPartId(toolCallId),\n type: \"tool\",\n toolName: event.toolName,\n toolCallId,\n ...(event.toolCallId === undefined ? {} : { callId: event.toolCallId }),\n state: \"output-available\",\n output:\n event.structuredResult === undefined\n ? event.result\n : (event.structuredResult as JsonValue),\n },\n };\n continue;\n }\n\n if (event.type === \"final\") {\n const missingText = missingTextDelta(accumulatedText, event.output);\n if (missingText !== undefined) {\n accumulatedText += missingText;\n yield {\n type: \"text_delta\",\n messageId,\n partId: textPartId(messageId),\n delta: missingText,\n };\n }\n yield {\n type: \"message_end\",\n messageId,\n usage: event.usage,\n metadata: { runId: event.runId },\n };\n continue;\n }\n\n if (event.type === \"error\") {\n yield { type: \"error\", error: uiError(event.error) };\n }\n }\n}\n\nfunction messageStart(messageId: string): UIStreamEvent {\n return {\n type: \"message_start\",\n message: {\n id: messageId,\n role: \"assistant\",\n parts: [],\n },\n };\n}\n\nfunction uiError(error: unknown): UIError {\n if (error instanceof Error) {\n return { name: error.name, message: error.message };\n }\n return { message: typeof error === \"string\" ? error : serializeToolResultOutput(error) };\n}\n\nfunction missingTextDelta(current: string, finalText: string): string | undefined {\n if (finalText.length === 0 || finalText === current) {\n return undefined;\n }\n if (finalText.startsWith(current)) {\n return finalText.slice(current.length);\n }\n return current.length === 0 ? finalText : undefined;\n}\n\nfunction textPartId(messageId: string): string {\n return `${messageId}_text`;\n}\n\nfunction reasoningPartId(messageId: string, id: string | undefined): string {\n return id === undefined ? `${messageId}_reasoning` : `${messageId}_reasoning_${id}`;\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"],"mappings":";;;;;;;;;;;;;;AAgBO,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,IAAI,CAAC;AAAA,MACxC;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,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,qBAAa,KAAK,QAAQ,KAAK,OAAO,CAAC;AAAA,MACzC;AACA;AAAA,IACF;AAEA,QAAI,QAAQ,SAAS,aAAa;AAChC,YAAM,UAAkC,CA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AiB,OAAO;AAC1B,WAAO,EAAE,MAAM,MAAM,MAAM,SAAS,MAAM,QAAQ;AAAA,EACpD;AACA,SAAO,EAAE,SAAS,OAAO,UAAU,WAAW,QAAQ,0BAA0B,KAAK,EAAE;AACzF;AAEA,SAAS,iBAAiB,SAAiB,WAAuC;AAChF,MAAI,UAAU,WAAW,KAAK,cAAc,SAAS;AACnD,WAAO;AAAA,EACT;AACA,MAAI,UAAU,WAAW,OAAO,GAAG;AACjC,WAAO,UAAU,MAAM,QAAQ,MAAM;AAAA,EACvC;AACA,SAAO,QAAQ,WAAW,IAAI,YAAY;AAC5C;AAEA,SAAS,WAAW,WAA2B;AAC7C,SAAO,GAAG,SAAS;AACrB;AAEA,SAAS,gBAAgB,WAAmB,IAAgC;AAC1E,SAAO,OAAO,SAAY,GAAG,SAAS,eAAe,GAAG,SAAS,cAAc,EAAE;AACnF;AAEA,SAASA,YAAW,YAA4B;AAC9C,SAAO,QAAQ,UAAU;AAC3B;AAEA,IAAIC,UAAS;AAEb,SAASF,UAAS,QAAwB;AACxC,QAAM,SAAS,WAAW,QAAQ,aAAa;AAC/C,MAAI,WAAW,QAAW;AACxB,WAAO,GAAG,MAAM,IAAI,MAAM;AAAA,EAC5B;AACA,EAAAE,WAAU;AACV,SAAO,GAAG,MAAM,IAAIA,QAAO,SAAS,EAAE,CAAC;AACzC;","names":["toolResults","parts","createId","toolPartId","nextId"]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  InMemoryVectorStore,
3
3
  createTool
4
- } from "./chunk-66IJDP6L.js";
4
+ } from "./chunk-T22FYPE2.js";
5
5
  import {
6
6
  compact
7
7
  } from "./chunk-MMHG7WAM.js";
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-WJO6NVE2.js";
12
12
  import {
13
13
  embedDocuments
14
- } from "./chunk-FTO3W4UP.js";
14
+ } from "./chunk-W4DZU6IW.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-IA47SXLS.js.map
228
+ //# sourceMappingURL=chunk-BVGDCFQW.js.map