export type SerializablePrimitive = string | number | boolean | null | undefined; export type SerializableObject = { [key: string]: Serializable; }; export type Serializable = SerializablePrimitive | Array | SerializableObject; type AbortDispatcher = () => void; /** * Abort the current stream from the action. */ export declare const abort: AbortDispatcher; export type NodeData = SerializableObject; export type OutputEvent = { type: string; data: T | Partial | Partial; stream?: boolean; }; type OutputDispatcher = (event: OutputEvent) => void; export declare const output: OutputDispatcher; type SessionIdReader = () => string; export declare const sessionId: SessionIdReader; type EnvReader = (envName: string) => Promise; /** * Retrieves an environment value by name. If the value is not found, * the user is prompted to enter the environment variable. */ export declare const env: EnvReader; export declare const collection: CollectionDocumentConnector; export type CollectionDocumentConnector = (collectionName: Lowercase) => CollectionOperations; export interface CollectionOperations { get:

(id: string, options?: { properties?: P[]; }) => Promise | undefined>; getProperty:

(id: string, properyName: P) => Promise; set: (data: CollectionDocumentSet, options?: O) => Promise; setProperty:

(id: string, properyName: P, value: T[P]) => Promise<{ id: string; }>; query:

(...properties: P[]) => QueryBuilder; delete: (id: string) => Promise; } export type QueryOperators = "==" | "!=" | "<" | "<=" | ">" | ">="; export type CollectionDocumentQueryResult = { items: Array & { id: string; }>; }; export interface QueryBuilder { select(...properties: K[]): QueryBuilder; eq(property: K, value: T[K]): QueryBuilder; lt(property: K, value: T[K]): QueryBuilder; lte(property: K, value: T[K]): QueryBuilder; gt(property: K, value: T[K]): QueryBuilder; gte(property: K, value: T[K]): QueryBuilder; or(): QueryBuilder; orderBy(property: keyof T, direction?: OrderByDirection): QueryBuilder; limit(count: number): QueryBuilder; offset(index: number): QueryBuilder; first(): Promise | undefined>; execute(): Promise>; } export interface CollectionDocumentQuery { conditions?: QueryCondition[][]; properties?: string[]; orderBy?: OrderBy[]; limit?: number; offset?: number; } export type OrderBy = [keyof T] | [keyof T, OrderByDirection | undefined]; export type OrderByDirection = "asc" | "desc"; export type QueryCondition = [keyof T, QueryOperators, any]; export type CollectionDocumentSet = Omit & { id?: string; }; export interface DocumentSetResult { id: string; } export interface Message { /** * The identifier, which can be referenced in API endpoints. */ id: string; /** * The content of the message in array of text and/or images. */ content: ContentPart[]; /** * The Unix timestamp (in seconds) for when the message was created. */ created_at: number; /** * The Unix timestamp (in seconds) for when the message was marked as incomplete. */ incomplete_at: number | null; /** * On an incomplete message, details about why the message is incomplete. */ incomplete_details: Message.IncompleteDetails | null; /** * The entity that produced the message. One of `user` or `assistant`. */ role: "user" | "assistant"; /** * The status of the message, which can be either `in_progress`, `incomplete`, or * `completed`. */ status: "in_progress" | "incomplete" | "completed"; /** * The thread ID that this message belongs to. */ thread_id: string; } export declare namespace Message { /** * On an incomplete message, details about why the message is incomplete. */ interface IncompleteDetails { /** * The reason the message is incomplete. */ reason: "content_filter" | "max_tokens" | "run_cancelled" | "run_expired" | "run_failed"; } } /** * A MessageParam is a message that is initially provided by the user and not yet stored * in the document store. A MessageParam does not need to have an "id" property, whereas a Message * must have an "id" property set, which can only be provided by the store. * A MessageParam must have a "role" property, which can be either "user", "assistant", or "system". */ export type MessageParam = SystemMessageParam | UserMessageParam | AssistantMessageParam; export interface SystemMessageParam { /** * The contents of the system message. */ content: string | ContentPartText[]; /** * The role of the messages author, in this case `system`. */ role: "system"; /** * An optional name for the participant. Provides the model information to * differentiate between participants of the same role. */ name?: string; id?: string; cache?: boolean; } export interface UserMessageParam { /** * The contents of the user message. */ content: string | ContentPart[]; /** * The role of the messages author, in this case `user`. */ role: "user"; /** * An optional name for the participant. Provides the model information to * differentiate between participants of the same role. */ name?: string; id?: string; cache?: boolean; } export interface AssistantMessageParam { /** * The role of the messages author, in this case `assistant`. */ role: "assistant"; /** * The contents of the assistant message. */ content?: string | ContentPartText[] | null; /** * An optional name for the participant. Provides the model information to * differentiate between participants of the same role. */ name?: string; id?: string; cache?: boolean; } export type ContentPart = ContentPartText | ContentPartImage; export interface ContentPartImage { image_url: ContentPartImage.ImageURL; /** * The type of the content part. */ type: "image_url"; } export declare namespace ContentPartImage { interface ImageURL { /** * Either a URL of the image or the base64 encoded image data. */ url: string; /** * Specifies the detail level of the image. Learn more in the * [Vision guide](https://platform.openai.com/docs/guides/vision/low-or-high-fidelity-image-understanding). */ detail?: "auto" | "low" | "high"; } } export interface ContentPartText { /** * The text content. */ text: string; /** * The type of the content part. */ type: "text"; } export interface Thread { messages: MessageParam[]; } /** * Returns an array of valid Message objects. */ export declare function getMessages(messages: any): Message[]; /** * Returns an array of valid MessageParam objects. A Message object will be converted to a MessageParam. * * This is useful when passing a list of messages to an API endpoint since the endpoint may only accept * MessageParam objects. */ export declare function getMessageParams(messages: (Message | MessageParam)[]): MessageParam[]; /** * Returns the last user message from a list of valid messages. */ export declare function getUserMessage(messages: (Message | MessageParam)[]): UserMessageParam; /** * Returns the last assistant message from a list of valid messages. */ export declare function getAssistantMessage(messages: (Message | MessageParam)[]): Message | undefined; /** * Returns the text content of a message. For example, if the message is a user message, which * has an array of content parts, this will return the concatenated text of all the parts. */ export declare function getMessageText(message: { content?: ContentPart[] | string | null | undefined; }): string; /** * Indicates whether the message is valid or not. * A Message must already have the "id" property set, which can only be provided by the store. * A Message must have a "role" property, which can be either "user", or "assistant". */ export declare function isMessage(message: Message): boolean; /** * Indicates whether the message param is valid or not. A MessageParam is a message that is * initially provided by the user and not yet stored in the document store. * A MessageParam does not need to have an "id" property, as it is not a required field. * A MessageParam must have a "role" property, which can be either "user", "assistant", or "system". */ export declare function isMessageParam(messageParam: MessageParam): boolean; export declare function isUserMessage(message: Message): boolean; export declare function isUserMessageParam(messageParam: MessageParam | Message): boolean; export declare function isMessageContentParam(content: ContentPart): boolean; export declare function isAssistantMessage(message: Message): boolean; export declare function isAssistantMessageParam(messageParam: MessageParam): boolean; export declare function isSystemMessageParam(messageParam: MessageParam): boolean; export declare function convertContentPartToText(content: string | ContentPart[] | null | undefined): string; export {};