@anvia/core 0.12.4 → 0.12.5
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 +11 -11
- package/dist/agent/index.js +6 -6
- package/dist/{agent-BBj3jvBi.d.ts → agent-BB9vVH6P.d.ts} +7 -7
- package/dist/audio-generation/index.d.ts +1 -1
- package/dist/{chunk-C7JLBS3F.js → chunk-5MUPA66B.js} +4 -4
- package/dist/{chunk-SRBW3LD7.js → chunk-FUJ3POKH.js} +3 -3
- package/dist/chunk-FUJ3POKH.js.map +1 -0
- package/dist/{chunk-OODGSEUU.js → chunk-JJ3JGL5D.js} +3 -3
- package/dist/{chunk-OQXRM5DO.js → chunk-N3I6HH2J.js} +4 -4
- package/dist/{chunk-LKLKEECY.js → chunk-PHCPUMAV.js} +33 -13
- package/dist/chunk-PHCPUMAV.js.map +1 -0
- package/dist/{chunk-5LFGEMIW.js → chunk-QVFOCNF6.js} +21 -4
- package/dist/chunk-QVFOCNF6.js.map +1 -0
- package/dist/{chunk-ZHIZZWBJ.js → chunk-TD6A4RYQ.js} +5 -5
- package/dist/{chunk-YVQBC3SJ.js → chunk-YZLOFKTT.js} +2 -2
- package/dist/completion/index.d.ts +3 -3
- package/dist/completion/index.js +2 -2
- package/dist/{create-completion-Y6YsYbQB.d.ts → create-completion-CC8-Ep3w.d.ts} +1 -1
- package/dist/evals/index.d.ts +8 -8
- package/dist/evals/index.js +7 -7
- package/dist/extractor/index.d.ts +8 -8
- package/dist/extractor/index.js +7 -7
- 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-Oucb3Ljj.d.ts → index-CM-V4LS3.d.ts} +2 -2
- package/dist/index.d.ts +12 -12
- package/dist/index.js +7 -7
- package/dist/internal/agent.d.ts +8 -8
- package/dist/internal/agent.js +5 -5
- 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-ByyL6Rj0.d.ts → middleware-i-jLsLom.d.ts} +3 -3
- package/dist/observability/index.d.ts +3 -3
- package/dist/pipeline/index.d.ts +8 -8
- package/dist/request/index.d.ts +8 -8
- package/dist/request/index.js +4 -4
- package/dist/skills/index.d.ts +4 -4
- package/dist/skills/index.js +2 -2
- package/dist/{think-tool-B065hm73.d.ts → think-tool-BKDCOJh5.d.ts} +1 -1
- package/dist/tool/index.d.ts +5 -5
- package/dist/tool/index.js +2 -2
- package/dist/{tool-B8K543oQ.d.ts → tool-f2stpvUP.d.ts} +1 -1
- package/dist/transcription/index.d.ts +1 -1
- package/dist/{types-7F_IKQQW.d.ts → types-5JgWDgaM.d.ts} +2 -2
- package/dist/{types-q9G7Bvwl.d.ts → types-C15r7N_4.d.ts} +7 -4
- package/dist/{types-CGML74sE.d.ts → types-Dh7gfoGw.d.ts} +1 -1
- package/dist/{types-Pl4PFQWL.d.ts → types-DmvXANwl.d.ts} +1 -1
- package/dist/{types-BzUuhjKr.d.ts → types-b6fOVoW1.d.ts} +1 -1
- package/dist/{types-CqG6d7Ce.d.ts → types-bNDxj4Tt.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/package.json +1 -1
- package/dist/chunk-5LFGEMIW.js.map +0 -1
- package/dist/chunk-LKLKEECY.js.map +0 -1
- package/dist/chunk-SRBW3LD7.js.map +0 -1
- /package/dist/{chunk-C7JLBS3F.js.map → chunk-5MUPA66B.js.map} +0 -0
- /package/dist/{chunk-OODGSEUU.js.map → chunk-JJ3JGL5D.js.map} +0 -0
- /package/dist/{chunk-OQXRM5DO.js.map → chunk-N3I6HH2J.js.map} +0 -0
- /package/dist/{chunk-ZHIZZWBJ.js.map → chunk-TD6A4RYQ.js.map} +0 -0
- /package/dist/{chunk-YVQBC3SJ.js.map → chunk-YZLOFKTT.js.map} +0 -0
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { D as DynamicContextOptions, a as DynamicToolOptions, b as AgentEventStore, c as AgentEventStoreOptions, A as Agent } from '../agent-
|
|
2
|
-
export { d as AgentEventAppendInput, e as AgentEventRecord, f as AgentEventStoreInclude, g as AgentSession, h as AgentToolOptions } from '../agent-
|
|
1
|
+
import { D as DynamicContextOptions, a as DynamicToolOptions, b as AgentEventStore, c as AgentEventStoreOptions, A as Agent } from '../agent-BB9vVH6P.js';
|
|
2
|
+
export { d as AgentEventAppendInput, e as AgentEventRecord, f as AgentEventStoreInclude, g as AgentSession, h as AgentToolOptions } from '../agent-BB9vVH6P.js';
|
|
3
3
|
import { Z as ZodSchema } from '../zod-schema-C7F4clpm.js';
|
|
4
|
-
import { C as CompletionModel, e as JsonValue, n as ToolChoice } from '../types-
|
|
4
|
+
import { C as CompletionModel, e as JsonValue, n as ToolChoice } from '../types-C15r7N_4.js';
|
|
5
5
|
import { GuardrailPolicyInput } from '../guardrails/index.js';
|
|
6
|
-
import { P as PromptHook } from '../types-
|
|
7
|
-
import { a as McpServer } from '../types-
|
|
8
|
-
import { M as MemoryStore, a as MemoryOptions } from '../types-
|
|
9
|
-
import { b as AgentObserver, O as ObserveOptions } from '../index-
|
|
10
|
-
import { a as SkillSet } from '../types-
|
|
11
|
-
import { k as ToolSearchDocument, l as ToolSet, A as AgentMiddleware, e as ToolMiddleware } from '../middleware-
|
|
12
|
-
import { A as AnyTool, e as ToolApprovalsOptions } from '../tool-
|
|
13
|
-
import { a as VectorSearchIndex } from '../types-
|
|
6
|
+
import { P as PromptHook } from '../types-Dh7gfoGw.js';
|
|
7
|
+
import { a as McpServer } from '../types-5JgWDgaM.js';
|
|
8
|
+
import { M as MemoryStore, a as MemoryOptions } from '../types-bNDxj4Tt.js';
|
|
9
|
+
import { b as AgentObserver, O as ObserveOptions } from '../index-CM-V4LS3.js';
|
|
10
|
+
import { a as SkillSet } from '../types-b6fOVoW1.js';
|
|
11
|
+
import { k as ToolSearchDocument, l as ToolSet, A as AgentMiddleware, e as ToolMiddleware } from '../middleware-i-jLsLom.js';
|
|
12
|
+
import { A as AnyTool, e as ToolApprovalsOptions } from '../tool-f2stpvUP.js';
|
|
13
|
+
import { a as VectorSearchIndex } from '../types-DmvXANwl.js';
|
|
14
14
|
import 'zod';
|
|
15
15
|
import '@modelcontextprotocol/sdk/client/sse.js';
|
|
16
16
|
import '@modelcontextprotocol/sdk/client/stdio.js';
|
package/dist/agent/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentBuilder
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-JJ3JGL5D.js";
|
|
4
|
+
import "../chunk-N3I6HH2J.js";
|
|
5
|
+
import "../chunk-5MUPA66B.js";
|
|
6
6
|
import "../chunk-YK4WAAS4.js";
|
|
7
7
|
import "../chunk-XUUY2L2D.js";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-YZLOFKTT.js";
|
|
9
9
|
import "../chunk-QKA6OQTH.js";
|
|
10
10
|
import "../chunk-NPZDYOE6.js";
|
|
11
11
|
import "../chunk-MMHG7WAM.js";
|
|
12
12
|
import "../chunk-M6RPFHG7.js";
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-
|
|
13
|
+
import "../chunk-FUJ3POKH.js";
|
|
14
|
+
import "../chunk-QVFOCNF6.js";
|
|
15
15
|
import "../chunk-WQKHFADH.js";
|
|
16
16
|
import "../chunk-JS5MGVNM.js";
|
|
17
17
|
import "../chunk-OIMLU4SF.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { C as CompletionModel, M as Message, D as Document, e as JsonValue, n as ToolChoice, J as JsonObject } from './types-
|
|
1
|
+
import { C as CompletionModel, M as Message, D as Document, e as JsonValue, n as ToolChoice, J as JsonObject } from './types-C15r7N_4.js';
|
|
2
2
|
import { GuardrailPolicyInput, GuardrailPolicy } from './guardrails/index.js';
|
|
3
|
-
import { P as PromptHook } from './types-
|
|
4
|
-
import { c as MemoryContext, e as MemoryRegistration, S as SessionOptions } from './types-
|
|
5
|
-
import { c as AgentTraceOptions, P as PromptResponse, a as AgentStreamEvent, d as AgentObserverRegistration } from './index-
|
|
6
|
-
import { e as ToolApprovalsOptions, T as Tool, A as AnyTool, f as ToolCallContext, N as NormalizedToolOutput } from './tool-
|
|
7
|
-
import { A as AgentMiddleware, e as ToolMiddleware, k as ToolSearchDocument, l as ToolSet } from './middleware-
|
|
8
|
-
import { V as VectorFilter, c as VectorSearchResult, a as VectorSearchIndex } from './types-
|
|
3
|
+
import { P as PromptHook } from './types-Dh7gfoGw.js';
|
|
4
|
+
import { c as MemoryContext, e as MemoryRegistration, S as SessionOptions } from './types-bNDxj4Tt.js';
|
|
5
|
+
import { c as AgentTraceOptions, P as PromptResponse, a as AgentStreamEvent, d as AgentObserverRegistration } from './index-CM-V4LS3.js';
|
|
6
|
+
import { e as ToolApprovalsOptions, T as Tool, A as AnyTool, f as ToolCallContext, N as NormalizedToolOutput } from './tool-f2stpvUP.js';
|
|
7
|
+
import { A as AgentMiddleware, e as ToolMiddleware, k as ToolSearchDocument, l as ToolSet } from './middleware-i-jLsLom.js';
|
|
8
|
+
import { V as VectorFilter, c as VectorSearchResult, a as VectorSearchIndex } from './types-DmvXANwl.js';
|
|
9
9
|
|
|
10
10
|
declare class PromptRequest<M extends CompletionModel = CompletionModel> {
|
|
11
11
|
private readonly agent;
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
parseToolArgs,
|
|
6
6
|
toolResultContentToText
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-YZLOFKTT.js";
|
|
8
8
|
import {
|
|
9
9
|
runControl,
|
|
10
10
|
toolCallControl
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
CompletionRequestBuilder,
|
|
17
17
|
isStreamingCompletionModel
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-FUJ3POKH.js";
|
|
19
19
|
import {
|
|
20
20
|
AssistantContent,
|
|
21
21
|
Message,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
Usage,
|
|
24
24
|
assertCompletionRequestSupported,
|
|
25
25
|
textFromAssistantContent
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-QVFOCNF6.js";
|
|
27
27
|
import {
|
|
28
28
|
mapWithConcurrency
|
|
29
29
|
} from "./chunk-OIMLU4SF.js";
|
|
@@ -2100,4 +2100,4 @@ export {
|
|
|
2100
2100
|
extractRagText,
|
|
2101
2101
|
PromptRequest
|
|
2102
2102
|
};
|
|
2103
|
-
//# sourceMappingURL=chunk-
|
|
2103
|
+
//# sourceMappingURL=chunk-5MUPA66B.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
Message,
|
|
3
3
|
assertCompletionRequestSupported,
|
|
4
4
|
textFromAssistantContent
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-QVFOCNF6.js";
|
|
6
6
|
import {
|
|
7
7
|
toProviderJsonSchema
|
|
8
8
|
} from "./chunk-WQKHFADH.js";
|
|
@@ -149,7 +149,7 @@ function isAssistantContent(value) {
|
|
|
149
149
|
return false;
|
|
150
150
|
}
|
|
151
151
|
function isToolContent(value) {
|
|
152
|
-
return isRecord(value) && value.type === "tool_result" && typeof value.id === "string" && (value.callId === void 0 || typeof value.callId === "string") && Array.isArray(value.content) && value.content.every(isToolResultContent);
|
|
152
|
+
return isRecord(value) && value.type === "tool_result" && typeof value.id === "string" && (value.callId === void 0 || typeof value.callId === "string") && (value.toolName === void 0 || typeof value.toolName === "string") && Array.isArray(value.content) && value.content.every(isToolResultContent);
|
|
153
153
|
}
|
|
154
154
|
function isToolResultContent(value) {
|
|
155
155
|
if (!isRecord(value)) {
|
|
@@ -335,4 +335,4 @@ export {
|
|
|
335
335
|
formatDocument,
|
|
336
336
|
CompletionRequestBuilder
|
|
337
337
|
};
|
|
338
|
-
//# sourceMappingURL=chunk-
|
|
338
|
+
//# sourceMappingURL=chunk-FUJ3POKH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/completion/create-completion.ts","../src/completion/documents.ts","../src/completion/request.ts"],"sourcesContent":["import { toProviderJsonSchema, type ZodSchema } from \"../schema/zod-schema\";\nimport type {\n AssistantContent,\n CompletionModel,\n CompletionRequest,\n CompletionResponse,\n CompletionStreamEvent,\n Document,\n JsonObject,\n JsonValue,\n Message as MessageType,\n StreamingCompletionModel,\n ToolChoice,\n ToolDefinition,\n Usage,\n} from \"./types\";\nimport { assertCompletionRequestSupported, Message, textFromAssistantContent } from \"./types\";\n\nexport type CreateCompletionInput = string | MessageType | MessageType[];\n\nexport type CreateCompletionBaseOptions = {\n input?: CreateCompletionInput | undefined;\n messages?: MessageType[] | undefined;\n instructions?: string | undefined;\n documents?: Document[] | undefined;\n tools?: ToolDefinition[] | undefined;\n temperature?: number | undefined;\n maxTokens?: number | undefined;\n toolChoice?: ToolChoice | undefined;\n outputSchema?: JsonObject | undefined;\n params?: JsonValue | undefined;\n};\n\nexport type CreateCompletionOptions = CreateCompletionBaseOptions;\n\nexport type CreateCompletionStreamOptions = CreateCompletionBaseOptions;\n\nexport type CreateParsedCompletionOptions<T> = Omit<CreateCompletionBaseOptions, \"outputSchema\"> & {\n schema: ZodSchema<T>;\n};\n\nexport type CreateCompletionResult<RawResponse = unknown> = {\n text: string;\n content: AssistantContent[];\n usage: Usage;\n response: CompletionResponse<RawResponse>;\n};\n\nexport type CreateParsedCompletionResult<\n T,\n RawResponse = unknown,\n> = CreateCompletionResult<RawResponse> & {\n data: T;\n};\n\ntype RawResponseOf<Model> =\n Model extends CompletionModel<infer RawResponse, infer _ModelName> ? RawResponse : unknown;\n\nexport function createCompletion<Model extends CompletionModel>(\n model: Model,\n options: CreateCompletionOptions,\n): Promise<CreateCompletionResult<RawResponseOf<Model>>> {\n return sendCompletion(model, options);\n}\n\nexport function createCompletionStream<Model extends StreamingCompletionModel>(\n model: Model,\n options: CreateCompletionStreamOptions,\n): AsyncIterable<CompletionStreamEvent<RawResponseOf<Model>>> {\n const request = toCompletionRequest(options);\n if (!isStreamingCompletionModel(model) || !model.capabilities.streaming) {\n throw new Error(\"This completion model does not support streaming\");\n }\n assertCompletionRequestSupported(model, request, { streaming: true });\n return model.streamCompletion(request) as AsyncIterable<\n CompletionStreamEvent<RawResponseOf<Model>>\n >;\n}\n\nexport async function createParsedCompletion<T, Model extends CompletionModel>(\n model: Model,\n options: CreateParsedCompletionOptions<T>,\n): Promise<CreateParsedCompletionResult<T, RawResponseOf<Model>>> {\n const { schema, ...completionOptions } = options;\n const request = toCompletionRequest(\n {\n ...completionOptions,\n outputSchema: toProviderJsonSchema(schema),\n },\n \"createParsedCompletion\",\n );\n assertCompletionRequestSupported(model, request);\n const response = (await model.completion(request)) as CompletionResponse<RawResponseOf<Model>>;\n const text = textFromAssistantContent(response.choice);\n return {\n data: parseCompletionData(text, schema),\n text,\n content: response.choice,\n usage: response.usage,\n response,\n };\n}\n\nasync function sendCompletion<Model extends CompletionModel>(\n model: Model,\n options: CreateCompletionOptions,\n): Promise<CreateCompletionResult<RawResponseOf<Model>>> {\n const request = toCompletionRequest(options);\n assertCompletionRequestSupported(model, request);\n const response = (await model.completion(request)) as CompletionResponse<RawResponseOf<Model>>;\n return {\n text: textFromAssistantContent(response.choice),\n content: response.choice,\n usage: response.usage,\n response,\n };\n}\n\nfunction toCompletionRequest(\n options: CreateCompletionBaseOptions,\n helperName = \"createCompletion\",\n): CompletionRequest {\n const chatHistory = [\n ...messagesFromMessages(options.messages),\n ...messagesFromInput(options.input),\n ];\n\n if (chatHistory.length === 0) {\n throw new Error(`${helperName} requires input or messages.`);\n }\n\n const request: CompletionRequest = {\n chatHistory,\n documents: [...(options.documents ?? [])],\n tools: [...(options.tools ?? [])],\n };\n\n if (options.instructions !== undefined && options.instructions.length > 0) {\n request.instructions = options.instructions;\n }\n if (options.temperature !== undefined) request.temperature = options.temperature;\n if (options.maxTokens !== undefined) request.maxTokens = options.maxTokens;\n if (options.toolChoice !== undefined) request.toolChoice = options.toolChoice;\n if (options.outputSchema !== undefined) request.outputSchema = options.outputSchema;\n if (options.params !== undefined) request.additionalParams = options.params;\n\n return request;\n}\n\nfunction messagesFromInput(input: CreateCompletionInput | undefined): MessageType[] {\n if (input === undefined) {\n return [];\n }\n if (typeof input === \"string\") {\n return [Message.user(input)];\n }\n if (Array.isArray(input)) {\n return normalizeMessageArray(input, \"input\");\n }\n if (!isCoreMessage(input)) {\n throw new TypeError(\"input must be a string, Message, or Message[].\");\n }\n return [input];\n}\n\nfunction messagesFromMessages(messages: MessageType[] | undefined): MessageType[] {\n return messages === undefined ? [] : normalizeMessageArray(messages, \"messages\");\n}\n\nfunction normalizeMessageArray(\n messages: MessageType[],\n fieldName: \"input\" | \"messages\",\n): MessageType[] {\n if (!messages.every(isCoreMessage)) {\n throw new TypeError(`${fieldName} must contain only Message values.`);\n }\n\n return [...messages];\n}\n\nfunction isCoreMessage(value: unknown): value is MessageType {\n if (!isRecord(value)) {\n return false;\n }\n\n if (value.role === \"system\") {\n return typeof value.content === \"string\";\n }\n\n if (value.role === \"user\") {\n return Array.isArray(value.content) && value.content.every(isUserContent);\n }\n\n if (value.role === \"assistant\") {\n return (\n (value.id === undefined || typeof value.id === \"string\") &&\n Array.isArray(value.content) &&\n value.content.every(isAssistantContent)\n );\n }\n\n if (value.role === \"tool\") {\n return Array.isArray(value.content) && value.content.every(isToolContent);\n }\n\n return false;\n}\n\nfunction isUserContent(value: unknown): boolean {\n if (!isRecord(value)) {\n return false;\n }\n\n if (value.type === \"text\") {\n return typeof value.text === \"string\";\n }\n\n if (value.type === \"image\") {\n return isImageContent(value);\n }\n\n if (value.type === \"document\") {\n return isDocumentContent(value);\n }\n\n return false;\n}\n\nfunction isAssistantContent(value: unknown): boolean {\n if (!isRecord(value)) {\n return false;\n }\n\n if (value.type === \"text\") {\n return typeof value.text === \"string\";\n }\n\n if (value.type === \"reasoning\") {\n return (\n typeof value.text === \"string\" &&\n (value.id === undefined || typeof value.id === \"string\") &&\n (value.content === undefined || Array.isArray(value.content))\n );\n }\n\n if (value.type === \"tool_call\") {\n return (\n typeof value.id === \"string\" &&\n (value.callId === undefined || typeof value.callId === \"string\") &&\n isRecord(value.function) &&\n typeof value.function.name === \"string\" &&\n \"arguments\" in value.function\n );\n }\n\n if (value.type === \"image\") {\n return isImageContent(value);\n }\n\n return false;\n}\n\nfunction isToolContent(value: unknown): boolean {\n return (\n isRecord(value) &&\n value.type === \"tool_result\" &&\n typeof value.id === \"string\" &&\n (value.callId === undefined || typeof value.callId === \"string\") &&\n (value.toolName === undefined || typeof value.toolName === \"string\") &&\n Array.isArray(value.content) &&\n value.content.every(isToolResultContent)\n );\n}\n\nfunction isToolResultContent(value: unknown): boolean {\n if (!isRecord(value)) {\n return false;\n }\n\n if (value.type === \"text\") {\n return typeof value.text === \"string\";\n }\n\n if (value.type === \"image\") {\n return (\n typeof value.data === \"string\" &&\n (value.mediaType === undefined || typeof value.mediaType === \"string\")\n );\n }\n\n return false;\n}\n\nfunction isImageContent(value: Record<string, unknown>): boolean {\n if (!isRecord(value.source)) {\n return false;\n }\n\n if (value.source.type === \"url\") {\n return typeof value.source.url === \"string\";\n }\n\n if (value.source.type === \"base64\") {\n return typeof value.source.data === \"string\" && typeof value.source.mediaType === \"string\";\n }\n\n return false;\n}\n\nfunction isDocumentContent(value: Record<string, unknown>): boolean {\n if (!isRecord(value.source)) {\n return false;\n }\n\n if (value.source.type === \"url\") {\n return typeof value.source.url === \"string\" && typeof value.source.mediaType === \"string\";\n }\n\n if (value.source.type === \"base64\") {\n return typeof value.source.data === \"string\" && typeof value.source.mediaType === \"string\";\n }\n\n if (value.source.type === \"text\") {\n return (\n typeof value.source.text === \"string\" &&\n (value.source.mediaType === undefined || typeof value.source.mediaType === \"string\")\n );\n }\n\n return false;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nexport function isStreamingCompletionModel(\n model: CompletionModel,\n): model is StreamingCompletionModel {\n return typeof (model as { streamCompletion?: unknown }).streamCompletion === \"function\";\n}\n\nfunction parseCompletionData<T>(text: string, schema: ZodSchema<T>): T {\n let json: unknown;\n try {\n json = JSON.parse(text);\n } catch (error) {\n throw new Error(\"createParsedCompletion expected the model response to be valid JSON.\", {\n cause: error,\n });\n }\n\n return schema.parse(json);\n}\n","import { type Document, Message, type Message as MessageType } from \"./types\";\n\nexport function normalizeDocuments(documents: Document[]): MessageType | undefined {\n if (documents.length === 0) {\n return undefined;\n }\n\n return Message.user(documents.map(formatDocument).join(\"\\n\"));\n}\n\nexport function formatDocument(document: Document): string {\n return `<file id: ${document.id}>\\n${formatDocumentBody(document)}\\n</file>\\n`;\n}\n\nfunction formatDocumentBody(document: Document): string {\n const metadata = formatMetadata(document.additionalProps);\n return metadata === undefined ? document.text : `${metadata}\\n${document.text}`;\n}\n\nfunction formatMetadata(additionalProps: Record<string, string> | undefined): string | undefined {\n if (additionalProps === undefined) {\n return undefined;\n }\n\n const entries = Object.entries(additionalProps).sort(([left], [right]) =>\n left.localeCompare(right),\n );\n if (entries.length === 0) {\n return undefined;\n }\n\n const metadata = entries.map(([key, value]) => `${key}: ${JSON.stringify(value)}`).join(\" \");\n return `<metadata ${metadata} />`;\n}\n","import type {\n CompletionModel,\n CompletionRequest,\n CompletionResponse,\n Document,\n JsonObject,\n JsonValue,\n Message as MessageType,\n ToolChoice,\n ToolDefinition,\n} from \"./types\";\nimport { assertCompletionRequestSupported } from \"./types\";\n\ntype ModelNameOf<M extends CompletionModel> =\n M extends CompletionModel<unknown, infer ModelName> ? ModelName : string;\n\ntype RawResponseOf<M extends CompletionModel> =\n M extends CompletionModel<infer RawResponse, infer _ModelName> ? RawResponse : unknown;\n\nexport class CompletionRequestBuilder<M extends CompletionModel = CompletionModel> {\n private requestModel: ModelNameOf<M> | undefined;\n private instructionBlocks: string[] = [];\n private history: MessageType[] = [];\n private docs: Document[] = [];\n private toolDefs: ToolDefinition[] = [];\n private temp: number | undefined;\n private maxTokenCount: number | undefined;\n private choice: ToolChoice | undefined;\n private params: JsonValue | undefined;\n private schema: JsonObject | undefined;\n\n constructor(\n private readonly model: M,\n private readonly promptMessage: MessageType,\n ) {}\n\n modelOverride(model: ModelNameOf<M> | undefined): this {\n this.requestModel = model;\n return this;\n }\n\n instructions(instructions: string | undefined): this {\n if (instructions !== undefined && instructions.length > 0) {\n this.instructionBlocks.push(instructions);\n }\n return this;\n }\n\n messages(messages: MessageType[]): this {\n this.history.push(...messages);\n return this;\n }\n\n documents(documents: Document[]): this {\n this.docs.push(...documents);\n return this;\n }\n\n tools(tools: ToolDefinition[]): this {\n this.toolDefs.push(...tools);\n return this;\n }\n\n temperature(temperature: number | undefined): this {\n this.temp = temperature;\n return this;\n }\n\n maxTokens(maxTokens: number | undefined): this {\n this.maxTokenCount = maxTokens;\n return this;\n }\n\n toolChoice(toolChoice: ToolChoice | undefined): this {\n this.choice = toolChoice;\n return this;\n }\n\n additionalParams(additionalParams: JsonValue | undefined): this {\n this.params = additionalParams;\n return this;\n }\n\n outputSchema(outputSchema: JsonObject | undefined): this {\n this.schema = outputSchema;\n return this;\n }\n\n build(): CompletionRequest<ModelNameOf<M>> {\n const instructions = this.buildInstructions();\n const request: CompletionRequest<ModelNameOf<M>> = {\n chatHistory: [...this.history, this.promptMessage],\n documents: [...this.docs],\n tools: [...this.toolDefs],\n };\n\n if (this.requestModel !== undefined) request.model = this.requestModel;\n if (instructions !== undefined) request.instructions = instructions;\n if (this.temp !== undefined) request.temperature = this.temp;\n if (this.maxTokenCount !== undefined) request.maxTokens = this.maxTokenCount;\n if (this.choice !== undefined) request.toolChoice = this.choice;\n if (this.params !== undefined) request.additionalParams = this.params;\n if (this.schema !== undefined) request.outputSchema = this.schema;\n\n return request;\n }\n\n async send(): Promise<CompletionResponse<RawResponseOf<M>>> {\n const request = this.build();\n assertCompletionRequestSupported(this.model, request);\n return this.model.completion(request) as Promise<CompletionResponse<RawResponseOf<M>>>;\n }\n\n private buildInstructions(): string | undefined {\n return this.instructionBlocks.length === 0 ? undefined : this.instructionBlocks.join(\"\\n\\n\");\n }\n}\n"],"mappings":";;;;;;;;;;AA0DO,SAAS,iBACd,OACA,SACuD;AACvD,SAAO,eAAe,OAAO,OAAO;AACtC;AAEO,SAAS,uBACd,OACA,SAC4D;AAC5D,QAAM,UAAU,oBAAoB,OAAO;AAC3C,MAAI,CAAC,2BAA2B,KAAK,KAAK,CAAC,MAAM,aAAa,WAAW;AACvE,UAAM,IAAI,MAAM,kDAAkD;AAAA,EACpE;AACA,mCAAiC,OAAO,SAAS,EAAE,WAAW,KAAK,CAAC;AACpE,SAAO,MAAM,iBAAiB,OAAO;AAGvC;AAEA,eAAsB,uBACpB,OACA,SACgE;AAChE,QAAM,EAAE,QAAQ,GAAG,kBAAkB,IAAI;AACzC,QAAM,UAAU;AAAA,IACd;AAAA,MACE,GAAG;AAAA,MACH,cAAc,qBAAqB,MAAM;AAAA,IAC3C;AAAA,IACA;AAAA,EACF;AACA,mCAAiC,OAAO,OAAO;AAC/C,QAAM,WAAY,MAAM,MAAM,WAAW,OAAO;AAChD,QAAM,OAAO,yBAAyB,SAAS,MAAM;AACrD,SAAO;AAAA,IACL,MAAM,oBAAoB,MAAM,MAAM;AAAA,IACtC;AAAA,IACA,SAAS,SAAS;AAAA,IAClB,OAAO,SAAS;AAAA,IAChB;AAAA,EACF;AACF;AAEA,eAAe,eACb,OACA,SACuD;AACvD,QAAM,UAAU,oBAAoB,OAAO;AAC3C,mCAAiC,OAAO,OAAO;AAC/C,QAAM,WAAY,MAAM,MAAM,WAAW,OAAO;AAChD,SAAO;AAAA,IACL,MAAM,yBAAyB,SAAS,MAAM;AAAA,IAC9C,SAAS,SAAS;AAAA,IAClB,OAAO,S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
2
|
Agent,
|
|
3
3
|
normalizeAgentId
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-N3I6HH2J.js";
|
|
5
5
|
import {
|
|
6
6
|
ToolSet
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-YZLOFKTT.js";
|
|
8
8
|
import {
|
|
9
9
|
resolveMemoryOptions
|
|
10
10
|
} from "./chunk-M6RPFHG7.js";
|
|
@@ -212,4 +212,4 @@ var AgentBuilder = class {
|
|
|
212
212
|
export {
|
|
213
213
|
AgentBuilder
|
|
214
214
|
};
|
|
215
|
-
//# sourceMappingURL=chunk-
|
|
215
|
+
//# sourceMappingURL=chunk-JJ3JGL5D.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PromptRequest
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5MUPA66B.js";
|
|
4
4
|
import {
|
|
5
5
|
isSkillTool
|
|
6
6
|
} from "./chunk-YK4WAAS4.js";
|
|
7
7
|
import {
|
|
8
8
|
ToolSet
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YZLOFKTT.js";
|
|
10
10
|
import {
|
|
11
11
|
createTool
|
|
12
12
|
} from "./chunk-QKA6OQTH.js";
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "./chunk-MMHG7WAM.js";
|
|
16
16
|
import {
|
|
17
17
|
isStreamingCompletionModel
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-FUJ3POKH.js";
|
|
19
19
|
|
|
20
20
|
// src/agent/agent.ts
|
|
21
21
|
import { z } from "zod";
|
|
@@ -204,4 +204,4 @@ export {
|
|
|
204
204
|
Agent,
|
|
205
205
|
AgentSession
|
|
206
206
|
};
|
|
207
|
-
//# sourceMappingURL=chunk-
|
|
207
|
+
//# sourceMappingURL=chunk-N3I6HH2J.js.map
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
UserContent,
|
|
6
6
|
reasoningDisplayText,
|
|
7
7
|
serializeToolResultOutput
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-QVFOCNF6.js";
|
|
9
9
|
|
|
10
10
|
// src/ui/messages.ts
|
|
11
11
|
function uiMessagesToCoreMessages(messages) {
|
|
@@ -65,11 +65,10 @@ function uiMessagesToCoreMessages(messages) {
|
|
|
65
65
|
);
|
|
66
66
|
if (part.state === "output-available") {
|
|
67
67
|
toolResults2.push(
|
|
68
|
-
ToolContent.toolResult(
|
|
69
|
-
part.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
)
|
|
68
|
+
ToolContent.toolResult(part.toolCallId, outputToToolResultContent(part.output), {
|
|
69
|
+
callId: part.callId,
|
|
70
|
+
toolName: part.toolName
|
|
71
|
+
})
|
|
73
72
|
);
|
|
74
73
|
}
|
|
75
74
|
}
|
|
@@ -88,11 +87,10 @@ function uiMessagesToCoreMessages(messages) {
|
|
|
88
87
|
continue;
|
|
89
88
|
}
|
|
90
89
|
toolResults.push(
|
|
91
|
-
ToolContent.toolResult(
|
|
92
|
-
part.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
)
|
|
90
|
+
ToolContent.toolResult(part.toolCallId, outputToToolResultContent(part.output), {
|
|
91
|
+
callId: part.callId,
|
|
92
|
+
toolName: part.toolName
|
|
93
|
+
})
|
|
96
94
|
);
|
|
97
95
|
}
|
|
98
96
|
if (toolResults.length > 0) {
|
|
@@ -103,6 +101,7 @@ function uiMessagesToCoreMessages(messages) {
|
|
|
103
101
|
}
|
|
104
102
|
function coreMessagesToUIMessages(messages) {
|
|
105
103
|
const uiMessages = [];
|
|
104
|
+
const toolNamesByCallKey = toolCallNameLookup(messages);
|
|
106
105
|
for (const message of messages) {
|
|
107
106
|
if (message.role === "system") {
|
|
108
107
|
uiMessages.push({
|
|
@@ -177,7 +176,7 @@ function coreMessagesToUIMessages(messages) {
|
|
|
177
176
|
const part = {
|
|
178
177
|
id: toolPartId(content.id),
|
|
179
178
|
type: "tool",
|
|
180
|
-
toolName:
|
|
179
|
+
toolName: toolNameForResult(content, toolNamesByCallKey),
|
|
181
180
|
toolCallId: content.id,
|
|
182
181
|
state: "output-available",
|
|
183
182
|
output: toolResultContentToJson(content.content)
|
|
@@ -191,6 +190,27 @@ function coreMessagesToUIMessages(messages) {
|
|
|
191
190
|
}
|
|
192
191
|
return uiMessages;
|
|
193
192
|
}
|
|
193
|
+
function toolCallNameLookup(messages) {
|
|
194
|
+
const toolNamesByCallKey = /* @__PURE__ */ new Map();
|
|
195
|
+
for (const message of messages) {
|
|
196
|
+
if (message.role !== "assistant") {
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
for (const content of message.content) {
|
|
200
|
+
if (content.type !== "tool_call") {
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
toolNamesByCallKey.set(content.id, content.function.name);
|
|
204
|
+
if (content.callId !== void 0) {
|
|
205
|
+
toolNamesByCallKey.set(content.callId, content.function.name);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return toolNamesByCallKey;
|
|
210
|
+
}
|
|
211
|
+
function toolNameForResult(content, toolNamesByCallKey) {
|
|
212
|
+
return content.toolName ?? toolNamesByCallKey.get(content.id) ?? (content.callId === void 0 ? void 0 : toolNamesByCallKey.get(content.callId)) ?? "tool";
|
|
213
|
+
}
|
|
194
214
|
function textFromUIParts(parts) {
|
|
195
215
|
return parts.flatMap((part) => part.type === "text" ? [part.text] : []).join("");
|
|
196
216
|
}
|
|
@@ -350,4 +370,4 @@ export {
|
|
|
350
370
|
uiMessagesToCoreMessages,
|
|
351
371
|
coreMessagesToUIMessages
|
|
352
372
|
};
|
|
353
|
-
//# sourceMappingURL=chunk-
|
|
373
|
+
//# sourceMappingURL=chunk-PHCPUMAV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ui/messages.ts"],"sourcesContent":["import {\n AssistantContent,\n type AssistantContent as AssistantContentType,\n type Message as CoreMessage,\n type DocumentContent,\n type ImageContent,\n type ImageDetail,\n type JsonValue,\n Message,\n reasoningDisplayText,\n serializeToolResultOutput,\n ToolContent,\n type ToolContent as ToolContentType,\n type ToolResultContent,\n UserContent,\n type UserContent as UserContentType,\n} from \"../completion/types\";\nimport type { UIAttachment, UIMessage, UIMessagePart } from \"./types\";\n\nexport function uiMessagesToCoreMessages(messages: UIMessage[]): CoreMessage[] {\n const coreMessages: CoreMessage[] = [];\n\n for (const message of messages) {\n const text = textFromUIParts(message.parts);\n\n if (message.role === \"system\") {\n if (text.length > 0) {\n coreMessages.push(Message.system(text));\n }\n continue;\n }\n\n if (message.role === \"user\") {\n const content: UserContentType[] = [];\n for (const part of message.parts) {\n if (part.type === \"text\") {\n content.push(UserContent.text(part.text));\n continue;\n }\n if (part.type === \"attachment\") {\n content.push(attachmentToUserContent(part.attachment));\n continue;\n }\n if (part.type === \"data\" && isUserContent(part.data)) {\n content.push(part.data);\n continue;\n }\n throw new TypeError(\n \"User UI messages can only be converted from text, attachment, or image/document data parts.\",\n );\n }\n if (content.length > 0) {\n coreMessages.push(Message.user(content));\n }\n continue;\n }\n\n if (message.role === \"assistant\") {\n const content: AssistantContentType[] = [];\n const toolResults: ToolContentType[] = [];\n for (const part of message.parts) {\n if (part.type === \"text\" && part.text.length > 0) {\n content.push(AssistantContent.text(part.text));\n continue;\n }\n if (part.type === \"reasoning\" && part.text.length > 0) {\n content.push(AssistantContent.reasoning(part.text, part.reasoningId));\n continue;\n }\n if (\n part.type === \"tool\" &&\n (part.state === \"input-streaming\" ||\n part.state === \"input-available\" ||\n part.state === \"output-available\")\n ) {\n content.push(\n AssistantContent.toolCall(\n part.toolCallId,\n part.toolName,\n part.input ?? {},\n part.callId,\n ),\n );\n if (part.state === \"output-available\") {\n toolResults.push(\n ToolContent.toolResult(part.toolCallId, outputToToolResultContent(part.output), {\n callId: part.callId,\n toolName: part.toolName,\n }),\n );\n }\n }\n }\n if (content.length > 0) {\n coreMessages.push(Message.assistant(content, message.id));\n }\n if (toolResults.length > 0) {\n coreMessages.push(Message.tool(toolResults));\n }\n continue;\n }\n\n const toolResults: ToolContentType[] = [];\n for (const part of message.parts) {\n if (part.type !== \"tool\" || part.state !== \"output-available\") {\n continue;\n }\n toolResults.push(\n ToolContent.toolResult(part.toolCallId, outputToToolResultContent(part.output), {\n callId: part.callId,\n toolName: part.toolName,\n }),\n );\n }\n if (toolResults.length > 0) {\n coreMessages.push(Message.tool(toolResults));\n }\n }\n\n return coreMessages;\n}\n\nexport function coreMessagesToUIMessages(messages: CoreMessage[]): UIMessage[] {\n const uiMessages: UIMessage[] = [];\n const toolNamesByCallKey = toolCallNameLookup(messages);\n\n for (const message of messages) {\n if (message.role === \"system\") {\n uiMessages.push({\n id: createId(\"msg\"),\n role: \"system\",\n parts: [{ id: createId(\"part\"), type: \"text\", text: message.content }],\n });\n continue;\n }\n\n if (message.role === \"user\") {\n const parts: UIMessagePart[] = [];\n for (const content of message.content) {\n if (content.type === \"text\") {\n parts.push({ id: createId(\"part\"), type: \"text\", text: content.text });\n } else {\n parts.push({\n id: createId(\"part\"),\n type: \"attachment\",\n attachment: userContentToAttachment(content),\n });\n }\n }\n uiMessages.push({ id: createId(\"msg\"), role: \"user\", parts });\n continue;\n }\n\n if (message.role === \"assistant\") {\n const parts: UIMessagePart[] = [];\n for (const content of message.content) {\n if (content.type === \"text\") {\n parts.push({ id: createId(\"part\"), type: \"text\", text: content.text });\n continue;\n }\n if (content.type === \"reasoning\") {\n const part: UIMessagePart = {\n id: createId(\"part\"),\n type: \"reasoning\",\n text: reasoningDisplayText(content),\n };\n if (content.id !== undefined) {\n part.reasoningId = content.id;\n }\n parts.push(part);\n continue;\n }\n if (content.type === \"tool_call\") {\n const part: UIMessagePart = {\n id: toolPartId(content.id),\n type: \"tool\",\n toolName: content.function.name,\n toolCallId: content.id,\n state: \"input-available\",\n input: content.function.arguments,\n };\n if (content.callId !== undefined) {\n part.callId = content.callId;\n }\n parts.push(part);\n continue;\n }\n parts.push({\n id: createId(\"part\"),\n type: \"data\",\n name: content.type,\n data: content as JsonValue,\n });\n }\n uiMessages.push({ id: message.id ?? createId(\"msg\"), role: \"assistant\", parts });\n continue;\n }\n\n const parts: UIMessagePart[] = [];\n for (const content of message.content) {\n const part: UIMessagePart = {\n id: toolPartId(content.id),\n type: \"tool\",\n toolName: toolNameForResult(content, toolNamesByCallKey),\n toolCallId: content.id,\n state: \"output-available\",\n output: toolResultContentToJson(content.content),\n };\n if (content.callId !== undefined) {\n part.callId = content.callId;\n }\n parts.push(part);\n }\n uiMessages.push({ id: createId(\"msg\"), role: \"tool\", parts });\n }\n\n return uiMessages;\n}\n\nfunction toolCallNameLookup(messages: CoreMessage[]): Map<string, string> {\n const toolNamesByCallKey = new Map<string, string>();\n\n for (const message of messages) {\n if (message.role !== \"assistant\") {\n continue;\n }\n for (const content of message.content) {\n if (content.type !== \"tool_call\") {\n continue;\n }\n toolNamesByCallKey.set(content.id, content.function.name);\n if (content.callId !== undefined) {\n toolNamesByCallKey.set(content.callId, content.function.name);\n }\n }\n }\n\n return toolNamesByCallKey;\n}\n\nfunction toolNameForResult(\n content: ToolContentType,\n toolNamesByCallKey: Map<string, string>,\n): string {\n return (\n content.toolName ??\n toolNamesByCallKey.get(content.id) ??\n (content.callId === undefined ? undefined : toolNamesByCallKey.get(content.callId)) ??\n \"tool\"\n );\n}\n\nexport function isUIMessage(value: unknown): value is UIMessage {\n return (\n isRecord(value) &&\n typeof value.id === \"string\" &&\n isUIMessageRole(value.role) &&\n Array.isArray(value.parts)\n );\n}\n\nexport function isUIMessageArray(value: unknown): value is UIMessage[] {\n return Array.isArray(value) && value.every(isUIMessage);\n}\n\nfunction textFromUIParts(parts: UIMessagePart[]): string {\n return parts.flatMap((part) => (part.type === \"text\" ? [part.text] : [])).join(\"\");\n}\n\nfunction outputToToolResultContent(output: JsonValue | undefined): ToolResultContent[] {\n return [{ type: \"text\", text: serializeToolResultOutput(output ?? null) }];\n}\n\nfunction attachmentToUserContent(attachment: UIAttachment): UserContentType {\n if (attachment.type === \"image\" || isImageFileAttachment(attachment)) {\n if (attachment.url !== undefined) {\n return UserContent.imageUrl(attachment.url, imageOptions(attachment));\n }\n if (attachment.data !== undefined && attachment.mediaType !== undefined) {\n return UserContent.imageBase64(\n attachment.data,\n attachment.mediaType,\n imageOptions(attachment),\n );\n }\n throw new TypeError(\"Image attachments require a url or base64 data with mediaType.\");\n }\n\n if (attachment.text !== undefined) {\n return {\n type: \"document\",\n source: {\n type: \"text\",\n text: attachment.text,\n ...(attachment.mediaType === undefined ? {} : { mediaType: attachment.mediaType }),\n ...(attachment.name === undefined ? {} : { filename: attachment.name }),\n },\n };\n }\n\n const mediaType = attachment.mediaType ?? \"application/octet-stream\";\n if (attachment.url !== undefined) {\n return UserContent.documentUrl(attachment.url, mediaType, documentOptions(attachment));\n }\n if (attachment.data !== undefined) {\n return UserContent.documentBase64(attachment.data, mediaType, documentOptions(attachment));\n }\n\n throw new TypeError(\"Document attachments require a url, base64 data, or text.\");\n}\n\nfunction userContentToAttachment(content: ImageContent | DocumentContent): UIAttachment {\n if (content.type === \"image\") {\n const attachment: UIAttachment = {\n id: createId(\"attachment\"),\n type: \"image\",\n ...(content.detail === undefined ? {} : { detail: content.detail }),\n };\n if (content.source.type === \"url\") {\n attachment.url = content.source.url;\n } else {\n attachment.data = content.source.data;\n attachment.mediaType = content.source.mediaType;\n }\n return attachment;\n }\n\n const attachment: UIAttachment = {\n id: createId(\"attachment\"),\n type: \"document\",\n };\n if (content.source.type === \"url\") {\n attachment.url = content.source.url;\n attachment.mediaType = content.source.mediaType;\n if (content.source.filename !== undefined) {\n attachment.name = content.source.filename;\n }\n } else if (content.source.type === \"base64\") {\n attachment.data = content.source.data;\n attachment.mediaType = content.source.mediaType;\n if (content.source.filename !== undefined) {\n attachment.name = content.source.filename;\n }\n } else {\n attachment.text = content.source.text;\n if (content.source.mediaType !== undefined) {\n attachment.mediaType = content.source.mediaType;\n }\n if (content.source.filename !== undefined) {\n attachment.name = content.source.filename;\n }\n }\n return attachment;\n}\n\nfunction isImageFileAttachment(attachment: UIAttachment): boolean {\n return attachment.type === \"file\" && attachment.mediaType?.startsWith(\"image/\") === true;\n}\n\nfunction imageOptions(attachment: UIAttachment): { detail?: ImageDetail } {\n return attachment.detail === undefined ? {} : { detail: attachment.detail };\n}\n\nfunction documentOptions(attachment: UIAttachment): { filename?: string } {\n return attachment.name === undefined ? {} : { filename: attachment.name };\n}\n\nfunction toolResultContentToJson(content: ToolResultContent[]): JsonValue {\n if (content.length === 1 && content[0]?.type === \"text\") {\n return content[0].text;\n }\n return content as JsonValue;\n}\n\nfunction isUserContent(value: unknown): value is UserContentType {\n if (!isRecord(value)) {\n return false;\n }\n\n if (value.type === \"text\") {\n return typeof value.text === \"string\";\n }\n\n if (value.type === \"image\") {\n return isImageContent(value);\n }\n\n if (value.type === \"document\") {\n return isDocumentContent(value);\n }\n\n return false;\n}\n\nfunction isImageContent(value: Record<string, unknown>): boolean {\n if (!isRecord(value.source)) {\n return false;\n }\n\n if (value.source.type === \"url\") {\n return typeof value.source.url === \"string\";\n }\n\n if (value.source.type === \"base64\") {\n return typeof value.source.data === \"string\" && typeof value.source.mediaType === \"string\";\n }\n\n return false;\n}\n\nfunction isDocumentContent(value: Record<string, unknown>): boolean {\n if (!isRecord(value.source)) {\n return false;\n }\n\n if (value.source.type === \"url\") {\n return typeof value.source.url === \"string\" && typeof value.source.mediaType === \"string\";\n }\n\n if (value.source.type === \"base64\") {\n return typeof value.source.data === \"string\" && typeof value.source.mediaType === \"string\";\n }\n\n if (value.source.type === \"text\") {\n return (\n typeof value.source.text === \"string\" &&\n (value.source.mediaType === undefined || typeof value.source.mediaType === \"string\")\n );\n }\n\n return false;\n}\n\nfunction toolPartId(toolCallId: string): string {\n return `tool_${toolCallId}`;\n}\n\nlet nextId = 0;\n\nfunction createId(prefix: string): string {\n const random = globalThis.crypto?.randomUUID?.();\n if (random !== undefined) {\n return `${prefix}_${random}`;\n }\n nextId += 1;\n return `${prefix}_${nextId.toString(36)}`;\n}\n\nfunction isUIMessageRole(value: unknown): value is UIMessage[\"role\"] {\n return value === \"system\" || value === \"user\" || value === \"assistant\" || value === \"tool\";\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n"],"mappings":";;;;;;;;;;AAmBO,SAAS,yBAAyB,UAAsC;AAC7E,QAAM,eAA8B,CAAC;AAErC,aAAW,WAAW,UAAU;AAC9B,UAAM,OAAO,gBAAgB,QAAQ,KAAK;AAE1C,QAAI,QAAQ,SAAS,UAAU;AAC7B,UAAI,KAAK,SAAS,GAAG;AACnB,qBAAa,KAAK,QAAQ,OAAO,IAAI,CAAC;AAAA,MACxC;AACA;AAAA,IACF;AAEA,QAAI,QAAQ,SAAS,QAAQ;AAC3B,YAAM,UAA6B,CAAC;AACpC,iBAAW,QAAQ,QAAQ,OAAO;AAChC,YAAI,KAAK,SAAS,QAAQ;AACxB,kBAAQ,KAAK,YAAY,KAAK,KAAK,IAAI,CAAC;AACxC;AAAA,QACF;AACA,YAAI,KAAK,SAAS,cAAc;AAC9B,kBAAQ,KAAK,wBAAwB,KAAK,UAAU,CAAC;AACrD;AAAA,QACF;AACA,YAAI,KAAK,SAAS,UAAU,cAAc,KAAK,IAAI,GAAG;AACpD,kBAAQ,KAAK,KAAK,IAAI;AACtB;AAAA,QACF;AACA,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AAAA,MACF;AACA,UAAI,QAAQ,SAAS,GAAG;AACtB,qBAAa,KAAK,QAAQ,KAAK,OAAO,CAAC;AAAA,MACzC;AACA;AAAA,IACF;AAEA,QAAI,QAAQ,SAAS,aAAa;AAChC,YAAM,UAAkC,CAAC;AACzC,YAAMA,eAAiC,CAAC;AACxC,iBAAW,QAAQ,QAAQ,OAAO;AAChC,YAAI,KAAK,SAAS,UAAU,KAAK,KAAK,SAAS,GAAG;AAChD,kBAAQ,KAAK,iBAAiB,K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A,EACrC;AAEA,MAAI,MAAM,OAAO,SAAS,UAAU;AAClC,WAAO,OAAO,MAAM,OAAO,SAAS,YAAY,OAAO,MAAM,OAAO,cAAc;AAAA,EACpF;AAEA,SAAO;AACT;AAEA,SAAS,kBAAkB,OAAyC;AAClE,MAAI,CAAC,SAAS,MAAM,MAAM,GAAG;AAC3B,WAAO;AAAA,EACT;AAEA,MAAI,MAAM,OAAO,SAAS,OAAO;AAC/B,WAAO,OAAO,MAAM,OAAO,QAAQ,YAAY,OAAO,MAAM,OAAO,cAAc;AAAA,EACnF;AAEA,MAAI,MAAM,OAAO,SAAS,UAAU;AAClC,WAAO,OAAO,MAAM,OAAO,SAAS,YAAY,OAAO,MAAM,OAAO,cAAc;AAAA,EACpF;AAEA,MAAI,MAAM,OAAO,SAAS,QAAQ;AAChC,WACE,OAAO,MAAM,OAAO,SAAS,aAC5B,MAAM,OAAO,cAAc,UAAa,OAAO,MAAM,OAAO,cAAc;AAAA,EAE/E;AAEA,SAAO;AACT;AAEA,SAAS,WAAW,YAA4B;AAC9C,SAAO,QAAQ,UAAU;AAC3B;AAEA,IAAI,SAAS;AAEb,SAAS,SAAS,QAAwB;AACxC,QAAM,SAAS,WAAW,QAAQ,aAAa;AAC/C,MAAI,WAAW,QAAW;AACxB,WAAO,GAAG,MAAM,IAAI,MAAM;AAAA,EAC5B;AACA,YAAU;AACV,SAAO,GAAG,MAAM,IAAI,OAAO,SAAS,EAAE,CAAC;AACzC;AAMA,SAAS,SAAS,OAAkD;AAClE,SAAO,OAAO,UAAU,YAAY,UAAU;AAChD;","names":["toolResults","parts","attachment"]}
|
|
@@ -37,11 +37,28 @@ var UserContent = {
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
var ToolContent = {
|
|
40
|
-
toolResult(id, content,
|
|
40
|
+
toolResult(id, content, callIdOrOptions, toolName) {
|
|
41
41
|
const normalized = typeof content === "string" ? [{ type: "text", text: content }] : content;
|
|
42
|
-
|
|
42
|
+
const options = normalizeToolResultOptions(callIdOrOptions, toolName);
|
|
43
|
+
const result = { type: "tool_result", id, content: normalized };
|
|
44
|
+
if (options.callId !== void 0) {
|
|
45
|
+
result.callId = options.callId;
|
|
46
|
+
}
|
|
47
|
+
if (options.toolName !== void 0) {
|
|
48
|
+
result.toolName = options.toolName;
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
43
51
|
}
|
|
44
52
|
};
|
|
53
|
+
function normalizeToolResultOptions(callIdOrOptions, toolName) {
|
|
54
|
+
if (callIdOrOptions === void 0) {
|
|
55
|
+
return toolName === void 0 ? {} : { toolName };
|
|
56
|
+
}
|
|
57
|
+
if (typeof callIdOrOptions === "string") {
|
|
58
|
+
return toolName === void 0 ? { callId: callIdOrOptions } : { callId: callIdOrOptions, toolName };
|
|
59
|
+
}
|
|
60
|
+
return toolName === void 0 ? callIdOrOptions : { ...callIdOrOptions, toolName };
|
|
61
|
+
}
|
|
45
62
|
function serializeToolResultOutput(output) {
|
|
46
63
|
if (typeof output === "string") {
|
|
47
64
|
return output;
|
|
@@ -151,7 +168,7 @@ var Message = {
|
|
|
151
168
|
},
|
|
152
169
|
toolResult(id, output, options = {}) {
|
|
153
170
|
const content = isToolResultContentArray(output) ? output : serializeToolResultOutput(output);
|
|
154
|
-
return Message.tool(ToolContent.toolResult(id, content, options
|
|
171
|
+
return Message.tool(ToolContent.toolResult(id, content, options));
|
|
155
172
|
}
|
|
156
173
|
};
|
|
157
174
|
var Usage = {
|
|
@@ -231,4 +248,4 @@ export {
|
|
|
231
248
|
assertCompletionRequestSupported,
|
|
232
249
|
textFromAssistantContent
|
|
233
250
|
};
|
|
234
|
-
//# sourceMappingURL=chunk-
|
|
251
|
+
//# sourceMappingURL=chunk-QVFOCNF6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/completion/types.ts"],"sourcesContent":["export 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\ntype ToolResultOptions = {\n callId?: string | undefined;\n toolName?: string | undefined;\n};\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};\n\nexport type UserMessage = {\n role: \"user\";\n content: UserContent[];\n};\n\nexport type AssistantMessage = {\n role: \"assistant\";\n id?: string;\n content: AssistantContent[];\n};\n\nexport type ToolMessage = {\n role: \"tool\";\n content: ToolContent[];\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): Message {\n return { role: \"system\", content };\n },\n user(content: string | UserContent[]): Message {\n return {\n role: \"user\",\n content: typeof content === \"string\" ? [UserContent.text(content)] : content,\n };\n },\n assistant(content: string | AssistantContent[], id?: string): Message {\n const normalized = typeof content === \"string\" ? [AssistantContent.text(content)] : content;\n return id === undefined\n ? { role: \"assistant\", content: normalized }\n : { role: \"assistant\", id, content: normalized };\n },\n tool(content: ToolContent | ToolContent[]): Message {\n return {\n role: \"tool\",\n content: Array.isArray(content) ? content : [content],\n };\n },\n toolResult(id: string, output: unknown, options: ToolResultOptions = {}): Message {\n const content = isToolResultContentArray(output) ? output : serializeToolResultOutput(output);\n return Message.tool(ToolContent.toolResult(id, content, options));\n },\n};\n\nexport type ToolChoice =\n | \"auto\"\n | \"required\"\n | \"none\"\n | {\n type: \"function\";\n name: string;\n };\n\nexport type ToolDefinition = {\n name: string;\n description: string;\n parameters: JsonObject;\n};\n\nexport type Usage = {\n inputTokens: number;\n outputTokens: number;\n totalTokens: number;\n cachedInputTokens: number;\n cacheCreationInputTokens: number;\n};\n\nexport const Usage = {\n empty(): Usage {\n return {\n inputTokens: 0,\n outputTokens: 0,\n totalTokens: 0,\n cachedInputTokens: 0,\n cacheCreationInputTokens: 0,\n };\n },\n add(left: Usage, right: Usage): Usage {\n return {\n inputTokens: left.inputTokens + right.inputTokens,\n outputTokens: left.outputTokens + right.outputTokens,\n totalTokens: left.totalTokens + right.totalTokens,\n cachedInputTokens: left.cachedInputTokens + right.cachedInputTokens,\n cacheCreationInputTokens: left.cacheCreationInputTokens + right.cacheCreationInputTokens,\n };\n },\n};\n\nexport type CompletionRequest<ModelName extends string = string> = {\n model?: ModelName;\n instructions?: string;\n chatHistory: Message[];\n documents: Document[];\n tools: ToolDefinition[];\n temperature?: number;\n maxTokens?: number;\n toolChoice?: ToolChoice;\n additionalParams?: JsonValue;\n outputSchema?: JsonObject;\n};\n\nexport type CompletionResponse<RawResponse = unknown> = {\n choice: AssistantContent[];\n usage: Usage;\n rawResponse: RawResponse;\n messageId?: string;\n};\n\nexport type CompletionModelCapabilities = {\n streaming: boolean;\n tools: boolean;\n toolChoice: boolean;\n imageInput: boolean;\n documentInput: boolean;\n outputSchema: boolean;\n reasoning: boolean;\n};\n\nexport interface CompletionModel<RawResponse = unknown, ModelName extends string = string> {\n readonly provider: string;\n readonly defaultModel: ModelName;\n readonly capabilities: CompletionModelCapabilities;\n traceRequest?(\n request: CompletionRequest<ModelName>,\n options?: { stream?: boolean | undefined },\n ): JsonObject | undefined;\n completion(request: CompletionRequest<ModelName>): Promise<CompletionResponse<RawResponse>>;\n}\n\nexport type CompletionStreamEvent<RawResponse = unknown> =\n | {\n type: \"text_delta\";\n delta: string;\n }\n | {\n type: \"reasoning_delta\";\n delta: string;\n id?: string;\n contentType?: ReasoningContentType;\n signature?: string;\n }\n | {\n type: \"tool_call_delta\";\n id: string;\n callId?: string;\n name?: string;\n argumentsDelta?: string;\n signature?: string;\n }\n | {\n type: \"tool_call\";\n toolCall: ToolCall;\n }\n | {\n type: \"message_id\";\n id: string;\n }\n | {\n type: \"final\";\n response: CompletionResponse<RawResponse>;\n }\n | {\n type: \"error\";\n error: unknown;\n };\n\nexport interface StreamingCompletionModel<RawResponse = unknown, ModelName extends string = string>\n extends CompletionModel<RawResponse, ModelName> {\n streamCompletion(\n request: CompletionRequest<ModelName>,\n ): AsyncIterable<CompletionStreamEvent<RawResponse>>;\n}\n\nexport class CompletionCapabilityError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"CompletionCapabilityError\";\n }\n}\n\nexport function assertCompletionRequestSupported(\n model: CompletionModel,\n request: CompletionRequest,\n options: { streaming?: boolean | undefined } = {},\n): void {\n const modelLabel = `${model.provider}:${request.model ?? model.defaultModel}`;\n const capabilities = model.capabilities;\n\n if (options.streaming === true && !capabilities.streaming) {\n throw new CompletionCapabilityError(`${modelLabel} does not support streaming completions.`);\n }\n\n if (request.tools.length > 0 && !capabilities.tools) {\n throw new CompletionCapabilityError(`${modelLabel} does not support tool definitions.`);\n }\n\n if (request.toolChoice !== undefined && !capabilities.toolChoice) {\n throw new CompletionCapabilityError(`${modelLabel} does not support tool choice.`);\n }\n\n if (request.outputSchema !== undefined && !capabilities.outputSchema) {\n throw new CompletionCapabilityError(`${modelLabel} does not support output schemas.`);\n }\n\n if (!capabilities.imageInput && requestHasImageInput(request)) {\n throw new CompletionCapabilityError(`${modelLabel} does not support image input.`);\n }\n\n if (!capabilities.documentInput && requestHasFileDocumentInput(request)) {\n throw new CompletionCapabilityError(`${modelLabel} does not support document file input.`);\n }\n}\n\nexport function textFromAssistantContent(content: AssistantContent[]): string {\n return content.flatMap((item) => (item.type === \"text\" ? [item.text] : [])).join(\"\\n\");\n}\n\nfunction requestHasImageInput(request: CompletionRequest): boolean {\n return request.chatHistory.some((message) =>\n message.role === \"system\" ? false : message.content.some((content) => content.type === \"image\"),\n );\n}\n\nfunction requestHasFileDocumentInput(request: CompletionRequest): boolean {\n return request.chatHistory.some((message) =>\n message.role === \"user\"\n ? message.content.some(\n (content) => content.type === \"document\" && content.source.type !== \"text\",\n )\n : false,\n );\n}\n"],"mappings":";AA8IO,I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AAc,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,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentBuilder
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JJ3JGL5D.js";
|
|
4
4
|
import {
|
|
5
5
|
extractRagText
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5MUPA66B.js";
|
|
7
7
|
import {
|
|
8
8
|
createTool
|
|
9
9
|
} from "./chunk-QKA6OQTH.js";
|
|
10
10
|
import {
|
|
11
11
|
CompletionRequestBuilder
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-FUJ3POKH.js";
|
|
13
13
|
import {
|
|
14
14
|
CompletionCapabilityError,
|
|
15
15
|
Message,
|
|
16
16
|
Usage
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-QVFOCNF6.js";
|
|
18
18
|
|
|
19
19
|
// src/extractor/extractor.ts
|
|
20
20
|
var SUBMIT_TOOL_NAME = "submit";
|
|
@@ -138,4 +138,4 @@ export {
|
|
|
138
138
|
Extractor,
|
|
139
139
|
ExtractorBuilder
|
|
140
140
|
};
|
|
141
|
-
//# sourceMappingURL=chunk-
|
|
141
|
+
//# sourceMappingURL=chunk-TD6A4RYQ.js.map
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
isToolResultContentArray,
|
|
10
10
|
serializeToolResultOutput
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-QVFOCNF6.js";
|
|
12
12
|
import {
|
|
13
13
|
embedDocuments
|
|
14
14
|
} from "./chunk-JS5MGVNM.js";
|
|
@@ -225,4 +225,4 @@ export {
|
|
|
225
225
|
createToolMiddleware,
|
|
226
226
|
createThinkTool
|
|
227
227
|
};
|
|
228
|
-
//# sourceMappingURL=chunk-
|
|
228
|
+
//# sourceMappingURL=chunk-YZLOFKTT.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 isStreamingCompletionModel } from '../create-completion-
|
|
2
|
-
import { D as Document, M as Message, C as CompletionModel, h as ToolDefinition, n as ToolChoice, e as JsonValue, J as JsonObject, b as CompletionRequest, c as CompletionResponse } from '../types-
|
|
3
|
-
export { A as AssistantContent, a as AssistantMessage, r as CompletionCapabilityError, t as CompletionModelCapabilities, p as CompletionStreamEvent, u as DocumentContent, I as ImageContent, v as ImageDetail, d as JsonPrimitive, R as Reasoning, w as ReasoningContent, x as ReasoningContentType, o as StreamingCompletionModel, S as SystemMessage, T as Text, f as ToolCall, g as ToolContent, y as ToolFunction, i as ToolMessage, j as ToolResult, k as ToolResultContent, U as Usage, l as UserContent, m as UserMessage, z as assertCompletionRequestSupported, q as isToolResultContentArray, B as reasoningDisplayText, s as serializeToolResultOutput, E as textFromAssistantContent } from '../types-
|
|
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 isStreamingCompletionModel } from '../create-completion-CC8-Ep3w.js';
|
|
2
|
+
import { D as Document, M as Message, C as CompletionModel, h as ToolDefinition, n as ToolChoice, e as JsonValue, J as JsonObject, b as CompletionRequest, c as CompletionResponse } from '../types-C15r7N_4.js';
|
|
3
|
+
export { A as AssistantContent, a as AssistantMessage, r as CompletionCapabilityError, t as CompletionModelCapabilities, p as CompletionStreamEvent, u as DocumentContent, I as ImageContent, v as ImageDetail, d as JsonPrimitive, R as Reasoning, w as ReasoningContent, x as ReasoningContentType, o as StreamingCompletionModel, S as SystemMessage, T as Text, f as ToolCall, g as ToolContent, y as ToolFunction, i as ToolMessage, j as ToolResult, k as ToolResultContent, U as Usage, l as UserContent, m as UserMessage, z as assertCompletionRequestSupported, q as isToolResultContentArray, B as reasoningDisplayText, s as serializeToolResultOutput, E as textFromAssistantContent } from '../types-C15r7N_4.js';
|
|
4
4
|
import '../zod-schema-C7F4clpm.js';
|
|
5
5
|
import 'zod';
|
|
6
6
|
|
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-FUJ3POKH.js";
|
|
10
10
|
import {
|
|
11
11
|
AssistantContent,
|
|
12
12
|
CompletionCapabilityError,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
reasoningDisplayText,
|
|
20
20
|
serializeToolResultOutput,
|
|
21
21
|
textFromAssistantContent
|
|
22
|
-
} from "../chunk-
|
|
22
|
+
} from "../chunk-QVFOCNF6.js";
|
|
23
23
|
import "../chunk-WQKHFADH.js";
|
|
24
24
|
export {
|
|
25
25
|
AssistantContent,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Z as ZodSchema } from './zod-schema-C7F4clpm.js';
|
|
2
|
-
import { M as Message, D as Document, h as ToolDefinition, n as ToolChoice, J as JsonObject, e as JsonValue, A as AssistantContent, U as Usage, c as CompletionResponse, C as CompletionModel, o as StreamingCompletionModel, p as CompletionStreamEvent } from './types-
|
|
2
|
+
import { M as Message, D as Document, h as ToolDefinition, n as ToolChoice, J as JsonObject, e as JsonValue, A as AssistantContent, U as Usage, c as CompletionResponse, C as CompletionModel, o as StreamingCompletionModel, p as CompletionStreamEvent } from './types-C15r7N_4.js';
|
|
3
3
|
|
|
4
4
|
type CreateCompletionInput = string | Message | Message[];
|
|
5
5
|
type CreateCompletionBaseOptions = {
|
package/dist/evals/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { A as Agent } from '../agent-
|
|
2
|
-
import { e as JsonValue, M as Message, C as CompletionModel } from '../types-
|
|
3
|
-
import { P as PromptResponse } from '../index-
|
|
1
|
+
import { A as Agent } from '../agent-BB9vVH6P.js';
|
|
2
|
+
import { e as JsonValue, M as Message, C as CompletionModel } from '../types-C15r7N_4.js';
|
|
3
|
+
import { P as PromptResponse } from '../index-CM-V4LS3.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-Dh7gfoGw.js';
|
|
8
|
+
import '../types-bNDxj4Tt.js';
|
|
9
|
+
import '../tool-f2stpvUP.js';
|
|
10
|
+
import '../middleware-i-jLsLom.js';
|
|
11
|
+
import '../types-DmvXANwl.js';
|
|
12
12
|
import 'zod';
|
|
13
13
|
|
|
14
14
|
type EvalOutcome<Score = unknown> = {
|