UNPKG

jorel

Version:

A unified wrapper for working with LLMs from multiple providers, including streams, images, documents & automatic tool use.

76 lines (75 loc) 2.62 kB
import { Nullable } from "../shared"; import { LlmAssistantMessage, LlmAssistantMessageWithToolCalls, LlmToolCall, LlmToolCallApprovalState, LlmUserMessage } from "../providers"; import { JorElAgentManager } from "../jorel/jorel.team"; import { LlmAgent } from "./agent"; import { TaskExecutionThreadEvent } from "./task-execution-thread-event"; export interface TaskExecutionThreadDefinition { id: string; agentId: string; messages: (LlmUserMessage | LlmAssistantMessage | LlmAssistantMessageWithToolCalls)[]; parentThreadId: Nullable<string>; parentToolCallId: Nullable<string>; events: TaskExecutionThreadEvent[]; modified: boolean; } /** * Represents an execution thread (messages along with the responsible agent) within a task execution */ export declare class TaskExecutionThread { id: string; agentId: string; messages: (LlmUserMessage | LlmAssistantMessage | LlmAssistantMessageWithToolCalls)[]; parentThreadId: Nullable<string>; parentToolCallId: Nullable<string>; readonly events: TaskExecutionThreadEvent[]; modified: boolean; /** * Create a new task execution thread * @param data * @param jorEl */ constructor(data: TaskExecutionThreadDefinition, jorEl: JorElAgentManager); /** * Whether this thread is the main thread */ get isMain(): boolean; /** * Get the agent instance for this thread */ get agent(): Nullable<LlmAgent>; /** * Get the last message in this thread */ get latestMessage(): LlmUserMessage | LlmAssistantMessage | LlmAssistantMessageWithToolCalls; /** * Get the definition of this task execution thread */ get definition(): TaskExecutionThreadDefinition; /** * Create a new instance of this thread - e.g. to avoid modifying the original */ get copy(): TaskExecutionThread; /** * Get the pending approvals for this thread */ get toolCallsWithPendingApprovals(): (LlmToolCall & { messageId: string; threadId: string; })[]; /** * Approve or reject tool calls * @param messageId * @param toolCallIds * @param approvalState */ approveOrRejectToolCalls(messageId: string, toolCallIds: string[], approvalState: LlmToolCallApprovalState): void; /** * Add an event to this thread’s event list. */ addEvent(event: TaskExecutionThreadEvent): void; /** * Add a message to this thread * @param message */ addMessage(message: LlmUserMessage | LlmAssistantMessage | LlmAssistantMessageWithToolCalls): void; }