UNPKG

loom-agents

Version:

A lightweight, composable framework for building hierarchical AI agent systems using OpenAI's API.

60 lines (59 loc) 1.8 kB
import { ChatCompletionMessageParam } from "openai/resources/chat"; import { ResponseInputItem } from "openai/resources/responses/responses"; import { MCPServerSSE, MCPServerStdio } from "../MCP/MCP.js"; import { ClientOptions } from "openai"; import { TraceSession } from "../TraceSession/TraceSession.js"; export interface ToolCall { name: string; parameters: Record<string, any>; callback: (...args: any[]) => any; description: string; } export interface WebSearchConfig { enabled: boolean; config?: { search_context_size?: "high" | "medium" | "low"; user_location?: { type: "approximate"; country?: string; city?: string; region?: string; }; }; } export interface AgentConfig { name: string; purpose: string; sub_agents?: Agent[]; tools?: ToolCall[]; mcp_servers?: (MCPServerSSE | MCPServerStdio)[]; model?: string; web_search?: WebSearchConfig; timeout_ms?: number; client_config?: ClientOptions; api?: "completions" | "responses"; } export interface AgentRequest<T> { context: T[]; } export interface AgentResponse<T> { status: string; final_message: string; context: T[]; } export declare class Agent { uuid: string; private config; private defaultModel; private defaultTimeout; private _client; private _api; constructor(config: AgentConfig); private get client(); private prepareTools; private ToolsToCompletionTools; private run_completions; private run_responses; run(input: string | AgentRequest<ResponseInputItem | ChatCompletionMessageParam>, trace?: TraceSession): Promise<AgentResponse<ResponseInputItem | ChatCompletionMessageParam>>; asTool(parameters?: object): ToolCall; }