@convex-dev/agent
Version:
A agent component for Convex.
1,460 lines (1,457 loc) • 59.7 kB
TypeScript
/* eslint-disable */
/**
* Generated `api` utility.
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* To regenerate, run `npx convex dev`.
* @module
*/
import type * as apiKeys from "../apiKeys.js";
import type * as files from "../files.js";
import type * as messages from "../messages.js";
import type * as streams from "../streams.js";
import type * as threads from "../threads.js";
import type * as users from "../users.js";
import type * as vector_index from "../vector/index.js";
import type * as vector_tables from "../vector/tables.js";
import type {
ApiFromModules,
FilterApi,
FunctionReference,
} from "convex/server";
/**
* A utility for referencing Convex functions in your app's API.
*
* Usage:
* ```js
* const myFunctionReference = api.myModule.myFunction;
* ```
*/
declare const fullApi: ApiFromModules<{
apiKeys: typeof apiKeys;
files: typeof files;
messages: typeof messages;
streams: typeof streams;
threads: typeof threads;
users: typeof users;
"vector/index": typeof vector_index;
"vector/tables": typeof vector_tables;
}>;
export type Mounts = {
apiKeys: {
destroy: FunctionReference<
"mutation",
"public",
{ apiKey?: string; name?: string },
| "missing"
| "deleted"
| "name mismatch"
| "must provide either apiKey or name"
>;
issue: FunctionReference<"mutation", "public", { name?: string }, string>;
validate: FunctionReference<"query", "public", { apiKey: string }, boolean>;
};
files: {
addFile: FunctionReference<
"mutation",
"public",
{ filename?: string; hash: string; mimeType: string; storageId: string },
{ fileId: string; storageId: string }
>;
copyFile: FunctionReference<"mutation", "public", { fileId: string }, null>;
deleteFiles: FunctionReference<
"mutation",
"public",
{ fileIds: Array<string>; force?: boolean },
Array<string>
>;
get: FunctionReference<
"query",
"public",
{ fileId: string },
null | {
_creationTime: number;
_id: string;
filename?: string;
hash: string;
lastTouchedAt: number;
mimeType: string;
refcount: number;
storageId: string;
}
>;
getFilesToDelete: FunctionReference<
"query",
"public",
{
paginationOpts: {
cursor: string | null;
endCursor?: string | null;
id?: number;
maximumBytesRead?: number;
maximumRowsRead?: number;
numItems: number;
};
},
{
continueCursor: string;
isDone: boolean;
page: Array<{
_creationTime: number;
_id: string;
filename?: string;
hash: string;
lastTouchedAt: number;
mimeType: string;
refcount: number;
storageId: string;
}>;
}
>;
useExistingFile: FunctionReference<
"mutation",
"public",
{ filename?: string; hash: string },
null | { fileId: string; storageId: string }
>;
};
messages: {
addMessages: FunctionReference<
"mutation",
"public",
{
agentName?: string;
embeddings?: {
dimension:
| 128
| 256
| 512
| 768
| 1024
| 1408
| 1536
| 2048
| 3072
| 4096;
model: string;
vectors: Array<Array<number> | null>;
};
failPendingSteps?: boolean;
messages: Array<{
error?: string;
fileIds?: Array<string>;
finishReason?:
| "stop"
| "length"
| "content-filter"
| "tool-calls"
| "error"
| "other"
| "unknown";
message:
| {
content:
| string
| Array<
| {
providerOptions?: Record<string, Record<string, any>>;
text: string;
type: "text";
}
| {
image: string | ArrayBuffer;
mimeType?: string;
providerOptions?: Record<string, Record<string, any>>;
type: "image";
}
| {
data: string | ArrayBuffer;
filename?: string;
mimeType: string;
providerOptions?: Record<string, Record<string, any>>;
type: "file";
}
>;
providerOptions?: Record<string, Record<string, any>>;
role: "user";
}
| {
content:
| string
| Array<
| {
providerOptions?: Record<string, Record<string, any>>;
text: string;
type: "text";
}
| {
data: string | ArrayBuffer;
filename?: string;
mimeType: string;
providerOptions?: Record<string, Record<string, any>>;
type: "file";
}
| {
providerOptions?: Record<string, Record<string, any>>;
signature?: string;
state?: "streaming" | "done";
text: string;
type: "reasoning";
}
| {
data: string;
providerOptions?: Record<string, Record<string, any>>;
type: "redacted-reasoning";
}
| {
args: any;
providerExecuted?: boolean;
providerOptions?: Record<string, Record<string, any>>;
toolCallId: string;
toolName: string;
type: "tool-call";
}
>;
providerOptions?: Record<string, Record<string, any>>;
role: "assistant";
}
| {
content: Array<{
args?: any;
experimental_content?: Array<
| { text: string; type: "text" }
| { data: string; mimeType?: string; type: "image" }
>;
isError?: boolean;
providerExecuted?: boolean;
providerOptions?: Record<string, Record<string, any>>;
result: any;
toolCallId: string;
toolName: string;
type: "tool-result";
}>;
providerOptions?: Record<string, Record<string, any>>;
role: "tool";
}
| {
content: string;
providerOptions?: Record<string, Record<string, any>>;
role: "system";
};
model?: string;
provider?: string;
providerMetadata?: Record<string, Record<string, any>>;
reasoning?: string;
reasoningDetails?: Array<
| {
providerOptions?: Record<string, Record<string, any>>;
signature?: string;
state?: "streaming" | "done";
text: string;
type: "reasoning";
}
| { signature?: string; text: string; type: "text" }
| { data: string; type: "redacted" }
>;
sources?: Array<
| {
id: string;
providerOptions?: Record<string, Record<string, any>>;
sourceType: "url";
title?: string;
type?: "source";
url: string;
}
| {
filename?: string;
id: string;
mediaType: string;
providerMetadata?: Record<string, Record<string, any>>;
sourceType: "document";
title: string;
type: "source";
}
>;
status?: "pending" | "success" | "failed";
text?: string;
usage?: {
cachedInputTokens?: number;
completionTokens: number;
promptTokens: number;
reasoningTokens?: number;
totalTokens: number;
};
warnings?: Array<
| { details?: string; setting: string; type: "unsupported-setting" }
| { details?: string; tool: any; type: "unsupported-tool" }
| { message: string; type: "other" }
>;
}>;
pendingMessageId?: string;
promptMessageId?: string;
threadId: string;
userId?: string;
},
{
messages: Array<{
_creationTime: number;
_id: string;
agentName?: string;
embeddingId?: string;
error?: string;
fileIds?: Array<string>;
finishReason?:
| "stop"
| "length"
| "content-filter"
| "tool-calls"
| "error"
| "other"
| "unknown";
id?: string;
message?:
| {
content:
| string
| Array<
| {
providerOptions?: Record<string, Record<string, any>>;
text: string;
type: "text";
}
| {
image: string | ArrayBuffer;
mimeType?: string;
providerOptions?: Record<string, Record<string, any>>;
type: "image";
}
| {
data: string | ArrayBuffer;
filename?: string;
mimeType: string;
providerOptions?: Record<string, Record<string, any>>;
type: "file";
}
>;
providerOptions?: Record<string, Record<string, any>>;
role: "user";
}
| {
content:
| string
| Array<
| {
providerOptions?: Record<string, Record<string, any>>;
text: string;
type: "text";
}
| {
data: string | ArrayBuffer;
filename?: string;
mimeType: string;
providerOptions?: Record<string, Record<string, any>>;
type: "file";
}
| {
providerOptions?: Record<string, Record<string, any>>;
signature?: string;
state?: "streaming" | "done";
text: string;
type: "reasoning";
}
| {
data: string;
providerOptions?: Record<string, Record<string, any>>;
type: "redacted-reasoning";
}
| {
args: any;
providerExecuted?: boolean;
providerOptions?: Record<string, Record<string, any>>;
toolCallId: string;
toolName: string;
type: "tool-call";
}
>;
providerOptions?: Record<string, Record<string, any>>;
role: "assistant";
}
| {
content: Array<{
args?: any;
experimental_content?: Array<
| { text: string; type: "text" }
| { data: string; mimeType?: string; type: "image" }
>;
isError?: boolean;
providerExecuted?: boolean;
providerOptions?: Record<string, Record<string, any>>;
result: any;
toolCallId: string;
toolName: string;
type: "tool-result";
}>;
providerOptions?: Record<string, Record<string, any>>;
role: "tool";
}
| {
content: string;
providerOptions?: Record<string, Record<string, any>>;
role: "system";
};
model?: string;
order: number;
provider?: string;
providerMetadata?: Record<string, Record<string, any>>;
providerOptions?: Record<string, Record<string, any>>;
reasoning?: string;
reasoningDetails?: Array<
| {
providerOptions?: Record<string, Record<string, any>>;
signature?: string;
state?: "streaming" | "done";
text: string;
type: "reasoning";
}
| { signature?: string; text: string; type: "text" }
| { data: string; type: "redacted" }
>;
sources?: Array<
| {
id: string;
providerOptions?: Record<string, Record<string, any>>;
sourceType: "url";
title?: string;
type?: "source";
url: string;
}
| {
filename?: string;
id: string;
mediaType: string;
providerMetadata?: Record<string, Record<string, any>>;
sourceType: "document";
title: string;
type: "source";
}
>;
status: "pending" | "success" | "failed";
stepOrder: number;
text?: string;
threadId: string;
tool: boolean;
usage?: {
cachedInputTokens?: number;
completionTokens: number;
promptTokens: number;
reasoningTokens?: number;
totalTokens: number;
};
userId?: string;
warnings?: Array<
| { details?: string; setting: string; type: "unsupported-setting" }
| { details?: string; tool: any; type: "unsupported-tool" }
| { message: string; type: "other" }
>;
}>;
}
>;
deleteByIds: FunctionReference<
"mutation",
"public",
{ messageIds: Array<string> },
Array<string>
>;
deleteByOrder: FunctionReference<
"mutation",
"public",
{
endOrder: number;
endStepOrder?: number;
startOrder: number;
startStepOrder?: number;
threadId: string;
},
{ isDone: boolean; lastOrder?: number; lastStepOrder?: number }
>;
finalizeMessage: FunctionReference<
"mutation",
"public",
{
messageId: string;
result: { status: "success" } | { error: string; status: "failed" };
},
null
>;
getMessagesByIds: FunctionReference<
"query",
"public",
{ messageIds: Array<string> },
Array<null | {
_creationTime: number;
_id: string;
agentName?: string;
embeddingId?: string;
error?: string;
fileIds?: Array<string>;
finishReason?:
| "stop"
| "length"
| "content-filter"
| "tool-calls"
| "error"
| "other"
| "unknown";
id?: string;
message?:
| {
content:
| string
| Array<
| {
providerOptions?: Record<string, Record<string, any>>;
text: string;
type: "text";
}
| {
image: string | ArrayBuffer;
mimeType?: string;
providerOptions?: Record<string, Record<string, any>>;
type: "image";
}
| {
data: string | ArrayBuffer;
filename?: string;
mimeType: string;
providerOptions?: Record<string, Record<string, any>>;
type: "file";
}
>;
providerOptions?: Record<string, Record<string, any>>;
role: "user";
}
| {
content:
| string
| Array<
| {
providerOptions?: Record<string, Record<string, any>>;
text: string;
type: "text";
}
| {
data: string | ArrayBuffer;
filename?: string;
mimeType: string;
providerOptions?: Record<string, Record<string, any>>;
type: "file";
}
| {
providerOptions?: Record<string, Record<string, any>>;
signature?: string;
state?: "streaming" | "done";
text: string;
type: "reasoning";
}
| {
data: string;
providerOptions?: Record<string, Record<string, any>>;
type: "redacted-reasoning";
}
| {
args: any;
providerExecuted?: boolean;
providerOptions?: Record<string, Record<string, any>>;
toolCallId: string;
toolName: string;
type: "tool-call";
}
>;
providerOptions?: Record<string, Record<string, any>>;
role: "assistant";
}
| {
content: Array<{
args?: any;
experimental_content?: Array<
| { text: string; type: "text" }
| { data: string; mimeType?: string; type: "image" }
>;
isError?: boolean;
providerExecuted?: boolean;
providerOptions?: Record<string, Record<string, any>>;
result: any;
toolCallId: string;
toolName: string;
type: "tool-result";
}>;
providerOptions?: Record<string, Record<string, any>>;
role: "tool";
}
| {
content: string;
providerOptions?: Record<string, Record<string, any>>;
role: "system";
};
model?: string;
order: number;
provider?: string;
providerMetadata?: Record<string, Record<string, any>>;
providerOptions?: Record<string, Record<string, any>>;
reasoning?: string;
reasoningDetails?: Array<
| {
providerOptions?: Record<string, Record<string, any>>;
signature?: string;
state?: "streaming" | "done";
text: string;
type: "reasoning";
}
| { signature?: string; text: string; type: "text" }
| { data: string; type: "redacted" }
>;
sources?: Array<
| {
id: string;
providerOptions?: Record<string, Record<string, any>>;
sourceType: "url";
title?: string;
type?: "source";
url: string;
}
| {
filename?: string;
id: string;
mediaType: string;
providerMetadata?: Record<string, Record<string, any>>;
sourceType: "document";
title: string;
type: "source";
}
>;
status: "pending" | "success" | "failed";
stepOrder: number;
text?: string;
threadId: string;
tool: boolean;
usage?: {
cachedInputTokens?: number;
completionTokens: number;
promptTokens: number;
reasoningTokens?: number;
totalTokens: number;
};
userId?: string;
warnings?: Array<
| { details?: string; setting: string; type: "unsupported-setting" }
| { details?: string; tool: any; type: "unsupported-tool" }
| { message: string; type: "other" }
>;
}>
>;
listMessagesByThreadId: FunctionReference<
"query",
"public",
{
excludeToolMessages?: boolean;
order: "asc" | "desc";
paginationOpts?: {
cursor: string | null;
endCursor?: string | null;
id?: number;
maximumBytesRead?: number;
maximumRowsRead?: number;
numItems: number;
};
statuses?: Array<"pending" | "success" | "failed">;
threadId: string;
upToAndIncludingMessageId?: string;
},
{
continueCursor: string;
isDone: boolean;
page: Array<{
_creationTime: number;
_id: string;
agentName?: string;
embeddingId?: string;
error?: string;
fileIds?: Array<string>;
finishReason?:
| "stop"
| "length"
| "content-filter"
| "tool-calls"
| "error"
| "other"
| "unknown";
id?: string;
message?:
| {
content:
| string
| Array<
| {
providerOptions?: Record<string, Record<string, any>>;
text: string;
type: "text";
}
| {
image: string | ArrayBuffer;
mimeType?: string;
providerOptions?: Record<string, Record<string, any>>;
type: "image";
}
| {
data: string | ArrayBuffer;
filename?: string;
mimeType: string;
providerOptions?: Record<string, Record<string, any>>;
type: "file";
}
>;
providerOptions?: Record<string, Record<string, any>>;
role: "user";
}
| {
content:
| string
| Array<
| {
providerOptions?: Record<string, Record<string, any>>;
text: string;
type: "text";
}
| {
data: string | ArrayBuffer;
filename?: string;
mimeType: string;
providerOptions?: Record<string, Record<string, any>>;
type: "file";
}
| {
providerOptions?: Record<string, Record<string, any>>;
signature?: string;
state?: "streaming" | "done";
text: string;
type: "reasoning";
}
| {
data: string;
providerOptions?: Record<string, Record<string, any>>;
type: "redacted-reasoning";
}
| {
args: any;
providerExecuted?: boolean;
providerOptions?: Record<string, Record<string, any>>;
toolCallId: string;
toolName: string;
type: "tool-call";
}
>;
providerOptions?: Record<string, Record<string, any>>;
role: "assistant";
}
| {
content: Array<{
args?: any;
experimental_content?: Array<
| { text: string; type: "text" }
| { data: string; mimeType?: string; type: "image" }
>;
isError?: boolean;
providerExecuted?: boolean;
providerOptions?: Record<string, Record<string, any>>;
result: any;
toolCallId: string;
toolName: string;
type: "tool-result";
}>;
providerOptions?: Record<string, Record<string, any>>;
role: "tool";
}
| {
content: string;
providerOptions?: Record<string, Record<string, any>>;
role: "system";
};
model?: string;
order: number;
provider?: string;
providerMetadata?: Record<string, Record<string, any>>;
providerOptions?: Record<string, Record<string, any>>;
reasoning?: string;
reasoningDetails?: Array<
| {
providerOptions?: Record<string, Record<string, any>>;
signature?: string;
state?: "streaming" | "done";
text: string;
type: "reasoning";
}
| { signature?: string; text: string; type: "text" }
| { data: string; type: "redacted" }
>;
sources?: Array<
| {
id: string;
providerOptions?: Record<string, Record<string, any>>;
sourceType: "url";
title?: string;
type?: "source";
url: string;
}
| {
filename?: string;
id: string;
mediaType: string;
providerMetadata?: Record<string, Record<string, any>>;
sourceType: "document";
title: string;
type: "source";
}
>;
status: "pending" | "success" | "failed";
stepOrder: number;
text?: string;
threadId: string;
tool: boolean;
usage?: {
cachedInputTokens?: number;
completionTokens: number;
promptTokens: number;
reasoningTokens?: number;
totalTokens: number;
};
userId?: string;
warnings?: Array<
| { details?: string; setting: string; type: "unsupported-setting" }
| { details?: string; tool: any; type: "unsupported-tool" }
| { message: string; type: "other" }
>;
}>;
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
splitCursor?: string | null;
}
>;
searchMessages: FunctionReference<
"action",
"public",
{
beforeMessageId?: string;
embedding?: Array<number>;
embeddingModel?: string;
limit: number;
messageRange?: { after: number; before: number };
searchAllMessagesForUserId?: string;
text?: string;
threadId?: string;
vectorScoreThreshold?: number;
},
Array<{
_creationTime: number;
_id: string;
agentName?: string;
embeddingId?: string;
error?: string;
fileIds?: Array<string>;
finishReason?:
| "stop"
| "length"
| "content-filter"
| "tool-calls"
| "error"
| "other"
| "unknown";
id?: string;
message?:
| {
content:
| string
| Array<
| {
providerOptions?: Record<string, Record<string, any>>;
text: string;
type: "text";
}
| {
image: string | ArrayBuffer;
mimeType?: string;
providerOptions?: Record<string, Record<string, any>>;
type: "image";
}
| {
data: string | ArrayBuffer;
filename?: string;
mimeType: string;
providerOptions?: Record<string, Record<string, any>>;
type: "file";
}
>;
providerOptions?: Record<string, Record<string, any>>;
role: "user";
}
| {
content:
| string
| Array<
| {
providerOptions?: Record<string, Record<string, any>>;
text: string;
type: "text";
}
| {
data: string | ArrayBuffer;
filename?: string;
mimeType: string;
providerOptions?: Record<string, Record<string, any>>;
type: "file";
}
| {
providerOptions?: Record<string, Record<string, any>>;
signature?: string;
state?: "streaming" | "done";
text: string;
type: "reasoning";
}
| {
data: string;
providerOptions?: Record<string, Record<string, any>>;
type: "redacted-reasoning";
}
| {
args: any;
providerExecuted?: boolean;
providerOptions?: Record<string, Record<string, any>>;
toolCallId: string;
toolName: string;
type: "tool-call";
}
>;
providerOptions?: Record<string, Record<string, any>>;
role: "assistant";
}
| {
content: Array<{
args?: any;
experimental_content?: Array<
| { text: string; type: "text" }
| { data: string; mimeType?: string; type: "image" }
>;
isError?: boolean;
providerExecuted?: boolean;
providerOptions?: Record<string, Record<string, any>>;
result: any;
toolCallId: string;
toolName: string;
type: "tool-result";
}>;
providerOptions?: Record<string, Record<string, any>>;
role: "tool";
}
| {
content: string;
providerOptions?: Record<string, Record<string, any>>;
role: "system";
};
model?: string;
order: number;
provider?: string;
providerMetadata?: Record<string, Record<string, any>>;
providerOptions?: Record<string, Record<string, any>>;
reasoning?: string;
reasoningDetails?: Array<
| {
providerOptions?: Record<string, Record<string, any>>;
signature?: string;
state?: "streaming" | "done";
text: string;
type: "reasoning";
}
| { signature?: string; text: string; type: "text" }
| { data: string; type: "redacted" }
>;
sources?: Array<
| {
id: string;
providerOptions?: Record<string, Record<string, any>>;
sourceType: "url";
title?: string;
type?: "source";
url: string;
}
| {
filename?: string;
id: string;
mediaType: string;
providerMetadata?: Record<string, Record<string, any>>;
sourceType: "document";
title: string;
type: "source";
}
>;
status: "pending" | "success" | "failed";
stepOrder: number;
text?: string;
threadId: string;
tool: boolean;
usage?: {
cachedInputTokens?: number;
completionTokens: number;
promptTokens: number;
reasoningTokens?: number;
totalTokens: number;
};
userId?: string;
warnings?: Array<
| { details?: string; setting: string; type: "unsupported-setting" }
| { details?: string; tool: any; type: "unsupported-tool" }
| { message: string; type: "other" }
>;
}>
>;
textSearch: FunctionReference<
"query",
"public",
{
beforeMessageId?: string;
limit: number;
searchAllMessagesForUserId?: string;
text: string;
threadId?: string;
},
Array<{
_creationTime: number;
_id: string;
agentName?: string;
embeddingId?: string;
error?: string;
fileIds?: Array<string>;
finishReason?:
| "stop"
| "length"
| "content-filter"
| "tool-calls"
| "error"
| "other"
| "unknown";
id?: string;
message?:
| {
content:
| string
| Array<
| {
providerOptions?: Record<string, Record<string, any>>;
text: string;
type: "text";
}
| {
image: string | ArrayBuffer;
mimeType?: string;
providerOptions?: Record<string, Record<string, any>>;
type: "image";
}
| {
data: string | ArrayBuffer;
filename?: string;
mimeType: string;
providerOptions?: Record<string, Record<string, any>>;
type: "file";
}
>;
providerOptions?: Record<string, Record<string, any>>;
role: "user";
}
| {
content:
| string
| Array<
| {
providerOptions?: Record<string, Record<string, any>>;
text: string;
type: "text";
}
| {
data: string | ArrayBuffer;
filename?: string;
mimeType: string;
providerOptions?: Record<string, Record<string, any>>;
type: "file";
}
| {
providerOptions?: Record<string, Record<string, any>>;
signature?: string;
state?: "streaming" | "done";
text: string;
type: "reasoning";
}
| {
data: string;
providerOptions?: Record<string, Record<string, any>>;
type: "redacted-reasoning";
}
| {
args: any;
providerExecuted?: boolean;
providerOptions?: Record<string, Record<string, any>>;
toolCallId: string;
toolName: string;
type: "tool-call";
}
>;
providerOptions?: Record<string, Record<string, any>>;
role: "assistant";
}
| {
content: Array<{
args?: any;
experimental_content?: Array<
| { text: string; type: "text" }
| { data: string; mimeType?: string; type: "image" }
>;
isError?: boolean;
providerExecuted?: boolean;
providerOptions?: Record<string, Record<string, any>>;
result: any;
toolCallId: string;
toolName: string;
type: "tool-result";
}>;
providerOptions?: Record<string, Record<string, any>>;
role: "tool";
}
| {
content: string;
providerOptions?: Record<string, Record<string, any>>;
role: "system";
};
model?: string;
order: number;
provider?: string;
providerMetadata?: Record<string, Record<string, any>>;
providerOptions?: Record<string, Record<string, any>>;
reasoning?: string;
reasoningDetails?: Array<
| {
providerOptions?: Record<string, Record<string, any>>;
signature?: string;
state?: "streaming" | "done";
text: string;
type: "reasoning";
}
| { signature?: string; text: string; type: "text" }
| { data: string; type: "redacted" }
>;
sources?: Array<
| {
id: string;
providerOptions?: Record<string, Record<string, any>>;
sourceType: "url";
title?: string;
type?: "source";
url: string;
}
| {
filename?: string;
id: string;
mediaType: string;
providerMetadata?: Record<string, Record<string, any>>;
sourceType: "document";
title: string;
type: "source";
}
>;
status: "pending" | "success" | "failed";
stepOrder: number;
text?: string;
threadId: string;
tool: boolean;
usage?: {
cachedInputTokens?: number;
completionTokens: number;
promptTokens: number;
reasoningTokens?: number;
totalTokens: number;
};
userId?: string;
warnings?: Array<
| { details?: string; setting: string; type: "unsupported-setting" }
| { details?: string; tool: any; type: "unsupported-tool" }
| { message: string; type: "other" }
>;
}>
>;
updateMessage: FunctionReference<
"mutation",
"public",
{
messageId: string;
patch: {
error?: string;
fileIds?: Array<string>;
finishReason?:
| "stop"
| "length"
| "content-filter"
| "tool-calls"
| "error"
| "other"
| "unknown";
message?:
| {
content:
| string
| Array<
| {
providerOptions?: Record<string, Record<string, any>>;
text: string;
type: "text";
}
| {
image: string | ArrayBuffer;
mimeType?: string;
providerOptions?: Record<string, Record<string, any>>;
type: "image";
}
| {
data: string | ArrayBuffer;
filename?: string;
mimeType: string;
providerOptions?: Record<string, Record<string, any>>;
type: "file";
}
>;
providerOptions?: Record<string, Record<string, any>>;
role: "user";
}
| {
content:
| string
| Array<
| {
providerOptions?: Record<string, Record<string, any>>;
text: string;
type: "text";
}
| {
data: string | ArrayBuffer;
filename?: string;
mimeType: string;
providerOptions?: Record<string, Record<string, any>>;
type: "file";
}
| {
providerOptions?: Record<string, Record<string, any>>;
signature?: string;
state?: "streaming" | "done";
text: string;
type: "reasoning";
}
| {
data: string;
providerOptions?: Record<string, Record<string, any>>;
type: "redacted-reasoning";
}
| {
args: any;
providerExecuted?: boolean;
providerOptions?: Record<string, Record<string, any>>;
toolCallId: string;
toolName: string;
type: "tool-call";
}
>;
providerOptions?: Record<string, Record<string, any>>;
role: "assistant";
}
| {
content: Array<{
args?: any;
experimental_content?: Array<
| { text: string; type: "text" }
| { data: string; mimeType?: string; type: "image" }
>;
isError?: boolean;
providerExecuted?: boolean;
providerOptions?: Record<string, Record<string, any>>;
result: any;
toolCallId: string;
toolName: string;
type: "tool-result";
}>;
providerOptions?: Record<string, Record<string, any>>;
role: "tool";
}
| {
content: string;
providerOptions?: Record<string, Record<string, any>>;
role: "system";
};
model?: string;
provider?: string;
providerOptions?: Record<string, Record<string, any>>;
status?: "pending" | "success" | "failed";
};
},
{
_creationTime: number;
_id: string;
agentName?: string;
embeddingId?: string;
error?: string;
fileIds?: Array<string>;
finishReason?:
| "stop"
| "length"
| "content-filter"
| "tool-calls"
| "error"
| "other"
| "unknown";
id?: string;
message?:
| {
content:
| string
| Array<
| {
providerOptions?: Record<string, Record<string, any>>;
text: string;
type: "text";
}
| {
image: string | ArrayBuffer;
mimeType?: string;
providerOptions?: Record<string, Record<string, any>>;
type: "image";
}
| {
data: string | ArrayBuffer;
filename?: string;
mimeType: string;
providerOptions?: Record<string, Record<string, any>>;
type: "file";
}
>;
providerOptions?: Record<string, Record<string, any>>;
role: "user";
}
| {
content:
| string
| Array<
| {
providerOptions?: Record<string, Record<string, any>>;
text: string;
type: "text";
}
| {
data: string | ArrayBuffer;
filename?: string;
mimeType: string;
providerOptions?: Record<string, Record<string, any>>;
type: "file";
}
| {
providerOptions?: Record<string, Record<string, any>>;
signature?: string;
state?: "streaming" | "done";
text: string;
type: "reasoning";
}
| {
data: string;
providerOptions?: Record<string, Record<string, any>>;
type: "redacted-reasoning";
}
| {
args: any;
providerExecuted?: boolean;
providerOptions?: Record<string, Record<string, any>>;
toolCallId: string;
toolName: string;
type: "tool-call";
}
>;
providerOptions?: Record<string, Record<string, any>>;
role: "assistant";
}
| {
content: Array<{
args?: any;
experimental_content?: Array<
| { text: string; type: "text" }
| { data: string; mimeType?: string; type: "image" }
>;
isError?: boolean;
providerExecuted?: boolean;
providerOptions?: Record<string, Record<string, any>>;
result: any;
toolCallId: string;
toolName: string;
type: "tool-result";
}>;
providerOptions?: Record<string, Record<string, any>>;
role: "tool";
}
| {
content: string;
providerOptions?: Record<string, Record<string, any>>;
role: "system";
};
model?: string;
order: number;
provider?: string;
providerMetadata?: Record<string, Record<string, any>>;
providerOptions?: Record<string, Record<string, any>>;
reasoning?: string;
reasoningDetails?: Array<
| {
providerOptions?: Record<string, Record<string, any>>;
signature?: string;
state?: "streaming" | "done";
text: string;
type: "reasoning";
}
| { signature?: string; text: string; type: "text" }
| { data: string; type: "redacted" }
>;
sources?: Array<
| {
id: string;
providerOptions?: Record<string, Record<string, any>>;
sourceType: "url";
title?: string;
type?: "source";
url: string;
}
| {
filename?: string;
id: string;
mediaType: string;
providerMetadata?: Record<string, Record<string, any>>;
sourceType: "document";
title: string;
type: "source";
}
>;
status: "pending" | "success" | "failed";
stepOrder: number;
text?: string;
threadId: string;
tool: boolean;
usage?: {
cachedInputTokens?: number;
completionTokens: number;
promptTokens: number;
reasoningTokens?: number;
totalTokens: number;
};
userId?: string;
warnings?: Array<
| { details?: string; setting: string; type: "unsupported-setting" }
| { details?: string; tool: any; type: "unsupported-tool" }
| { message: