import { type BgentRuntime } from "./runtime"; /** * Represents a UUID, which is a universally unique identifier conforming to the UUID standard. */ export type UUID = `${string}-${string}-${string}-${string}-${string}`; /** * Represents the content of a message, including its main text (`content`), any associated action (`action`), and the source of the content (`source`), if applicable. */ export interface Content { content: string; action?: string; source?: string; [key: string]: unknown; } /** * Represents an example of content, typically used for demonstrating or testing purposes. Includes user, content, optional action, and optional source. */ export interface ActionExample { user: string; content: Content; } /** * Represents an example of content, typically used for demonstrating or testing purposes. Includes user, content, optional action, and optional source. */ export interface ConversationExample { user_id: UUID; content: Content; } /** * Represents an actor in the conversation, which could be a user or the agent itself, including their name, details (such as tagline, summary, and quote), and a unique identifier. */ export interface Actor { name: string; details: { tagline: string; summary: string; quote: string; }; id: UUID; } /** * Represents a memory record, which could be a message or any other piece of information remembered by the system, including its content, associated user IDs, and optionally, its embedding vector for similarity comparisons. */ export interface Memory { id?: UUID; user_id: UUID; created_at?: string; content: Content; embedding?: number[]; room_id: UUID; } /** * Represents an objective within a goal, detailing what needs to be achieved and whether it has been completed. */ export interface Objective { id?: string; description: string; completed: boolean; } export declare enum GoalStatus { DONE = "DONE", FAILED = "FAILED", IN_PROGRESS = "IN_PROGRESS" } /** * Represents a goal, which is a higher-level aim composed of one or more objectives. Goals are tracked to measure progress or achievements within the conversation or system. */ export interface Goal { id?: UUID; room_id: UUID; user_id: UUID; name: string; status: GoalStatus; objectives: Objective[]; } /** * Represents the state of the conversation or context in which the agent is operating, including information about users, messages, goals, and other relevant data. */ export interface State { user_id?: UUID; agentId?: UUID; room_id: UUID; agentName?: string; senderName?: string; actors: string; actorsData?: Actor[]; goals?: string; goalsData?: Goal[]; recentMessages: string; recentMessagesData: Memory[]; recentFacts?: string; recentFactsData?: Memory[]; relevantFacts?: string; relevantFactsData?: Memory[]; actionNames?: string; actions?: string; actionsData?: Action[]; actionExamples?: string; providers?: string; responseData?: Content; [key: string]: unknown; } /** * Represents a message within the conversation, including its content and associated metadata such as the sender, agent, and room IDs. */ export interface Message { user_id: UUID; content: Content; room_id: UUID; } /** * Represents an example of a message, typically used for demonstrating or testing purposes, including optional content and action. */ export interface MessageExample { user: string; content: Content; } /** * Represents the type of a handler function, which takes a runtime instance, a message, and an optional state, and returns a promise resolving to any type. */ export type Handler = (runtime: BgentRuntime, message: Message, state?: State, options?: { [key: string]: unknown; }) => Promise; /** * Represents the type of a validator function, which takes a runtime instance, a message, and an optional state, and returns a promise resolving to a boolean indicating whether the validation passed. */ export type Validator = (runtime: BgentRuntime, message: Message, state?: State) => Promise; /** * Represents an action that the agent can perform, including conditions for its use, a description, examples, a handler function, and a validation function. */ export interface Action { condition: string; description: string; examples: ActionExample[][]; handler: Handler; name: string; validate: Validator; } /** * Represents an example for evaluation, including the context, an array of message examples, and the expected outcome. */ export interface EvaluationExample { context: string; messages: Array; outcome: string; } /** * Represents an evaluator, which is used to assess and guide the agent's responses based on the current context and state. */ export interface Evaluator { condition: string; description: string; examples: EvaluationExample[]; handler: Handler; name: string; validate: Validator; } /** * Represents a provider, which is used to retrieve information or perform actions on behalf of the agent, such as fetching data from an external API or service. */ export interface Provider { get: (runtime: BgentRuntime, message: Message, state?: State) => Promise; } /** * Represents a relationship between two users, including their IDs, the status of the relationship, and the room ID in which the relationship is established. */ export interface Relationship { id: UUID; user_a: UUID; user_b: UUID; user_id: UUID; room_id: UUID; status: string; created_at?: string; } /** * Represents a user, including their name, details, and a unique identifier. */ export interface Account { id: UUID; name: string; details?: { [key: string]: unknown; }; email?: string; avatar_url?: string; } /** * Represents a participant in a room, including their ID and account details. */ export interface Participant { id: UUID; account: Account; } /** * Represents a room or conversation context, including its ID and a list of participants. */ export interface Room { id: UUID; participants: Participant[]; }