@anvia/core 0.13.5 → 0.14.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 (66) hide show
  1. package/dist/agent/index.d.ts +11 -11
  2. package/dist/agent/index.js +8 -8
  3. package/dist/{agent-W8sT6P5T.d.ts → agent-ib2-Ahyi.d.ts} +7 -7
  4. package/dist/audio-generation/index.d.ts +1 -1
  5. package/dist/{chunk-XH6LZMGH.js → chunk-2XD7Z7NB.js} +6 -6
  6. package/dist/{chunk-3LB36HON.js → chunk-BOJP4ARV.js} +17 -9
  7. package/dist/chunk-BOJP4ARV.js.map +1 -0
  8. package/dist/{chunk-TTKCFLW6.js → chunk-CESSRJYD.js} +6 -6
  9. package/dist/{chunk-77D7XBWL.js → chunk-DC2GJDPR.js} +2 -2
  10. package/dist/{chunk-6FLW6XS6.js → chunk-FBHF7WZJ.js} +3 -3
  11. package/dist/{chunk-IBKCOBAS.js → chunk-HHHNMP3V.js} +2 -2
  12. package/dist/{chunk-FE5QL4G3.js → chunk-HU55YP24.js} +1 -1
  13. package/dist/{chunk-FE5QL4G3.js.map → chunk-HU55YP24.js.map} +1 -1
  14. package/dist/{chunk-F3C5653H.js → chunk-I7TM7TKX.js} +4 -4
  15. package/dist/{chunk-3LMKHICK.js → chunk-X2Q3AXFM.js} +2 -2
  16. package/dist/{chunk-LJT67CFB.js → chunk-YQF7QOCO.js} +5 -5
  17. package/dist/completion/index.d.ts +3 -3
  18. package/dist/completion/index.js +2 -2
  19. package/dist/evals/index.d.ts +8 -8
  20. package/dist/evals/index.js +9 -9
  21. package/dist/extractor/index.d.ts +8 -8
  22. package/dist/extractor/index.js +9 -9
  23. package/dist/guardrails/index.d.ts +1 -1
  24. package/dist/hooks/index.d.ts +3 -3
  25. package/dist/image-generation/index.d.ts +1 -1
  26. package/dist/{index-BtyK30mL.d.ts → index-AK084cvC.d.ts} +9 -7
  27. package/dist/index.d.ts +12 -12
  28. package/dist/index.js +11 -11
  29. package/dist/internal/agent.d.ts +8 -8
  30. package/dist/internal/agent.js +7 -7
  31. package/dist/{json-BOHFS4AG.d.ts → json-k5r34q-F.d.ts} +1 -1
  32. package/dist/loaders/index.d.ts +1 -1
  33. package/dist/mcp/index.d.ts +4 -4
  34. package/dist/memory/index.d.ts +3 -3
  35. package/dist/{middleware-D6p0Uzky.d.ts → middleware-C6ZuwXjf.d.ts} +3 -3
  36. package/dist/observability/index.d.ts +3 -3
  37. package/dist/pipeline/index.d.ts +8 -8
  38. package/dist/request/index.d.ts +8 -8
  39. package/dist/request/index.js +6 -6
  40. package/dist/skills/index.d.ts +4 -4
  41. package/dist/skills/index.js +5 -5
  42. package/dist/{think-tool-B7p_7_5P.d.ts → think-tool-D3_K8NJa.d.ts} +1 -1
  43. package/dist/tool/index.d.ts +5 -5
  44. package/dist/tool/index.js +5 -5
  45. package/dist/{tool-DhT6kR0Z.d.ts → tool-DyC_XPPY.d.ts} +1 -1
  46. package/dist/transcription/index.d.ts +1 -1
  47. package/dist/{types-BNq9tWdA.d.ts → types-BySyFZTT.d.ts} +1 -0
  48. package/dist/{types-BjPcB4PA.d.ts → types-CqlNB5VN.d.ts} +1 -1
  49. package/dist/{types-9TeQF79I.d.ts → types-D1iyZY9M.d.ts} +1 -1
  50. package/dist/{types-Cz24JCei.d.ts → types-DBd1zAyo.d.ts} +1 -1
  51. package/dist/{types-CaXSh3vK.d.ts → types-VadeVz_w.d.ts} +1 -1
  52. package/dist/{types-CibT6_rS.d.ts → types-t_DnP78R.d.ts} +2 -2
  53. package/dist/ui/index.d.ts +1 -1
  54. package/dist/ui/index.js +2 -2
  55. package/dist/vector-store/index.d.ts +4 -4
  56. package/dist/vector-store/index.js +2 -2
  57. package/package.json +1 -1
  58. package/dist/chunk-3LB36HON.js.map +0 -1
  59. /package/dist/{chunk-XH6LZMGH.js.map → chunk-2XD7Z7NB.js.map} +0 -0
  60. /package/dist/{chunk-TTKCFLW6.js.map → chunk-CESSRJYD.js.map} +0 -0
  61. /package/dist/{chunk-77D7XBWL.js.map → chunk-DC2GJDPR.js.map} +0 -0
  62. /package/dist/{chunk-6FLW6XS6.js.map → chunk-FBHF7WZJ.js.map} +0 -0
  63. /package/dist/{chunk-IBKCOBAS.js.map → chunk-HHHNMP3V.js.map} +0 -0
  64. /package/dist/{chunk-F3C5653H.js.map → chunk-I7TM7TKX.js.map} +0 -0
  65. /package/dist/{chunk-3LMKHICK.js.map → chunk-X2Q3AXFM.js.map} +0 -0
  66. /package/dist/{chunk-LJT67CFB.js.map → chunk-YQF7QOCO.js.map} +0 -0
@@ -2,7 +2,7 @@ import {
2
2
  Message,
3
3
  assertCompletionRequestSupported,
4
4
  textFromAssistantContent
5
- } from "./chunk-FE5QL4G3.js";
5
+ } from "./chunk-HU55YP24.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-IBKCOBAS.js.map
338
+ //# sourceMappingURL=chunk-HHHNMP3V.js.map
@@ -368,4 +368,4 @@ export {
368
368
  assertCompletionRequestSupported,
369
369
  textFromAssistantContent
370
370
  };
371
- //# sourceMappingURL=chunk-FE5QL4G3.js.map
371
+ //# sourceMappingURL=chunk-HU55YP24.js.map
@@ -1 +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 const metadata = messageMetadata(options).metadata;\n const message: AssistantMessage =\n options.id === undefined\n ? { role: \"assistant\", content: normalized }\n : { role: \"assistant\", id: options.id, content: normalized };\n if (metadata !== undefined) {\n message.metadata = metadata;\n }\n return message;\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 type AssistantGenerationMetadata = {\n provider: string;\n model: string;\n usage: Usage;\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 function getAssistantGenerationMetadata(\n message: Message,\n): AssistantGenerationMetadata | undefined {\n if (message.role !== \"assistant\" || !isJsonObjectValue(message.metadata)) {\n return undefined;\n }\n const frameworkMetadata = message.metadata.anvia;\n if (!isJsonObjectValue(frameworkMetadata)) {\n return undefined;\n }\n const generation = frameworkMetadata.generation;\n if (\n !isJsonObjectValue(generation) ||\n typeof generation.provider !== \"string\" ||\n typeof generation.model !== \"string\" ||\n !isUsageValue(generation.usage)\n ) {\n return undefined;\n }\n return {\n provider: generation.provider,\n model: generation.model,\n usage: { ...generation.usage },\n };\n}\n\nfunction isJsonObjectValue(value: JsonValue | undefined): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isUsageValue(value: JsonValue | undefined): value is JsonObject & Usage {\n if (!isJsonObjectValue(value)) {\n return false;\n }\n return (\n isNonnegativeFiniteNumber(value.inputTokens) &&\n isNonnegativeFiniteNumber(value.outputTokens) &&\n isNonnegativeFiniteNumber(value.totalTokens) &&\n isNonnegativeFiniteNumber(value.cachedInputTokens) &&\n isNonnegativeFiniteNumber(value.cacheCreationInputTokens)\n );\n}\n\nfunction isNonnegativeFiniteNumber(value: JsonValue | undefined): value is number {\n return typeof value === \"number\" && Number.isFinite(value) && value >= 0;\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,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QAAQ;AAAA,MACd,CAAC,YAAY,QAAQ,SAAS,cAAc,QAAQ,OAAO,SAAS;AAAA,IACtE,IACA;AAAA,EACN;AACF;","names":[]}
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 const metadata = messageMetadata(options).metadata;\n const message: AssistantMessage =\n options.id === undefined\n ? { role: \"assistant\", content: normalized }\n : { role: \"assistant\", id: options.id, content: normalized };\n if (metadata !== undefined) {\n message.metadata = metadata;\n }\n return message;\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 type AssistantGenerationMetadata = {\n provider: string;\n model: string;\n usage: Usage;\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 function getAssistantGenerationMetadata(\n message: Message,\n): AssistantGenerationMetadata | undefined {\n if (message.role !== \"assistant\" || !isJsonObjectValue(message.metadata)) {\n return undefined;\n }\n const frameworkMetadata = message.metadata.anvia;\n if (!isJsonObjectValue(frameworkMetadata)) {\n return undefined;\n }\n const generation = frameworkMetadata.generation;\n if (\n !isJsonObjectValue(generation) ||\n typeof generation.provider !== \"string\" ||\n typeof generation.model !== \"string\" ||\n !isUsageValue(generation.usage)\n ) {\n return undefined;\n }\n return {\n provider: generation.provider,\n model: generation.model,\n usage: { ...generation.usage },\n };\n}\n\nfunction isJsonObjectValue(value: JsonValue | undefined): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isUsageValue(value: JsonValue | undefined): value is JsonObject & Usage {\n if (!isJsonObjectValue(value)) {\n return false;\n }\n return (\n isNonnegativeFiniteNumber(value.inputTokens) &&\n isNonnegativeFiniteNumber(value.outputTokens) &&\n isNonnegativeFiniteNumber(value.totalTokens) &&\n isNonnegativeFiniteNumber(value.cachedInputTokens) &&\n isNonnegativeFiniteNumber(value.cacheCreationInputTokens)\n );\n}\n\nfunction isNonnegativeFiniteNumber(value: JsonValue | undefined): value is number {\n return typeof value === \"number\" && Number.isFinite(value) && value >= 0;\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 usage?: Usage;\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,a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BAA4B,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":[]}
@@ -1,10 +1,10 @@
1
+ import {
2
+ toProviderJsonSchema
3
+ } from "./chunk-WQKHFADH.js";
1
4
  import {
2
5
  cosineSimilarity,
3
6
  embedText
4
7
  } from "./chunk-YBBD4HZ3.js";
5
- import {
6
- toProviderJsonSchema
7
- } from "./chunk-WQKHFADH.js";
8
8
 
9
9
  // src/vector-store/index.ts
10
10
  import { z } from "zod";
@@ -334,4 +334,4 @@ export {
334
334
  InMemoryVectorIndex,
335
335
  createVectorSearchTool
336
336
  };
337
- //# sourceMappingURL=chunk-F3C5653H.js.map
337
+ //# sourceMappingURL=chunk-I7TM7TKX.js.map
@@ -6,7 +6,7 @@ import {
6
6
  isJsonValue,
7
7
  reasoningDisplayText,
8
8
  serializeToolResultOutput
9
- } from "./chunk-FE5QL4G3.js";
9
+ } from "./chunk-HU55YP24.js";
10
10
 
11
11
  // src/ui/messages.ts
12
12
  function uiMessagesToCoreMessages(messages) {
@@ -463,4 +463,4 @@ export {
463
463
  uiMessagesToCoreMessages,
464
464
  coreMessagesToUIMessages
465
465
  };
466
- //# sourceMappingURL=chunk-3LMKHICK.js.map
466
+ //# sourceMappingURL=chunk-X2Q3AXFM.js.map
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  PromptRequest
3
- } from "./chunk-3LB36HON.js";
3
+ } from "./chunk-BOJP4ARV.js";
4
4
  import {
5
5
  isSkillTool
6
6
  } from "./chunk-YK4WAAS4.js";
7
7
  import {
8
8
  ToolSet
9
- } from "./chunk-XH6LZMGH.js";
9
+ } from "./chunk-2XD7Z7NB.js";
10
10
  import {
11
11
  createTool
12
- } from "./chunk-F3C5653H.js";
12
+ } from "./chunk-I7TM7TKX.js";
13
13
  import {
14
14
  isStreamingCompletionModel
15
- } from "./chunk-IBKCOBAS.js";
15
+ } from "./chunk-HHHNMP3V.js";
16
16
 
17
17
  // src/agent/agent.ts
18
18
  import { z } from "zod";
@@ -207,4 +207,4 @@ export {
207
207
  Agent,
208
208
  AgentSession
209
209
  };
210
- //# sourceMappingURL=chunk-LJT67CFB.js.map
210
+ //# sourceMappingURL=chunk-YQF7QOCO.js.map
@@ -1,6 +1,6 @@
1
- export { C as CreateCompletionBaseOptions, a as CreateCompletionInput, b as CreateCompletionOptions, c as CreateCompletionResult, d as CreateCompletionStreamOptions, e as CreateParsedCompletionOptions, f as CreateParsedCompletionResult, g as createCompletion, h as createCompletionStream, i as createParsedCompletion, j as isJsonValue, k as isStreamingCompletionModel } from '../json-BOHFS4AG.js';
2
- import { D as Document, M as Message, C as CompletionModel, k as ToolDefinition, v as ToolChoice, g as JsonValue, J as JsonObject, d as CompletionRequest, e as CompletionResponse } from '../types-BNq9tWdA.js';
3
- export { A as AssistantContent, a as AssistantGenerationMetadata, b as AssistantMessage, c as AssistantMessageOptions, w as CompletionCapabilityError, x as CompletionModelCapabilities, y as CompletionStreamEvent, z as DocumentContent, I as ImageContent, B as ImageDetail, f as JsonPrimitive, h as MessageOptions, R as Reasoning, E as ReasoningContent, F as ReasoningContentType, G as StreamingCompletionModel, S as SystemMessage, T as Text, i as ToolCall, j as ToolContent, H as ToolFunction, l as ToolMessage, m as ToolResult, n as ToolResultContent, o as ToolResultMessageOptions, p as ToolResultOptions, U as Usage, q as UserContent, r as UserMessage, K as assertCompletionRequestSupported, s as getAssistantGenerationMetadata, t as isToolResultContentArray, L as reasoningDisplayText, u as serializeToolResultOutput, N as textFromAssistantContent } from '../types-BNq9tWdA.js';
1
+ export { C as CreateCompletionBaseOptions, a as CreateCompletionInput, b as CreateCompletionOptions, c as CreateCompletionResult, d as CreateCompletionStreamOptions, e as CreateParsedCompletionOptions, f as CreateParsedCompletionResult, g as createCompletion, h as createCompletionStream, i as createParsedCompletion, j as isJsonValue, k as isStreamingCompletionModel } from '../json-k5r34q-F.js';
2
+ import { D as Document, M as Message, C as CompletionModel, k as ToolDefinition, v as ToolChoice, g as JsonValue, J as JsonObject, d as CompletionRequest, e as CompletionResponse } from '../types-BySyFZTT.js';
3
+ export { A as AssistantContent, a as AssistantGenerationMetadata, b as AssistantMessage, c as AssistantMessageOptions, w as CompletionCapabilityError, x as CompletionModelCapabilities, y as CompletionStreamEvent, z as DocumentContent, I as ImageContent, B as ImageDetail, f as JsonPrimitive, h as MessageOptions, R as Reasoning, E as ReasoningContent, F as ReasoningContentType, G as StreamingCompletionModel, S as SystemMessage, T as Text, i as ToolCall, j as ToolContent, H as ToolFunction, l as ToolMessage, m as ToolResult, n as ToolResultContent, o as ToolResultMessageOptions, p as ToolResultOptions, U as Usage, q as UserContent, r as UserMessage, K as assertCompletionRequestSupported, s as getAssistantGenerationMetadata, t as isToolResultContentArray, L as reasoningDisplayText, u as serializeToolResultOutput, N as textFromAssistantContent } from '../types-BySyFZTT.js';
4
4
  import '../zod-schema-C7F4clpm.js';
5
5
  import 'zod';
6
6
 
@@ -6,7 +6,7 @@ import {
6
6
  formatDocument,
7
7
  isStreamingCompletionModel,
8
8
  normalizeDocuments
9
- } from "../chunk-IBKCOBAS.js";
9
+ } from "../chunk-HHHNMP3V.js";
10
10
  import {
11
11
  AssistantContent,
12
12
  CompletionCapabilityError,
@@ -21,7 +21,7 @@ import {
21
21
  reasoningDisplayText,
22
22
  serializeToolResultOutput,
23
23
  textFromAssistantContent
24
- } from "../chunk-FE5QL4G3.js";
24
+ } from "../chunk-HU55YP24.js";
25
25
  import "../chunk-WQKHFADH.js";
26
26
  export {
27
27
  AssistantContent,
@@ -1,14 +1,14 @@
1
- import { A as Agent } from '../agent-W8sT6P5T.js';
2
- import { g as JsonValue, M as Message, C as CompletionModel } from '../types-BNq9tWdA.js';
3
- import { P as PromptResponse } from '../index-BtyK30mL.js';
1
+ import { A as Agent } from '../agent-ib2-Ahyi.js';
2
+ import { g as JsonValue, M as Message, C as CompletionModel } from '../types-BySyFZTT.js';
3
+ import { P as PromptResponse } from '../index-AK084cvC.js';
4
4
  import { Z as ZodSchema } from '../zod-schema-C7F4clpm.js';
5
5
  import { E as EmbeddingModel } from '../types-DHHZztGO.js';
6
6
  import '../guardrails/index.js';
7
- import '../types-BjPcB4PA.js';
8
- import '../types-CaXSh3vK.js';
9
- import '../tool-DhT6kR0Z.js';
10
- import '../middleware-D6p0Uzky.js';
11
- import '../types-9TeQF79I.js';
7
+ import '../types-CqlNB5VN.js';
8
+ import '../types-VadeVz_w.js';
9
+ import '../tool-DyC_XPPY.js';
10
+ import '../middleware-C6ZuwXjf.js';
11
+ import '../types-D1iyZY9M.js';
12
12
  import 'zod';
13
13
 
14
14
  type EvalOutcome<Score = unknown> = {
@@ -1,15 +1,18 @@
1
1
  import {
2
2
  ExtractorBuilder
3
- } from "../chunk-TTKCFLW6.js";
4
- import "../chunk-6FLW6XS6.js";
5
- import "../chunk-LJT67CFB.js";
6
- import "../chunk-3LB36HON.js";
3
+ } from "../chunk-CESSRJYD.js";
4
+ import "../chunk-FBHF7WZJ.js";
5
+ import "../chunk-YQF7QOCO.js";
6
+ import "../chunk-BOJP4ARV.js";
7
7
  import "../chunk-YK4WAAS4.js";
8
8
  import "../chunk-XUUY2L2D.js";
9
- import "../chunk-XH6LZMGH.js";
10
- import "../chunk-F3C5653H.js";
9
+ import "../chunk-2XD7Z7NB.js";
10
+ import "../chunk-I7TM7TKX.js";
11
11
  import "../chunk-2ODTMRHP.js";
12
12
  import "../chunk-M6RPFHG7.js";
13
+ import "../chunk-HHHNMP3V.js";
14
+ import "../chunk-HU55YP24.js";
15
+ import "../chunk-WQKHFADH.js";
13
16
  import {
14
17
  cosineSimilarity,
15
18
  embedText
@@ -17,9 +20,6 @@ import {
17
20
  import {
18
21
  mapWithConcurrency
19
22
  } from "../chunk-OIMLU4SF.js";
20
- import "../chunk-IBKCOBAS.js";
21
- import "../chunk-FE5QL4G3.js";
22
- import "../chunk-WQKHFADH.js";
23
23
  import "../chunk-CWUJUSOS.js";
24
24
 
25
25
  // src/evals/agent-target.ts
@@ -1,14 +1,14 @@
1
- import { A as Agent } from '../agent-W8sT6P5T.js';
1
+ import { A as Agent } from '../agent-ib2-Ahyi.js';
2
2
  import { Z as ZodSchema } from '../zod-schema-C7F4clpm.js';
3
- import { U as Usage, M as Message, C as CompletionModel, g as JsonValue, v as ToolChoice } from '../types-BNq9tWdA.js';
3
+ import { U as Usage, M as Message, C as CompletionModel, g as JsonValue, v as ToolChoice } from '../types-BySyFZTT.js';
4
4
  import '../guardrails/index.js';
5
- import '../types-BjPcB4PA.js';
6
- import '../types-CaXSh3vK.js';
7
- import '../index-BtyK30mL.js';
8
- import '../tool-DhT6kR0Z.js';
9
- import '../middleware-D6p0Uzky.js';
5
+ import '../types-CqlNB5VN.js';
6
+ import '../types-VadeVz_w.js';
7
+ import '../index-AK084cvC.js';
8
+ import '../tool-DyC_XPPY.js';
9
+ import '../middleware-C6ZuwXjf.js';
10
10
  import '../types-DHHZztGO.js';
11
- import '../types-9TeQF79I.js';
11
+ import '../types-D1iyZY9M.js';
12
12
  import 'zod';
13
13
 
14
14
  type ExtractionResponse<T> = {
@@ -2,21 +2,21 @@ import {
2
2
  ExtractionError,
3
3
  Extractor,
4
4
  ExtractorBuilder
5
- } from "../chunk-TTKCFLW6.js";
6
- import "../chunk-6FLW6XS6.js";
7
- import "../chunk-LJT67CFB.js";
8
- import "../chunk-3LB36HON.js";
5
+ } from "../chunk-CESSRJYD.js";
6
+ import "../chunk-FBHF7WZJ.js";
7
+ import "../chunk-YQF7QOCO.js";
8
+ import "../chunk-BOJP4ARV.js";
9
9
  import "../chunk-YK4WAAS4.js";
10
10
  import "../chunk-XUUY2L2D.js";
11
- import "../chunk-XH6LZMGH.js";
12
- import "../chunk-F3C5653H.js";
11
+ import "../chunk-2XD7Z7NB.js";
12
+ import "../chunk-I7TM7TKX.js";
13
13
  import "../chunk-2ODTMRHP.js";
14
14
  import "../chunk-M6RPFHG7.js";
15
+ import "../chunk-HHHNMP3V.js";
16
+ import "../chunk-HU55YP24.js";
17
+ import "../chunk-WQKHFADH.js";
15
18
  import "../chunk-YBBD4HZ3.js";
16
19
  import "../chunk-OIMLU4SF.js";
17
- import "../chunk-IBKCOBAS.js";
18
- import "../chunk-FE5QL4G3.js";
19
- import "../chunk-WQKHFADH.js";
20
20
  import "../chunk-CWUJUSOS.js";
21
21
  export {
22
22
  ExtractionError,
@@ -1,4 +1,4 @@
1
- import { M as Message, J as JsonObject, U as Usage } from '../types-BNq9tWdA.js';
1
+ import { M as Message, J as JsonObject, U as Usage } from '../types-BySyFZTT.js';
2
2
 
3
3
  type MaybePromise<T> = T | Promise<T>;
4
4
  type GuardrailMode = "enforce" | "observe";
@@ -1,6 +1,6 @@
1
- import { H as HookAction, P as PromptHook, T as ToolApprovalRequestOptions, a as ToolCallHookAction, R as RunControl, b as ToolCallControl } from '../types-BjPcB4PA.js';
2
- export { C as CompletionCallHookArgs, c as CompletionErrorHookArgs, d as CompletionResponseHookArgs, e as HookResult, f as RunEndHookArgs, g as RunErrorHookArgs, h as RunStartHookArgs, i as ToolCallHookArgs, j as ToolCallHookResult, k as ToolErrorHookArgs, l as ToolHookArgs, m as ToolResultHookArgs, n as TurnEndHookArgs, o as TurnStartHookArgs } from '../types-BjPcB4PA.js';
3
- import '../types-BNq9tWdA.js';
1
+ import { H as HookAction, P as PromptHook, T as ToolApprovalRequestOptions, a as ToolCallHookAction, R as RunControl, b as ToolCallControl } from '../types-CqlNB5VN.js';
2
+ export { C as CompletionCallHookArgs, c as CompletionErrorHookArgs, d as CompletionResponseHookArgs, e as HookResult, f as RunEndHookArgs, g as RunErrorHookArgs, h as RunStartHookArgs, i as ToolCallHookArgs, j as ToolCallHookResult, k as ToolErrorHookArgs, l as ToolHookArgs, m as ToolResultHookArgs, n as TurnEndHookArgs, o as TurnStartHookArgs } from '../types-CqlNB5VN.js';
3
+ import '../types-BySyFZTT.js';
4
4
 
5
5
  declare function createHook<RawResponse = unknown>(hook: PromptHook<RawResponse>): PromptHook<RawResponse>;
6
6
  declare function cancelPrompt(reason: string): HookAction;
@@ -1,4 +1,4 @@
1
- import { g as JsonValue } from '../types-BNq9tWdA.js';
1
+ import { g as JsonValue } from '../types-BySyFZTT.js';
2
2
 
3
3
  type ImageGenerationRequest = {
4
4
  prompt: string;
@@ -1,6 +1,6 @@
1
- import { F as ReasoningContentType, i as ToolCall, U as Usage, M as Message, n as ToolResultContent, e as CompletionResponse, d as CompletionRequest, J as JsonObject, x as CompletionModelCapabilities, k as ToolDefinition, g as JsonValue } from './types-BNq9tWdA.js';
1
+ import { F as ReasoningContentType, i as ToolCall, U as Usage, M as Message, n as ToolResultContent, e as CompletionResponse, d as CompletionRequest, J as JsonObject, x as CompletionModelCapabilities, k as ToolDefinition, g as JsonValue } from './types-BySyFZTT.js';
2
2
  import { GuardrailDecisionRecord } from './guardrails/index.js';
3
- import { g as ToolCallStreamEvent } from './tool-DhT6kR0Z.js';
3
+ import { g as ToolCallStreamEvent } from './tool-DyC_XPPY.js';
4
4
 
5
5
  type PromptResponse = {
6
6
  output: string;
@@ -22,6 +22,11 @@ type AgentDeltaEvent = {
22
22
  type: "tool_call";
23
23
  toolCall: ToolCall;
24
24
  };
25
+ type AgentErrorStreamEvent = {
26
+ type: "error";
27
+ error: unknown;
28
+ usage: Usage;
29
+ };
25
30
  type AgentChildStreamEvent<RawResponse = unknown> = {
26
31
  type: "turn_start";
27
32
  turn: number;
@@ -67,10 +72,7 @@ type AgentChildStreamEvent<RawResponse = unknown> = {
67
72
  messages: Message[];
68
73
  trace?: AgentTraceInfo | undefined;
69
74
  guardrails?: GuardrailDecisionRecord[] | undefined;
70
- } | {
71
- type: "error";
72
- error: unknown;
73
- };
75
+ } | AgentErrorStreamEvent;
74
76
  type AgentStreamEvent<RawResponse = unknown> = AgentChildStreamEvent<RawResponse> | {
75
77
  type: "agent_tool_event";
76
78
  turn: number;
@@ -202,4 +204,4 @@ type ObserveOptions = {
202
204
  };
203
205
  declare function createObserver(observer: AgentObserver): AgentObserver;
204
206
 
205
- export { type AgentChildStreamEvent as A, type ObserveOptions as O, type PromptResponse as P, type AgentStreamEvent as a, type AgentObserver as b, type AgentTraceOptions as c, type AgentObserverRegistration as d, type AgentDeltaEvent as e, type AgentGenerationEndArgs as f, type AgentGenerationErrorArgs as g, type AgentGenerationObserver as h, type AgentGenerationStartArgs as i, type AgentGenerationUpdateArgs as j, type AgentRunEndArgs as k, type AgentRunErrorArgs as l, type AgentRunEventArgs as m, type AgentRunObserver as n, type AgentRunPromptRef as o, type AgentRunStartArgs as p, type AgentToolEndArgs as q, type AgentToolErrorArgs as r, type AgentToolObserver as s, type AgentToolStartArgs as t, type AgentToolStreamEventArgs as u, type AgentTraceInfo as v, createObserver as w };
207
+ export { type AgentChildStreamEvent as A, type ObserveOptions as O, type PromptResponse as P, type AgentErrorStreamEvent as a, type AgentStreamEvent as b, type AgentObserver as c, type AgentTraceOptions as d, type AgentObserverRegistration as e, type AgentDeltaEvent as f, type AgentGenerationEndArgs as g, type AgentGenerationErrorArgs as h, type AgentGenerationObserver as i, type AgentGenerationStartArgs as j, type AgentGenerationUpdateArgs as k, type AgentRunEndArgs as l, type AgentRunErrorArgs as m, type AgentRunEventArgs as n, type AgentRunObserver as o, type AgentRunPromptRef as p, type AgentRunStartArgs as q, type AgentToolEndArgs as r, type AgentToolErrorArgs as s, type AgentToolObserver as t, type AgentToolStartArgs as u, type AgentToolStreamEventArgs as v, type AgentTraceInfo as w, createObserver as x };
package/dist/index.d.ts CHANGED
@@ -1,24 +1,24 @@
1
1
  export { AgentBuilder } from './agent/index.js';
2
- export { C as CreateCompletionBaseOptions, a as CreateCompletionInput, b as CreateCompletionOptions, c as CreateCompletionResult, d as CreateCompletionStreamOptions, e as CreateParsedCompletionOptions, f as CreateParsedCompletionResult, g as createCompletion, h as createCompletionStream, i as createParsedCompletion, j as isJsonValue } from './json-BOHFS4AG.js';
3
- export { A as AssistantContent, a as AssistantGenerationMetadata, b as AssistantMessage, c as AssistantMessageOptions, C as CompletionModel, d as CompletionRequest, e as CompletionResponse, D as Document, I as ImageContent, J as JsonObject, f as JsonPrimitive, g as JsonValue, M as Message, h as MessageOptions, S as SystemMessage, T as Text, i as ToolCall, j as ToolContent, k as ToolDefinition, l as ToolMessage, m as ToolResult, n as ToolResultContent, o as ToolResultMessageOptions, p as ToolResultOptions, U as Usage, q as UserContent, r as UserMessage, s as getAssistantGenerationMetadata } from './types-BNq9tWdA.js';
2
+ export { C as CreateCompletionBaseOptions, a as CreateCompletionInput, b as CreateCompletionOptions, c as CreateCompletionResult, d as CreateCompletionStreamOptions, e as CreateParsedCompletionOptions, f as CreateParsedCompletionResult, g as createCompletion, h as createCompletionStream, i as createParsedCompletion, j as isJsonValue } from './json-k5r34q-F.js';
3
+ export { A as AssistantContent, a as AssistantGenerationMetadata, b as AssistantMessage, c as AssistantMessageOptions, C as CompletionModel, d as CompletionRequest, e as CompletionResponse, D as Document, I as ImageContent, J as JsonObject, f as JsonPrimitive, g as JsonValue, M as Message, h as MessageOptions, S as SystemMessage, T as Text, i as ToolCall, j as ToolContent, k as ToolDefinition, l as ToolMessage, m as ToolResult, n as ToolResultContent, o as ToolResultMessageOptions, p as ToolResultOptions, U as Usage, q as UserContent, r as UserMessage, s as getAssistantGenerationMetadata } from './types-BySyFZTT.js';
4
4
  export { GuardrailBoundary, GuardrailDecisionRecord, GuardrailMode, GuardrailPolicy, GuardrailPolicyInput, GuardrailPolicyOptions, InputGuardrail, InputGuardrailActions, InputGuardrailContext, OutputGuardrail, OutputGuardrailActions, OutputGuardrailContext, allow, block, defineGuardrailPolicy, defineInputGuardrail, defineOutputGuardrail, guardrails } from './guardrails/index.js';
5
5
  export { cancelPrompt, createHook, requestToolApproval, runControl, skipTool, toolCallControl } from './hooks/index.js';
6
- export { M as MemoryConversation, a as MemoryConversationListOptions, b as MemoryConversationMessage, c as MemoryConversationSummary, d as MemoryInspector, e as MemoryStore } from './types-CaXSh3vK.js';
6
+ export { M as MemoryConversation, a as MemoryConversationListOptions, b as MemoryConversationMessage, c as MemoryConversationSummary, d as MemoryInspector, e as MemoryStore } from './types-VadeVz_w.js';
7
7
  export { MaxTurnsError, PromptCancelledError, ToolApprovalRequiredError } from './request/index.js';
8
- export { C as CompletionRetryContext, a as CompletionRetryOptions } from './agent-W8sT6P5T.js';
9
- export { A as AgentChildStreamEvent, a as AgentStreamEvent, P as PromptResponse } from './index-BtyK30mL.js';
8
+ export { C as CompletionRetryContext, a as CompletionRetryOptions } from './agent-ib2-Ahyi.js';
9
+ export { A as AgentChildStreamEvent, a as AgentErrorStreamEvent, b as AgentStreamEvent, P as PromptResponse } from './index-AK084cvC.js';
10
10
  export { Z as ZodSchema } from './zod-schema-C7F4clpm.js';
11
11
  export { loadSkills, skill } from './skills/index.js';
12
- export { S as SkillValidationError } from './types-Cz24JCei.js';
13
- export { C as CreateToolOptions, c as createThinkTool, a as createTool } from './think-tool-B7p_7_5P.js';
14
- export { A as AnyTool, T as Tool, a as ToolApprovalContext, b as ToolApprovalDecision, c as ToolApprovalPolicy, d as ToolApprovalRequest, e as ToolApprovalsOptions, f as ToolCallContext, g as ToolCallStreamEvent } from './tool-DhT6kR0Z.js';
15
- export { A as AgentMiddleware, C as CompletionRequestMiddlewareArgs, a as CompletionRequestMiddlewareResult, b as CompletionResponseMiddlewareArgs, c as CompletionResponseMiddlewareResult, T as ToolInputMiddlewareArgs, d as ToolInputMiddlewareResult, e as ToolMiddleware, f as ToolOutputMiddlewareArgs, g as ToolOutputMiddlewareResult, h as ToolResultMiddlewareArgs, i as createMiddleware, j as createToolMiddleware } from './middleware-D6p0Uzky.js';
12
+ export { S as SkillValidationError } from './types-DBd1zAyo.js';
13
+ export { C as CreateToolOptions, c as createThinkTool, a as createTool } from './think-tool-D3_K8NJa.js';
14
+ export { A as AnyTool, T as Tool, a as ToolApprovalContext, b as ToolApprovalDecision, c as ToolApprovalPolicy, d as ToolApprovalRequest, e as ToolApprovalsOptions, f as ToolCallContext, g as ToolCallStreamEvent } from './tool-DyC_XPPY.js';
15
+ export { A as AgentMiddleware, C as CompletionRequestMiddlewareArgs, a as CompletionRequestMiddlewareResult, b as CompletionResponseMiddlewareArgs, c as CompletionResponseMiddlewareResult, T as ToolInputMiddlewareArgs, d as ToolInputMiddlewareResult, e as ToolMiddleware, f as ToolOutputMiddlewareArgs, g as ToolOutputMiddlewareResult, h as ToolResultMiddlewareArgs, i as createMiddleware, j as createToolMiddleware } from './middleware-C6ZuwXjf.js';
16
16
  export { CreateUIAttachment, UIAttachment, UIError, UIMessage, UIMessagePart, UIMessageRole, UIStreamEvent, UIStreamRequest, coreMessagesToUIMessages, uiMessagesToCoreMessages } from './ui/index.js';
17
- import './types-BjPcB4PA.js';
18
- import './types-CibT6_rS.js';
17
+ import './types-CqlNB5VN.js';
18
+ import './types-t_DnP78R.js';
19
19
  import '@modelcontextprotocol/sdk/client/sse.js';
20
20
  import '@modelcontextprotocol/sdk/client/stdio.js';
21
21
  import '@modelcontextprotocol/sdk/client/streamableHttp.js';
22
- import './types-9TeQF79I.js';
22
+ import './types-D1iyZY9M.js';
23
23
  import './types-DHHZztGO.js';
24
24
  import 'zod';
package/dist/index.js CHANGED
@@ -2,31 +2,31 @@ import {
2
2
  SkillValidationError,
3
3
  loadSkills,
4
4
  skill
5
- } from "./chunk-77D7XBWL.js";
5
+ } from "./chunk-DC2GJDPR.js";
6
6
  import {
7
7
  coreMessagesToUIMessages,
8
8
  uiMessagesToCoreMessages
9
- } from "./chunk-3LMKHICK.js";
9
+ } from "./chunk-X2Q3AXFM.js";
10
10
  import "./chunk-CQNNSZPG.js";
11
11
  import {
12
12
  AgentBuilder
13
- } from "./chunk-6FLW6XS6.js";
14
- import "./chunk-LJT67CFB.js";
13
+ } from "./chunk-FBHF7WZJ.js";
14
+ import "./chunk-YQF7QOCO.js";
15
15
  import {
16
16
  MaxTurnsError,
17
17
  PromptCancelledError,
18
18
  ToolApprovalRequiredError
19
- } from "./chunk-3LB36HON.js";
19
+ } from "./chunk-BOJP4ARV.js";
20
20
  import "./chunk-YK4WAAS4.js";
21
21
  import "./chunk-XUUY2L2D.js";
22
22
  import {
23
23
  createMiddleware,
24
24
  createThinkTool,
25
25
  createToolMiddleware
26
- } from "./chunk-XH6LZMGH.js";
26
+ } from "./chunk-2XD7Z7NB.js";
27
27
  import {
28
28
  createTool
29
- } from "./chunk-F3C5653H.js";
29
+ } from "./chunk-I7TM7TKX.js";
30
30
  import {
31
31
  cancelPrompt,
32
32
  createHook,
@@ -36,13 +36,11 @@ import {
36
36
  toolCallControl
37
37
  } from "./chunk-2ODTMRHP.js";
38
38
  import "./chunk-M6RPFHG7.js";
39
- import "./chunk-YBBD4HZ3.js";
40
- import "./chunk-OIMLU4SF.js";
41
39
  import {
42
40
  createCompletion,
43
41
  createCompletionStream,
44
42
  createParsedCompletion
45
- } from "./chunk-IBKCOBAS.js";
43
+ } from "./chunk-HHHNMP3V.js";
46
44
  import {
47
45
  AssistantContent,
48
46
  Message,
@@ -51,8 +49,10 @@ import {
51
49
  UserContent,
52
50
  getAssistantGenerationMetadata,
53
51
  isJsonValue
54
- } from "./chunk-FE5QL4G3.js";
52
+ } from "./chunk-HU55YP24.js";
55
53
  import "./chunk-WQKHFADH.js";
54
+ import "./chunk-YBBD4HZ3.js";
55
+ import "./chunk-OIMLU4SF.js";
56
56
  import {
57
57
  allow,
58
58
  block,
@@ -1,10 +1,10 @@
1
- export { A as Agent, e as AgentEventAppendInput, f as AgentEventRecord, c as AgentEventStore, g as AgentEventStoreInclude, d as AgentEventStoreOptions, j as AgentEventStoreRegistration, k as AgentOptions, h as AgentSession, i as AgentToolOptions, l as DEFAULT_MAX_TURNS, D as DynamicContextOptions, m as DynamicContextRegistration, b as DynamicToolOptions, n as DynamicToolRegistration } from '../agent-W8sT6P5T.js';
2
- import '../types-BNq9tWdA.js';
1
+ export { A as Agent, e as AgentEventAppendInput, f as AgentEventRecord, c as AgentEventStore, g as AgentEventStoreInclude, d as AgentEventStoreOptions, j as AgentEventStoreRegistration, k as AgentOptions, h as AgentSession, i as AgentToolOptions, l as DEFAULT_MAX_TURNS, D as DynamicContextOptions, m as DynamicContextRegistration, b as DynamicToolOptions, n as DynamicToolRegistration } from '../agent-ib2-Ahyi.js';
2
+ import '../types-BySyFZTT.js';
3
3
  import '../guardrails/index.js';
4
- import '../types-BjPcB4PA.js';
5
- import '../types-CaXSh3vK.js';
6
- import '../index-BtyK30mL.js';
7
- import '../tool-DhT6kR0Z.js';
8
- import '../middleware-D6p0Uzky.js';
4
+ import '../types-CqlNB5VN.js';
5
+ import '../types-VadeVz_w.js';
6
+ import '../index-AK084cvC.js';
7
+ import '../tool-DyC_XPPY.js';
8
+ import '../middleware-C6ZuwXjf.js';
9
9
  import '../types-DHHZztGO.js';
10
- import '../types-9TeQF79I.js';
10
+ import '../types-D1iyZY9M.js';
@@ -2,18 +2,18 @@ import {
2
2
  Agent,
3
3
  AgentSession,
4
4
  DEFAULT_MAX_TURNS
5
- } from "../chunk-LJT67CFB.js";
6
- import "../chunk-3LB36HON.js";
5
+ } from "../chunk-YQF7QOCO.js";
6
+ import "../chunk-BOJP4ARV.js";
7
7
  import "../chunk-YK4WAAS4.js";
8
8
  import "../chunk-XUUY2L2D.js";
9
- import "../chunk-XH6LZMGH.js";
10
- import "../chunk-F3C5653H.js";
9
+ import "../chunk-2XD7Z7NB.js";
10
+ import "../chunk-I7TM7TKX.js";
11
11
  import "../chunk-2ODTMRHP.js";
12
+ import "../chunk-HHHNMP3V.js";
13
+ import "../chunk-HU55YP24.js";
14
+ import "../chunk-WQKHFADH.js";
12
15
  import "../chunk-YBBD4HZ3.js";
13
16
  import "../chunk-OIMLU4SF.js";
14
- import "../chunk-IBKCOBAS.js";
15
- import "../chunk-FE5QL4G3.js";
16
- import "../chunk-WQKHFADH.js";
17
17
  import "../chunk-CWUJUSOS.js";
18
18
  export {
19
19
  Agent,
@@ -1,5 +1,5 @@
1
1
  import { Z as ZodSchema } from './zod-schema-C7F4clpm.js';
2
- import { M as Message, D as Document, k as ToolDefinition, v as ToolChoice, J as JsonObject, g as JsonValue, A as AssistantContent, U as Usage, e as CompletionResponse, C as CompletionModel, G as StreamingCompletionModel, y as CompletionStreamEvent } from './types-BNq9tWdA.js';
2
+ import { M as Message, D as Document, k as ToolDefinition, v as ToolChoice, J as JsonObject, g as JsonValue, A as AssistantContent, U as Usage, e as CompletionResponse, C as CompletionModel, G as StreamingCompletionModel, y as CompletionStreamEvent } from './types-BySyFZTT.js';
3
3
 
4
4
  type CreateCompletionInput = string | Message | Message[];
5
5
  type CreateCompletionBaseOptions = {
@@ -1,4 +1,4 @@
1
- import { D as Document } from '../types-BNq9tWdA.js';
1
+ import { D as Document } from '../types-BySyFZTT.js';
2
2
 
3
3
  type LoaderResult<T> = {
4
4
  ok: true;