anon-identity
Version:
Decentralized identity framework with DIDs, Verifiable Credentials, and privacy-preserving selective disclosure
168 lines • 4.02 kB
TypeScript
/**
* Function Adapter for MCP
*
* Converts between different provider function calling formats
*/
import { FunctionDefinition, FunctionCall } from '../types';
/**
* OpenAI function format
*/
export interface OpenAIFunction {
name: string;
description: string;
parameters: {
type: 'object';
properties: Record<string, any>;
required?: string[];
};
}
export interface OpenAIFunctionCall {
name: string;
arguments: string;
}
/**
* Anthropic function format
*/
export interface AnthropicTool {
name: string;
description: string;
input_schema: {
type: 'object';
properties: Record<string, any>;
required?: string[];
};
}
export interface AnthropicToolUse {
type: 'tool_use';
id: string;
name: string;
input: Record<string, any>;
}
/**
* Google function format
*/
export interface GoogleFunction {
name: string;
description: string;
parameters: {
type: 'object';
properties: Record<string, any>;
required?: string[];
};
}
/**
* Provider types
*/
export type ProviderType = 'openai' | 'anthropic' | 'google' | 'generic';
/**
* Function adapter configuration
*/
export interface FunctionAdapterConfig {
strictValidation: boolean;
preserveMetadata: boolean;
sanitizeArguments: boolean;
maxArgumentSize: number;
}
/**
* Function Adapter
*/
export declare class FunctionAdapter {
private config;
constructor(config?: FunctionAdapterConfig);
/**
* Convert MCP function definition to provider format
*/
toProviderFormat(definition: FunctionDefinition, providerType: ProviderType): any;
/**
* Convert provider function call to MCP format
*/
fromProviderCall(providerCall: any, providerType: ProviderType): FunctionCall;
/**
* Convert provider format to MCP function definition
*/
fromProviderFormat(providerFunction: any, providerType: ProviderType): FunctionDefinition;
/**
* Batch convert function definitions
*/
batchToProviderFormat(definitions: FunctionDefinition[], providerType: ProviderType): any[];
/**
* Convert to OpenAI format
*/
private toOpenAIFormat;
/**
* Convert from OpenAI format
*/
private fromOpenAIFormat;
/**
* Convert from OpenAI function call
*/
private fromOpenAICall;
/**
* Convert to Anthropic format
*/
private toAnthropicFormat;
/**
* Convert from Anthropic format
*/
private fromAnthropicFormat;
/**
* Convert from Anthropic tool use
*/
private fromAnthropicCall;
/**
* Convert to Google format
*/
private toGoogleFormat;
/**
* Convert from Google format
*/
private fromGoogleFormat;
/**
* Convert from Google function call
*/
private fromGoogleCall;
/**
* Convert parameter definitions between formats
*/
private convertParameters;
/**
* Convert single parameter definition
*/
private convertSingleParameter;
/**
* Validate OpenAI function
*/
private validateOpenAIFunction;
/**
* Validate parameters structure
*/
private validateParametersStructure;
/**
* Sanitize function arguments
*/
private sanitizeArguments;
/**
* Sanitize individual value
*/
private sanitizeValue;
/**
* Get supported provider types
*/
getSupportedProviders(): ProviderType[];
/**
* Check if provider supports feature
*/
supportsFeature(providerType: ProviderType, feature: string): boolean;
/**
* Get provider constraints
*/
getProviderConstraints(providerType: ProviderType): {
maxFunctionNameLength: number;
maxDescriptionLength: number;
maxParameters: number;
maxNestingDepth: number;
supportedTypes: string[];
};
}
export default FunctionAdapter;
//# sourceMappingURL=function-adapter.d.ts.map