video-context-mcp-server 1.1.5 → 1.2.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.
Files changed (39) hide show
  1. package/README.md +40 -27
  2. package/dist/generated/version.d.ts +1 -1
  3. package/dist/generated/version.js +1 -1
  4. package/dist/index.js +12 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/services/ffmpeg.d.ts +37 -0
  7. package/dist/services/ffmpeg.d.ts.map +1 -1
  8. package/dist/services/ffmpeg.js +175 -0
  9. package/dist/services/ffmpeg.js.map +1 -1
  10. package/dist/services/providerRouter.d.ts +9 -0
  11. package/dist/services/providerRouter.d.ts.map +1 -1
  12. package/dist/services/providerRouter.js +14 -0
  13. package/dist/services/providerRouter.js.map +1 -1
  14. package/dist/services/redactionDetector.d.ts +187 -0
  15. package/dist/services/redactionDetector.d.ts.map +1 -0
  16. package/dist/services/redactionDetector.js +766 -0
  17. package/dist/services/redactionDetector.js.map +1 -0
  18. package/dist/tools/analyzeVideo.d.ts.map +1 -1
  19. package/dist/tools/analyzeVideo.js +4 -3
  20. package/dist/tools/analyzeVideo.js.map +1 -1
  21. package/dist/tools/redactSensitive.d.ts +11 -0
  22. package/dist/tools/redactSensitive.d.ts.map +1 -0
  23. package/dist/tools/redactSensitive.js +466 -0
  24. package/dist/tools/redactSensitive.js.map +1 -0
  25. package/dist/tools/schemas.d.ts +53 -0
  26. package/dist/tools/schemas.d.ts.map +1 -1
  27. package/dist/tools/schemas.js +87 -0
  28. package/dist/tools/schemas.js.map +1 -1
  29. package/dist/tools/summarizeVideo.d.ts +17 -0
  30. package/dist/tools/summarizeVideo.d.ts.map +1 -1
  31. package/dist/tools/summarizeVideo.js +36 -2
  32. package/dist/tools/summarizeVideo.js.map +1 -1
  33. package/dist/types/redaction.d.ts +32 -0
  34. package/dist/types/redaction.d.ts.map +1 -0
  35. package/dist/types/redaction.js +5 -0
  36. package/dist/types/redaction.js.map +1 -0
  37. package/dist/utils/license.js +1 -1
  38. package/dist/utils/license.js.map +1 -1
  39. package/package.json +1 -1
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Redaction Detector
3
+ * AI-assisted sensitive region detection in video frames.
4
+ * Samples frames, sends to a vision provider, and parses JSON detections.
5
+ */
6
+ import { z } from 'zod';
7
+ import type { RedactionRegion } from '../types/redaction.js';
8
+ /** Full detection response from the AI provider. */
9
+ export declare const detectionResponseSchema: z.ZodObject<{
10
+ frames: z.ZodArray<z.ZodObject<{
11
+ frameIndex: z.ZodNumber;
12
+ timestampSec: z.ZodNumber;
13
+ detections: z.ZodArray<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
14
+ label: z.ZodString;
15
+ confidence: z.ZodNumber;
16
+ box: z.ZodOptional<z.ZodObject<{
17
+ left: z.ZodNumber;
18
+ top: z.ZodNumber;
19
+ width: z.ZodNumber;
20
+ height: z.ZodNumber;
21
+ }, z.core.$strip>>;
22
+ reason: z.ZodOptional<z.ZodString>;
23
+ }, z.core.$strip>>>;
24
+ }, z.core.$strip>>;
25
+ }, z.core.$strip>;
26
+ export type DetectionResponse = z.infer<typeof detectionResponseSchema>;
27
+ export interface FrameDetection {
28
+ label: string;
29
+ confidence: number;
30
+ box: {
31
+ left: number;
32
+ top: number;
33
+ width: number;
34
+ height: number;
35
+ };
36
+ reason?: string;
37
+ }
38
+ /**
39
+ * Supported detection categories inferred from a user's natural-language intent.
40
+ * Using an allowlist prevents prompt-injection: raw user text is NEVER
41
+ * interpolated into the AI prompt.
42
+ */
43
+ export type DetectionCategory = 'credentials' | 'pii' | 'infrastructure' | 'financial' | 'general';
44
+ /**
45
+ * Classify a free-text intent string into one of the allowed detection
46
+ * categories. Returns 'general' when no specific category is recognised.
47
+ * Raw user text is never forwarded to the AI prompt.
48
+ */
49
+ export declare function classifyIntent(intent: string): DetectionCategory;
50
+ /** Return the sampling/confidence defaults for a given intent category. */
51
+ export declare function getDetectionDefaults(category: DetectionCategory): {
52
+ sampleIntervalSeconds: number;
53
+ maxFrames: number;
54
+ minConfidence: number;
55
+ };
56
+ export interface SamplingOptions {
57
+ /** Interval between sampled frames in seconds. Default: 5. */
58
+ sampleIntervalSeconds?: number;
59
+ /** Maximum number of frames to sample. Default: 20. */
60
+ maxFrames?: number;
61
+ /** Video duration in seconds. */
62
+ duration: number;
63
+ }
64
+ export declare function computeSampleTimestamps(options: SamplingOptions): number[];
65
+ /**
66
+ * Options for running AI-assisted detection.
67
+ */
68
+ export interface DetectionOptions {
69
+ /** Path to the video file. */
70
+ videoPath: string;
71
+ /** Video metadata. */
72
+ duration: number;
73
+ width: number;
74
+ height: number;
75
+ /** Sampling configuration. */
76
+ sampling?: SamplingOptions;
77
+ /** Minimum confidence threshold (0–1). Detections below this are dropped. Default: 0.5. */
78
+ minConfidence?: number;
79
+ /** Extra padding in pixels to expand each detected region. Default: 10. */
80
+ paddingPixels?: number;
81
+ /** Custom instructions to append to the detection prompt. */
82
+ customInstructions?: string;
83
+ /** Intent category inferred from the user's natural-language request. When set,
84
+ * the detection system prompt and sampling defaults are tuned for that category. */
85
+ intentCategory?: DetectionCategory;
86
+ /** AI provider client to use for detection. */
87
+ provider: DetectionProvider;
88
+ }
89
+ /**
90
+ * Provider-agnostic interface for vision-based detection.
91
+ * Each AI client expects images as { data: string; mimeType: string }[].
92
+ */
93
+ export interface DetectionProvider {
94
+ analyzeImages(images: Array<{
95
+ data: string;
96
+ mimeType: string;
97
+ }>, prompt: string): Promise<string>;
98
+ }
99
+ /**
100
+ * Detection statistics returned alongside detected regions.
101
+ */
102
+ export interface DetectionResult {
103
+ /** Confidence-filtered pixel-coordinate regions (before consolidation). */
104
+ regions: RedactionRegion[];
105
+ /** Number of frames that were sampled and sent to the AI provider. */
106
+ sampledFrames: number;
107
+ /** Total number of raw detections returned by the provider (before confidence filtering). */
108
+ rawDetectionsCount: number;
109
+ }
110
+ /**
111
+ * Run AI-assisted detection on a video.
112
+ *
113
+ * 1. Extract evenly-spaced frames
114
+ * 2. Convert frames to base64
115
+ * 3. Send to the AI provider for analysis
116
+ * 4. Parse and validate the JSON response
117
+ * 5. Convert normalized coordinates to pixel coordinates
118
+ * 6. Filter by confidence threshold
119
+ * 7. Apply padding expansion
120
+ *
121
+ * @returns Detection result with regions, frame count, and raw detection count
122
+ */
123
+ export declare function detectSensitiveRegions(options: DetectionOptions): Promise<DetectionResult>;
124
+ export declare function parseDetectionResponse(responseText: string, videoWidth?: number, videoHeight?: number): DetectionResponse;
125
+ export declare function convertDetectionsToRegions(response: DetectionResponse, videoWidth: number, videoHeight: number, timestamps: number[], minConfidence: number, paddingPixels: number): RedactionRegion[];
126
+ /**
127
+ * Merge overlapping detections across frames into consolidated regions.
128
+ * Uses simple label + proximity matching (no full IOU in v1).
129
+ */
130
+ export declare function mergeDetections(regions: RedactionRegion[], proximityThreshold?: number): RedactionRegion[];
131
+ /**
132
+ * Internal track representing a persistent detection across time.
133
+ */
134
+ interface DetectionTrack {
135
+ label: string;
136
+ x: number;
137
+ y: number;
138
+ width: number;
139
+ height: number;
140
+ startTime: number;
141
+ endTime: number;
142
+ confidence: number;
143
+ frameCount: number;
144
+ }
145
+ /**
146
+ * Group detections into temporal tracks across adjacent sampled frames.
147
+ *
148
+ * Uses IOU overlap and label similarity to merge boxes that represent the
149
+ * same persistent secret across time. Treats persistent detections in
150
+ * roughly the same area as one track.
151
+ *
152
+ * @param regions - Flat list of per-frame detections (already converted to pixels)
153
+ * @param iouThreshold - Minimum IOU to consider two boxes the same track (default: 0.3)
154
+ * @param sampleInterval - Seconds between sampled frames (used for gap-filling)
155
+ * @returns Consolidated tracks with stable time ranges
156
+ */
157
+ export declare function groupDetectionsIntoTracks(regions: RedactionRegion[], iouThreshold?: number, sampleInterval?: number): DetectionTrack[];
158
+ /**
159
+ * Convert temporal tracks into a final `RedactionPlan` with time ranges.
160
+ *
161
+ * - Start time: detection timestamp minus half the sample interval
162
+ * - End time: last detection timestamp plus half the sample interval
163
+ * - Clamp to video duration
164
+ * - Merge short gaps between nearby detections
165
+ * - Expand boxes slightly to absorb tiny camera/UI shifts
166
+ *
167
+ * @param tracks - Grouped detection tracks
168
+ * @param videoDuration - Total video duration in seconds
169
+ * @param sampleInterval - Seconds between sampled frames
170
+ * @param paddingPixels - Extra padding to expand each region
171
+ * @param videoWidth - Video width for clamping
172
+ * @param videoHeight - Video height for clamping
173
+ * @returns Final consolidated redaction regions
174
+ */
175
+ export declare function tracksToRedactionPlan(tracks: DetectionTrack[], videoDuration: number, sampleInterval: number, paddingPixels: number, videoWidth: number, videoHeight: number): RedactionRegion[];
176
+ /**
177
+ * Full consolidation pipeline: raw detections → stable redaction regions.
178
+ *
179
+ * 1. Group detections into temporal tracks (IOU + label matching)
180
+ * 2. Convert tracks to time-bounded regions
181
+ * 3. Expand boxes and clamp to video bounds
182
+ *
183
+ * This replaces the simpler `mergeDetections()` for AI-mode detection.
184
+ */
185
+ export declare function consolidateDetections(regions: RedactionRegion[], videoDuration: number, sampleInterval: number, paddingPixels: number, videoWidth: number, videoHeight: number, iouThreshold?: number): RedactionRegion[];
186
+ export {};
187
+ //# sourceMappingURL=redactionDetector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redactionDetector.d.ts","sourceRoot":"","sources":["../../src/services/redactionDetector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAmJ5D,oDAAoD;AACpD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;iBAElC,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AACvE,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,C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