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14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
<html>
<head>
    <title>Document Query</title>
</head>

<body>
    <div x-data="{
        defaults: {
            fetch_timeout: 30,
            fetch_retries: 3,
            fetch_retry_backoff: 1.0,
            per_document_timeout: 60,
            gather_timeout: 120,
            parser_concurrency: 1,
            context_intro_chunks: 2,
            chunk_size: 1000,
            chunk_overlap: 100,
            max_index_chunks: 1200,
            search_threshold: 0.5,
            search_limit: 100,
            max_remote_bytes: 52428800,
            liteparse_enabled: true,
            liteparse_ocr_enabled: true,
            liteparse_ocr_language: 'eng',
            liteparse_ocr_server_url: '',
            liteparse_tessdata_path: '',
            liteparse_max_pages: 1000,
            liteparse_target_pages: '',
            liteparse_dpi: 150,
            liteparse_preserve_very_small_text: false,
            liteparse_output_format: 'text',
            liteparse_num_workers: 2,
            pdf_ocr_fallback: true,
            thread_offload: true,
        },
        initDefaults() {
            for (const [key, value] of Object.entries(this.defaults)) {
                if (config[key] === undefined || config[key] === null) config[key] = value;
            }
            this.ensureInt('parser_concurrency', 1, 1);
            this.ensureInt('context_intro_chunks', 2, 0);
            this.ensureInt('chunk_size', 1000, 100);
            this.ensureInt('chunk_overlap', 100, 0);
            this.ensureInt('max_index_chunks', 1200, 0);
            this.ensureInt('search_limit', 100, 1);
            this.ensureInt('max_remote_bytes', 52428800, 1);
            this.ensureNumber('search_threshold', 0.5, 0, 1);
            this.ensureNumber('fetch_timeout', 30, 1);
            this.ensureInt('fetch_retries', 3, 1);
            this.ensureNumber('fetch_retry_backoff', 1.0, 0);
            this.ensureNumber('per_document_timeout', 60, 1);
            this.ensureNumber('gather_timeout', 120, 1);
            this.ensureInt('liteparse_max_pages', 1000, 1);
            this.ensureNumber('liteparse_dpi', 150, 72);
            this.ensureInt('liteparse_num_workers', 2, 1);
            this.syncChunkOverlap();
        },
        ensureInt(key, fallback, min = null, max = null) {
            let value = parseInt(config[key], 10);
            if (!Number.isFinite(value)) value = fallback;
            if (min !== null) value = Math.max(min, value);
            if (max !== null) value = Math.min(max, value);
            config[key] = value;
        },
        ensureNumber(key, fallback, min = null, max = null) {
            let value = parseFloat(config[key]);
            if (!Number.isFinite(value)) value = fallback;
            if (min !== null) value = Math.max(min, value);
            if (max !== null) value = Math.min(max, value);
            config[key] = value;
        },
        syncChunkOverlap() {
            this.ensureInt('chunk_size', 1000, 100);
            this.ensureInt('chunk_overlap', 100, 0);
            if (config.chunk_overlap >= config.chunk_size) {
                config.chunk_overlap = Math.max(0, config.chunk_size - 1);
            }
        },
    }">
        <template x-if="config">
            <div x-init="initDefaults()">
                <div class="section-title">Document Query</div>
                <div class="section-description">
                    Settings for document parsing and retrieval.
                </div>

                <div class="field">
                    <div class="field-label">
                        <div class="field-title">Max parser concurrency</div>
                        <div class="field-description">
                            Maximum document parser jobs allowed to run at the same time in this Agent Zero process.
                        </div>
                    </div>
                    <div class="field-control">
                        <input type="number" min="1" step="1"
                            @change="ensureInt('parser_concurrency', 1, 1)"
                            x-model.number="config.parser_concurrency" />
                    </div>
                </div>

                <div class="field">
                    <div class="field-label">
                        <div class="field-title">Per-document timeout</div>
                        <div class="field-description">
                            Seconds allowed for a single document parse before trying the next parser or returning an error.
                        </div>
                    </div>
                    <div class="field-control">
                        <input type="number" min="1" step="1"
                            @change="ensureNumber('per_document_timeout', 60, 1)"
                            x-model.number="config.per_document_timeout" />
                    </div>
                </div>

                <div class="field">
                    <div class="field-label">
                        <div class="field-title">Batch timeout</div>
                        <div class="field-description">
                            Seconds allowed for a document-query call that processes multiple files.
                        </div>
                    </div>
                    <div class="field-control">
                        <input type="number" min="1" step="1"
                            @change="ensureNumber('gather_timeout', 120, 1)"
                            x-model.number="config.gather_timeout" />
                    </div>
                </div>

                <div class="section-title">Retrieval</div>
                <div class="section-description">
                    Controls how parsed text is split, indexed, and selected for Q&A.
                </div>

                <div class="field">
                    <div class="field-label">
                        <div class="field-title">Chunk size</div>
                        <div class="field-description">
                            Target character count for indexed chunks.
                        </div>
                    </div>
                    <div class="field-control">
                        <input type="number" min="100" step="50"
                            @change="syncChunkOverlap()"
                            x-model.number="config.chunk_size" />
                    </div>
                </div>

                <div class="field">
                    <div class="field-label">
                        <div class="field-title">Chunk overlap</div>
                        <div class="field-description">
                            Characters repeated between neighboring chunks.
                        </div>
                    </div>
                    <div class="field-control">
                        <input type="number" min="0" step="25"
                            :max="Math.max(0, config.chunk_size - 1)"
                            @change="syncChunkOverlap()"
                            x-model.number="config.chunk_overlap" />
                    </div>
                </div>

                <div class="field">
                    <div class="field-label">
                        <div class="field-title">Search threshold</div>
                        <div class="field-description">
                            Minimum vector similarity score for retrieved chunks.
                        </div>
                    </div>
                    <div class="field-control">
                        <input type="number" min="0" max="1" step="0.05"
                            @change="ensureNumber('search_threshold', 0.5, 0, 1)"
                            x-model.number="config.search_threshold" />
                    </div>
                </div>

                <div class="field">
                    <div class="field-label">
                        <div class="field-title">Max index chunks</div>
                        <div class="field-description">
                            Adapt chunk size when a parsed document would exceed this many indexed chunks. Use 0 for no cap.
                        </div>
                    </div>
                    <div class="field-control">
                        <input type="number" min="0" step="50"
                            @change="ensureInt('max_index_chunks', 1200, 0)"
                            x-model.number="config.max_index_chunks" />
                    </div>
                </div>

                <div class="field">
                    <div class="field-label">
                        <div class="field-title">Search limit</div>
                        <div class="field-description">
                            Maximum matching chunks considered during document Q&A.
                        </div>
                    </div>
                    <div class="field-control">
                        <input type="number" min="1" step="1"
                            @change="ensureInt('search_limit', 100, 1)"
                            x-model.number="config.search_limit" />
                    </div>
                </div>

                <div class="field">
                    <div class="field-label">
                        <div class="field-title">Intro chunks</div>
                        <div class="field-description">
                            Leading chunks always included per document to preserve titles, abstracts, and setup context.
                        </div>
                    </div>
                    <div class="field-control">
                        <input type="number" min="0" step="1"
                            @change="ensureInt('context_intro_chunks', 2, 0)"
                            x-model.number="config.context_intro_chunks" />
                    </div>
                </div>

                <div class="section-title">Remote Files</div>
                <div class="section-description">
                    Limits for documents loaded from HTTP or HTTPS URLs.
                </div>

                <div class="field">
                    <div class="field-label">
                        <div class="field-title">Fetch timeout</div>
                        <div class="field-description">
                            Seconds allowed for each remote fetch attempt.
                        </div>
                    </div>
                    <div class="field-control">
                        <input type="number" min="1" step="1"
                            @change="ensureNumber('fetch_timeout', 30, 1)"
                            x-model.number="config.fetch_timeout" />
                    </div>
                </div>

                <div class="field">
                    <div class="field-label">
                        <div class="field-title">Fetch retries</div>
                        <div class="field-description">
                            Attempts made before giving up on a remote document.
                        </div>
                    </div>
                    <div class="field-control">
                        <input type="number" min="1" step="1"
                            @change="ensureInt('fetch_retries', 3, 1)"
                            x-model.number="config.fetch_retries" />
                    </div>
                </div>

                <div class="field">
                    <div class="field-label">
                        <div class="field-title">Retry backoff</div>
                        <div class="field-description">
                            Delay in seconds between remote fetch retries.
                        </div>
                    </div>
                    <div class="field-control">
                        <input type="number" min="0" step="0.1"
                            @change="ensureNumber('fetch_retry_backoff', 1.0, 0)"
                            x-model.number="config.fetch_retry_backoff" />
                    </div>
                </div>

                <div class="field">
                    <div class="field-label">
                        <div class="field-title">Max remote bytes</div>
                        <div class="field-description">
                            Maximum size accepted for a remote document.
                        </div>
                    </div>
                    <div class="field-control">
                        <input type="number" min="1" step="1048576"
                            @change="ensureInt('max_remote_bytes', 52428800, 1)"
                            x-model.number="config.max_remote_bytes" />
                    </div>
                </div>

                <div class="section-title">LiteParse and OCR</div>
                <div class="section-description">
                    Parser preference and OCR controls for PDFs, document images, and mixed-format inputs.
                </div>

                <div class="field">
                    <div class="field-label">
                        <div class="field-title">Use LiteParse first</div>
                        <div class="field-description">
                            Prefer LiteParse before legacy parser fallbacks.
                        </div>
                    </div>
                    <div class="field-control">
                        <label class="toggle">
                            <input type="checkbox" x-model="config.liteparse_enabled" />
                            <span class="toggler"></span>
                        </label>
                    </div>
                </div>

                <template x-if="config.liteparse_enabled !== false">
                    <div>
                        <div class="field">
                            <div class="field-label">
                                <div class="field-title">LiteParse workers</div>
                                <div class="field-description">
                                    Worker count passed to LiteParse for a single parser job.
                                </div>
                            </div>
                            <div class="field-control">
                                <input type="number" min="1" step="1"
                                    @change="ensureInt('liteparse_num_workers', 2, 1)"
                                    x-model.number="config.liteparse_num_workers" />
                            </div>
                        </div>

                        <div class="field">
                            <div class="field-label">
                                <div class="field-title">Max pages</div>
                                <div class="field-description">
                                    Maximum pages LiteParse should parse from one document.
                                </div>
                            </div>
                            <div class="field-control">
                                <input type="number" min="1" step="1"
                                    @change="ensureInt('liteparse_max_pages', 1000, 1)"
                                    x-model.number="config.liteparse_max_pages" />
                            </div>
                        </div>

                        <div class="field">
                            <div class="field-label">
                                <div class="field-title">Target pages</div>
                                <div class="field-description">
                                    Optional page range expression passed to LiteParse.
                                </div>
                            </div>
                            <div class="field-control">
                                <input type="text"
                                    placeholder="all pages"
                                    x-model="config.liteparse_target_pages" />
                            </div>
                        </div>

                        <div class="field">
                            <div class="field-label">
                                <div class="field-title">Enable OCR</div>
                                <div class="field-description">
                                    Allow OCR for scanned PDFs and document images.
                                </div>
                            </div>
                            <div class="field-control">
                                <label class="toggle">
                                    <input type="checkbox" x-model="config.liteparse_ocr_enabled" />
                                    <span class="toggler"></span>
                                </label>
                            </div>
                        </div>

                        <template x-if="config.liteparse_ocr_enabled !== false">
                            <div>
                                <div class="field">
                                    <div class="field-label">
                                        <div class="field-title">OCR language</div>
                                        <div class="field-description">
                                            Tesseract language code used by LiteParse OCR.
                                        </div>
                                    </div>
                                    <div class="field-control">
                                        <input type="text"
                                            placeholder="eng"
                                            x-model="config.liteparse_ocr_language" />
                                    </div>
                                </div>

                                <div class="field">
                                    <div class="field-label">
                                        <div class="field-title">OCR DPI</div>
                                        <div class="field-description">
                                            Render density used before OCR.
                                        </div>
                                    </div>
                                    <div class="field-control">
                                        <input type="number" min="72" step="1"
                                            @change="ensureNumber('liteparse_dpi', 150, 72)"
                                            x-model.number="config.liteparse_dpi" />
                                    </div>
                                </div>

                                <div class="field">
                                    <div class="field-label">
                                        <div class="field-title">OCR server URL</div>
                                        <div class="field-description">
                                            Optional external OCR service URL.
                                        </div>
                                    </div>
                                    <div class="field-control">
                                        <input type="text"
                                            placeholder="none"
                                            x-model="config.liteparse_ocr_server_url" />
                                    </div>
                                </div>

                                <div class="field">
                                    <div class="field-label">
                                        <div class="field-title">Tessdata path</div>
                                        <div class="field-description">
                                            Optional path to Tesseract language data.
                                        </div>
                                    </div>
                                    <div class="field-control">
                                        <input type="text"
                                            placeholder="auto-detect"
                                            x-model="config.liteparse_tessdata_path" />
                                    </div>
                                </div>
                            </div>
                        </template>

                        <div class="field">
                            <div class="field-label">
                                <div class="field-title">Output format</div>
                                <div class="field-description">
                                    LiteParse output format passed to the parser runtime.
                                </div>
                            </div>
                            <div class="field-control">
                                <input type="text"
                                    placeholder="text"
                                    x-model="config.liteparse_output_format" />
                            </div>
                        </div>

                        <div class="field">
                            <div class="field-label">
                                <div class="field-title">Preserve very small text</div>
                                <div class="field-description">
                                    Keep tiny text regions that OCR or PDF extraction might otherwise discard.
                                </div>
                            </div>
                            <div class="field-control">
                                <label class="toggle">
                                    <input type="checkbox" x-model="config.liteparse_preserve_very_small_text" />
                                    <span class="toggler"></span>
                                </label>
                            </div>
                        </div>

                    </div>
                </template>

                <div class="section-title">Fallbacks</div>
                <div class="section-description">
                    Legacy parser behavior used when the preferred parser cannot produce text.
                </div>

                <div class="field">
                    <div class="field-label">
                        <div class="field-title">PDF OCR fallback</div>
                        <div class="field-description">
                            Try legacy Tesseract OCR when direct PDF text extraction is empty.
                        </div>
                    </div>
                    <div class="field-control">
                        <label class="toggle">
                            <input type="checkbox" x-model="config.pdf_ocr_fallback" />
                            <span class="toggler"></span>
                        </label>
                    </div>
                </div>

                <div class="field">
                    <div class="field-label">
                        <div class="field-title">Thread offload</div>
                        <div class="field-description">
                            Run synchronous parser fallbacks in a worker thread.
                        </div>
                    </div>
                    <div class="field-control">
                        <label class="toggle">
                            <input type="checkbox" x-model="config.thread_offload" />
                            <span class="toggler"></span>
                        </label>
                    </div>
                </div>
            </div>
        </template>
    </div>
</body>

</html>