@juspay/neurolink 9.36.1 → 9.38.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/auth/errors.d.ts +1 -1
- package/dist/auth/middleware/AuthMiddleware.d.ts +1 -1
- package/dist/auth/providers/BaseAuthProvider.d.ts +1 -1
- package/dist/browser/neurolink.min.js +1105 -556
- package/dist/cli/commands/evaluate.d.ts +48 -0
- package/dist/cli/commands/evaluate.js +955 -0
- package/dist/cli/parser.js +4 -1
- package/dist/evaluation/BatchEvaluator.d.ts +163 -0
- package/dist/evaluation/BatchEvaluator.js +267 -0
- package/dist/evaluation/EvaluationAggregator.d.ts +272 -0
- package/dist/evaluation/EvaluationAggregator.js +377 -0
- package/dist/evaluation/EvaluatorFactory.d.ts +113 -0
- package/dist/evaluation/EvaluatorFactory.js +280 -0
- package/dist/evaluation/EvaluatorRegistry.d.ts +160 -0
- package/dist/evaluation/EvaluatorRegistry.js +184 -0
- package/dist/evaluation/errors/EvaluationError.d.ts +189 -0
- package/dist/evaluation/errors/EvaluationError.js +206 -0
- package/dist/evaluation/errors/index.d.ts +4 -0
- package/dist/evaluation/errors/index.js +4 -0
- package/dist/evaluation/hooks/index.d.ts +6 -0
- package/dist/evaluation/hooks/index.js +6 -0
- package/dist/evaluation/hooks/langfuseAdapter.d.ts +99 -0
- package/dist/evaluation/hooks/langfuseAdapter.js +172 -0
- package/dist/evaluation/hooks/observabilityHooks.d.ts +129 -0
- package/dist/evaluation/hooks/observabilityHooks.js +181 -0
- package/dist/evaluation/index.d.ts +11 -2
- package/dist/evaluation/index.js +15 -0
- package/dist/evaluation/pipeline/evaluationPipeline.d.ts +114 -0
- package/dist/evaluation/pipeline/evaluationPipeline.js +381 -0
- package/dist/evaluation/pipeline/index.d.ts +8 -0
- package/dist/evaluation/pipeline/index.js +8 -0
- package/dist/evaluation/pipeline/pipelineBuilder.d.ts +126 -0
- package/dist/evaluation/pipeline/pipelineBuilder.js +260 -0
- package/dist/evaluation/pipeline/presets.d.ts +66 -0
- package/dist/evaluation/pipeline/presets.js +224 -0
- package/dist/evaluation/pipeline/strategies/batchStrategy.d.ts +99 -0
- package/dist/evaluation/pipeline/strategies/batchStrategy.js +238 -0
- package/dist/evaluation/pipeline/strategies/index.d.ts +6 -0
- package/dist/evaluation/pipeline/strategies/index.js +6 -0
- package/dist/evaluation/pipeline/strategies/samplingStrategy.d.ts +76 -0
- package/dist/evaluation/pipeline/strategies/samplingStrategy.js +238 -0
- package/dist/evaluation/reporting/index.d.ts +6 -0
- package/dist/evaluation/reporting/index.js +6 -0
- package/dist/evaluation/reporting/metricsCollector.d.ts +147 -0
- package/dist/evaluation/reporting/metricsCollector.js +285 -0
- package/dist/evaluation/reporting/reportGenerator.d.ts +90 -0
- package/dist/evaluation/reporting/reportGenerator.js +374 -0
- package/dist/evaluation/scorers/baseScorer.d.ts +83 -0
- package/dist/evaluation/scorers/baseScorer.js +232 -0
- package/dist/evaluation/scorers/customScorerUtils.d.ts +95 -0
- package/dist/evaluation/scorers/customScorerUtils.js +381 -0
- package/dist/evaluation/scorers/index.d.ts +10 -0
- package/dist/evaluation/scorers/index.js +16 -0
- package/dist/evaluation/scorers/llm/answerRelevancyScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/answerRelevancyScorer.js +99 -0
- package/dist/evaluation/scorers/llm/baseLLMScorer.d.ts +71 -0
- package/dist/evaluation/scorers/llm/baseLLMScorer.js +281 -0
- package/dist/evaluation/scorers/llm/biasDetectionScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/biasDetectionScorer.js +127 -0
- package/dist/evaluation/scorers/llm/contextPrecisionScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/contextPrecisionScorer.js +92 -0
- package/dist/evaluation/scorers/llm/contextRelevancyScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/contextRelevancyScorer.js +107 -0
- package/dist/evaluation/scorers/llm/faithfulnessScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/faithfulnessScorer.js +121 -0
- package/dist/evaluation/scorers/llm/hallucinationScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/hallucinationScorer.js +140 -0
- package/dist/evaluation/scorers/llm/index.d.ts +15 -0
- package/dist/evaluation/scorers/llm/index.js +16 -0
- package/dist/evaluation/scorers/llm/promptAlignmentScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/promptAlignmentScorer.js +106 -0
- package/dist/evaluation/scorers/llm/summarizationScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/summarizationScorer.js +114 -0
- package/dist/evaluation/scorers/llm/toneConsistencyScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/toneConsistencyScorer.js +106 -0
- package/dist/evaluation/scorers/llm/toxicityScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/toxicityScorer.js +121 -0
- package/dist/evaluation/scorers/rule/baseRuleScorer.d.ts +77 -0
- package/dist/evaluation/scorers/rule/baseRuleScorer.js +233 -0
- package/dist/evaluation/scorers/rule/contentSimilarityScorer.d.ts +108 -0
- package/dist/evaluation/scorers/rule/contentSimilarityScorer.js +350 -0
- package/dist/evaluation/scorers/rule/formatScorer.d.ts +147 -0
- package/dist/evaluation/scorers/rule/formatScorer.js +470 -0
- package/dist/evaluation/scorers/rule/index.d.ts +9 -0
- package/dist/evaluation/scorers/rule/index.js +10 -0
- package/dist/evaluation/scorers/rule/keywordCoverageScorer.d.ts +83 -0
- package/dist/evaluation/scorers/rule/keywordCoverageScorer.js +347 -0
- package/dist/evaluation/scorers/rule/lengthScorer.d.ts +105 -0
- package/dist/evaluation/scorers/rule/lengthScorer.js +351 -0
- package/dist/evaluation/scorers/scorerBuilder.d.ts +161 -0
- package/dist/evaluation/scorers/scorerBuilder.js +420 -0
- package/dist/evaluation/scorers/scorerRegistry.d.ts +62 -0
- package/dist/evaluation/scorers/scorerRegistry.js +467 -0
- package/dist/index.d.ts +37 -25
- package/dist/index.js +65 -26
- package/dist/lib/auth/providers/BaseAuthProvider.d.ts +1 -1
- package/dist/lib/evaluation/BatchEvaluator.d.ts +163 -0
- package/dist/lib/evaluation/BatchEvaluator.js +268 -0
- package/dist/lib/evaluation/EvaluationAggregator.d.ts +272 -0
- package/dist/lib/evaluation/EvaluationAggregator.js +378 -0
- package/dist/lib/evaluation/EvaluatorFactory.d.ts +113 -0
- package/dist/lib/evaluation/EvaluatorFactory.js +281 -0
- package/dist/lib/evaluation/EvaluatorRegistry.d.ts +160 -0
- package/dist/lib/evaluation/EvaluatorRegistry.js +185 -0
- package/dist/lib/evaluation/errors/EvaluationError.d.ts +189 -0
- package/dist/lib/evaluation/errors/EvaluationError.js +207 -0
- package/dist/lib/evaluation/errors/index.d.ts +4 -0
- package/dist/lib/evaluation/errors/index.js +5 -0
- package/dist/lib/evaluation/hooks/index.d.ts +6 -0
- package/dist/lib/evaluation/hooks/index.js +7 -0
- package/dist/lib/evaluation/hooks/langfuseAdapter.d.ts +99 -0
- package/dist/lib/evaluation/hooks/langfuseAdapter.js +173 -0
- package/dist/lib/evaluation/hooks/observabilityHooks.d.ts +129 -0
- package/dist/lib/evaluation/hooks/observabilityHooks.js +182 -0
- package/dist/lib/evaluation/index.d.ts +11 -2
- package/dist/lib/evaluation/index.js +15 -0
- package/dist/lib/evaluation/pipeline/evaluationPipeline.d.ts +114 -0
- package/dist/lib/evaluation/pipeline/evaluationPipeline.js +382 -0
- package/dist/lib/evaluation/pipeline/index.d.ts +8 -0
- package/dist/lib/evaluation/pipeline/index.js +9 -0
- package/dist/lib/evaluation/pipeline/pipelineBuilder.d.ts +126 -0
- package/dist/lib/evaluation/pipeline/pipelineBuilder.js +261 -0
- package/dist/lib/evaluation/pipeline/presets.d.ts +66 -0
- package/dist/lib/evaluation/pipeline/presets.js +225 -0
- package/dist/lib/evaluation/pipeline/strategies/batchStrategy.d.ts +99 -0
- package/dist/lib/evaluation/pipeline/strategies/batchStrategy.js +239 -0
- package/dist/lib/evaluation/pipeline/strategies/index.d.ts +6 -0
- package/dist/lib/evaluation/pipeline/strategies/index.js +7 -0
- package/dist/lib/evaluation/pipeline/strategies/samplingStrategy.d.ts +76 -0
- package/dist/lib/evaluation/pipeline/strategies/samplingStrategy.js +239 -0
- package/dist/lib/evaluation/reporting/index.d.ts +6 -0
- package/dist/lib/evaluation/reporting/index.js +7 -0
- package/dist/lib/evaluation/reporting/metricsCollector.d.ts +147 -0
- package/dist/lib/evaluation/reporting/metricsCollector.js +286 -0
- package/dist/lib/evaluation/reporting/reportGenerator.d.ts +90 -0
- package/dist/lib/evaluation/reporting/reportGenerator.js +375 -0
- package/dist/lib/evaluation/scorers/baseScorer.d.ts +83 -0
- package/dist/lib/evaluation/scorers/baseScorer.js +233 -0
- package/dist/lib/evaluation/scorers/customScorerUtils.d.ts +95 -0
- package/dist/lib/evaluation/scorers/customScorerUtils.js +382 -0
- package/dist/lib/evaluation/scorers/index.d.ts +10 -0
- package/dist/lib/evaluation/scorers/index.js +17 -0
- package/dist/lib/evaluation/scorers/llm/answerRelevancyScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/answerRelevancyScorer.js +100 -0
- package/dist/lib/evaluation/scorers/llm/baseLLMScorer.d.ts +71 -0
- package/dist/lib/evaluation/scorers/llm/baseLLMScorer.js +282 -0
- package/dist/lib/evaluation/scorers/llm/biasDetectionScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/biasDetectionScorer.js +128 -0
- package/dist/lib/evaluation/scorers/llm/contextPrecisionScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/contextPrecisionScorer.js +93 -0
- package/dist/lib/evaluation/scorers/llm/contextRelevancyScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/contextRelevancyScorer.js +108 -0
- package/dist/lib/evaluation/scorers/llm/faithfulnessScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/faithfulnessScorer.js +122 -0
- package/dist/lib/evaluation/scorers/llm/hallucinationScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/hallucinationScorer.js +141 -0
- package/dist/lib/evaluation/scorers/llm/index.d.ts +15 -0
- package/dist/lib/evaluation/scorers/llm/index.js +17 -0
- package/dist/lib/evaluation/scorers/llm/promptAlignmentScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/promptAlignmentScorer.js +107 -0
- package/dist/lib/evaluation/scorers/llm/summarizationScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/summarizationScorer.js +115 -0
- package/dist/lib/evaluation/scorers/llm/toneConsistencyScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/toneConsistencyScorer.js +107 -0
- package/dist/lib/evaluation/scorers/llm/toxicityScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/toxicityScorer.js +122 -0
- package/dist/lib/evaluation/scorers/rule/baseRuleScorer.d.ts +77 -0
- package/dist/lib/evaluation/scorers/rule/baseRuleScorer.js +234 -0
- package/dist/lib/evaluation/scorers/rule/contentSimilarityScorer.d.ts +108 -0
- package/dist/lib/evaluation/scorers/rule/contentSimilarityScorer.js +351 -0
- package/dist/lib/evaluation/scorers/rule/formatScorer.d.ts +147 -0
- package/dist/lib/evaluation/scorers/rule/formatScorer.js +471 -0
- package/dist/lib/evaluation/scorers/rule/index.d.ts +9 -0
- package/dist/lib/evaluation/scorers/rule/index.js +11 -0
- package/dist/lib/evaluation/scorers/rule/keywordCoverageScorer.d.ts +83 -0
- package/dist/lib/evaluation/scorers/rule/keywordCoverageScorer.js +348 -0
- package/dist/lib/evaluation/scorers/rule/lengthScorer.d.ts +105 -0
- package/dist/lib/evaluation/scorers/rule/lengthScorer.js +352 -0
- package/dist/lib/evaluation/scorers/scorerBuilder.d.ts +161 -0
- package/dist/lib/evaluation/scorers/scorerBuilder.js +421 -0
- package/dist/lib/evaluation/scorers/scorerRegistry.d.ts +62 -0
- package/dist/lib/evaluation/scorers/scorerRegistry.js +468 -0
- package/dist/lib/index.d.ts +37 -25
- package/dist/lib/index.js +65 -26
- package/dist/lib/neurolink.d.ts +204 -0
- package/dist/lib/neurolink.js +296 -0
- package/dist/lib/processors/media/VideoProcessor.d.ts +8 -2
- package/dist/lib/processors/media/VideoProcessor.js +90 -41
- package/dist/lib/telemetry/telemetryService.d.ts +1 -1
- package/dist/lib/telemetry/telemetryService.js +27 -13
- package/dist/lib/types/index.d.ts +3 -1
- package/dist/lib/types/index.js +3 -2
- package/dist/lib/types/scorerTypes.d.ts +423 -0
- package/dist/lib/types/scorerTypes.js +6 -0
- package/dist/lib/utils/errorHandling.d.ts +20 -0
- package/dist/lib/utils/errorHandling.js +60 -0
- package/dist/neurolink.d.ts +204 -0
- package/dist/neurolink.js +296 -0
- package/dist/processors/media/VideoProcessor.d.ts +8 -2
- package/dist/processors/media/VideoProcessor.js +90 -41
- package/dist/telemetry/telemetryService.d.ts +1 -1
- package/dist/telemetry/telemetryService.js +27 -13
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.js +3 -2
- package/dist/types/scorerTypes.d.ts +423 -0
- package/dist/types/scorerTypes.js +5 -0
- package/dist/utils/errorHandling.d.ts +20 -0
- package/dist/utils/errorHandling.js +60 -0
- package/package.json +7 -7
- package/dist/processors/media/ffprobe-static.d.ts +0 -4
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
* The extracted content is formatted as text + images that can be sent to any
|
|
11
11
|
* AI provider for analysis.
|
|
12
12
|
*
|
|
13
|
-
* Uses
|
|
14
|
-
*
|
|
13
|
+
* Uses mediabunny (pure TypeScript) for metadata extraction, with fluent-ffmpeg
|
|
14
|
+
* as a fallback for unsupported formats. Requires ffmpeg for keyframe/subtitle
|
|
15
|
+
* extraction (via ffmpeg-static or system PATH).
|
|
15
16
|
*
|
|
16
17
|
* Key features:
|
|
17
18
|
* - Adaptive keyframe extraction intervals based on video duration
|
|
@@ -42,10 +43,10 @@
|
|
|
42
43
|
* }
|
|
43
44
|
* ```
|
|
44
45
|
*/
|
|
45
|
-
/// <reference path="./ffprobe-static.d.ts" />
|
|
46
46
|
import { randomUUID } from "crypto";
|
|
47
47
|
import ffmpegCommand from "fluent-ffmpeg";
|
|
48
48
|
import { createWriteStream, existsSync, promises as fs } from "fs";
|
|
49
|
+
import { Input, FilePathSource, ALL_FORMATS } from "mediabunny";
|
|
49
50
|
import { tmpdir } from "os";
|
|
50
51
|
import { join } from "path";
|
|
51
52
|
import { Readable } from "stream";
|
|
@@ -64,8 +65,12 @@ import { logger } from "../../utils/logger.js";
|
|
|
64
65
|
*/
|
|
65
66
|
let ffmpegPathInitialized = false;
|
|
66
67
|
/**
|
|
67
|
-
* Initialize ffmpeg
|
|
68
|
-
* Tries ffmpeg-static
|
|
68
|
+
* Initialize ffmpeg binary paths.
|
|
69
|
+
* Tries ffmpeg-static first, falls back to system binary in PATH.
|
|
70
|
+
*
|
|
71
|
+
* Note: ffprobe-static has been removed. Metadata probing now uses mediabunny
|
|
72
|
+
* (pure TypeScript) as the primary method, with ffprobe as a fallback only when
|
|
73
|
+
* mediabunny cannot handle the format (e.g., AVI, FLV).
|
|
69
74
|
*
|
|
70
75
|
* This is called lazily on the first processFile() invocation so that the module
|
|
71
76
|
* can be imported without side effects.
|
|
@@ -91,27 +96,6 @@ async function initFfmpegPaths() {
|
|
|
91
96
|
catch {
|
|
92
97
|
// Use system ffmpeg (already in PATH)
|
|
93
98
|
}
|
|
94
|
-
// Try ffprobe-static first, fall back to system ffprobe
|
|
95
|
-
try {
|
|
96
|
-
const ffprobeStatic = (await import("ffprobe-static"));
|
|
97
|
-
// Direct path property (CommonJS default)
|
|
98
|
-
if (typeof ffprobeStatic["path"] === "string" &&
|
|
99
|
-
existsSync(ffprobeStatic["path"])) {
|
|
100
|
-
ffmpegCommand.setFfprobePath(ffprobeStatic["path"]);
|
|
101
|
-
}
|
|
102
|
-
else if (ffprobeStatic["default"] &&
|
|
103
|
-
typeof ffprobeStatic["default"] === "object" &&
|
|
104
|
-
typeof ffprobeStatic["default"]["path"] ===
|
|
105
|
-
"string") {
|
|
106
|
-
const probePath = ffprobeStatic["default"]["path"];
|
|
107
|
-
if (existsSync(probePath)) {
|
|
108
|
-
ffmpegCommand.setFfprobePath(probePath);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
catch {
|
|
113
|
-
// Use system ffprobe (already in PATH)
|
|
114
|
-
}
|
|
115
99
|
}
|
|
116
100
|
// =============================================================================
|
|
117
101
|
// CONSTANTS
|
|
@@ -372,23 +356,33 @@ export class VideoProcessor extends BaseFileProcessor {
|
|
|
372
356
|
const extension = this.getExtensionFromFileInfo(fileInfo);
|
|
373
357
|
const tempVideoPath = join(tempDir, `input${extension}`);
|
|
374
358
|
await this.writeBufferToFile(buffer, tempVideoPath);
|
|
375
|
-
// Step 4: Extract metadata
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
359
|
+
// Step 4: Extract metadata — try mediabunny first (pure TS, no binary),
|
|
360
|
+
// fall back to ffprobe for formats mediabunny doesn't support (AVI, FLV, WMV).
|
|
361
|
+
let metadata;
|
|
362
|
+
const mediabunnyResult = await this.probeVideoWithMediabunny(tempVideoPath);
|
|
363
|
+
if (mediabunnyResult.success && mediabunnyResult.data) {
|
|
364
|
+
metadata = { ...mediabunnyResult.data, fileSize: buffer.length };
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
// Fall back to ffprobe (requires system ffprobe to be available)
|
|
368
|
+
const probeResult = await this.probeVideo(tempVideoPath);
|
|
369
|
+
if (probeResult.success && probeResult.data) {
|
|
370
|
+
metadata = this.buildMetadata(probeResult.data, buffer.length);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
if (!metadata) {
|
|
374
|
+
metadata = {
|
|
375
|
+
duration: 0,
|
|
376
|
+
durationFormatted: "unknown",
|
|
377
|
+
width: 0,
|
|
378
|
+
height: 0,
|
|
379
|
+
codec: "unknown",
|
|
380
|
+
fps: 0,
|
|
381
|
+
bitrate: 0,
|
|
382
|
+
subtitleTracks: 0,
|
|
383
|
+
fileSize: buffer.length,
|
|
388
384
|
};
|
|
389
385
|
}
|
|
390
|
-
const probeData = probeResult.data;
|
|
391
|
-
const metadata = this.buildMetadata(probeData, buffer.length);
|
|
392
386
|
// Record video-specific metadata on span
|
|
393
387
|
span.setAttribute(ATTR.VIDEO_DURATION_SEC, metadata.duration);
|
|
394
388
|
span.setAttribute(ATTR.VIDEO_WIDTH, metadata.width);
|
|
@@ -494,6 +488,61 @@ export class VideoProcessor extends BaseFileProcessor {
|
|
|
494
488
|
});
|
|
495
489
|
});
|
|
496
490
|
}
|
|
491
|
+
/**
|
|
492
|
+
* Probe a video file using mediabunny (pure TypeScript, no native binary).
|
|
493
|
+
* Falls back to ffprobe if mediabunny fails or doesn't support the format.
|
|
494
|
+
*/
|
|
495
|
+
async probeVideoWithMediabunny(filePath) {
|
|
496
|
+
let input;
|
|
497
|
+
try {
|
|
498
|
+
input = new Input({
|
|
499
|
+
source: new FilePathSource(filePath),
|
|
500
|
+
formats: [...ALL_FORMATS],
|
|
501
|
+
});
|
|
502
|
+
const duration = await input.computeDuration();
|
|
503
|
+
const videoTrack = await input.getPrimaryVideoTrack();
|
|
504
|
+
const audioTrack = await input.getPrimaryAudioTrack();
|
|
505
|
+
const allTracks = await input.getTracks();
|
|
506
|
+
const subtitleTracks = allTracks.filter((t) => !t.isVideoTrack() && !t.isAudioTrack());
|
|
507
|
+
// Get FPS from video track packet stats (sample a small number of packets)
|
|
508
|
+
let fps = 0;
|
|
509
|
+
if (videoTrack) {
|
|
510
|
+
try {
|
|
511
|
+
const stats = await videoTrack.computePacketStats(120);
|
|
512
|
+
fps = Math.round(stats.averagePacketRate * 100) / 100;
|
|
513
|
+
}
|
|
514
|
+
catch {
|
|
515
|
+
// FPS unavailable — non-fatal
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
return {
|
|
519
|
+
success: true,
|
|
520
|
+
data: {
|
|
521
|
+
duration: duration ?? 0,
|
|
522
|
+
durationFormatted: this.formatDuration(duration ?? 0),
|
|
523
|
+
width: videoTrack?.displayWidth ?? 0,
|
|
524
|
+
height: videoTrack?.displayHeight ?? 0,
|
|
525
|
+
codec: videoTrack?.codec ?? "unknown",
|
|
526
|
+
fps,
|
|
527
|
+
bitrate: 0,
|
|
528
|
+
audioCodec: audioTrack?.codec ?? undefined,
|
|
529
|
+
audioChannels: audioTrack?.numberOfChannels,
|
|
530
|
+
audioSampleRate: audioTrack?.sampleRate,
|
|
531
|
+
subtitleTracks: subtitleTracks.length,
|
|
532
|
+
fileSize: 0,
|
|
533
|
+
},
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
catch (error) {
|
|
537
|
+
return {
|
|
538
|
+
success: false,
|
|
539
|
+
error: `mediabunny failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
finally {
|
|
543
|
+
input?.dispose();
|
|
544
|
+
}
|
|
545
|
+
}
|
|
497
546
|
/**
|
|
498
547
|
* Build a structured metadata object from ffprobe data.
|
|
499
548
|
*
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { context, metrics, trace, } from "@opentelemetry/api";
|
|
2
|
+
import { BasicTracerProvider, BatchSpanProcessor, } from "@opentelemetry/sdk-trace-base";
|
|
3
|
+
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
4
4
|
import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
5
5
|
import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION, } from "@opentelemetry/semantic-conventions";
|
|
6
6
|
import { logger } from "../utils/logger.js";
|
|
7
7
|
export class TelemetryService {
|
|
8
8
|
static instance;
|
|
9
|
-
|
|
9
|
+
tracerProvider;
|
|
10
10
|
enabled = false;
|
|
11
11
|
initialized = false;
|
|
12
12
|
meter;
|
|
@@ -52,11 +52,16 @@ export class TelemetryService {
|
|
|
52
52
|
[ATTR_SERVICE_NAME]: process.env.OTEL_SERVICE_NAME || "neurolink-ai",
|
|
53
53
|
[ATTR_SERVICE_VERSION]: process.env.OTEL_SERVICE_VERSION || "3.0.1",
|
|
54
54
|
});
|
|
55
|
-
|
|
55
|
+
const exporter = new OTLPTraceExporter({
|
|
56
|
+
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT
|
|
57
|
+
? `${process.env.OTEL_EXPORTER_OTLP_ENDPOINT}/v1/traces`
|
|
58
|
+
: undefined,
|
|
59
|
+
});
|
|
60
|
+
this.tracerProvider = new BasicTracerProvider({
|
|
56
61
|
resource,
|
|
57
|
-
|
|
58
|
-
instrumentations: [getNodeAutoInstrumentations()],
|
|
62
|
+
spanProcessors: [new BatchSpanProcessor(exporter)],
|
|
59
63
|
});
|
|
64
|
+
trace.setGlobalTracerProvider(this.tracerProvider);
|
|
60
65
|
this.meter = metrics.getMeter("neurolink-ai");
|
|
61
66
|
this.tracer = trace.getTracer("neurolink-ai");
|
|
62
67
|
this.initializeMetrics();
|
|
@@ -101,12 +106,21 @@ export class TelemetryService {
|
|
|
101
106
|
return;
|
|
102
107
|
}
|
|
103
108
|
try {
|
|
104
|
-
|
|
109
|
+
// Register AsyncLocalStorage context manager for proper parent-child
|
|
110
|
+
// span relationships across async boundaries (required for startActiveSpan)
|
|
111
|
+
try {
|
|
112
|
+
const { AsyncLocalStorageContextManager } = await import("@opentelemetry/context-async-hooks");
|
|
113
|
+
context.setGlobalContextManager(new AsyncLocalStorageContextManager().enable());
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
// context-async-hooks not installed — context propagation
|
|
117
|
+
// will use the default (noop) manager
|
|
118
|
+
}
|
|
105
119
|
this.initialized = true;
|
|
106
|
-
logger.debug("[Telemetry]
|
|
120
|
+
logger.debug("[Telemetry] Tracer provider started successfully");
|
|
107
121
|
}
|
|
108
122
|
catch (error) {
|
|
109
|
-
logger.error("[Telemetry] Failed to start
|
|
123
|
+
logger.error("[Telemetry] Failed to start:", error);
|
|
110
124
|
this.enabled = false;
|
|
111
125
|
this.initialized = false;
|
|
112
126
|
}
|
|
@@ -294,11 +308,11 @@ export class TelemetryService {
|
|
|
294
308
|
}
|
|
295
309
|
// Cleanup
|
|
296
310
|
async shutdown() {
|
|
297
|
-
if (this.enabled && this.
|
|
311
|
+
if (this.enabled && this.tracerProvider) {
|
|
298
312
|
try {
|
|
299
|
-
await this.
|
|
313
|
+
await this.tracerProvider.shutdown();
|
|
300
314
|
this.initialized = false;
|
|
301
|
-
logger.debug("[Telemetry]
|
|
315
|
+
logger.debug("[Telemetry] Tracer provider shutdown completed");
|
|
302
316
|
}
|
|
303
317
|
catch (error) {
|
|
304
318
|
logger.error("[Telemetry] Error during shutdown:", error);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -27,13 +27,15 @@ TextGenerationOptions, TextGenerationResult, UnifiedGenerationOptions, } from ".
|
|
|
27
27
|
export * from "./hitlTypes.js";
|
|
28
28
|
export * from "./middlewareTypes.js";
|
|
29
29
|
export * from "./modelTypes.js";
|
|
30
|
+
export * from "./scorerTypes.js";
|
|
30
31
|
export * from "./sdkTypes.js";
|
|
31
32
|
export * from "./serviceTypes.js";
|
|
32
33
|
export type { EnhancedStreamProvider, ProgressCallback, StreamingMetadata, StreamingOptions, StreamingProgressData, StreamOptions, StreamResult, ToolCall as StreamToolCall, // Renamed to avoid conflict with tools.js ToolCall
|
|
33
34
|
ToolCallResults, ToolCalls, ToolResult as StreamToolResult, } from "./streamTypes.js";
|
|
34
35
|
export * from "./ttsTypes.js";
|
|
35
36
|
export * from "./utilities.js";
|
|
36
|
-
export
|
|
37
|
+
export type { AggregatedUsage, ConditioningConfig, ConditionOptions, ConditionResult, EnsembleExecutionResult, EnsembleResponse, ExecuteEnsembleOptions, ExecuteLayerOptions, ExecuteModelOptions, ExecutionConfig, ExecutionStrategy, JudgeConfig, JudgeOutputFormat, JudgeScores, LayerExecutionResult, ListOptions, ModelGroup, MultiJudgeScores, ParsedJudgeResponse, RegisterOptions, RegisterResult, RegistryEntry, RegistryStats, ScoreOptions, ScoreResult as WorkflowScoreResult, SummaryStats, ToneAdjustment, ValidationIssues, WorkflowAnalytics, WorkflowComparison, WorkflowConfig, WorkflowErrorDetails, WorkflowEvaluationData, WorkflowExecutionMetrics, WorkflowGenerateOptions, WorkflowInput, WorkflowMetadata, WorkflowModelConfig, WorkflowResult, WorkflowType, WorkflowValidationError, WorkflowValidationResult, WorkflowValidationWarning, } from "./workflowTypes.js";
|
|
38
|
+
export { WorkflowError } from "./workflowTypes.js";
|
|
37
39
|
export * from "./contextTypes.js";
|
|
38
40
|
export * from "./fileReferenceTypes.js";
|
|
39
41
|
export * from "./ragTypes.js";
|
package/dist/types/index.js
CHANGED
|
@@ -28,6 +28,8 @@ export * from "./hitlTypes.js";
|
|
|
28
28
|
export * from "./middlewareTypes.js";
|
|
29
29
|
// Model types - NEW
|
|
30
30
|
export * from "./modelTypes.js";
|
|
31
|
+
// Scorer types for evaluation system
|
|
32
|
+
export * from "./scorerTypes.js";
|
|
31
33
|
// SDK Types - Core types for external developers
|
|
32
34
|
// Note: sdkTypes.ts uses selective re-exports internally, so we use wildcard here
|
|
33
35
|
// The conflicts were from generateTypes and analytics which are now handled above
|
|
@@ -38,8 +40,7 @@ export * from "./serviceTypes.js";
|
|
|
38
40
|
export * from "./ttsTypes.js";
|
|
39
41
|
// Utilities Types - Utility module types (selective export to avoid conflicts)
|
|
40
42
|
export * from "./utilities.js";
|
|
41
|
-
|
|
42
|
-
export * from "./workflowTypes.js";
|
|
43
|
+
export { WorkflowError } from "./workflowTypes.js";
|
|
43
44
|
// Context compaction types
|
|
44
45
|
export * from "./contextTypes.js";
|
|
45
46
|
// File reference types
|