@juspay/neurolink 7.7.0 → 7.8.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 +20 -2
- package/README.md +33 -2
- package/dist/cli/commands/config.d.ts +3 -3
- package/dist/cli/commands/sagemaker.d.ts +11 -0
- package/dist/cli/commands/sagemaker.js +778 -0
- package/dist/cli/factories/commandFactory.js +1 -0
- package/dist/cli/index.js +3 -0
- package/dist/cli/utils/interactiveSetup.js +28 -0
- package/dist/core/baseProvider.d.ts +2 -2
- package/dist/core/types.d.ts +1 -0
- package/dist/core/types.js +1 -0
- package/dist/factories/providerRegistry.js +5 -0
- package/dist/lib/core/baseProvider.d.ts +2 -2
- package/dist/lib/core/types.d.ts +1 -0
- package/dist/lib/core/types.js +1 -0
- package/dist/lib/factories/providerRegistry.js +5 -0
- package/dist/lib/providers/amazonSagemaker.d.ts +67 -0
- package/dist/lib/providers/amazonSagemaker.js +149 -0
- package/dist/lib/providers/index.d.ts +4 -0
- package/dist/lib/providers/index.js +4 -0
- package/dist/lib/providers/sagemaker/adaptive-semaphore.d.ts +86 -0
- package/dist/lib/providers/sagemaker/adaptive-semaphore.js +212 -0
- package/dist/lib/providers/sagemaker/client.d.ts +156 -0
- package/dist/lib/providers/sagemaker/client.js +462 -0
- package/dist/lib/providers/sagemaker/config.d.ts +73 -0
- package/dist/lib/providers/sagemaker/config.js +308 -0
- package/dist/lib/providers/sagemaker/detection.d.ts +176 -0
- package/dist/lib/providers/sagemaker/detection.js +596 -0
- package/dist/lib/providers/sagemaker/diagnostics.d.ts +37 -0
- package/dist/lib/providers/sagemaker/diagnostics.js +137 -0
- package/dist/lib/providers/sagemaker/error-constants.d.ts +78 -0
- package/dist/lib/providers/sagemaker/error-constants.js +227 -0
- package/dist/lib/providers/sagemaker/errors.d.ts +83 -0
- package/dist/lib/providers/sagemaker/errors.js +216 -0
- package/dist/lib/providers/sagemaker/index.d.ts +35 -0
- package/dist/lib/providers/sagemaker/index.js +67 -0
- package/dist/lib/providers/sagemaker/language-model.d.ts +182 -0
- package/dist/lib/providers/sagemaker/language-model.js +755 -0
- package/dist/lib/providers/sagemaker/parsers.d.ts +136 -0
- package/dist/lib/providers/sagemaker/parsers.js +625 -0
- package/dist/lib/providers/sagemaker/streaming.d.ts +39 -0
- package/dist/lib/providers/sagemaker/streaming.js +320 -0
- package/dist/lib/providers/sagemaker/structured-parser.d.ts +117 -0
- package/dist/lib/providers/sagemaker/structured-parser.js +625 -0
- package/dist/lib/providers/sagemaker/types.d.ts +456 -0
- package/dist/lib/providers/sagemaker/types.js +7 -0
- package/dist/lib/types/cli.d.ts +36 -1
- package/dist/lib/utils/providerConfig.js +6 -2
- package/dist/lib/utils/providerHealth.js +45 -9
- package/dist/providers/amazonSagemaker.d.ts +67 -0
- package/dist/providers/amazonSagemaker.js +149 -0
- package/dist/providers/index.d.ts +4 -0
- package/dist/providers/index.js +4 -0
- package/dist/providers/sagemaker/adaptive-semaphore.d.ts +86 -0
- package/dist/providers/sagemaker/adaptive-semaphore.js +212 -0
- package/dist/providers/sagemaker/client.d.ts +156 -0
- package/dist/providers/sagemaker/client.js +462 -0
- package/dist/providers/sagemaker/config.d.ts +73 -0
- package/dist/providers/sagemaker/config.js +308 -0
- package/dist/providers/sagemaker/detection.d.ts +176 -0
- package/dist/providers/sagemaker/detection.js +596 -0
- package/dist/providers/sagemaker/diagnostics.d.ts +37 -0
- package/dist/providers/sagemaker/diagnostics.js +137 -0
- package/dist/providers/sagemaker/error-constants.d.ts +78 -0
- package/dist/providers/sagemaker/error-constants.js +227 -0
- package/dist/providers/sagemaker/errors.d.ts +83 -0
- package/dist/providers/sagemaker/errors.js +216 -0
- package/dist/providers/sagemaker/index.d.ts +35 -0
- package/dist/providers/sagemaker/index.js +67 -0
- package/dist/providers/sagemaker/language-model.d.ts +182 -0
- package/dist/providers/sagemaker/language-model.js +755 -0
- package/dist/providers/sagemaker/parsers.d.ts +136 -0
- package/dist/providers/sagemaker/parsers.js +625 -0
- package/dist/providers/sagemaker/streaming.d.ts +39 -0
- package/dist/providers/sagemaker/streaming.js +320 -0
- package/dist/providers/sagemaker/structured-parser.d.ts +117 -0
- package/dist/providers/sagemaker/structured-parser.js +625 -0
- package/dist/providers/sagemaker/types.d.ts +456 -0
- package/dist/providers/sagemaker/types.js +7 -0
- package/dist/types/cli.d.ts +36 -1
- package/dist/utils/providerConfig.js +6 -2
- package/dist/utils/providerHealth.js +45 -9
- package/package.json +4 -1
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript type definitions for Amazon SageMaker Provider
|
|
3
|
+
*
|
|
4
|
+
* This module contains all interfaces and types for SageMaker integration
|
|
5
|
+
* with the NeuroLink ecosystem and Vercel AI SDK compatibility.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* AWS configuration options for SageMaker client
|
|
9
|
+
*/
|
|
10
|
+
export interface SageMakerConfig {
|
|
11
|
+
/** AWS region for SageMaker service */
|
|
12
|
+
region: string;
|
|
13
|
+
/** AWS access key ID */
|
|
14
|
+
accessKeyId: string;
|
|
15
|
+
/** AWS secret access key */
|
|
16
|
+
secretAccessKey: string;
|
|
17
|
+
/** AWS session token (optional, for temporary credentials) */
|
|
18
|
+
sessionToken?: string;
|
|
19
|
+
/** Request timeout in milliseconds */
|
|
20
|
+
timeout?: number;
|
|
21
|
+
/** Maximum number of retry attempts */
|
|
22
|
+
maxRetries?: number;
|
|
23
|
+
/** Custom SageMaker endpoint URL (optional) */
|
|
24
|
+
endpoint?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Model-specific configuration for SageMaker endpoints
|
|
28
|
+
*/
|
|
29
|
+
export interface SageMakerModelConfig {
|
|
30
|
+
/** SageMaker endpoint name */
|
|
31
|
+
endpointName: string;
|
|
32
|
+
/** Model type for request/response formatting */
|
|
33
|
+
modelType?: "llama" | "mistral" | "claude" | "huggingface" | "jumpstart" | "custom";
|
|
34
|
+
/** Content type for requests */
|
|
35
|
+
contentType?: string;
|
|
36
|
+
/** Accept header for responses */
|
|
37
|
+
accept?: string;
|
|
38
|
+
/** Custom attributes for the endpoint */
|
|
39
|
+
customAttributes?: string;
|
|
40
|
+
/** Input format specification */
|
|
41
|
+
inputFormat?: "huggingface" | "jumpstart" | "custom";
|
|
42
|
+
/** Output format specification */
|
|
43
|
+
outputFormat?: "huggingface" | "jumpstart" | "custom";
|
|
44
|
+
/** Maximum tokens for generation */
|
|
45
|
+
maxTokens?: number;
|
|
46
|
+
/** Temperature parameter */
|
|
47
|
+
temperature?: number;
|
|
48
|
+
/** Top-p parameter */
|
|
49
|
+
topP?: number;
|
|
50
|
+
/** Stop sequences */
|
|
51
|
+
stopSequences?: string[];
|
|
52
|
+
/** Initial concurrency for batch processing */
|
|
53
|
+
initialConcurrency?: number;
|
|
54
|
+
/** Maximum concurrency for batch processing */
|
|
55
|
+
maxConcurrency?: number;
|
|
56
|
+
/** Minimum concurrency for batch processing */
|
|
57
|
+
minConcurrency?: number;
|
|
58
|
+
/** Maximum concurrent detection tests */
|
|
59
|
+
maxConcurrentDetectionTests?: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* SageMaker endpoint information and metadata
|
|
63
|
+
*/
|
|
64
|
+
export interface SageMakerEndpointInfo {
|
|
65
|
+
/** Endpoint name */
|
|
66
|
+
endpointName: string;
|
|
67
|
+
/** Endpoint ARN */
|
|
68
|
+
endpointArn: string;
|
|
69
|
+
/** Associated model name */
|
|
70
|
+
modelName: string;
|
|
71
|
+
/** EC2 instance type */
|
|
72
|
+
instanceType: string;
|
|
73
|
+
/** Endpoint creation timestamp */
|
|
74
|
+
creationTime: string;
|
|
75
|
+
/** Last modification timestamp */
|
|
76
|
+
lastModifiedTime: string;
|
|
77
|
+
/** Current endpoint status */
|
|
78
|
+
endpointStatus: "InService" | "Creating" | "Updating" | "SystemUpdating" | "RollingBack" | "Deleting" | "Failed";
|
|
79
|
+
/** Current instance count */
|
|
80
|
+
currentInstanceCount?: number;
|
|
81
|
+
/** Variant weights for A/B testing */
|
|
82
|
+
productionVariants?: Array<{
|
|
83
|
+
variantName: string;
|
|
84
|
+
modelName: string;
|
|
85
|
+
initialInstanceCount: number;
|
|
86
|
+
instanceType: string;
|
|
87
|
+
currentWeight?: number;
|
|
88
|
+
}>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Token usage and billing information
|
|
92
|
+
*/
|
|
93
|
+
export interface SageMakerUsage {
|
|
94
|
+
/** Number of prompt tokens */
|
|
95
|
+
promptTokens: number;
|
|
96
|
+
/** Number of completion tokens */
|
|
97
|
+
completionTokens: number;
|
|
98
|
+
/** Total tokens used */
|
|
99
|
+
totalTokens: number;
|
|
100
|
+
/** Request processing time in milliseconds */
|
|
101
|
+
requestTime?: number;
|
|
102
|
+
/** Model inference time in milliseconds */
|
|
103
|
+
inferenceTime?: number;
|
|
104
|
+
/** Estimated cost in USD */
|
|
105
|
+
estimatedCost?: number;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Parameters for SageMaker endpoint invocation
|
|
109
|
+
*/
|
|
110
|
+
export interface InvokeEndpointParams {
|
|
111
|
+
/** Endpoint name to invoke */
|
|
112
|
+
EndpointName: string;
|
|
113
|
+
/** Request body as string or Uint8Array */
|
|
114
|
+
Body: string | Uint8Array;
|
|
115
|
+
/** Content type of the request */
|
|
116
|
+
ContentType?: string;
|
|
117
|
+
/** Accept header for response format */
|
|
118
|
+
Accept?: string;
|
|
119
|
+
/** Custom attributes for the request */
|
|
120
|
+
CustomAttributes?: string;
|
|
121
|
+
/** Target model for multi-model endpoints */
|
|
122
|
+
TargetModel?: string;
|
|
123
|
+
/** Target variant for A/B testing */
|
|
124
|
+
TargetVariant?: string;
|
|
125
|
+
/** Inference ID for request tracking */
|
|
126
|
+
InferenceId?: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Response from SageMaker endpoint invocation
|
|
130
|
+
*/
|
|
131
|
+
export interface InvokeEndpointResponse {
|
|
132
|
+
/** Response body */
|
|
133
|
+
Body?: Uint8Array;
|
|
134
|
+
/** Content type of the response */
|
|
135
|
+
ContentType?: string;
|
|
136
|
+
/** Invoked production variant */
|
|
137
|
+
InvokedProductionVariant?: string;
|
|
138
|
+
/** Custom attributes in the response */
|
|
139
|
+
CustomAttributes?: string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Streaming response chunk from SageMaker
|
|
143
|
+
*/
|
|
144
|
+
export interface SageMakerStreamChunk {
|
|
145
|
+
/** Text content in the chunk */
|
|
146
|
+
content?: string;
|
|
147
|
+
/** Indicates if this is the final chunk */
|
|
148
|
+
done?: boolean;
|
|
149
|
+
/** Usage information (only in final chunk) */
|
|
150
|
+
usage?: SageMakerUsage;
|
|
151
|
+
/** Error information if chunk contains error */
|
|
152
|
+
error?: string;
|
|
153
|
+
/** Finish reason for generation */
|
|
154
|
+
finishReason?: "stop" | "length" | "tool-calls" | "content-filter" | "unknown";
|
|
155
|
+
/** Tool call in progress (Phase 2.3) */
|
|
156
|
+
toolCall?: SageMakerStreamingToolCall;
|
|
157
|
+
/** Tool result chunk (Phase 2.3) */
|
|
158
|
+
toolResult?: SageMakerStreamingToolResult;
|
|
159
|
+
/** Structured output streaming (Phase 2.3) */
|
|
160
|
+
structuredOutput?: SageMakerStructuredOutput;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Tool call information for function calling
|
|
164
|
+
*/
|
|
165
|
+
export interface SageMakerToolCall {
|
|
166
|
+
/** Tool call identifier */
|
|
167
|
+
id: string;
|
|
168
|
+
/** Tool/function name */
|
|
169
|
+
name: string;
|
|
170
|
+
/** Tool arguments as JSON object */
|
|
171
|
+
arguments: Record<string, unknown>;
|
|
172
|
+
/** Tool call type */
|
|
173
|
+
type: "function";
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Tool result information
|
|
177
|
+
*/
|
|
178
|
+
export interface SageMakerToolResult {
|
|
179
|
+
/** Tool call identifier */
|
|
180
|
+
toolCallId: string;
|
|
181
|
+
/** Tool name */
|
|
182
|
+
toolName: string;
|
|
183
|
+
/** Tool result data */
|
|
184
|
+
result: unknown;
|
|
185
|
+
/** Execution status */
|
|
186
|
+
status: "success" | "error";
|
|
187
|
+
/** Error message if status is error */
|
|
188
|
+
error?: string;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Streaming tool call information (Phase 2.3)
|
|
192
|
+
*/
|
|
193
|
+
export interface SageMakerStreamingToolCall {
|
|
194
|
+
/** Tool call identifier */
|
|
195
|
+
id: string;
|
|
196
|
+
/** Tool/function name */
|
|
197
|
+
name?: string;
|
|
198
|
+
/** Partial or complete arguments as JSON string */
|
|
199
|
+
arguments?: string;
|
|
200
|
+
/** Tool call type */
|
|
201
|
+
type: "function";
|
|
202
|
+
/** Indicates if this tool call is complete */
|
|
203
|
+
complete?: boolean;
|
|
204
|
+
/** Delta text for incremental argument building */
|
|
205
|
+
argumentsDelta?: string;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Streaming tool result information (Phase 2.3)
|
|
209
|
+
*/
|
|
210
|
+
export interface SageMakerStreamingToolResult {
|
|
211
|
+
/** Tool call identifier */
|
|
212
|
+
toolCallId: string;
|
|
213
|
+
/** Tool name */
|
|
214
|
+
toolName: string;
|
|
215
|
+
/** Partial or complete result data */
|
|
216
|
+
result?: unknown;
|
|
217
|
+
/** Result delta for incremental responses */
|
|
218
|
+
resultDelta?: string;
|
|
219
|
+
/** Execution status */
|
|
220
|
+
status: "pending" | "running" | "success" | "error";
|
|
221
|
+
/** Error message if status is error */
|
|
222
|
+
error?: string;
|
|
223
|
+
/** Indicates if this result is complete */
|
|
224
|
+
complete?: boolean;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Structured output streaming information (Phase 2.3)
|
|
228
|
+
*/
|
|
229
|
+
export interface SageMakerStructuredOutput {
|
|
230
|
+
/** Partial JSON object being built */
|
|
231
|
+
partialObject?: Record<string, unknown>;
|
|
232
|
+
/** JSON delta text */
|
|
233
|
+
jsonDelta?: string;
|
|
234
|
+
/** Current parsing path (e.g., "user.name") */
|
|
235
|
+
currentPath?: string;
|
|
236
|
+
/** Schema validation errors */
|
|
237
|
+
validationErrors?: string[];
|
|
238
|
+
/** Indicates if JSON is complete and valid */
|
|
239
|
+
complete?: boolean;
|
|
240
|
+
/** JSON schema being validated against */
|
|
241
|
+
schema?: Record<string, unknown>;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Enhanced generation request options
|
|
245
|
+
*/
|
|
246
|
+
export interface SageMakerGenerationOptions {
|
|
247
|
+
/** Input prompt text */
|
|
248
|
+
prompt: string;
|
|
249
|
+
/** System prompt for context */
|
|
250
|
+
systemPrompt?: string;
|
|
251
|
+
/** Maximum tokens to generate */
|
|
252
|
+
maxTokens?: number;
|
|
253
|
+
/** Temperature for randomness (0-1) */
|
|
254
|
+
temperature?: number;
|
|
255
|
+
/** Top-p nucleus sampling (0-1) */
|
|
256
|
+
topP?: number;
|
|
257
|
+
/** Top-k sampling */
|
|
258
|
+
topK?: number;
|
|
259
|
+
/** Stop sequences to end generation */
|
|
260
|
+
stopSequences?: string[];
|
|
261
|
+
/** Enable streaming response */
|
|
262
|
+
stream?: boolean;
|
|
263
|
+
/** Tools available for function calling */
|
|
264
|
+
tools?: Array<{
|
|
265
|
+
name: string;
|
|
266
|
+
description: string;
|
|
267
|
+
parameters: Record<string, unknown>;
|
|
268
|
+
}>;
|
|
269
|
+
/** Tool choice mode */
|
|
270
|
+
toolChoice?: "auto" | "none" | {
|
|
271
|
+
type: "tool";
|
|
272
|
+
name: string;
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Generation response from SageMaker
|
|
277
|
+
*/
|
|
278
|
+
export interface SageMakerGenerationResponse {
|
|
279
|
+
/** Generated text content */
|
|
280
|
+
text: string;
|
|
281
|
+
/** Token usage information */
|
|
282
|
+
usage: SageMakerUsage;
|
|
283
|
+
/** Finish reason for generation */
|
|
284
|
+
finishReason: "stop" | "length" | "tool-calls" | "content-filter" | "unknown";
|
|
285
|
+
/** Tool calls made during generation */
|
|
286
|
+
toolCalls?: SageMakerToolCall[];
|
|
287
|
+
/** Tool results if tools were executed */
|
|
288
|
+
toolResults?: SageMakerToolResult[];
|
|
289
|
+
/** Additional metadata */
|
|
290
|
+
metadata?: Record<string, unknown>;
|
|
291
|
+
/** Model version or identifier */
|
|
292
|
+
modelVersion?: string;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Error codes specific to SageMaker operations
|
|
296
|
+
*/
|
|
297
|
+
export type SageMakerErrorCode = "VALIDATION_ERROR" | "MODEL_ERROR" | "INTERNAL_ERROR" | "SERVICE_UNAVAILABLE" | "CREDENTIALS_ERROR" | "NETWORK_ERROR" | "ENDPOINT_NOT_FOUND" | "THROTTLING_ERROR" | "UNKNOWN_ERROR";
|
|
298
|
+
/**
|
|
299
|
+
* SageMaker-specific error information
|
|
300
|
+
*/
|
|
301
|
+
export interface SageMakerErrorInfo {
|
|
302
|
+
/** Error code */
|
|
303
|
+
code: SageMakerErrorCode;
|
|
304
|
+
/** Human-readable error message */
|
|
305
|
+
message: string;
|
|
306
|
+
/** HTTP status code if applicable */
|
|
307
|
+
statusCode?: number;
|
|
308
|
+
/** Original error from AWS SDK */
|
|
309
|
+
cause?: Error;
|
|
310
|
+
/** Endpoint name where error occurred */
|
|
311
|
+
endpoint?: string;
|
|
312
|
+
/** Request ID for debugging */
|
|
313
|
+
requestId?: string;
|
|
314
|
+
/** Retry suggestion */
|
|
315
|
+
retryable?: boolean;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Batch inference job configuration
|
|
319
|
+
*/
|
|
320
|
+
export interface BatchInferenceConfig {
|
|
321
|
+
/** Input S3 location */
|
|
322
|
+
inputS3Uri: string;
|
|
323
|
+
/** Output S3 location */
|
|
324
|
+
outputS3Uri: string;
|
|
325
|
+
/** SageMaker model name */
|
|
326
|
+
modelName: string;
|
|
327
|
+
/** Instance type for batch job */
|
|
328
|
+
instanceType: string;
|
|
329
|
+
/** Instance count for batch job */
|
|
330
|
+
instanceCount: number;
|
|
331
|
+
/** Maximum payload size in MB */
|
|
332
|
+
maxPayloadInMB?: number;
|
|
333
|
+
/** Batch strategy */
|
|
334
|
+
batchStrategy?: "MultiRecord" | "SingleRecord";
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Model deployment configuration
|
|
338
|
+
*/
|
|
339
|
+
export interface ModelDeploymentConfig {
|
|
340
|
+
/** Model name */
|
|
341
|
+
modelName: string;
|
|
342
|
+
/** Endpoint name */
|
|
343
|
+
endpointName: string;
|
|
344
|
+
/** EC2 instance type */
|
|
345
|
+
instanceType: string;
|
|
346
|
+
/** Initial instance count */
|
|
347
|
+
initialInstanceCount: number;
|
|
348
|
+
/** Model data S3 location */
|
|
349
|
+
modelDataUrl: string;
|
|
350
|
+
/** Container image URI */
|
|
351
|
+
image: string;
|
|
352
|
+
/** IAM execution role ARN */
|
|
353
|
+
executionRoleArn: string;
|
|
354
|
+
/** Resource tags */
|
|
355
|
+
tags?: Record<string, string>;
|
|
356
|
+
/** Auto scaling configuration */
|
|
357
|
+
autoScaling?: {
|
|
358
|
+
minCapacity: number;
|
|
359
|
+
maxCapacity: number;
|
|
360
|
+
targetValue: number;
|
|
361
|
+
scaleUpCooldown: number;
|
|
362
|
+
scaleDownCooldown: number;
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Endpoint metrics and monitoring data
|
|
367
|
+
*/
|
|
368
|
+
export interface EndpointMetrics {
|
|
369
|
+
/** Endpoint name */
|
|
370
|
+
endpointName: string;
|
|
371
|
+
/** Total invocations */
|
|
372
|
+
invocations: number;
|
|
373
|
+
/** Average latency in milliseconds */
|
|
374
|
+
averageLatency: number;
|
|
375
|
+
/** Error rate percentage */
|
|
376
|
+
errorRate: number;
|
|
377
|
+
/** CPU utilization percentage */
|
|
378
|
+
cpuUtilization?: number;
|
|
379
|
+
/** Memory utilization percentage */
|
|
380
|
+
memoryUtilization?: number;
|
|
381
|
+
/** Instance count */
|
|
382
|
+
instanceCount: number;
|
|
383
|
+
/** Timestamp of metrics */
|
|
384
|
+
timestamp: string;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Cost estimation data
|
|
388
|
+
*/
|
|
389
|
+
export interface CostEstimate {
|
|
390
|
+
/** Estimated cost in USD */
|
|
391
|
+
estimatedCost: number;
|
|
392
|
+
/** Currency code */
|
|
393
|
+
currency: string;
|
|
394
|
+
/** Cost breakdown */
|
|
395
|
+
breakdown: {
|
|
396
|
+
/** Instance hours cost */
|
|
397
|
+
instanceCost: number;
|
|
398
|
+
/** Request-based cost */
|
|
399
|
+
requestCost: number;
|
|
400
|
+
/** Total processing hours */
|
|
401
|
+
totalHours: number;
|
|
402
|
+
};
|
|
403
|
+
/** Time period for estimate */
|
|
404
|
+
period?: {
|
|
405
|
+
start: string;
|
|
406
|
+
end: string;
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* SageMaker generation result interface for better type safety
|
|
411
|
+
*/
|
|
412
|
+
export interface SageMakerGenerateResult {
|
|
413
|
+
text?: string;
|
|
414
|
+
reasoning?: string | Array<{
|
|
415
|
+
type: "text";
|
|
416
|
+
text: string;
|
|
417
|
+
signature?: string;
|
|
418
|
+
} | {
|
|
419
|
+
type: "redacted";
|
|
420
|
+
data: string;
|
|
421
|
+
}>;
|
|
422
|
+
files?: Array<{
|
|
423
|
+
data: string | Uint8Array;
|
|
424
|
+
mimeType: string;
|
|
425
|
+
}>;
|
|
426
|
+
logprobs?: Array<{
|
|
427
|
+
token: string;
|
|
428
|
+
logprob: number;
|
|
429
|
+
topLogprobs: Array<{
|
|
430
|
+
token: string;
|
|
431
|
+
logprob: number;
|
|
432
|
+
}>;
|
|
433
|
+
}>;
|
|
434
|
+
usage: {
|
|
435
|
+
promptTokens: number;
|
|
436
|
+
completionTokens: number;
|
|
437
|
+
totalTokens?: number;
|
|
438
|
+
};
|
|
439
|
+
finishReason: "stop" | "length" | "content-filter" | "tool-calls" | "error" | "unknown";
|
|
440
|
+
warnings?: Array<{
|
|
441
|
+
type: "other";
|
|
442
|
+
message: string;
|
|
443
|
+
}>;
|
|
444
|
+
rawCall: {
|
|
445
|
+
rawPrompt: unknown;
|
|
446
|
+
rawSettings: Record<string, unknown>;
|
|
447
|
+
};
|
|
448
|
+
rawResponse?: {
|
|
449
|
+
headers?: Record<string, string>;
|
|
450
|
+
};
|
|
451
|
+
request?: {
|
|
452
|
+
body?: string;
|
|
453
|
+
};
|
|
454
|
+
toolCalls?: SageMakerToolCall[];
|
|
455
|
+
object?: unknown;
|
|
456
|
+
}
|
package/dist/lib/types/cli.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface BaseCommandArgs {
|
|
|
12
12
|
/** Enable debug output */
|
|
13
13
|
debug?: boolean;
|
|
14
14
|
/** Output format */
|
|
15
|
-
format?: "text" | "json" | "table";
|
|
15
|
+
format?: "text" | "json" | "table" | "yaml";
|
|
16
16
|
/** Verbose output */
|
|
17
17
|
verbose?: boolean;
|
|
18
18
|
/** Quiet mode */
|
|
@@ -153,6 +153,41 @@ export interface OllamaCommandArgs extends BaseCommandArgs {
|
|
|
153
153
|
/** Show model information */
|
|
154
154
|
show?: boolean;
|
|
155
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* SageMaker command arguments
|
|
158
|
+
*/
|
|
159
|
+
export interface SageMakerCommandArgs extends BaseCommandArgs {
|
|
160
|
+
/** SageMaker endpoint name */
|
|
161
|
+
endpoint?: string;
|
|
162
|
+
/** Model name for the endpoint */
|
|
163
|
+
model?: string;
|
|
164
|
+
/** Test prompt for endpoint testing */
|
|
165
|
+
prompt?: string;
|
|
166
|
+
/** List endpoints */
|
|
167
|
+
list?: boolean;
|
|
168
|
+
/** Show configuration */
|
|
169
|
+
config?: boolean;
|
|
170
|
+
/** Setup configuration */
|
|
171
|
+
setup?: boolean;
|
|
172
|
+
/** Clear configuration cache */
|
|
173
|
+
clearCache?: boolean;
|
|
174
|
+
/** Run benchmark test */
|
|
175
|
+
benchmark?: boolean;
|
|
176
|
+
/** Duration for benchmark test (in seconds) */
|
|
177
|
+
duration?: number;
|
|
178
|
+
/** Concurrency level for benchmark */
|
|
179
|
+
concurrency?: number;
|
|
180
|
+
/** Number of requests for benchmark */
|
|
181
|
+
requests?: number;
|
|
182
|
+
/** Maximum tokens per request */
|
|
183
|
+
maxTokens?: number;
|
|
184
|
+
/** Validate endpoint configuration */
|
|
185
|
+
validate?: boolean;
|
|
186
|
+
/** AWS region override */
|
|
187
|
+
region?: string;
|
|
188
|
+
/** Force operation without confirmation */
|
|
189
|
+
force?: boolean;
|
|
190
|
+
}
|
|
156
191
|
/**
|
|
157
192
|
* Provider status command arguments
|
|
158
193
|
*/
|
|
@@ -308,7 +308,11 @@ export function createVertexProjectConfig() {
|
|
|
308
308
|
"3. Enable Vertex AI API",
|
|
309
309
|
"4. Set up authentication",
|
|
310
310
|
],
|
|
311
|
-
fallbackEnvVars: [
|
|
311
|
+
fallbackEnvVars: [
|
|
312
|
+
"VERTEX_PROJECT_ID",
|
|
313
|
+
"GOOGLE_VERTEX_PROJECT",
|
|
314
|
+
"GOOGLE_CLOUD_PROJECT",
|
|
315
|
+
],
|
|
312
316
|
};
|
|
313
317
|
}
|
|
314
318
|
/**
|
|
@@ -331,7 +335,7 @@ export function createGoogleAuthConfig() {
|
|
|
331
335
|
"GOOGLE_AUTH_CLIENT_EMAIL=your-service-account@project.iam.gserviceaccount.com",
|
|
332
336
|
"GOOGLE_AUTH_PRIVATE_KEY=-----BEGIN PRIVATE KEY-----...",
|
|
333
337
|
],
|
|
334
|
-
fallbackEnvVars: ["GOOGLE_SERVICE_ACCOUNT_KEY"
|
|
338
|
+
fallbackEnvVars: ["GOOGLE_SERVICE_ACCOUNT_KEY"],
|
|
335
339
|
};
|
|
336
340
|
}
|
|
337
341
|
/**
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { logger } from "./logger.js";
|
|
6
6
|
import { AIProviderName } from "../core/types.js";
|
|
7
|
+
import { basename } from "path";
|
|
7
8
|
export class ProviderHealthChecker {
|
|
8
9
|
static healthCache = new Map();
|
|
9
10
|
static DEFAULT_TIMEOUT = 5000; // 5 seconds
|
|
@@ -245,7 +246,11 @@ export class ProviderHealthChecker {
|
|
|
245
246
|
case AIProviderName.OPENAI:
|
|
246
247
|
return ["OPENAI_API_KEY"];
|
|
247
248
|
case AIProviderName.VERTEX:
|
|
248
|
-
|
|
249
|
+
// Vertex AI requires authentication, but not via a single environment variable.
|
|
250
|
+
// Authentication can be provided via a credential file or individual credentials + project.
|
|
251
|
+
// The required authentication is checked in checkProviderSpecificConfig instead of here.
|
|
252
|
+
// Returning an empty array here does NOT mean authentication is not required.
|
|
253
|
+
return [];
|
|
249
254
|
case AIProviderName.GOOGLE_AI:
|
|
250
255
|
return ["GOOGLE_AI_API_KEY"];
|
|
251
256
|
case AIProviderName.BEDROCK:
|
|
@@ -324,20 +329,51 @@ export class ProviderHealthChecker {
|
|
|
324
329
|
*/
|
|
325
330
|
static async checkProviderSpecificConfig(providerName, healthStatus) {
|
|
326
331
|
switch (providerName) {
|
|
327
|
-
case AIProviderName.VERTEX:
|
|
328
|
-
// Check for Google Cloud
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
+
case AIProviderName.VERTEX: {
|
|
333
|
+
// Check for Google Cloud project ID (with fallbacks)
|
|
334
|
+
const projectId = process.env.GOOGLE_PROJECT_ID ||
|
|
335
|
+
process.env.GOOGLE_CLOUD_PROJECT_ID ||
|
|
336
|
+
process.env.GOOGLE_VERTEX_PROJECT ||
|
|
337
|
+
process.env.GOOGLE_CLOUD_PROJECT ||
|
|
338
|
+
process.env.VERTEX_PROJECT_ID;
|
|
339
|
+
if (!projectId) {
|
|
340
|
+
healthStatus.configurationIssues.push("Google Cloud project ID not set");
|
|
341
|
+
healthStatus.recommendations.push("Set one of: GOOGLE_VERTEX_PROJECT, GOOGLE_CLOUD_PROJECT_ID, GOOGLE_PROJECT_ID, or GOOGLE_CLOUD_PROJECT");
|
|
342
|
+
}
|
|
343
|
+
// Check for authentication (either credentials file OR individual credentials)
|
|
344
|
+
const hasCredentialsFile = !!process.env.GOOGLE_APPLICATION_CREDENTIALS;
|
|
345
|
+
const hasServiceAccountKey = !!process.env.GOOGLE_SERVICE_ACCOUNT_KEY;
|
|
346
|
+
const hasIndividualCredentials = !!(process.env.GOOGLE_AUTH_CLIENT_EMAIL &&
|
|
347
|
+
process.env.GOOGLE_AUTH_PRIVATE_KEY);
|
|
348
|
+
if (!hasCredentialsFile &&
|
|
349
|
+
!hasServiceAccountKey &&
|
|
350
|
+
!hasIndividualCredentials) {
|
|
351
|
+
healthStatus.configurationIssues.push("Google Cloud authentication not configured");
|
|
352
|
+
healthStatus.recommendations.push("Set either GOOGLE_APPLICATION_CREDENTIALS (file path), GOOGLE_SERVICE_ACCOUNT_KEY (base64), or both GOOGLE_AUTH_CLIENT_EMAIL and GOOGLE_AUTH_PRIVATE_KEY");
|
|
332
353
|
}
|
|
333
|
-
{
|
|
354
|
+
else {
|
|
355
|
+
healthStatus.hasApiKey = true; // At least one auth method is configured
|
|
356
|
+
}
|
|
357
|
+
// Validate credentials file if provided
|
|
358
|
+
if (hasCredentialsFile) {
|
|
334
359
|
const credPath = process.env.GOOGLE_APPLICATION_CREDENTIALS;
|
|
335
|
-
|
|
360
|
+
const fileName = basename(credPath);
|
|
361
|
+
// Use regex to match .json files with optional backup extensions
|
|
362
|
+
const jsonFilePattern = /\.json(\.\w+)?$/;
|
|
363
|
+
if (!jsonFilePattern.test(fileName)) {
|
|
336
364
|
healthStatus.warning =
|
|
337
|
-
"GOOGLE_APPLICATION_CREDENTIALS should point to a JSON file";
|
|
365
|
+
"GOOGLE_APPLICATION_CREDENTIALS should point to a JSON file (e.g., 'credentials.json' or 'key.json.backup')";
|
|
338
366
|
}
|
|
339
367
|
}
|
|
368
|
+
// Mark as configured if we have both project ID and auth
|
|
369
|
+
if (projectId &&
|
|
370
|
+
(hasCredentialsFile ||
|
|
371
|
+
hasServiceAccountKey ||
|
|
372
|
+
hasIndividualCredentials)) {
|
|
373
|
+
healthStatus.isConfigured = true;
|
|
374
|
+
}
|
|
340
375
|
break;
|
|
376
|
+
}
|
|
341
377
|
case AIProviderName.BEDROCK:
|
|
342
378
|
// Check AWS region
|
|
343
379
|
if (!process.env.AWS_REGION) {
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Amazon SageMaker Provider Implementation (Simplified)
|
|
3
|
+
*
|
|
4
|
+
* This module provides a simplified SageMaker provider that extends BaseProvider
|
|
5
|
+
* and integrates with the NeuroLink ecosystem using existing patterns.
|
|
6
|
+
*/
|
|
7
|
+
import type { ZodType, ZodTypeDef } from "zod";
|
|
8
|
+
import type { Schema, LanguageModelV1 } from "ai";
|
|
9
|
+
import type { AIProviderName } from "../core/types.js";
|
|
10
|
+
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
11
|
+
import { BaseProvider } from "../core/baseProvider.js";
|
|
12
|
+
/**
|
|
13
|
+
* Amazon SageMaker Provider extending BaseProvider
|
|
14
|
+
*/
|
|
15
|
+
export declare class AmazonSageMakerProvider extends BaseProvider {
|
|
16
|
+
private sagemakerModel;
|
|
17
|
+
private sagemakerConfig;
|
|
18
|
+
private modelConfig;
|
|
19
|
+
constructor(modelName?: string, endpointName?: string);
|
|
20
|
+
protected getProviderName(): AIProviderName;
|
|
21
|
+
protected getDefaultModel(): string;
|
|
22
|
+
protected getAISDKModel(): LanguageModelV1;
|
|
23
|
+
protected executeStream(options: StreamOptions, analysisSchema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>): Promise<StreamResult>;
|
|
24
|
+
protected handleProviderError(error: unknown): Error;
|
|
25
|
+
/**
|
|
26
|
+
* Get SageMaker-specific provider information
|
|
27
|
+
*/
|
|
28
|
+
getSageMakerInfo(): {
|
|
29
|
+
endpointName: string;
|
|
30
|
+
modelType: string;
|
|
31
|
+
region: string;
|
|
32
|
+
configured: boolean;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Test basic configuration
|
|
36
|
+
*/
|
|
37
|
+
testConnection(): Promise<{
|
|
38
|
+
connected: boolean;
|
|
39
|
+
error?: string;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Public method to get the AI SDK model for CLI and external usage
|
|
43
|
+
*/
|
|
44
|
+
getModel(): Promise<LanguageModelV1>;
|
|
45
|
+
/**
|
|
46
|
+
* Test connectivity to the SageMaker endpoint
|
|
47
|
+
*/
|
|
48
|
+
testConnectivity(): Promise<{
|
|
49
|
+
success: boolean;
|
|
50
|
+
error?: string;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* Get model capabilities and information
|
|
54
|
+
*/
|
|
55
|
+
getModelCapabilities(): {
|
|
56
|
+
capabilities: {
|
|
57
|
+
streaming: boolean;
|
|
58
|
+
toolCalling: boolean;
|
|
59
|
+
structuredOutput: boolean;
|
|
60
|
+
batchInference: boolean;
|
|
61
|
+
supportedResponseFormats: string[];
|
|
62
|
+
supportedToolTypes: string[];
|
|
63
|
+
maxBatchSize: number;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export default AmazonSageMakerProvider;
|