UNPKG

@convex-dev/agent

Version:

A agent component for Convex.

1,325 lines (1,323 loc) 106 kB
/* eslint-disable */ /** * Generated `ComponentApi` utility. * * THIS CODE IS AUTOMATICALLY GENERATED. * * To regenerate, run `npx convex dev`. * @module */ import type { FunctionReference } from "convex/server"; /** * A utility for referencing a Convex component's exposed API. * * Useful when expecting a parameter like `components.myComponent`. * Usage: * ```ts * async function myFunction(ctx: QueryCtx, component: ComponentApi) { * return ctx.runQuery(component.someFile.someQuery, { ...args }); * } * ``` */ export type ComponentApi<Name extends string | undefined = string | undefined> = { apiKeys: { destroy: FunctionReference< "mutation", "internal", { apiKey?: string; name?: string }, | "missing" | "deleted" | "name mismatch" | "must provide either apiKey or name", Name >; issue: FunctionReference< "mutation", "internal", { name?: string }, string, Name >; validate: FunctionReference< "query", "internal", { apiKey: string }, boolean, Name >; }; files: { addFile: FunctionReference< "mutation", "internal", { filename?: string; hash: string; mimeType: string; storageId: string; }, { fileId: string; storageId: string }, Name >; copyFile: FunctionReference< "mutation", "internal", { fileId: string }, null, Name >; deleteFiles: FunctionReference< "mutation", "internal", { fileIds: Array<string>; force?: boolean }, Array<string>, Name >; get: FunctionReference< "query", "internal", { fileId: string }, null | { _creationTime: number; _id: string; filename?: string; hash: string; lastTouchedAt: number; mimeType: string; refcount: number; storageId: string; }, Name >; getFilesToDelete: FunctionReference< "query", "internal", { 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; }>; }, Name >; useExistingFile: FunctionReference< "mutation", "internal", { filename?: string; hash: string }, null | { fileId: string; storageId: string }, Name >; }; messages: { addMessages: FunctionReference< "mutation", "internal", { agentName?: string; embeddings?: { dimension: | 128 | 256 | 512 | 768 | 1024 | 1408 | 1536 | 2048 | 3072 | 4096; model: string; vectors: Array<Array<number> | null>; }; failPendingSteps?: boolean; hideFromUserIdSearch?: boolean; messages: Array<{ error?: string; fileIds?: Array<string>; finishReason?: | "stop" | "length" | "content-filter" | "tool-calls" | "error" | "other" | "unknown"; message: | { content: | string | Array< | { providerMetadata?: Record< string, Record<string, any> >; 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; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; type: "file"; } >; providerOptions?: Record<string, Record<string, any>>; role: "user"; } | { content: | string | Array< | { providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; text: string; type: "text"; } | { data: string | ArrayBuffer; filename?: string; mimeType: string; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; type: "file"; } | { providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; signature?: string; text: string; type: "reasoning"; } | { data: string; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; type: "redacted-reasoning"; } | { args: any; providerExecuted?: boolean; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; toolCallId: string; toolName: string; type: "tool-call"; } | { args?: any; experimental_content?: Array< | { text: string; type: "text" } | { data: string; mimeType?: string; type: "image"; } >; isError?: boolean; output?: | { type: "text"; value: string } | { type: "json"; value: any } | { type: "error-text"; value: string } | { type: "error-json"; value: any } | { type: "content"; value: Array< | { text: string; type: "text" } | { data: string; mediaType: string; type: "media"; } >; }; providerExecuted?: boolean; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; result?: any; toolCallId: string; toolName: string; type: "tool-result"; } | { id: string; providerMetadata?: Record< string, Record<string, any> >; 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> >; providerOptions?: Record< string, Record<string, any> >; sourceType: "document"; title: string; type: "source"; } >; 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; output?: | { type: "text"; value: string } | { type: "json"; value: any } | { type: "error-text"; value: string } | { type: "error-json"; value: any } | { type: "content"; value: Array< | { text: string; type: "text" } | { data: string; mediaType: string; type: "media" } >; }; providerExecuted?: boolean; providerMetadata?: Record<string, Record<string, any>>; 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< | { providerMetadata?: Record<string, Record<string, any>>; providerOptions?: Record<string, Record<string, any>>; signature?: string; text: string; type: "reasoning"; } | { signature?: string; text: string; type: "text" } | { data: string; type: "redacted" } >; sources?: Array< | { id: string; providerMetadata?: Record<string, Record<string, any>>; 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>>; providerOptions?: 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< | { providerMetadata?: Record< string, Record<string, any> >; 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; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; type: "file"; } >; providerOptions?: Record<string, Record<string, any>>; role: "user"; } | { content: | string | Array< | { providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; text: string; type: "text"; } | { data: string | ArrayBuffer; filename?: string; mimeType: string; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; type: "file"; } | { providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; signature?: string; text: string; type: "reasoning"; } | { data: string; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; type: "redacted-reasoning"; } | { args: any; providerExecuted?: boolean; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; toolCallId: string; toolName: string; type: "tool-call"; } | { args?: any; experimental_content?: Array< | { text: string; type: "text" } | { data: string; mimeType?: string; type: "image"; } >; isError?: boolean; output?: | { type: "text"; value: string } | { type: "json"; value: any } | { type: "error-text"; value: string } | { type: "error-json"; value: any } | { type: "content"; value: Array< | { text: string; type: "text" } | { data: string; mediaType: string; type: "media"; } >; }; providerExecuted?: boolean; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; result?: any; toolCallId: string; toolName: string; type: "tool-result"; } | { id: string; providerMetadata?: Record< string, Record<string, any> >; 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> >; providerOptions?: Record< string, Record<string, any> >; sourceType: "document"; title: string; type: "source"; } >; 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; output?: | { type: "text"; value: string } | { type: "json"; value: any } | { type: "error-text"; value: string } | { type: "error-json"; value: any } | { type: "content"; value: Array< | { text: string; type: "text" } | { data: string; mediaType: string; type: "media" } >; }; providerExecuted?: boolean; providerMetadata?: Record<string, Record<string, any>>; 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< | { providerMetadata?: Record<string, Record<string, any>>; providerOptions?: Record<string, Record<string, any>>; signature?: string; text: string; type: "reasoning"; } | { signature?: string; text: string; type: "text" } | { data: string; type: "redacted" } >; sources?: Array< | { id: string; providerMetadata?: Record<string, Record<string, any>>; 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>>; providerOptions?: 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" } >; }>; }, Name >; cloneThread: FunctionReference< "action", "internal", { batchSize?: number; copyUserIdForVectorSearch?: boolean; excludeToolMessages?: boolean; insertAtOrder?: number; limit?: number; sourceThreadId: string; statuses?: Array<"pending" | "success" | "failed">; targetThreadId: string; upToAndIncludingMessageId?: string; }, number, Name >; deleteByIds: FunctionReference< "mutation", "internal", { messageIds: Array<string> }, Array<string>, Name >; deleteByOrder: FunctionReference< "mutation", "internal", { endOrder: number; endStepOrder?: number; startOrder: number; startStepOrder?: number; threadId: string; }, { isDone: boolean; lastOrder?: number; lastStepOrder?: number }, Name >; finalizeMessage: FunctionReference< "mutation", "internal", { messageId: string; result: { status: "success" } | { error: string; status: "failed" }; }, null, Name >; getMessagesByIds: FunctionReference< "query", "internal", { 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< | { providerMetadata?: Record< string, Record<string, any> >; 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; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record<string, Record<string, any>>; type: "file"; } >; providerOptions?: Record<string, Record<string, any>>; role: "user"; } | { content: | string | Array< | { providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record<string, Record<string, any>>; text: string; type: "text"; } | { data: string | ArrayBuffer; filename?: string; mimeType: string; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record<string, Record<string, any>>; type: "file"; } | { providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record<string, Record<string, any>>; signature?: string; text: string; type: "reasoning"; } | { data: string; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record<string, Record<string, any>>; type: "redacted-reasoning"; } | { args: any; providerExecuted?: boolean; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record<string, Record<string, any>>; toolCallId: string; toolName: string; type: "tool-call"; } | { args?: any; experimental_content?: Array< | { text: string; type: "text" } | { data: string; mimeType?: string; type: "image" } >; isError?: boolean; output?: | { type: "text"; value: string } | { type: "json"; value: any } | { type: "error-text"; value: string } | { type: "error-json"; value: any } | { type: "content"; value: Array< | { text: string; type: "text" } | { data: string; mediaType: string; type: "media"; } >; }; providerExecuted?: boolean; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record<string, Record<string, any>>; result?: any; toolCallId: string; toolName: string; type: "tool-result"; } | { id: string; providerMetadata?: Record< string, Record<string, any> >; 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> >; providerOptions?: Record<string, Record<string, any>>; sourceType: "document"; title: string; type: "source"; } >; 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; output?: | { type: "text"; value: string } | { type: "json"; value: any } | { type: "error-text"; value: string } | { type: "error-json"; value: any } | { type: "content"; value: Array< | { text: string; type: "text" } | { data: string; mediaType: string; type: "media" } >; }; providerExecuted?: boolean; providerMetadata?: Record<string, Record<string, any>>; 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< | { providerMetadata?: Record<string, Record<string, any>>; providerOptions?: Record<string, Record<string, any>>; signature?: string; text: string; type: "reasoning"; } | { signature?: string; text: string; type: "text" } | { data: string; type: "redacted" } >; sources?: Array< | { id: string; providerMetadata?: Record<string, Record<string, any>>; 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>>; providerOptions?: 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" } >; }>, Name >; getMessageSearchFields: FunctionReference< "query", "internal", { messageId: string }, { embedding?: Array<number>; embeddingModel?: string; text?: string }, Name >; listMessagesByThreadId: FunctionReference< "query", "internal", { 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< | { providerMetadata?: Record< string, Record<string, any> >; 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; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; type: "file"; } >; providerOptions?: Record<string, Record<string, any>>; role: "user"; } | { content: | string | Array< | { providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; text: string; type: "text"; } | { data: string | ArrayBuffer; filename?: string; mimeType: string; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; type: "file"; } | { providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; signature?: string; text: string; type: "reasoning"; } | { data: string; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; type: "redacted-reasoning"; } | { args: any; providerExecuted?: boolean; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; toolCallId: string; toolName: string; type: "tool-call"; } | { args?: any; experimental_content?: Array< | { text: string; type: "text" } | { data: string; mimeType?: string; type: "image"; } >; isError?: boolean; output?: | { type: "text"; value: string } | { type: "json"; value: any } | { type: "error-text"; value: string } | { type: "error-json"; value: any } | { type: "content"; value: Array< | { text: string; type: "text" } | { data: string; mediaType: string; type: "media"; } >; }; providerExecuted?: boolean; providerMetadata?: Record< string, Record<string, any> >; providerOptions?: Record< string, Record<string, any> >; result?: any; toolCallId: string; toolName: string; type: "tool-result"; } | { id: string; providerMetadata?: Record< string, Record<string, any> >; 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> >; providerOptions?: Record< string, Record<string, any> >; sourceType: "document"; title: string; type: "source"; } >; 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; output?: | { type: "text"; value: string } | { type: "json"; value: any } | { type: "error-text"; value: string } | { type: "error-json"; value: any } | { type: "content"; value: Array< | { text: string; type: "text" } | { data: string; mediaType: string