@juspay/neurolink 7.49.0 → 7.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +12 -9
- package/dist/adapters/providerImageAdapter.js +82 -10
- package/dist/agent/directTools.d.ts +10 -10
- package/dist/agent/directTools.js +5 -3
- package/dist/cli/commands/config.js +1 -0
- package/dist/cli/commands/mcp.js +1 -0
- package/dist/cli/commands/models.js +1 -0
- package/dist/cli/commands/ollama.js +1 -0
- package/dist/cli/commands/setup-anthropic.js +1 -0
- package/dist/cli/commands/setup-azure.js +1 -0
- package/dist/cli/commands/setup-bedrock.js +1 -0
- package/dist/cli/commands/setup-gcp.js +1 -0
- package/dist/cli/commands/setup-google-ai.js +1 -0
- package/dist/cli/commands/setup-huggingface.js +1 -0
- package/dist/cli/commands/setup-mistral.js +1 -0
- package/dist/cli/commands/setup-openai.js +1 -0
- package/dist/cli/commands/setup.js +1 -0
- package/dist/cli/errorHandler.js +1 -0
- package/dist/cli/factories/commandFactory.d.ts +5 -0
- package/dist/cli/factories/commandFactory.js +42 -6
- package/dist/cli/factories/ollamaCommandFactory.js +1 -0
- package/dist/cli/factories/sagemakerCommandFactory.js +1 -0
- package/dist/cli/factories/setupCommandFactory.js +1 -0
- package/dist/cli/index.js +14 -2
- package/dist/cli/loop/conversationSelector.js +1 -0
- package/dist/cli/loop/optionsSchema.js +1 -0
- package/dist/cli/loop/session.js +1 -0
- package/dist/cli/parser.js +1 -0
- package/dist/cli/utils/completeSetup.js +1 -0
- package/dist/cli/utils/envManager.js +1 -0
- package/dist/cli/utils/interactiveSetup.js +1 -0
- package/dist/cli/utils/ollamaUtils.js +1 -0
- package/dist/constants/index.js +1 -1
- package/dist/core/baseProvider.d.ts +14 -0
- package/dist/core/baseProvider.js +106 -23
- package/dist/index.d.ts +11 -5
- package/dist/index.js +11 -10
- package/dist/lib/adapters/providerImageAdapter.js +83 -10
- package/dist/lib/agent/directTools.d.ts +10 -10
- package/dist/lib/agent/directTools.js +6 -3
- package/dist/lib/config/configManager.js +1 -0
- package/dist/lib/config/conversationMemory.js +1 -0
- package/dist/lib/config/taskClassificationConfig.js +1 -0
- package/dist/lib/constants/index.js +2 -1
- package/dist/lib/constants/performance.js +1 -0
- package/dist/lib/constants/retry.js +1 -0
- package/dist/lib/constants/timeouts.js +1 -0
- package/dist/lib/constants/tokens.js +1 -0
- package/dist/lib/core/analytics.js +1 -0
- package/dist/lib/core/baseProvider.d.ts +14 -0
- package/dist/lib/core/baseProvider.js +107 -23
- package/dist/lib/core/constants.js +1 -0
- package/dist/lib/core/conversationMemoryFactory.js +1 -0
- package/dist/lib/core/conversationMemoryInitializer.js +1 -0
- package/dist/lib/core/conversationMemoryManager.js +1 -0
- package/dist/lib/core/dynamicModels.js +1 -0
- package/dist/lib/core/evaluation.js +1 -0
- package/dist/lib/core/evaluationProviders.js +1 -0
- package/dist/lib/core/factory.js +1 -0
- package/dist/lib/core/modelConfiguration.js +1 -0
- package/dist/lib/core/redisConversationMemoryManager.js +1 -0
- package/dist/lib/core/serviceRegistry.js +1 -0
- package/dist/lib/core/streamAnalytics.js +1 -0
- package/dist/lib/evaluation/contextBuilder.js +1 -0
- package/dist/lib/evaluation/index.js +1 -0
- package/dist/lib/evaluation/prompts.js +1 -0
- package/dist/lib/evaluation/ragasEvaluator.js +1 -0
- package/dist/lib/evaluation/retryManager.js +1 -0
- package/dist/lib/evaluation/scoring.js +1 -0
- package/dist/lib/factories/providerFactory.js +1 -0
- package/dist/lib/factories/providerRegistry.js +1 -0
- package/dist/lib/hitl/hitlErrors.js +1 -0
- package/dist/lib/hitl/hitlManager.js +1 -0
- package/dist/lib/hitl/index.js +1 -0
- package/dist/lib/hitl/types.js +1 -0
- package/dist/lib/index.d.ts +11 -5
- package/dist/lib/index.js +12 -10
- package/dist/lib/mcp/externalServerManager.js +1 -0
- package/dist/lib/mcp/factory.js +1 -0
- package/dist/lib/mcp/flexibleToolValidator.js +1 -0
- package/dist/lib/mcp/index.js +1 -0
- package/dist/lib/mcp/mcpCircuitBreaker.js +1 -0
- package/dist/lib/mcp/mcpClientFactory.js +2 -1
- package/dist/lib/mcp/registry.js +1 -0
- package/dist/lib/mcp/servers/agent/directToolsServer.js +2 -0
- package/dist/lib/mcp/servers/aiProviders/aiAnalysisTools.js +1 -0
- package/dist/lib/mcp/servers/aiProviders/aiCoreServer.js +1 -0
- package/dist/lib/mcp/servers/aiProviders/aiWorkflowTools.js +1 -0
- package/dist/lib/mcp/servers/utilities/utilityServer.js +1 -0
- package/dist/lib/mcp/toolDiscoveryService.js +1 -0
- package/dist/lib/mcp/toolRegistry.js +1 -0
- package/dist/lib/memory/mem0Initializer.js +1 -0
- package/dist/lib/middleware/builtin/analytics.js +1 -0
- package/dist/lib/middleware/builtin/autoEvaluation.js +1 -0
- package/dist/lib/middleware/builtin/guardrails.js +1 -0
- package/dist/lib/middleware/factory.js +1 -0
- package/dist/lib/middleware/index.js +1 -0
- package/dist/lib/middleware/registry.js +1 -0
- package/dist/lib/middleware/utils/guardrailsUtils.js +1 -0
- package/dist/lib/models/modelRegistry.js +1 -0
- package/dist/lib/models/modelResolver.js +2 -0
- package/dist/lib/neurolink.d.ts +41 -6
- package/dist/lib/neurolink.js +276 -5
- package/dist/lib/providers/amazonBedrock.d.ts +1 -0
- package/dist/lib/providers/amazonBedrock.js +166 -14
- package/dist/lib/providers/amazonSagemaker.js +1 -0
- package/dist/lib/providers/anthropic.js +8 -21
- package/dist/lib/providers/anthropicBaseProvider.js +1 -0
- package/dist/lib/providers/azureOpenai.js +6 -21
- package/dist/lib/providers/googleAiStudio.js +6 -21
- package/dist/lib/providers/googleVertex.js +9 -1
- package/dist/lib/providers/huggingFace.js +34 -3
- package/dist/lib/providers/index.js +1 -0
- package/dist/lib/providers/litellm.js +34 -3
- package/dist/lib/providers/mistral.js +32 -2
- package/dist/lib/providers/ollama.d.ts +37 -1
- package/dist/lib/providers/ollama.js +544 -58
- package/dist/lib/providers/openAI.js +6 -21
- package/dist/lib/providers/openaiCompatible.js +41 -4
- package/dist/lib/providers/sagemaker/adaptive-semaphore.js +1 -0
- package/dist/lib/providers/sagemaker/client.js +1 -0
- package/dist/lib/providers/sagemaker/config.js +1 -0
- package/dist/lib/providers/sagemaker/detection.js +1 -0
- package/dist/lib/providers/sagemaker/diagnostics.js +1 -0
- package/dist/lib/providers/sagemaker/error-constants.js +1 -0
- package/dist/lib/providers/sagemaker/errors.js +1 -0
- package/dist/lib/providers/sagemaker/index.js +1 -0
- package/dist/lib/providers/sagemaker/language-model.js +1 -0
- package/dist/lib/providers/sagemaker/parsers.js +1 -0
- package/dist/lib/providers/sagemaker/streaming.js +1 -0
- package/dist/lib/providers/sagemaker/structured-parser.js +1 -0
- package/dist/lib/proxy/awsProxyIntegration.js +1 -0
- package/dist/lib/proxy/proxyFetch.js +1 -0
- package/dist/lib/proxy/utils/noProxyUtils.js +1 -0
- package/dist/lib/sdk/toolRegistration.js +2 -0
- package/dist/lib/services/server/ai/observability/instrumentation.d.ts +57 -0
- package/dist/lib/services/server/ai/observability/instrumentation.js +171 -0
- package/dist/lib/session/globalSessionState.js +38 -1
- package/dist/lib/telemetry/index.d.ts +1 -0
- package/dist/lib/telemetry/index.js +1 -0
- package/dist/lib/telemetry/telemetryService.d.ts +2 -0
- package/dist/lib/telemetry/telemetryService.js +8 -7
- package/dist/lib/types/analytics.js +1 -0
- package/dist/lib/types/cli.js +1 -0
- package/dist/lib/types/common.js +1 -0
- package/dist/lib/types/configTypes.js +1 -0
- package/dist/lib/types/content.d.ts +14 -1
- package/dist/lib/types/content.js +1 -0
- package/dist/lib/types/contextTypes.js +1 -0
- package/dist/lib/types/conversation.d.ts +2 -0
- package/dist/lib/types/conversation.js +1 -0
- package/dist/lib/types/domainTypes.js +1 -0
- package/dist/lib/types/errors.js +1 -0
- package/dist/lib/types/evaluation.js +1 -0
- package/dist/lib/types/evaluationProviders.js +1 -0
- package/dist/lib/types/evaluationTypes.js +1 -0
- package/dist/lib/types/externalMcp.js +1 -0
- package/dist/lib/types/fileTypes.d.ts +44 -0
- package/dist/lib/types/fileTypes.js +1 -0
- package/dist/lib/types/generateTypes.d.ts +1 -0
- package/dist/lib/types/generateTypes.js +1 -0
- package/dist/lib/types/guardrails.js +1 -0
- package/dist/lib/types/index.js +1 -0
- package/dist/lib/types/mcpTypes.js +1 -0
- package/dist/lib/types/middlewareTypes.js +1 -0
- package/dist/lib/types/modelTypes.d.ts +6 -6
- package/dist/lib/types/modelTypes.js +1 -0
- package/dist/lib/types/observability.d.ts +49 -0
- package/dist/lib/types/observability.js +7 -0
- package/dist/lib/types/providers.d.ts +44 -0
- package/dist/lib/types/providers.js +1 -0
- package/dist/lib/types/sdkTypes.js +1 -0
- package/dist/lib/types/serviceTypes.js +1 -0
- package/dist/lib/types/streamTypes.d.ts +1 -0
- package/dist/lib/types/streamTypes.js +1 -0
- package/dist/lib/types/taskClassificationTypes.js +1 -0
- package/dist/lib/types/tools.js +2 -0
- package/dist/lib/types/typeAliases.js +1 -0
- package/dist/lib/types/universalProviderOptions.js +1 -0
- package/dist/lib/utils/analyticsUtils.js +1 -0
- package/dist/lib/utils/conversationMemory.js +1 -0
- package/dist/lib/utils/conversationMemoryUtils.js +1 -0
- package/dist/lib/utils/csvProcessor.js +1 -0
- package/dist/lib/utils/errorHandling.js +1 -0
- package/dist/lib/utils/evaluationUtils.js +1 -0
- package/dist/lib/utils/factoryProcessing.js +1 -0
- package/dist/lib/utils/fileDetector.js +7 -3
- package/dist/lib/utils/imageProcessor.js +1 -0
- package/dist/lib/utils/logger.js +1 -0
- package/dist/lib/utils/loopUtils.js +1 -0
- package/dist/lib/utils/mcpDefaults.js +1 -0
- package/dist/lib/utils/messageBuilder.js +96 -9
- package/dist/lib/utils/modelRouter.js +1 -0
- package/dist/lib/utils/multimodalOptionsBuilder.d.ts +67 -0
- package/dist/lib/utils/multimodalOptionsBuilder.js +65 -0
- package/dist/lib/utils/optionsConversion.js +1 -0
- package/dist/lib/utils/optionsUtils.js +1 -0
- package/dist/lib/utils/parameterValidation.js +1 -0
- package/dist/lib/utils/pdfProcessor.d.ts +10 -0
- package/dist/lib/utils/pdfProcessor.js +199 -0
- package/dist/lib/utils/performance.js +1 -0
- package/dist/lib/utils/promptRedaction.js +1 -0
- package/dist/lib/utils/providerConfig.js +1 -0
- package/dist/lib/utils/providerHealth.js +1 -0
- package/dist/lib/utils/providerSetupMessages.js +1 -0
- package/dist/lib/utils/providerUtils.js +1 -0
- package/dist/lib/utils/redis.js +1 -0
- package/dist/lib/utils/retryHandler.js +1 -0
- package/dist/lib/utils/schemaConversion.js +1 -0
- package/dist/lib/utils/taskClassificationUtils.js +1 -0
- package/dist/lib/utils/taskClassifier.js +1 -0
- package/dist/lib/utils/timeout.js +1 -0
- package/dist/lib/utils/tokenLimits.js +1 -0
- package/dist/lib/utils/toolUtils.js +1 -0
- package/dist/lib/utils/transformationUtils.js +1 -0
- package/dist/lib/utils/typeUtils.js +1 -0
- package/dist/mcp/mcpClientFactory.js +1 -1
- package/dist/mcp/servers/agent/directToolsServer.js +1 -0
- package/dist/models/modelResolver.js +1 -0
- package/dist/neurolink.d.ts +41 -6
- package/dist/neurolink.js +275 -5
- package/dist/providers/amazonBedrock.d.ts +1 -0
- package/dist/providers/amazonBedrock.js +165 -14
- package/dist/providers/anthropic.js +7 -21
- package/dist/providers/azureOpenai.js +5 -21
- package/dist/providers/googleAiStudio.js +5 -21
- package/dist/providers/googleVertex.js +8 -1
- package/dist/providers/huggingFace.js +33 -3
- package/dist/providers/litellm.js +33 -3
- package/dist/providers/mistral.js +31 -2
- package/dist/providers/ollama.d.ts +37 -1
- package/dist/providers/ollama.js +543 -58
- package/dist/providers/openAI.js +5 -21
- package/dist/providers/openaiCompatible.js +40 -4
- package/dist/sdk/toolRegistration.js +1 -0
- package/dist/services/server/ai/observability/instrumentation.d.ts +57 -0
- package/dist/services/server/ai/observability/instrumentation.js +170 -0
- package/dist/session/globalSessionState.js +37 -1
- package/dist/telemetry/index.d.ts +1 -0
- package/dist/telemetry/telemetryService.d.ts +2 -0
- package/dist/telemetry/telemetryService.js +7 -7
- package/dist/types/content.d.ts +14 -1
- package/dist/types/conversation.d.ts +2 -0
- package/dist/types/fileTypes.d.ts +44 -0
- package/dist/types/generateTypes.d.ts +1 -0
- package/dist/types/observability.d.ts +49 -0
- package/dist/types/observability.js +6 -0
- package/dist/types/providers.d.ts +44 -0
- package/dist/types/streamTypes.d.ts +1 -0
- package/dist/types/tools.js +1 -0
- package/dist/utils/fileDetector.js +6 -3
- package/dist/utils/messageBuilder.js +95 -9
- package/dist/utils/multimodalOptionsBuilder.d.ts +67 -0
- package/dist/utils/multimodalOptionsBuilder.js +64 -0
- package/dist/utils/pdfProcessor.d.ts +10 -0
- package/dist/utils/pdfProcessor.js +198 -0
- package/package.json +12 -16
|
@@ -133,6 +133,11 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
|
133
133
|
* Process custom tools from setupToolExecutor
|
|
134
134
|
*/
|
|
135
135
|
private processCustomTools;
|
|
136
|
+
/**
|
|
137
|
+
* Recursively fix JSON Schema for OpenAI strict mode compatibility
|
|
138
|
+
* OpenAI requires additionalProperties: false at ALL levels and preserves required array
|
|
139
|
+
*/
|
|
140
|
+
private fixSchemaForOpenAIStrictMode;
|
|
136
141
|
/**
|
|
137
142
|
* Create an external MCP tool
|
|
138
143
|
*/
|
|
@@ -236,4 +241,13 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
|
236
241
|
* @returns Array of prompt chunks
|
|
237
242
|
*/
|
|
238
243
|
static chunkPrompt(prompt: string, maxChunkSize?: number, overlap?: number): string[];
|
|
244
|
+
/**
|
|
245
|
+
* Create telemetry configuration for Vercel AI SDK experimental_telemetry
|
|
246
|
+
* This enables automatic OpenTelemetry tracing when telemetry is enabled
|
|
247
|
+
*/
|
|
248
|
+
protected getStreamTelemetryConfig(options: StreamOptions | TextGenerationOptions, operationType?: "stream" | "generate"): {
|
|
249
|
+
isEnabled: boolean;
|
|
250
|
+
functionId?: string;
|
|
251
|
+
metadata?: Record<string, string | number | boolean>;
|
|
252
|
+
} | undefined;
|
|
239
253
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { generateText } from "ai";
|
|
2
|
+
import { generateText, tool as createAISDKTool, jsonSchema } from "ai";
|
|
3
3
|
import { MiddlewareFactory } from "../middleware/factory.js";
|
|
4
4
|
import { logger } from "../utils/logger.js";
|
|
5
5
|
import { DEFAULT_MAX_STEPS, STEP_LIMITS } from "../core/constants.js";
|
|
6
6
|
import { directAgentTools } from "../agent/directTools.js";
|
|
7
7
|
import { getSafeMaxTokens } from "../utils/tokenLimits.js";
|
|
8
8
|
import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|
|
9
|
+
import { nanoid } from "nanoid";
|
|
10
|
+
import { createAnalytics } from "./analytics.js";
|
|
9
11
|
import { shouldDisableBuiltinTools } from "../utils/toolUtils.js";
|
|
10
12
|
import { buildMessagesArray, buildMultimodalMessagesArray, } from "../utils/messageBuilder.js";
|
|
11
13
|
import { getKeysAsString, getKeyCount } from "../utils/transformationUtils.js";
|
|
@@ -232,8 +234,9 @@ export class BaseProvider {
|
|
|
232
234
|
const hasImages = !!input?.images?.length;
|
|
233
235
|
const hasContent = !!input?.content?.length;
|
|
234
236
|
const hasCSVFiles = !!input?.csvFiles?.length;
|
|
237
|
+
const hasPdfFiles = !!input?.pdfFiles?.length;
|
|
235
238
|
const hasFiles = !!input?.files?.length;
|
|
236
|
-
return hasImages || hasContent || hasCSVFiles || hasFiles;
|
|
239
|
+
return hasImages || hasContent || hasCSVFiles || hasPdfFiles || hasFiles;
|
|
237
240
|
};
|
|
238
241
|
let messages;
|
|
239
242
|
if (hasMultimodalInput(options)) {
|
|
@@ -247,6 +250,7 @@ export class BaseProvider {
|
|
|
247
250
|
images: input?.images,
|
|
248
251
|
content: input?.content,
|
|
249
252
|
csvFiles: input?.csvFiles,
|
|
253
|
+
pdfFiles: input?.pdfFiles,
|
|
250
254
|
files: input?.files,
|
|
251
255
|
},
|
|
252
256
|
csvOptions: options.csvOptions,
|
|
@@ -304,6 +308,7 @@ export class BaseProvider {
|
|
|
304
308
|
toolChoice: shouldUseTools ? "auto" : "none",
|
|
305
309
|
temperature: options.temperature,
|
|
306
310
|
maxTokens: options.maxTokens,
|
|
311
|
+
experimental_telemetry: this.getStreamTelemetryConfig(options, "generate"),
|
|
307
312
|
onStepFinish: ({ toolCalls, toolResults }) => {
|
|
308
313
|
logger.info("Tool execution completed", { toolResults, toolCalls });
|
|
309
314
|
// Handle tool execution storage
|
|
@@ -764,22 +769,24 @@ export class BaseProvider {
|
|
|
764
769
|
async createCustomToolFromDefinition(toolName, toolInfo) {
|
|
765
770
|
try {
|
|
766
771
|
logger.debug(`[BaseProvider] Converting custom tool: ${toolName}`);
|
|
767
|
-
// Convert to AI SDK tool format
|
|
768
|
-
const { tool: createAISDKTool } = await import("ai");
|
|
769
|
-
const { z } = await import("zod");
|
|
770
772
|
let finalSchema;
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
773
|
+
let originalInputSchema;
|
|
774
|
+
// Prioritize parameters (Zod), then inputSchema (JSON Schema)
|
|
775
|
+
if (toolInfo.parameters && this.isZodSchema(toolInfo.parameters)) {
|
|
776
|
+
finalSchema = toolInfo.parameters;
|
|
775
777
|
}
|
|
776
|
-
else if (
|
|
777
|
-
|
|
778
|
-
|
|
778
|
+
else if (toolInfo.inputSchema &&
|
|
779
|
+
typeof toolInfo.inputSchema === "object") {
|
|
780
|
+
// Use original JSON Schema with jsonSchema() wrapper - NO CONVERSION!
|
|
781
|
+
originalInputSchema = toolInfo.inputSchema;
|
|
782
|
+
finalSchema = jsonSchema(originalInputSchema);
|
|
783
|
+
}
|
|
784
|
+
else if (toolInfo.parameters &&
|
|
785
|
+
typeof toolInfo.parameters === "object") {
|
|
786
|
+
finalSchema = convertJsonSchemaToZod(toolInfo.parameters);
|
|
779
787
|
}
|
|
780
788
|
else {
|
|
781
789
|
finalSchema = z.object({});
|
|
782
|
-
logger.debug(`[BaseProvider] ${toolName}: No schema found, using empty object`);
|
|
783
790
|
}
|
|
784
791
|
return createAISDKTool({
|
|
785
792
|
description: toolInfo.description || `Tool ${toolName}`,
|
|
@@ -973,7 +980,7 @@ export class BaseProvider {
|
|
|
973
980
|
{};
|
|
974
981
|
if (toolInfo && typeof toolInfo.execute === "function") {
|
|
975
982
|
const tool = await this.createCustomToolFromDefinition(toolName, toolInfo);
|
|
976
|
-
if (tool) {
|
|
983
|
+
if (tool && !tools[toolName]) {
|
|
977
984
|
tools[toolName] = tool;
|
|
978
985
|
}
|
|
979
986
|
}
|
|
@@ -982,17 +989,58 @@ export class BaseProvider {
|
|
|
982
989
|
customToolsProcessed: this.customTools.size,
|
|
983
990
|
});
|
|
984
991
|
}
|
|
992
|
+
/**
|
|
993
|
+
* Recursively fix JSON Schema for OpenAI strict mode compatibility
|
|
994
|
+
* OpenAI requires additionalProperties: false at ALL levels and preserves required array
|
|
995
|
+
*/
|
|
996
|
+
fixSchemaForOpenAIStrictMode(schema) {
|
|
997
|
+
const fixedSchema = JSON.parse(JSON.stringify(schema));
|
|
998
|
+
if (fixedSchema.type === "object" &&
|
|
999
|
+
fixedSchema.properties &&
|
|
1000
|
+
typeof fixedSchema.properties === "object") {
|
|
1001
|
+
const allPropertyNames = Object.keys(fixedSchema.properties);
|
|
1002
|
+
if (!fixedSchema.required || !Array.isArray(fixedSchema.required)) {
|
|
1003
|
+
fixedSchema.required = [];
|
|
1004
|
+
}
|
|
1005
|
+
fixedSchema.additionalProperties = false;
|
|
1006
|
+
for (const propName of allPropertyNames) {
|
|
1007
|
+
const propValue = fixedSchema.properties[propName];
|
|
1008
|
+
if (propValue && typeof propValue === "object") {
|
|
1009
|
+
if (propValue.type === "object") {
|
|
1010
|
+
fixedSchema.properties[propName] =
|
|
1011
|
+
this.fixSchemaForOpenAIStrictMode(propValue);
|
|
1012
|
+
}
|
|
1013
|
+
else if (propValue.type === "array" &&
|
|
1014
|
+
propValue.items &&
|
|
1015
|
+
typeof propValue.items === "object") {
|
|
1016
|
+
fixedSchema.properties[propName].items =
|
|
1017
|
+
this.fixSchemaForOpenAIStrictMode(propValue.items);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
return fixedSchema;
|
|
1023
|
+
}
|
|
985
1024
|
/**
|
|
986
1025
|
* Create an external MCP tool
|
|
987
1026
|
*/
|
|
988
1027
|
async createExternalMCPTool(tool) {
|
|
989
1028
|
try {
|
|
990
1029
|
logger.debug(`[BaseProvider] Converting external MCP tool: ${tool.name}`);
|
|
991
|
-
//
|
|
992
|
-
|
|
1030
|
+
// Use original JSON Schema from MCP tool if available, otherwise use permissive schema
|
|
1031
|
+
let finalSchema;
|
|
1032
|
+
if (tool.inputSchema && typeof tool.inputSchema === "object") {
|
|
1033
|
+
// Clone and fix the schema for OpenAI strict mode compatibility
|
|
1034
|
+
const originalSchema = tool.inputSchema;
|
|
1035
|
+
const fixedSchema = this.fixSchemaForOpenAIStrictMode(originalSchema);
|
|
1036
|
+
finalSchema = jsonSchema(fixedSchema);
|
|
1037
|
+
}
|
|
1038
|
+
else {
|
|
1039
|
+
finalSchema = this.createPermissiveZodSchema();
|
|
1040
|
+
}
|
|
993
1041
|
return createAISDKTool({
|
|
994
1042
|
description: tool.description || `External MCP tool ${tool.name}`,
|
|
995
|
-
parameters:
|
|
1043
|
+
parameters: finalSchema,
|
|
996
1044
|
execute: async (params) => {
|
|
997
1045
|
logger.debug(`Executing external MCP tool: ${tool.name}`, {
|
|
998
1046
|
toolName: tool.name,
|
|
@@ -1115,7 +1163,7 @@ export class BaseProvider {
|
|
|
1115
1163
|
logger.debug(`[BaseProvider] Found ${externalTools.length} external MCP tools`);
|
|
1116
1164
|
for (const tool of externalTools) {
|
|
1117
1165
|
const mcpTool = await this.createExternalMCPTool(tool);
|
|
1118
|
-
if (mcpTool) {
|
|
1166
|
+
if (mcpTool && !tools[tool.name]) {
|
|
1119
1167
|
tools[tool.name] = mcpTool;
|
|
1120
1168
|
logger.debug(`[BaseProvider] Successfully added external MCP tool: ${tool.name}`);
|
|
1121
1169
|
}
|
|
@@ -1138,9 +1186,14 @@ export class BaseProvider {
|
|
|
1138
1186
|
// Set empty tools object - MCP tools are handled at a higher level
|
|
1139
1187
|
this.mcpTools = {};
|
|
1140
1188
|
}
|
|
1141
|
-
// Add MCP tools if available
|
|
1189
|
+
// Add MCP tools if available, but don't overwrite existing direct tools
|
|
1190
|
+
// Direct tools (Zod-based) take precedence over MCP tools (JSON Schema)
|
|
1142
1191
|
if (this.mcpTools) {
|
|
1143
|
-
Object.
|
|
1192
|
+
for (const [name, tool] of Object.entries(this.mcpTools)) {
|
|
1193
|
+
if (!tools[name]) {
|
|
1194
|
+
tools[name] = tool;
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1144
1197
|
}
|
|
1145
1198
|
}
|
|
1146
1199
|
/**
|
|
@@ -1283,9 +1336,8 @@ export class BaseProvider {
|
|
|
1283
1336
|
*/
|
|
1284
1337
|
async createStreamAnalytics(result, startTime, options) {
|
|
1285
1338
|
try {
|
|
1286
|
-
const { createAnalytics } = await import("./analytics.js");
|
|
1287
1339
|
const analytics = createAnalytics(this.providerName, this.modelName, result, Date.now() - startTime, {
|
|
1288
|
-
requestId: `${this.providerName}-stream-${
|
|
1340
|
+
requestId: `${this.providerName}-stream-${nanoid()}`,
|
|
1289
1341
|
streamingMode: true,
|
|
1290
1342
|
...options.context,
|
|
1291
1343
|
});
|
|
@@ -1518,7 +1570,7 @@ export class BaseProvider {
|
|
|
1518
1570
|
}
|
|
1519
1571
|
const sessionId = options.context?.sessionId ||
|
|
1520
1572
|
options.sessionId ||
|
|
1521
|
-
`session-${
|
|
1573
|
+
`session-${nanoid()}`;
|
|
1522
1574
|
const userId = options.context?.userId ||
|
|
1523
1575
|
options.userId;
|
|
1524
1576
|
try {
|
|
@@ -1565,4 +1617,36 @@ export class BaseProvider {
|
|
|
1565
1617
|
}
|
|
1566
1618
|
return chunks;
|
|
1567
1619
|
}
|
|
1620
|
+
/**
|
|
1621
|
+
* Create telemetry configuration for Vercel AI SDK experimental_telemetry
|
|
1622
|
+
* This enables automatic OpenTelemetry tracing when telemetry is enabled
|
|
1623
|
+
*/
|
|
1624
|
+
getStreamTelemetryConfig(options, operationType = "stream") {
|
|
1625
|
+
// Check if telemetry is enabled via NeuroLink observability config
|
|
1626
|
+
if (!this.neurolink?.isTelemetryEnabled()) {
|
|
1627
|
+
return undefined;
|
|
1628
|
+
}
|
|
1629
|
+
const functionId = `${this.providerName}-${operationType}-${nanoid()}`;
|
|
1630
|
+
const metadata = {
|
|
1631
|
+
provider: this.providerName,
|
|
1632
|
+
model: this.modelName,
|
|
1633
|
+
toolsEnabled: !options.disableTools,
|
|
1634
|
+
neurolink: true,
|
|
1635
|
+
};
|
|
1636
|
+
// Add sessionId if available
|
|
1637
|
+
if ("sessionId" in options && options.sessionId) {
|
|
1638
|
+
const sessionId = options.sessionId;
|
|
1639
|
+
if (typeof sessionId === "string" ||
|
|
1640
|
+
typeof sessionId === "number" ||
|
|
1641
|
+
typeof sessionId === "boolean") {
|
|
1642
|
+
metadata.sessionId = sessionId;
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
return {
|
|
1646
|
+
isEnabled: true,
|
|
1647
|
+
functionId,
|
|
1648
|
+
metadata,
|
|
1649
|
+
};
|
|
1650
|
+
}
|
|
1568
1651
|
}
|
|
1652
|
+
//# sourceMappingURL=baseProvider.js.map
|
package/dist/lib/core/factory.js
CHANGED
package/dist/lib/hitl/index.js
CHANGED
package/dist/lib/hitl/types.js
CHANGED
package/dist/lib/index.d.ts
CHANGED
|
@@ -21,6 +21,9 @@ import { NeuroLink } from "./neurolink.js";
|
|
|
21
21
|
export { NeuroLink };
|
|
22
22
|
export type { ProviderStatus, MCPStatus } from "./neurolink.js";
|
|
23
23
|
export type { MCPServerInfo } from "./types/mcpTypes.js";
|
|
24
|
+
export type { ObservabilityConfig, LangfuseConfig, OpenTelemetryConfig, } from "./types/observability.js";
|
|
25
|
+
import { initializeOpenTelemetry, shutdownOpenTelemetry, flushOpenTelemetry, getLangfuseHealthStatus } from "./services/server/ai/observability/instrumentation.js";
|
|
26
|
+
export { initializeOpenTelemetry, shutdownOpenTelemetry, flushOpenTelemetry, getLangfuseHealthStatus, };
|
|
24
27
|
export type { NeuroLinkMiddleware, MiddlewareContext, MiddlewareFactoryOptions, MiddlewarePreset, MiddlewareConfig, } from "./types/middlewareTypes.js";
|
|
25
28
|
export { MiddlewareFactory } from "./middleware/factory.js";
|
|
26
29
|
export declare const VERSION = "1.0.0";
|
|
@@ -35,7 +38,7 @@ export declare const VERSION = "1.0.0";
|
|
|
35
38
|
* const result = await provider.stream({ input: { text: 'Hello, AI!' } });
|
|
36
39
|
* ```
|
|
37
40
|
*/
|
|
38
|
-
export declare function createAIProvider(providerName?: string, modelName?: string): Promise<import("./
|
|
41
|
+
export declare function createAIProvider(providerName?: string, modelName?: string): Promise<import("./types/providers.js").AIProvider>;
|
|
39
42
|
/**
|
|
40
43
|
* Create provider with automatic fallback
|
|
41
44
|
*
|
|
@@ -46,7 +49,7 @@ export declare function createAIProvider(providerName?: string, modelName?: stri
|
|
|
46
49
|
* const { primary, fallback } = await createAIProviderWithFallback('bedrock', 'vertex');
|
|
47
50
|
* ```
|
|
48
51
|
*/
|
|
49
|
-
export declare function createAIProviderWithFallback(primaryProvider?: string, fallbackProvider?: string, modelName?: string): Promise<import("./types/typeAliases.js").ProviderPairResult<import("./
|
|
52
|
+
export declare function createAIProviderWithFallback(primaryProvider?: string, fallbackProvider?: string, modelName?: string): Promise<import("./types/typeAliases.js").ProviderPairResult<import("./types/providers.js").AIProvider>>;
|
|
50
53
|
/**
|
|
51
54
|
* Create the best available provider based on configuration
|
|
52
55
|
*
|
|
@@ -57,7 +60,7 @@ export declare function createAIProviderWithFallback(primaryProvider?: string, f
|
|
|
57
60
|
* const provider = await createBestAIProvider();
|
|
58
61
|
* ```
|
|
59
62
|
*/
|
|
60
|
-
export declare function createBestAIProvider(requestedProvider?: string, modelName?: string): Promise<import("./
|
|
63
|
+
export declare function createBestAIProvider(requestedProvider?: string, modelName?: string): Promise<import("./types/providers.js").AIProvider>;
|
|
61
64
|
/**
|
|
62
65
|
* MCP (Model Context Protocol) Plugin Ecosystem
|
|
63
66
|
*
|
|
@@ -82,10 +85,13 @@ export declare function createBestAIProvider(requestedProvider?: string, modelNa
|
|
|
82
85
|
export { initializeMCPEcosystem, listMCPs, executeMCP, getMCPStats, mcpLogger, } from "./mcp/index.js";
|
|
83
86
|
export type { McpMetadata, ExecutionContext, DiscoveredMcp, ToolInfo, ToolExecutionResult, LogLevel, } from "./mcp/index.js";
|
|
84
87
|
export declare function initializeTelemetry(): Promise<boolean>;
|
|
85
|
-
export declare function getTelemetryStatus(): {
|
|
88
|
+
export declare function getTelemetryStatus(): Promise<{
|
|
86
89
|
enabled: boolean;
|
|
87
90
|
initialized: boolean;
|
|
88
|
-
|
|
91
|
+
endpoint?: string;
|
|
92
|
+
service?: string;
|
|
93
|
+
version?: string;
|
|
94
|
+
}>;
|
|
89
95
|
export type { TextGenerationOptions, TextGenerationResult, AnalyticsData, EvaluationData, } from "./types/index.js";
|
|
90
96
|
/**
|
|
91
97
|
* BACKWARD COMPATIBILITY: Legacy generateText function
|
package/dist/lib/index.js
CHANGED
|
@@ -19,6 +19,9 @@ export { dynamicModelProvider } from "./core/dynamicModels.js";
|
|
|
19
19
|
// Main NeuroLink wrapper class and diagnostic types
|
|
20
20
|
import { NeuroLink } from "./neurolink.js";
|
|
21
21
|
export { NeuroLink };
|
|
22
|
+
import { initializeOpenTelemetry, shutdownOpenTelemetry, flushOpenTelemetry, getLangfuseHealthStatus, } from "./services/server/ai/observability/instrumentation.js";
|
|
23
|
+
import { initializeTelemetry as init, getTelemetryStatus as getStatus, } from "./telemetry/index.js";
|
|
24
|
+
export { initializeOpenTelemetry, shutdownOpenTelemetry, flushOpenTelemetry, getLangfuseHealthStatus, };
|
|
22
25
|
export { MiddlewareFactory } from "./middleware/factory.js";
|
|
23
26
|
// Version
|
|
24
27
|
export const VERSION = "1.0.0";
|
|
@@ -96,20 +99,18 @@ initializeMCPEcosystem, listMCPs, executeMCP, getMCPStats, mcpLogger, } from "./
|
|
|
96
99
|
// Real-time Services (Phase 1) - Basic SSE functionality only
|
|
97
100
|
// export { createEnhancedChatService } from './chat/index.js';
|
|
98
101
|
// export type * from './services/types.js';
|
|
99
|
-
// Optional Telemetry (Phase 2) -
|
|
102
|
+
// Optional Telemetry (Phase 2) - Telemetry service initialization
|
|
100
103
|
export async function initializeTelemetry() {
|
|
101
|
-
|
|
102
|
-
const { initializeTelemetry: init } = await import("./telemetry/index.js");
|
|
104
|
+
try {
|
|
103
105
|
const result = await init();
|
|
104
|
-
return !!result;
|
|
106
|
+
return !!result;
|
|
105
107
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
export function getTelemetryStatus() {
|
|
109
|
-
if (process.env.NEUROLINK_TELEMETRY_ENABLED === "true") {
|
|
110
|
-
return { enabled: true, initialized: false };
|
|
108
|
+
catch {
|
|
109
|
+
return false;
|
|
111
110
|
}
|
|
112
|
-
|
|
111
|
+
}
|
|
112
|
+
export async function getTelemetryStatus() {
|
|
113
|
+
return getStatus();
|
|
113
114
|
}
|
|
114
115
|
/**
|
|
115
116
|
* BACKWARD COMPATIBILITY: Legacy generateText function
|
|
@@ -132,3 +133,4 @@ export async function generateText(options) {
|
|
|
132
133
|
const neurolink = new NeuroLink();
|
|
133
134
|
return await neurolink.generateText(options);
|
|
134
135
|
}
|
|
136
|
+
//# sourceMappingURL=index.js.map
|
package/dist/lib/mcp/factory.js
CHANGED
package/dist/lib/mcp/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
|
7
7
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
8
8
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
9
9
|
import { WebSocketClientTransport } from "@modelcontextprotocol/sdk/client/websocket.js";
|
|
10
|
-
import { spawn } from "child_process";
|
|
10
|
+
import { spawn, ChildProcess } from "child_process";
|
|
11
11
|
import { mcpLogger } from "../utils/logger.js";
|
|
12
12
|
import { globalCircuitBreakerManager } from "./mcpCircuitBreaker.js";
|
|
13
13
|
/**
|
|
@@ -470,3 +470,4 @@ export class MCPClientFactory {
|
|
|
470
470
|
return { ...this.DEFAULT_CAPABILITIES };
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
|
+
//# sourceMappingURL=mcpClientFactory.js.map
|
package/dist/lib/mcp/registry.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* NeuroLink Direct Tools Server
|
|
3
3
|
* Wraps the agent direct tools as an MCP server for proper registration
|
|
4
4
|
*/
|
|
5
|
+
import { z } from "zod";
|
|
5
6
|
import { createMCPServer } from "../../factory.js";
|
|
6
7
|
import { directAgentTools } from "../../../agent/directTools.js";
|
|
7
8
|
import { logger } from "../../../utils/logger.js";
|
|
@@ -142,3 +143,4 @@ function getToolCategory(toolName) {
|
|
|
142
143
|
return "utility";
|
|
143
144
|
}
|
|
144
145
|
}
|
|
146
|
+
//# sourceMappingURL=directToolsServer.js.map
|