@convex-dev/agent
Version:
A agent component for Convex.
1,083 lines • 78.7 kB
TypeScript
import { type ApiFromModules, type GenericActionCtx, type GenericDataModel, type GenericQueryCtx } from "convex/server";
import { type Agent, type AgentComponent } from "./index.js";
export type PlaygroundAPI = ApiFromModules<{
playground: ReturnType<typeof definePlaygroundAPI>;
}>["playground"];
export type AgentsFn<DataModel extends GenericDataModel> = (ctx: GenericActionCtx<DataModel> | GenericQueryCtx<DataModel>, args: {
userId: string | undefined;
threadId: string | undefined;
}) => Agent[] | Promise<Agent[]>;
export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(component: AgentComponent, { agents: agentsOrFn, userNameLookup, }: {
agents: Agent[] | AgentsFn<DataModel>;
userNameLookup?: (ctx: GenericQueryCtx<DataModel>, userId: string) => string | Promise<string>;
}): {
isApiKeyValid: import("convex/server").RegisteredQuery<"public", {
apiKey: string;
}, Promise<boolean>>;
listUsers: import("convex/server").RegisteredQuery<"public", {
apiKey: string;
paginationOpts: {
id?: number;
endCursor?: string | null;
maximumRowsRead?: number;
maximumBytesRead?: number;
numItems: number;
cursor: string | null;
};
}, Promise<{
page: {
_id: string;
name: string;
}[];
continueCursor: string;
isDone: boolean;
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
splitCursor?: string | null;
}>>;
listThreads: import("convex/server").RegisteredQuery<"public", {
userId?: string | undefined;
apiKey: string;
paginationOpts: {
id?: number;
endCursor?: string | null;
maximumRowsRead?: number;
maximumBytesRead?: number;
numItems: number;
cursor: string | null;
};
}, Promise<{
page: {
lastAgentName: string | undefined;
latestMessage: string | undefined;
lastMessageAt: number;
_creationTime: number;
_id: string;
status: "active" | "archived";
summary?: string;
title?: string;
userId?: string;
}[];
continueCursor: string;
isDone: boolean;
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
splitCursor?: string | null;
}>>;
listMessages: import("convex/server").RegisteredQuery<"public", {
streamArgs?: {
startOrder?: number | undefined;
kind: "list";
} | {
kind: "deltas";
cursors: {
streamId: string;
cursor: number;
}[];
} | undefined;
threadId: string;
apiKey: string;
paginationOpts: {
id?: number;
endCursor?: string | null;
maximumRowsRead?: number;
maximumBytesRead?: number;
numItems: number;
cursor: string | null;
};
}, Promise<{
streams: import("./types.js").SyncStreamsReturnValue;
page: {
id?: string | undefined;
userId?: string | undefined;
embeddingId?: string | undefined;
fileIds?: string[] | undefined;
error?: string | undefined;
agentName?: string | undefined;
model?: string | undefined;
provider?: string | undefined;
providerOptions?: Record<string, Record<string, any>> | undefined;
message?: {
providerOptions?: Record<string, Record<string, any>> | undefined;
role: "user";
content: string | ({
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
type: "text";
text: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
mediaType?: string | undefined;
mimeType?: string | undefined;
type: "image";
image: string | ArrayBuffer;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
mediaType?: string | undefined;
mimeType?: string | undefined;
filename?: string | undefined;
type: "file";
data: string | ArrayBuffer;
})[];
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
role: "assistant";
content: string | ({
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
type: "text";
text: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
mediaType?: string | undefined;
mimeType?: string | undefined;
filename?: string | undefined;
type: "file";
data: string | ArrayBuffer;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
signature?: string | undefined;
type: "reasoning";
text: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
type: "redacted-reasoning";
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
args?: any;
providerExecuted?: boolean | undefined;
type: "tool-call";
toolCallId: string;
toolName: string;
input: any;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
input?: any;
providerExecuted?: boolean | undefined;
type: "tool-call";
toolCallId: string;
toolName: string;
args: any;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
args?: any;
providerExecuted?: boolean | undefined;
output?: {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "text";
value: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "json";
value: any;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "error-text";
value: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "error-json";
value: any;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
reason?: string | undefined;
type: "execution-denied";
} | {
type: "content";
value: ({
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "text";
text: string;
} | {
type: "media";
mediaType: string;
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
filename?: string | undefined;
type: "file-data";
mediaType: string;
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "file-url";
url: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "file-id";
fileId: string | Record<string, string>;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "image-data";
mediaType: string;
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "image-url";
url: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "image-file-id";
fileId: string | Record<string, string>;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "custom";
})[];
} | undefined;
result?: any;
isError?: boolean | undefined;
experimental_content?: ({
type: "text";
text: string;
} | {
mimeType?: string | undefined;
type: "image";
data: string;
})[] | undefined;
type: "tool-result";
toolCallId: string;
toolName: string;
} | {
title?: string | undefined;
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
id: string;
type: "source";
url: string;
sourceType: "url";
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
filename?: string | undefined;
id: string;
title: string;
type: "source";
mediaType: string;
sourceType: "document";
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
type: "tool-approval-request";
toolCallId: string;
approvalId: string;
})[];
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
role: "tool";
content: ({
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
args?: any;
providerExecuted?: boolean | undefined;
output?: {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "text";
value: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "json";
value: any;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "error-text";
value: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "error-json";
value: any;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
reason?: string | undefined;
type: "execution-denied";
} | {
type: "content";
value: ({
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "text";
text: string;
} | {
type: "media";
mediaType: string;
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
filename?: string | undefined;
type: "file-data";
mediaType: string;
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "file-url";
url: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "file-id";
fileId: string | Record<string, string>;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "image-data";
mediaType: string;
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "image-url";
url: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "image-file-id";
fileId: string | Record<string, string>;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "custom";
})[];
} | undefined;
result?: any;
isError?: boolean | undefined;
experimental_content?: ({
type: "text";
text: string;
} | {
mimeType?: string | undefined;
type: "image";
data: string;
})[] | undefined;
type: "tool-result";
toolCallId: string;
toolName: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
providerExecuted?: boolean | undefined;
reason?: string | undefined;
type: "tool-approval-response";
approvalId: string;
approved: boolean;
})[];
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
role: "system";
content: string;
} | undefined;
text?: string | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
reasoning?: string | undefined;
usage?: {
reasoningTokens?: number | undefined;
cachedInputTokens?: number | undefined;
promptTokens: number;
completionTokens: number;
totalTokens: number;
} | undefined;
sources?: ({
title?: string | undefined;
type?: "source" | undefined;
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
id: string;
url: string;
sourceType: "url";
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
filename?: string | undefined;
id: string;
title: string;
type: "source";
mediaType: string;
sourceType: "document";
})[] | undefined;
warnings?: ({
details?: string | undefined;
type: "unsupported-setting";
setting: string;
} | {
details?: string | undefined;
type: "unsupported-tool";
tool: any;
} | {
type: "other";
message: string;
})[] | undefined;
finishReason?: "error" | "length" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
reasoningDetails?: ({
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
signature?: string | undefined;
type: "reasoning";
text: string;
} | {
signature?: string | undefined;
type: "text";
text: string;
} | {
type: "redacted";
data: string;
})[] | undefined;
status: "pending" | "success" | "failed";
order: number;
_creationTime: number;
threadId: string;
stepOrder: number;
tool: boolean;
_id: string;
}[];
isDone: boolean;
continueCursor: import("convex/server").Cursor;
splitCursor?: import("convex/server").Cursor | null;
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
}>>;
listAgents: import("convex/server").RegisteredQuery<"public", {
userId?: string | undefined;
threadId?: string | undefined;
apiKey: string;
}, Promise<{
name: string;
instructions: string | undefined;
contextOptions: import("./types.js").ContextOptions | undefined;
storageOptions: import("./types.js").StorageOptions | undefined;
maxRetries: number | undefined;
tools: string[];
}[]>>;
createThread: import("convex/server").RegisteredMutation<"public", {
title?: string | undefined;
summary?: string | undefined;
agentName?: string | undefined;
userId: string;
apiKey: string;
}, Promise<{
threadId: string;
}>>;
generateText: import("convex/server").RegisteredAction<"public", {
system?: string | undefined;
messages?: ({
providerOptions?: Record<string, Record<string, any>> | undefined;
role: "user";
content: string | ({
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
type: "text";
text: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
mediaType?: string | undefined;
mimeType?: string | undefined;
type: "image";
image: string | ArrayBuffer;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
mediaType?: string | undefined;
mimeType?: string | undefined;
filename?: string | undefined;
type: "file";
data: string | ArrayBuffer;
})[];
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
role: "assistant";
content: string | ({
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
type: "text";
text: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
mediaType?: string | undefined;
mimeType?: string | undefined;
filename?: string | undefined;
type: "file";
data: string | ArrayBuffer;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
signature?: string | undefined;
type: "reasoning";
text: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
type: "redacted-reasoning";
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
args?: any;
providerExecuted?: boolean | undefined;
type: "tool-call";
toolCallId: string;
toolName: string;
input: any;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
input?: any;
providerExecuted?: boolean | undefined;
type: "tool-call";
toolCallId: string;
toolName: string;
args: any;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
args?: any;
providerExecuted?: boolean | undefined;
output?: {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "text";
value: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "json";
value: any;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "error-text";
value: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "error-json";
value: any;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
reason?: string | undefined;
type: "execution-denied";
} | {
type: "content";
value: ({
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "text";
text: string;
} | {
type: "media";
mediaType: string;
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
filename?: string | undefined;
type: "file-data";
mediaType: string;
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "file-url";
url: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "file-id";
fileId: string | Record<string, string>;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "image-data";
mediaType: string;
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "image-url";
url: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "image-file-id";
fileId: string | Record<string, string>;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "custom";
})[];
} | undefined;
result?: any;
isError?: boolean | undefined;
experimental_content?: ({
type: "text";
text: string;
} | {
mimeType?: string | undefined;
type: "image";
data: string;
})[] | undefined;
type: "tool-result";
toolCallId: string;
toolName: string;
} | {
title?: string | undefined;
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
id: string;
type: "source";
url: string;
sourceType: "url";
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
filename?: string | undefined;
id: string;
title: string;
type: "source";
mediaType: string;
sourceType: "document";
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
type: "tool-approval-request";
toolCallId: string;
approvalId: string;
})[];
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
role: "tool";
content: ({
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
args?: any;
providerExecuted?: boolean | undefined;
output?: {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "text";
value: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "json";
value: any;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "error-text";
value: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "error-json";
value: any;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
reason?: string | undefined;
type: "execution-denied";
} | {
type: "content";
value: ({
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "text";
text: string;
} | {
type: "media";
mediaType: string;
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
filename?: string | undefined;
type: "file-data";
mediaType: string;
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "file-url";
url: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "file-id";
fileId: string | Record<string, string>;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "image-data";
mediaType: string;
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "image-url";
url: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "image-file-id";
fileId: string | Record<string, string>;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "custom";
})[];
} | undefined;
result?: any;
isError?: boolean | undefined;
experimental_content?: ({
type: "text";
text: string;
} | {
mimeType?: string | undefined;
type: "image";
data: string;
})[] | undefined;
type: "tool-result";
toolCallId: string;
toolName: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
providerExecuted?: boolean | undefined;
reason?: string | undefined;
type: "tool-approval-response";
approvalId: string;
approved: boolean;
})[];
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
role: "system";
content: string;
})[] | undefined;
prompt?: string | undefined;
contextOptions?: {
excludeToolMessages?: boolean | undefined;
recentMessages?: number | undefined;
searchOptions?: {
textSearch?: boolean | undefined;
vectorSearch?: boolean | undefined;
vectorScoreThreshold?: number | undefined;
messageRange?: {
before: number;
after: number;
} | undefined;
limit: number;
} | undefined;
searchOtherThreads?: boolean | undefined;
} | undefined;
storageOptions?: {
saveMessages?: "all" | "none" | "promptAndOutput" | undefined;
} | undefined;
userId: string;
threadId: string;
agentName: string;
apiKey: string;
}, Promise<{
text: string;
messages: {
id?: string | undefined;
userId?: string | undefined;
embeddingId?: string | undefined;
fileIds?: string[] | undefined;
error?: string | undefined;
agentName?: string | undefined;
model?: string | undefined;
provider?: string | undefined;
providerOptions?: Record<string, Record<string, any>> | undefined;
message?: {
providerOptions?: Record<string, Record<string, any>> | undefined;
role: "user";
content: string | ({
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
type: "text";
text: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
mediaType?: string | undefined;
mimeType?: string | undefined;
type: "image";
image: string | ArrayBuffer;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
mediaType?: string | undefined;
mimeType?: string | undefined;
filename?: string | undefined;
type: "file";
data: string | ArrayBuffer;
})[];
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
role: "assistant";
content: string | ({
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
type: "text";
text: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
mediaType?: string | undefined;
mimeType?: string | undefined;
filename?: string | undefined;
type: "file";
data: string | ArrayBuffer;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
signature?: string | undefined;
type: "reasoning";
text: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
type: "redacted-reasoning";
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
args?: any;
providerExecuted?: boolean | undefined;
type: "tool-call";
toolCallId: string;
toolName: string;
input: any;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
input?: any;
providerExecuted?: boolean | undefined;
type: "tool-call";
toolCallId: string;
toolName: string;
args: any;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
args?: any;
providerExecuted?: boolean | undefined;
output?: {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "text";
value: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "json";
value: any;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "error-text";
value: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "error-json";
value: any;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
reason?: string | undefined;
type: "execution-denied";
} | {
type: "content";
value: ({
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "text";
text: string;
} | {
type: "media";
mediaType: string;
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
filename?: string | undefined;
type: "file-data";
mediaType: string;
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "file-url";
url: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "file-id";
fileId: string | Record<string, string>;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "image-data";
mediaType: string;
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "image-url";
url: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "image-file-id";
fileId: string | Record<string, string>;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "custom";
})[];
} | undefined;
result?: any;
isError?: boolean | undefined;
experimental_content?: ({
type: "text";
text: string;
} | {
mimeType?: string | undefined;
type: "image";
data: string;
})[] | undefined;
type: "tool-result";
toolCallId: string;
toolName: string;
} | {
title?: string | undefined;
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
id: string;
type: "source";
url: string;
sourceType: "url";
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
filename?: string | undefined;
id: string;
title: string;
type: "source";
mediaType: string;
sourceType: "document";
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
type: "tool-approval-request";
toolCallId: string;
approvalId: string;
})[];
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
role: "tool";
content: ({
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
args?: any;
providerExecuted?: boolean | undefined;
output?: {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "text";
value: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "json";
value: any;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "error-text";
value: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "error-json";
value: any;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
reason?: string | undefined;
type: "execution-denied";
} | {
type: "content";
value: ({
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "text";
text: string;
} | {
type: "media";
mediaType: string;
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
filename?: string | undefined;
type: "file-data";
mediaType: string;
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "file-url";
url: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "file-id";
fileId: string | Record<string, string>;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "image-data";
mediaType: string;
data: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "image-url";
url: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "image-file-id";
fileId: string | Record<string, string>;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
type: "custom";
})[];
} | undefined;
result?: any;
isError?: boolean | undefined;
experimental_content?: ({
type: "text";
text: string;
} | {
mimeType?: string | undefined;
type: "image";
data: string;
})[] | undefined;
type: "tool-result";
toolCallId: string;
toolName: string;
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
providerExecuted?: boolean | undefined;
reason?: string | undefined;
type: "tool-approval-response";
approvalId: string;
approved: boolean;
})[];
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
role: "system";
content: string;
} | undefined;
text?: string | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
reasoning?: string | undefined;
usage?: {
reasoningTokens?: number | undefined;
cachedInputTokens?: number | undefined;
promptTokens: number;
completionTokens: number;
totalTokens: number;
} | undefined;
sources?: ({
title?: string | undefined;
type?: "source" | undefined;
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
id: string;
url: string;
sourceType: "url";
} | {
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
filename?: string | undefined;
id: string;
title: string;
type: "source";
mediaType: string;
sourceType: "document";
})[] | undefined;
warnings?: ({
details?: string | undefined;
type: "unsupported-setting";
setting: string;
} | {
details?: string | undefined;
type: "unsupported-tool";
tool: any;
} | {
type: "other";
message: string;
})[] | undefined;
finishReason?: "error" | "length" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
reasoningDetails?: ({
providerOptions?: Record<string, Record<string, any>> | undefined;
providerMetadata?: Record<string, Record<string, any>> | undefined;
signature?: string | undefined;
type: "reasoning";
text: string;
} | {
signature?: string | undefined;
type: "text";
text: string;
} | {
type: "reda