@bedolla/enrivision 0.1.5 → 0.1.7
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/README.md +43 -9
- package/dist/client/EnriProxyClient.d.ts +296 -248
- package/dist/client/EnriProxyClient.d.ts.map +1 -1
- package/dist/client/EnriProxyClient.js +849 -119
- package/dist/client/EnriProxyClient.js.map +1 -1
- package/dist/client/EnriProxyClientContract.d.ts +478 -0
- package/dist/client/EnriProxyClientContract.d.ts.map +1 -0
- package/dist/client/EnriProxyClientContract.js +136 -0
- package/dist/client/EnriProxyClientContract.js.map +1 -0
- package/dist/index.js +23 -12
- package/dist/index.js.map +1 -1
- package/dist/package-info.d.ts +28 -0
- package/dist/package-info.d.ts.map +1 -1
- package/dist/package-info.js +28 -0
- package/dist/package-info.js.map +1 -1
- package/dist/server/EnriVisionServer.d.ts +186 -0
- package/dist/server/EnriVisionServer.d.ts.map +1 -1
- package/dist/server/EnriVisionServer.js +804 -94
- package/dist/server/EnriVisionServer.js.map +1 -1
- package/dist/shared/codepointTruncation.d.ts +61 -0
- package/dist/shared/codepointTruncation.d.ts.map +1 -0
- package/dist/shared/codepointTruncation.js +73 -0
- package/dist/shared/codepointTruncation.js.map +1 -0
- package/dist/shared/mediaUrlFetcher.d.ts +247 -9
- package/dist/shared/mediaUrlFetcher.d.ts.map +1 -1
- package/dist/shared/mediaUrlFetcher.js +712 -53
- package/dist/shared/mediaUrlFetcher.js.map +1 -1
- package/dist/shared/tar.d.ts +82 -2
- package/dist/shared/tar.d.ts.map +1 -1
- package/dist/shared/tar.js +106 -43
- package/dist/shared/tar.js.map +1 -1
- package/dist/shared/validation.d.ts +96 -2
- package/dist/shared/validation.d.ts.map +1 -1
- package/dist/shared/validation.js +169 -10
- package/dist/shared/validation.js.map +1 -1
- package/dist/tools/AnalyzeMediaContract.d.ts +462 -0
- package/dist/tools/AnalyzeMediaContract.d.ts.map +1 -0
- package/dist/tools/AnalyzeMediaContract.js +161 -0
- package/dist/tools/AnalyzeMediaContract.js.map +1 -0
- package/dist/tools/AnalyzeMediaExtractionSanitizer.d.ts +35 -0
- package/dist/tools/AnalyzeMediaExtractionSanitizer.d.ts.map +1 -0
- package/dist/tools/AnalyzeMediaExtractionSanitizer.js +214 -0
- package/dist/tools/AnalyzeMediaExtractionSanitizer.js.map +1 -0
- package/dist/tools/AnalyzeMediaInputResolver.d.ts +250 -0
- package/dist/tools/AnalyzeMediaInputResolver.d.ts.map +1 -0
- package/dist/tools/AnalyzeMediaInputResolver.js +430 -0
- package/dist/tools/AnalyzeMediaInputResolver.js.map +1 -0
- package/dist/tools/AnalyzeMediaParamParser.d.ts +307 -0
- package/dist/tools/AnalyzeMediaParamParser.d.ts.map +1 -0
- package/dist/tools/AnalyzeMediaParamParser.js +843 -0
- package/dist/tools/AnalyzeMediaParamParser.js.map +1 -0
- package/dist/tools/AnalyzeMediaResumableUploader.d.ts +244 -0
- package/dist/tools/AnalyzeMediaResumableUploader.d.ts.map +1 -0
- package/dist/tools/AnalyzeMediaResumableUploader.js +549 -0
- package/dist/tools/AnalyzeMediaResumableUploader.js.map +1 -0
- package/dist/tools/AnalyzeMediaTarPackager.d.ts +42 -0
- package/dist/tools/AnalyzeMediaTarPackager.d.ts.map +1 -0
- package/dist/tools/AnalyzeMediaTarPackager.js +245 -0
- package/dist/tools/AnalyzeMediaTarPackager.js.map +1 -0
- package/dist/tools/AnalyzeMediaTool.d.ts +156 -294
- package/dist/tools/AnalyzeMediaTool.d.ts.map +1 -1
- package/dist/tools/AnalyzeMediaTool.js +611 -457
- package/dist/tools/AnalyzeMediaTool.js.map +1 -1
- package/package.json +2 -1
|
@@ -1,370 +1,232 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ANALYZE MEDIA TOOL
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* - Validates local file paths or http(s) URLs
|
|
6
|
-
* - Materializes URL inputs via bounded downloads (
|
|
7
|
-
* -
|
|
8
|
-
*
|
|
4
|
+
* Facade for the `analyze_media` MCP tool:
|
|
5
|
+
* - Validates local file paths or http(s) URLs (param parser)
|
|
6
|
+
* - Materializes URL inputs via bounded downloads (input resolver)
|
|
7
|
+
* - Uploads single files or multi-image tar sets through resumable
|
|
8
|
+
* EnriProxy sessions (uploader + tar packager)
|
|
9
|
+
* - Triggers server-side analysis and returns sanitized text-only results
|
|
9
10
|
*
|
|
10
11
|
* @module tools/AnalyzeMediaTool
|
|
11
12
|
*/
|
|
12
|
-
import { type EnriProxyClient } from "../client/EnriProxyClient.js";
|
|
13
13
|
import { MediaUrlFetcher } from "../shared/mediaUrlFetcher.js";
|
|
14
|
+
import type { AnalyzeMediaElementBox, AnalyzeMediaExecutionOptions, AnalyzeMediaToolDeps, AnalyzeMediaToolParams, AnalyzeMediaToolResult, ImageRegion } from "./AnalyzeMediaContract.js";
|
|
15
|
+
export type { AnalyzeMediaElementBox, AnalyzeMediaExecutionOptions, AnalyzeMediaToolDeps, AnalyzeMediaToolParams, AnalyzeMediaToolResult, ImageRegion, };
|
|
14
16
|
/**
|
|
15
|
-
*
|
|
17
|
+
* MCP tool that uploads and analyzes local or http(s) URL media.
|
|
16
18
|
*/
|
|
17
|
-
export
|
|
18
|
-
/**
|
|
19
|
-
* Absolute local filesystem path on the MCP host, or one http(s) URL to
|
|
20
|
-
* download (bounded, temporary) and analyze.
|
|
21
|
-
*
|
|
22
|
-
* @remarks
|
|
23
|
-
* Use `paths` to analyze multiple images in a single call.
|
|
24
|
-
*/
|
|
25
|
-
readonly path?: string;
|
|
26
|
-
/**
|
|
27
|
-
* Absolute local filesystem paths or http(s) URLs on the MCP host.
|
|
28
|
-
*
|
|
29
|
-
* @remarks
|
|
30
|
-
* When provided, EnriVision uploads the files as a single media-set archive
|
|
31
|
-
* (resumable, up to 4GB) and triggers server-side batching + reduce.
|
|
32
|
-
*
|
|
33
|
-
* This is intended for many UI screenshots / photo sets.
|
|
34
|
-
*/
|
|
35
|
-
readonly paths?: ReadonlyArray<string>;
|
|
36
|
-
/**
|
|
37
|
-
* Optional analysis hint (ui, diagram, chart, error, code, meeting, tutorial, photo).
|
|
38
|
-
*/
|
|
39
|
-
readonly context?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Optional explicit user question.
|
|
42
|
-
*/
|
|
43
|
-
readonly question?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Preferred response language code (e.g., "es", "en").
|
|
46
|
-
*/
|
|
47
|
-
readonly language?: string;
|
|
48
|
-
/**
|
|
49
|
-
* Optional max frames override for videos (1-20).
|
|
50
|
-
*/
|
|
51
|
-
readonly maxFrames?: number;
|
|
52
|
-
/**
|
|
53
|
-
* Optional override for transcription on videos.
|
|
54
|
-
*/
|
|
55
|
-
readonly transcribe?: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Optional transcription language hint for Whisper.
|
|
58
|
-
*/
|
|
59
|
-
readonly transcriptionLanguage?: string;
|
|
60
|
-
/**
|
|
61
|
-
* Optional analysis mode selector (auto|single|multipass).
|
|
62
|
-
*/
|
|
63
|
-
readonly analysisMode?: "auto" | "single" | "multipass";
|
|
64
|
-
/**
|
|
65
|
-
* Optional video multipass tuning.
|
|
66
|
-
*/
|
|
67
|
-
readonly video?: {
|
|
68
|
-
/**
|
|
69
|
-
* Optional clip start offset in seconds for targeted video analysis.
|
|
70
|
-
*
|
|
71
|
-
* @remarks
|
|
72
|
-
* Use this when the question references a specific timestamp to avoid
|
|
73
|
-
* scanning the full timeline.
|
|
74
|
-
*/
|
|
75
|
-
readonly clipStartSeconds?: number;
|
|
76
|
-
/**
|
|
77
|
-
* Optional clip duration in seconds for targeted video analysis.
|
|
78
|
-
*
|
|
79
|
-
* @remarks
|
|
80
|
-
* Use together with {@link clipStartSeconds} to analyze only a time window.
|
|
81
|
-
*/
|
|
82
|
-
readonly clipDurationSeconds?: number;
|
|
83
|
-
/**
|
|
84
|
-
* Segment duration in seconds.
|
|
85
|
-
*/
|
|
86
|
-
readonly segmentSeconds?: number;
|
|
87
|
-
/**
|
|
88
|
-
* Maximum number of segments to analyze.
|
|
89
|
-
*/
|
|
90
|
-
readonly maxSegments?: number;
|
|
91
|
-
/**
|
|
92
|
-
* Maximum frames per segment.
|
|
93
|
-
*/
|
|
94
|
-
readonly maxFramesPerSegment?: number;
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Optional document multipass tuning (PDF).
|
|
98
|
-
*/
|
|
99
|
-
readonly document?: {
|
|
100
|
-
/**
|
|
101
|
-
* Maximum pages to analyze in total.
|
|
102
|
-
*/
|
|
103
|
-
readonly maxPagesTotal?: number;
|
|
104
|
-
/**
|
|
105
|
-
* Pages per batch.
|
|
106
|
-
*/
|
|
107
|
-
readonly pagesPerBatch?: number;
|
|
108
|
-
/**
|
|
109
|
-
* Maximum rendered pages per batch.
|
|
110
|
-
*/
|
|
111
|
-
readonly maxImagesPerBatch?: number;
|
|
112
|
-
/**
|
|
113
|
-
* Minimum extracted text length to treat a page as textual.
|
|
114
|
-
*/
|
|
115
|
-
readonly scannedTextThresholdChars?: number;
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* Optional audio multipass tuning.
|
|
119
|
-
*/
|
|
120
|
-
readonly audio?: {
|
|
121
|
-
/**
|
|
122
|
-
* Whether to include timestamped segments in audio extraction.
|
|
123
|
-
*/
|
|
124
|
-
readonly timestamps?: boolean;
|
|
125
|
-
/**
|
|
126
|
-
* Segment duration in seconds for audio multipass.
|
|
127
|
-
*/
|
|
128
|
-
readonly segmentSeconds?: number;
|
|
129
|
-
/**
|
|
130
|
-
* Maximum number of audio segments to analyze.
|
|
131
|
-
*/
|
|
132
|
-
readonly maxSegments?: number;
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* Optional image-set multipass tuning.
|
|
136
|
-
*
|
|
137
|
-
* @remarks
|
|
138
|
-
* Used only when analyzing multiple images via `paths`.
|
|
139
|
-
*/
|
|
140
|
-
readonly images?: {
|
|
141
|
-
/**
|
|
142
|
-
* Maximum number of images to analyze in total.
|
|
143
|
-
*/
|
|
144
|
-
readonly maxImagesTotal?: number;
|
|
145
|
-
/**
|
|
146
|
-
* Images per batch for multipass map calls.
|
|
147
|
-
*/
|
|
148
|
-
readonly imagesPerBatch?: number;
|
|
149
|
-
/**
|
|
150
|
-
* Maximum dimension for images (width/height).
|
|
151
|
-
*/
|
|
152
|
-
readonly maxDimension?: number;
|
|
153
|
-
};
|
|
19
|
+
export declare class AnalyzeMediaTool {
|
|
154
20
|
/**
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
* @remarks
|
|
158
|
-
* Normalized [0,1] coordinates over the original image (0,0 = top-left
|
|
159
|
-
* corner). Use the boxes returned in `elements` of a previous analysis of
|
|
160
|
-
* the same image; never invent coordinates.
|
|
21
|
+
* Tool dependencies.
|
|
161
22
|
*/
|
|
162
|
-
readonly
|
|
163
|
-
readonly x: number;
|
|
164
|
-
readonly y: number;
|
|
165
|
-
readonly width: number;
|
|
166
|
-
readonly height: number;
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* One grounded element box returned by an image analysis.
|
|
171
|
-
*/
|
|
172
|
-
export interface AnalyzeMediaElementBox {
|
|
23
|
+
private readonly deps;
|
|
173
24
|
/**
|
|
174
|
-
*
|
|
25
|
+
* Raw argument validator.
|
|
175
26
|
*/
|
|
176
|
-
readonly
|
|
27
|
+
private readonly paramParser;
|
|
177
28
|
/**
|
|
178
|
-
*
|
|
29
|
+
* Local/URL input materializer.
|
|
179
30
|
*/
|
|
180
|
-
readonly
|
|
181
|
-
readonly x: number;
|
|
182
|
-
readonly y: number;
|
|
183
|
-
readonly width: number;
|
|
184
|
-
readonly height: number;
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Structured result for `analyze_media`.
|
|
189
|
-
*/
|
|
190
|
-
export interface AnalyzeMediaToolResult extends Record<string, unknown> {
|
|
31
|
+
private readonly inputResolver;
|
|
191
32
|
/**
|
|
192
|
-
*
|
|
33
|
+
* Resumable chunk uploader.
|
|
193
34
|
*/
|
|
194
|
-
readonly
|
|
35
|
+
private readonly uploader;
|
|
195
36
|
/**
|
|
196
|
-
*
|
|
37
|
+
* Multi-image tar set packager.
|
|
197
38
|
*/
|
|
198
|
-
readonly
|
|
39
|
+
private readonly tarPackager;
|
|
199
40
|
/**
|
|
200
|
-
*
|
|
41
|
+
* Extraction output sanitizer.
|
|
201
42
|
*/
|
|
202
|
-
readonly
|
|
43
|
+
private readonly sanitizer;
|
|
203
44
|
/**
|
|
204
|
-
*
|
|
45
|
+
* Cached vision-capability verdicts keyed by endpoint + model.
|
|
205
46
|
*
|
|
206
47
|
* @remarks
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
48
|
+
* `execute` builds a fresh client per call, so instance-keyed caching
|
|
49
|
+
* would never hit: the key is `serverUrl + model` (one account per
|
|
50
|
+
* endpoint). Entries live for `ANALYZE_MEDIA_LIMITS.visionProbeCacheTtlMs`
|
|
51
|
+
* (mirrors EnriCode `PROBE_CACHE_TTL_MS` and its per-client scoping).
|
|
210
52
|
*/
|
|
211
|
-
readonly
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Dependencies for {@link AnalyzeMediaTool}.
|
|
215
|
-
*/
|
|
216
|
-
export interface AnalyzeMediaToolDeps {
|
|
217
|
-
/**
|
|
218
|
-
* Creates an EnriProxy client with a base URL, API key, and timeout.
|
|
219
|
-
*
|
|
220
|
-
* @param serverUrl - EnriProxy URL
|
|
221
|
-
* @param apiKey - EnriProxy API key
|
|
222
|
-
* @param timeoutMs - Timeout in ms
|
|
223
|
-
* @returns Client instance
|
|
224
|
-
*/
|
|
225
|
-
readonly createClient: (serverUrl: string, apiKey: string, timeoutMs: number) => EnriProxyClient;
|
|
226
|
-
/**
|
|
227
|
-
* Default EnriProxy server URL.
|
|
228
|
-
*/
|
|
229
|
-
readonly defaultServerUrl: string;
|
|
230
|
-
/**
|
|
231
|
-
* Default EnriProxy API key.
|
|
232
|
-
*/
|
|
233
|
-
readonly defaultApiKey: string;
|
|
234
|
-
/**
|
|
235
|
-
* Default timeout in milliseconds.
|
|
236
|
-
*/
|
|
237
|
-
readonly defaultTimeoutMs: number;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* MCP tool that uploads and analyzes local or http(s) URL media.
|
|
241
|
-
*/
|
|
242
|
-
export declare class AnalyzeMediaTool {
|
|
243
|
-
/**
|
|
244
|
-
* Tool dependencies.
|
|
245
|
-
*/
|
|
246
|
-
private readonly deps;
|
|
247
|
-
/**
|
|
248
|
-
* Bounded http(s) media fetcher used when `path`/`paths` carry URLs.
|
|
249
|
-
*/
|
|
250
|
-
private readonly urlFetcher;
|
|
53
|
+
private readonly visionProbeCache;
|
|
251
54
|
/**
|
|
252
55
|
* Creates a new {@link AnalyzeMediaTool}.
|
|
253
56
|
*
|
|
254
|
-
* @param deps - Tool dependencies
|
|
255
|
-
* @param urlFetcher - Optional URL fetcher override for tests
|
|
57
|
+
* @param deps - Tool dependencies.
|
|
58
|
+
* @param urlFetcher - Optional URL fetcher override for tests.
|
|
256
59
|
*/
|
|
257
60
|
constructor(deps: AnalyzeMediaToolDeps, urlFetcher?: MediaUrlFetcher);
|
|
258
61
|
/**
|
|
259
62
|
* Validates raw MCP tool arguments.
|
|
260
63
|
*
|
|
261
|
-
* @param raw - Raw tool arguments
|
|
262
|
-
* @returns Validated parameters
|
|
64
|
+
* @param raw - Raw tool arguments.
|
|
65
|
+
* @returns Validated parameters.
|
|
66
|
+
* @throws Error with an Spanish-first bilingual message when arguments are missing or out of range.
|
|
263
67
|
*/
|
|
264
68
|
parseParams(raw: unknown): AnalyzeMediaToolParams;
|
|
265
69
|
/**
|
|
266
70
|
* Executes the tool.
|
|
267
71
|
*
|
|
268
|
-
* @param params - Validated parameters
|
|
269
|
-
* @
|
|
72
|
+
* @param params - Validated parameters.
|
|
73
|
+
* @param options - Optional execution options (cancellation signal).
|
|
74
|
+
* @returns Tool result.
|
|
75
|
+
* @throws Error with an Spanish-first bilingual message when configuration, upload, or analysis fails.
|
|
270
76
|
*/
|
|
271
|
-
execute(params: AnalyzeMediaToolParams): Promise<AnalyzeMediaToolResult>;
|
|
77
|
+
execute(params: AnalyzeMediaToolParams, options?: AnalyzeMediaExecutionOptions): Promise<AnalyzeMediaToolResult>;
|
|
272
78
|
/**
|
|
273
|
-
*
|
|
79
|
+
* Rejects a `region` zoom against non-image inputs before any upload.
|
|
274
80
|
*
|
|
275
81
|
* @remarks
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
82
|
+
* `region` zooms one image at native resolution: sending it with video,
|
|
83
|
+
* audio, PDF, or a tar set wastes an upload plus a server rejection (or
|
|
84
|
+
* a silent ignore). Fail locally in Spanish using the resolved effective
|
|
85
|
+
* content type (server-reported type wins, mirroring the resolver).
|
|
279
86
|
*
|
|
280
|
-
* @param
|
|
281
|
-
* @param
|
|
282
|
-
* @
|
|
87
|
+
* @param region - Validated region, or undefined when absent.
|
|
88
|
+
* @param inputs - Resolved upload-ready inputs.
|
|
89
|
+
* @throws Error with an Spanish-first bilingual message when `region` targets non-image media.
|
|
283
90
|
*/
|
|
284
|
-
private
|
|
91
|
+
private rejectRegionForNonImage;
|
|
285
92
|
/**
|
|
286
|
-
*
|
|
287
|
-
*
|
|
93
|
+
* Rejects tuning knobs that the resolved content type would silently ignore.
|
|
94
|
+
*
|
|
95
|
+
* @remarks
|
|
96
|
+
* Pre-upload gate mirroring EnriCode `VisionAnalyzeMediaRequestRecords`:
|
|
97
|
+
* `video.*` tuning only applies to video, `images.*` only to images
|
|
98
|
+
* and documents (PDF page-image sets on the remote route), `document.*`
|
|
99
|
+
* only to PDF/Office/TXT/CSV, clip/`maxFramesPerSegment` never to audio,
|
|
100
|
+
* `video.segment_seconds`/`max_segments` never to audio without an audio
|
|
101
|
+
* section, and `audio.segment_seconds`/`max_segments` never to video
|
|
102
|
+
* without a video section (shared flats fan out to both sections by
|
|
103
|
+
* design and are exempt). Multi-image sets only accept `images.*`. The top-level
|
|
104
|
+
* `maxFrames` knob is media-agnostic by design (EnriCode declares
|
|
105
|
+
* `max_frames` "sin efecto en imágenes fijas o audio"): it never
|
|
106
|
+
* triggers a mismatch gate and is forwarded for the server to apply or
|
|
107
|
+
* ignore. Unknown content types (`application/octet-stream` included)
|
|
108
|
+
* skip every gate by design so the server (not this gate) decides
|
|
109
|
+
* applicability, mirroring EnriCode `VisionAnalyzeMediaRequestRecords`.
|
|
110
|
+
* Failing here saves the
|
|
111
|
+
* full upload plus a late server rejection.
|
|
112
|
+
*
|
|
113
|
+
* @param params - Validated tool parameters.
|
|
114
|
+
* @param inputs - Resolved upload-ready inputs.
|
|
115
|
+
* @throws Error with an Spanish-first bilingual message when tuning mismatches the content type.
|
|
116
|
+
*/
|
|
117
|
+
private rejectMismatchedTuning;
|
|
118
|
+
/**
|
|
119
|
+
* Resolves the requested server-side model id for dispatch affinity.
|
|
120
|
+
*
|
|
121
|
+
* @remarks
|
|
122
|
+
* Pure read of `params.model` plus the validated `ENRIVISION_MODEL` env
|
|
123
|
+
* fallback (no operator logging): used by the pre-upload vision probe,
|
|
124
|
+
* which runs before the main model-resolution block in `execute`.
|
|
288
125
|
*
|
|
289
|
-
* @param
|
|
290
|
-
* @returns
|
|
126
|
+
* @param params - Validated tool parameters.
|
|
127
|
+
* @returns Trimmed model id, or undefined for auto-dispatch.
|
|
291
128
|
*/
|
|
292
|
-
private
|
|
129
|
+
private resolveRequestedModel;
|
|
293
130
|
/**
|
|
294
|
-
*
|
|
131
|
+
* Fails fast when the requested model explicitly lacks vision, before any byte.
|
|
132
|
+
*
|
|
133
|
+
* @remarks
|
|
134
|
+
* Mirrors EnriCode `assertRemoteVisionCapable`: probes `GET
|
|
135
|
+
* `/v1/account/models` (15 s budget inside the client) and matches the
|
|
136
|
+
* requested model by `id`, `requestModelId`, or canonical ids. Only an
|
|
137
|
+
* explicit `vision === false` rejects; unknown models, missing flags, and
|
|
138
|
+
* probe failures stay fail-open so a stale discovery snapshot never blocks
|
|
139
|
+
* a valid upload. Verdicts are cached per client for 5 min; 401/404 probe
|
|
140
|
+
* failures invalidate the entry so revoked keys never ride a stale verdict.
|
|
141
|
+
* Clients without `getAccountModels` (older stubs) skip the probe entirely.
|
|
295
142
|
*
|
|
296
|
-
* @param
|
|
297
|
-
* @
|
|
143
|
+
* @param client - EnriProxy client used for the upload.
|
|
144
|
+
* @param requestedModel - Trimmed model id, or undefined for auto-dispatch.
|
|
145
|
+
* @param signal - Optional cancellation signal.
|
|
146
|
+
* @throws Error with an Spanish-first bilingual message when the model explicitly lacks vision.
|
|
298
147
|
*/
|
|
299
|
-
private
|
|
148
|
+
private assertVisionCapable;
|
|
300
149
|
/**
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
* @param value - Sanitized value
|
|
304
|
-
* @returns Plain object
|
|
150
|
+
* Maximum vision-probe cache entries (model ids are caller-controlled).
|
|
305
151
|
*/
|
|
306
|
-
private
|
|
152
|
+
private static readonly MAX_VISION_PROBE_ENTRIES;
|
|
307
153
|
/**
|
|
308
|
-
*
|
|
154
|
+
* Remembers one vision-probe verdict, purging expired entries and
|
|
155
|
+
* evicting oldest-first past the cap so long-lived tool instances
|
|
156
|
+
* cannot leak one entry per distinct model id.
|
|
309
157
|
*
|
|
310
|
-
* @param
|
|
158
|
+
* @param cacheKey - Server plus model cache key.
|
|
159
|
+
* @param verdict - Whether the model has vision.
|
|
160
|
+
* @param now - Current epoch milliseconds.
|
|
161
|
+
* @returns Nothing.
|
|
162
|
+
*/
|
|
163
|
+
private rememberVisionProbe;
|
|
311
164
|
/**
|
|
312
|
-
*
|
|
165
|
+
* Builds the visionless-model rejection error.
|
|
313
166
|
*
|
|
314
|
-
* @param
|
|
315
|
-
* @returns
|
|
167
|
+
* @param modelId - Requested model id.
|
|
168
|
+
* @returns Spanish-first bilingual error (no byte was uploaded).
|
|
316
169
|
*/
|
|
317
|
-
private
|
|
170
|
+
private static buildVisionlessModelError;
|
|
318
171
|
/**
|
|
319
|
-
*
|
|
172
|
+
* Executes one truncated-list continuation read (no upload, no analysis).
|
|
320
173
|
*
|
|
321
|
-
* @param
|
|
322
|
-
* @
|
|
174
|
+
* @param client - EnriProxy client.
|
|
175
|
+
* @param cursor - Opaque cursor from a truncated response.
|
|
176
|
+
* @param offset - Start index, or undefined for the stored next offset.
|
|
177
|
+
* @param limit - Window length (1-100), or undefined for the server default.
|
|
178
|
+
* @param signal - Optional cancellation signal.
|
|
179
|
+
* @returns Tool result carrying the page plus chaining state.
|
|
323
180
|
*/
|
|
324
|
-
private
|
|
181
|
+
private executeContinuation;
|
|
325
182
|
/**
|
|
326
|
-
*
|
|
183
|
+
* Warns when `transcribe` is set for media it cannot affect.
|
|
327
184
|
*
|
|
328
|
-
* @
|
|
329
|
-
*
|
|
185
|
+
* @remarks
|
|
186
|
+
* Mirrors EnriCode `LocalMediaAnalysisService` (transcribe is inapplicable
|
|
187
|
+
* for images and documents): instead of failing, the knob is forwarded
|
|
188
|
+
* and declared as a bilingual honesty warning so the model never assumes
|
|
189
|
+
* audio was transcribed. Videos and audio files never warn.
|
|
190
|
+
*
|
|
191
|
+
* @param params - Validated tool parameters.
|
|
192
|
+
* @param inputs - Resolved upload-ready inputs.
|
|
193
|
+
* @returns Bilingual warning, or undefined when `transcribe` may apply.
|
|
330
194
|
*/
|
|
331
|
-
private
|
|
195
|
+
private transcribeInapplicableWarning;
|
|
332
196
|
/**
|
|
333
|
-
*
|
|
197
|
+
* Runs the mismatch gates on the remote (`source_url`) branch as advisories.
|
|
334
198
|
*
|
|
335
199
|
* @remarks
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
200
|
+
* The local gates no-op on the empty remote input list by design (the
|
|
201
|
+
* server, which sees the served type, decides applicability). When the URL
|
|
202
|
+
* extension guesses a known media type, the same gates run against the
|
|
203
|
+
* guess and likely-ignored tuning is declared as bilingual warnings
|
|
204
|
+
* instead of errors; URLs with no usable extension stay server-decides
|
|
205
|
+
* with no warnings.
|
|
339
206
|
*
|
|
340
|
-
* @param
|
|
341
|
-
* @param
|
|
342
|
-
* @
|
|
343
|
-
* @param clientTraceId - Client trace id for correlation
|
|
344
|
-
* @returns Upload id for the created tar session
|
|
207
|
+
* @param params - Validated tool parameters.
|
|
208
|
+
* @param remoteUrl - Remote http(s) URL the server will ingest.
|
|
209
|
+
* @returns Advisory warnings (empty when nothing looks mismatched).
|
|
345
210
|
*/
|
|
346
|
-
private
|
|
211
|
+
private advisoryRemoteTuningWarnings;
|
|
347
212
|
/**
|
|
348
|
-
*
|
|
213
|
+
* Releases uploaded bytes when the analysis fails or is cancelled.
|
|
349
214
|
*
|
|
350
|
-
* @
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
* @
|
|
215
|
+
* @remarks
|
|
216
|
+
* Best-effort by design: it runs on an independent 15 s signal (the
|
|
217
|
+
* caller signal may already be cancelled) and never throws, so the
|
|
218
|
+
* original upload/analysis error always reaches the model unchanged.
|
|
219
|
+
*
|
|
220
|
+
* @param client - EnriProxy client used for the upload.
|
|
221
|
+
* @param uploadId - Upload id to release, or null when nothing was uploaded.
|
|
356
222
|
*/
|
|
357
|
-
private
|
|
223
|
+
private deleteUploadedBytesBestEffort;
|
|
358
224
|
/**
|
|
359
|
-
*
|
|
225
|
+
* Removes internal identifiers from the extraction payload.
|
|
360
226
|
*
|
|
361
|
-
* @param
|
|
362
|
-
* @
|
|
363
|
-
* @param offset - Expected offset
|
|
364
|
-
* @param chunk - Chunk bytes
|
|
365
|
-
* @param timeoutMs - Timeout in ms
|
|
366
|
-
* @returns New offset
|
|
227
|
+
* @param extraction - Raw extraction object returned by EnriProxy.
|
|
228
|
+
* @returns Sanitized extraction object.
|
|
367
229
|
*/
|
|
368
|
-
private
|
|
230
|
+
private stripInternalExtractionFields;
|
|
369
231
|
}
|
|
370
232
|
//# sourceMappingURL=AnalyzeMediaTool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyzeMediaTool.d.ts","sourceRoot":"","sources":["../../src/tools/AnalyzeMediaTool.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"AnalyzeMediaTool.d.ts","sourceRoot":"","sources":["../../src/tools/AnalyzeMediaTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAS/D,OAAO,KAAK,EACV,sBAAsB,EACtB,4BAA4B,EAC5B,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,WAAW,EACZ,MAAM,2BAA2B,CAAC;AAGnC,YAAY,EACV,sBAAsB,EACtB,4BAA4B,EAC5B,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,WAAW,GACZ,CAAC;AAEF;;GAEG;AACH,qBAAa,gBAAgB;IAC3B;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAuB;IAE5C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA0B;IAEtD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA4B;IAE1D;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgC;IAEzD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA0B;IAEtD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkC;IAE5D;;;;;;;;OAQG;IACH,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CACrB;IAEZ;;;;;OAKG;gBACgB,IAAI,EAAE,oBAAoB,EAAE,UAAU,GAAE,eAAuC;IASlG;;;;;;OAMG;IACI,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,sBAAsB;IAIxD;;;;;;;OAOG;IACU,OAAO,CAClB,MAAM,EAAE,sBAAsB,EAC9B,OAAO,CAAC,EAAE,4BAA4B,GACrC,OAAO,CAAC,sBAAsB,CAAC;IAyOlC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,uBAAuB;IAe/B;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,OAAO,CAAC,sBAAsB;IAiG9B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,qBAAqB;IAc7B;;;;;;;;;;;;;;;;;OAiBG;YACW,mBAAmB;IAkDjC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAe;IAE/D;;;;;;;;;OASG;IACH,OAAO,CAAC,mBAAmB;IAgB3B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAMxC;;;;;;;;;OASG;YACW,mBAAmB;IAgDjC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,6BAA6B;IAiCrC;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,4BAA4B;IAsCpC;;;;;;;;;;OAUG;YACW,6BAA6B;IAyB3C;;;;;OAKG;IACH,OAAO,CAAC,6BAA6B;CAKtC"}
|