@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.
Files changed (57) hide show
  1. package/CHANGELOG.md +14 -5
  2. package/README.md +150 -92
  3. package/dist/lib/mcp/dynamic-chain-executor.d.ts +201 -0
  4. package/dist/lib/mcp/dynamic-chain-executor.js +489 -0
  5. package/dist/lib/mcp/dynamic-orchestrator.d.ts +109 -0
  6. package/dist/lib/mcp/dynamic-orchestrator.js +351 -0
  7. package/dist/lib/mcp/error-manager.d.ts +254 -0
  8. package/dist/lib/mcp/error-manager.js +501 -0
  9. package/dist/lib/mcp/error-recovery.d.ts +158 -0
  10. package/dist/lib/mcp/error-recovery.js +405 -0
  11. package/dist/lib/mcp/health-monitor.d.ts +256 -0
  12. package/dist/lib/mcp/health-monitor.js +621 -0
  13. package/dist/lib/mcp/orchestrator.d.ts +136 -5
  14. package/dist/lib/mcp/orchestrator.js +316 -9
  15. package/dist/lib/mcp/registry.d.ts +22 -0
  16. package/dist/lib/mcp/registry.js +24 -0
  17. package/dist/lib/mcp/semaphore-manager.d.ts +137 -0
  18. package/dist/lib/mcp/semaphore-manager.js +329 -0
  19. package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.d.ts +2 -2
  20. package/dist/lib/mcp/session-manager.d.ts +186 -0
  21. package/dist/lib/mcp/session-manager.js +400 -0
  22. package/dist/lib/mcp/session-persistence.d.ts +93 -0
  23. package/dist/lib/mcp/session-persistence.js +298 -0
  24. package/dist/lib/mcp/transport-manager.d.ts +153 -0
  25. package/dist/lib/mcp/transport-manager.js +330 -0
  26. package/dist/lib/mcp/unified-registry.d.ts +42 -1
  27. package/dist/lib/mcp/unified-registry.js +122 -2
  28. package/dist/lib/neurolink.d.ts +75 -0
  29. package/dist/lib/neurolink.js +104 -0
  30. package/dist/mcp/dynamic-chain-executor.d.ts +201 -0
  31. package/dist/mcp/dynamic-chain-executor.js +489 -0
  32. package/dist/mcp/dynamic-orchestrator.d.ts +109 -0
  33. package/dist/mcp/dynamic-orchestrator.js +351 -0
  34. package/dist/mcp/error-manager.d.ts +254 -0
  35. package/dist/mcp/error-manager.js +501 -0
  36. package/dist/mcp/error-recovery.d.ts +158 -0
  37. package/dist/mcp/error-recovery.js +405 -0
  38. package/dist/mcp/health-monitor.d.ts +256 -0
  39. package/dist/mcp/health-monitor.js +621 -0
  40. package/dist/mcp/orchestrator.d.ts +136 -5
  41. package/dist/mcp/orchestrator.js +316 -9
  42. package/dist/mcp/plugins/core/neurolink-mcp.json +15 -15
  43. package/dist/mcp/registry.d.ts +22 -0
  44. package/dist/mcp/registry.js +24 -0
  45. package/dist/mcp/semaphore-manager.d.ts +137 -0
  46. package/dist/mcp/semaphore-manager.js +329 -0
  47. package/dist/mcp/session-manager.d.ts +186 -0
  48. package/dist/mcp/session-manager.js +400 -0
  49. package/dist/mcp/session-persistence.d.ts +93 -0
  50. package/dist/mcp/session-persistence.js +299 -0
  51. package/dist/mcp/transport-manager.d.ts +153 -0
  52. package/dist/mcp/transport-manager.js +331 -0
  53. package/dist/mcp/unified-registry.d.ts +42 -1
  54. package/dist/mcp/unified-registry.js +122 -2
  55. package/dist/neurolink.d.ts +75 -0
  56. package/dist/neurolink.js +104 -0
  57. package/package.json +245 -244
@@ -0,0 +1,137 @@
1
+ /**
2
+ * NeuroLink MCP Semaphore Manager
3
+ * Prevents race conditions in concurrent tool executions using a robust semaphore pattern
4
+ * Based on proven patterns from 1MCP reference implementation
5
+ */
6
+ import type { NeuroLinkExecutionContext } from "./factory.js";
7
+ /**
8
+ * Semaphore operation result
9
+ */
10
+ export interface SemaphoreResult<T> {
11
+ success: boolean;
12
+ result?: T;
13
+ error?: Error;
14
+ waitTime: number;
15
+ executionTime: number;
16
+ queueDepth: number;
17
+ }
18
+ /**
19
+ * Semaphore statistics
20
+ */
21
+ export interface SemaphoreStats {
22
+ activeOperations: number;
23
+ queuedOperations: number;
24
+ totalOperations: number;
25
+ totalWaitTime: number;
26
+ averageWaitTime: number;
27
+ peakQueueDepth: number;
28
+ lastActivity: number;
29
+ }
30
+ /**
31
+ * Semaphore Manager for concurrent operation control
32
+ * Implements the proven semaphore pattern from 1MCP to prevent race conditions
33
+ */
34
+ export declare class SemaphoreManager {
35
+ private locks;
36
+ private queues;
37
+ private stats;
38
+ private globalStats;
39
+ /**
40
+ * Acquire a semaphore and execute an operation
41
+ * Ensures exclusive access to resources identified by the key
42
+ *
43
+ * @param key Unique identifier for the resource
44
+ * @param operation Async operation to execute with exclusive access
45
+ * @param context Optional execution context for enhanced tracking
46
+ * @returns Result of the operation with timing metrics
47
+ */
48
+ acquire<T>(key: string, operation: () => Promise<T>, context?: NeuroLinkExecutionContext): Promise<SemaphoreResult<T>>;
49
+ /**
50
+ * Try to acquire a semaphore without waiting
51
+ * Returns immediately if the resource is locked
52
+ *
53
+ * @param key Unique identifier for the resource
54
+ * @param operation Async operation to execute if lock is available
55
+ * @param context Optional execution context
56
+ * @returns Result of the operation or null if resource is locked
57
+ */
58
+ tryAcquire<T>(key: string, operation: () => Promise<T>, context?: NeuroLinkExecutionContext): Promise<SemaphoreResult<T> | null>;
59
+ /**
60
+ * Check if a resource is currently locked
61
+ *
62
+ * @param key Resource identifier
63
+ * @returns True if the resource is locked
64
+ */
65
+ isLocked(key: string): boolean;
66
+ /**
67
+ * Get the current queue depth for a resource
68
+ *
69
+ * @param key Resource identifier
70
+ * @returns Number of operations waiting for this resource
71
+ */
72
+ getQueueDepth(key: string): number;
73
+ /**
74
+ * Get statistics for a specific resource or global stats
75
+ *
76
+ * @param key Optional resource identifier
77
+ * @returns Semaphore statistics
78
+ */
79
+ getStats(key?: string): SemaphoreStats;
80
+ /**
81
+ * Clear all semaphores (use with caution)
82
+ * This will reject all pending operations
83
+ */
84
+ clearAll(): void;
85
+ /**
86
+ * Update queue depth statistics
87
+ *
88
+ * @private
89
+ */
90
+ private updateQueueDepth;
91
+ /**
92
+ * Increment active operations counter
93
+ *
94
+ * @private
95
+ */
96
+ private incrementActiveOperations;
97
+ /**
98
+ * Decrement active operations counter
99
+ *
100
+ * @private
101
+ */
102
+ private decrementActiveOperations;
103
+ /**
104
+ * Update timing statistics
105
+ *
106
+ * @private
107
+ */
108
+ private updateStats;
109
+ /**
110
+ * Create empty statistics object
111
+ *
112
+ * @private
113
+ */
114
+ private createEmptyStats;
115
+ }
116
+ /**
117
+ * Default semaphore manager instance
118
+ */
119
+ export declare const defaultSemaphoreManager: SemaphoreManager;
120
+ /**
121
+ * Utility function to acquire semaphore with default manager
122
+ *
123
+ * @param key Resource identifier
124
+ * @param operation Operation to execute
125
+ * @param context Optional execution context
126
+ * @returns Operation result with metrics
127
+ */
128
+ export declare function acquireSemaphore<T>(key: string, operation: () => Promise<T>, context?: NeuroLinkExecutionContext): Promise<SemaphoreResult<T>>;
129
+ /**
130
+ * Utility function to try acquiring semaphore without waiting
131
+ *
132
+ * @param key Resource identifier
133
+ * @param operation Operation to execute
134
+ * @param context Optional execution context
135
+ * @returns Operation result or null if locked
136
+ */
137
+ export declare function tryAcquireSemaphore<T>(key: string, operation: () => Promise<T>, context?: NeuroLinkExecutionContext): Promise<SemaphoreResult<T> | null>;
@@ -0,0 +1,329 @@
1
+ /**
2
+ * NeuroLink MCP Semaphore Manager
3
+ * Prevents race conditions in concurrent tool executions using a robust semaphore pattern
4
+ * Based on proven patterns from 1MCP reference implementation
5
+ */
6
+ /**
7
+ * Semaphore Manager for concurrent operation control
8
+ * Implements the proven semaphore pattern from 1MCP to prevent race conditions
9
+ */
10
+ export class SemaphoreManager {
11
+ locks = new Map();
12
+ queues = new Map();
13
+ stats = new Map();
14
+ globalStats = {
15
+ activeOperations: 0,
16
+ queuedOperations: 0,
17
+ totalOperations: 0,
18
+ totalWaitTime: 0,
19
+ averageWaitTime: 0,
20
+ peakQueueDepth: 0,
21
+ lastActivity: Date.now(),
22
+ };
23
+ /**
24
+ * Acquire a semaphore and execute an operation
25
+ * Ensures exclusive access to resources identified by the key
26
+ *
27
+ * @param key Unique identifier for the resource
28
+ * @param operation Async operation to execute with exclusive access
29
+ * @param context Optional execution context for enhanced tracking
30
+ * @returns Result of the operation with timing metrics
31
+ */
32
+ async acquire(key, operation, context) {
33
+ const startTime = Date.now();
34
+ let waitTime = 0;
35
+ let executionTime = 0;
36
+ let queueDepth = 0;
37
+ // Get or create queue for this key
38
+ const queue = this.queues.get(key) || [];
39
+ queueDepth = queue.length;
40
+ // Check if there's an active lock
41
+ const existingLock = this.locks.get(key);
42
+ if (existingLock) {
43
+ // Add to queue and wait
44
+ queueDepth++;
45
+ this.updateQueueDepth(key, queueDepth);
46
+ const waitPromise = new Promise((resolve, reject) => {
47
+ queue.push({ resolve, reject });
48
+ this.queues.set(key, queue);
49
+ });
50
+ if (process.env.NEUROLINK_DEBUG === "true") {
51
+ console.log(`[Semaphore] Operation waiting in queue for key: ${key} (depth: ${queueDepth})`);
52
+ }
53
+ // Wait for existing lock and our turn in queue
54
+ await existingLock;
55
+ await waitPromise;
56
+ waitTime = Date.now() - startTime;
57
+ }
58
+ // Create new lock for this operation
59
+ let lockResolve;
60
+ const lockPromise = new Promise((resolve) => {
61
+ lockResolve = resolve;
62
+ });
63
+ this.locks.set(key, lockPromise);
64
+ // Update statistics
65
+ this.incrementActiveOperations(key);
66
+ // Execute the operation
67
+ const executionStartTime = Date.now();
68
+ if (process.env.NEUROLINK_DEBUG === "true") {
69
+ console.log(`[Semaphore] Executing operation for key: ${key}`);
70
+ }
71
+ try {
72
+ const result = await operation();
73
+ executionTime = Math.max(1, Date.now() - executionStartTime); // Ensure at least 1ms
74
+ // Update statistics
75
+ this.updateStats(key, waitTime, executionTime);
76
+ if (process.env.NEUROLINK_DEBUG === "true") {
77
+ console.log(`[Semaphore] Operation completed successfully for key: ${key}`);
78
+ }
79
+ return {
80
+ success: true,
81
+ result,
82
+ waitTime,
83
+ executionTime,
84
+ queueDepth,
85
+ };
86
+ }
87
+ catch (error) {
88
+ executionTime = Math.max(1, Date.now() - executionStartTime); // Ensure at least 1ms
89
+ const errorObj = error instanceof Error ? error : new Error(String(error));
90
+ // Update statistics even for errors
91
+ this.updateStats(key, waitTime, executionTime);
92
+ if (process.env.NEUROLINK_DEBUG === "true") {
93
+ console.error(`[Semaphore] Operation failed for key: ${key}`, errorObj.message);
94
+ }
95
+ return {
96
+ success: false,
97
+ error: errorObj,
98
+ waitTime,
99
+ executionTime,
100
+ queueDepth,
101
+ };
102
+ }
103
+ finally {
104
+ // Release the lock
105
+ this.locks.delete(key);
106
+ if (lockResolve) {
107
+ lockResolve();
108
+ }
109
+ // Process queue
110
+ const queue = this.queues.get(key) || [];
111
+ if (queue.length > 0) {
112
+ const next = queue.shift();
113
+ if (queue.length === 0) {
114
+ this.queues.delete(key);
115
+ }
116
+ else {
117
+ this.queues.set(key, queue);
118
+ }
119
+ // Allow next operation to proceed
120
+ next.resolve();
121
+ }
122
+ // Update statistics
123
+ this.decrementActiveOperations(key);
124
+ if (process.env.NEUROLINK_DEBUG === "true") {
125
+ console.log(`[Semaphore] Released lock for key: ${key}`);
126
+ }
127
+ }
128
+ }
129
+ /**
130
+ * Try to acquire a semaphore without waiting
131
+ * Returns immediately if the resource is locked
132
+ *
133
+ * @param key Unique identifier for the resource
134
+ * @param operation Async operation to execute if lock is available
135
+ * @param context Optional execution context
136
+ * @returns Result of the operation or null if resource is locked
137
+ */
138
+ async tryAcquire(key, operation, context) {
139
+ // Check if there's an active lock or queue
140
+ if (this.locks.has(key) || (this.queues.get(key) || []).length > 0) {
141
+ if (process.env.NEUROLINK_DEBUG === "true") {
142
+ console.log(`[Semaphore] tryAcquire failed - resource locked: ${key}`);
143
+ }
144
+ return null;
145
+ }
146
+ // No lock, proceed with normal acquire
147
+ return this.acquire(key, operation, context);
148
+ }
149
+ /**
150
+ * Check if a resource is currently locked
151
+ *
152
+ * @param key Resource identifier
153
+ * @returns True if the resource is locked
154
+ */
155
+ isLocked(key) {
156
+ return this.locks.has(key);
157
+ }
158
+ /**
159
+ * Get the current queue depth for a resource
160
+ *
161
+ * @param key Resource identifier
162
+ * @returns Number of operations waiting for this resource
163
+ */
164
+ getQueueDepth(key) {
165
+ const queue = this.queues.get(key) || [];
166
+ const hasLock = this.locks.has(key);
167
+ return queue.length + (hasLock ? 1 : 0);
168
+ }
169
+ /**
170
+ * Get statistics for a specific resource or global stats
171
+ *
172
+ * @param key Optional resource identifier
173
+ * @returns Semaphore statistics
174
+ */
175
+ getStats(key) {
176
+ if (key) {
177
+ return (this.stats.get(key) || {
178
+ activeOperations: 0,
179
+ queuedOperations: 0,
180
+ totalOperations: 0,
181
+ totalWaitTime: 0,
182
+ averageWaitTime: 0,
183
+ peakQueueDepth: 0,
184
+ lastActivity: 0,
185
+ });
186
+ }
187
+ return { ...this.globalStats };
188
+ }
189
+ /**
190
+ * Clear all semaphores (use with caution)
191
+ * This will reject all pending operations
192
+ */
193
+ clearAll() {
194
+ console.warn("[Semaphore] Clearing all semaphores - pending operations will be rejected");
195
+ // Reject all queued operations
196
+ for (const [key, queue] of this.queues) {
197
+ for (const op of queue) {
198
+ op.reject(new Error("Semaphore cleared"));
199
+ }
200
+ }
201
+ // Clear all data structures
202
+ this.locks.clear();
203
+ this.queues.clear();
204
+ this.stats.clear();
205
+ // Reset global stats
206
+ this.globalStats = {
207
+ activeOperations: 0,
208
+ queuedOperations: 0,
209
+ totalOperations: this.globalStats.totalOperations,
210
+ totalWaitTime: this.globalStats.totalWaitTime,
211
+ averageWaitTime: this.globalStats.averageWaitTime,
212
+ peakQueueDepth: this.globalStats.peakQueueDepth,
213
+ lastActivity: Date.now(),
214
+ };
215
+ }
216
+ /**
217
+ * Update queue depth statistics
218
+ *
219
+ * @private
220
+ */
221
+ updateQueueDepth(key, depth) {
222
+ const keyStats = this.stats.get(key) || this.createEmptyStats();
223
+ if (depth > keyStats.peakQueueDepth) {
224
+ keyStats.peakQueueDepth = depth;
225
+ }
226
+ keyStats.queuedOperations = depth;
227
+ this.stats.set(key, keyStats);
228
+ // Update global stats
229
+ this.globalStats.queuedOperations = Array.from(this.stats.values()).reduce((total, stats) => total + stats.queuedOperations, 0);
230
+ // Update global peak
231
+ if (depth > this.globalStats.peakQueueDepth) {
232
+ this.globalStats.peakQueueDepth = depth;
233
+ }
234
+ }
235
+ /**
236
+ * Increment active operations counter
237
+ *
238
+ * @private
239
+ */
240
+ incrementActiveOperations(key) {
241
+ const keyStats = this.stats.get(key) || this.createEmptyStats();
242
+ keyStats.activeOperations++;
243
+ keyStats.totalOperations++;
244
+ keyStats.lastActivity = Date.now();
245
+ this.stats.set(key, keyStats);
246
+ this.globalStats.activeOperations++;
247
+ this.globalStats.totalOperations++;
248
+ this.globalStats.lastActivity = Date.now();
249
+ }
250
+ /**
251
+ * Decrement active operations counter
252
+ *
253
+ * @private
254
+ */
255
+ decrementActiveOperations(key) {
256
+ const keyStats = this.stats.get(key);
257
+ if (keyStats && keyStats.activeOperations > 0) {
258
+ keyStats.activeOperations--;
259
+ keyStats.lastActivity = Date.now();
260
+ }
261
+ if (this.globalStats.activeOperations > 0) {
262
+ this.globalStats.activeOperations--;
263
+ }
264
+ this.globalStats.lastActivity = Date.now();
265
+ }
266
+ /**
267
+ * Update timing statistics
268
+ *
269
+ * @private
270
+ */
271
+ updateStats(key, waitTime, executionTime) {
272
+ const keyStats = this.stats.get(key) || this.createEmptyStats();
273
+ keyStats.totalWaitTime += waitTime;
274
+ keyStats.averageWaitTime =
275
+ keyStats.totalOperations > 0
276
+ ? keyStats.totalWaitTime / keyStats.totalOperations
277
+ : 0;
278
+ keyStats.lastActivity = Date.now();
279
+ this.stats.set(key, keyStats);
280
+ // Update global stats
281
+ this.globalStats.totalWaitTime += waitTime;
282
+ this.globalStats.averageWaitTime =
283
+ this.globalStats.totalOperations > 0
284
+ ? this.globalStats.totalWaitTime / this.globalStats.totalOperations
285
+ : 0;
286
+ }
287
+ /**
288
+ * Create empty statistics object
289
+ *
290
+ * @private
291
+ */
292
+ createEmptyStats() {
293
+ return {
294
+ activeOperations: 0,
295
+ queuedOperations: 0,
296
+ totalOperations: 0,
297
+ totalWaitTime: 0,
298
+ averageWaitTime: 0,
299
+ peakQueueDepth: 0,
300
+ lastActivity: Date.now(),
301
+ };
302
+ }
303
+ }
304
+ /**
305
+ * Default semaphore manager instance
306
+ */
307
+ export const defaultSemaphoreManager = new SemaphoreManager();
308
+ /**
309
+ * Utility function to acquire semaphore with default manager
310
+ *
311
+ * @param key Resource identifier
312
+ * @param operation Operation to execute
313
+ * @param context Optional execution context
314
+ * @returns Operation result with metrics
315
+ */
316
+ export async function acquireSemaphore(key, operation, context) {
317
+ return defaultSemaphoreManager.acquire(key, operation, context);
318
+ }
319
+ /**
320
+ * Utility function to try acquiring semaphore without waiting
321
+ *
322
+ * @param key Resource identifier
323
+ * @param operation Operation to execute
324
+ * @param context Optional execution context
325
+ * @returns Operation result or null if locked
326
+ */
327
+ export async function tryAcquireSemaphore(key, operation, context) {
328
+ return defaultSemaphoreManager.tryAcquire(key, operation, context);
329
+ }
@@ -30,13 +30,13 @@ export declare const workflowToolSchemas: {
30
30
  includeAsyncTests: z.ZodDefault<z.ZodBoolean>;
31
31
  }, "strip", z.ZodTypeAny, {
32
32
  codeFunction: string;
33
- testTypes: ("integration" | "unit" | "edge-cases" | "performance" | "security")[];
33
+ testTypes: ("integration" | "unit" | "performance" | "edge-cases" | "security")[];
34
34
  framework: "jest" | "mocha" | "vitest" | "pytest" | "unittest" | "rspec";
35
35
  coverageTarget: number;
36
36
  includeAsyncTests: boolean;
37
37
  }, {
38
38
  codeFunction: string;
39
- testTypes?: ("integration" | "unit" | "edge-cases" | "performance" | "security")[] | undefined;
39
+ testTypes?: ("integration" | "unit" | "performance" | "edge-cases" | "security")[] | undefined;
40
40
  framework?: "jest" | "mocha" | "vitest" | "pytest" | "unittest" | "rspec" | undefined;
41
41
  coverageTarget?: number | undefined;
42
42
  includeAsyncTests?: boolean | undefined;
@@ -0,0 +1,186 @@
1
+ /**
2
+ * NeuroLink MCP Session Management System
3
+ * Enables continuous tool calling with persistent state across executions
4
+ * Based on patterns from Cline's session management implementation
5
+ */
6
+ import type { NeuroLinkExecutionContext, ToolResult } from "./factory.js";
7
+ import { type PersistenceOptions } from "./session-persistence.js";
8
+ /**
9
+ * Session state for orchestrator operations
10
+ */
11
+ export interface OrchestratorSession {
12
+ id: string;
13
+ context: NeuroLinkExecutionContext;
14
+ toolHistory: ToolResult[];
15
+ state: Map<string, any>;
16
+ metadata: {
17
+ userAgent?: string;
18
+ origin?: string;
19
+ tags?: string[];
20
+ };
21
+ createdAt: number;
22
+ lastActivity: number;
23
+ expiresAt: number;
24
+ }
25
+ /**
26
+ * Session creation options
27
+ */
28
+ export interface SessionOptions {
29
+ ttl?: number;
30
+ metadata?: {
31
+ userAgent?: string;
32
+ origin?: string;
33
+ tags?: string[];
34
+ };
35
+ }
36
+ /**
37
+ * Session statistics
38
+ */
39
+ export interface SessionStats {
40
+ activeSessions: number;
41
+ totalSessionsCreated: number;
42
+ totalSessionsExpired: number;
43
+ averageSessionDuration: number;
44
+ averageToolsPerSession: number;
45
+ peakConcurrentSessions: number;
46
+ lastCleanup: number;
47
+ }
48
+ /**
49
+ * Session Manager for maintaining state across tool executions
50
+ * Implements session lifecycle management with automatic cleanup
51
+ */
52
+ export declare class SessionManager {
53
+ private sessions;
54
+ private sessionCounter;
55
+ private stats;
56
+ private cleanupInterval;
57
+ private defaultTTL;
58
+ private cleanupIntervalMs;
59
+ private persistence;
60
+ private persistenceEnabled;
61
+ constructor(defaultTTL?: number, cleanupIntervalMs?: number, autoCleanup?: boolean, enablePersistence?: boolean);
62
+ /**
63
+ * Initialize session manager with persistence
64
+ */
65
+ initialize(persistenceOptions?: PersistenceOptions): Promise<void>;
66
+ /**
67
+ * Create a new session
68
+ *
69
+ * @param context Execution context for the session
70
+ * @param options Session configuration options
71
+ * @returns Created session
72
+ */
73
+ createSession(context: NeuroLinkExecutionContext, options?: SessionOptions): OrchestratorSession;
74
+ /**
75
+ * Get an existing session
76
+ *
77
+ * @param sessionId Session identifier
78
+ * @param extend Whether to extend the session's expiration
79
+ * @returns Session if found and not expired
80
+ */
81
+ getSession(sessionId: string, extend?: boolean): OrchestratorSession | null;
82
+ /**
83
+ * Update session with new tool result
84
+ *
85
+ * @param sessionId Session identifier
86
+ * @param toolResult Result from tool execution
87
+ * @returns Updated session or null if not found
88
+ */
89
+ updateSession(sessionId: string, toolResult: ToolResult): OrchestratorSession | null;
90
+ /**
91
+ * Set session state value
92
+ *
93
+ * @param sessionId Session identifier
94
+ * @param key State key
95
+ * @param value State value
96
+ * @returns Updated session or null if not found
97
+ */
98
+ setSessionState(sessionId: string, key: string, value: any): OrchestratorSession | null;
99
+ /**
100
+ * Get session state value
101
+ *
102
+ * @param sessionId Session identifier
103
+ * @param key State key
104
+ * @returns State value or undefined
105
+ */
106
+ getSessionState(sessionId: string, key: string): any;
107
+ /**
108
+ * Remove a session
109
+ *
110
+ * @param sessionId Session identifier
111
+ * @returns True if session was removed
112
+ */
113
+ removeSession(sessionId: string): boolean;
114
+ /**
115
+ * Clean up expired sessions
116
+ *
117
+ * @returns Number of sessions cleaned up
118
+ */
119
+ cleanup(): Promise<number>;
120
+ /**
121
+ * Get an existing session with async persistence loading
122
+ *
123
+ * @param sessionId Session identifier
124
+ * @param extend Whether to extend the session's expiration
125
+ * @returns Session if found and not expired, or null
126
+ */
127
+ getSessionAsync(sessionId: string, extend?: boolean): Promise<OrchestratorSession | null>;
128
+ /**
129
+ * Get all active sessions
130
+ *
131
+ * @returns Array of active sessions
132
+ */
133
+ getActiveSessions(): Promise<OrchestratorSession[]>;
134
+ /**
135
+ * Get session statistics
136
+ *
137
+ * @returns Session statistics
138
+ */
139
+ getStats(): SessionStats;
140
+ /**
141
+ * Clear all sessions
142
+ */
143
+ clearAll(): void;
144
+ /**
145
+ * Start automatic cleanup interval
146
+ *
147
+ * @private
148
+ */
149
+ private startAutoCleanup;
150
+ /**
151
+ * Stop automatic cleanup interval
152
+ */
153
+ stopAutoCleanup(): void;
154
+ /**
155
+ * Generate unique session ID
156
+ *
157
+ * @private
158
+ */
159
+ private generateSessionId;
160
+ /**
161
+ * Update statistics
162
+ *
163
+ * @private
164
+ */
165
+ private updateStats;
166
+ }
167
+ /**
168
+ * Default session manager instance
169
+ */
170
+ export declare const defaultSessionManager: SessionManager;
171
+ /**
172
+ * Utility function to create session with default manager
173
+ *
174
+ * @param context Execution context
175
+ * @param options Session options
176
+ * @returns Created session
177
+ */
178
+ export declare function createSession(context: NeuroLinkExecutionContext, options?: SessionOptions): Promise<OrchestratorSession>;
179
+ /**
180
+ * Utility function to get session with default manager
181
+ *
182
+ * @param sessionId Session identifier
183
+ * @param extend Whether to extend expiration
184
+ * @returns Session or null
185
+ */
186
+ export declare function getSession(sessionId: string, extend?: boolean): Promise<OrchestratorSession | null>;