@juspay/neurolink 7.48.1 → 7.50.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 +19 -0
- package/README.md +215 -16
- package/dist/agent/directTools.d.ts +55 -0
- package/dist/agent/directTools.js +266 -0
- package/dist/cli/factories/commandFactory.d.ts +6 -0
- package/dist/cli/factories/commandFactory.js +149 -16
- package/dist/cli/index.js +13 -2
- package/dist/cli/loop/conversationSelector.d.ts +45 -0
- package/dist/cli/loop/conversationSelector.js +222 -0
- package/dist/cli/loop/optionsSchema.d.ts +1 -1
- package/dist/cli/loop/session.d.ts +36 -8
- package/dist/cli/loop/session.js +257 -61
- package/dist/core/baseProvider.d.ts +9 -0
- package/dist/core/baseProvider.js +45 -5
- package/dist/core/evaluation.js +5 -2
- package/dist/factories/providerRegistry.js +2 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +11 -10
- package/dist/lib/agent/directTools.d.ts +55 -0
- package/dist/lib/agent/directTools.js +266 -0
- package/dist/lib/core/baseProvider.d.ts +9 -0
- package/dist/lib/core/baseProvider.js +45 -5
- package/dist/lib/core/evaluation.js +5 -2
- package/dist/lib/factories/providerRegistry.js +2 -2
- package/dist/lib/index.d.ts +8 -2
- package/dist/lib/index.js +11 -10
- package/dist/lib/mcp/factory.d.ts +2 -157
- package/dist/lib/mcp/flexibleToolValidator.d.ts +1 -5
- package/dist/lib/mcp/index.d.ts +3 -2
- package/dist/lib/mcp/mcpCircuitBreaker.d.ts +1 -75
- package/dist/lib/mcp/mcpClientFactory.d.ts +1 -20
- package/dist/lib/mcp/mcpClientFactory.js +1 -0
- package/dist/lib/mcp/registry.d.ts +3 -10
- package/dist/lib/mcp/servers/agent/directToolsServer.d.ts +1 -1
- package/dist/lib/mcp/servers/aiProviders/aiCoreServer.d.ts +1 -1
- package/dist/lib/mcp/servers/utilities/utilityServer.d.ts +1 -1
- package/dist/lib/mcp/toolDiscoveryService.d.ts +3 -84
- package/dist/lib/mcp/toolRegistry.d.ts +2 -24
- package/dist/lib/middleware/builtin/guardrails.d.ts +5 -16
- package/dist/lib/middleware/builtin/guardrails.js +44 -39
- package/dist/lib/middleware/utils/guardrailsUtils.d.ts +64 -0
- package/dist/lib/middleware/utils/guardrailsUtils.js +387 -0
- package/dist/lib/neurolink.d.ts +36 -7
- package/dist/lib/neurolink.js +141 -0
- package/dist/lib/providers/anthropic.js +47 -3
- package/dist/lib/providers/azureOpenai.js +9 -2
- package/dist/lib/providers/googleAiStudio.js +9 -2
- package/dist/lib/providers/googleVertex.js +12 -2
- package/dist/lib/providers/huggingFace.js +1 -1
- package/dist/lib/providers/litellm.js +1 -1
- package/dist/lib/providers/mistral.js +1 -1
- package/dist/lib/providers/openAI.js +47 -3
- package/dist/lib/services/server/ai/observability/instrumentation.d.ts +57 -0
- package/dist/lib/services/server/ai/observability/instrumentation.js +170 -0
- package/dist/lib/session/globalSessionState.d.ts +26 -0
- package/dist/lib/session/globalSessionState.js +86 -1
- package/dist/lib/telemetry/index.d.ts +1 -0
- package/dist/lib/telemetry/telemetryService.d.ts +2 -0
- package/dist/lib/telemetry/telemetryService.js +7 -7
- package/dist/lib/types/cli.d.ts +28 -0
- package/dist/lib/types/content.d.ts +18 -5
- package/dist/lib/types/contextTypes.d.ts +1 -1
- package/dist/lib/types/conversation.d.ts +57 -4
- package/dist/lib/types/fileTypes.d.ts +65 -0
- package/dist/lib/types/fileTypes.js +4 -0
- package/dist/lib/types/generateTypes.d.ts +12 -0
- package/dist/lib/types/guardrails.d.ts +103 -0
- package/dist/lib/types/guardrails.js +1 -0
- package/dist/lib/types/index.d.ts +4 -2
- package/dist/lib/types/index.js +4 -0
- package/dist/lib/types/mcpTypes.d.ts +407 -14
- package/dist/lib/types/modelTypes.d.ts +6 -6
- package/dist/lib/types/observability.d.ts +49 -0
- package/dist/lib/types/observability.js +6 -0
- package/dist/lib/types/streamTypes.d.ts +7 -0
- package/dist/lib/types/tools.d.ts +132 -35
- package/dist/lib/utils/csvProcessor.d.ts +68 -0
- package/dist/lib/utils/csvProcessor.js +277 -0
- package/dist/lib/utils/fileDetector.d.ts +57 -0
- package/dist/lib/utils/fileDetector.js +457 -0
- package/dist/lib/utils/imageProcessor.d.ts +10 -0
- package/dist/lib/utils/imageProcessor.js +22 -0
- package/dist/lib/utils/loopUtils.d.ts +71 -0
- package/dist/lib/utils/loopUtils.js +262 -0
- package/dist/lib/utils/messageBuilder.d.ts +2 -1
- package/dist/lib/utils/messageBuilder.js +197 -2
- package/dist/lib/utils/optionsUtils.d.ts +1 -1
- package/dist/mcp/factory.d.ts +2 -157
- package/dist/mcp/flexibleToolValidator.d.ts +1 -5
- package/dist/mcp/index.d.ts +3 -2
- package/dist/mcp/mcpCircuitBreaker.d.ts +1 -75
- package/dist/mcp/mcpClientFactory.d.ts +1 -20
- package/dist/mcp/mcpClientFactory.js +1 -0
- package/dist/mcp/registry.d.ts +3 -10
- package/dist/mcp/servers/agent/directToolsServer.d.ts +1 -1
- package/dist/mcp/servers/aiProviders/aiCoreServer.d.ts +1 -1
- package/dist/mcp/servers/utilities/utilityServer.d.ts +1 -1
- package/dist/mcp/toolDiscoveryService.d.ts +3 -84
- package/dist/mcp/toolRegistry.d.ts +2 -24
- package/dist/middleware/builtin/guardrails.d.ts +5 -16
- package/dist/middleware/builtin/guardrails.js +44 -39
- package/dist/middleware/utils/guardrailsUtils.d.ts +64 -0
- package/dist/middleware/utils/guardrailsUtils.js +387 -0
- package/dist/neurolink.d.ts +36 -7
- package/dist/neurolink.js +141 -0
- package/dist/providers/anthropic.js +47 -3
- package/dist/providers/azureOpenai.js +9 -2
- package/dist/providers/googleAiStudio.js +9 -2
- package/dist/providers/googleVertex.js +12 -2
- package/dist/providers/huggingFace.js +1 -1
- package/dist/providers/litellm.js +1 -1
- package/dist/providers/mistral.js +1 -1
- package/dist/providers/openAI.js +47 -3
- 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.d.ts +26 -0
- package/dist/session/globalSessionState.js +86 -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/cli.d.ts +28 -0
- package/dist/types/content.d.ts +18 -5
- package/dist/types/contextTypes.d.ts +1 -1
- package/dist/types/conversation.d.ts +57 -4
- package/dist/types/fileTypes.d.ts +65 -0
- package/dist/types/fileTypes.js +4 -0
- package/dist/types/generateTypes.d.ts +12 -0
- package/dist/types/guardrails.d.ts +103 -0
- package/dist/types/guardrails.js +1 -0
- package/dist/types/index.d.ts +4 -2
- package/dist/types/index.js +4 -0
- package/dist/types/mcpTypes.d.ts +407 -14
- package/dist/types/modelTypes.d.ts +6 -6
- package/dist/types/observability.d.ts +49 -0
- package/dist/types/observability.js +6 -0
- package/dist/types/streamTypes.d.ts +7 -0
- package/dist/types/tools.d.ts +132 -35
- package/dist/utils/csvProcessor.d.ts +68 -0
- package/dist/utils/csvProcessor.js +277 -0
- package/dist/utils/fileDetector.d.ts +57 -0
- package/dist/utils/fileDetector.js +457 -0
- package/dist/utils/imageProcessor.d.ts +10 -0
- package/dist/utils/imageProcessor.js +22 -0
- package/dist/utils/loopUtils.d.ts +71 -0
- package/dist/utils/loopUtils.js +262 -0
- package/dist/utils/messageBuilder.d.ts +2 -1
- package/dist/utils/messageBuilder.js +197 -2
- package/dist/utils/optionsUtils.d.ts +1 -1
- package/package.json +18 -16
- package/dist/lib/mcp/contracts/mcpContract.d.ts +0 -106
- package/dist/lib/mcp/contracts/mcpContract.js +0 -5
- package/dist/mcp/contracts/mcpContract.d.ts +0 -106
- package/dist/mcp/contracts/mcpContract.js +0 -5
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observability Configuration Types
|
|
3
|
+
* These configs are passed from the parent application (e.g., Lighthouse)
|
|
4
|
+
* to enable telemetry and observability features in Neurolink SDK
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Langfuse observability configuration
|
|
8
|
+
*/
|
|
9
|
+
export interface LangfuseConfig {
|
|
10
|
+
/** Whether Langfuse is enabled */
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
/** Langfuse public key */
|
|
13
|
+
publicKey: string;
|
|
14
|
+
/**
|
|
15
|
+
* Langfuse secret key
|
|
16
|
+
* @sensitive
|
|
17
|
+
* WARNING: This is a sensitive credential. Handle securely.
|
|
18
|
+
* Do NOT log, expose, or share this key. Follow best practices for secret management.
|
|
19
|
+
*/
|
|
20
|
+
secretKey: string;
|
|
21
|
+
/** Langfuse base URL (default: https://cloud.langfuse.com) */
|
|
22
|
+
baseUrl?: string;
|
|
23
|
+
/** Environment name (e.g., dev, staging, prod) */
|
|
24
|
+
environment?: string;
|
|
25
|
+
/** Release/version identifier */
|
|
26
|
+
release?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* OpenTelemetry configuration
|
|
30
|
+
*/
|
|
31
|
+
export interface OpenTelemetryConfig {
|
|
32
|
+
/** Whether OpenTelemetry is enabled */
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
/** OTLP endpoint URL */
|
|
35
|
+
endpoint?: string;
|
|
36
|
+
/** Service name for traces */
|
|
37
|
+
serviceName?: string;
|
|
38
|
+
/** Service version */
|
|
39
|
+
serviceVersion?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Complete observability configuration for Neurolink SDK
|
|
43
|
+
*/
|
|
44
|
+
export interface ObservabilityConfig {
|
|
45
|
+
/** Langfuse configuration */
|
|
46
|
+
langfuse?: LangfuseConfig;
|
|
47
|
+
/** OpenTelemetry configuration */
|
|
48
|
+
openTelemetry?: OpenTelemetryConfig;
|
|
49
|
+
}
|
|
@@ -125,6 +125,8 @@ export interface StreamOptions {
|
|
|
125
125
|
text: string;
|
|
126
126
|
audio?: AudioInputSpec;
|
|
127
127
|
images?: Array<Buffer | string>;
|
|
128
|
+
csvFiles?: Array<Buffer | string>;
|
|
129
|
+
files?: Array<Buffer | string>;
|
|
128
130
|
content?: Array<TextContent | ImageContent>;
|
|
129
131
|
};
|
|
130
132
|
output?: {
|
|
@@ -135,6 +137,11 @@ export interface StreamOptions {
|
|
|
135
137
|
enableProgress?: boolean;
|
|
136
138
|
};
|
|
137
139
|
};
|
|
140
|
+
csvOptions?: {
|
|
141
|
+
maxRows?: number;
|
|
142
|
+
formatStyle?: "raw" | "markdown" | "json";
|
|
143
|
+
includeHeaders?: boolean;
|
|
144
|
+
};
|
|
138
145
|
provider?: AIProviderName | string;
|
|
139
146
|
model?: string;
|
|
140
147
|
region?: string;
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import type { Result, JsonValue, ErrorInfo } from "./common.js";
|
|
7
|
+
import type { StandardRecord, ZodUnknownSchema } from "./typeAliases.js";
|
|
7
8
|
/**
|
|
8
9
|
* Commonly used Zod schema type aliases for cleaner type declarations
|
|
9
10
|
*/
|
|
10
|
-
import type { ZodUnknownSchema } from "./typeAliases.js";
|
|
11
11
|
export type { ZodUnknownSchema } from "./typeAliases.js";
|
|
12
12
|
export type ZodAnySchema = z.ZodSchema<unknown>;
|
|
13
13
|
export type ZodObjectSchema = z.ZodObject<z.ZodRawShape>;
|
|
@@ -19,148 +19,245 @@ export type ToolParameterSchema = ZodUnknownSchema | Record<string, JsonValue>;
|
|
|
19
19
|
/**
|
|
20
20
|
* Standard tool input parameters
|
|
21
21
|
*/
|
|
22
|
-
export
|
|
22
|
+
export type BaseToolArgs = {
|
|
23
23
|
[key: string]: JsonValue | undefined;
|
|
24
|
-
}
|
|
24
|
+
};
|
|
25
25
|
/**
|
|
26
26
|
* Tool execution arguments with specific common patterns
|
|
27
27
|
*/
|
|
28
|
-
export
|
|
28
|
+
export type ToolArgs = BaseToolArgs & {
|
|
29
29
|
input?: JsonValue;
|
|
30
30
|
data?: JsonValue;
|
|
31
31
|
options?: JsonValue;
|
|
32
|
-
}
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Generic execution context for MCP operations
|
|
35
|
+
* Moved from src/lib/mcp/contracts/mcpContract.ts
|
|
36
|
+
*/
|
|
37
|
+
export type ExecutionContext<T = StandardRecord> = {
|
|
38
|
+
sessionId?: string;
|
|
39
|
+
userId?: string;
|
|
40
|
+
config?: T;
|
|
41
|
+
metadata?: StandardRecord;
|
|
42
|
+
cacheOptions?: CacheOptions;
|
|
43
|
+
fallbackOptions?: FallbackOptions;
|
|
44
|
+
timeoutMs?: number;
|
|
45
|
+
startTime?: number;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Cache configuration options
|
|
49
|
+
* Moved from src/lib/mcp/contracts/mcpContract.ts
|
|
50
|
+
*/
|
|
51
|
+
export type CacheOptions = {
|
|
52
|
+
enabled?: boolean;
|
|
53
|
+
ttlMs?: number;
|
|
54
|
+
strategy?: "memory" | "writeThrough" | "cacheAside";
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Fallback configuration options
|
|
58
|
+
* Moved from src/lib/mcp/contracts/mcpContract.ts
|
|
59
|
+
*/
|
|
60
|
+
export type FallbackOptions = {
|
|
61
|
+
enabled?: boolean;
|
|
62
|
+
maxAttempts?: number;
|
|
63
|
+
delayMs?: number;
|
|
64
|
+
circuitBreaker?: boolean;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Tool information with extensibility
|
|
68
|
+
* Moved from src/lib/mcp/contracts/mcpContract.ts
|
|
69
|
+
*/
|
|
70
|
+
export type ToolInfo = {
|
|
71
|
+
name: string;
|
|
72
|
+
description?: string;
|
|
73
|
+
category?: string;
|
|
74
|
+
serverId?: string;
|
|
75
|
+
inputSchema?: StandardRecord;
|
|
76
|
+
outputSchema?: StandardRecord;
|
|
77
|
+
[key: string]: unknown;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Tool Implementation type for MCP tool registry
|
|
81
|
+
* Extracted from toolRegistry.ts for centralized type management
|
|
82
|
+
*/
|
|
83
|
+
export type ToolImplementation = {
|
|
84
|
+
execute: (params: unknown, context?: ExecutionContext) => Promise<unknown> | unknown;
|
|
85
|
+
description?: string;
|
|
86
|
+
inputSchema?: unknown;
|
|
87
|
+
outputSchema?: unknown;
|
|
88
|
+
category?: string;
|
|
89
|
+
permissions?: string[];
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Tool execution options for enhanced control
|
|
93
|
+
* Extracted from toolRegistry.ts for centralized type management
|
|
94
|
+
*/
|
|
95
|
+
export type ToolExecutionOptions = {
|
|
96
|
+
timeout?: number;
|
|
97
|
+
retries?: number;
|
|
98
|
+
context?: unknown;
|
|
99
|
+
preferredSource?: string;
|
|
100
|
+
fallbackEnabled?: boolean;
|
|
101
|
+
validateBeforeExecution?: boolean;
|
|
102
|
+
timeoutMs?: number;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Tool execution result
|
|
106
|
+
* Moved from src/lib/mcp/contracts/mcpContract.ts
|
|
107
|
+
*/
|
|
108
|
+
export type ToolExecutionResult<T = unknown> = {
|
|
109
|
+
result: T;
|
|
110
|
+
context?: ExecutionContext;
|
|
111
|
+
performance?: {
|
|
112
|
+
duration: number;
|
|
113
|
+
tokensUsed?: number;
|
|
114
|
+
cost?: number;
|
|
115
|
+
};
|
|
116
|
+
validation?: ValidationResult;
|
|
117
|
+
cached?: boolean;
|
|
118
|
+
fallback?: boolean;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Validation result for runtime checks
|
|
122
|
+
* Moved from src/lib/mcp/contracts/mcpContract.ts
|
|
123
|
+
*/
|
|
124
|
+
export type ValidationResult = {
|
|
125
|
+
valid: boolean;
|
|
126
|
+
missing: string[];
|
|
127
|
+
warnings: string[];
|
|
128
|
+
recommendations: string[];
|
|
129
|
+
};
|
|
33
130
|
/**
|
|
34
131
|
* Tool execution metadata
|
|
35
132
|
*/
|
|
36
|
-
export
|
|
133
|
+
export type ToolExecutionMetadata = {
|
|
37
134
|
requestId?: string;
|
|
38
135
|
startTime?: number;
|
|
39
136
|
version?: string;
|
|
40
137
|
[key: string]: JsonValue | undefined;
|
|
41
|
-
}
|
|
138
|
+
};
|
|
42
139
|
/**
|
|
43
140
|
* Tool execution context
|
|
44
141
|
*/
|
|
45
|
-
export
|
|
142
|
+
export type ToolContext = {
|
|
46
143
|
sessionId?: string;
|
|
47
144
|
userId?: string;
|
|
48
145
|
aiProvider?: string;
|
|
49
146
|
metadata?: ToolExecutionMetadata;
|
|
50
|
-
}
|
|
147
|
+
};
|
|
51
148
|
/**
|
|
52
149
|
* Tool execution result metadata
|
|
53
150
|
*/
|
|
54
|
-
export
|
|
151
|
+
export type ToolResultMetadata = {
|
|
55
152
|
toolName?: string;
|
|
56
153
|
executionTime?: number;
|
|
57
154
|
timestamp?: number;
|
|
58
155
|
source?: string;
|
|
59
156
|
version?: string;
|
|
60
157
|
serverId?: string;
|
|
61
|
-
}
|
|
158
|
+
};
|
|
62
159
|
/**
|
|
63
160
|
* Tool execution result
|
|
64
161
|
*/
|
|
65
|
-
export
|
|
162
|
+
export type ToolResult<T = JsonValue> = Result<T, ErrorInfo> & {
|
|
66
163
|
success: boolean;
|
|
67
164
|
data?: T;
|
|
68
165
|
error?: ErrorInfo;
|
|
69
166
|
metadata?: ToolResultMetadata;
|
|
70
|
-
}
|
|
167
|
+
};
|
|
71
168
|
/**
|
|
72
169
|
* Tool metadata for registration
|
|
73
170
|
*/
|
|
74
|
-
export
|
|
171
|
+
export type ToolMetadata = {
|
|
75
172
|
category?: string;
|
|
76
173
|
version?: string;
|
|
77
174
|
author?: string;
|
|
78
175
|
tags?: string[];
|
|
79
176
|
documentation?: string;
|
|
80
177
|
[key: string]: JsonValue | undefined;
|
|
81
|
-
}
|
|
178
|
+
};
|
|
82
179
|
/**
|
|
83
|
-
* Tool definition
|
|
180
|
+
* Tool definition type
|
|
84
181
|
*/
|
|
85
|
-
export
|
|
182
|
+
export type ToolDefinition<TArgs = ToolArgs, TResult = JsonValue> = {
|
|
86
183
|
description: string;
|
|
87
184
|
parameters?: ToolParameterSchema;
|
|
88
185
|
metadata?: ToolMetadata;
|
|
89
186
|
execute: (params: TArgs, context?: ToolContext) => Promise<ToolResult<TResult>> | ToolResult<TResult>;
|
|
90
|
-
}
|
|
187
|
+
};
|
|
91
188
|
/**
|
|
92
|
-
* Simple tool
|
|
189
|
+
* Simple tool type (for SDK)
|
|
93
190
|
*/
|
|
94
|
-
export
|
|
191
|
+
export type SimpleTool<TArgs = ToolArgs, TResult = JsonValue> = {
|
|
95
192
|
description: string;
|
|
96
193
|
parameters?: ZodUnknownSchema;
|
|
97
194
|
metadata?: ToolMetadata;
|
|
98
195
|
execute: (params: TArgs, context?: ToolContext) => Promise<TResult>;
|
|
99
|
-
}
|
|
196
|
+
};
|
|
100
197
|
/**
|
|
101
198
|
* Tool registry entry
|
|
102
199
|
*/
|
|
103
|
-
export
|
|
200
|
+
export type ToolRegistryEntry = {
|
|
104
201
|
name: string;
|
|
105
202
|
description: string;
|
|
106
203
|
serverId?: string;
|
|
107
204
|
isImplemented?: boolean;
|
|
108
205
|
parameters?: ToolParameterSchema;
|
|
109
206
|
execute?: ToolDefinition["execute"];
|
|
110
|
-
}
|
|
207
|
+
};
|
|
111
208
|
/**
|
|
112
209
|
* Tool execution information
|
|
113
210
|
*/
|
|
114
|
-
export
|
|
211
|
+
export type ToolExecution = {
|
|
115
212
|
toolName: string;
|
|
116
213
|
params: ToolArgs;
|
|
117
214
|
result: ToolResult;
|
|
118
215
|
executionTime: number;
|
|
119
216
|
timestamp: number;
|
|
120
|
-
}
|
|
217
|
+
};
|
|
121
218
|
/**
|
|
122
219
|
* Available tool information
|
|
123
220
|
*/
|
|
124
|
-
export
|
|
221
|
+
export type AvailableTool = {
|
|
125
222
|
name: string;
|
|
126
223
|
description: string;
|
|
127
224
|
serverId?: string;
|
|
128
225
|
toolName?: string;
|
|
129
226
|
parameters?: ToolParameterSchema;
|
|
130
|
-
}
|
|
227
|
+
};
|
|
131
228
|
/**
|
|
132
229
|
* Tool validation options
|
|
133
230
|
*/
|
|
134
|
-
export
|
|
231
|
+
export type ToolValidationOptions = {
|
|
135
232
|
customValidator?: (toolName: string, params: ToolArgs) => boolean | Promise<boolean>;
|
|
136
233
|
validateSchema?: boolean;
|
|
137
234
|
allowUnknownProperties?: boolean;
|
|
138
|
-
}
|
|
235
|
+
};
|
|
139
236
|
/**
|
|
140
237
|
* Tool call information (for AI SDK integration)
|
|
141
238
|
*/
|
|
142
|
-
export
|
|
239
|
+
export type ToolCall = {
|
|
143
240
|
toolName: string;
|
|
144
241
|
parameters: ToolArgs;
|
|
145
242
|
id?: string;
|
|
146
|
-
}
|
|
243
|
+
};
|
|
147
244
|
/**
|
|
148
245
|
* AI SDK Tool Call format (from Vercel AI SDK)
|
|
149
246
|
*/
|
|
150
|
-
export
|
|
247
|
+
export type AiSdkToolCall = {
|
|
151
248
|
type: "tool-call";
|
|
152
249
|
toolCallId: string;
|
|
153
250
|
toolName: string;
|
|
154
251
|
params: ToolArgs;
|
|
155
|
-
}
|
|
252
|
+
};
|
|
156
253
|
/**
|
|
157
254
|
* Tool call result (for AI SDK integration)
|
|
158
255
|
*/
|
|
159
|
-
export
|
|
256
|
+
export type ToolCallResult = {
|
|
160
257
|
id?: string;
|
|
161
258
|
result: ToolResult;
|
|
162
259
|
formattedForAI: string;
|
|
163
|
-
}
|
|
260
|
+
};
|
|
164
261
|
/**
|
|
165
262
|
* Type guard for tool result
|
|
166
263
|
*/
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSV Processing Utility
|
|
3
|
+
* Converts CSV files to LLM-friendly text formats
|
|
4
|
+
* Uses streaming for memory efficiency with large files
|
|
5
|
+
*/
|
|
6
|
+
import type { FileProcessingResult, CSVProcessorOptions } from "../types/fileTypes.js";
|
|
7
|
+
/**
|
|
8
|
+
* CSV processor for converting CSV data to LLM-optimized formats
|
|
9
|
+
*
|
|
10
|
+
* Supports three output formats:
|
|
11
|
+
* - raw: Original CSV format with proper escaping (RECOMMENDED for best LLM performance)
|
|
12
|
+
* - json: JSON array format (best for structured data processing)
|
|
13
|
+
* - markdown: Markdown table format (best for small datasets <100 rows)
|
|
14
|
+
*
|
|
15
|
+
* All formats use csv-parser for reliable parsing, then convert to the target format.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const csvBuffer = Buffer.from('name,age\nAlice,30\nBob,25');
|
|
20
|
+
* const result = await CSVProcessor.process(csvBuffer, {
|
|
21
|
+
* maxRows: 1000,
|
|
22
|
+
* formatStyle: 'raw'
|
|
23
|
+
* });
|
|
24
|
+
* console.log(result.content); // CSV string with proper escaping
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare class CSVProcessor {
|
|
28
|
+
/**
|
|
29
|
+
* Process CSV Buffer to LLM-friendly format
|
|
30
|
+
* Content already loaded by FileDetector
|
|
31
|
+
*
|
|
32
|
+
* @param content - CSV file as Buffer
|
|
33
|
+
* @param options - Processing options
|
|
34
|
+
* @returns Formatted CSV data ready for LLM (JSON or Markdown)
|
|
35
|
+
*/
|
|
36
|
+
static process(content: Buffer, options?: CSVProcessorOptions): Promise<FileProcessingResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Parse CSV string into array of row objects using streaming
|
|
39
|
+
* Memory-efficient for large files
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* Parse CSV file from disk using streaming (memory efficient)
|
|
43
|
+
*
|
|
44
|
+
* @param filePath - Path to CSV file
|
|
45
|
+
* @param maxRows - Maximum rows to parse (default: 1000)
|
|
46
|
+
* @returns Array of row objects
|
|
47
|
+
*/
|
|
48
|
+
static parseCSVFile(filePath: string, maxRows?: number): Promise<unknown[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Parse CSV string to array of row objects
|
|
51
|
+
* Exposed for use by tools that need direct CSV parsing
|
|
52
|
+
*
|
|
53
|
+
* @param csvString - CSV data as string
|
|
54
|
+
* @param maxRows - Maximum rows to parse (default: 1000)
|
|
55
|
+
* @returns Array of row objects
|
|
56
|
+
*/
|
|
57
|
+
static parseCSVString(csvString: string, maxRows?: number): Promise<unknown[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Format parsed CSV data for LLM consumption
|
|
60
|
+
* Only used for JSON and Markdown formats (raw format handled separately)
|
|
61
|
+
*/
|
|
62
|
+
private static formatForLLM;
|
|
63
|
+
/**
|
|
64
|
+
* Format as markdown table
|
|
65
|
+
* Best for small datasets (<100 rows)
|
|
66
|
+
*/
|
|
67
|
+
private static toMarkdownTable;
|
|
68
|
+
}
|