@anvia/core 0.15.0 → 0.17.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.
- package/dist/agent/index.d.ts +14 -13
- package/dist/agent/index.js +8 -8
- package/dist/{agent-C1yoidvI.d.ts → agent-Cg0UigNK.d.ts} +9 -7
- package/dist/audio-generation/index.d.ts +1 -1
- package/dist/{chunk-BPU264XB.js → chunk-54S4I3SX.js} +7 -7
- package/dist/chunk-54S4I3SX.js.map +1 -0
- package/dist/{chunk-DC2GJDPR.js → chunk-77D7XBWL.js} +2 -2
- package/dist/{chunk-GCZIIYZW.js → chunk-BQCTJSNL.js} +7 -5
- package/dist/chunk-BQCTJSNL.js.map +1 -0
- package/dist/{chunk-I7TM7TKX.js → chunk-F3C5653H.js} +4 -4
- package/dist/{chunk-QTZHDPQX.js → chunk-GCED5ZNM.js} +16 -4
- package/dist/chunk-GCED5ZNM.js.map +1 -0
- package/dist/{chunk-CNANX5OL.js → chunk-OPAEENGD.js} +141 -25
- package/dist/chunk-OPAEENGD.js.map +1 -0
- package/dist/{chunk-TIV3WFSR.js → chunk-PJDL5UT2.js} +84 -5
- package/dist/chunk-PJDL5UT2.js.map +1 -0
- package/dist/{chunk-7NULHGAO.js → chunk-RWAOHGRL.js} +16 -5
- package/dist/chunk-RWAOHGRL.js.map +1 -0
- package/dist/{chunk-MEUZ4NBO.js → chunk-SWUH4G2I.js} +2 -2
- package/dist/{chunk-BIYXGG33.js → chunk-SWUIBS4N.js} +6 -6
- package/dist/completion/index.d.ts +6 -5
- package/dist/completion/index.js +4 -2
- package/dist/evals/index.d.ts +8 -8
- package/dist/evals/index.js +9 -9
- package/dist/extractor/index.d.ts +8 -8
- package/dist/extractor/index.js +9 -9
- package/dist/guardrails/index.d.ts +1 -1
- package/dist/hooks/index.d.ts +3 -3
- package/dist/image-generation/index.d.ts +1 -1
- package/dist/{index-VH93vDXo.d.ts → index-XTUEMWhU.d.ts} +36 -8
- package/dist/index.d.ts +12 -12
- package/dist/index.js +14 -12
- package/dist/internal/agent.d.ts +8 -8
- package/dist/internal/agent.js +7 -7
- package/dist/{json-CaCUxJqG.d.ts → json-D9IvOgx_.d.ts} +2 -2
- package/dist/loaders/index.d.ts +1 -1
- package/dist/mcp/index.d.ts +4 -4
- package/dist/memory/index.d.ts +3 -3
- package/dist/{middleware-CGEYQndv.d.ts → middleware-Cp0tm6zE.d.ts} +3 -3
- package/dist/observability/index.d.ts +3 -3
- package/dist/observability/index.js.map +1 -1
- package/dist/pipeline/index.d.ts +8 -8
- package/dist/request/index.d.ts +8 -8
- package/dist/request/index.js +6 -6
- package/dist/skills/index.d.ts +4 -4
- package/dist/skills/index.js +5 -5
- package/dist/{think-tool-DABDgW_E.d.ts → think-tool-CpCKo8Q8.d.ts} +1 -1
- package/dist/tool/index.d.ts +5 -5
- package/dist/tool/index.js +5 -5
- package/dist/{tool-tHPNeWMR.d.ts → tool-Dhwg__1L.d.ts} +1 -1
- package/dist/transcription/index.d.ts +1 -1
- package/dist/{types-BbLcbRqM.d.ts → types-BBEf34DP.d.ts} +2 -2
- package/dist/{types-D78Vnorg.d.ts → types-BCA8p0sb.d.ts} +1 -1
- package/dist/{types-DPYoqg8M.d.ts → types-CBmhLT_r.d.ts} +1 -1
- package/dist/{types-BHxJcHMk.d.ts → types-DMGvEFRf.d.ts} +1 -1
- package/dist/{types-Byo50mwr.d.ts → types-XjIh933x.d.ts} +49 -1
- package/dist/{types-DW1Va3vx.d.ts → types-fBv8mhvP.d.ts} +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +2 -2
- package/dist/vector-store/index.d.ts +4 -4
- package/dist/vector-store/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-7NULHGAO.js.map +0 -1
- package/dist/chunk-BPU264XB.js.map +0 -1
- package/dist/chunk-CNANX5OL.js.map +0 -1
- package/dist/chunk-GCZIIYZW.js.map +0 -1
- package/dist/chunk-QTZHDPQX.js.map +0 -1
- package/dist/chunk-TIV3WFSR.js.map +0 -1
- /package/dist/{chunk-DC2GJDPR.js.map → chunk-77D7XBWL.js.map} +0 -0
- /package/dist/{chunk-I7TM7TKX.js.map → chunk-F3C5653H.js.map} +0 -0
- /package/dist/{chunk-MEUZ4NBO.js.map → chunk-SWUH4G2I.js.map} +0 -0
- /package/dist/{chunk-BIYXGG33.js.map → chunk-SWUIBS4N.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/completion/json.ts","../src/completion/types.ts"],"sourcesContent":["import type { JsonValue } from \"./types\";\n\nexport function isJsonValue(value: unknown): value is JsonValue {\n return isJsonValueWithAncestors(value, new WeakSet<object>());\n}\n\nfunction isJsonValueWithAncestors(value: unknown, ancestors: WeakSet<object>): value is JsonValue {\n if (value === null || typeof value === \"string\" || typeof value === \"boolean\") {\n return true;\n }\n if (typeof value === \"number\") {\n return Number.isFinite(value);\n }\n if (typeof value !== \"object\" || ancestors.has(value)) {\n return false;\n }\n\n ancestors.add(value);\n try {\n if (Array.isArray(value)) {\n if (!hasOnlyDenseArrayProperties(value)) {\n return false;\n }\n for (let index = 0; index < value.length; index += 1) {\n if (!isJsonValueWithAncestors(value[index], ancestors)) {\n return false;\n }\n }\n return true;\n }\n\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n return false;\n }\n for (const key of Reflect.ownKeys(value)) {\n if (typeof key !== \"string\") {\n return false;\n }\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (\n descriptor === undefined ||\n !descriptor.enumerable ||\n !(\"value\" in descriptor) ||\n !isJsonValueWithAncestors(descriptor.value, ancestors)\n ) {\n return false;\n }\n }\n return true;\n } catch {\n return false;\n } finally {\n ancestors.delete(value);\n }\n}\n\nfunction hasOnlyDenseArrayProperties(value: unknown[]): boolean {\n const keys = Reflect.ownKeys(value);\n if (keys.length !== value.length + 1 || keys.at(-1) !== \"length\") {\n return false;\n }\n for (let index = 0; index < value.length; index += 1) {\n const key = String(index);\n if (keys[index] !== key) {\n return false;\n }\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (descriptor === undefined || !descriptor.enumerable || !(\"value\" in descriptor)) {\n return false;\n }\n }\n return true;\n}\n","import { isJsonValue } from \"./json\";\n\nexport type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue = JsonPrimitive | JsonObject | JsonValue[];\nexport type JsonObject = { [key: string]: JsonValue | undefined };\n\nexport type Document = {\n id: string;\n text: string;\n additionalProps?: Record<string, string>;\n};\n\nexport type Text = {\n type: \"text\";\n text: string;\n signature?: string;\n};\n\nexport type ImageDetail = \"auto\" | \"low\" | \"high\";\n\nexport type ImageContent = {\n type: \"image\";\n source:\n | {\n type: \"url\";\n url: string;\n }\n | {\n type: \"base64\";\n data: string;\n mediaType: string;\n };\n detail?: ImageDetail;\n};\n\nexport type DocumentContent = {\n type: \"document\";\n source:\n | {\n type: \"url\";\n url: string;\n mediaType: string;\n filename?: string;\n }\n | {\n type: \"base64\";\n data: string;\n mediaType: string;\n filename?: string;\n }\n | {\n type: \"text\";\n text: string;\n mediaType?: string;\n filename?: string;\n };\n};\n\nexport type Reasoning = {\n type: \"reasoning\";\n text: string;\n id?: string;\n content?: ReasoningContent[];\n};\n\nexport type ReasoningContent =\n | {\n type: \"text\";\n text: string;\n signature?: string;\n }\n | {\n type: \"summary\";\n text: string;\n }\n | {\n type: \"encrypted\";\n data: string;\n }\n | {\n type: \"redacted\";\n data: string;\n };\n\nexport type ReasoningContentType = ReasoningContent[\"type\"];\n\nexport type ToolFunction = {\n name: string;\n arguments: JsonValue;\n};\n\nexport type ToolCall = {\n type: \"tool_call\";\n id: string;\n callId?: string;\n function: ToolFunction;\n signature?: string;\n additionalParams?: JsonValue;\n};\n\nexport type ToolResultContent =\n | { type: \"text\"; text: string }\n | { type: \"image\"; data: string; mediaType?: string };\n\nexport type ToolResult = {\n type: \"tool_result\";\n id: string;\n callId?: string;\n toolName?: string;\n content: ToolResultContent[];\n};\n\nexport type MessageOptions = {\n metadata?: JsonValue | undefined;\n};\n\nexport type AssistantMessageOptions = MessageOptions & {\n id?: string | undefined;\n};\n\nexport type ToolResultOptions = {\n callId?: string | undefined;\n toolName?: string | undefined;\n};\n\nexport type ToolResultMessageOptions = ToolResultOptions & MessageOptions;\n\nexport type UserContent = Text | ImageContent | DocumentContent;\nexport type AssistantContent = Text | ToolCall | Reasoning | ImageContent;\nexport type ToolContent = ToolResult;\n\nexport type SystemMessage = {\n role: \"system\";\n content: string;\n metadata?: JsonValue;\n};\n\nexport type UserMessage = {\n role: \"user\";\n content: UserContent[];\n metadata?: JsonValue;\n};\n\nexport type AssistantMessage = {\n role: \"assistant\";\n id?: string;\n content: AssistantContent[];\n metadata?: JsonValue;\n};\n\nexport type ToolMessage = {\n role: \"tool\";\n content: ToolContent[];\n metadata?: JsonValue;\n};\n\nexport type Message = SystemMessage | UserMessage | AssistantMessage | ToolMessage;\n\nexport const UserContent = {\n text(text: string): Text {\n return { type: \"text\", text };\n },\n imageUrl(url: string, options: { detail?: ImageDetail } = {}): ImageContent {\n const image: ImageContent = { type: \"image\", source: { type: \"url\", url } };\n if (options.detail !== undefined) {\n image.detail = options.detail;\n }\n return image;\n },\n imageBase64(\n data: string,\n mediaType: string,\n options: { detail?: ImageDetail } = {},\n ): ImageContent {\n const image: ImageContent = {\n type: \"image\",\n source: { type: \"base64\", data, mediaType },\n };\n if (options.detail !== undefined) {\n image.detail = options.detail;\n }\n return image;\n },\n documentUrl(\n url: string,\n mediaType: string,\n options: { filename?: string | undefined } = {},\n ): DocumentContent {\n return {\n type: \"document\",\n source:\n options.filename === undefined\n ? { type: \"url\", url, mediaType }\n : { type: \"url\", url, mediaType, filename: options.filename },\n };\n },\n documentBase64(\n data: string,\n mediaType: string,\n options: { filename?: string | undefined } = {},\n ): DocumentContent {\n return {\n type: \"document\",\n source:\n options.filename === undefined\n ? { type: \"base64\", data, mediaType }\n : { type: \"base64\", data, mediaType, filename: options.filename },\n };\n },\n documentText(text: string): Text {\n return { type: \"text\", text };\n },\n};\n\nexport const ToolContent = {\n toolResult(\n id: string,\n content: string | ToolResultContent[],\n callIdOrOptions?: string | ToolResultOptions,\n toolName?: string,\n ): ToolResult {\n const normalized =\n typeof content === \"string\" ? [{ type: \"text\" as const, text: content }] : content;\n const options = normalizeToolResultOptions(callIdOrOptions, toolName);\n const result: ToolResult = { type: \"tool_result\", id, content: normalized };\n if (options.callId !== undefined) {\n result.callId = options.callId;\n }\n if (options.toolName !== undefined) {\n result.toolName = options.toolName;\n }\n return result;\n },\n};\n\nfunction normalizeToolResultOptions(\n callIdOrOptions?: string | ToolResultOptions,\n toolName?: string,\n): ToolResultOptions {\n if (callIdOrOptions === undefined) {\n return toolName === undefined ? {} : { toolName };\n }\n if (typeof callIdOrOptions === \"string\") {\n return toolName === undefined\n ? { callId: callIdOrOptions }\n : { callId: callIdOrOptions, toolName };\n }\n return toolName === undefined ? callIdOrOptions : { ...callIdOrOptions, toolName };\n}\n\nexport function serializeToolResultOutput(output: unknown): string {\n if (typeof output === \"string\") {\n return output;\n }\n\n try {\n const serialized = JSON.stringify(output);\n return serialized === undefined ? String(output) : serialized;\n } catch {\n return String(output);\n }\n}\n\nexport function isToolResultContentArray(value: unknown): value is ToolResultContent[] {\n return (\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((item) => {\n if (typeof item !== \"object\" || item === null || !(\"type\" in item)) {\n return false;\n }\n if (item.type === \"text\") {\n return \"text\" in item && typeof item.text === \"string\";\n }\n if (item.type === \"image\") {\n return (\n \"data\" in item &&\n typeof item.data === \"string\" &&\n (!(\"mediaType\" in item) ||\n item.mediaType === undefined ||\n typeof item.mediaType === \"string\")\n );\n }\n return false;\n })\n );\n}\n\nexport const AssistantContent = {\n text(text: string): Text {\n return { type: \"text\", text };\n },\n imageUrl(url: string, options: { detail?: ImageDetail } = {}): ImageContent {\n const image: ImageContent = { type: \"image\", source: { type: \"url\", url } };\n if (options.detail !== undefined) {\n image.detail = options.detail;\n }\n return image;\n },\n imageBase64(\n data: string,\n mediaType: string,\n options: { detail?: ImageDetail } = {},\n ): ImageContent {\n const image: ImageContent = {\n type: \"image\",\n source: { type: \"base64\", data, mediaType },\n };\n if (options.detail !== undefined) {\n image.detail = options.detail;\n }\n return image;\n },\n reasoning(text: string, id?: string): Reasoning {\n return id === undefined ? { type: \"reasoning\", text } : { type: \"reasoning\", text, id };\n },\n reasoningFromContent(content: ReasoningContent[], id?: string): Reasoning {\n const text = reasoningDisplayText(content);\n const reasoning: Reasoning = { type: \"reasoning\", text, content };\n return id === undefined ? reasoning : { ...reasoning, id };\n },\n reasoningSummary(text: string, id?: string): Reasoning {\n return AssistantContent.reasoningFromContent([{ type: \"summary\", text }], id);\n },\n reasoningEncrypted(data: string, id?: string): Reasoning {\n return AssistantContent.reasoningFromContent([{ type: \"encrypted\", data }], id);\n },\n reasoningRedacted(data: string, id?: string): Reasoning {\n return AssistantContent.reasoningFromContent([{ type: \"redacted\", data }], id);\n },\n toolCall(id: string, name: string, args: JsonValue, callId?: string): ToolCall {\n const base: ToolCall = {\n type: \"tool_call\",\n id,\n function: {\n name,\n arguments: args,\n },\n };\n return callId === undefined ? base : { ...base, callId };\n },\n};\n\nexport function reasoningDisplayText(reasoning: Reasoning | ReasoningContent[]): string {\n const content = Array.isArray(reasoning) ? reasoning : reasoning.content;\n if (content === undefined) {\n return Array.isArray(reasoning) ? \"\" : reasoning.text;\n }\n return content\n .flatMap((item) => {\n if (item.type === \"text\" || item.type === \"summary\") {\n return [item.text];\n }\n return [];\n })\n .join(\"\");\n}\n\nexport const Message = {\n system(content: string, options: MessageOptions = {}): Message {\n return { role: \"system\", content, ...messageMetadata(options) };\n },\n user(content: string | UserContent[], options: MessageOptions = {}): Message {\n return {\n role: \"user\",\n content: typeof content === \"string\" ? [UserContent.text(content)] : content,\n ...messageMetadata(options),\n };\n },\n assistant(\n content: string | AssistantContent[],\n idOrOptions?: string | AssistantMessageOptions,\n ): Message {\n const normalized = typeof content === \"string\" ? [AssistantContent.text(content)] : content;\n const options = typeof idOrOptions === \"string\" ? { id: idOrOptions } : (idOrOptions ?? {});\n 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\n/**\n * A tool executed by the model provider rather than by Anvia's local tool runtime.\n *\n * Provider packages expose typed factories for these values. Application code can\n * pass them through the same high-level `tools` APIs used for local tools.\n */\nexport type ProviderTool = {\n kind: \"provider\";\n provider: string;\n name: string;\n configuration?: JsonObject;\n};\n\nexport type CompletionTool = ToolDefinition | ProviderTool;\n\nexport function isProviderTool(value: unknown): value is ProviderTool {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return false;\n }\n const candidate = value as Partial<ProviderTool>;\n return (\n candidate.kind === \"provider\" &&\n typeof candidate.provider === \"string\" &&\n candidate.provider.trim().length > 0 &&\n typeof candidate.name === \"string\" &&\n candidate.name.trim().length > 0 &&\n (candidate.configuration === undefined ||\n (typeof candidate.configuration === \"object\" &&\n candidate.configuration !== null &&\n !Array.isArray(candidate.configuration) &&\n isJsonValue(candidate.configuration)))\n );\n}\n\nexport type CompletionSource = {\n type: \"url\";\n url: string;\n title?: string;\n id?: string;\n startIndex?: number;\n endIndex?: number;\n};\n\nexport type ProviderToolCall = {\n id: string;\n name: string;\n status?: string;\n details?: JsonObject;\n};\n\n/**\n * Provider-normalized, mutually exclusive usage buckets.\n *\n * Every token should appear in exactly one non-total bucket. `total` is the\n * only aggregate key and should equal the sum of the other buckets.\n */\nexport type UsageDetails = Record<string, number>;\n\nexport type Usage = {\n inputTokens: number;\n outputTokens: number;\n totalTokens: number;\n cachedInputTokens: number;\n cacheCreationInputTokens: number;\n details?: UsageDetails;\n};\n\nexport type AssistantGenerationMetadata = {\n provider: string;\n model: string;\n usage: Usage;\n sources?: CompletionSource[];\n providerToolCalls?: ProviderToolCall[];\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 const result: Usage = {\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 const details = addUsageDetails(left, right);\n if (details !== undefined) {\n result.details = details;\n }\n return result;\n },\n};\n\nfunction addUsageDetails(left: Usage, right: Usage): UsageDetails | undefined {\n if (isEmptyUsage(left) && left.details === undefined) {\n return right.details === undefined ? undefined : { ...right.details };\n }\n if (isEmptyUsage(right) && right.details === undefined) {\n return left.details === undefined ? undefined : { ...left.details };\n }\n if (left.details === undefined || right.details === undefined) {\n return undefined;\n }\n const details: UsageDetails = { ...left.details };\n for (const [key, value] of Object.entries(right.details)) {\n details[key] = (details[key] ?? 0) + value;\n }\n return details;\n}\n\nfunction isEmptyUsage(usage: Usage): boolean {\n return (\n usage.inputTokens === 0 &&\n usage.outputTokens === 0 &&\n usage.totalTokens === 0 &&\n usage.cachedInputTokens === 0 &&\n usage.cacheCreationInputTokens === 0\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 const metadata: AssistantGenerationMetadata = {\n provider: generation.provider,\n model: generation.model,\n usage: {\n ...generation.usage,\n ...(generation.usage.details === undefined\n ? {}\n : { details: { ...generation.usage.details } }),\n },\n };\n if (isCompletionSourceArray(generation.sources)) {\n metadata.sources = generation.sources.map((source) => ({ ...source }));\n }\n if (isProviderToolCallArray(generation.providerToolCalls)) {\n metadata.providerToolCalls = generation.providerToolCalls.map((toolCall) => ({\n ...toolCall,\n ...(toolCall.details === undefined ? {} : { details: { ...toolCall.details } }),\n }));\n }\n return metadata;\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 isUsageDetailsValue(value.details)\n );\n}\n\nfunction isNonnegativeFiniteNumber(value: JsonValue | undefined): value is number {\n return typeof value === \"number\" && Number.isFinite(value) && value >= 0;\n}\n\nfunction isUsageDetailsValue(value: JsonValue | undefined): value is JsonObject | undefined {\n if (value === undefined) {\n return true;\n }\n if (!isJsonObjectValue(value)) {\n return false;\n }\n let total: number | undefined;\n let bucketSum = 0;\n for (const [key, detail] of Object.entries(value)) {\n if (detail === undefined || !isNonnegativeFiniteNumber(detail)) {\n return false;\n }\n if (key === \"total\") {\n total = detail;\n } else {\n bucketSum += detail;\n }\n }\n return total !== undefined && total === bucketSum;\n}\n\nfunction isCompletionSourceArray(value: JsonValue | undefined): value is CompletionSource[] {\n return (\n Array.isArray(value) &&\n value.every(\n (source) =>\n isJsonObjectValue(source) &&\n source.type === \"url\" &&\n typeof source.url === \"string\" &&\n (source.title === undefined || typeof source.title === \"string\") &&\n (source.id === undefined || typeof source.id === \"string\") &&\n (source.startIndex === undefined || typeof source.startIndex === \"number\") &&\n (source.endIndex === undefined || typeof source.endIndex === \"number\"),\n )\n );\n}\n\nfunction isProviderToolCallArray(value: JsonValue | undefined): value is ProviderToolCall[] {\n return (\n Array.isArray(value) &&\n value.every(\n (toolCall) =>\n isJsonObjectValue(toolCall) &&\n typeof toolCall.id === \"string\" &&\n typeof toolCall.name === \"string\" &&\n (toolCall.status === undefined || typeof toolCall.status === \"string\") &&\n (toolCall.details === undefined || isJsonObjectValue(toolCall.details)),\n )\n );\n}\n\nexport type CompletionRequest<ModelName extends string = string> = {\n model?: ModelName;\n instructions?: string;\n chatHistory: Message[];\n documents: Document[];\n tools: ToolDefinition[];\n providerTools?: ProviderTool[];\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 sources?: CompletionSource[];\n providerToolCalls?: ProviderToolCall[];\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 providerTools?: 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: \"source\";\n source: CompletionSource;\n }\n | {\n type: \"provider_tool_call\";\n toolCall: ProviderToolCall;\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.providerTools?.length ?? 0) > 0 && capabilities.providerTools !== true) {\n throw new CompletionCapabilityError(`${modelLabel} does not support provider-executed tools.`);\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,E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AC,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,13 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Agent,
|
|
3
3
|
normalizeAgentId
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BQCTJSNL.js";
|
|
5
5
|
import {
|
|
6
6
|
ToolSet
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-SWUIBS4N.js";
|
|
8
8
|
import {
|
|
9
9
|
resolveMemoryOptions
|
|
10
10
|
} from "./chunk-M6RPFHG7.js";
|
|
11
|
+
import {
|
|
12
|
+
isProviderTool
|
|
13
|
+
} from "./chunk-PJDL5UT2.js";
|
|
11
14
|
import {
|
|
12
15
|
toProviderJsonSchema
|
|
13
16
|
} from "./chunk-WQKHFADH.js";
|
|
@@ -44,6 +47,7 @@ var AgentBuilder = class {
|
|
|
44
47
|
memoryRegistration;
|
|
45
48
|
eventStoreRegistration;
|
|
46
49
|
activeToolSet = new ToolSet();
|
|
50
|
+
providerToolDefs = [];
|
|
47
51
|
name(name) {
|
|
48
52
|
this.agentName = name;
|
|
49
53
|
return this;
|
|
@@ -71,11 +75,17 @@ var AgentBuilder = class {
|
|
|
71
75
|
return this;
|
|
72
76
|
}
|
|
73
77
|
tool(tool) {
|
|
74
|
-
|
|
78
|
+
if (isProviderTool(tool)) {
|
|
79
|
+
this.providerToolDefs.push(tool);
|
|
80
|
+
} else {
|
|
81
|
+
this.activeToolSet.addTool(tool);
|
|
82
|
+
}
|
|
75
83
|
return this;
|
|
76
84
|
}
|
|
77
85
|
tools(tools) {
|
|
78
|
-
|
|
86
|
+
for (const tool of tools) {
|
|
87
|
+
this.tool(tool);
|
|
88
|
+
}
|
|
79
89
|
return this;
|
|
80
90
|
}
|
|
81
91
|
mcp(servers) {
|
|
@@ -187,6 +197,7 @@ var AgentBuilder = class {
|
|
|
187
197
|
maxTokens: this.maxTokenCount,
|
|
188
198
|
additionalParams: this.params,
|
|
189
199
|
toolSet: this.activeToolSet,
|
|
200
|
+
providerTools: this.providerToolDefs,
|
|
190
201
|
toolChoice: this.choice,
|
|
191
202
|
defaultMaxTurns: this.turns,
|
|
192
203
|
hook: this.requestHook,
|
|
@@ -212,4 +223,4 @@ var AgentBuilder = class {
|
|
|
212
223
|
export {
|
|
213
224
|
AgentBuilder
|
|
214
225
|
};
|
|
215
|
-
//# sourceMappingURL=chunk-
|
|
226
|
+
//# sourceMappingURL=chunk-RWAOHGRL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/agent/builder.ts"],"sourcesContent":["import {\n type CompletionModel,\n type Document,\n isProviderTool,\n type JsonObject,\n type JsonValue,\n type ProviderTool,\n type ToolChoice,\n} from \"../completion\";\nimport type { GuardrailPolicy, GuardrailPolicyInput } from \"../guardrails\";\nimport { appendGuardrailPolicies } from \"../guardrails\";\nimport type { PromptHook } from \"../hooks\";\nimport type { McpServer } from \"../mcp\";\nimport { resolveMemoryOptions } from \"../memory/options\";\nimport type { MemoryOptions, MemoryRegistration, MemoryStore } from \"../memory/types\";\nimport type { AgentObserver, AgentObserverRegistration, ObserveOptions } from \"../observability\";\nimport { toProviderJsonSchema, type ZodSchema } from \"../schema/zod-schema\";\nimport type { SkillSet } from \"../skills\";\nimport type { ToolSearchDocument } from \"../tool/dynamic-tools\";\nimport type { AgentMiddleware, ToolMiddleware } from \"../tool/middleware\";\nimport type { AnyTool, ToolApprovalsOptions } from \"../tool/tool\";\nimport { ToolSet } from \"../tool/tool-set\";\nimport type { VectorSearchIndex } from \"../vector-store\";\nimport { Agent } from \"./agent\";\nimport { normalizeAgentId } from \"./ids\";\nimport type {\n AgentEventStore,\n AgentEventStoreOptions,\n AgentEventStoreRegistration,\n DynamicContextOptions,\n DynamicContextRegistration,\n DynamicToolOptions,\n DynamicToolRegistration,\n} from \"./types\";\n\nexport class AgentBuilder<M extends CompletionModel = CompletionModel> {\n private readonly agentId: string;\n private agentName: string | undefined;\n private agentDescription: string | undefined;\n private instructionBlocks: string[] = [];\n private contextDocs: Document[] = [];\n private temp: number | undefined;\n private maxTokenCount: number | undefined;\n private params: JsonValue | undefined;\n private choice: ToolChoice | undefined;\n private turns: number | undefined;\n private requestHook: PromptHook | undefined;\n private schema: JsonObject | undefined;\n private approvalOptions: ToolApprovalsOptions | undefined;\n private guardrailPolicies: GuardrailPolicy[] = [];\n private skillInstructionBlocks: string[] = [];\n private observerRegistrations: AgentObserverRegistration[] = [];\n private dynamicContextRegistrations: DynamicContextRegistration[] = [];\n private dynamicToolRegistrations: DynamicToolRegistration[] = [];\n private middlewareRegistrations: AgentMiddleware[] = [];\n private memoryRegistration: MemoryRegistration | undefined;\n private eventStoreRegistration: AgentEventStoreRegistration | undefined;\n private activeToolSet = new ToolSet();\n private providerToolDefs: ProviderTool[] = [];\n\n constructor(\n agentId: string,\n private readonly completionModel: M,\n ) {\n this.agentId = normalizeAgentId(agentId);\n }\n\n name(name: string): this {\n this.agentName = name;\n return this;\n }\n\n description(description: string): this {\n this.agentDescription = description;\n return this;\n }\n\n instructions(instructions: string): this {\n if (instructions.length > 0) {\n this.instructionBlocks.push(instructions);\n }\n return this;\n }\n\n context(text: string, id = `static_doc_${this.contextDocs.length}`): this {\n this.contextDocs.push({ id, text });\n return this;\n }\n\n dynamicContext<T>(index: VectorSearchIndex<T>, options: DynamicContextOptions<T>): this {\n this.dynamicContextRegistrations.push({ index, options } as DynamicContextRegistration);\n return this;\n }\n\n dynamicTools(index: VectorSearchIndex<ToolSearchDocument>, options: DynamicToolOptions): this {\n this.dynamicToolRegistrations.push({ index, options });\n return this;\n }\n\n tool(tool: AnyTool | ProviderTool): this {\n if (isProviderTool(tool)) {\n this.providerToolDefs.push(tool);\n } else {\n this.activeToolSet.addTool(tool);\n }\n return this;\n }\n\n tools(tools: Array<AnyTool | ProviderTool>): this {\n for (const tool of tools) {\n this.tool(tool);\n }\n return this;\n }\n\n mcp(servers: McpServer[]): this {\n for (const server of servers) {\n this.activeToolSet.addTools(server.tools);\n }\n return this;\n }\n\n skills(skillSet: SkillSet): this {\n if (skillSet.instructions.length > 0) {\n this.skillInstructionBlocks.push(skillSet.instructions);\n }\n this.activeToolSet.addTools(skillSet.tools);\n return this;\n }\n\n useToolSet(toolSet: ToolSet): this {\n toolSet.addTools(this.activeToolSet);\n this.activeToolSet = toolSet;\n return this;\n }\n\n temperature(temperature: number): this {\n this.temp = temperature;\n return this;\n }\n\n maxTokens(maxTokens: number): this {\n this.maxTokenCount = maxTokens;\n return this;\n }\n\n additionalParams(params: JsonValue): this {\n this.params = params;\n return this;\n }\n\n toolChoice(toolChoice: ToolChoice): this {\n this.choice = toolChoice;\n return this;\n }\n\n defaultMaxTurns(defaultMaxTurns: number): this {\n this.turns = defaultMaxTurns;\n return this;\n }\n\n hook(hook: PromptHook): this {\n this.requestHook = hook;\n return this;\n }\n\n middleware(middleware: AgentMiddleware): this {\n this.middlewareRegistrations.push(middleware);\n return this;\n }\n\n middlewares(middlewares: AgentMiddleware[]): this {\n this.middlewareRegistrations.push(...middlewares);\n return this;\n }\n\n /**\n * @deprecated Use `middleware` instead.\n */\n toolMiddleware(middleware: ToolMiddleware): this {\n return this.middleware(middleware);\n }\n\n /**\n * @deprecated Use `middlewares` instead.\n */\n toolMiddlewares(middlewares: ToolMiddleware[]): this {\n return this.middlewares(middlewares);\n }\n\n observe(observer: AgentObserver, options: ObserveOptions = {}): this {\n this.observerRegistrations.push({\n observer,\n failOnObserverError: options.failOnObserverError,\n });\n return this;\n }\n\n approvals(options: ToolApprovalsOptions): this {\n this.approvalOptions = options;\n return this;\n }\n\n guardrails(policies: GuardrailPolicyInput): this {\n this.guardrailPolicies = appendGuardrailPolicies(this.guardrailPolicies, policies);\n return this;\n }\n\n memory(store: MemoryStore, options: MemoryOptions = {}): this {\n this.memoryRegistration = {\n store,\n options: resolveMemoryOptions(options),\n };\n return this;\n }\n\n eventStore(store: AgentEventStore, options: AgentEventStoreOptions = {}): this {\n this.eventStoreRegistration = {\n store,\n options: {\n include: options.include ?? \"all\",\n },\n };\n return this;\n }\n\n outputSchema(schema: ZodSchema): this {\n this.schema = toProviderJsonSchema(schema);\n return this;\n }\n\n build(): Agent<M> {\n return new Agent({\n id: this.agentId,\n name: this.agentName,\n description: this.agentDescription,\n model: this.completionModel,\n instructions: this.buildInstructions(),\n staticContext: this.contextDocs,\n temperature: this.temp,\n maxTokens: this.maxTokenCount,\n additionalParams: this.params,\n toolSet: this.activeToolSet,\n providerTools: this.providerToolDefs,\n toolChoice: this.choice,\n defaultMaxTurns: this.turns,\n hook: this.requestHook,\n outputSchema: this.schema,\n observers: this.observerRegistrations,\n approvals: this.approvalOptions,\n guardrails: this.guardrailPolicies,\n dynamicContexts: this.dynamicContextRegistrations,\n dynamicTools: this.dynamicToolRegistrations,\n middlewares: this.middlewareRegistrations,\n memory: this.memoryRegistration,\n eventStore: this.eventStoreRegistration,\n });\n }\n\n private buildInstructions(): string | undefined {\n const parts = [...this.instructionBlocks, ...this.skillInstructionBlocks].filter(\n (part): part is string => part !== undefined && part.length > 0,\n );\n return parts.length === 0 ? undefined : parts.join(\"\\n\\n\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmCO,IAAM,eAAN,MAAgE;AAAA,EAyBrE,YACE,SACiB,iBACjB;AADiB;AAEjB,SAAK,UAAU,iBAAiB,OAAO;AAAA,EACzC;AAAA,EAHmB;AAAA,EA1BF;AAAA,EACT;AAAA,EACA;AAAA,EACA,oBAA8B,CAAC;AAAA,EAC/B,cAA0B,CAAC;AAAA,EAC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;AAAA,EACH;AAAA,EAEQ,oBAAwC;AAC9C,UAAM,QAAQ,CAAC,GAAG,KAAK,mBAAmB,GAAG,KAAK,sBAAsB,EAAE;AAAA,MACxE,CAAC,SAAyB,SAAS,UAAa,KAAK,SAAS;AAAA,IAChE;AACA,WAAO,MAAM,WAAW,IAAI,SAAY,MAAM,KAAK,MAAM;AAAA,EAC3D;AACF;","names":[]}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
isJsonValue,
|
|
7
7
|
reasoningDisplayText,
|
|
8
8
|
serializeToolResultOutput
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-PJDL5UT2.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-
|
|
466
|
+
//# sourceMappingURL=chunk-SWUH4G2I.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
InMemoryVectorStore,
|
|
3
3
|
createTool
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import {
|
|
6
|
-
isToolResultContentArray,
|
|
7
|
-
serializeToolResultOutput
|
|
8
|
-
} from "./chunk-TIV3WFSR.js";
|
|
4
|
+
} from "./chunk-F3C5653H.js";
|
|
9
5
|
import {
|
|
10
6
|
embedDocuments
|
|
11
7
|
} from "./chunk-YBBD4HZ3.js";
|
|
8
|
+
import {
|
|
9
|
+
isToolResultContentArray,
|
|
10
|
+
serializeToolResultOutput
|
|
11
|
+
} from "./chunk-PJDL5UT2.js";
|
|
12
12
|
|
|
13
13
|
// src/tool/errors.ts
|
|
14
14
|
var ToolCallError = class extends Error {
|
|
@@ -224,4 +224,4 @@ export {
|
|
|
224
224
|
createToolMiddleware,
|
|
225
225
|
createThinkTool
|
|
226
226
|
};
|
|
227
|
-
//# sourceMappingURL=chunk-
|
|
227
|
+
//# sourceMappingURL=chunk-SWUIBS4N.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-
|
|
2
|
-
import { D as Document, M as Message, C as CompletionModel,
|
|
3
|
-
export { A as AssistantContent, a as AssistantGenerationMetadata, b as AssistantMessage, c as AssistantMessageOptions,
|
|
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-D9IvOgx_.js';
|
|
2
|
+
import { D as Document, M as Message, C as CompletionModel, g as CompletionTool, z as ToolChoice, i as JsonValue, J as JsonObject, d as CompletionRequest, e as CompletionResponse } from '../types-XjIh933x.js';
|
|
3
|
+
export { A as AssistantContent, a as AssistantGenerationMetadata, b as AssistantMessage, c as AssistantMessageOptions, B as CompletionCapabilityError, E as CompletionModelCapabilities, f as CompletionSource, F as CompletionStreamEvent, G as DocumentContent, I as ImageContent, H as ImageDetail, h as JsonPrimitive, j as MessageOptions, P as ProviderTool, k as ProviderToolCall, R as Reasoning, K as ReasoningContent, L as ReasoningContentType, N as StreamingCompletionModel, S as SystemMessage, T as Text, l as ToolCall, O as ToolCallArgumentsMode, m as ToolContent, n as ToolDefinition, Q as ToolFunction, o as ToolMessage, p as ToolResult, q as ToolResultContent, r as ToolResultMessageOptions, s as ToolResultOptions, U as Usage, V as UsageDetails, t as UserContent, u as UserMessage, W as assertCompletionRequestSupported, v as getAssistantGenerationMetadata, w as isProviderTool, x as isToolResultContentArray, X as reasoningDisplayText, y as serializeToolResultOutput, Y as textFromAssistantContent } from '../types-XjIh933x.js';
|
|
4
4
|
import '../zod-schema-C7F4clpm.js';
|
|
5
5
|
import 'zod';
|
|
6
6
|
|
|
@@ -17,6 +17,7 @@ declare class CompletionRequestBuilder<M extends CompletionModel = CompletionMod
|
|
|
17
17
|
private history;
|
|
18
18
|
private docs;
|
|
19
19
|
private toolDefs;
|
|
20
|
+
private providerToolDefs;
|
|
20
21
|
private temp;
|
|
21
22
|
private maxTokenCount;
|
|
22
23
|
private choice;
|
|
@@ -27,7 +28,7 @@ declare class CompletionRequestBuilder<M extends CompletionModel = CompletionMod
|
|
|
27
28
|
instructions(instructions: string | undefined): this;
|
|
28
29
|
messages(messages: Message[]): this;
|
|
29
30
|
documents(documents: Document[]): this;
|
|
30
|
-
tools(tools:
|
|
31
|
+
tools(tools: CompletionTool[]): this;
|
|
31
32
|
temperature(temperature: number | undefined): this;
|
|
32
33
|
maxTokens(maxTokens: number | undefined): this;
|
|
33
34
|
toolChoice(toolChoice: ToolChoice | undefined): this;
|
|
@@ -38,4 +39,4 @@ declare class CompletionRequestBuilder<M extends CompletionModel = CompletionMod
|
|
|
38
39
|
private buildInstructions;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
export { CompletionModel, CompletionRequest, CompletionRequestBuilder, CompletionResponse, Document, JsonObject, JsonValue, Message, ToolChoice,
|
|
42
|
+
export { CompletionModel, CompletionRequest, CompletionRequestBuilder, CompletionResponse, CompletionTool, Document, JsonObject, JsonValue, Message, ToolChoice, formatDocument, normalizeDocuments };
|
package/dist/completion/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
formatDocument,
|
|
7
7
|
isStreamingCompletionModel,
|
|
8
8
|
normalizeDocuments
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-GCED5ZNM.js";
|
|
10
10
|
import {
|
|
11
11
|
AssistantContent,
|
|
12
12
|
CompletionCapabilityError,
|
|
@@ -17,11 +17,12 @@ import {
|
|
|
17
17
|
assertCompletionRequestSupported,
|
|
18
18
|
getAssistantGenerationMetadata,
|
|
19
19
|
isJsonValue,
|
|
20
|
+
isProviderTool,
|
|
20
21
|
isToolResultContentArray,
|
|
21
22
|
reasoningDisplayText,
|
|
22
23
|
serializeToolResultOutput,
|
|
23
24
|
textFromAssistantContent
|
|
24
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-PJDL5UT2.js";
|
|
25
26
|
import "../chunk-WQKHFADH.js";
|
|
26
27
|
export {
|
|
27
28
|
AssistantContent,
|
|
@@ -38,6 +39,7 @@ export {
|
|
|
38
39
|
formatDocument,
|
|
39
40
|
getAssistantGenerationMetadata,
|
|
40
41
|
isJsonValue,
|
|
42
|
+
isProviderTool,
|
|
41
43
|
isStreamingCompletionModel,
|
|
42
44
|
isToolResultContentArray,
|
|
43
45
|
normalizeDocuments,
|
package/dist/evals/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { A as Agent } from '../agent-
|
|
2
|
-
import {
|
|
3
|
-
import { P as PromptResponse } from '../index-
|
|
1
|
+
import { A as Agent } from '../agent-Cg0UigNK.js';
|
|
2
|
+
import { i as JsonValue, M as Message, C as CompletionModel } from '../types-XjIh933x.js';
|
|
3
|
+
import { P as PromptResponse } from '../index-XTUEMWhU.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-
|
|
8
|
-
import '../types-
|
|
9
|
-
import '../tool-
|
|
10
|
-
import '../middleware-
|
|
11
|
-
import '../types-
|
|
7
|
+
import '../types-BCA8p0sb.js';
|
|
8
|
+
import '../types-CBmhLT_r.js';
|
|
9
|
+
import '../tool-Dhwg__1L.js';
|
|
10
|
+
import '../middleware-Cp0tm6zE.js';
|
|
11
|
+
import '../types-DMGvEFRf.js';
|
|
12
12
|
import 'zod';
|
|
13
13
|
|
|
14
14
|
type EvalOutcome<Score = unknown> = {
|
package/dist/evals/index.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ExtractorBuilder
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-54S4I3SX.js";
|
|
4
|
+
import "../chunk-RWAOHGRL.js";
|
|
5
|
+
import "../chunk-BQCTJSNL.js";
|
|
6
|
+
import "../chunk-OPAEENGD.js";
|
|
7
7
|
import "../chunk-YK4WAAS4.js";
|
|
8
8
|
import "../chunk-XUUY2L2D.js";
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-SWUIBS4N.js";
|
|
10
|
+
import "../chunk-F3C5653H.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";
|
|
16
13
|
import {
|
|
17
14
|
cosineSimilarity,
|
|
18
15
|
embedText
|
|
@@ -20,6 +17,9 @@ import {
|
|
|
20
17
|
import {
|
|
21
18
|
mapWithConcurrency
|
|
22
19
|
} from "../chunk-OIMLU4SF.js";
|
|
20
|
+
import "../chunk-GCED5ZNM.js";
|
|
21
|
+
import "../chunk-PJDL5UT2.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-
|
|
1
|
+
import { A as Agent } from '../agent-Cg0UigNK.js';
|
|
2
2
|
import { Z as ZodSchema } from '../zod-schema-C7F4clpm.js';
|
|
3
|
-
import { U as Usage, M as Message, C as CompletionModel,
|
|
3
|
+
import { U as Usage, M as Message, C as CompletionModel, i as JsonValue, z as ToolChoice } from '../types-XjIh933x.js';
|
|
4
4
|
import '../guardrails/index.js';
|
|
5
|
-
import '../types-
|
|
6
|
-
import '../types-
|
|
7
|
-
import '../index-
|
|
8
|
-
import '../tool-
|
|
9
|
-
import '../middleware-
|
|
5
|
+
import '../types-BCA8p0sb.js';
|
|
6
|
+
import '../types-CBmhLT_r.js';
|
|
7
|
+
import '../index-XTUEMWhU.js';
|
|
8
|
+
import '../tool-Dhwg__1L.js';
|
|
9
|
+
import '../middleware-Cp0tm6zE.js';
|
|
10
10
|
import '../types-DHHZztGO.js';
|
|
11
|
-
import '../types-
|
|
11
|
+
import '../types-DMGvEFRf.js';
|
|
12
12
|
import 'zod';
|
|
13
13
|
|
|
14
14
|
type ExtractionResponse<T> = {
|
package/dist/extractor/index.js
CHANGED
|
@@ -2,21 +2,21 @@ import {
|
|
|
2
2
|
ExtractionError,
|
|
3
3
|
Extractor,
|
|
4
4
|
ExtractorBuilder
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-54S4I3SX.js";
|
|
6
|
+
import "../chunk-RWAOHGRL.js";
|
|
7
|
+
import "../chunk-BQCTJSNL.js";
|
|
8
|
+
import "../chunk-OPAEENGD.js";
|
|
9
9
|
import "../chunk-YK4WAAS4.js";
|
|
10
10
|
import "../chunk-XUUY2L2D.js";
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
11
|
+
import "../chunk-SWUIBS4N.js";
|
|
12
|
+
import "../chunk-F3C5653H.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";
|
|
18
15
|
import "../chunk-YBBD4HZ3.js";
|
|
19
16
|
import "../chunk-OIMLU4SF.js";
|
|
17
|
+
import "../chunk-GCED5ZNM.js";
|
|
18
|
+
import "../chunk-PJDL5UT2.js";
|
|
19
|
+
import "../chunk-WQKHFADH.js";
|
|
20
20
|
import "../chunk-CWUJUSOS.js";
|
|
21
21
|
export {
|
|
22
22
|
ExtractionError,
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -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-
|
|
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-
|
|
3
|
-
import '../types-
|
|
1
|
+
import { H as HookAction, P as PromptHook, T as ToolApprovalRequestOptions, a as ToolCallHookAction, R as RunControl, b as ToolCallControl } from '../types-BCA8p0sb.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-BCA8p0sb.js';
|
|
3
|
+
import '../types-XjIh933x.js';
|
|
4
4
|
|
|
5
5
|
declare function createHook<RawResponse = unknown>(hook: PromptHook<RawResponse>): PromptHook<RawResponse>;
|
|
6
6
|
declare function cancelPrompt(reason: string): HookAction;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { L as ReasoningContentType, l as ToolCall, f as CompletionSource, k as ProviderToolCall, U as Usage, M as Message, d as CompletionRequest, q as ToolResultContent, e as CompletionResponse, O as ToolCallArgumentsMode, J as JsonObject, E as CompletionModelCapabilities, n as ToolDefinition, i as JsonValue } from './types-XjIh933x.js';
|
|
2
2
|
import { GuardrailDecisionRecord } from './guardrails/index.js';
|
|
3
|
-
import { g as ToolCallStreamEvent } from './tool-
|
|
3
|
+
import { g as ToolCallStreamEvent } from './tool-Dhwg__1L.js';
|
|
4
4
|
|
|
5
5
|
type PromptResponse = {
|
|
6
6
|
output: string;
|
|
@@ -8,6 +8,8 @@ type PromptResponse = {
|
|
|
8
8
|
messages: Message[];
|
|
9
9
|
trace?: AgentTraceInfo | undefined;
|
|
10
10
|
guardrails?: GuardrailDecisionRecord[] | undefined;
|
|
11
|
+
sources?: CompletionSource[] | undefined;
|
|
12
|
+
providerToolCalls?: ProviderToolCall[] | undefined;
|
|
11
13
|
};
|
|
12
14
|
type AgentDeltaEvent = {
|
|
13
15
|
type: "text_delta";
|
|
@@ -21,6 +23,12 @@ type AgentDeltaEvent = {
|
|
|
21
23
|
} | {
|
|
22
24
|
type: "tool_call";
|
|
23
25
|
toolCall: ToolCall;
|
|
26
|
+
} | {
|
|
27
|
+
type: "source";
|
|
28
|
+
source: CompletionSource;
|
|
29
|
+
} | {
|
|
30
|
+
type: "provider_tool_call";
|
|
31
|
+
toolCall: ProviderToolCall;
|
|
24
32
|
};
|
|
25
33
|
type AgentErrorStreamEvent = {
|
|
26
34
|
type: "error";
|
|
@@ -46,6 +54,11 @@ type AgentChildStreamEventBase<RawResponse = unknown> = {
|
|
|
46
54
|
turn: number;
|
|
47
55
|
prompt: Message;
|
|
48
56
|
history: Message[];
|
|
57
|
+
} | {
|
|
58
|
+
type: "generation_start";
|
|
59
|
+
turn: number;
|
|
60
|
+
request: CompletionRequest;
|
|
61
|
+
modelInfo: AgentGenerationModelInfo;
|
|
49
62
|
} | {
|
|
50
63
|
type: "text_delta";
|
|
51
64
|
turn: number;
|
|
@@ -61,6 +74,14 @@ type AgentChildStreamEventBase<RawResponse = unknown> = {
|
|
|
61
74
|
type: "tool_call";
|
|
62
75
|
turn: number;
|
|
63
76
|
toolCall: ToolCall;
|
|
77
|
+
} | {
|
|
78
|
+
type: "source";
|
|
79
|
+
turn: number;
|
|
80
|
+
source: CompletionSource;
|
|
81
|
+
} | {
|
|
82
|
+
type: "provider_tool_call";
|
|
83
|
+
turn: number;
|
|
84
|
+
toolCall: ProviderToolCall;
|
|
64
85
|
} | {
|
|
65
86
|
type: "tool_result";
|
|
66
87
|
turn: number;
|
|
@@ -74,6 +95,7 @@ type AgentChildStreamEventBase<RawResponse = unknown> = {
|
|
|
74
95
|
type: "turn_end";
|
|
75
96
|
turn: number;
|
|
76
97
|
response: CompletionResponse<RawResponse>;
|
|
98
|
+
firstDeltaMs?: number | undefined;
|
|
77
99
|
} | {
|
|
78
100
|
type: "guardrail_decision";
|
|
79
101
|
turn?: number | undefined;
|
|
@@ -86,6 +108,8 @@ type AgentChildStreamEventBase<RawResponse = unknown> = {
|
|
|
86
108
|
messages: Message[];
|
|
87
109
|
trace?: AgentTraceInfo | undefined;
|
|
88
110
|
guardrails?: GuardrailDecisionRecord[] | undefined;
|
|
111
|
+
sources?: CompletionSource[] | undefined;
|
|
112
|
+
providerToolCalls?: ProviderToolCall[] | undefined;
|
|
89
113
|
} | AgentErrorStreamEvent;
|
|
90
114
|
type AgentChildStreamEventWithoutToolCallDeltas<RawResponse = unknown> = AgentChildStreamEventBase<RawResponse>;
|
|
91
115
|
type AgentChildStreamEvent<RawResponse = unknown> = AgentChildStreamEventBase<RawResponse> | AgentToolCallDeltaEvent;
|
|
@@ -117,6 +141,7 @@ type AgentTraceOptions = {
|
|
|
117
141
|
version?: string | undefined;
|
|
118
142
|
traceId?: string | undefined;
|
|
119
143
|
failOnObserverError?: boolean | undefined;
|
|
144
|
+
promptRef?: AgentRunPromptRef | undefined;
|
|
120
145
|
};
|
|
121
146
|
type AgentRunPromptRef = {
|
|
122
147
|
name: string;
|
|
@@ -136,21 +161,24 @@ type AgentRunEndArgs = {
|
|
|
136
161
|
output: string;
|
|
137
162
|
usage: Usage;
|
|
138
163
|
messages: Message[];
|
|
164
|
+
sources?: CompletionSource[] | undefined;
|
|
165
|
+
providerToolCalls?: ProviderToolCall[] | undefined;
|
|
139
166
|
};
|
|
140
167
|
type AgentRunErrorArgs = {
|
|
141
168
|
error: unknown;
|
|
142
169
|
usage: Usage;
|
|
143
170
|
messages: Message[];
|
|
144
171
|
};
|
|
172
|
+
type AgentGenerationModelInfo = {
|
|
173
|
+
provider: string;
|
|
174
|
+
defaultModel: string;
|
|
175
|
+
capabilities?: CompletionModelCapabilities | undefined;
|
|
176
|
+
};
|
|
145
177
|
type AgentGenerationStartArgs = {
|
|
146
178
|
turn: number;
|
|
147
179
|
request: CompletionRequest;
|
|
148
180
|
providerRequest?: JsonObject | undefined;
|
|
149
|
-
modelInfo?:
|
|
150
|
-
provider: string;
|
|
151
|
-
defaultModel: string;
|
|
152
|
-
capabilities?: CompletionModelCapabilities | undefined;
|
|
153
|
-
};
|
|
181
|
+
modelInfo?: AgentGenerationModelInfo | undefined;
|
|
154
182
|
};
|
|
155
183
|
type AgentGenerationEndArgs<RawResponse = unknown> = {
|
|
156
184
|
turn: number;
|
|
@@ -224,4 +252,4 @@ type ObserveOptions = {
|
|
|
224
252
|
};
|
|
225
253
|
declare function createObserver(observer: AgentObserver): AgentObserver;
|
|
226
254
|
|
|
227
|
-
export { type AgentChildStreamEvent as A, type
|
|
255
|
+
export { type AgentChildStreamEvent as A, type AgentToolObserver as B, type AgentToolStartArgs as C, type AgentToolStreamEventArgs as D, type AgentTraceInfo as E, createObserver as F, 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 AgentGenerationModelInfo as o, type AgentGenerationObserver as p, type AgentGenerationStartArgs as q, type AgentGenerationUpdateArgs as r, type AgentRunEndArgs as s, type AgentRunErrorArgs as t, type AgentRunEventArgs as u, type AgentRunObserver as v, type AgentRunPromptRef as w, type AgentRunStartArgs as x, type AgentToolEndArgs as y, type AgentToolErrorArgs 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-
|
|
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,
|
|
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-D9IvOgx_.js';
|
|
3
|
+
export { A as AssistantContent, a as AssistantGenerationMetadata, b as AssistantMessage, c as AssistantMessageOptions, C as CompletionModel, d as CompletionRequest, e as CompletionResponse, f as CompletionSource, g as CompletionTool, D as Document, I as ImageContent, J as JsonObject, h as JsonPrimitive, i as JsonValue, M as Message, j as MessageOptions, P as ProviderTool, k as ProviderToolCall, S as SystemMessage, T as Text, l as ToolCall, m as ToolContent, n as ToolDefinition, o as ToolMessage, p as ToolResult, q as ToolResultContent, r as ToolResultMessageOptions, s as ToolResultOptions, U as Usage, t as UserContent, u as UserMessage, v as getAssistantGenerationMetadata, w as isProviderTool } from './types-XjIh933x.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-
|
|
6
|
+
export { M as MemoryConversation, a as MemoryConversationListOptions, b as MemoryConversationMessage, c as MemoryConversationSummary, d as MemoryInspector, e as MemoryStore } from './types-CBmhLT_r.js';
|
|
7
7
|
export { MaxTurnsError, PromptCancelledError, ToolApprovalRequiredError } from './request/index.js';
|
|
8
|
-
export { C as CompletionRetryContext, a as CompletionRetryOptions } from './agent-
|
|
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-
|
|
8
|
+
export { C as CompletionRetryContext, a as CompletionRetryOptions } from './agent-Cg0UigNK.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-XTUEMWhU.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-
|
|
13
|
-
export { C as CreateToolOptions, c as createThinkTool, a as createTool } from './think-tool-
|
|
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-
|
|
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-
|
|
12
|
+
export { S as SkillValidationError } from './types-fBv8mhvP.js';
|
|
13
|
+
export { C as CreateToolOptions, c as createThinkTool, a as createTool } from './think-tool-CpCKo8Q8.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-Dhwg__1L.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-Cp0tm6zE.js';
|
|
16
16
|
export { CreateUIAttachment, UIAttachment, UIError, UIMessage, UIMessagePart, UIMessageRole, UIStreamEvent, UIStreamRequest, coreMessagesToUIMessages, uiMessagesToCoreMessages } from './ui/index.js';
|
|
17
|
-
import './types-
|
|
18
|
-
import './types-
|
|
17
|
+
import './types-BCA8p0sb.js';
|
|
18
|
+
import './types-BBEf34DP.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-
|
|
22
|
+
import './types-DMGvEFRf.js';
|
|
23
23
|
import './types-DHHZztGO.js';
|
|
24
24
|
import 'zod';
|