@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, and professional CLI. Built-in tools operational, 58+ external MCP servers discoverable. Connect to filesystem, GitHub, database operations, and more. Build, test, and
150 lines (149 loc) • 4.24 kB
TypeScript
import type { Tool } from "ai";
import type { ValidationSchema, StandardRecord } from "./typeAliases.js";
import type { AIProviderName, AnalyticsData, EvaluationData } from "../core/types.js";
import type { UnknownRecord, JsonValue } from "./common.js";
import type { ChatMessage } from "./conversationTypes.js";
/**
* Interface for tool execution calls (AI SDK compatible)
*/
export interface ToolCall {
type?: "tool-call";
toolCallId?: string;
toolName: string;
parameters?: UnknownRecord;
args?: UnknownRecord;
id?: string;
}
/**
* Interface for tool execution results - Enhanced for type safety
*/
export interface ToolResult {
toolName: string;
status: "success" | "failure";
output?: JsonValue;
error?: string;
id?: string;
executionTime?: number;
metadata?: {
[key: string]: JsonValue;
} & {
serverId?: string;
toolCategory?: string;
isExternal?: boolean;
};
}
/**
* Tool Call Results Array - High Reusability
*/
export type ToolCallResults = Array<ToolResult>;
/**
* Tool Calls Array - High Reusability
*/
export type ToolCalls = Array<ToolCall>;
/**
* Stream Analytics Data - Enhanced for performance tracking
*/
export interface StreamAnalyticsData {
/** Tool execution results with timing */
toolResults?: Promise<ToolCallResults>;
/** Tool calls made during stream */
toolCalls?: Promise<ToolCalls>;
/** Stream performance metrics */
performance?: {
startTime: number;
endTime?: number;
chunkCount: number;
avgChunkSize: number;
totalBytes: number;
};
/** Provider analytics */
providerAnalytics?: AnalyticsData;
}
/**
* Stream function options interface - Primary method for streaming content
* Future-ready for multi-modal capabilities while maintaining text focus
*/
export interface StreamOptions {
input: {
text: string;
};
output?: {
format?: "text" | "structured" | "json";
streaming?: {
chunkSize?: number;
bufferSize?: number;
enableProgress?: boolean;
};
};
provider?: AIProviderName | string;
model?: string;
temperature?: number;
maxTokens?: number;
systemPrompt?: string;
schema?: ValidationSchema;
tools?: Record<string, Tool>;
timeout?: number | string;
disableTools?: boolean;
maxSteps?: number;
enableEvaluation?: boolean;
enableAnalytics?: boolean;
context?: UnknownRecord;
evaluationDomain?: string;
toolUsageContext?: string;
conversationHistory?: Array<{
role: string;
content: string;
}>;
factoryConfig?: {
domainType?: string;
domainConfig?: StandardRecord;
enhancementType?: "domain-configuration" | "streaming-optimization" | "mcp-integration" | "legacy-migration" | "context-conversion";
preserveLegacyFields?: boolean;
validateDomainData?: boolean;
};
streaming?: {
enabled?: boolean;
chunkSize?: number;
bufferSize?: number;
enableProgress?: boolean;
fallbackToGenerate?: boolean;
};
conversationMessages?: ChatMessage[];
}
/**
* Stream function result interface - Primary output format for streaming
* Future-ready for multi-modal outputs while maintaining text focus
*/
export interface StreamResult {
stream: AsyncIterable<{
content: string;
}>;
provider?: string;
model?: string;
usage?: {
inputTokens?: number;
outputTokens?: number;
totalTokens?: number;
};
finishReason?: string;
toolCalls?: ToolCall[];
toolResults?: ToolResult[];
metadata?: {
streamId?: string;
startTime?: number;
totalChunks?: number;
estimatedDuration?: number;
responseTime?: number;
fallback?: boolean;
};
analytics?: AnalyticsData | Promise<AnalyticsData>;
evaluation?: EvaluationData | Promise<EvaluationData>;
}
/**
* Enhanced provider interface with stream method
*/
export interface EnhancedStreamProvider {
stream(options: StreamOptions): Promise<StreamResult>;
getName(): string;
isAvailable(): Promise<boolean>;
}