@anvia/core 0.13.5 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/agent/index.d.ts +11 -11
  2. package/dist/agent/index.js +8 -8
  3. package/dist/{agent-W8sT6P5T.d.ts → agent-C1yoidvI.d.ts} +15 -8
  4. package/dist/audio-generation/index.d.ts +1 -1
  5. package/dist/{chunk-6FLW6XS6.js → chunk-7NULHGAO.js} +3 -3
  6. package/dist/{chunk-XH6LZMGH.js → chunk-BIYXGG33.js} +6 -6
  7. package/dist/chunk-BIYXGG33.js.map +1 -0
  8. package/dist/{chunk-TTKCFLW6.js → chunk-BPU264XB.js} +6 -6
  9. package/dist/{chunk-3LB36HON.js → chunk-CNANX5OL.js} +52 -17
  10. package/dist/chunk-CNANX5OL.js.map +1 -0
  11. package/dist/{chunk-77D7XBWL.js → chunk-DC2GJDPR.js} +2 -2
  12. package/dist/{chunk-LJT67CFB.js → chunk-GCZIIYZW.js} +7 -6
  13. package/dist/chunk-GCZIIYZW.js.map +1 -0
  14. package/dist/{chunk-F3C5653H.js → chunk-I7TM7TKX.js} +4 -4
  15. package/dist/{chunk-3LMKHICK.js → chunk-MEUZ4NBO.js} +2 -2
  16. package/dist/{chunk-IBKCOBAS.js → chunk-QTZHDPQX.js} +2 -2
  17. package/dist/{chunk-FE5QL4G3.js → chunk-TIV3WFSR.js} +1 -1
  18. package/dist/{chunk-FE5QL4G3.js.map → chunk-TIV3WFSR.js.map} +1 -1
  19. package/dist/completion/index.d.ts +3 -3
  20. package/dist/completion/index.js +2 -2
  21. package/dist/evals/index.d.ts +8 -8
  22. package/dist/evals/index.js +9 -9
  23. package/dist/extractor/index.d.ts +8 -8
  24. package/dist/extractor/index.js +9 -9
  25. package/dist/guardrails/index.d.ts +1 -1
  26. package/dist/hooks/index.d.ts +3 -3
  27. package/dist/image-generation/index.d.ts +1 -1
  28. package/dist/{index-BtyK30mL.d.ts → index-VH93vDXo.d.ts} +32 -10
  29. package/dist/index.d.ts +12 -12
  30. package/dist/index.js +11 -11
  31. package/dist/internal/agent.d.ts +8 -8
  32. package/dist/internal/agent.js +7 -7
  33. package/dist/{json-BOHFS4AG.d.ts → json-CaCUxJqG.d.ts} +1 -1
  34. package/dist/loaders/index.d.ts +1 -1
  35. package/dist/mcp/index.d.ts +4 -4
  36. package/dist/memory/index.d.ts +3 -3
  37. package/dist/{middleware-D6p0Uzky.d.ts → middleware-CGEYQndv.d.ts} +3 -3
  38. package/dist/observability/index.d.ts +3 -3
  39. package/dist/pipeline/index.d.ts +8 -8
  40. package/dist/request/index.d.ts +8 -8
  41. package/dist/request/index.js +6 -6
  42. package/dist/skills/index.d.ts +4 -4
  43. package/dist/skills/index.js +5 -5
  44. package/dist/{think-tool-B7p_7_5P.d.ts → think-tool-DABDgW_E.d.ts} +1 -1
  45. package/dist/tool/index.d.ts +5 -5
  46. package/dist/tool/index.js +5 -5
  47. package/dist/{tool-DhT6kR0Z.d.ts → tool-tHPNeWMR.d.ts} +2 -1
  48. package/dist/transcription/index.d.ts +1 -1
  49. package/dist/{types-9TeQF79I.d.ts → types-BHxJcHMk.d.ts} +1 -1
  50. package/dist/{types-CibT6_rS.d.ts → types-BbLcbRqM.d.ts} +2 -2
  51. package/dist/{types-BNq9tWdA.d.ts → types-Byo50mwr.d.ts} +4 -1
  52. package/dist/{types-BjPcB4PA.d.ts → types-D78Vnorg.d.ts} +1 -1
  53. package/dist/{types-CaXSh3vK.d.ts → types-DPYoqg8M.d.ts} +1 -1
  54. package/dist/{types-Cz24JCei.d.ts → types-DW1Va3vx.d.ts} +1 -1
  55. package/dist/ui/index.d.ts +1 -1
  56. package/dist/ui/index.js +2 -2
  57. package/dist/vector-store/index.d.ts +4 -4
  58. package/dist/vector-store/index.js +2 -2
  59. package/package.json +1 -1
  60. package/dist/chunk-3LB36HON.js.map +0 -1
  61. package/dist/chunk-LJT67CFB.js.map +0 -1
  62. package/dist/chunk-XH6LZMGH.js.map +0 -1
  63. /package/dist/{chunk-6FLW6XS6.js.map → chunk-7NULHGAO.js.map} +0 -0
  64. /package/dist/{chunk-TTKCFLW6.js.map → chunk-BPU264XB.js.map} +0 -0
  65. /package/dist/{chunk-77D7XBWL.js.map → chunk-DC2GJDPR.js.map} +0 -0
  66. /package/dist/{chunk-F3C5653H.js.map → chunk-I7TM7TKX.js.map} +0 -0
  67. /package/dist/{chunk-3LMKHICK.js.map → chunk-MEUZ4NBO.js.map} +0 -0
  68. /package/dist/{chunk-IBKCOBAS.js.map → chunk-QTZHDPQX.js.map} +0 -0
@@ -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,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,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A,EACnF;AAEA,MAAI,QAAQ,iBAAiB,UAAa,CAAC,aAAa,cAAc;AACpE,UAAM,IAAI,0BAA0B,GAAG,UAAU,mCAAmC;AAAA,EACtF;AAEA,MAAI,CAAC,aAAa,cAAc,qBAAqB,OAAO,GAAG;AAC7D,UAAM,IAAI,0BAA0B,GAAG,UAAU,gCAAgC;AAAA,EACnF;AAEA,MAAI,CAAC,aAAa,iBAAiB,4BAA4B,OAAO,GAAG;AACvE,UAAM,IAAI,0BAA0B,GAAG,UAAU,wCAAwC;AAAA,EAC3F;AACF;AAEO,SAAS,yBAAyB,SAAqC;AAC5E,SAAO,QAAQ,QAAQ,CAAC,SAAU,KAAK,SAAS,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC,CAAE,EAAE,KAAK,IAAI;AACvF;AAEA,SAAS,qBAAqB,SAAqC;AACjE,SAAO,QAAQ,YAAY;AAAA,IAAK,CAAC,YAC/B,QAAQ,SAAS,WAAW,QAAQ,QAAQ,QAAQ,KAAK,CAAC,YAAY,QAAQ,SAAS,OAAO;AAAA,EAChG;AACF;AAEA,SAAS,4BAA4B,SAAqC;AACxE,SAAO,QAAQ,YAAY;AAAA,IAAK,CAAC,YAC/B,QAAQ,SAAS,SACb,QAAQ,QAAQ;AAAA,MACd,CAAC,YAAY,QAAQ,SAAS,cAAc,QAAQ,OAAO,SAAS;AAAA,IACtE,IACA;AAAA,EACN;AACF;","names":[]}
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 ToolCallArgumentsMode = \"append\" | \"replace\";\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 argumentsMode?: ToolCallArgumentsMode;\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;AAC9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G;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,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-CaCUxJqG.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-Byo50mwr.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, H as ToolCallArgumentsMode, j as ToolContent, K 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, L as assertCompletionRequestSupported, s as getAssistantGenerationMetadata, t as isToolResultContentArray, N as reasoningDisplayText, u as serializeToolResultOutput, O as textFromAssistantContent } from '../types-Byo50mwr.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-QTZHDPQX.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-TIV3WFSR.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-C1yoidvI.js';
2
+ import { g as JsonValue, M as Message, C as CompletionModel } from '../types-Byo50mwr.js';
3
+ import { P as PromptResponse } from '../index-VH93vDXo.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-D78Vnorg.js';
8
+ import '../types-DPYoqg8M.js';
9
+ import '../tool-tHPNeWMR.js';
10
+ import '../middleware-CGEYQndv.js';
11
+ import '../types-BHxJcHMk.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-BPU264XB.js";
4
+ import "../chunk-7NULHGAO.js";
5
+ import "../chunk-GCZIIYZW.js";
6
+ import "../chunk-CNANX5OL.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-BIYXGG33.js";
10
+ import "../chunk-I7TM7TKX.js";
11
11
  import "../chunk-2ODTMRHP.js";
12
12
  import "../chunk-M6RPFHG7.js";
13
+ import "../chunk-QTZHDPQX.js";
14
+ import "../chunk-TIV3WFSR.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-C1yoidvI.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-Byo50mwr.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-D78Vnorg.js';
6
+ import '../types-DPYoqg8M.js';
7
+ import '../index-VH93vDXo.js';
8
+ import '../tool-tHPNeWMR.js';
9
+ import '../middleware-CGEYQndv.js';
10
10
  import '../types-DHHZztGO.js';
11
- import '../types-9TeQF79I.js';
11
+ import '../types-BHxJcHMk.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-BPU264XB.js";
6
+ import "../chunk-7NULHGAO.js";
7
+ import "../chunk-GCZIIYZW.js";
8
+ import "../chunk-CNANX5OL.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-BIYXGG33.js";
12
+ import "../chunk-I7TM7TKX.js";
13
13
  import "../chunk-2ODTMRHP.js";
14
14
  import "../chunk-M6RPFHG7.js";
15
+ import "../chunk-QTZHDPQX.js";
16
+ import "../chunk-TIV3WFSR.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-Byo50mwr.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-D78Vnorg.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-D78Vnorg.js';
3
+ import '../types-Byo50mwr.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-Byo50mwr.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, H as ToolCallArgumentsMode, d as CompletionRequest, J as JsonObject, x as CompletionModelCapabilities, k as ToolDefinition, g as JsonValue } from './types-Byo50mwr.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-tHPNeWMR.js';
4
4
 
5
5
  type PromptResponse = {
6
6
  output: string;
@@ -22,7 +22,26 @@ type AgentDeltaEvent = {
22
22
  type: "tool_call";
23
23
  toolCall: ToolCall;
24
24
  };
25
- type AgentChildStreamEvent<RawResponse = unknown> = {
25
+ type AgentErrorStreamEvent = {
26
+ type: "error";
27
+ error: unknown;
28
+ usage: Usage;
29
+ };
30
+ type AgentStreamOptions = {
31
+ /** @default true */
32
+ includeToolCallDeltas?: boolean;
33
+ };
34
+ type AgentToolCallDeltaEvent = {
35
+ type: "tool_call_delta";
36
+ turn: number;
37
+ id: string;
38
+ callId?: string;
39
+ name?: string;
40
+ argumentsDelta?: string;
41
+ argumentsMode?: ToolCallArgumentsMode;
42
+ signature?: string;
43
+ };
44
+ type AgentChildStreamEventBase<RawResponse = unknown> = {
26
45
  type: "turn_start";
27
46
  turn: number;
28
47
  prompt: Message;
@@ -67,11 +86,11 @@ type AgentChildStreamEvent<RawResponse = unknown> = {
67
86
  messages: Message[];
68
87
  trace?: AgentTraceInfo | undefined;
69
88
  guardrails?: GuardrailDecisionRecord[] | undefined;
70
- } | {
71
- type: "error";
72
- error: unknown;
73
- };
74
- type AgentStreamEvent<RawResponse = unknown> = AgentChildStreamEvent<RawResponse> | {
89
+ } | AgentErrorStreamEvent;
90
+ type AgentChildStreamEventWithoutToolCallDeltas<RawResponse = unknown> = AgentChildStreamEventBase<RawResponse>;
91
+ type AgentChildStreamEvent<RawResponse = unknown> = AgentChildStreamEventBase<RawResponse> | AgentToolCallDeltaEvent;
92
+ type AgentChildStreamEventWithToolCallDeltas<RawResponse = unknown> = AgentChildStreamEvent<RawResponse>;
93
+ type AgentToolStreamEvent<ChildEvent> = {
75
94
  type: "agent_tool_event";
76
95
  turn: number;
77
96
  toolName: string;
@@ -79,8 +98,11 @@ type AgentStreamEvent<RawResponse = unknown> = AgentChildStreamEvent<RawResponse
79
98
  internalCallId: string;
80
99
  agentId: string;
81
100
  agentName?: string;
82
- event: AgentChildStreamEvent<RawResponse>;
101
+ event: ChildEvent;
83
102
  };
103
+ type AgentStreamEventWithoutToolCallDeltas<RawResponse = unknown> = AgentChildStreamEventWithoutToolCallDeltas<RawResponse> | AgentToolStreamEvent<AgentChildStreamEventWithoutToolCallDeltas<RawResponse>>;
104
+ type AgentStreamEvent<RawResponse = unknown> = AgentChildStreamEvent<RawResponse> | AgentToolStreamEvent<AgentChildStreamEvent<RawResponse>>;
105
+ type AgentStreamEventWithToolCallDeltas<RawResponse = unknown> = AgentStreamEvent<RawResponse>;
84
106
 
85
107
  type AgentTraceInfo = {
86
108
  traceId?: string | undefined;
@@ -202,4 +224,4 @@ type ObserveOptions = {
202
224
  };
203
225
  declare function createObserver(observer: AgentObserver): AgentObserver;
204
226
 
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 };
227
+ export { type AgentChildStreamEvent as A, type AgentToolStartArgs as B, type AgentToolStreamEventArgs as C, type AgentTraceInfo as D, createObserver as E, type ObserveOptions as O, type PromptResponse as P, type AgentChildStreamEventWithToolCallDeltas as a, type AgentChildStreamEventWithoutToolCallDeltas as b, type AgentErrorStreamEvent as c, type AgentStreamEvent as d, type AgentStreamEventWithToolCallDeltas as e, type AgentStreamEventWithoutToolCallDeltas as f, type AgentStreamOptions as g, type AgentToolCallDeltaEvent as h, type AgentObserver as i, type AgentTraceOptions as j, type AgentObserverRegistration as k, type AgentDeltaEvent as l, type AgentGenerationEndArgs as m, type AgentGenerationErrorArgs as n, type AgentGenerationObserver as o, type AgentGenerationStartArgs as p, type AgentGenerationUpdateArgs as q, type AgentRunEndArgs as r, type AgentRunErrorArgs as s, type AgentRunEventArgs as t, type AgentRunObserver as u, type AgentRunPromptRef as v, type AgentRunStartArgs as w, type AgentToolEndArgs as x, type AgentToolErrorArgs as y, type AgentToolObserver as z };
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-CaCUxJqG.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-Byo50mwr.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-DPYoqg8M.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-C1yoidvI.js';
9
+ export { A as AgentChildStreamEvent, a as AgentChildStreamEventWithToolCallDeltas, b as AgentChildStreamEventWithoutToolCallDeltas, c as AgentErrorStreamEvent, d as AgentStreamEvent, e as AgentStreamEventWithToolCallDeltas, f as AgentStreamEventWithoutToolCallDeltas, g as AgentStreamOptions, h as AgentToolCallDeltaEvent, P as PromptResponse } from './index-VH93vDXo.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-DW1Va3vx.js';
13
+ export { C as CreateToolOptions, c as createThinkTool, a as createTool } from './think-tool-DABDgW_E.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-tHPNeWMR.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-CGEYQndv.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-D78Vnorg.js';
18
+ import './types-BbLcbRqM.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-BHxJcHMk.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-MEUZ4NBO.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-7NULHGAO.js";
14
+ import "./chunk-GCZIIYZW.js";
15
15
  import {
16
16
  MaxTurnsError,
17
17
  PromptCancelledError,
18
18
  ToolApprovalRequiredError
19
- } from "./chunk-3LB36HON.js";
19
+ } from "./chunk-CNANX5OL.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-BIYXGG33.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-QTZHDPQX.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-TIV3WFSR.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-C1yoidvI.js';
2
+ import '../types-Byo50mwr.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-D78Vnorg.js';
5
+ import '../types-DPYoqg8M.js';
6
+ import '../index-VH93vDXo.js';
7
+ import '../tool-tHPNeWMR.js';
8
+ import '../middleware-CGEYQndv.js';
9
9
  import '../types-DHHZztGO.js';
10
- import '../types-9TeQF79I.js';
10
+ import '../types-BHxJcHMk.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-GCZIIYZW.js";
6
+ import "../chunk-CNANX5OL.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-BIYXGG33.js";
10
+ import "../chunk-I7TM7TKX.js";
11
11
  import "../chunk-2ODTMRHP.js";
12
+ import "../chunk-QTZHDPQX.js";
13
+ import "../chunk-TIV3WFSR.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-Byo50mwr.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-Byo50mwr.js';
2
2
 
3
3
  type LoaderResult<T> = {
4
4
  ok: true;
@@ -1,10 +1,10 @@
1
- import { M as McpConnection, a as McpServer, b as McpStdioOptions, c as McpHttpOptions, d as McpSseOptions } from '../types-CibT6_rS.js';
2
- export { e as McpClient, f as McpToolCallContent, g as McpToolCallResult, h as McpToolDefinition } from '../types-CibT6_rS.js';
1
+ import { M as McpConnection, a as McpServer, b as McpStdioOptions, c as McpHttpOptions, d as McpSseOptions } from '../types-BbLcbRqM.js';
2
+ export { e as McpClient, f as McpToolCallContent, g as McpToolCallResult, h as McpToolDefinition } from '../types-BbLcbRqM.js';
3
3
  import '@modelcontextprotocol/sdk/client/sse.js';
4
4
  import '@modelcontextprotocol/sdk/client/stdio.js';
5
5
  import '@modelcontextprotocol/sdk/client/streamableHttp.js';
6
- import '../types-BNq9tWdA.js';
7
- import '../tool-DhT6kR0Z.js';
6
+ import '../types-Byo50mwr.js';
7
+ import '../tool-tHPNeWMR.js';
8
8
 
9
9
  declare function connectMcp(connection: McpConnection): Promise<McpServer>;
10
10
 
@@ -1,6 +1,6 @@
1
- import { f as MemoryOptions, R as ResolvedMemoryOptions } from '../types-CaXSh3vK.js';
2
- export { g as MemoryAppendInput, h as MemoryContext, M as MemoryConversation, a as MemoryConversationListOptions, b as MemoryConversationMessage, c as MemoryConversationSummary, i as MemoryErrorInput, d as MemoryInspector, j as MemoryRegistration, k as MemorySavePolicy, e as MemoryStore, S as SessionOptions } from '../types-CaXSh3vK.js';
3
- import '../types-BNq9tWdA.js';
1
+ import { f as MemoryOptions, R as ResolvedMemoryOptions } from '../types-DPYoqg8M.js';
2
+ export { g as MemoryAppendInput, h as MemoryContext, M as MemoryConversation, a as MemoryConversationListOptions, b as MemoryConversationMessage, c as MemoryConversationSummary, i as MemoryErrorInput, d as MemoryInspector, j as MemoryRegistration, k as MemorySavePolicy, e as MemoryStore, S as SessionOptions } from '../types-DPYoqg8M.js';
3
+ import '../types-Byo50mwr.js';
4
4
 
5
5
  declare function resolveMemoryOptions(options?: MemoryOptions): ResolvedMemoryOptions;
6
6
 
@@ -1,7 +1,7 @@
1
- import { k as ToolDefinition, d as CompletionRequest, e as CompletionResponse, g as JsonValue, n as ToolResultContent } from './types-BNq9tWdA.js';
1
+ import { k as ToolDefinition, d as CompletionRequest, e as CompletionResponse, g as JsonValue, n as ToolResultContent } from './types-Byo50mwr.js';
2
2
  import { V as VectorMetadata, E as EmbeddingModel, c as EmbeddedDocument } from './types-DHHZztGO.js';
3
- import { A as AnyTool, f as ToolCallContext, N as NormalizedToolOutput } from './tool-DhT6kR0Z.js';
4
- import { a as VectorSearchIndex } from './types-9TeQF79I.js';
3
+ import { A as AnyTool, f as ToolCallContext, N as NormalizedToolOutput } from './tool-tHPNeWMR.js';
4
+ import { a as VectorSearchIndex } from './types-BHxJcHMk.js';
5
5
 
6
6
  declare class ToolSet {
7
7
  private readonly tools;