@juspay/neurolink 4.0.0 → 4.1.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 +14 -5
- package/README.md +150 -92
- package/dist/lib/mcp/dynamic-chain-executor.d.ts +201 -0
- package/dist/lib/mcp/dynamic-chain-executor.js +489 -0
- package/dist/lib/mcp/dynamic-orchestrator.d.ts +109 -0
- package/dist/lib/mcp/dynamic-orchestrator.js +351 -0
- package/dist/lib/mcp/error-manager.d.ts +254 -0
- package/dist/lib/mcp/error-manager.js +501 -0
- package/dist/lib/mcp/error-recovery.d.ts +158 -0
- package/dist/lib/mcp/error-recovery.js +405 -0
- package/dist/lib/mcp/health-monitor.d.ts +256 -0
- package/dist/lib/mcp/health-monitor.js +621 -0
- package/dist/lib/mcp/orchestrator.d.ts +136 -5
- package/dist/lib/mcp/orchestrator.js +316 -9
- package/dist/lib/mcp/registry.d.ts +22 -0
- package/dist/lib/mcp/registry.js +24 -0
- package/dist/lib/mcp/semaphore-manager.d.ts +137 -0
- package/dist/lib/mcp/semaphore-manager.js +329 -0
- package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.d.ts +2 -2
- package/dist/lib/mcp/session-manager.d.ts +186 -0
- package/dist/lib/mcp/session-manager.js +400 -0
- package/dist/lib/mcp/session-persistence.d.ts +93 -0
- package/dist/lib/mcp/session-persistence.js +298 -0
- package/dist/lib/mcp/transport-manager.d.ts +153 -0
- package/dist/lib/mcp/transport-manager.js +330 -0
- package/dist/lib/mcp/unified-registry.d.ts +42 -1
- package/dist/lib/mcp/unified-registry.js +122 -2
- package/dist/lib/neurolink.d.ts +75 -0
- package/dist/lib/neurolink.js +104 -0
- package/dist/mcp/dynamic-chain-executor.d.ts +201 -0
- package/dist/mcp/dynamic-chain-executor.js +489 -0
- package/dist/mcp/dynamic-orchestrator.d.ts +109 -0
- package/dist/mcp/dynamic-orchestrator.js +351 -0
- package/dist/mcp/error-manager.d.ts +254 -0
- package/dist/mcp/error-manager.js +501 -0
- package/dist/mcp/error-recovery.d.ts +158 -0
- package/dist/mcp/error-recovery.js +405 -0
- package/dist/mcp/health-monitor.d.ts +256 -0
- package/dist/mcp/health-monitor.js +621 -0
- package/dist/mcp/orchestrator.d.ts +136 -5
- package/dist/mcp/orchestrator.js +316 -9
- package/dist/mcp/plugins/core/neurolink-mcp.json +15 -15
- package/dist/mcp/registry.d.ts +22 -0
- package/dist/mcp/registry.js +24 -0
- package/dist/mcp/semaphore-manager.d.ts +137 -0
- package/dist/mcp/semaphore-manager.js +329 -0
- package/dist/mcp/session-manager.d.ts +186 -0
- package/dist/mcp/session-manager.js +400 -0
- package/dist/mcp/session-persistence.d.ts +93 -0
- package/dist/mcp/session-persistence.js +299 -0
- package/dist/mcp/transport-manager.d.ts +153 -0
- package/dist/mcp/transport-manager.js +331 -0
- package/dist/mcp/unified-registry.d.ts +42 -1
- package/dist/mcp/unified-registry.js +122 -2
- package/dist/neurolink.d.ts +75 -0
- package/dist/neurolink.js +104 -0
- package/package.json +245 -244
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
# [4.
|
|
1
|
+
# [4.1.0](https://github.com/juspay/neurolink/compare/v4.0.0...v4.1.0) (2025-07-09)
|
|
2
|
+
|
|
2
3
|
|
|
4
|
+
### Features
|
|
3
5
|
|
|
4
|
-
*
|
|
6
|
+
* **mcp:** comprehensive MCP system overhaul with GitHub PR fixes ([c0d8114](https://github.com/juspay/neurolink/commit/c0d8114ef1ab2d5dd3162c369f234d0de17397f7))
|
|
7
|
+
|
|
8
|
+
# [4.0.0](https://github.com/juspay/neurolink/compare/v3.0.1...v4.0.0) (2025-07-06)
|
|
5
9
|
|
|
10
|
+
- feat(core)!: transform NeuroLink into enterprise AI analytics platform ([74c88d6](https://github.com/juspay/neurolink/commit/74c88d6484bbd983aba9119929481e655d62eab3))
|
|
6
11
|
|
|
7
12
|
### BREAKING CHANGES
|
|
8
13
|
|
|
9
|
-
|
|
10
|
-
to comprehensive enterprise platform with analytics, evaluation,
|
|
11
|
-
real-time services, and business intelligence capabilities.
|
|
14
|
+
- Major architectural enhancement from basic AI SDK
|
|
15
|
+
to comprehensive enterprise platform with analytics, evaluation,
|
|
16
|
+
real-time services, and business intelligence capabilities.
|
|
12
17
|
|
|
13
18
|
Core Features Added:
|
|
19
|
+
|
|
14
20
|
- Analytics System: Usage tracking, cost estimation, performance monitoring
|
|
15
21
|
- Evaluation Framework: AI-powered quality assessment and scoring
|
|
16
22
|
- Enterprise Config: Backup/restore, validation, provider management
|
|
@@ -21,6 +27,7 @@ Core Features Added:
|
|
|
21
27
|
- Provider Integration: Analytics helper integrated across all 9 providers
|
|
22
28
|
|
|
23
29
|
Technical Implementation:
|
|
30
|
+
|
|
24
31
|
- NEW: src/lib/core/analytics.ts - Real usage tracking engine
|
|
25
32
|
- NEW: src/lib/core/evaluation.ts - AI quality assessment framework
|
|
26
33
|
- NEW: src/lib/config/configManager.ts - Enterprise configuration management
|
|
@@ -38,6 +45,7 @@ Backward Compatibility: 100% maintained - existing functionality preserved
|
|
|
38
45
|
New Features: Opt-in via --enable-analytics --enable-evaluation flags
|
|
39
46
|
|
|
40
47
|
Business Impact:
|
|
48
|
+
|
|
41
49
|
- Production Monitoring: Real-time performance and cost tracking
|
|
42
50
|
- Quality Assurance: AI-powered response evaluation and scoring
|
|
43
51
|
- Cost Optimization: Usage analytics and provider comparison
|
|
@@ -46,6 +54,7 @@ Business Impact:
|
|
|
46
54
|
- Enterprise Readiness: OpenTelemetry observability and operational excellence
|
|
47
55
|
|
|
48
56
|
Performance Metrics:
|
|
57
|
+
|
|
49
58
|
- Analytics: Real token counts (299-768), response times (2-10s)
|
|
50
59
|
- Evaluation: Quality scores (8-10/10), sub-6s processing
|
|
51
60
|
- Providers: All 9 providers enhanced with zero breaking changes
|
package/README.md
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @juspay/neurolink
|
|
2
|
+
|
|
3
|
+
<!-- TOC -->
|
|
4
|
+
|
|
5
|
+
- [📄 License](#[object Object])
|
|
6
|
+
- [🔗 Related Projects](#-related-projects)
|
|
7
|
+
<!-- /TOC -->
|
|
8
|
+
|
|
9
|
+
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 deploy AI applications with 9 major providers: OpenAI, Anthropic, Google AI, AWS Bedrock, Azure, Hugging Face, Ollama, and Mistral AI.
|
|
10
|
+
|
|
11
|
+
**Version:** 4.0.0
|
|
12
|
+
**License:** MIT
|
|
2
13
|
|
|
3
14
|
[](https://www.npmjs.com/package/@juspay/neurolink)
|
|
4
15
|
[](https://www.npmjs.com/package/@juspay/neurolink)
|
|
@@ -37,28 +48,28 @@ npm run config:validate
|
|
|
37
48
|
```typescript
|
|
38
49
|
// Modern camelCase interfaces with rich context
|
|
39
50
|
interface ExecutionContext {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
sessionId?: string;
|
|
52
|
+
userId?: string;
|
|
53
|
+
aiProvider?: string;
|
|
54
|
+
permissions?: string[];
|
|
55
|
+
cacheOptions?: CacheOptions;
|
|
56
|
+
fallbackOptions?: FallbackOptions;
|
|
57
|
+
metadata?: Record<string, unknown>;
|
|
47
58
|
}
|
|
48
59
|
|
|
49
60
|
// Optional methods for maximum flexibility
|
|
50
61
|
interface McpRegistry {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
registerServer?(
|
|
63
|
+
serverId: string,
|
|
64
|
+
config?: unknown,
|
|
65
|
+
context?: ExecutionContext,
|
|
66
|
+
): Promise<void>;
|
|
67
|
+
executeTool?<T>(
|
|
68
|
+
toolName: string,
|
|
69
|
+
args?: unknown,
|
|
70
|
+
context?: ExecutionContext,
|
|
71
|
+
): Promise<T>;
|
|
72
|
+
listTools?(context?: ExecutionContext): Promise<ToolInfo[]>;
|
|
62
73
|
}
|
|
63
74
|
```
|
|
64
75
|
|
|
@@ -104,8 +115,8 @@ import { createBestAIProvider } from "@juspay/neurolink";
|
|
|
104
115
|
// Auto-selects best available provider
|
|
105
116
|
const provider = createBestAIProvider();
|
|
106
117
|
const result = await provider.generateText({
|
|
107
|
-
|
|
108
|
-
|
|
118
|
+
prompt: "Write a haiku about programming",
|
|
119
|
+
timeout: "30s", // Optional: Set custom timeout (default: 30s)
|
|
109
120
|
});
|
|
110
121
|
|
|
111
122
|
console.log(result.text);
|
|
@@ -127,8 +138,8 @@ const provider = createBestAIProvider();
|
|
|
127
138
|
|
|
128
139
|
// Detailed method name
|
|
129
140
|
const story = await provider.generateText({
|
|
130
|
-
|
|
131
|
-
|
|
141
|
+
prompt: "Write a short story about AI",
|
|
142
|
+
maxTokens: 200,
|
|
132
143
|
});
|
|
133
144
|
|
|
134
145
|
// CLI-style method names
|
|
@@ -166,10 +177,10 @@ const result = await neurolink.generateText("Write a story");
|
|
|
166
177
|
|
|
167
178
|
// With enhancements (NEW!)
|
|
168
179
|
const enhancedResult = await neurolink.generateText({
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
180
|
+
prompt: "Write a business proposal",
|
|
181
|
+
enableAnalytics: true, // Get usage & cost data
|
|
182
|
+
enableEvaluation: true, // Get AI quality scores
|
|
183
|
+
context: { project: "Q1-sales" }, // Custom context
|
|
173
184
|
});
|
|
174
185
|
|
|
175
186
|
// Access enhancement data
|
|
@@ -179,25 +190,25 @@ console.log("Response:", enhancedResult.content);
|
|
|
179
190
|
|
|
180
191
|
// 🆕 NEW: Enhanced Evaluation with Domain Awareness
|
|
181
192
|
import {
|
|
182
|
-
|
|
183
|
-
|
|
193
|
+
performEnhancedEvaluation,
|
|
194
|
+
createEnhancedContext,
|
|
184
195
|
} from "@juspay/neurolink";
|
|
185
196
|
|
|
186
197
|
const enhancedContext = createEnhancedContext(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
"Write a business proposal for Q1 expansion",
|
|
199
|
+
enhancedResult.text,
|
|
200
|
+
{
|
|
201
|
+
domain: "Business development",
|
|
202
|
+
role: "Business proposal assistant",
|
|
203
|
+
toolsUsed: ["generate-text", "analytics-helper"],
|
|
204
|
+
conversationHistory: [
|
|
205
|
+
{ role: "user", content: "I need help with our Q1 business plan" },
|
|
206
|
+
{
|
|
207
|
+
role: "assistant",
|
|
208
|
+
content: "I can help you create a comprehensive plan",
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
},
|
|
201
212
|
);
|
|
202
213
|
|
|
203
214
|
const domainEvaluation = await performEnhancedEvaluation(enhancedContext);
|
|
@@ -215,39 +226,39 @@ console.log("🎯 Enhanced Evaluation:", domainEvaluation);
|
|
|
215
226
|
|
|
216
227
|
```typescript
|
|
217
228
|
import {
|
|
218
|
-
|
|
219
|
-
|
|
229
|
+
createEnhancedChatService,
|
|
230
|
+
NeuroLinkWebSocketServer,
|
|
220
231
|
} from "@juspay/neurolink";
|
|
221
232
|
|
|
222
233
|
// Enhanced chat with WebSocket support
|
|
223
234
|
const chatService = createEnhancedChatService({
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
235
|
+
provider: await createBestAIProvider(),
|
|
236
|
+
enableWebSocket: true,
|
|
237
|
+
enableSSE: true,
|
|
238
|
+
streamingConfig: {
|
|
239
|
+
bufferSize: 8192,
|
|
240
|
+
compressionEnabled: true,
|
|
241
|
+
},
|
|
231
242
|
});
|
|
232
243
|
|
|
233
244
|
// WebSocket server for real-time applications
|
|
234
245
|
const wsServer = new NeuroLinkWebSocketServer({
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
246
|
+
port: 8080,
|
|
247
|
+
maxConnections: 1000,
|
|
248
|
+
enableCompression: true,
|
|
238
249
|
});
|
|
239
250
|
|
|
240
251
|
// Handle real-time chat
|
|
241
252
|
wsServer.on("chat-message", async ({ connectionId, message }) => {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
253
|
+
await chatService.streamChat({
|
|
254
|
+
prompt: message.data.prompt,
|
|
255
|
+
onChunk: (chunk) => {
|
|
256
|
+
wsServer.sendMessage(connectionId, {
|
|
257
|
+
type: "ai-chunk",
|
|
258
|
+
data: { chunk },
|
|
259
|
+
});
|
|
260
|
+
},
|
|
261
|
+
});
|
|
251
262
|
});
|
|
252
263
|
```
|
|
253
264
|
|
|
@@ -258,11 +269,11 @@ import { initializeTelemetry, getTelemetryStatus } from "@juspay/neurolink";
|
|
|
258
269
|
|
|
259
270
|
// Optional enterprise monitoring (zero overhead when disabled)
|
|
260
271
|
const telemetry = initializeTelemetry({
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
272
|
+
serviceName: "my-ai-app",
|
|
273
|
+
endpoint: "http://localhost:4318",
|
|
274
|
+
enableTracing: true,
|
|
275
|
+
enableMetrics: true,
|
|
276
|
+
enableLogs: true,
|
|
266
277
|
});
|
|
267
278
|
|
|
268
279
|
// Check telemetry status
|
|
@@ -274,7 +285,7 @@ console.log("Version:", status.version);
|
|
|
274
285
|
// All AI operations are now automatically monitored
|
|
275
286
|
const provider = await createBestAIProvider();
|
|
276
287
|
const result = await provider.generateText({
|
|
277
|
-
|
|
288
|
+
prompt: "Generate business report",
|
|
278
289
|
});
|
|
279
290
|
// Telemetry automatically tracks: response time, token usage, cost, errors
|
|
280
291
|
```
|
|
@@ -422,34 +433,34 @@ npx @juspay/neurolink batch prompts.txt --timeout 45s --output results.json
|
|
|
422
433
|
```typescript
|
|
423
434
|
// SvelteKit API route with timeout handling
|
|
424
435
|
export const POST: RequestHandler = async ({ request }) => {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
436
|
+
const { message } = await request.json();
|
|
437
|
+
const provider = createBestAIProvider();
|
|
438
|
+
|
|
439
|
+
try {
|
|
440
|
+
const result = await provider.streamText({
|
|
441
|
+
prompt: message,
|
|
442
|
+
timeout: "2m", // 2 minutes for streaming
|
|
443
|
+
});
|
|
444
|
+
return new Response(result.toReadableStream());
|
|
445
|
+
} catch (error) {
|
|
446
|
+
if (error.name === "TimeoutError") {
|
|
447
|
+
return new Response("Request timed out", { status: 408 });
|
|
448
|
+
}
|
|
449
|
+
throw error;
|
|
450
|
+
}
|
|
440
451
|
};
|
|
441
452
|
|
|
442
453
|
// Next.js API route with timeout
|
|
443
454
|
export async function POST(request: NextRequest) {
|
|
444
|
-
|
|
445
|
-
|
|
455
|
+
const { prompt } = await request.json();
|
|
456
|
+
const provider = createBestAIProvider();
|
|
446
457
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
458
|
+
const result = await provider.generateText({
|
|
459
|
+
prompt,
|
|
460
|
+
timeout: process.env.AI_TIMEOUT || "30s", // Configurable timeout
|
|
461
|
+
});
|
|
451
462
|
|
|
452
|
-
|
|
463
|
+
return NextResponse.json({ text: result.text });
|
|
453
464
|
}
|
|
454
465
|
```
|
|
455
466
|
|
|
@@ -536,6 +547,53 @@ cd neurolink-demo && node server.js
|
|
|
536
547
|
- **Analysis Tools**: Usage optimization, performance benchmarking, parameter tuning
|
|
537
548
|
- **Workflow Tools**: Test generation, code refactoring, documentation, debugging
|
|
538
549
|
- **Extensibility**: Connect external tools and services via MCP protocol
|
|
550
|
+
- **🆕 Dynamic Server Management**: Programmatically add MCP servers at runtime
|
|
551
|
+
|
|
552
|
+
### 🔧 NEW: Programmatic MCP Server Management
|
|
553
|
+
|
|
554
|
+
**Add external MCP servers dynamically** for enhanced tool ecosystem:
|
|
555
|
+
|
|
556
|
+
```typescript
|
|
557
|
+
import { NeuroLink } from "@juspay/neurolink";
|
|
558
|
+
const neurolink = new NeuroLink();
|
|
559
|
+
|
|
560
|
+
// Add Bitbucket integration
|
|
561
|
+
await neurolink.addMCPServer("bitbucket", {
|
|
562
|
+
command: "npx",
|
|
563
|
+
args: ["-y", "@nexus2520/bitbucket-mcp-server"],
|
|
564
|
+
env: {
|
|
565
|
+
BITBUCKET_USERNAME: "your-username",
|
|
566
|
+
BITBUCKET_APP_PASSWORD: "your-app-password",
|
|
567
|
+
},
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
// Add custom database connector
|
|
571
|
+
await neurolink.addMCPServer("database", {
|
|
572
|
+
command: "node",
|
|
573
|
+
args: ["./custom-db-mcp-server.js"],
|
|
574
|
+
env: { DB_CONNECTION_STRING: "postgresql://..." },
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
// Add any MCP-compatible server
|
|
578
|
+
await neurolink.addMCPServer("slack-integration", {
|
|
579
|
+
command: "npx",
|
|
580
|
+
args: ["-y", "@slack/mcp-server"],
|
|
581
|
+
env: { SLACK_BOT_TOKEN: "xoxb-..." },
|
|
582
|
+
cwd: "/tmp",
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
// Verify servers are registered
|
|
586
|
+
const status = await neurolink.getMCPStatus();
|
|
587
|
+
console.log("Active servers:", status.totalServers);
|
|
588
|
+
console.log("Available tools:", status.totalTools);
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
**Perfect for:**
|
|
592
|
+
|
|
593
|
+
- **External Service Integration**: Bitbucket, Slack, Jira, databases
|
|
594
|
+
- **Custom Tool Development**: Your own MCP servers
|
|
595
|
+
- **Dynamic Workflows**: Add servers based on project needs
|
|
596
|
+
- **Enterprise Applications**: Runtime tool ecosystem management
|
|
539
597
|
|
|
540
598
|
## 🤝 Contributing
|
|
541
599
|
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamic AI Tool Chain Executor
|
|
3
|
+
* Allows AI to dynamically decide tool execution sequences based on context and results
|
|
4
|
+
*/
|
|
5
|
+
import type { MCPOrchestrator } from "./orchestrator.js";
|
|
6
|
+
import type { MCPRegistry } from "./registry.js";
|
|
7
|
+
import type { NeuroLinkExecutionContext } from "./factory.js";
|
|
8
|
+
import { ErrorManager } from "./error-manager.js";
|
|
9
|
+
/**
|
|
10
|
+
* Tool execution result with metadata
|
|
11
|
+
*/
|
|
12
|
+
export interface ToolExecutionResult {
|
|
13
|
+
toolName: string;
|
|
14
|
+
success: boolean;
|
|
15
|
+
result?: any;
|
|
16
|
+
error?: Error;
|
|
17
|
+
timestamp: number;
|
|
18
|
+
executionTime: number;
|
|
19
|
+
context?: Record<string, any>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Chain execution step
|
|
23
|
+
*/
|
|
24
|
+
export interface ChainStep {
|
|
25
|
+
stepId: string;
|
|
26
|
+
toolName: string;
|
|
27
|
+
parameters: any;
|
|
28
|
+
reasoning: string;
|
|
29
|
+
confidence: number;
|
|
30
|
+
expectedOutcome: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Chain execution context
|
|
34
|
+
*/
|
|
35
|
+
export interface ChainExecutionContext {
|
|
36
|
+
goal: string;
|
|
37
|
+
currentStep: number;
|
|
38
|
+
totalSteps?: number;
|
|
39
|
+
executionHistory: ToolExecutionResult[];
|
|
40
|
+
accumulatedContext: Record<string, any>;
|
|
41
|
+
userContext?: NeuroLinkExecutionContext;
|
|
42
|
+
maxSteps: number;
|
|
43
|
+
aiModel?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Chain execution result
|
|
47
|
+
*/
|
|
48
|
+
export interface ChainExecutionResult {
|
|
49
|
+
success: boolean;
|
|
50
|
+
goal: string;
|
|
51
|
+
totalSteps: number;
|
|
52
|
+
executionTime: number;
|
|
53
|
+
results: ToolExecutionResult[];
|
|
54
|
+
finalResult?: any;
|
|
55
|
+
reasoning: string;
|
|
56
|
+
error?: Error;
|
|
57
|
+
metadata: {
|
|
58
|
+
toolsUsed: string[];
|
|
59
|
+
averageConfidence: number;
|
|
60
|
+
contextEvolution: Record<string, any>[];
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* AI Tool Chain Planner interface
|
|
65
|
+
*/
|
|
66
|
+
export interface AIChainPlanner {
|
|
67
|
+
name: string;
|
|
68
|
+
planNextStep(goal: string, availableTools: Array<{
|
|
69
|
+
name: string;
|
|
70
|
+
description: string;
|
|
71
|
+
inputSchema: any;
|
|
72
|
+
}>, executionHistory: ToolExecutionResult[], accumulatedContext: Record<string, any>): Promise<ChainStep | null>;
|
|
73
|
+
evaluateResult(step: ChainStep, result: ToolExecutionResult, goal: string): Promise<{
|
|
74
|
+
goalAchieved: boolean;
|
|
75
|
+
confidence: number;
|
|
76
|
+
nextAction: "continue" | "retry" | "abort" | "complete";
|
|
77
|
+
reasoning: string;
|
|
78
|
+
}>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Simple AI Chain Planner using heuristics
|
|
82
|
+
*/
|
|
83
|
+
export declare class HeuristicChainPlanner implements AIChainPlanner {
|
|
84
|
+
name: string;
|
|
85
|
+
planNextStep(goal: string, availableTools: Array<{
|
|
86
|
+
name: string;
|
|
87
|
+
description: string;
|
|
88
|
+
inputSchema: any;
|
|
89
|
+
}>, executionHistory: ToolExecutionResult[], accumulatedContext: Record<string, any>): Promise<ChainStep | null>;
|
|
90
|
+
evaluateResult(step: ChainStep, result: ToolExecutionResult, goal: string): Promise<{
|
|
91
|
+
goalAchieved: boolean;
|
|
92
|
+
confidence: number;
|
|
93
|
+
nextAction: "continue" | "retry" | "abort" | "complete";
|
|
94
|
+
reasoning: string;
|
|
95
|
+
}>;
|
|
96
|
+
private generateParameters;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Advanced AI Chain Planner using actual AI model
|
|
100
|
+
*/
|
|
101
|
+
export declare class AIModelChainPlanner implements AIChainPlanner {
|
|
102
|
+
name: string;
|
|
103
|
+
private aiModel;
|
|
104
|
+
constructor(aiModel?: string);
|
|
105
|
+
planNextStep(goal: string, availableTools: Array<{
|
|
106
|
+
name: string;
|
|
107
|
+
description: string;
|
|
108
|
+
inputSchema: any;
|
|
109
|
+
}>, executionHistory: ToolExecutionResult[], accumulatedContext: Record<string, any>): Promise<ChainStep | null>;
|
|
110
|
+
evaluateResult(step: ChainStep, result: ToolExecutionResult, goal: string): Promise<{
|
|
111
|
+
goalAchieved: boolean;
|
|
112
|
+
confidence: number;
|
|
113
|
+
nextAction: "continue" | "retry" | "abort" | "complete";
|
|
114
|
+
reasoning: string;
|
|
115
|
+
}>;
|
|
116
|
+
private buildPlanningPrompt;
|
|
117
|
+
private buildEvaluationPrompt;
|
|
118
|
+
private callAIModel;
|
|
119
|
+
private parseAIResponse;
|
|
120
|
+
private parseEvaluationResponse;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Dynamic Chain Executor
|
|
124
|
+
*/
|
|
125
|
+
export declare class DynamicChainExecutor {
|
|
126
|
+
private orchestrator;
|
|
127
|
+
private registry;
|
|
128
|
+
private errorManager;
|
|
129
|
+
private planner;
|
|
130
|
+
constructor(orchestrator: MCPOrchestrator, registry: MCPRegistry, errorManager: ErrorManager, planner?: AIChainPlanner);
|
|
131
|
+
/**
|
|
132
|
+
* Execute dynamic tool chain to achieve a goal
|
|
133
|
+
*
|
|
134
|
+
* @param goal The goal to achieve
|
|
135
|
+
* @param initialContext Initial context data
|
|
136
|
+
* @param userContext User execution context
|
|
137
|
+
* @param options Execution options
|
|
138
|
+
* @returns Chain execution result
|
|
139
|
+
*/
|
|
140
|
+
executeChain(goal: string, initialContext?: Record<string, any>, userContext?: NeuroLinkExecutionContext, options?: {
|
|
141
|
+
maxSteps?: number;
|
|
142
|
+
aiModel?: string;
|
|
143
|
+
timeout?: number;
|
|
144
|
+
}): Promise<ChainExecutionResult>;
|
|
145
|
+
/**
|
|
146
|
+
* Execute chain steps iteratively
|
|
147
|
+
*
|
|
148
|
+
* @private
|
|
149
|
+
*/
|
|
150
|
+
private executeChainSteps;
|
|
151
|
+
/**
|
|
152
|
+
* Execute a single step
|
|
153
|
+
*
|
|
154
|
+
* @private
|
|
155
|
+
*/
|
|
156
|
+
private executeStep;
|
|
157
|
+
/**
|
|
158
|
+
* Update accumulated context with new result
|
|
159
|
+
*
|
|
160
|
+
* @private
|
|
161
|
+
*/
|
|
162
|
+
private updateAccumulatedContext;
|
|
163
|
+
/**
|
|
164
|
+
* Calculate average confidence across execution history
|
|
165
|
+
*
|
|
166
|
+
* @private
|
|
167
|
+
*/
|
|
168
|
+
private calculateAverageConfidence;
|
|
169
|
+
/**
|
|
170
|
+
* Track context evolution through execution
|
|
171
|
+
*
|
|
172
|
+
* @private
|
|
173
|
+
*/
|
|
174
|
+
private trackContextEvolution;
|
|
175
|
+
/**
|
|
176
|
+
* Set AI planner
|
|
177
|
+
*
|
|
178
|
+
* @param planner AI chain planner instance
|
|
179
|
+
*/
|
|
180
|
+
setPlanner(planner: AIChainPlanner): void;
|
|
181
|
+
/**
|
|
182
|
+
* Get current planner
|
|
183
|
+
*
|
|
184
|
+
* @returns Current AI chain planner
|
|
185
|
+
*/
|
|
186
|
+
getPlanner(): AIChainPlanner;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Default dynamic chain executor instance
|
|
190
|
+
*/
|
|
191
|
+
export declare let defaultDynamicChainExecutor: DynamicChainExecutor | null;
|
|
192
|
+
/**
|
|
193
|
+
* Initialize default dynamic chain executor
|
|
194
|
+
*
|
|
195
|
+
* @param orchestrator MCP orchestrator
|
|
196
|
+
* @param registry Tool registry
|
|
197
|
+
* @param errorManager Error manager
|
|
198
|
+
* @param planner Optional AI planner
|
|
199
|
+
* @returns Dynamic chain executor instance
|
|
200
|
+
*/
|
|
201
|
+
export declare function initializeDynamicChainExecutor(orchestrator: MCPOrchestrator, registry: MCPRegistry, errorManager: ErrorManager, planner?: AIChainPlanner): DynamicChainExecutor;
|