@juspay/neurolink 7.7.1 → 7.9.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 +25 -2
- package/README.md +34 -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 +7 -2
- 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 +16 -4
- package/dist/core/types.js +24 -3
- package/dist/factories/providerFactory.js +10 -1
- package/dist/factories/providerRegistry.js +6 -1
- package/dist/lib/core/baseProvider.d.ts +2 -2
- package/dist/lib/core/types.d.ts +16 -4
- package/dist/lib/core/types.js +24 -3
- package/dist/lib/factories/providerFactory.js +10 -1
- package/dist/lib/factories/providerRegistry.js +6 -1
- package/dist/lib/neurolink.d.ts +15 -0
- package/dist/lib/neurolink.js +73 -1
- package/dist/lib/providers/amazonSagemaker.d.ts +67 -0
- package/dist/lib/providers/amazonSagemaker.js +149 -0
- package/dist/lib/providers/googleVertex.d.ts +4 -0
- package/dist/lib/providers/googleVertex.js +44 -3
- 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/sdk/toolRegistration.d.ts +1 -1
- package/dist/lib/sdk/toolRegistration.js +13 -5
- package/dist/lib/types/cli.d.ts +36 -1
- package/dist/lib/utils/providerHealth.js +19 -4
- package/dist/neurolink.d.ts +15 -0
- package/dist/neurolink.js +73 -1
- package/dist/providers/amazonSagemaker.d.ts +67 -0
- package/dist/providers/amazonSagemaker.js +149 -0
- package/dist/providers/googleVertex.d.ts +4 -0
- package/dist/providers/googleVertex.js +44 -3
- 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/sdk/toolRegistration.d.ts +1 -1
- package/dist/sdk/toolRegistration.js +13 -5
- package/dist/types/cli.d.ts +36 -1
- package/dist/utils/providerHealth.js +19 -4
- package/package.json +8 -2
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration management for Amazon SageMaker Provider
|
|
3
|
+
*
|
|
4
|
+
* This module handles loading, validation, and management of SageMaker
|
|
5
|
+
* configuration from environment variables, files, and defaults.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { logger } from "../../utils/logger.js";
|
|
9
|
+
/**
|
|
10
|
+
* Zod schema for SageMaker configuration validation
|
|
11
|
+
*/
|
|
12
|
+
const SageMakerConfigSchema = z.object({
|
|
13
|
+
region: z.string().min(1, "AWS region is required"),
|
|
14
|
+
accessKeyId: z.string().min(1, "AWS access key ID is required"),
|
|
15
|
+
secretAccessKey: z.string().min(1, "AWS secret access key is required"),
|
|
16
|
+
sessionToken: z.string().optional(),
|
|
17
|
+
timeout: z.number().min(1000).max(300000).optional(),
|
|
18
|
+
maxRetries: z.number().min(0).max(10).optional(),
|
|
19
|
+
endpoint: z.string().url().optional(),
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Zod schema for SageMaker model configuration validation
|
|
23
|
+
*/
|
|
24
|
+
const SageMakerModelConfigSchema = z.object({
|
|
25
|
+
endpointName: z.string().min(1, "Endpoint name is required"),
|
|
26
|
+
modelType: z
|
|
27
|
+
.enum(["llama", "mistral", "claude", "huggingface", "jumpstart", "custom"])
|
|
28
|
+
.optional(),
|
|
29
|
+
contentType: z.string().optional(),
|
|
30
|
+
accept: z.string().optional(),
|
|
31
|
+
customAttributes: z.string().optional(),
|
|
32
|
+
inputFormat: z.enum(["huggingface", "jumpstart", "custom"]).optional(),
|
|
33
|
+
outputFormat: z.enum(["huggingface", "jumpstart", "custom"]).optional(),
|
|
34
|
+
maxTokens: z.number().min(1).max(100000).optional(),
|
|
35
|
+
temperature: z.number().min(0).max(2).optional(),
|
|
36
|
+
topP: z.number().min(0).max(1).optional(),
|
|
37
|
+
stopSequences: z.array(z.string()).optional(),
|
|
38
|
+
maxConcurrentDetectionTests: z.number().min(1).max(10).optional(),
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* Configuration cache to avoid repeated environment variable reads
|
|
42
|
+
*/
|
|
43
|
+
let configCache = null;
|
|
44
|
+
const modelConfigCache = new Map();
|
|
45
|
+
/**
|
|
46
|
+
* Load and validate SageMaker configuration from environment variables
|
|
47
|
+
*
|
|
48
|
+
* Environment variable priority:
|
|
49
|
+
* 1. SAGEMAKER_* variables (highest priority)
|
|
50
|
+
* 2. AWS_* variables (standard AWS SDK variables)
|
|
51
|
+
* 3. Default values (lowest priority)
|
|
52
|
+
*
|
|
53
|
+
* @returns Validated SageMaker configuration
|
|
54
|
+
* @throws {Error} When required configuration is missing or invalid
|
|
55
|
+
*/
|
|
56
|
+
export function getSageMakerConfig() {
|
|
57
|
+
// Return cached config if available
|
|
58
|
+
if (configCache) {
|
|
59
|
+
return configCache;
|
|
60
|
+
}
|
|
61
|
+
const config = {
|
|
62
|
+
region: process.env.SAGEMAKER_REGION || process.env.AWS_REGION || "us-east-1",
|
|
63
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID || "",
|
|
64
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || "",
|
|
65
|
+
sessionToken: process.env.AWS_SESSION_TOKEN,
|
|
66
|
+
timeout: parseInt(process.env.SAGEMAKER_TIMEOUT || "30000"),
|
|
67
|
+
maxRetries: parseInt(process.env.SAGEMAKER_MAX_RETRIES || "3"),
|
|
68
|
+
endpoint: process.env.SAGEMAKER_ENDPOINT,
|
|
69
|
+
};
|
|
70
|
+
// Validate configuration using Zod schema
|
|
71
|
+
try {
|
|
72
|
+
const validatedConfig = SageMakerConfigSchema.parse(config);
|
|
73
|
+
// Cache the validated configuration
|
|
74
|
+
configCache = validatedConfig;
|
|
75
|
+
return validatedConfig;
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
if (error instanceof z.ZodError) {
|
|
79
|
+
const errorMessages = error.errors.map((err) => `${err.path.join(".")}: ${err.message}`);
|
|
80
|
+
throw new Error(`SageMaker configuration validation failed:\n${errorMessages.join("\n")}\n\n` +
|
|
81
|
+
`Please set the required environment variables:\n` +
|
|
82
|
+
`- AWS_ACCESS_KEY_ID: Your AWS access key\n` +
|
|
83
|
+
`- AWS_SECRET_ACCESS_KEY: Your AWS secret key\n` +
|
|
84
|
+
`- AWS_REGION: AWS region (default: us-east-1)\n` +
|
|
85
|
+
`- AWS_SESSION_TOKEN: Session token (optional, for temporary credentials)\n` +
|
|
86
|
+
`- SAGEMAKER_TIMEOUT: Request timeout in ms (optional, default: 30000)\n` +
|
|
87
|
+
`- SAGEMAKER_MAX_RETRIES: Max retry attempts (optional, default: 3)`);
|
|
88
|
+
}
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Load and validate SageMaker model configuration
|
|
94
|
+
*
|
|
95
|
+
* @param endpointName - Name of the SageMaker endpoint
|
|
96
|
+
* @returns Validated model configuration
|
|
97
|
+
*/
|
|
98
|
+
export function getSageMakerModelConfig(endpointName) {
|
|
99
|
+
const endpoint = endpointName || getDefaultSageMakerEndpoint();
|
|
100
|
+
// Check cache first
|
|
101
|
+
if (modelConfigCache.has(endpoint)) {
|
|
102
|
+
return modelConfigCache.get(endpoint);
|
|
103
|
+
}
|
|
104
|
+
const config = {
|
|
105
|
+
endpointName: endpoint,
|
|
106
|
+
modelType: process.env.SAGEMAKER_MODEL_TYPE || "custom",
|
|
107
|
+
contentType: process.env.SAGEMAKER_CONTENT_TYPE || "application/json",
|
|
108
|
+
accept: process.env.SAGEMAKER_ACCEPT || "application/json",
|
|
109
|
+
customAttributes: process.env.SAGEMAKER_CUSTOM_ATTRIBUTES,
|
|
110
|
+
inputFormat: process.env.SAGEMAKER_INPUT_FORMAT || "custom",
|
|
111
|
+
outputFormat: process.env.SAGEMAKER_OUTPUT_FORMAT || "custom",
|
|
112
|
+
maxTokens: process.env.SAGEMAKER_MAX_TOKENS
|
|
113
|
+
? parseInt(process.env.SAGEMAKER_MAX_TOKENS)
|
|
114
|
+
: undefined,
|
|
115
|
+
temperature: process.env.SAGEMAKER_TEMPERATURE
|
|
116
|
+
? parseFloat(process.env.SAGEMAKER_TEMPERATURE)
|
|
117
|
+
: undefined,
|
|
118
|
+
topP: process.env.SAGEMAKER_TOP_P
|
|
119
|
+
? parseFloat(process.env.SAGEMAKER_TOP_P)
|
|
120
|
+
: undefined,
|
|
121
|
+
stopSequences: process.env.SAGEMAKER_STOP_SEQUENCES
|
|
122
|
+
? process.env.SAGEMAKER_STOP_SEQUENCES.split(",").map((s) => s.trim())
|
|
123
|
+
: undefined,
|
|
124
|
+
};
|
|
125
|
+
// Validate configuration
|
|
126
|
+
try {
|
|
127
|
+
const validatedConfig = SageMakerModelConfigSchema.parse(config);
|
|
128
|
+
// Cache the validated configuration
|
|
129
|
+
modelConfigCache.set(endpoint, validatedConfig);
|
|
130
|
+
return validatedConfig;
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
if (error instanceof z.ZodError) {
|
|
134
|
+
const errorMessages = error.errors.map((err) => `${err.path.join(".")}: ${err.message}`);
|
|
135
|
+
throw new Error(`SageMaker model configuration validation failed for endpoint '${endpoint}':\n${errorMessages.join("\n")}`);
|
|
136
|
+
}
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Get the default SageMaker endpoint name from environment variables
|
|
142
|
+
*
|
|
143
|
+
* @returns Default endpoint name
|
|
144
|
+
*/
|
|
145
|
+
export function getDefaultSageMakerEndpoint() {
|
|
146
|
+
return (process.env.SAGEMAKER_DEFAULT_ENDPOINT ||
|
|
147
|
+
process.env.SAGEMAKER_ENDPOINT_NAME ||
|
|
148
|
+
"default-endpoint");
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Get SageMaker model name from environment variables
|
|
152
|
+
*
|
|
153
|
+
* @returns Model name
|
|
154
|
+
*/
|
|
155
|
+
export function getSageMakerModel() {
|
|
156
|
+
return (process.env.SAGEMAKER_MODEL ||
|
|
157
|
+
process.env.SAGEMAKER_MODEL_NAME ||
|
|
158
|
+
"sagemaker-model");
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Check AWS access key presence (minimal validation to prevent credential enumeration)
|
|
162
|
+
* @param accessKeyId - AWS access key to check
|
|
163
|
+
* @returns Validation result
|
|
164
|
+
*/
|
|
165
|
+
function checkAccessKeyPresence(accessKeyId) {
|
|
166
|
+
// Only check for obviously invalid keys (empty/whitespace)
|
|
167
|
+
// Delegate all other validation to AWS SDK to prevent credential enumeration
|
|
168
|
+
if (!accessKeyId || accessKeyId.trim() === "") {
|
|
169
|
+
return { isValid: false };
|
|
170
|
+
}
|
|
171
|
+
// Accept any non-empty string - let AWS handle validation
|
|
172
|
+
// This prevents attackers from learning about valid formats
|
|
173
|
+
return { isValid: true };
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Validate AWS credentials are properly configured
|
|
177
|
+
*
|
|
178
|
+
* @param config - SageMaker configuration to validate
|
|
179
|
+
* @returns true if credentials are valid
|
|
180
|
+
* @throws {Error} When credentials are missing or invalid
|
|
181
|
+
*/
|
|
182
|
+
export function validateAWSCredentials(config) {
|
|
183
|
+
if (!config.accessKeyId || config.accessKeyId.trim() === "") {
|
|
184
|
+
throw new Error("AWS Access Key ID is missing. Please set AWS_ACCESS_KEY_ID environment variable.");
|
|
185
|
+
}
|
|
186
|
+
if (!config.secretAccessKey || config.secretAccessKey.trim() === "") {
|
|
187
|
+
throw new Error("AWS Secret Access Key is missing. Please set AWS_SECRET_ACCESS_KEY environment variable.");
|
|
188
|
+
}
|
|
189
|
+
// Basic AWS access key validation (let AWS SDK handle detailed validation)
|
|
190
|
+
const accessKeyValidation = checkAccessKeyPresence(config.accessKeyId);
|
|
191
|
+
if (!accessKeyValidation.isValid) {
|
|
192
|
+
// Minimal logging for security - let AWS SDK handle detailed validation
|
|
193
|
+
logger.warn("AWS Access Key ID format check failed. " +
|
|
194
|
+
"Please verify your AWS credentials are correct.");
|
|
195
|
+
}
|
|
196
|
+
// Validate region format
|
|
197
|
+
if (!/^[a-z0-9-]+$/.test(config.region)) {
|
|
198
|
+
throw new Error(`Invalid AWS region format: ${config.region}. Expected format: us-east-1, eu-west-1, etc.`);
|
|
199
|
+
}
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Create a comprehensive configuration summary for debugging
|
|
204
|
+
*
|
|
205
|
+
* @returns Configuration summary (sensitive data masked)
|
|
206
|
+
*/
|
|
207
|
+
export function getConfigurationSummary() {
|
|
208
|
+
try {
|
|
209
|
+
const config = getSageMakerConfig();
|
|
210
|
+
const defaultEndpoint = getDefaultSageMakerEndpoint();
|
|
211
|
+
const modelConfig = getSageMakerModelConfig();
|
|
212
|
+
return {
|
|
213
|
+
aws: {
|
|
214
|
+
region: config.region,
|
|
215
|
+
accessKeyId: config.accessKeyId
|
|
216
|
+
? `${config.accessKeyId.substring(0, 4)}***`
|
|
217
|
+
: "NOT_SET",
|
|
218
|
+
secretAccessKey: config.secretAccessKey ? "***SET***" : "NOT_SET",
|
|
219
|
+
sessionToken: config.sessionToken ? "***SET***" : "NOT_SET",
|
|
220
|
+
timeout: config.timeout,
|
|
221
|
+
maxRetries: config.maxRetries,
|
|
222
|
+
endpoint: config.endpoint || "DEFAULT",
|
|
223
|
+
},
|
|
224
|
+
sagemaker: {
|
|
225
|
+
defaultEndpoint,
|
|
226
|
+
model: getSageMakerModel(),
|
|
227
|
+
modelConfig: {
|
|
228
|
+
endpointName: modelConfig.endpointName,
|
|
229
|
+
modelType: modelConfig.modelType,
|
|
230
|
+
contentType: modelConfig.contentType,
|
|
231
|
+
accept: modelConfig.accept,
|
|
232
|
+
inputFormat: modelConfig.inputFormat,
|
|
233
|
+
outputFormat: modelConfig.outputFormat,
|
|
234
|
+
maxTokens: modelConfig.maxTokens,
|
|
235
|
+
temperature: modelConfig.temperature,
|
|
236
|
+
topP: modelConfig.topP,
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
environment: {
|
|
240
|
+
nodeEnv: process.env.NODE_ENV || "development",
|
|
241
|
+
sagemakerConfigured: !!process.env.SAGEMAKER_DEFAULT_ENDPOINT,
|
|
242
|
+
awsConfigured: !!(process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY),
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
return {
|
|
248
|
+
error: error instanceof Error ? error.message : "Unknown configuration error",
|
|
249
|
+
configured: false,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Clear configuration cache (useful for testing or credential rotation)
|
|
255
|
+
*/
|
|
256
|
+
export function clearConfigurationCache() {
|
|
257
|
+
configCache = null;
|
|
258
|
+
modelConfigCache.clear();
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Load configuration from a JSON file (alternative to environment variables)
|
|
262
|
+
*
|
|
263
|
+
* @param filePath - Path to configuration JSON file
|
|
264
|
+
* @returns Loaded configuration
|
|
265
|
+
*/
|
|
266
|
+
export async function loadConfigurationFromFile(filePath) {
|
|
267
|
+
try {
|
|
268
|
+
const fs = await import("fs/promises");
|
|
269
|
+
const configData = await fs.readFile(filePath, "utf-8");
|
|
270
|
+
const parsedConfig = JSON.parse(configData);
|
|
271
|
+
// Validate the loaded configuration
|
|
272
|
+
const validatedConfig = SageMakerConfigSchema.parse(parsedConfig);
|
|
273
|
+
// Update cache with file-based configuration
|
|
274
|
+
configCache = validatedConfig;
|
|
275
|
+
return validatedConfig;
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
throw new Error(`Failed to load SageMaker configuration from file '${filePath}': ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Check if SageMaker provider is properly configured
|
|
283
|
+
*
|
|
284
|
+
* @returns Configuration check result
|
|
285
|
+
*/
|
|
286
|
+
export function checkSageMakerConfiguration() {
|
|
287
|
+
const issues = [];
|
|
288
|
+
let configured = false;
|
|
289
|
+
try {
|
|
290
|
+
// Try to load configuration
|
|
291
|
+
const config = getSageMakerConfig();
|
|
292
|
+
validateAWSCredentials(config);
|
|
293
|
+
// Check endpoint configuration
|
|
294
|
+
const endpoint = getDefaultSageMakerEndpoint();
|
|
295
|
+
if (endpoint === "default-endpoint") {
|
|
296
|
+
issues.push("Default endpoint name detected. Consider setting SAGEMAKER_DEFAULT_ENDPOINT.");
|
|
297
|
+
}
|
|
298
|
+
configured = true;
|
|
299
|
+
}
|
|
300
|
+
catch (error) {
|
|
301
|
+
issues.push(error instanceof Error ? error.message : "Unknown configuration error");
|
|
302
|
+
}
|
|
303
|
+
return {
|
|
304
|
+
configured,
|
|
305
|
+
issues,
|
|
306
|
+
summary: getConfigurationSummary(),
|
|
307
|
+
};
|
|
308
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SageMaker Model Detection and Streaming Capability Discovery
|
|
3
|
+
*
|
|
4
|
+
* This module provides intelligent detection of SageMaker endpoint capabilities
|
|
5
|
+
* including model type identification and streaming protocol support.
|
|
6
|
+
*/
|
|
7
|
+
import type { SageMakerConfig, SageMakerModelConfig } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Streaming capability information for an endpoint
|
|
10
|
+
*/
|
|
11
|
+
export interface StreamingCapability {
|
|
12
|
+
/** Whether streaming is supported */
|
|
13
|
+
supported: boolean;
|
|
14
|
+
/** Detected streaming protocol */
|
|
15
|
+
protocol: "sse" | "jsonl" | "chunked" | "none";
|
|
16
|
+
/** Detected model framework */
|
|
17
|
+
modelType: "huggingface" | "llama" | "pytorch" | "tensorflow" | "custom";
|
|
18
|
+
/** Test endpoint for streaming validation */
|
|
19
|
+
testEndpoint?: string;
|
|
20
|
+
/** Required parameters for streaming */
|
|
21
|
+
parameters?: Record<string, unknown>;
|
|
22
|
+
/** Confidence level of detection (0-1) */
|
|
23
|
+
confidence: number;
|
|
24
|
+
/** Additional metadata about the model */
|
|
25
|
+
metadata?: {
|
|
26
|
+
modelName?: string;
|
|
27
|
+
framework?: string;
|
|
28
|
+
version?: string;
|
|
29
|
+
tags?: string[];
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Model type detection result
|
|
34
|
+
*/
|
|
35
|
+
export interface ModelDetectionResult {
|
|
36
|
+
/** Primary model type */
|
|
37
|
+
type: StreamingCapability["modelType"];
|
|
38
|
+
/** Detection confidence (0-1) */
|
|
39
|
+
confidence: number;
|
|
40
|
+
/** Evidence used for detection */
|
|
41
|
+
evidence: string[];
|
|
42
|
+
/** Suggested configuration */
|
|
43
|
+
suggestedConfig?: Partial<SageMakerModelConfig>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Endpoint health and metadata information
|
|
47
|
+
*/
|
|
48
|
+
export interface EndpointHealth {
|
|
49
|
+
/** Health status */
|
|
50
|
+
status: "healthy" | "unhealthy" | "unknown";
|
|
51
|
+
/** Response time in milliseconds */
|
|
52
|
+
responseTime: number;
|
|
53
|
+
/** Endpoint metadata if available */
|
|
54
|
+
metadata?: Record<string, unknown>;
|
|
55
|
+
/** Model information if discoverable */
|
|
56
|
+
modelInfo?: {
|
|
57
|
+
name?: string;
|
|
58
|
+
version?: string;
|
|
59
|
+
framework?: string;
|
|
60
|
+
architecture?: string;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* SageMaker Model Detection and Capability Discovery Service
|
|
65
|
+
*/
|
|
66
|
+
export declare class SageMakerDetector {
|
|
67
|
+
private client;
|
|
68
|
+
private config;
|
|
69
|
+
constructor(config: SageMakerConfig);
|
|
70
|
+
/**
|
|
71
|
+
* Detect streaming capabilities for a given endpoint
|
|
72
|
+
*/
|
|
73
|
+
detectStreamingCapability(endpointName: string): Promise<StreamingCapability>;
|
|
74
|
+
/**
|
|
75
|
+
* Detect the model type/framework for an endpoint
|
|
76
|
+
*/
|
|
77
|
+
detectModelType(endpointName: string): Promise<ModelDetectionResult>;
|
|
78
|
+
/**
|
|
79
|
+
* Check endpoint health and gather metadata
|
|
80
|
+
*/
|
|
81
|
+
checkEndpointHealth(endpointName: string): Promise<EndpointHealth>;
|
|
82
|
+
/**
|
|
83
|
+
* Test if endpoint supports streaming for given model type
|
|
84
|
+
*/
|
|
85
|
+
private testStreamingSupport;
|
|
86
|
+
/**
|
|
87
|
+
* Detect streaming protocol used by endpoint
|
|
88
|
+
*/
|
|
89
|
+
private detectStreamingProtocol;
|
|
90
|
+
/**
|
|
91
|
+
* Test for HuggingFace Transformers signature
|
|
92
|
+
*/
|
|
93
|
+
private testHuggingFaceSignature;
|
|
94
|
+
/**
|
|
95
|
+
* Test for LLaMA model signature
|
|
96
|
+
*/
|
|
97
|
+
private testLlamaSignature;
|
|
98
|
+
/**
|
|
99
|
+
* Test for PyTorch model signature
|
|
100
|
+
*/
|
|
101
|
+
private testPyTorchSignature;
|
|
102
|
+
/**
|
|
103
|
+
* Test for TensorFlow Serving signature
|
|
104
|
+
*/
|
|
105
|
+
private testTensorFlowSignature;
|
|
106
|
+
/**
|
|
107
|
+
* Get streaming test cases for a model type
|
|
108
|
+
*/
|
|
109
|
+
private getStreamingTestCases;
|
|
110
|
+
/**
|
|
111
|
+
* Check if response indicates streaming support
|
|
112
|
+
*/
|
|
113
|
+
private indicatesStreamingSupport;
|
|
114
|
+
/**
|
|
115
|
+
* Extract model information from response
|
|
116
|
+
*/
|
|
117
|
+
private extractModelInfo;
|
|
118
|
+
/**
|
|
119
|
+
* Get suggested configuration for detected model type
|
|
120
|
+
*/
|
|
121
|
+
private getSuggestedConfig;
|
|
122
|
+
/**
|
|
123
|
+
* Run detection tests in parallel with intelligent rate limiting and circuit breaker
|
|
124
|
+
* Now uses configuration object for better parameter management
|
|
125
|
+
*/
|
|
126
|
+
private runDetectionTestsInParallel;
|
|
127
|
+
/**
|
|
128
|
+
* Create a semaphore for detection test concurrency control
|
|
129
|
+
*/
|
|
130
|
+
private createDetectionSemaphore;
|
|
131
|
+
/**
|
|
132
|
+
* Wrap a detection test with error handling, rate limiting, and retry logic
|
|
133
|
+
* Now uses configuration object instead of multiple parameters
|
|
134
|
+
*/
|
|
135
|
+
private wrapDetectionTest;
|
|
136
|
+
/**
|
|
137
|
+
* Execute a test with staggered start to spread load
|
|
138
|
+
*/
|
|
139
|
+
private executeWithStaggeredStart;
|
|
140
|
+
/**
|
|
141
|
+
* Handle detection test errors with rate limiting and retry logic
|
|
142
|
+
*/
|
|
143
|
+
private handleDetectionTestError;
|
|
144
|
+
/**
|
|
145
|
+
* Check if an error indicates rate limiting
|
|
146
|
+
*/
|
|
147
|
+
private isRateLimitError;
|
|
148
|
+
/**
|
|
149
|
+
* Retry a test with exponential backoff
|
|
150
|
+
*/
|
|
151
|
+
private retryWithBackoff;
|
|
152
|
+
/**
|
|
153
|
+
* Execute wrapped tests with concurrency control
|
|
154
|
+
*/
|
|
155
|
+
private executeTestsWithConcurrencyControl;
|
|
156
|
+
/**
|
|
157
|
+
* Log detection test failure
|
|
158
|
+
*/
|
|
159
|
+
private logDetectionTestFailure;
|
|
160
|
+
/**
|
|
161
|
+
* Log detection test retry failure
|
|
162
|
+
*/
|
|
163
|
+
private logDetectionTestRetryFailure;
|
|
164
|
+
/**
|
|
165
|
+
* Log final detection results
|
|
166
|
+
*/
|
|
167
|
+
private logDetectionResults;
|
|
168
|
+
/**
|
|
169
|
+
* Create a no-streaming capability result
|
|
170
|
+
*/
|
|
171
|
+
private createNoStreamingCapability;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Create a detector instance with configuration
|
|
175
|
+
*/
|
|
176
|
+
export declare function createSageMakerDetector(config: SageMakerConfig): SageMakerDetector;
|