/** * @mzhub/plexus - Shared Types * Core interfaces shared between client, server, and AI runtime */ import type { ZodType } from "zod"; export interface Intent { id: string; text: string; context?: Record; timestamp: number; } export interface ToolContext { sessionId: string; userId?: string; userRole?: "user" | "admin" | "service"; isInternalRequest?: boolean; requireHumanApproval: (message: string) => Promise; emit: (event: string, data: unknown) => void; } export interface ToolResult { success: boolean; data?: T; error?: string; } export interface ToolDefinition { name: string; description: string; schema: ZodType; critical?: boolean; requiredRole?: "admin" | "service"; internal?: boolean; timeout?: number; execute: (args: TInput, ctx: ToolContext) => Promise>; } export declare const DEFAULT_TOOL_TIMEOUT = 10000; export interface OpenAITool { type: "function"; function: { name: string; description: string; parameters: Record; }; } export type MessageRole = "system" | "user" | "assistant" | "tool"; export interface Message { role: MessageRole; content: string | null; tool_calls?: ToolCall[]; tool_call_id?: string; } export interface ToolCall { id: string; type: "function"; function: { name: string; arguments: string; }; } export interface AgentConfig { provider: AIProvider; tools: ToolDefinition[]; plugins?: AgentPluginRef[]; requireAuth?: boolean; maxIterations?: number; maxCost?: number; costPerToken?: number; maxTokens?: number; sessionMemory?: boolean; maxHistoryMessages?: number; onThinking?: (thought: string) => void; onToolCall?: (name: string, args: unknown) => void; onToolResult?: (name: string, result: ToolResult) => void; } export interface AgentPluginRef { name: string; hooks?: { beforeRequest?: (messages: Message[], ctx: unknown) => Promise | Message[]; afterResponse?: (result: AgentResult, ctx: unknown) => Promise | AgentResult; onToolCall?: (tool: ToolCall, ctx: unknown) => Promise | void; }; } export interface AgentResult { content: string | null; messages: Message[]; iterations: number; aborted: boolean; } export interface AIProvider { name: string; chat: (options: ChatOptions) => Promise; stream?: (options: ChatOptions) => AsyncGenerator; } export interface ChatOptions { messages: Message[]; tools?: OpenAITool[]; tool_choice?: "auto" | "none" | { type: "function"; function: { name: string; }; }; temperature?: number; max_tokens?: number; } export interface ChatResponse { choices: Array<{ message: Message; finish_reason: string; }>; usage?: { prompt_tokens: number; completion_tokens: number; total_tokens: number; }; } export interface SemanticElement { selector: string; tagName: string; text?: string; attributes?: Record; isInteractive: boolean; isVisible: boolean; rect?: DOMRect; agentHint?: string; } export interface DomSnapshot { url: string; title: string; viewport: { width: number; height: number; }; elements: SemanticElement[]; timestamp: number; } export interface SessionInfo { id: string; userId?: string; createdAt: number; lastActivity: number; isViewing: boolean; } export type FrameworkEvent = "AGENT_THINKING" | "AGENT_TOOL_CALL" | "AGENT_TOOL_RESULT" | "AGENT_RESPONSE" | "AGENT_ERROR" | "DOM_UPDATE" | "CONFIRM_ACTION" | "HANDOFF_REQUEST"; //# sourceMappingURL=types.d.ts.map