/** * Shared types for all AI framework adapters. * * These types define the common interface that all adapters consume, * as well as the output shapes for each supported framework. */ /** * JSON Schema representation (subset used for tool parameter definitions). */ export interface JSONSchema { type: string; properties?: Record; required?: readonly string[]; description?: string; items?: JSONSchema; enum?: readonly string[]; additionalProperties?: boolean | JSONSchema; } /** * Result returned from executing a bash tool call. */ export interface ToolExecutionResult { stdout: string; stderr: string; exitCode: number; } /** * Error result returned when execution fails. */ export interface ToolExecutionError { error: string; exitCode: number; } /** * Union of possible execution outcomes. */ export type ToolResult = ToolExecutionResult | ToolExecutionError; /** * A single tool definition with its execution logic. */ export interface ToolDefinition { name: string; description: string; inputSchema: JSONSchema; execute: (args: Record) => Promise; } /** * OpenAI function calling format. */ export interface OpenAIToolSet { tools: Array<{ type: "function"; function: { name: string; description: string; parameters: JSONSchema; }; }>; handleToolCall(name: string, args: string): Promise; } /** * Anthropic tool_use format. */ export interface AnthropicToolSet { tools: Array<{ name: string; description: string; input_schema: JSONSchema; }>; handleToolUse(name: string, input: Record): Promise<{ content: string; }>; } /** * LangChain DynamicStructuredTool-compatible format. */ export interface LangChainToolDef { name: string; description: string; schema: { parse: (input: unknown) => Record; _def: { typeName: string; }; }; func: (input: Record) => Promise; } export interface LangChainToolSet { tools: LangChainToolDef[]; } /** * Vercel AI SDK format. */ export interface VercelToolSet { tools: Record) => Promise; }>; } /** * Generic framework-agnostic format. */ export interface GenericToolSet { tools: ToolDefinition[]; handleCall(name: string, args: Record): Promise; }