@bedolla/enrivision 0.1.4 → 0.1.6

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 (64) hide show
  1. package/README.md +31 -6
  2. package/dist/client/EnriProxyClient.d.ts +289 -244
  3. package/dist/client/EnriProxyClient.d.ts.map +1 -1
  4. package/dist/client/EnriProxyClient.js +841 -115
  5. package/dist/client/EnriProxyClient.js.map +1 -1
  6. package/dist/client/EnriProxyClientContract.d.ts +425 -0
  7. package/dist/client/EnriProxyClientContract.d.ts.map +1 -0
  8. package/dist/client/EnriProxyClientContract.js +87 -0
  9. package/dist/client/EnriProxyClientContract.js.map +1 -0
  10. package/dist/index.js +23 -12
  11. package/dist/index.js.map +1 -1
  12. package/dist/package-info.d.ts +28 -0
  13. package/dist/package-info.d.ts.map +1 -1
  14. package/dist/package-info.js +28 -0
  15. package/dist/package-info.js.map +1 -1
  16. package/dist/server/EnriVisionServer.d.ts +186 -0
  17. package/dist/server/EnriVisionServer.d.ts.map +1 -1
  18. package/dist/server/EnriVisionServer.js +780 -93
  19. package/dist/server/EnriVisionServer.js.map +1 -1
  20. package/dist/shared/codepointTruncation.d.ts +61 -0
  21. package/dist/shared/codepointTruncation.d.ts.map +1 -0
  22. package/dist/shared/codepointTruncation.js +73 -0
  23. package/dist/shared/codepointTruncation.js.map +1 -0
  24. package/dist/shared/mediaUrlFetcher.d.ts +247 -9
  25. package/dist/shared/mediaUrlFetcher.d.ts.map +1 -1
  26. package/dist/shared/mediaUrlFetcher.js +712 -53
  27. package/dist/shared/mediaUrlFetcher.js.map +1 -1
  28. package/dist/shared/tar.d.ts +82 -2
  29. package/dist/shared/tar.d.ts.map +1 -1
  30. package/dist/shared/tar.js +106 -43
  31. package/dist/shared/tar.js.map +1 -1
  32. package/dist/shared/validation.d.ts +96 -2
  33. package/dist/shared/validation.d.ts.map +1 -1
  34. package/dist/shared/validation.js +169 -10
  35. package/dist/shared/validation.js.map +1 -1
  36. package/dist/tools/AnalyzeMediaContract.d.ts +457 -0
  37. package/dist/tools/AnalyzeMediaContract.d.ts.map +1 -0
  38. package/dist/tools/AnalyzeMediaContract.js +161 -0
  39. package/dist/tools/AnalyzeMediaContract.js.map +1 -0
  40. package/dist/tools/AnalyzeMediaExtractionSanitizer.d.ts +35 -0
  41. package/dist/tools/AnalyzeMediaExtractionSanitizer.d.ts.map +1 -0
  42. package/dist/tools/AnalyzeMediaExtractionSanitizer.js +214 -0
  43. package/dist/tools/AnalyzeMediaExtractionSanitizer.js.map +1 -0
  44. package/dist/tools/AnalyzeMediaInputResolver.d.ts +250 -0
  45. package/dist/tools/AnalyzeMediaInputResolver.d.ts.map +1 -0
  46. package/dist/tools/AnalyzeMediaInputResolver.js +430 -0
  47. package/dist/tools/AnalyzeMediaInputResolver.js.map +1 -0
  48. package/dist/tools/AnalyzeMediaParamParser.d.ts +299 -0
  49. package/dist/tools/AnalyzeMediaParamParser.d.ts.map +1 -0
  50. package/dist/tools/AnalyzeMediaParamParser.js +824 -0
  51. package/dist/tools/AnalyzeMediaParamParser.js.map +1 -0
  52. package/dist/tools/AnalyzeMediaResumableUploader.d.ts +244 -0
  53. package/dist/tools/AnalyzeMediaResumableUploader.d.ts.map +1 -0
  54. package/dist/tools/AnalyzeMediaResumableUploader.js +549 -0
  55. package/dist/tools/AnalyzeMediaResumableUploader.js.map +1 -0
  56. package/dist/tools/AnalyzeMediaTarPackager.d.ts +42 -0
  57. package/dist/tools/AnalyzeMediaTarPackager.d.ts.map +1 -0
  58. package/dist/tools/AnalyzeMediaTarPackager.js +245 -0
  59. package/dist/tools/AnalyzeMediaTarPackager.js.map +1 -0
  60. package/dist/tools/AnalyzeMediaTool.d.ts +155 -294
  61. package/dist/tools/AnalyzeMediaTool.d.ts.map +1 -1
  62. package/dist/tools/AnalyzeMediaTool.js +600 -457
  63. package/dist/tools/AnalyzeMediaTool.js.map +1 -1
  64. package/package.json +2 -1
@@ -0,0 +1,299 @@
1
+ /**
2
+ * ANALYZE MEDIA PARAMETER PARSER
3
+ *
4
+ * Validates raw MCP tool arguments for `analyze_media`, including multipass
5
+ * knob ranges, so out-of-range values fail locally in Spanish instead of
6
+ * being silently clamped by EnriProxy.
7
+ *
8
+ * Enforced knob contract (documented in the MCP tool schema, mirrors EnriProxy `VisionAnalysisHandler`):
9
+ * - max_frames (or maxFrames): integer 1-20 (default 20)
10
+ * - analysis_mode (or analysisMode): auto|single|multipass
11
+ * - video.segment_seconds (or segmentSeconds, flat or nested): 5-600 seconds (default 60)
12
+ * - video.max_segments (or maxSegments, flat or nested): integer 1-60
13
+ * - video.max_frames_per_segment (or maxFramesPerSegment, flat or nested): integer 1-20 (default 8)
14
+ * - video.clip_start_seconds (or clipStartSeconds): 0-86400
15
+ * - video.clip_end_seconds (or clipEndSeconds): 0-86400, > start; duration derives as end - start
16
+ * - video.clip_duration_seconds (or clipDurationSeconds): (0, 86400]
17
+ * - audio.segment_seconds (or segmentSeconds, flat or nested): 5-600 seconds (default 60)
18
+ * - audio.max_segments (or maxSegments, flat or nested): integer 1-60
19
+ * - audio.timestamps (or audioTimestamps flat): strict boolean
20
+ * - document.max_pages_total (or documentMaxPages flat): integer 1-200 (default 20)
21
+ * - document.pages_per_batch: integer 1-200
22
+ * - document.max_images_per_batch: integer 0-20 (0 = no render)
23
+ * - document.scanned_text_threshold_chars: integer 0-5000
24
+ * - images.max_images_total: integer 1-500
25
+ * - images.images_per_batch: integer 1-20
26
+ * - images.max_dimension: integer 256-4096
27
+ * - paths[]: at most 100 entries
28
+ *
29
+ * @module tools/AnalyzeMediaParamParser
30
+ */
31
+ import type { AnalyzeMediaToolParams } from "./AnalyzeMediaContract.js";
32
+ /**
33
+ * Validates raw `analyze_media` tool arguments.
34
+ */
35
+ export declare class AnalyzeMediaParamParser {
36
+ /**
37
+ * Honesty notes collected while parsing (reset on every `parseParams` call).
38
+ */
39
+ private parseWarnings;
40
+ /**
41
+ * Validates raw MCP tool arguments.
42
+ *
43
+ * @remarks
44
+ * Accepts `snake_case` and `camelCase` spellings (`max_frames` or
45
+ * `maxFrames`) plus EnriCode-style flat knobs (`segmentSeconds`,
46
+ * `maxSegments`, `maxFramesPerSegment`, `audioTimestamps`,
47
+ * `documentMaxPages`, `clipStartSeconds`, `clipEndSeconds`,
48
+ * `clipDurationSeconds`). Flat knobs win over their nested
49
+ * `video`/`audio`/`document` counterparts, mirroring EnriCode.
50
+ *
51
+ * @param raw - Raw tool arguments.
52
+ * @returns Validated parameters.
53
+ * @throws Error with an Spanish-first bilingual message when arguments are missing or out of range.
54
+ */
55
+ parseParams(raw: unknown): AnalyzeMediaToolParams;
56
+ /**
57
+ * Rejects differing nested video/audio segment knobs without a flat winner.
58
+ *
59
+ * @remarks
60
+ * Flat-over-nested precedence mirrors EnriCode: a flat `segmentSeconds` or
61
+ * `maxSegments` wins over both nested sections (fan-out to both is
62
+ * intentional; the server applies the media-matching one). Without a flat,
63
+ * differing nested `video` vs `audio` values for the same knob fail in
64
+ * Spanish and point at the flat winner, mirroring
65
+ * `VisionAnalyzeMediaToolInputParser` video-beats-audio conflict guards.
66
+ *
67
+ * @param flat - Top-level arguments carrying flat knob aliases.
68
+ * @throws Error with an Spanish-first bilingual message when nested video/audio values differ without a flat.
69
+ */
70
+ private rejectConflictingNestedSegmentKnobs;
71
+ /**
72
+ * Parses the `analysis_mode` selector accepting both spellings.
73
+ *
74
+ * @param raw - Raw selector value.
75
+ * @returns Validated selector or undefined when absent.
76
+ * @throws Error with an Spanish-first bilingual message when the value is not auto|single|multipass.
77
+ */
78
+ private parseAnalysisMode;
79
+ /**
80
+ * Parses the single `path` argument.
81
+ *
82
+ * @param raw - Raw `path` argument.
83
+ * @returns Trimmed path, or undefined when absent.
84
+ * @throws Error with an Spanish-first bilingual message when the path is neither absolute nor http(s).
85
+ */
86
+ private parsePath;
87
+ /**
88
+ * Parses the continuation cursor for truncated-list reads.
89
+ *
90
+ * @param raw - Raw `cursor` argument.
91
+ * @returns Validated cursor, or undefined when absent.
92
+ * @throws Error with a Spanish-first bilingual message when present but malformed.
93
+ */
94
+ private parseCursor;
95
+ /**
96
+ * Parses the continuation start index.
97
+ *
98
+ * @param raw - Raw `offset` argument.
99
+ * @returns Validated offset, or undefined when absent.
100
+ * @throws Error with a Spanish-first bilingual message when present but not an integer >= 0.
101
+ */
102
+ private parseOffset;
103
+ /**
104
+ * Parses the multi-image `paths` argument.
105
+ *
106
+ * @remarks
107
+ * Blank entries are discarded (documented in the tool schema); when at
108
+ * least one valid entry remains, `paths` wins over `path` at execution.
109
+ *
110
+ * @param raw - Raw `paths` argument.
111
+ * @returns Validated paths, or undefined when absent/empty.
112
+ * @throws Error with an Spanish-first bilingual message when `paths` is not an array of absolute paths or http(s) URLs.
113
+ */
114
+ private parsePaths;
115
+ /**
116
+ * Parses the optional `video` tuning object with range validation.
117
+ *
118
+ * @remarks
119
+ * Accepts `snake_case` and `camelCase` spellings inside `video`, plus
120
+ * flat knobs (`clipStartSeconds`, `clipEndSeconds`, `clipDurationSeconds`,
121
+ * `segmentSeconds`, `maxSegments`, `maxFramesPerSegment`) with
122
+ * flat-over-nested precedence. When `clip_end_seconds` is present the
123
+ * duration derives as `fin = inicio + duración` (`duration = end - start`)
124
+ * and `end <= start` fails (a zero window would be dropped downstream,
125
+ * silently widening the analysis); otherwise an explicit `clip_duration_seconds`
126
+ * is used. Every clip bound lives in `0-86400` segundos (24 h). When any
127
+ * clip knob is present but `clip_start_seconds` is absent, the start is
128
+ * synthesized as `0` so the server never defaults the offset (mirrors
129
+ * EnriCode `VisionAnalyzeMediaRequestRecords`), and
130
+ * `start + duration > 86400` clamps the duration to the 24 h range with
131
+ * a Spanish warning in `warnings` (mirrors the proxy timeline trim);
132
+ * only a start already at the limit fails. A lone `clip_start_seconds`
133
+ * at the 86400 cap with no duration forwards untouched (server decides),
134
+ * mirroring EnriCode `VisionAnalyzeMediaClipWindowReader`, which likewise
135
+ * returns a start-only window with no warning in that case.
136
+ *
137
+ * @param raw - Raw `video` argument.
138
+ * @param flat - Top-level arguments carrying flat knob aliases.
139
+ * @param applySharedFlats - Whether shared `segmentSeconds`/`maxSegments` flats feed this section.
140
+ * @returns Validated video tuning, or undefined when absent.
141
+ * @throws Error with an Spanish-first bilingual message when any knob is present but invalid or out of range.
142
+ */
143
+ private parseVideo;
144
+ /**
145
+ * Parses the optional `document` tuning object with range validation.
146
+ *
147
+ * @remarks
148
+ * Accepts `snake_case` and `camelCase` spellings, plus the flat
149
+ * `documentMaxPages` knob with flat-over-nested precedence.
150
+ *
151
+ * @param raw - Raw `document` argument.
152
+ * @param flat - Top-level arguments carrying flat knob aliases.
153
+ * @returns Validated document tuning, or undefined when absent.
154
+ * @throws Error with an Spanish-first bilingual message when any knob is present but invalid or out of range.
155
+ */
156
+ private parseDocument;
157
+ /**
158
+ * Parses the optional `audio` tuning object with range validation.
159
+ *
160
+ * @remarks
161
+ * Accepts `snake_case` and `camelCase` spellings, plus the flat
162
+ * `audioTimestamps`, `segmentSeconds`, and `maxSegments` knobs with
163
+ * flat-over-nested precedence. Boolean knobs are strict: `"yes"` fails
164
+ * instead of being dropped silently.
165
+ *
166
+ * @param raw - Raw `audio` argument.
167
+ * @param flat - Top-level arguments carrying flat knob aliases.
168
+ * @param applySharedFlats - Whether shared `segmentSeconds`/`maxSegments` flats feed this section.
169
+ * @returns Validated audio tuning, or undefined when absent.
170
+ * @throws Error with an Spanish-first bilingual message when any knob is present but invalid or out of range.
171
+ */
172
+ private parseAudio;
173
+ /**
174
+ * Parses the optional `images` tuning object with sanity validation.
175
+ *
176
+ * @param raw - Raw `images` argument.
177
+ * @returns Validated images tuning, or undefined when absent.
178
+ * @throws Error with an Spanish-first bilingual message when any knob is present but invalid.
179
+ */
180
+ private parseImages;
181
+ /**
182
+ * Rejects unknown keys inside one nested tuning object with Spanish coaching.
183
+ *
184
+ * @remarks
185
+ * Typos (`max_pages_totall`, `segement_seconds`) must fail locally instead
186
+ * of being ignored silently and analyzing the whole file at full cost.
187
+ *
188
+ * @param actual - Raw nested tuning object.
189
+ * @param known - Accepted key spellings for the section.
190
+ * @param section - Section name for error messages.
191
+ * @throws Error with an Spanish-first bilingual message when the section carries unknown keys.
192
+ */
193
+ private throwOnUnknownKeys;
194
+ /**
195
+ * Validates one language hint against the EnriCode pattern.
196
+ *
197
+ * @param raw - Raw language value.
198
+ * @param fieldName - Field name for error messages.
199
+ * @returns Validated hint, or undefined when absent.
200
+ * @throws Error with an Spanish-first bilingual message when the hint has an invalid shape.
201
+ */
202
+ private parseLanguageHint;
203
+ /**
204
+ * Parses an optional integer knob that must be absent or within a range.
205
+ *
206
+ * @param raw - Raw knob value.
207
+ * @param fieldName - Dotted field name for error messages.
208
+ * @param min - Inclusive minimum.
209
+ * @param max - Inclusive maximum.
210
+ * @returns Validated integer, or undefined when absent.
211
+ * @throws Error with an Spanish-first bilingual message when present but not an integer within range.
212
+ */
213
+ private parseBoundedInt;
214
+ /**
215
+ * Parses an optional numeric knob that must be absent or within a range.
216
+ *
217
+ * @param raw - Raw knob value.
218
+ * @param fieldName - Dotted field name for error messages.
219
+ * @param min - Inclusive minimum.
220
+ * @param max - Inclusive maximum.
221
+ * @returns Validated number, or undefined when absent.
222
+ * @throws Error with an Spanish-first bilingual message when present but not a number within range.
223
+ */
224
+ private parseBoundedNumber;
225
+ /**
226
+ * Parses an optional clip-window bound that must be absent or within 0-86400.
227
+ *
228
+ * @param raw - Raw knob value.
229
+ * @param fieldName - Dotted field name for error messages.
230
+ * @param min - Inclusive minimum.
231
+ * @param max - Inclusive maximum.
232
+ * @returns Validated number, or undefined when absent.
233
+ * @throws Error with an Spanish-first bilingual message when present but not a number within range.
234
+ */
235
+ private parseClipBound;
236
+ /**
237
+ * Parses an optional clip duration that must be absent or within (0, 86400].
238
+ *
239
+ * @param raw - Raw knob value.
240
+ * @returns Validated duration, or undefined when absent.
241
+ * @throws Error with an Spanish-first bilingual message when present but not a positive number within range.
242
+ */
243
+ private parseClipDuration;
244
+ /**
245
+ * Parses the optional requested model id for server-side dispatch affinity.
246
+ *
247
+ * @param raw - Raw `model` argument.
248
+ * @returns Trimmed model id, or undefined when absent/blank.
249
+ * @throws Error with an Spanish-first bilingual message when the model id is not a short string.
250
+ */
251
+ private parseModelHint;
252
+ /**
253
+ * Parses and validates the optional relative image region.
254
+ *
255
+ * @param raw - Raw `region` argument.
256
+ * @returns Validated region, or undefined when absent.
257
+ * @throws Error with an Spanish-first bilingual message when the region is malformed or out of range.
258
+ */
259
+ private parseRegion;
260
+ /**
261
+ * Rejects oversized prompt text before any byte is uploaded.
262
+ *
263
+ * @remarks
264
+ * Mirrors EnriProxy `VISION_MAX_QUESTION_CHARS`/`VISION_MAX_CONTEXT_CHARS`
265
+ * (2000): the server 400s after upload cost, so the gate lives here.
266
+ *
267
+ * @param value - Optional prompt text.
268
+ * @param fieldName - `question` or `context`.
269
+ * @returns Prompt text, or undefined when absent.
270
+ * @throws Error in Spanish naming the 2000-character cap.
271
+ */
272
+ private static requireBoundedPromptText;
273
+ }
274
+ /**
275
+ * Accepted top-level argument keys (exported for the schema-parser
276
+ * agreement test: every key here must exist as an `inputSchema` property).
277
+ */
278
+ export declare const TOP_LEVEL_KNOWN_KEYS: ReadonlySet<string>;
279
+ /**
280
+ * Accepted key spellings inside the `video` tuning object (snake_case + camelCase).
281
+ */
282
+ export declare const VIDEO_KNOWN_KEYS: ReadonlySet<string>;
283
+ /**
284
+ * Accepted key spellings inside the `document` tuning object (snake_case + camelCase + legacy aliases).
285
+ */
286
+ export declare const DOCUMENT_KNOWN_KEYS: ReadonlySet<string>;
287
+ /**
288
+ * Accepted key spellings inside the `audio` tuning object (snake_case + camelCase).
289
+ */
290
+ export declare const AUDIO_KNOWN_KEYS: ReadonlySet<string>;
291
+ /**
292
+ * Accepted key spellings inside the `region` zoom object.
293
+ */
294
+ export declare const REGION_KNOWN_KEYS: ReadonlySet<string>;
295
+ /**
296
+ * Accepted key spellings inside the `images` tuning object (snake_case + camelCase).
297
+ */
298
+ export declare const IMAGES_KNOWN_KEYS: ReadonlySet<string>;
299
+ //# sourceMappingURL=AnalyzeMediaParamParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyzeMediaParamParser.d.ts","sourceRoot":"","sources":["../../src/tools/AnalyzeMediaParamParser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAeH,OAAO,KAAK,EACV,sBAAsB,EAEvB,MAAM,2BAA2B,CAAC;AAGnC;;GAEG;AACH,qBAAa,uBAAuB;IAClC;;OAEG;IACH,OAAO,CAAC,aAAa,CAAgB;IAErC;;;;;;;;;;;;;;OAcG;IACI,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,sBAAsB;IA6GxD;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,mCAAmC;IA6C3C;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IAezB;;;;;;OAMG;IACH,OAAO,CAAC,SAAS;IAmBjB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAUnB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAUnB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,UAAU;IAmClB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,OAAO,CAAC,UAAU;IAuGlB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,aAAa;IAsDrB;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,UAAU;IAmClB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAyCnB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,kBAAkB;IAa1B;;;;;;;OAOG;IACH,OAAO,CAAC,iBAAiB;IAczB;;;;;;;;;OASG;IACH,OAAO,CAAC,eAAe;IAkBvB;;;;;;;;;OASG;IACH,OAAO,CAAC,kBAAkB;IAmB1B;;;;;;;;;OASG;IACH,OAAO,CAAC,cAAc;IAWtB;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IAkBzB;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IAUtB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAuCnB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,MAAM,CAAC,wBAAwB;CAWxC;AAgBD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAqCnD,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAa/C,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAalD,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAQ/C,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAKhD,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAOhD,CAAC"}