@bobmatnyc/ai-code-review
Version:
A TypeScript-based tool for automated code reviews using AI models from Google Gemini, Anthropic Claude, and OpenRouter
108 lines (107 loc) • 3.29 kB
TypeScript
/**
* @fileoverview Tool calling abstractions for LLM clients
*
* This module provides interfaces and utilities for tool calling
* across different LLM providers.
*/
import { PackageInfo } from '../../utils/dependencies/packageAnalyzer';
import { DependencySecurityInfo } from '../../utils/dependencies/serpApiHelper';
/**
* Base interface for all tool definitions
*/
export interface ToolDefinition {
type: string;
name: string;
description: string;
}
/**
* Function-style tool definition (OpenAI style)
*/
export interface FunctionToolDefinition extends ToolDefinition {
type: 'function';
parameters: {
type: string;
properties: Record<string, any>;
required?: string[];
};
}
/**
* Result of a tool call
*/
export interface ToolCallResult {
toolName: string;
result: any;
}
/**
* Definition for the dependency security search tool
*/
export declare const DEPENDENCY_SECURITY_TOOL: FunctionToolDefinition;
/**
* Definition for the batch dependency security search tool
*/
export declare const BATCH_DEPENDENCY_SECURITY_TOOL: FunctionToolDefinition;
/**
* Define all available tools
*/
export declare const ALL_TOOLS: FunctionToolDefinition[];
/**
* Interface for tool calling handlers for each LLM provider
*/
export interface ToolCallingHandler {
/**
* Prepare tool definitions in the format expected by the LLM provider
* @param tools The tools to prepare
* @returns The prepared tools
*/
prepareTools(tools: FunctionToolDefinition[]): any;
/**
* Process a tool call response from the LLM
* @param response The LLM response
* @returns The processed tool calls
*/
processToolCallsFromResponse(response: any): {
toolCalls: Array<{
id?: string;
name: string;
arguments: any;
}>;
responseMessage: string;
};
/**
* Create the final request with tool results
* @param conversation The conversation so far
* @param toolResults The results of the tool calls
* @returns The final request
*/
createToolResultsRequest(conversation: Array<{
role: string;
content: string | null;
toolCalls?: any;
toolCallId?: string;
name?: string;
}>, toolResults: ToolCallResult[]): any;
}
/**
* Helper to extract package information from tool call arguments
* @param args The tool call arguments
* @returns The package information
*/
export declare function packageInfoFromToolArgs(args: any): PackageInfo;
/**
* Helper to extract package information from batch tool call arguments
* @param args The tool call arguments
* @returns The package information array
*/
export declare function packageInfosFromBatchToolArgs(args: any): PackageInfo[];
/**
* Format dependency security information for the model
* @param info The security information
* @returns Formatted information
*/
export declare function formatDependencySecurityInfo(info: DependencySecurityInfo | null): string;
/**
* Format batch dependency security information for the model
* @param infos The security information array
* @returns Formatted information
*/
export declare function formatBatchDependencySecurityInfo(infos: DependencySecurityInfo[]): string;