@juspay/neurolink 7.29.2 → 7.30.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 +12 -0
- package/dist/cli/commands/config.d.ts +83 -83
- package/dist/cli/commands/mcp.js +39 -9
- package/dist/cli/commands/models.js +25 -21
- package/dist/cli/commands/ollama.js +2 -2
- package/dist/cli/factories/commandFactory.d.ts +8 -0
- package/dist/cli/factories/commandFactory.js +65 -65
- package/dist/cli/factories/ollamaCommandFactory.js +3 -1
- package/dist/cli/factories/sagemakerCommandFactory.js +3 -2
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +11 -11
- package/dist/cli/utils/envManager.js +5 -5
- package/dist/cli/utils/ollamaUtils.d.ts +12 -0
- package/dist/cli/utils/ollamaUtils.js +58 -42
- package/dist/config/configManager.js +5 -2
- package/dist/config/conversationMemoryConfig.js +5 -0
- package/dist/core/analytics.d.ts +2 -24
- package/dist/core/analytics.js +12 -17
- package/dist/core/baseProvider.d.ts +30 -1
- package/dist/core/baseProvider.js +180 -198
- package/dist/core/conversationMemoryManager.d.ts +9 -15
- package/dist/core/conversationMemoryManager.js +98 -57
- package/dist/core/dynamicModels.d.ts +4 -4
- package/dist/core/dynamicModels.js +7 -7
- package/dist/core/evaluation.d.ts +9 -9
- package/dist/core/evaluation.js +117 -65
- package/dist/core/evaluationProviders.d.ts +18 -2
- package/dist/core/evaluationProviders.js +15 -13
- package/dist/core/modelConfiguration.d.ts +63 -0
- package/dist/core/modelConfiguration.js +354 -290
- package/dist/core/streamAnalytics.d.ts +10 -5
- package/dist/core/streamAnalytics.js +10 -10
- package/dist/core/types.d.ts +22 -110
- package/dist/core/types.js +13 -0
- package/dist/factories/providerFactory.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/lib/config/configManager.js +5 -2
- package/dist/lib/config/conversationMemoryConfig.js +5 -0
- package/dist/lib/core/analytics.d.ts +2 -24
- package/dist/lib/core/analytics.js +12 -17
- package/dist/lib/core/baseProvider.d.ts +30 -1
- package/dist/lib/core/baseProvider.js +180 -198
- package/dist/lib/core/conversationMemoryManager.d.ts +9 -15
- package/dist/lib/core/conversationMemoryManager.js +98 -57
- package/dist/lib/core/dynamicModels.js +7 -7
- package/dist/lib/core/evaluation.d.ts +9 -9
- package/dist/lib/core/evaluation.js +117 -65
- package/dist/lib/core/evaluationProviders.d.ts +18 -2
- package/dist/lib/core/evaluationProviders.js +15 -13
- package/dist/lib/core/modelConfiguration.d.ts +63 -0
- package/dist/lib/core/modelConfiguration.js +354 -290
- package/dist/lib/core/streamAnalytics.d.ts +10 -5
- package/dist/lib/core/streamAnalytics.js +10 -10
- package/dist/lib/core/types.d.ts +22 -110
- package/dist/lib/core/types.js +13 -0
- package/dist/lib/factories/providerFactory.js +1 -1
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/mcp/externalServerManager.js +15 -6
- package/dist/lib/mcp/factory.js +1 -1
- package/dist/lib/mcp/index.d.ts +1 -1
- package/dist/lib/mcp/index.js +1 -1
- package/dist/lib/mcp/mcpCircuitBreaker.js +5 -1
- package/dist/lib/mcp/mcpClientFactory.js +3 -0
- package/dist/lib/mcp/registry.d.ts +3 -3
- package/dist/lib/mcp/registry.js +3 -3
- package/dist/lib/mcp/servers/aiProviders/aiAnalysisTools.js +5 -5
- package/dist/lib/mcp/servers/aiProviders/aiWorkflowTools.js +6 -6
- package/dist/lib/mcp/servers/utilities/utilityServer.js +1 -1
- package/dist/lib/mcp/toolDiscoveryService.js +8 -2
- package/dist/lib/mcp/toolRegistry.js +4 -4
- package/dist/lib/middleware/builtin/analytics.js +4 -4
- package/dist/lib/middleware/builtin/guardrails.js +2 -2
- package/dist/lib/middleware/registry.js +11 -2
- package/dist/lib/models/modelRegistry.d.ts +1 -1
- package/dist/lib/models/modelRegistry.js +3 -3
- package/dist/lib/models/modelResolver.d.ts +1 -1
- package/dist/lib/models/modelResolver.js +2 -2
- package/dist/lib/neurolink.d.ts +116 -9
- package/dist/lib/neurolink.js +718 -956
- package/dist/lib/providers/amazonSagemaker.d.ts +1 -1
- package/dist/lib/providers/amazonSagemaker.js +12 -3
- package/dist/lib/providers/anthropic.d.ts +1 -1
- package/dist/lib/providers/anthropic.js +7 -6
- package/dist/lib/providers/anthropicBaseProvider.d.ts +1 -1
- package/dist/lib/providers/anthropicBaseProvider.js +4 -3
- package/dist/lib/providers/azureOpenai.d.ts +1 -1
- package/dist/lib/providers/azureOpenai.js +1 -1
- package/dist/lib/providers/googleAiStudio.d.ts +1 -1
- package/dist/lib/providers/googleAiStudio.js +2 -2
- package/dist/lib/providers/googleVertex.d.ts +40 -0
- package/dist/lib/providers/googleVertex.js +330 -274
- package/dist/lib/providers/huggingFace.js +1 -1
- package/dist/lib/providers/mistral.d.ts +1 -1
- package/dist/lib/providers/mistral.js +2 -2
- package/dist/lib/providers/ollama.d.ts +4 -0
- package/dist/lib/providers/ollama.js +38 -18
- package/dist/lib/providers/openAI.d.ts +1 -1
- package/dist/lib/providers/openAI.js +2 -2
- package/dist/lib/providers/sagemaker/adaptive-semaphore.js +7 -4
- package/dist/lib/providers/sagemaker/client.js +13 -3
- package/dist/lib/providers/sagemaker/config.js +5 -1
- package/dist/lib/providers/sagemaker/detection.js +19 -9
- package/dist/lib/providers/sagemaker/errors.d.ts +8 -1
- package/dist/lib/providers/sagemaker/errors.js +103 -20
- package/dist/lib/providers/sagemaker/language-model.d.ts +3 -3
- package/dist/lib/providers/sagemaker/language-model.js +4 -4
- package/dist/lib/providers/sagemaker/parsers.js +14 -6
- package/dist/lib/providers/sagemaker/streaming.js +14 -3
- package/dist/lib/providers/sagemaker/types.d.ts +1 -1
- package/dist/lib/proxy/awsProxyIntegration.js +1 -1
- package/dist/lib/sdk/toolRegistration.d.ts +1 -1
- package/dist/lib/types/cli.d.ts +80 -8
- package/dist/lib/types/contextTypes.js +2 -2
- package/dist/lib/types/conversationTypes.d.ts +10 -0
- package/dist/lib/types/generateTypes.d.ts +2 -5
- package/dist/lib/types/providers.d.ts +81 -19
- package/dist/lib/types/providers.js +6 -6
- package/dist/lib/types/streamTypes.d.ts +4 -6
- package/dist/lib/types/typeAliases.d.ts +1 -1
- package/dist/lib/utils/analyticsUtils.d.ts +33 -0
- package/dist/lib/utils/analyticsUtils.js +76 -0
- package/dist/lib/utils/conversationMemoryUtils.d.ts +1 -2
- package/dist/lib/utils/conversationMemoryUtils.js +6 -7
- package/dist/lib/utils/errorHandling.js +4 -1
- package/dist/lib/utils/evaluationUtils.d.ts +27 -0
- package/dist/lib/utils/evaluationUtils.js +131 -0
- package/dist/lib/utils/optionsUtils.js +10 -1
- package/dist/lib/utils/performance.d.ts +1 -1
- package/dist/lib/utils/performance.js +15 -3
- package/dist/lib/utils/providerHealth.d.ts +48 -0
- package/dist/lib/utils/providerHealth.js +199 -254
- package/dist/lib/utils/providerUtils.js +2 -2
- package/dist/lib/utils/timeout.js +8 -3
- package/dist/mcp/externalServerManager.js +15 -6
- package/dist/mcp/factory.js +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/mcpCircuitBreaker.js +5 -1
- package/dist/mcp/mcpClientFactory.js +3 -0
- package/dist/mcp/registry.d.ts +3 -3
- package/dist/mcp/registry.js +3 -3
- package/dist/mcp/servers/aiProviders/aiAnalysisTools.js +5 -5
- package/dist/mcp/servers/aiProviders/aiWorkflowTools.js +6 -6
- package/dist/mcp/servers/utilities/utilityServer.js +1 -1
- package/dist/mcp/toolDiscoveryService.js +8 -2
- package/dist/mcp/toolRegistry.js +4 -4
- package/dist/middleware/builtin/analytics.js +4 -4
- package/dist/middleware/builtin/guardrails.js +2 -2
- package/dist/middleware/registry.js +11 -2
- package/dist/models/modelRegistry.d.ts +1 -1
- package/dist/models/modelRegistry.js +3 -3
- package/dist/models/modelResolver.d.ts +1 -1
- package/dist/models/modelResolver.js +2 -2
- package/dist/neurolink.d.ts +116 -9
- package/dist/neurolink.js +718 -956
- package/dist/providers/amazonSagemaker.d.ts +1 -1
- package/dist/providers/amazonSagemaker.js +12 -3
- package/dist/providers/anthropic.d.ts +1 -1
- package/dist/providers/anthropic.js +7 -6
- package/dist/providers/anthropicBaseProvider.d.ts +1 -1
- package/dist/providers/anthropicBaseProvider.js +4 -3
- package/dist/providers/azureOpenai.d.ts +1 -1
- package/dist/providers/azureOpenai.js +1 -1
- package/dist/providers/googleAiStudio.d.ts +1 -1
- package/dist/providers/googleAiStudio.js +2 -2
- package/dist/providers/googleVertex.d.ts +40 -0
- package/dist/providers/googleVertex.js +330 -274
- package/dist/providers/huggingFace.js +1 -1
- package/dist/providers/mistral.d.ts +1 -1
- package/dist/providers/mistral.js +2 -2
- package/dist/providers/ollama.d.ts +4 -0
- package/dist/providers/ollama.js +38 -18
- package/dist/providers/openAI.d.ts +1 -1
- package/dist/providers/openAI.js +2 -2
- package/dist/providers/sagemaker/adaptive-semaphore.js +7 -4
- package/dist/providers/sagemaker/client.js +13 -3
- package/dist/providers/sagemaker/config.js +5 -1
- package/dist/providers/sagemaker/detection.js +19 -9
- package/dist/providers/sagemaker/errors.d.ts +8 -1
- package/dist/providers/sagemaker/errors.js +103 -20
- package/dist/providers/sagemaker/language-model.d.ts +3 -3
- package/dist/providers/sagemaker/language-model.js +4 -4
- package/dist/providers/sagemaker/parsers.js +14 -6
- package/dist/providers/sagemaker/streaming.js +14 -3
- package/dist/providers/sagemaker/types.d.ts +1 -1
- package/dist/proxy/awsProxyIntegration.js +1 -1
- package/dist/sdk/toolRegistration.d.ts +1 -1
- package/dist/types/cli.d.ts +80 -8
- package/dist/types/contextTypes.js +2 -2
- package/dist/types/conversationTypes.d.ts +10 -0
- package/dist/types/generateTypes.d.ts +2 -5
- package/dist/types/providers.d.ts +81 -19
- package/dist/types/providers.js +6 -6
- package/dist/types/streamTypes.d.ts +4 -6
- package/dist/types/typeAliases.d.ts +1 -1
- package/dist/utils/analyticsUtils.d.ts +33 -0
- package/dist/utils/analyticsUtils.js +76 -0
- package/dist/utils/conversationMemoryUtils.d.ts +1 -2
- package/dist/utils/conversationMemoryUtils.js +6 -7
- package/dist/utils/errorHandling.js +4 -1
- package/dist/utils/evaluationUtils.d.ts +27 -0
- package/dist/utils/evaluationUtils.js +131 -0
- package/dist/utils/optionsUtils.js +10 -1
- package/dist/utils/performance.d.ts +1 -1
- package/dist/utils/performance.js +15 -3
- package/dist/utils/providerHealth.d.ts +48 -0
- package/dist/utils/providerHealth.js +199 -254
- package/dist/utils/providerUtils.js +2 -2
- package/dist/utils/timeout.js +8 -3
- package/package.json +1 -1
- package/dist/context/ContextManager.d.ts +0 -28
- package/dist/context/ContextManager.js +0 -113
- package/dist/context/config.d.ts +0 -5
- package/dist/context/config.js +0 -42
- package/dist/context/types.d.ts +0 -20
- package/dist/context/types.js +0 -1
- package/dist/context/utils.d.ts +0 -7
- package/dist/context/utils.js +0 -8
- package/dist/lib/context/ContextManager.d.ts +0 -28
- package/dist/lib/context/ContextManager.js +0 -113
- package/dist/lib/context/config.d.ts +0 -5
- package/dist/lib/context/config.js +0 -42
- package/dist/lib/context/types.d.ts +0 -20
- package/dist/lib/context/types.js +0 -1
- package/dist/lib/context/utils.d.ts +0 -7
- package/dist/lib/context/utils.js +0 -8
|
@@ -101,7 +101,7 @@ const createVertexSettings = async () => {
|
|
|
101
101
|
return baseSettings;
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
catch
|
|
104
|
+
catch {
|
|
105
105
|
// Silent error handling for runtime credentials file creation
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -187,7 +187,7 @@ const createVertexSettings = async () => {
|
|
|
187
187
|
hasProjectId: !!requiredEnvVars.project_id,
|
|
188
188
|
hasType: !!requiredEnvVars.type,
|
|
189
189
|
missingFields: Object.entries(requiredEnvVars)
|
|
190
|
-
.filter(([
|
|
190
|
+
.filter(([_key, value]) => !value)
|
|
191
191
|
.map(([key]) => key),
|
|
192
192
|
},
|
|
193
193
|
},
|
|
@@ -272,12 +272,9 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
272
272
|
return model;
|
|
273
273
|
}
|
|
274
274
|
/**
|
|
275
|
-
*
|
|
276
|
-
* Uses dual provider architecture for proper model routing
|
|
277
|
-
* Creates fresh instances for each request to ensure proper authentication
|
|
275
|
+
* Initialize model creation logging and tracking
|
|
278
276
|
*/
|
|
279
|
-
|
|
280
|
-
// 🚀 EXHAUSTIVE LOGGING POINT V001: MODEL CREATION ENTRY
|
|
277
|
+
initializeModelCreationLogging() {
|
|
281
278
|
const modelCreationId = `vertex-model-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
|
282
279
|
const modelCreationStartTime = Date.now();
|
|
283
280
|
const modelCreationHrTimeStart = process.hrtime.bigint();
|
|
@@ -310,7 +307,17 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
310
307
|
cpuUsage: process.cpuUsage(),
|
|
311
308
|
message: "Starting model creation with comprehensive environment analysis",
|
|
312
309
|
});
|
|
313
|
-
|
|
310
|
+
return {
|
|
311
|
+
modelCreationId,
|
|
312
|
+
modelCreationStartTime,
|
|
313
|
+
modelCreationHrTimeStart,
|
|
314
|
+
modelName,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Check if model is Anthropic-based and attempt creation
|
|
319
|
+
*/
|
|
320
|
+
async attemptAnthropicModelCreation(modelName, modelCreationId, modelCreationStartTime, modelCreationHrTimeStart) {
|
|
314
321
|
const anthropicCheckStartTime = process.hrtime.bigint();
|
|
315
322
|
const isAnthropic = isAnthropicModel(modelName);
|
|
316
323
|
logger.debug(`[GoogleVertexProvider] 🤖 LOG_POINT_V002_ANTHROPIC_CHECK`, {
|
|
@@ -327,90 +334,93 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
327
334
|
anthropicModelPatterns: ["claude"],
|
|
328
335
|
message: "Checking if model is Anthropic-based",
|
|
329
336
|
});
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
337
|
+
if (!isAnthropic) {
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
const anthropicModelStartTime = process.hrtime.bigint();
|
|
341
|
+
logger.debug(`[GoogleVertexProvider] 🧠 LOG_POINT_V003_ANTHROPIC_MODEL_START`, {
|
|
342
|
+
logPoint: "V003_ANTHROPIC_MODEL_START",
|
|
343
|
+
modelCreationId,
|
|
344
|
+
timestamp: new Date().toISOString(),
|
|
345
|
+
elapsedMs: Date.now() - modelCreationStartTime,
|
|
346
|
+
elapsedNs: (process.hrtime.bigint() - modelCreationHrTimeStart).toString(),
|
|
347
|
+
anthropicModelStartTimeNs: anthropicModelStartTime.toString(),
|
|
348
|
+
modelName,
|
|
349
|
+
hasAnthropicSupport: hasAnthropicSupport(),
|
|
350
|
+
message: "Creating Anthropic model using vertexAnthropic provider",
|
|
351
|
+
});
|
|
352
|
+
logger.debug("Creating Anthropic model using vertexAnthropic provider", {
|
|
353
|
+
modelName,
|
|
354
|
+
});
|
|
355
|
+
if (!hasAnthropicSupport()) {
|
|
356
|
+
logger.warn(`[GoogleVertexProvider] Anthropic support not available, falling back to Google model`);
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
try {
|
|
360
|
+
const anthropicModel = await this.createAnthropicModel(modelName);
|
|
361
|
+
if (anthropicModel) {
|
|
362
|
+
const anthropicModelSuccessTime = process.hrtime.bigint();
|
|
363
|
+
const anthropicModelDurationNs = anthropicModelSuccessTime - anthropicModelStartTime;
|
|
364
|
+
logger.debug(`[GoogleVertexProvider] ✅ LOG_POINT_V004_ANTHROPIC_MODEL_SUCCESS`, {
|
|
365
|
+
logPoint: "V004_ANTHROPIC_MODEL_SUCCESS",
|
|
366
|
+
modelCreationId,
|
|
367
|
+
timestamp: new Date().toISOString(),
|
|
368
|
+
elapsedMs: Date.now() - modelCreationStartTime,
|
|
369
|
+
elapsedNs: (process.hrtime.bigint() - modelCreationHrTimeStart).toString(),
|
|
370
|
+
anthropicModelDurationNs: anthropicModelDurationNs.toString(),
|
|
371
|
+
anthropicModelDurationMs: Number(anthropicModelDurationNs) / 1000000,
|
|
372
|
+
modelName,
|
|
373
|
+
hasAnthropicModel: !!anthropicModel,
|
|
374
|
+
anthropicModelType: typeof anthropicModel,
|
|
375
|
+
memoryUsageAfterAnthropicCreation: process.memoryUsage(),
|
|
376
|
+
message: "Anthropic model created successfully via vertexAnthropic",
|
|
377
|
+
});
|
|
378
|
+
return anthropicModel;
|
|
379
|
+
}
|
|
380
|
+
// Anthropic model creation returned null
|
|
381
|
+
const anthropicModelNullTime = process.hrtime.bigint();
|
|
382
|
+
const anthropicModelDurationNs = anthropicModelNullTime - anthropicModelStartTime;
|
|
383
|
+
logger.warn(`[GoogleVertexProvider] ⚠️ LOG_POINT_V005_ANTHROPIC_MODEL_NULL`, {
|
|
384
|
+
logPoint: "V005_ANTHROPIC_MODEL_NULL",
|
|
336
385
|
modelCreationId,
|
|
337
386
|
timestamp: new Date().toISOString(),
|
|
338
387
|
elapsedMs: Date.now() - modelCreationStartTime,
|
|
339
388
|
elapsedNs: (process.hrtime.bigint() - modelCreationHrTimeStart).toString(),
|
|
340
|
-
|
|
389
|
+
anthropicModelDurationNs: anthropicModelDurationNs.toString(),
|
|
390
|
+
anthropicModelDurationMs: Number(anthropicModelDurationNs) / 1000000,
|
|
341
391
|
modelName,
|
|
342
|
-
|
|
343
|
-
|
|
392
|
+
hasAnthropicModel: false,
|
|
393
|
+
fallbackToGoogle: true,
|
|
394
|
+
message: "Anthropic model creation returned null - falling back to Google model",
|
|
344
395
|
});
|
|
345
|
-
|
|
396
|
+
}
|
|
397
|
+
catch (error) {
|
|
398
|
+
const anthropicModelErrorTime = process.hrtime.bigint();
|
|
399
|
+
const anthropicModelDurationNs = anthropicModelErrorTime - anthropicModelStartTime;
|
|
400
|
+
logger.error(`[GoogleVertexProvider] ❌ LOG_POINT_V006_ANTHROPIC_MODEL_ERROR`, {
|
|
401
|
+
logPoint: "V006_ANTHROPIC_MODEL_ERROR",
|
|
402
|
+
modelCreationId,
|
|
403
|
+
timestamp: new Date().toISOString(),
|
|
404
|
+
elapsedMs: Date.now() - modelCreationStartTime,
|
|
405
|
+
elapsedNs: (process.hrtime.bigint() - modelCreationHrTimeStart).toString(),
|
|
406
|
+
anthropicModelDurationNs: anthropicModelDurationNs.toString(),
|
|
407
|
+
anthropicModelDurationMs: Number(anthropicModelDurationNs) / 1000000,
|
|
346
408
|
modelName,
|
|
409
|
+
error: error instanceof Error ? error.message : String(error),
|
|
410
|
+
errorName: error instanceof Error ? error.name : "UnknownError",
|
|
411
|
+
errorStack: error instanceof Error ? error.stack : undefined,
|
|
412
|
+
fallbackToGoogle: true,
|
|
413
|
+
message: "Anthropic model creation failed - falling back to Google model",
|
|
347
414
|
});
|
|
348
|
-
if (!hasAnthropicSupport()) {
|
|
349
|
-
logger.warn(`[GoogleVertexProvider] Anthropic support not available, falling back to Google model`);
|
|
350
|
-
}
|
|
351
|
-
else {
|
|
352
|
-
try {
|
|
353
|
-
const anthropicModel = await this.createAnthropicModel(modelName);
|
|
354
|
-
if (anthropicModel) {
|
|
355
|
-
const anthropicModelSuccessTime = process.hrtime.bigint();
|
|
356
|
-
const anthropicModelDurationNs = anthropicModelSuccessTime - anthropicModelStartTime;
|
|
357
|
-
logger.debug(`[GoogleVertexProvider] ✅ LOG_POINT_V004_ANTHROPIC_MODEL_SUCCESS`, {
|
|
358
|
-
logPoint: "V004_ANTHROPIC_MODEL_SUCCESS",
|
|
359
|
-
modelCreationId,
|
|
360
|
-
timestamp: new Date().toISOString(),
|
|
361
|
-
elapsedMs: Date.now() - modelCreationStartTime,
|
|
362
|
-
elapsedNs: (process.hrtime.bigint() - modelCreationHrTimeStart).toString(),
|
|
363
|
-
anthropicModelDurationNs: anthropicModelDurationNs.toString(),
|
|
364
|
-
anthropicModelDurationMs: Number(anthropicModelDurationNs) / 1000000,
|
|
365
|
-
modelName,
|
|
366
|
-
hasAnthropicModel: !!anthropicModel,
|
|
367
|
-
anthropicModelType: typeof anthropicModel,
|
|
368
|
-
memoryUsageAfterAnthropicCreation: process.memoryUsage(),
|
|
369
|
-
message: "Anthropic model created successfully via vertexAnthropic",
|
|
370
|
-
});
|
|
371
|
-
return anthropicModel;
|
|
372
|
-
}
|
|
373
|
-
// Anthropic model creation returned null
|
|
374
|
-
const anthropicModelNullTime = process.hrtime.bigint();
|
|
375
|
-
const anthropicModelDurationNs = anthropicModelNullTime - anthropicModelStartTime;
|
|
376
|
-
logger.warn(`[GoogleVertexProvider] ⚠️ LOG_POINT_V005_ANTHROPIC_MODEL_NULL`, {
|
|
377
|
-
logPoint: "V005_ANTHROPIC_MODEL_NULL",
|
|
378
|
-
modelCreationId,
|
|
379
|
-
timestamp: new Date().toISOString(),
|
|
380
|
-
elapsedMs: Date.now() - modelCreationStartTime,
|
|
381
|
-
elapsedNs: (process.hrtime.bigint() - modelCreationHrTimeStart).toString(),
|
|
382
|
-
anthropicModelDurationNs: anthropicModelDurationNs.toString(),
|
|
383
|
-
anthropicModelDurationMs: Number(anthropicModelDurationNs) / 1000000,
|
|
384
|
-
modelName,
|
|
385
|
-
hasAnthropicModel: false,
|
|
386
|
-
fallbackToGoogle: true,
|
|
387
|
-
message: "Anthropic model creation returned null - falling back to Google model",
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
catch (error) {
|
|
391
|
-
const anthropicModelErrorTime = process.hrtime.bigint();
|
|
392
|
-
const anthropicModelDurationNs = anthropicModelErrorTime - anthropicModelStartTime;
|
|
393
|
-
logger.error(`[GoogleVertexProvider] ❌ LOG_POINT_V006_ANTHROPIC_MODEL_ERROR`, {
|
|
394
|
-
logPoint: "V006_ANTHROPIC_MODEL_ERROR",
|
|
395
|
-
modelCreationId,
|
|
396
|
-
timestamp: new Date().toISOString(),
|
|
397
|
-
elapsedMs: Date.now() - modelCreationStartTime,
|
|
398
|
-
elapsedNs: (process.hrtime.bigint() - modelCreationHrTimeStart).toString(),
|
|
399
|
-
anthropicModelDurationNs: anthropicModelDurationNs.toString(),
|
|
400
|
-
anthropicModelDurationMs: Number(anthropicModelDurationNs) / 1000000,
|
|
401
|
-
modelName,
|
|
402
|
-
error: error instanceof Error ? error.message : String(error),
|
|
403
|
-
errorName: error instanceof Error ? error.name : "UnknownError",
|
|
404
|
-
errorStack: error instanceof Error ? error.stack : undefined,
|
|
405
|
-
fallbackToGoogle: true,
|
|
406
|
-
message: "Anthropic model creation failed - falling back to Google model",
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
// Fall back to regular model if Anthropic not available
|
|
411
|
-
logger.warn(`Anthropic model ${modelName} requested but not available, falling back to Google model`);
|
|
412
415
|
}
|
|
413
|
-
//
|
|
416
|
+
// Fall back to regular model if Anthropic not available
|
|
417
|
+
logger.warn(`Anthropic model ${modelName} requested but not available, falling back to Google model`);
|
|
418
|
+
return null;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Create Google Vertex model with comprehensive logging and error handling
|
|
422
|
+
*/
|
|
423
|
+
async createGoogleVertexModel(modelName, modelCreationId, modelCreationStartTime, modelCreationHrTimeStart, isAnthropic) {
|
|
414
424
|
const googleModelStartTime = process.hrtime.bigint();
|
|
415
425
|
logger.debug(`[GoogleVertexProvider] 🌐 LOG_POINT_V007_GOOGLE_MODEL_START`, {
|
|
416
426
|
logPoint: "V007_GOOGLE_MODEL_START",
|
|
@@ -425,13 +435,11 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
425
435
|
reason: isAnthropic ? "ANTHROPIC_FALLBACK" : "DIRECT_GOOGLE_MODEL",
|
|
426
436
|
message: "Creating fresh Google Vertex model with current settings",
|
|
427
437
|
});
|
|
428
|
-
// Create fresh Google Vertex model with current settings
|
|
429
438
|
logger.debug("Creating Google Vertex model", {
|
|
430
439
|
modelName,
|
|
431
440
|
project: this.projectId,
|
|
432
441
|
location: this.location,
|
|
433
442
|
});
|
|
434
|
-
// 🚀 EXHAUSTIVE LOGGING POINT V008: VERTEX SETTINGS CREATION
|
|
435
443
|
const vertexSettingsStartTime = process.hrtime.bigint();
|
|
436
444
|
logger.debug(`[GoogleVertexProvider] ⚙️ LOG_POINT_V008_VERTEX_SETTINGS_START`, {
|
|
437
445
|
logPoint: "V008_VERTEX_SETTINGS_START",
|
|
@@ -482,122 +490,7 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
482
490
|
},
|
|
483
491
|
message: "Vertex settings created successfully",
|
|
484
492
|
});
|
|
485
|
-
|
|
486
|
-
const vertexInstanceStartTime = process.hrtime.bigint();
|
|
487
|
-
logger.debug(`[GoogleVertexProvider] 🏗️ LOG_POINT_V010_VERTEX_INSTANCE_START`, {
|
|
488
|
-
logPoint: "V010_VERTEX_INSTANCE_START",
|
|
489
|
-
modelCreationId,
|
|
490
|
-
timestamp: new Date().toISOString(),
|
|
491
|
-
elapsedMs: Date.now() - modelCreationStartTime,
|
|
492
|
-
elapsedNs: (process.hrtime.bigint() - modelCreationHrTimeStart).toString(),
|
|
493
|
-
vertexInstanceStartTimeNs: vertexInstanceStartTime.toString(),
|
|
494
|
-
// Pre-creation network environment
|
|
495
|
-
networkEnvironment: {
|
|
496
|
-
dnsServers: (() => {
|
|
497
|
-
try {
|
|
498
|
-
return dns.getServers ? dns.getServers() : "NOT_AVAILABLE";
|
|
499
|
-
}
|
|
500
|
-
catch {
|
|
501
|
-
return "NOT_AVAILABLE";
|
|
502
|
-
}
|
|
503
|
-
})(),
|
|
504
|
-
networkInterfaces: (() => {
|
|
505
|
-
try {
|
|
506
|
-
return Object.keys(os.networkInterfaces());
|
|
507
|
-
}
|
|
508
|
-
catch {
|
|
509
|
-
return [];
|
|
510
|
-
}
|
|
511
|
-
})(),
|
|
512
|
-
hostname: (() => {
|
|
513
|
-
try {
|
|
514
|
-
return os.hostname();
|
|
515
|
-
}
|
|
516
|
-
catch {
|
|
517
|
-
return "UNKNOWN";
|
|
518
|
-
}
|
|
519
|
-
})(),
|
|
520
|
-
platform: (() => {
|
|
521
|
-
try {
|
|
522
|
-
return os.platform();
|
|
523
|
-
}
|
|
524
|
-
catch {
|
|
525
|
-
return "UNKNOWN";
|
|
526
|
-
}
|
|
527
|
-
})(),
|
|
528
|
-
release: (() => {
|
|
529
|
-
try {
|
|
530
|
-
return os.release();
|
|
531
|
-
}
|
|
532
|
-
catch {
|
|
533
|
-
return "UNKNOWN";
|
|
534
|
-
}
|
|
535
|
-
})(),
|
|
536
|
-
},
|
|
537
|
-
message: "Creating Vertex AI instance",
|
|
538
|
-
});
|
|
539
|
-
const vertex = createVertex(vertexSettings);
|
|
540
|
-
const vertexInstanceEndTime = process.hrtime.bigint();
|
|
541
|
-
const vertexInstanceDurationNs = vertexInstanceEndTime - vertexInstanceStartTime;
|
|
542
|
-
logger.debug(`[GoogleVertexProvider] ✅ LOG_POINT_V011_VERTEX_INSTANCE_SUCCESS`, {
|
|
543
|
-
logPoint: "V011_VERTEX_INSTANCE_SUCCESS",
|
|
544
|
-
modelCreationId,
|
|
545
|
-
timestamp: new Date().toISOString(),
|
|
546
|
-
elapsedMs: Date.now() - modelCreationStartTime,
|
|
547
|
-
elapsedNs: (process.hrtime.bigint() - modelCreationHrTimeStart).toString(),
|
|
548
|
-
vertexInstanceDurationNs: vertexInstanceDurationNs.toString(),
|
|
549
|
-
vertexInstanceDurationMs: Number(vertexInstanceDurationNs) / 1000000,
|
|
550
|
-
hasVertexInstance: !!vertex,
|
|
551
|
-
vertexInstanceType: typeof vertex,
|
|
552
|
-
message: "Vertex AI instance created successfully",
|
|
553
|
-
});
|
|
554
|
-
// 🚀 EXHAUSTIVE LOGGING POINT V012: MODEL INSTANCE CREATION
|
|
555
|
-
const modelInstanceStartTime = process.hrtime.bigint();
|
|
556
|
-
logger.debug(`[GoogleVertexProvider] 🎯 LOG_POINT_V012_MODEL_INSTANCE_START`, {
|
|
557
|
-
logPoint: "V012_MODEL_INSTANCE_START",
|
|
558
|
-
modelCreationId,
|
|
559
|
-
timestamp: new Date().toISOString(),
|
|
560
|
-
elapsedMs: Date.now() - modelCreationStartTime,
|
|
561
|
-
elapsedNs: (process.hrtime.bigint() - modelCreationHrTimeStart).toString(),
|
|
562
|
-
modelInstanceStartTimeNs: modelInstanceStartTime.toString(),
|
|
563
|
-
modelName,
|
|
564
|
-
hasVertexInstance: !!vertex,
|
|
565
|
-
message: "Creating model instance from Vertex AI instance",
|
|
566
|
-
});
|
|
567
|
-
const model = vertex(modelName);
|
|
568
|
-
const modelInstanceEndTime = process.hrtime.bigint();
|
|
569
|
-
const modelInstanceDurationNs = modelInstanceEndTime - modelInstanceStartTime;
|
|
570
|
-
const totalModelCreationDurationNs = modelInstanceEndTime - modelCreationHrTimeStart;
|
|
571
|
-
logger.info(`[GoogleVertexProvider] 🏁 LOG_POINT_V013_MODEL_CREATION_COMPLETE`, {
|
|
572
|
-
logPoint: "V013_MODEL_CREATION_COMPLETE",
|
|
573
|
-
modelCreationId,
|
|
574
|
-
timestamp: new Date().toISOString(),
|
|
575
|
-
totalElapsedMs: Date.now() - modelCreationStartTime,
|
|
576
|
-
totalElapsedNs: totalModelCreationDurationNs.toString(),
|
|
577
|
-
totalDurationMs: Number(totalModelCreationDurationNs) / 1000000,
|
|
578
|
-
modelInstanceDurationNs: modelInstanceDurationNs.toString(),
|
|
579
|
-
modelInstanceDurationMs: Number(modelInstanceDurationNs) / 1000000,
|
|
580
|
-
// Final model analysis
|
|
581
|
-
finalModel: {
|
|
582
|
-
hasModel: !!model,
|
|
583
|
-
modelType: typeof model,
|
|
584
|
-
modelName,
|
|
585
|
-
isAnthropicModel: isAnthropic,
|
|
586
|
-
projectId: this.projectId,
|
|
587
|
-
location: this.location,
|
|
588
|
-
},
|
|
589
|
-
// Performance summary
|
|
590
|
-
performanceSummary: {
|
|
591
|
-
vertexSettingsDurationMs: Number(vertexSettingsDurationNs) / 1000000,
|
|
592
|
-
vertexInstanceDurationMs: Number(vertexInstanceDurationNs) / 1000000,
|
|
593
|
-
modelInstanceDurationMs: Number(modelInstanceDurationNs) / 1000000,
|
|
594
|
-
totalDurationMs: Number(totalModelCreationDurationNs) / 1000000,
|
|
595
|
-
},
|
|
596
|
-
// Memory usage
|
|
597
|
-
finalMemoryUsage: process.memoryUsage(),
|
|
598
|
-
message: "Model creation completed successfully - ready for API calls",
|
|
599
|
-
});
|
|
600
|
-
return model;
|
|
493
|
+
return await this.createVertexInstance(vertexSettings, modelName, modelCreationId, modelCreationStartTime, modelCreationHrTimeStart);
|
|
601
494
|
}
|
|
602
495
|
catch (error) {
|
|
603
496
|
const vertexSettingsErrorTime = process.hrtime.bigint();
|
|
@@ -654,14 +547,146 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
654
547
|
throw error;
|
|
655
548
|
}
|
|
656
549
|
}
|
|
550
|
+
/**
|
|
551
|
+
* Create Vertex AI instance and model with comprehensive logging
|
|
552
|
+
*/
|
|
553
|
+
async createVertexInstance(vertexSettings, modelName, modelCreationId, modelCreationStartTime, modelCreationHrTimeStart) {
|
|
554
|
+
const vertexInstanceStartTime = process.hrtime.bigint();
|
|
555
|
+
logger.debug(`[GoogleVertexProvider] 🏗️ LOG_POINT_V010_VERTEX_INSTANCE_START`, {
|
|
556
|
+
logPoint: "V010_VERTEX_INSTANCE_START",
|
|
557
|
+
modelCreationId,
|
|
558
|
+
timestamp: new Date().toISOString(),
|
|
559
|
+
elapsedMs: Date.now() - modelCreationStartTime,
|
|
560
|
+
elapsedNs: (process.hrtime.bigint() - modelCreationHrTimeStart).toString(),
|
|
561
|
+
vertexInstanceStartTimeNs: vertexInstanceStartTime.toString(),
|
|
562
|
+
// Pre-creation network environment
|
|
563
|
+
networkEnvironment: {
|
|
564
|
+
dnsServers: (() => {
|
|
565
|
+
try {
|
|
566
|
+
return dns.getServers ? dns.getServers() : "NOT_AVAILABLE";
|
|
567
|
+
}
|
|
568
|
+
catch {
|
|
569
|
+
return "NOT_AVAILABLE";
|
|
570
|
+
}
|
|
571
|
+
})(),
|
|
572
|
+
networkInterfaces: (() => {
|
|
573
|
+
try {
|
|
574
|
+
return Object.keys(os.networkInterfaces());
|
|
575
|
+
}
|
|
576
|
+
catch {
|
|
577
|
+
return [];
|
|
578
|
+
}
|
|
579
|
+
})(),
|
|
580
|
+
hostname: (() => {
|
|
581
|
+
try {
|
|
582
|
+
return os.hostname();
|
|
583
|
+
}
|
|
584
|
+
catch {
|
|
585
|
+
return "UNKNOWN";
|
|
586
|
+
}
|
|
587
|
+
})(),
|
|
588
|
+
platform: (() => {
|
|
589
|
+
try {
|
|
590
|
+
return os.platform();
|
|
591
|
+
}
|
|
592
|
+
catch {
|
|
593
|
+
return "UNKNOWN";
|
|
594
|
+
}
|
|
595
|
+
})(),
|
|
596
|
+
release: (() => {
|
|
597
|
+
try {
|
|
598
|
+
return os.release();
|
|
599
|
+
}
|
|
600
|
+
catch {
|
|
601
|
+
return "UNKNOWN";
|
|
602
|
+
}
|
|
603
|
+
})(),
|
|
604
|
+
},
|
|
605
|
+
message: "Creating Vertex AI instance",
|
|
606
|
+
});
|
|
607
|
+
const vertex = createVertex(vertexSettings);
|
|
608
|
+
const vertexInstanceEndTime = process.hrtime.bigint();
|
|
609
|
+
const vertexInstanceDurationNs = vertexInstanceEndTime - vertexInstanceStartTime;
|
|
610
|
+
logger.debug(`[GoogleVertexProvider] ✅ LOG_POINT_V011_VERTEX_INSTANCE_SUCCESS`, {
|
|
611
|
+
logPoint: "V011_VERTEX_INSTANCE_SUCCESS",
|
|
612
|
+
modelCreationId,
|
|
613
|
+
timestamp: new Date().toISOString(),
|
|
614
|
+
elapsedMs: Date.now() - modelCreationStartTime,
|
|
615
|
+
elapsedNs: (process.hrtime.bigint() - modelCreationHrTimeStart).toString(),
|
|
616
|
+
vertexInstanceDurationNs: vertexInstanceDurationNs.toString(),
|
|
617
|
+
vertexInstanceDurationMs: Number(vertexInstanceDurationNs) / 1000000,
|
|
618
|
+
hasVertexInstance: !!vertex,
|
|
619
|
+
vertexInstanceType: typeof vertex,
|
|
620
|
+
message: "Vertex AI instance created successfully",
|
|
621
|
+
});
|
|
622
|
+
const modelInstanceStartTime = process.hrtime.bigint();
|
|
623
|
+
logger.debug(`[GoogleVertexProvider] 🎯 LOG_POINT_V012_MODEL_INSTANCE_START`, {
|
|
624
|
+
logPoint: "V012_MODEL_INSTANCE_START",
|
|
625
|
+
modelCreationId,
|
|
626
|
+
timestamp: new Date().toISOString(),
|
|
627
|
+
elapsedMs: Date.now() - modelCreationStartTime,
|
|
628
|
+
elapsedNs: (process.hrtime.bigint() - modelCreationHrTimeStart).toString(),
|
|
629
|
+
modelInstanceStartTimeNs: modelInstanceStartTime.toString(),
|
|
630
|
+
modelName,
|
|
631
|
+
hasVertexInstance: !!vertex,
|
|
632
|
+
message: "Creating model instance from Vertex AI instance",
|
|
633
|
+
});
|
|
634
|
+
const model = vertex(modelName);
|
|
635
|
+
const modelInstanceEndTime = process.hrtime.bigint();
|
|
636
|
+
const modelInstanceDurationNs = modelInstanceEndTime - modelInstanceStartTime;
|
|
637
|
+
const totalModelCreationDurationNs = modelInstanceEndTime - modelCreationHrTimeStart;
|
|
638
|
+
logger.info(`[GoogleVertexProvider] 🏁 LOG_POINT_V013_MODEL_CREATION_COMPLETE`, {
|
|
639
|
+
logPoint: "V013_MODEL_CREATION_COMPLETE",
|
|
640
|
+
modelCreationId,
|
|
641
|
+
timestamp: new Date().toISOString(),
|
|
642
|
+
totalElapsedMs: Date.now() - modelCreationStartTime,
|
|
643
|
+
totalElapsedNs: totalModelCreationDurationNs.toString(),
|
|
644
|
+
totalDurationMs: Number(totalModelCreationDurationNs) / 1000000,
|
|
645
|
+
modelInstanceDurationNs: modelInstanceDurationNs.toString(),
|
|
646
|
+
modelInstanceDurationMs: Number(modelInstanceDurationNs) / 1000000,
|
|
647
|
+
// Final model analysis
|
|
648
|
+
finalModel: {
|
|
649
|
+
hasModel: !!model,
|
|
650
|
+
modelType: typeof model,
|
|
651
|
+
modelName,
|
|
652
|
+
isAnthropicModel: isAnthropicModel(modelName),
|
|
653
|
+
projectId: this.projectId,
|
|
654
|
+
location: this.location,
|
|
655
|
+
},
|
|
656
|
+
// Performance summary
|
|
657
|
+
performanceSummary: {
|
|
658
|
+
vertexSettingsDurationMs: Number(vertexInstanceDurationNs) / 1000000,
|
|
659
|
+
vertexInstanceDurationMs: Number(vertexInstanceDurationNs) / 1000000,
|
|
660
|
+
modelInstanceDurationMs: Number(modelInstanceDurationNs) / 1000000,
|
|
661
|
+
totalDurationMs: Number(totalModelCreationDurationNs) / 1000000,
|
|
662
|
+
},
|
|
663
|
+
// Memory usage
|
|
664
|
+
finalMemoryUsage: process.memoryUsage(),
|
|
665
|
+
message: "Model creation completed successfully - ready for API calls",
|
|
666
|
+
});
|
|
667
|
+
return model;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Gets the appropriate model instance (Google or Anthropic)
|
|
671
|
+
* Uses dual provider architecture for proper model routing
|
|
672
|
+
* Creates fresh instances for each request to ensure proper authentication
|
|
673
|
+
*/
|
|
674
|
+
async getModel() {
|
|
675
|
+
// Initialize logging and setup
|
|
676
|
+
const { modelCreationId, modelCreationStartTime, modelCreationHrTimeStart, modelName, } = this.initializeModelCreationLogging();
|
|
677
|
+
// Check if this is an Anthropic model and attempt creation
|
|
678
|
+
const anthropicModel = await this.attemptAnthropicModelCreation(modelName, modelCreationId, modelCreationStartTime, modelCreationHrTimeStart);
|
|
679
|
+
if (anthropicModel) {
|
|
680
|
+
return anthropicModel;
|
|
681
|
+
}
|
|
682
|
+
// Fall back to Google Vertex model creation
|
|
683
|
+
return await this.createGoogleVertexModel(modelName, modelCreationId, modelCreationStartTime, modelCreationHrTimeStart, isAnthropicModel(modelName));
|
|
684
|
+
}
|
|
657
685
|
// executeGenerate removed - BaseProvider handles all generation with tools
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
const streamExecutionHrTimeStart = process.hrtime.bigint();
|
|
663
|
-
const functionTag = "GoogleVertexProvider.executeStream";
|
|
664
|
-
let chunkCount = 0;
|
|
686
|
+
/**
|
|
687
|
+
* Log stream execution start with comprehensive analysis
|
|
688
|
+
*/
|
|
689
|
+
logStreamExecutionStart(streamExecutionId, streamExecutionStartTime, streamExecutionHrTimeStart, functionTag, options, analysisSchema) {
|
|
665
690
|
logger.info(`[GoogleVertexProvider] 🎬 LOG_POINT_S001_STREAM_EXECUTION_START`, {
|
|
666
691
|
logPoint: "S001_STREAM_EXECUTION_START",
|
|
667
692
|
streamExecutionId,
|
|
@@ -708,9 +733,11 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
708
733
|
cpuUsage: process.cpuUsage(),
|
|
709
734
|
message: "Stream execution starting with comprehensive analysis",
|
|
710
735
|
});
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Log timeout setup process
|
|
739
|
+
*/
|
|
740
|
+
logTimeoutSetup(streamExecutionId, streamExecutionStartTime, streamExecutionHrTimeStart, timeoutSetupStartTime, timeout) {
|
|
714
741
|
logger.debug(`[GoogleVertexProvider] ⏰ LOG_POINT_S002_TIMEOUT_SETUP`, {
|
|
715
742
|
logPoint: "S002_TIMEOUT_SETUP",
|
|
716
743
|
streamExecutionId,
|
|
@@ -723,8 +750,11 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
723
750
|
streamType: "stream",
|
|
724
751
|
message: "Setting up timeout controller for stream execution",
|
|
725
752
|
});
|
|
726
|
-
|
|
727
|
-
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* Log successful timeout setup
|
|
756
|
+
*/
|
|
757
|
+
logTimeoutSetupSuccess(streamExecutionId, streamExecutionStartTime, streamExecutionHrTimeStart, timeoutSetupStartTime, timeoutController, timeout) {
|
|
728
758
|
const timeoutSetupEndTime = process.hrtime.bigint();
|
|
729
759
|
const timeoutSetupDurationNs = timeoutSetupEndTime - timeoutSetupStartTime;
|
|
730
760
|
logger.debug(`[GoogleVertexProvider] ✅ LOG_POINT_S003_TIMEOUT_SETUP_SUCCESS`, {
|
|
@@ -739,83 +769,109 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
739
769
|
timeoutValue: timeout,
|
|
740
770
|
message: "Timeout controller setup completed",
|
|
741
771
|
});
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Log and perform stream options validation
|
|
775
|
+
*/
|
|
776
|
+
logAndValidateStreamOptions(streamExecutionId, streamExecutionStartTime, streamExecutionHrTimeStart, options) {
|
|
777
|
+
const validationStartTime = process.hrtime.bigint();
|
|
778
|
+
logger.debug(`[GoogleVertexProvider] ✔️ LOG_POINT_S004_VALIDATION_START`, {
|
|
779
|
+
logPoint: "S004_VALIDATION_START",
|
|
780
|
+
streamExecutionId,
|
|
781
|
+
timestamp: new Date().toISOString(),
|
|
782
|
+
elapsedMs: Date.now() - streamExecutionStartTime,
|
|
783
|
+
elapsedNs: (process.hrtime.bigint() - streamExecutionHrTimeStart).toString(),
|
|
784
|
+
validationStartTimeNs: validationStartTime.toString(),
|
|
785
|
+
message: "Starting stream options validation",
|
|
786
|
+
});
|
|
787
|
+
this.validateStreamOptions(options);
|
|
788
|
+
const validationEndTime = process.hrtime.bigint();
|
|
789
|
+
const validationDurationNs = validationEndTime - validationStartTime;
|
|
790
|
+
logger.debug(`[GoogleVertexProvider] ✅ LOG_POINT_S005_VALIDATION_SUCCESS`, {
|
|
791
|
+
logPoint: "S005_VALIDATION_SUCCESS",
|
|
792
|
+
streamExecutionId,
|
|
793
|
+
timestamp: new Date().toISOString(),
|
|
794
|
+
elapsedMs: Date.now() - streamExecutionStartTime,
|
|
795
|
+
elapsedNs: (process.hrtime.bigint() - streamExecutionHrTimeStart).toString(),
|
|
796
|
+
validationDurationNs: validationDurationNs.toString(),
|
|
797
|
+
validationDurationMs: Number(validationDurationNs) / 1000000,
|
|
798
|
+
message: "Stream options validation successful",
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Log start of message building process
|
|
803
|
+
*/
|
|
804
|
+
logMessageBuildStart(streamExecutionId, streamExecutionStartTime, streamExecutionHrTimeStart) {
|
|
805
|
+
const messagesBuildStartTime = process.hrtime.bigint();
|
|
806
|
+
logger.debug(`[GoogleVertexProvider] 📝 LOG_POINT_S006_MESSAGES_BUILD_START`, {
|
|
807
|
+
logPoint: "S006_MESSAGES_BUILD_START",
|
|
808
|
+
streamExecutionId,
|
|
809
|
+
timestamp: new Date().toISOString(),
|
|
810
|
+
elapsedMs: Date.now() - streamExecutionStartTime,
|
|
811
|
+
elapsedNs: (process.hrtime.bigint() - streamExecutionHrTimeStart).toString(),
|
|
812
|
+
messagesBuildStartTimeNs: messagesBuildStartTime.toString(),
|
|
813
|
+
message: "Starting message array building",
|
|
814
|
+
});
|
|
815
|
+
return messagesBuildStartTime;
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* Log successful message building
|
|
819
|
+
*/
|
|
820
|
+
logMessageBuildSuccess(streamExecutionId, streamExecutionStartTime, streamExecutionHrTimeStart, messagesBuildStartTime, messages) {
|
|
821
|
+
const messagesBuildEndTime = process.hrtime.bigint();
|
|
822
|
+
const messagesBuildDurationNs = messagesBuildEndTime - messagesBuildStartTime;
|
|
823
|
+
logger.debug(`[GoogleVertexProvider] ✅ LOG_POINT_S007_MESSAGES_BUILD_SUCCESS`, {
|
|
824
|
+
logPoint: "S007_MESSAGES_BUILD_SUCCESS",
|
|
825
|
+
streamExecutionId,
|
|
826
|
+
timestamp: new Date().toISOString(),
|
|
827
|
+
elapsedMs: Date.now() - streamExecutionStartTime,
|
|
828
|
+
elapsedNs: (process.hrtime.bigint() - streamExecutionHrTimeStart).toString(),
|
|
829
|
+
messagesBuildDurationNs: messagesBuildDurationNs.toString(),
|
|
830
|
+
messagesBuildDurationMs: Number(messagesBuildDurationNs) / 1000000,
|
|
831
|
+
messagesCount: Array.isArray(messages) ? messages.length : 0,
|
|
832
|
+
messagesType: typeof messages,
|
|
833
|
+
hasMessages: !!messages,
|
|
834
|
+
message: "Message array built successfully",
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
async executeStream(options, analysisSchema) {
|
|
838
|
+
// Initialize stream execution tracking
|
|
839
|
+
const streamExecutionId = `vertex-stream-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
|
840
|
+
const streamExecutionStartTime = Date.now();
|
|
841
|
+
const streamExecutionHrTimeStart = process.hrtime.bigint();
|
|
842
|
+
const functionTag = "GoogleVertexProvider.executeStream";
|
|
843
|
+
let chunkCount = 0;
|
|
844
|
+
// Log stream execution start
|
|
845
|
+
this.logStreamExecutionStart(streamExecutionId, streamExecutionStartTime, streamExecutionHrTimeStart, functionTag, options, analysisSchema);
|
|
846
|
+
// Setup timeout controller
|
|
847
|
+
const timeoutSetupStartTime = process.hrtime.bigint();
|
|
848
|
+
const timeout = this.getTimeout(options);
|
|
849
|
+
this.logTimeoutSetup(streamExecutionId, streamExecutionStartTime, streamExecutionHrTimeStart, timeoutSetupStartTime, timeout);
|
|
850
|
+
const timeoutController = createTimeoutController(timeout, this.providerName, "stream");
|
|
851
|
+
this.logTimeoutSetupSuccess(streamExecutionId, streamExecutionStartTime, streamExecutionHrTimeStart, timeoutSetupStartTime, timeoutController, timeout);
|
|
742
852
|
try {
|
|
743
|
-
//
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
streamExecutionId,
|
|
748
|
-
timestamp: new Date().toISOString(),
|
|
749
|
-
elapsedMs: Date.now() - streamExecutionStartTime,
|
|
750
|
-
elapsedNs: (process.hrtime.bigint() - streamExecutionHrTimeStart).toString(),
|
|
751
|
-
validationStartTimeNs: validationStartTime.toString(),
|
|
752
|
-
message: "Starting stream options validation",
|
|
753
|
-
});
|
|
754
|
-
this.validateStreamOptions(options);
|
|
755
|
-
const validationEndTime = process.hrtime.bigint();
|
|
756
|
-
const validationDurationNs = validationEndTime - validationStartTime;
|
|
757
|
-
logger.debug(`[GoogleVertexProvider] ✅ LOG_POINT_S005_VALIDATION_SUCCESS`, {
|
|
758
|
-
logPoint: "S005_VALIDATION_SUCCESS",
|
|
759
|
-
streamExecutionId,
|
|
760
|
-
timestamp: new Date().toISOString(),
|
|
761
|
-
elapsedMs: Date.now() - streamExecutionStartTime,
|
|
762
|
-
elapsedNs: (process.hrtime.bigint() - streamExecutionHrTimeStart).toString(),
|
|
763
|
-
validationDurationNs: validationDurationNs.toString(),
|
|
764
|
-
validationDurationMs: Number(validationDurationNs) / 1000000,
|
|
765
|
-
message: "Stream options validation successful",
|
|
766
|
-
});
|
|
767
|
-
// 🚀 EXHAUSTIVE LOGGING POINT S006: MESSAGE ARRAY BUILDING
|
|
768
|
-
const messagesBuildStartTime = process.hrtime.bigint();
|
|
769
|
-
logger.debug(`[GoogleVertexProvider] 📝 LOG_POINT_S006_MESSAGES_BUILD_START`, {
|
|
770
|
-
logPoint: "S006_MESSAGES_BUILD_START",
|
|
771
|
-
streamExecutionId,
|
|
772
|
-
timestamp: new Date().toISOString(),
|
|
773
|
-
elapsedMs: Date.now() - streamExecutionStartTime,
|
|
774
|
-
elapsedNs: (process.hrtime.bigint() - streamExecutionHrTimeStart).toString(),
|
|
775
|
-
messagesBuildStartTimeNs: messagesBuildStartTime.toString(),
|
|
776
|
-
message: "Building message array from stream options",
|
|
777
|
-
});
|
|
853
|
+
// Validate stream options with logging
|
|
854
|
+
this.logAndValidateStreamOptions(streamExecutionId, streamExecutionStartTime, streamExecutionHrTimeStart, options);
|
|
855
|
+
// Build messages with logging
|
|
856
|
+
const messagesBuildStartTime = this.logMessageBuildStart(streamExecutionId, streamExecutionStartTime, streamExecutionHrTimeStart);
|
|
778
857
|
// Build message array from options
|
|
779
858
|
const messages = buildMessagesArray(options);
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
logger.debug(`[GoogleVertexProvider] ✅ LOG_POINT_S007_MESSAGES_BUILD_SUCCESS`, {
|
|
783
|
-
logPoint: "S007_MESSAGES_BUILD_SUCCESS",
|
|
784
|
-
streamExecutionId,
|
|
785
|
-
timestamp: new Date().toISOString(),
|
|
786
|
-
elapsedMs: Date.now() - streamExecutionStartTime,
|
|
787
|
-
elapsedNs: (process.hrtime.bigint() - streamExecutionHrTimeStart).toString(),
|
|
788
|
-
messagesBuildDurationNs: messagesBuildDurationNs.toString(),
|
|
789
|
-
messagesBuildDurationMs: Number(messagesBuildDurationNs) / 1000000,
|
|
790
|
-
messagesCount: messages?.length || 0,
|
|
791
|
-
messagesType: typeof messages,
|
|
792
|
-
hasMessages: !!messages,
|
|
793
|
-
message: "Message array built successfully",
|
|
794
|
-
});
|
|
795
|
-
// 🚀 EXHAUSTIVE LOGGING POINT S008: INITIAL STREAM REQUEST LOG
|
|
859
|
+
this.logMessageBuildSuccess(streamExecutionId, streamExecutionStartTime, streamExecutionHrTimeStart, messagesBuildStartTime, messages);
|
|
860
|
+
// Log stream request details
|
|
796
861
|
logger.debug(`[GoogleVertexProvider] 🚀 LOG_POINT_S008_STREAM_REQUEST_DETAILS`, {
|
|
797
862
|
logPoint: "S008_STREAM_REQUEST_DETAILS",
|
|
798
863
|
streamExecutionId,
|
|
799
|
-
timestamp: new Date().toISOString(),
|
|
800
|
-
elapsedMs: Date.now() - streamExecutionStartTime,
|
|
801
|
-
elapsedNs: (process.hrtime.bigint() - streamExecutionHrTimeStart).toString(),
|
|
802
|
-
// Detailed request information
|
|
803
864
|
streamRequestDetails: {
|
|
804
865
|
modelName: this.modelName,
|
|
805
866
|
promptLength: options.input.text.length,
|
|
806
867
|
hasSchema: !!analysisSchema,
|
|
807
|
-
messagesCount: messages
|
|
868
|
+
messagesCount: Array.isArray(messages) ? messages.length : 0,
|
|
808
869
|
temperature: options?.temperature,
|
|
809
870
|
maxTokens: options?.maxTokens,
|
|
810
871
|
disableTools: options?.disableTools || false,
|
|
811
872
|
},
|
|
812
873
|
message: "Starting comprehensive stream request processing",
|
|
813
874
|
});
|
|
814
|
-
logger.debug(`${functionTag}: Starting stream request`, {
|
|
815
|
-
modelName: this.modelName,
|
|
816
|
-
promptLength: options.input.text.length,
|
|
817
|
-
hasSchema: !!analysisSchema,
|
|
818
|
-
});
|
|
819
875
|
// 🚀 EXHAUSTIVE LOGGING POINT S009: MODEL CREATION FOR STREAM
|
|
820
876
|
const modelCreationStartTime = process.hrtime.bigint();
|
|
821
877
|
logger.debug(`[GoogleVertexProvider] 🏭 LOG_POINT_S009_MODEL_CREATION_FOR_STREAM`, {
|