@juspay/neurolink 9.43.0 → 9.44.1
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 +8 -0
- package/dist/browser/neurolink.min.js +258 -258
- package/dist/cli/commands/authProviders.d.ts +1 -1
- package/dist/cli/commands/task.js +1 -1
- package/dist/cli/errorHandler.js +1 -1
- package/dist/cli/factories/commandFactory.js +1 -1
- package/dist/cli/loop/conversationSelector.d.ts +2 -2
- package/dist/cli/loop/optionsSchema.d.ts +2 -2
- package/dist/cli/loop/session.d.ts +1 -1
- package/dist/cli/utils/audioFileUtils.d.ts +1 -1
- package/dist/cli/utils/envManager.d.ts +1 -1
- package/dist/cli/utils/videoFileUtils.d.ts +1 -1
- package/dist/client/auth.d.ts +3 -3
- package/dist/client/httpClient.d.ts +20 -20
- package/dist/client/index.d.ts +3 -3
- package/dist/client/interceptors.d.ts +1 -1
- package/dist/client/reactHooks.d.ts +1 -1
- package/dist/client/reactHooks.tsx +2 -2
- package/dist/client/sseClient.d.ts +1 -1
- package/dist/client/streamingClient.d.ts +1 -1
- package/dist/client/wsClient.d.ts +1 -1
- package/dist/files/fileTools.d.ts +1 -1
- package/dist/lib/agent/directTools.d.ts +2 -2
- package/dist/lib/client/auth.d.ts +3 -3
- package/dist/lib/client/httpClient.d.ts +20 -20
- package/dist/lib/client/index.d.ts +3 -3
- package/dist/lib/client/interceptors.d.ts +1 -1
- package/dist/lib/client/reactHooks.d.ts +1 -1
- package/dist/lib/client/sseClient.d.ts +1 -1
- package/dist/lib/client/streamingClient.d.ts +1 -1
- package/dist/lib/client/wsClient.d.ts +1 -1
- package/dist/lib/files/fileTools.d.ts +1 -1
- package/dist/lib/rag/types.d.ts +1 -68
- package/dist/lib/server/types.d.ts +3 -847
- package/dist/lib/server/types.js +3 -64
- package/dist/lib/tasks/tools/taskTools.d.ts +1 -1
- package/dist/lib/types/analytics.d.ts +1 -1
- package/dist/lib/types/cli.d.ts +1 -1
- package/dist/lib/types/clientTypes.d.ts +38 -20
- package/dist/lib/types/configTypes.d.ts +1 -1
- package/dist/lib/types/configTypes.js +0 -1
- package/dist/lib/types/index.d.ts +8 -6
- package/dist/lib/types/index.js +3 -0
- package/dist/lib/types/ragTypes.d.ts +69 -0
- package/dist/lib/types/sdkTypes.d.ts +1 -2
- package/dist/lib/types/serverTypes.d.ts +858 -0
- package/dist/lib/types/serverTypes.js +68 -0
- package/dist/lib/types/streamTypes.d.ts +2 -2
- package/dist/lib/types/typeAliases.d.ts +1 -37
- package/dist/lib/workflow/config.d.ts +3 -3
- package/dist/rag/errors/RAGError.d.ts +1 -1
- package/dist/rag/types.d.ts +1 -68
- package/dist/server/types.d.ts +3 -847
- package/dist/server/types.js +3 -64
- package/dist/types/analytics.d.ts +1 -1
- package/dist/types/cli.d.ts +1 -1
- package/dist/types/clientTypes.d.ts +38 -20
- package/dist/types/configTypes.d.ts +1 -1
- package/dist/types/index.d.ts +8 -6
- package/dist/types/index.js +3 -0
- package/dist/types/ragTypes.d.ts +69 -0
- package/dist/types/sdkTypes.d.ts +1 -2
- package/dist/types/serverTypes.d.ts +858 -0
- package/dist/types/serverTypes.js +67 -0
- package/dist/types/streamTypes.d.ts +2 -2
- package/dist/types/typeAliases.d.ts +1 -37
- package/dist/workflow/config.d.ts +3 -3
- package/package.json +1 -1
|
@@ -1,850 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Server Adapter Types
|
|
3
|
-
*
|
|
3
|
+
* Re-exported from types/serverTypes.ts for backward compatibility.
|
|
4
|
+
* Import from '@juspay/neurolink' or '../types/index.js' for new code.
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
-
import type { MCPToolRegistry } from "../mcp/toolRegistry.js";
|
|
7
|
-
import type { NeuroLink } from "../neurolink.js";
|
|
8
|
-
import type { JsonObject, JsonValue } from "../types/common.js";
|
|
9
|
-
import type { ExternalMCPServerStatus } from "../types/externalMcp.js";
|
|
10
|
-
/**
|
|
11
|
-
* Server adapter configuration
|
|
12
|
-
*/
|
|
13
|
-
export type ServerAdapterConfig = {
|
|
14
|
-
/** Server port (default: 3000) */
|
|
15
|
-
port?: number;
|
|
16
|
-
/** Server host (default: "0.0.0.0") */
|
|
17
|
-
host?: string;
|
|
18
|
-
/** Base path for all routes (default: "/api") */
|
|
19
|
-
basePath?: string;
|
|
20
|
-
/** CORS configuration */
|
|
21
|
-
cors?: CORSConfig;
|
|
22
|
-
/** Rate limiting configuration */
|
|
23
|
-
rateLimit?: RateLimitConfig;
|
|
24
|
-
/** Body parser configuration */
|
|
25
|
-
bodyParser?: BodyParserConfig;
|
|
26
|
-
/** Logging configuration */
|
|
27
|
-
logging?: LoggingConfig;
|
|
28
|
-
/** Request timeout in milliseconds (default: 30000) */
|
|
29
|
-
timeout?: number;
|
|
30
|
-
/** Enable metrics endpoint (default: true) */
|
|
31
|
-
enableMetrics?: boolean;
|
|
32
|
-
/** Enable Swagger/OpenAPI documentation (default: false) */
|
|
33
|
-
enableSwagger?: boolean;
|
|
34
|
-
/** Disable built-in health routes (use when registering healthRoutes separately) */
|
|
35
|
-
disableBuiltInHealth?: boolean;
|
|
36
|
-
/** Stream redaction configuration (disabled by default) */
|
|
37
|
-
redaction?: RedactionConfig;
|
|
38
|
-
/** Shutdown configuration for graceful shutdown behavior */
|
|
39
|
-
shutdown?: ShutdownConfig;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Required server adapter configuration (with defaults applied)
|
|
43
|
-
*/
|
|
44
|
-
export type RequiredServerAdapterConfig = {
|
|
45
|
-
port: number;
|
|
46
|
-
host: string;
|
|
47
|
-
basePath: string;
|
|
48
|
-
cors: RequiredCORSConfig;
|
|
49
|
-
rateLimit: RequiredRateLimitConfig;
|
|
50
|
-
bodyParser: RequiredBodyParserConfig;
|
|
51
|
-
logging: RequiredLoggingConfig;
|
|
52
|
-
timeout: number;
|
|
53
|
-
enableMetrics: boolean;
|
|
54
|
-
enableSwagger: boolean;
|
|
55
|
-
disableBuiltInHealth: boolean;
|
|
56
|
-
shutdown: RequiredShutdownConfig;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* CORS configuration
|
|
60
|
-
*/
|
|
61
|
-
export type CORSConfig = {
|
|
62
|
-
/** Enable CORS (default: true) */
|
|
63
|
-
enabled?: boolean;
|
|
64
|
-
/** Allowed origins (default: ["*"]) */
|
|
65
|
-
origins?: string[];
|
|
66
|
-
/** Allowed HTTP methods */
|
|
67
|
-
methods?: string[];
|
|
68
|
-
/** Allowed headers */
|
|
69
|
-
headers?: string[];
|
|
70
|
-
/** Allow credentials */
|
|
71
|
-
credentials?: boolean;
|
|
72
|
-
/** Preflight cache max age in seconds */
|
|
73
|
-
maxAge?: number;
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* Required CORS configuration
|
|
77
|
-
*/
|
|
78
|
-
export type RequiredCORSConfig = {
|
|
79
|
-
enabled: boolean;
|
|
80
|
-
origins: string[];
|
|
81
|
-
methods: string[];
|
|
82
|
-
headers: string[];
|
|
83
|
-
credentials: boolean;
|
|
84
|
-
maxAge: number;
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Rate limiting configuration
|
|
88
|
-
*/
|
|
89
|
-
export type RateLimitConfig = {
|
|
90
|
-
/** Enable rate limiting (default: true) */
|
|
91
|
-
enabled?: boolean;
|
|
92
|
-
/** Time window in milliseconds (default: 15 minutes) */
|
|
93
|
-
windowMs?: number;
|
|
94
|
-
/** Maximum requests per window (default: 100) */
|
|
95
|
-
maxRequests?: number;
|
|
96
|
-
/** Custom error message */
|
|
97
|
-
message?: string;
|
|
98
|
-
/** Skip rate limiting for certain paths */
|
|
99
|
-
skipPaths?: string[];
|
|
100
|
-
/** Custom key generator function */
|
|
101
|
-
keyGenerator?: (ctx: ServerContext) => string;
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* Required rate limit configuration
|
|
105
|
-
*/
|
|
106
|
-
export type RequiredRateLimitConfig = {
|
|
107
|
-
enabled: boolean;
|
|
108
|
-
windowMs: number;
|
|
109
|
-
maxRequests: number;
|
|
110
|
-
message: string;
|
|
111
|
-
skipPaths?: string[];
|
|
112
|
-
keyGenerator?: (ctx: ServerContext) => string;
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* Body parser configuration
|
|
116
|
-
*/
|
|
117
|
-
export type BodyParserConfig = {
|
|
118
|
-
/** Enable body parsing (default: true) */
|
|
119
|
-
enabled?: boolean;
|
|
120
|
-
/** Maximum body size (default: "10mb") */
|
|
121
|
-
maxSize?: string;
|
|
122
|
-
/** JSON body limit (default: "10mb") */
|
|
123
|
-
jsonLimit?: string;
|
|
124
|
-
/** Enable URL-encoded body parsing */
|
|
125
|
-
urlEncoded?: boolean;
|
|
126
|
-
};
|
|
127
|
-
/**
|
|
128
|
-
* Required body parser configuration
|
|
129
|
-
*/
|
|
130
|
-
export type RequiredBodyParserConfig = {
|
|
131
|
-
enabled: boolean;
|
|
132
|
-
maxSize: string;
|
|
133
|
-
jsonLimit: string;
|
|
134
|
-
urlEncoded: boolean;
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* Logging configuration
|
|
138
|
-
*/
|
|
139
|
-
export type LoggingConfig = {
|
|
140
|
-
/** Enable request logging (default: true) */
|
|
141
|
-
enabled?: boolean;
|
|
142
|
-
/** Log level */
|
|
143
|
-
level?: "debug" | "info" | "warn" | "error";
|
|
144
|
-
/** Include request body in logs */
|
|
145
|
-
includeBody?: boolean;
|
|
146
|
-
/** Include response body in logs */
|
|
147
|
-
includeResponse?: boolean;
|
|
148
|
-
};
|
|
149
|
-
/**
|
|
150
|
-
* Required logging configuration
|
|
151
|
-
*/
|
|
152
|
-
export type RequiredLoggingConfig = {
|
|
153
|
-
enabled: boolean;
|
|
154
|
-
level: "debug" | "info" | "warn" | "error";
|
|
155
|
-
includeBody: boolean;
|
|
156
|
-
includeResponse: boolean;
|
|
157
|
-
};
|
|
158
|
-
/**
|
|
159
|
-
* Configuration for stream redaction
|
|
160
|
-
*
|
|
161
|
-
* IMPORTANT: Redaction is DISABLED by default (enabled: false)
|
|
162
|
-
* This is an opt-in security feature to prevent accidental data exposure.
|
|
163
|
-
*/
|
|
164
|
-
export type RedactionConfig = {
|
|
165
|
-
/**
|
|
166
|
-
* Enable stream redaction (default: false)
|
|
167
|
-
*
|
|
168
|
-
* When false, redactStreamChunk() returns chunks unchanged.
|
|
169
|
-
* Must be explicitly set to true to enable redaction.
|
|
170
|
-
*/
|
|
171
|
-
enabled?: boolean;
|
|
172
|
-
/** Additional field names to redact (case-insensitive) */
|
|
173
|
-
additionalFields?: string[];
|
|
174
|
-
/** Field names to preserve (not redact) */
|
|
175
|
-
preserveFields?: string[];
|
|
176
|
-
/** Whether to redact tool arguments when enabled (default: true) */
|
|
177
|
-
redactToolArgs?: boolean;
|
|
178
|
-
/** Whether to redact tool results when enabled (default: true) */
|
|
179
|
-
redactToolResults?: boolean;
|
|
180
|
-
/** Custom redaction placeholder (default: "[REDACTED]") */
|
|
181
|
-
placeholder?: string;
|
|
182
|
-
};
|
|
183
|
-
/**
|
|
184
|
-
* Server request context
|
|
185
|
-
* Passed to all route handlers and middleware
|
|
186
|
-
*/
|
|
187
|
-
export type ServerContext = {
|
|
188
|
-
/** Unique request ID */
|
|
189
|
-
requestId: string;
|
|
190
|
-
/** HTTP method */
|
|
191
|
-
method: string;
|
|
192
|
-
/** Request path */
|
|
193
|
-
path: string;
|
|
194
|
-
/** Request headers */
|
|
195
|
-
headers: Record<string, string>;
|
|
196
|
-
/** Query parameters */
|
|
197
|
-
query: Record<string, string>;
|
|
198
|
-
/** Path parameters */
|
|
199
|
-
params: Record<string, string>;
|
|
200
|
-
/** Request body (parsed) */
|
|
201
|
-
body?: unknown;
|
|
202
|
-
/** NeuroLink SDK instance */
|
|
203
|
-
neurolink: NeuroLink;
|
|
204
|
-
/** Tool registry instance */
|
|
205
|
-
toolRegistry: MCPToolRegistry;
|
|
206
|
-
/** External server manager (optional) */
|
|
207
|
-
externalServerManager?: ExternalServerManager;
|
|
208
|
-
/** Request timestamp */
|
|
209
|
-
timestamp: number;
|
|
210
|
-
/** Additional metadata */
|
|
211
|
-
metadata: Record<string, unknown>;
|
|
212
|
-
/** User information (if authenticated) */
|
|
213
|
-
user?: {
|
|
214
|
-
id: string;
|
|
215
|
-
email?: string;
|
|
216
|
-
roles?: string[];
|
|
217
|
-
};
|
|
218
|
-
/** Session information */
|
|
219
|
-
session?: {
|
|
220
|
-
id: string;
|
|
221
|
-
data?: Record<string, JsonValue>;
|
|
222
|
-
};
|
|
223
|
-
/** Abort signal for cancellation (set by abort signal middleware) */
|
|
224
|
-
abortSignal?: AbortSignal;
|
|
225
|
-
/** Abort controller for manual cancellation (set by abort signal middleware) */
|
|
226
|
-
abortController?: AbortController;
|
|
227
|
-
/** Raw framework response object (for framework-specific operations) */
|
|
228
|
-
rawResponse?: unknown;
|
|
229
|
-
/** Raw framework request object (for framework-specific operations) */
|
|
230
|
-
rawRequest?: unknown;
|
|
231
|
-
/** Response headers to be set (used by middleware to add headers) */
|
|
232
|
-
responseHeaders?: Record<string, string>;
|
|
233
|
-
/** Redaction configuration (for stream redaction support) */
|
|
234
|
-
redaction?: RedactionConfig;
|
|
235
|
-
};
|
|
236
|
-
/**
|
|
237
|
-
* Server response object
|
|
238
|
-
*/
|
|
239
|
-
export type ServerResponse<T = unknown> = {
|
|
240
|
-
/** Response data */
|
|
241
|
-
data?: T;
|
|
242
|
-
/** Error information */
|
|
243
|
-
error?: {
|
|
244
|
-
code: string;
|
|
245
|
-
message: string;
|
|
246
|
-
details?: Record<string, unknown>;
|
|
247
|
-
};
|
|
248
|
-
/** Response metadata */
|
|
249
|
-
metadata?: {
|
|
250
|
-
requestId: string;
|
|
251
|
-
timestamp: string;
|
|
252
|
-
duration?: number;
|
|
253
|
-
};
|
|
254
|
-
};
|
|
255
|
-
/**
|
|
256
|
-
* Streaming response configuration
|
|
257
|
-
*/
|
|
258
|
-
export type StreamingConfig = {
|
|
259
|
-
/** Enable streaming response */
|
|
260
|
-
enabled: boolean;
|
|
261
|
-
/** Content type for streaming */
|
|
262
|
-
contentType?: "text/event-stream" | "application/x-ndjson";
|
|
263
|
-
/** Keep-alive interval in milliseconds */
|
|
264
|
-
keepAliveInterval?: number;
|
|
265
|
-
};
|
|
266
|
-
/**
|
|
267
|
-
* HTTP methods supported by server adapters
|
|
268
|
-
*/
|
|
269
|
-
export type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS";
|
|
270
|
-
/**
|
|
271
|
-
* Route deprecation information
|
|
272
|
-
*/
|
|
273
|
-
export type RouteDeprecation = {
|
|
274
|
-
/** Whether the route is deprecated */
|
|
275
|
-
enabled: boolean;
|
|
276
|
-
/** Version when deprecated */
|
|
277
|
-
since?: string;
|
|
278
|
-
/** Version when route will be removed */
|
|
279
|
-
removeIn?: string;
|
|
280
|
-
/** Alternative route to use */
|
|
281
|
-
alternative?: string;
|
|
282
|
-
/** Deprecation message */
|
|
283
|
-
message?: string;
|
|
284
|
-
};
|
|
285
|
-
/**
|
|
286
|
-
* Route definition
|
|
287
|
-
*/
|
|
288
|
-
export type RouteDefinition = {
|
|
289
|
-
/** HTTP method */
|
|
290
|
-
method: HttpMethod;
|
|
291
|
-
/** Route path (supports parameters like :id) */
|
|
292
|
-
path: string;
|
|
293
|
-
/** Route handler function */
|
|
294
|
-
handler: RouteHandler;
|
|
295
|
-
/** Route description (for documentation) */
|
|
296
|
-
description?: string;
|
|
297
|
-
/** Request schema (for validation) */
|
|
298
|
-
requestSchema?: JsonObject;
|
|
299
|
-
/** Response schema (for documentation) */
|
|
300
|
-
responseSchema?: JsonObject;
|
|
301
|
-
/** Authentication required */
|
|
302
|
-
auth?: boolean;
|
|
303
|
-
/** Required roles */
|
|
304
|
-
roles?: string[];
|
|
305
|
-
/** Rate limit override for this route */
|
|
306
|
-
rateLimit?: RateLimitConfig;
|
|
307
|
-
/** Streaming configuration */
|
|
308
|
-
streaming?: StreamingConfig;
|
|
309
|
-
/** Route tags (for documentation) */
|
|
310
|
-
tags?: string[];
|
|
311
|
-
/** Route deprecation information */
|
|
312
|
-
deprecated?: RouteDeprecation;
|
|
313
|
-
};
|
|
314
|
-
/**
|
|
315
|
-
* Route handler function
|
|
316
|
-
*/
|
|
317
|
-
export type RouteHandler<T = unknown> = (ctx: ServerContext) => Promise<T | ServerResponse<T> | AsyncIterable<unknown>>;
|
|
318
|
-
/**
|
|
319
|
-
* Route group for organizing related routes
|
|
320
|
-
*/
|
|
321
|
-
export type RouteGroup = {
|
|
322
|
-
/** Group prefix */
|
|
323
|
-
prefix: string;
|
|
324
|
-
/** Routes in this group */
|
|
325
|
-
routes: RouteDefinition[];
|
|
326
|
-
/** Middleware specific to this group */
|
|
327
|
-
middleware?: MiddlewareDefinition[];
|
|
328
|
-
/** Group-level authentication */
|
|
329
|
-
auth?: boolean;
|
|
330
|
-
/** Group-level roles */
|
|
331
|
-
roles?: string[];
|
|
332
|
-
};
|
|
333
|
-
/**
|
|
334
|
-
* Middleware definition
|
|
335
|
-
*/
|
|
336
|
-
export type MiddlewareDefinition = {
|
|
337
|
-
/** Middleware name */
|
|
338
|
-
name: string;
|
|
339
|
-
/** Execution order (lower = earlier) */
|
|
340
|
-
order?: number;
|
|
341
|
-
/** Middleware handler */
|
|
342
|
-
handler: MiddlewareHandler;
|
|
343
|
-
/** Paths to apply middleware to (default: all) */
|
|
344
|
-
paths?: string[];
|
|
345
|
-
/** Paths to exclude from middleware */
|
|
346
|
-
excludePaths?: string[];
|
|
347
|
-
};
|
|
348
|
-
/**
|
|
349
|
-
* Middleware handler function
|
|
350
|
-
*/
|
|
351
|
-
export type MiddlewareHandler = (ctx: ServerContext, next: () => Promise<unknown>) => Promise<unknown>;
|
|
352
|
-
/**
|
|
353
|
-
* Server adapter events
|
|
354
|
-
*/
|
|
355
|
-
export type ServerAdapterEvents = {
|
|
356
|
-
/** Server initialized */
|
|
357
|
-
initialized: {
|
|
358
|
-
config: ServerAdapterConfig;
|
|
359
|
-
routeCount: number;
|
|
360
|
-
middlewareCount: number;
|
|
361
|
-
};
|
|
362
|
-
/** Server started */
|
|
363
|
-
started: {
|
|
364
|
-
port: number;
|
|
365
|
-
host: string;
|
|
366
|
-
timestamp: Date;
|
|
367
|
-
};
|
|
368
|
-
/** Server stopped */
|
|
369
|
-
stopped: {
|
|
370
|
-
uptime: number;
|
|
371
|
-
timestamp: Date;
|
|
372
|
-
};
|
|
373
|
-
/** Request received */
|
|
374
|
-
request: {
|
|
375
|
-
requestId: string;
|
|
376
|
-
method: string;
|
|
377
|
-
path: string;
|
|
378
|
-
timestamp: Date;
|
|
379
|
-
};
|
|
380
|
-
/** Response sent */
|
|
381
|
-
response: {
|
|
382
|
-
requestId: string;
|
|
383
|
-
statusCode: number;
|
|
384
|
-
duration: number;
|
|
385
|
-
timestamp: Date;
|
|
386
|
-
};
|
|
387
|
-
/** Error occurred */
|
|
388
|
-
error: {
|
|
389
|
-
requestId?: string;
|
|
390
|
-
error: Error;
|
|
391
|
-
timestamp: Date;
|
|
392
|
-
};
|
|
393
|
-
};
|
|
394
|
-
/**
|
|
395
|
-
* Agent execution request
|
|
396
|
-
*/
|
|
397
|
-
export type AgentExecuteRequest = {
|
|
398
|
-
/** Input prompt or message */
|
|
399
|
-
input: string | {
|
|
400
|
-
text: string;
|
|
401
|
-
images?: string[];
|
|
402
|
-
files?: string[];
|
|
403
|
-
};
|
|
404
|
-
/** Provider to use (optional) */
|
|
405
|
-
provider?: string;
|
|
406
|
-
/** Model to use (optional) */
|
|
407
|
-
model?: string;
|
|
408
|
-
/** System prompt (optional) */
|
|
409
|
-
systemPrompt?: string;
|
|
410
|
-
/** Temperature (0-1) */
|
|
411
|
-
temperature?: number;
|
|
412
|
-
/** Maximum tokens */
|
|
413
|
-
maxTokens?: number;
|
|
414
|
-
/** Tools to enable */
|
|
415
|
-
tools?: string[];
|
|
416
|
-
/** Enable streaming */
|
|
417
|
-
stream?: boolean;
|
|
418
|
-
/** Session ID for conversation memory */
|
|
419
|
-
sessionId?: string;
|
|
420
|
-
/** User ID for context */
|
|
421
|
-
userId?: string;
|
|
422
|
-
};
|
|
423
|
-
/**
|
|
424
|
-
* Agent execution response
|
|
425
|
-
*/
|
|
426
|
-
export type AgentExecuteResponse = {
|
|
427
|
-
/** Generated content */
|
|
428
|
-
content: string;
|
|
429
|
-
/** Provider used */
|
|
430
|
-
provider: string;
|
|
431
|
-
/** Model used */
|
|
432
|
-
model: string;
|
|
433
|
-
/** Token usage */
|
|
434
|
-
usage?: {
|
|
435
|
-
/** Input tokens (also known as prompt tokens) */
|
|
436
|
-
input: number;
|
|
437
|
-
/** Output tokens (also known as completion tokens) */
|
|
438
|
-
output: number;
|
|
439
|
-
/** Total tokens used */
|
|
440
|
-
total: number;
|
|
441
|
-
/** Cache creation tokens (if applicable) */
|
|
442
|
-
cacheCreationTokens?: number;
|
|
443
|
-
/** Cache read tokens (if applicable) */
|
|
444
|
-
cacheReadTokens?: number;
|
|
445
|
-
/** Reasoning tokens (if applicable) */
|
|
446
|
-
reasoning?: number;
|
|
447
|
-
/** Cache savings percentage */
|
|
448
|
-
cacheSavingsPercent?: number;
|
|
449
|
-
};
|
|
450
|
-
/** Tool calls made */
|
|
451
|
-
toolCalls?: Array<{
|
|
452
|
-
name: string;
|
|
453
|
-
arguments: Record<string, unknown>;
|
|
454
|
-
result?: unknown;
|
|
455
|
-
}>;
|
|
456
|
-
/** Finish reason */
|
|
457
|
-
finishReason?: string;
|
|
458
|
-
/** Response metadata */
|
|
459
|
-
metadata?: Record<string, JsonValue>;
|
|
460
|
-
};
|
|
461
|
-
/**
|
|
462
|
-
* Embed request (single text)
|
|
463
|
-
*/
|
|
464
|
-
export type EmbedRequest = {
|
|
465
|
-
/** Text to embed */
|
|
466
|
-
text: string;
|
|
467
|
-
/** Provider to use (optional) */
|
|
468
|
-
provider?: string;
|
|
469
|
-
/** Embedding model to use (optional) */
|
|
470
|
-
model?: string;
|
|
471
|
-
};
|
|
472
|
-
/**
|
|
473
|
-
* Embed response (single text)
|
|
474
|
-
*/
|
|
475
|
-
export type EmbedResponse = {
|
|
476
|
-
/** The embedding vector */
|
|
477
|
-
embedding: number[];
|
|
478
|
-
/** Provider used */
|
|
479
|
-
provider: string;
|
|
480
|
-
/** Model used */
|
|
481
|
-
model: string;
|
|
482
|
-
/** Embedding dimension */
|
|
483
|
-
dimension: number;
|
|
484
|
-
};
|
|
485
|
-
/**
|
|
486
|
-
* Embed many request (batch texts)
|
|
487
|
-
*/
|
|
488
|
-
export type EmbedManyRequest = {
|
|
489
|
-
/** Texts to embed */
|
|
490
|
-
texts: string[];
|
|
491
|
-
/** Provider to use (optional) */
|
|
492
|
-
provider?: string;
|
|
493
|
-
/** Embedding model to use (optional) */
|
|
494
|
-
model?: string;
|
|
495
|
-
};
|
|
496
|
-
/**
|
|
497
|
-
* Embed many response (batch texts)
|
|
498
|
-
*/
|
|
499
|
-
export type EmbedManyResponse = {
|
|
500
|
-
/** The embedding vectors */
|
|
501
|
-
embeddings: number[][];
|
|
502
|
-
/** Provider used */
|
|
503
|
-
provider: string;
|
|
504
|
-
/** Model used */
|
|
505
|
-
model: string;
|
|
506
|
-
/** Number of embeddings */
|
|
507
|
-
count: number;
|
|
508
|
-
/** Embedding dimension */
|
|
509
|
-
dimension: number;
|
|
510
|
-
};
|
|
511
|
-
/**
|
|
512
|
-
* Tool execution request
|
|
513
|
-
*/
|
|
514
|
-
export type ToolExecuteRequest = {
|
|
515
|
-
/** Tool name */
|
|
516
|
-
name: string;
|
|
517
|
-
/** Tool arguments */
|
|
518
|
-
arguments: Record<string, unknown>;
|
|
519
|
-
/** Session context */
|
|
520
|
-
sessionId?: string;
|
|
521
|
-
/** User context */
|
|
522
|
-
userId?: string;
|
|
523
|
-
};
|
|
524
|
-
/**
|
|
525
|
-
* Tool execution response
|
|
526
|
-
*/
|
|
527
|
-
export type ToolExecuteResponse = {
|
|
528
|
-
/** Whether execution was successful */
|
|
529
|
-
success: boolean;
|
|
530
|
-
/** Result data */
|
|
531
|
-
data?: unknown;
|
|
532
|
-
/** Error message if failed */
|
|
533
|
-
error?: string;
|
|
534
|
-
/** Execution duration in ms */
|
|
535
|
-
duration: number;
|
|
536
|
-
/** Tool metadata */
|
|
537
|
-
metadata?: Record<string, JsonValue>;
|
|
538
|
-
};
|
|
539
|
-
/**
|
|
540
|
-
* MCP server status response
|
|
541
|
-
*/
|
|
542
|
-
export type MCPServerStatusResponse = {
|
|
543
|
-
/** Server ID */
|
|
544
|
-
serverId: string;
|
|
545
|
-
/** Server name */
|
|
546
|
-
name: string;
|
|
547
|
-
/** Connection status */
|
|
548
|
-
status: ExternalMCPServerStatus;
|
|
549
|
-
/** Available tools count */
|
|
550
|
-
toolCount: number;
|
|
551
|
-
/** Last health check time */
|
|
552
|
-
lastHealthCheck?: string;
|
|
553
|
-
/** Error message if failed */
|
|
554
|
-
error?: string;
|
|
555
|
-
};
|
|
556
|
-
/**
|
|
557
|
-
* Health check response
|
|
558
|
-
*/
|
|
559
|
-
export type HealthResponse = {
|
|
560
|
-
/** Health status */
|
|
561
|
-
status: "ok" | "degraded" | "unhealthy";
|
|
562
|
-
/** Timestamp */
|
|
563
|
-
timestamp: string;
|
|
564
|
-
/** Server uptime in milliseconds */
|
|
565
|
-
uptime: number;
|
|
566
|
-
/** Version information */
|
|
567
|
-
version: string;
|
|
568
|
-
};
|
|
569
|
-
/**
|
|
570
|
-
* Ready check response
|
|
571
|
-
*/
|
|
572
|
-
export type ReadyResponse = {
|
|
573
|
-
/** Ready status */
|
|
574
|
-
ready: boolean;
|
|
575
|
-
/** Timestamp */
|
|
576
|
-
timestamp: string;
|
|
577
|
-
/** Service status */
|
|
578
|
-
services: {
|
|
579
|
-
neurolink: boolean;
|
|
580
|
-
tools: boolean;
|
|
581
|
-
externalServers: boolean;
|
|
582
|
-
};
|
|
583
|
-
};
|
|
584
|
-
/**
|
|
585
|
-
* Supported server frameworks
|
|
586
|
-
*/
|
|
587
|
-
export type ServerFramework = "hono" | "express" | "fastify" | "koa";
|
|
588
|
-
/**
|
|
589
|
-
* Server adapter factory options
|
|
590
|
-
*/
|
|
591
|
-
export type ServerAdapterFactoryOptions = {
|
|
592
|
-
/** Framework to use */
|
|
593
|
-
framework: ServerFramework;
|
|
594
|
-
/** NeuroLink instance */
|
|
595
|
-
neurolink: NeuroLink;
|
|
596
|
-
/** Server configuration */
|
|
597
|
-
config?: ServerAdapterConfig;
|
|
598
|
-
};
|
|
599
|
-
/**
|
|
600
|
-
* Server status information
|
|
601
|
-
*/
|
|
602
|
-
export type ServerStatus = {
|
|
603
|
-
/** Whether server is running */
|
|
604
|
-
running: boolean;
|
|
605
|
-
/** Server port */
|
|
606
|
-
port: number;
|
|
607
|
-
/** Server host */
|
|
608
|
-
host: string;
|
|
609
|
-
/** Server uptime in milliseconds */
|
|
610
|
-
uptime: number;
|
|
611
|
-
/** Number of registered routes */
|
|
612
|
-
routes: number;
|
|
613
|
-
/** Number of registered middleware */
|
|
614
|
-
middlewares: number;
|
|
615
|
-
/** Current lifecycle state */
|
|
616
|
-
lifecycleState?: ServerLifecycleState;
|
|
617
|
-
/** Number of active connections */
|
|
618
|
-
activeConnections?: number;
|
|
619
|
-
};
|
|
620
|
-
/**
|
|
621
|
-
* SSE write options
|
|
622
|
-
*/
|
|
623
|
-
export type SSEWriteOptions = {
|
|
624
|
-
/** Event name */
|
|
625
|
-
event?: string;
|
|
626
|
-
/** Event data (will be JSON stringified if object) */
|
|
627
|
-
data: string | object;
|
|
628
|
-
/** Event ID */
|
|
629
|
-
id?: string;
|
|
630
|
-
/** Retry interval in milliseconds */
|
|
631
|
-
retry?: number;
|
|
632
|
-
};
|
|
633
|
-
/**
|
|
634
|
-
* Data stream writer interface
|
|
635
|
-
*/
|
|
636
|
-
export type DataStreamWriter = {
|
|
637
|
-
/** Write text start event */
|
|
638
|
-
writeTextStart(id: string): Promise<void>;
|
|
639
|
-
/** Write text delta event */
|
|
640
|
-
writeTextDelta(id: string, delta: string): Promise<void>;
|
|
641
|
-
/** Write text end event */
|
|
642
|
-
writeTextEnd(id: string): Promise<void>;
|
|
643
|
-
/** Write tool call event */
|
|
644
|
-
writeToolCall(toolCall: {
|
|
645
|
-
id: string;
|
|
646
|
-
name: string;
|
|
647
|
-
arguments: Record<string, unknown>;
|
|
648
|
-
}): Promise<void>;
|
|
649
|
-
/** Write tool result event */
|
|
650
|
-
writeToolResult(toolResult: {
|
|
651
|
-
id: string;
|
|
652
|
-
name: string;
|
|
653
|
-
result: unknown;
|
|
654
|
-
}): Promise<void>;
|
|
655
|
-
/** Write arbitrary data event */
|
|
656
|
-
writeData(data: unknown): Promise<void>;
|
|
657
|
-
/** Write error event */
|
|
658
|
-
writeError(error: {
|
|
659
|
-
message: string;
|
|
660
|
-
code?: string;
|
|
661
|
-
}): Promise<void>;
|
|
662
|
-
/** Close the stream */
|
|
663
|
-
close(): Promise<void>;
|
|
664
|
-
};
|
|
665
|
-
/**
|
|
666
|
-
* WebSocket message types
|
|
667
|
-
*/
|
|
668
|
-
export type WebSocketMessageType = "text" | "binary" | "ping" | "pong" | "close";
|
|
669
|
-
/**
|
|
670
|
-
* WebSocket message
|
|
671
|
-
*/
|
|
672
|
-
export type WebSocketMessage = {
|
|
673
|
-
type: WebSocketMessageType;
|
|
674
|
-
data: string | ArrayBuffer;
|
|
675
|
-
timestamp: number;
|
|
676
|
-
};
|
|
677
|
-
/**
|
|
678
|
-
* Authenticated user information
|
|
679
|
-
*/
|
|
680
|
-
export type AuthenticatedUser = {
|
|
681
|
-
id: string;
|
|
682
|
-
email?: string;
|
|
683
|
-
name?: string;
|
|
684
|
-
roles?: string[];
|
|
685
|
-
permissions?: string[];
|
|
686
|
-
metadata?: Record<string, unknown>;
|
|
687
|
-
};
|
|
688
|
-
/**
|
|
689
|
-
* WebSocket connection
|
|
690
|
-
*/
|
|
691
|
-
export type WebSocketConnection = {
|
|
692
|
-
id: string;
|
|
693
|
-
socket: unknown;
|
|
694
|
-
user?: AuthenticatedUser;
|
|
695
|
-
metadata: Record<string, unknown>;
|
|
696
|
-
createdAt: number;
|
|
697
|
-
lastActivity: number;
|
|
698
|
-
};
|
|
699
|
-
/**
|
|
700
|
-
* Authentication strategy types
|
|
701
|
-
*/
|
|
702
|
-
export type AuthStrategy = "bearer" | "apiKey" | "basic" | "custom" | "none";
|
|
703
|
-
/**
|
|
704
|
-
* Authentication configuration
|
|
705
|
-
*/
|
|
706
|
-
export type AuthConfig = {
|
|
707
|
-
strategy: AuthStrategy;
|
|
708
|
-
required?: boolean;
|
|
709
|
-
headerName?: string;
|
|
710
|
-
queryParam?: string;
|
|
711
|
-
validate?: (token: string) => Promise<AuthenticatedUser | null>;
|
|
712
|
-
roles?: string[];
|
|
713
|
-
permissions?: string[];
|
|
714
|
-
};
|
|
715
|
-
/**
|
|
716
|
-
* WebSocket handler interface
|
|
717
|
-
*/
|
|
718
|
-
export type WebSocketHandler = {
|
|
719
|
-
onOpen?: (connection: WebSocketConnection) => void | Promise<void>;
|
|
720
|
-
onMessage?: (connection: WebSocketConnection, message: WebSocketMessage) => void | Promise<void>;
|
|
721
|
-
onClose?: (connection: WebSocketConnection, code: number, reason: string) => void | Promise<void>;
|
|
722
|
-
onError?: (connection: WebSocketConnection, error: Error) => void | Promise<void>;
|
|
723
|
-
};
|
|
724
|
-
/**
|
|
725
|
-
* WebSocket server configuration
|
|
726
|
-
*/
|
|
727
|
-
export type WebSocketConfig = {
|
|
728
|
-
path?: string;
|
|
729
|
-
maxConnections?: number;
|
|
730
|
-
pingInterval?: number;
|
|
731
|
-
pongTimeout?: number;
|
|
732
|
-
maxMessageSize?: number;
|
|
733
|
-
auth?: AuthConfig;
|
|
734
|
-
};
|
|
735
|
-
/**
|
|
736
|
-
* Server lifecycle states
|
|
737
|
-
* Represents the current state of the server adapter
|
|
738
|
-
*/
|
|
739
|
-
export type ServerLifecycleState = "uninitialized" | "initializing" | "initialized" | "starting" | "running" | "draining" | "stopping" | "stopped" | "error";
|
|
740
|
-
/**
|
|
741
|
-
* Configuration for graceful shutdown behavior
|
|
742
|
-
*/
|
|
743
|
-
export type ShutdownConfig = {
|
|
744
|
-
/**
|
|
745
|
-
* Maximum time to wait for graceful shutdown in milliseconds
|
|
746
|
-
* Default: 30000 (30 seconds)
|
|
747
|
-
*/
|
|
748
|
-
gracefulShutdownTimeoutMs?: number;
|
|
749
|
-
/**
|
|
750
|
-
* Maximum time to wait for connections to drain in milliseconds
|
|
751
|
-
* Default: 15000 (15 seconds)
|
|
752
|
-
*/
|
|
753
|
-
drainTimeoutMs?: number;
|
|
754
|
-
/**
|
|
755
|
-
* Whether to force close connections after timeout
|
|
756
|
-
* Default: true
|
|
757
|
-
*/
|
|
758
|
-
forceClose?: boolean;
|
|
759
|
-
};
|
|
760
|
-
/**
|
|
761
|
-
* Required shutdown configuration (with defaults applied)
|
|
762
|
-
*/
|
|
763
|
-
export type RequiredShutdownConfig = {
|
|
764
|
-
gracefulShutdownTimeoutMs: number;
|
|
765
|
-
drainTimeoutMs: number;
|
|
766
|
-
forceClose: boolean;
|
|
767
|
-
};
|
|
768
|
-
/**
|
|
769
|
-
* Tracked connection for graceful shutdown
|
|
770
|
-
*/
|
|
771
|
-
export type TrackedConnection = {
|
|
772
|
-
/** Unique connection identifier */
|
|
773
|
-
id: string;
|
|
774
|
-
/** Timestamp when connection was created */
|
|
775
|
-
createdAt: number;
|
|
776
|
-
/** Underlying socket or connection object */
|
|
777
|
-
socket?: unknown;
|
|
778
|
-
/** Request ID if associated with a request */
|
|
779
|
-
requestId?: string;
|
|
780
|
-
/** Whether the connection is currently processing a request */
|
|
781
|
-
isActive?: boolean;
|
|
782
|
-
};
|
|
783
|
-
/**
|
|
784
|
-
* Error categories for server adapter errors
|
|
785
|
-
*/
|
|
786
|
-
export declare const ErrorCategory: {
|
|
787
|
-
readonly CONFIG: "CONFIG";
|
|
788
|
-
readonly VALIDATION: "VALIDATION";
|
|
789
|
-
readonly EXECUTION: "EXECUTION";
|
|
790
|
-
readonly EXTERNAL: "EXTERNAL";
|
|
791
|
-
readonly RATE_LIMIT: "RATE_LIMIT";
|
|
792
|
-
readonly AUTHENTICATION: "AUTHENTICATION";
|
|
793
|
-
readonly AUTHORIZATION: "AUTHORIZATION";
|
|
794
|
-
readonly STREAMING: "STREAMING";
|
|
795
|
-
readonly WEBSOCKET: "WEBSOCKET";
|
|
796
|
-
};
|
|
797
|
-
export type ErrorCategoryType = (typeof ErrorCategory)[keyof typeof ErrorCategory];
|
|
798
|
-
/**
|
|
799
|
-
* Error severity levels
|
|
800
|
-
*/
|
|
801
|
-
export declare const ErrorSeverity: {
|
|
802
|
-
readonly LOW: "LOW";
|
|
803
|
-
readonly MEDIUM: "MEDIUM";
|
|
804
|
-
readonly HIGH: "HIGH";
|
|
805
|
-
readonly CRITICAL: "CRITICAL";
|
|
806
|
-
};
|
|
807
|
-
export type ErrorSeverityType = (typeof ErrorSeverity)[keyof typeof ErrorSeverity];
|
|
808
|
-
/**
|
|
809
|
-
* Server adapter error codes
|
|
810
|
-
*/
|
|
811
|
-
export declare const ServerAdapterErrorCode: {
|
|
812
|
-
readonly INVALID_CONFIG: "SERVER_ADAPTER_INVALID_CONFIG";
|
|
813
|
-
readonly MISSING_DEPENDENCY: "SERVER_ADAPTER_MISSING_DEPENDENCY";
|
|
814
|
-
readonly FRAMEWORK_INIT_FAILED: "SERVER_ADAPTER_FRAMEWORK_INIT_FAILED";
|
|
815
|
-
readonly ROUTE_NOT_FOUND: "SERVER_ADAPTER_ROUTE_NOT_FOUND";
|
|
816
|
-
readonly ROUTE_CONFLICT: "SERVER_ADAPTER_ROUTE_CONFLICT";
|
|
817
|
-
readonly INVALID_ROUTE: "SERVER_ADAPTER_INVALID_ROUTE";
|
|
818
|
-
readonly HANDLER_ERROR: "SERVER_ADAPTER_HANDLER_ERROR";
|
|
819
|
-
readonly TIMEOUT: "SERVER_ADAPTER_TIMEOUT";
|
|
820
|
-
readonly MIDDLEWARE_ERROR: "SERVER_ADAPTER_MIDDLEWARE_ERROR";
|
|
821
|
-
readonly RATE_LIMIT_EXCEEDED: "SERVER_ADAPTER_RATE_LIMIT_EXCEEDED";
|
|
822
|
-
readonly AUTH_REQUIRED: "SERVER_ADAPTER_AUTH_REQUIRED";
|
|
823
|
-
readonly AUTH_INVALID: "SERVER_ADAPTER_AUTH_INVALID";
|
|
824
|
-
readonly FORBIDDEN: "SERVER_ADAPTER_FORBIDDEN";
|
|
825
|
-
readonly STREAM_ERROR: "SERVER_ADAPTER_STREAM_ERROR";
|
|
826
|
-
readonly STREAM_ABORTED: "SERVER_ADAPTER_STREAM_ABORTED";
|
|
827
|
-
readonly WEBSOCKET_ERROR: "SERVER_ADAPTER_WEBSOCKET_ERROR";
|
|
828
|
-
readonly WEBSOCKET_CONNECTION_FAILED: "SERVER_ADAPTER_WEBSOCKET_CONNECTION_FAILED";
|
|
829
|
-
readonly VALIDATION_ERROR: "SERVER_ADAPTER_VALIDATION_ERROR";
|
|
830
|
-
readonly SCHEMA_ERROR: "SERVER_ADAPTER_SCHEMA_ERROR";
|
|
831
|
-
readonly START_FAILED: "SERVER_ADAPTER_START_FAILED";
|
|
832
|
-
readonly STOP_FAILED: "SERVER_ADAPTER_STOP_FAILED";
|
|
833
|
-
readonly ALREADY_RUNNING: "SERVER_ADAPTER_ALREADY_RUNNING";
|
|
834
|
-
readonly NOT_RUNNING: "SERVER_ADAPTER_NOT_RUNNING";
|
|
835
|
-
};
|
|
836
|
-
export type ServerAdapterErrorCodeType = (typeof ServerAdapterErrorCode)[keyof typeof ServerAdapterErrorCode];
|
|
837
|
-
/**
|
|
838
|
-
* Error context for server adapter errors
|
|
839
|
-
*/
|
|
840
|
-
export type ServerAdapterErrorContext = {
|
|
841
|
-
category: ErrorCategoryType;
|
|
842
|
-
severity: ErrorSeverityType;
|
|
843
|
-
retryable: boolean;
|
|
844
|
-
retryAfterMs?: number;
|
|
845
|
-
requestId?: string;
|
|
846
|
-
path?: string;
|
|
847
|
-
method?: string;
|
|
848
|
-
details?: Record<string, unknown>;
|
|
849
|
-
cause?: Error;
|
|
850
|
-
};
|
|
6
|
+
export * from "../types/serverTypes.js";
|