@curio-data/mcp-intelli-search 0.19.1 → 0.21.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/README.md +21 -8
- package/dist/{chunk-V5TY66GM.js → chunk-HLF5TGKP.js} +215 -44
- package/dist/{chunk-57DS6B3Q.js → chunk-LXLEWIYT.js} +12 -2
- package/dist/cli.js +1 -1
- package/dist/runtime.js +2 -2
- package/dist/server.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/@curio-data/mcp-intelli-search)
|
|
7
7
|
[](https://nodejs.org/)
|
|
8
8
|
[](https://github.com/Curio-Data/pi-intelli-search/blob/main/LICENSE)
|
|
9
|
-

|
|
10
10
|
|
|
11
11
|
Intelligent web research for coding agents: search, extract, collate, and cache grounded web context in one tool call.
|
|
12
12
|
|
|
@@ -59,6 +59,7 @@ The native extension uses `Pi` settings and authentication. Generic MCP registra
|
|
|
59
59
|
- [Generic MCP Host](#generic-mcp-host)
|
|
60
60
|
- [Tools](#tools)
|
|
61
61
|
- [Evidence and Provenance](#evidence-and-provenance)
|
|
62
|
+
- [Extraction Diagnostics](#extraction-diagnostics)
|
|
62
63
|
- [Usage Examples](#usage-examples)
|
|
63
64
|
- [Quick Search](#quick-search)
|
|
64
65
|
- [Deep Research](#deep-research)
|
|
@@ -219,13 +220,13 @@ codex plugin marketplace add Curio-Data/pi-intelli-search
|
|
|
219
220
|
codex plugin add intelli-search --marketplace curio-data-plugins
|
|
220
221
|
```
|
|
221
222
|
|
|
222
|
-
After installation, open a [_Bash_](https://www.gnu.org/software/bash/) shell in the project folder whose `.search/` directory will hold research results. Store the OpenRouter key with the
|
|
223
|
+
After installation, open a [_Bash_](https://www.gnu.org/software/bash/) shell in the project folder whose `.search/` directory will hold research results. Store the OpenRouter key with the setup command below. The key travels through standard input, not process arguments or configuration JSON:
|
|
223
224
|
|
|
224
225
|
```bash
|
|
225
226
|
read -r -s -p 'OpenRouter API key: ' OPENROUTER_API_KEY
|
|
226
227
|
printf '\n'
|
|
227
228
|
printf '%s\n' "$OPENROUTER_API_KEY" | \
|
|
228
|
-
npx -y --package @curio-data/mcp-intelli-search
|
|
229
|
+
npx -y --package @curio-data/mcp-intelli-search \
|
|
229
230
|
mcp-intelli-search setup
|
|
230
231
|
unset OPENROUTER_API_KEY
|
|
231
232
|
codex
|
|
@@ -287,6 +288,18 @@ Research collation receives only successful, non-empty page extractions, not the
|
|
|
287
288
|
|
|
288
289
|
Manual `intelli_collate` labels its evidence as caller-supplied extractions; it does not claim the server fetched those pages. Empty or duplicate source evidence is rejected. The optional `searchSummary` input remains accepted for compatibility but does not supply synthesis evidence. Per-source relevance and contribution ratings are no longer model-generated. Read exact cache paths from the inventory; `Not cached` means no full-page file was supplied.
|
|
289
290
|
|
|
291
|
+
### Extraction Diagnostics
|
|
292
|
+
|
|
293
|
+
A completed research result can contain failed or incomplete sources. `details.pagesFailed` counts fetch failures; `details.extractionFailed` counts failures after a page was fetched. Inspect the failed-source list before relying on a report's coverage. A saved full-page link is provided only when that page was written to the cache. If pages were fetched but no extraction succeeds, the `extraction-failed` result returns the search summary and up to ten known failure reasons without writing a new report or saved pages. If every fetch fails, the separate `fetch-failed` result returns the search summary without a per-source reason list.
|
|
294
|
+
|
|
295
|
+
Nonempty output whose reported token count reaches the configured cap is kept with a truncation warning. `intelli_extract` returns `details.truncated`; research and manual collation mark affected sources in the Source Assessment inventory. A synthesis warning applies to the summary itself. Missing usage does not establish completeness, and `outcome: "completed"` does not guarantee complete source coverage.
|
|
296
|
+
|
|
297
|
+
For a budget-exhaustion diagnostic, review `extractionMaxTokens` for page extraction or `collationMaxTokens` for synthesis. On reasoning models, the budget includes reasoning as well as visible text. Increase the relevant cap within the model's output and context limits, or select a model with a smaller reasoning requirement. Lowering reasoning effort did not prevent exhaustion on the serving route identified in the investigation; it is not a guaranteed remedy. Read an available saved page before repeating paid research. Raising `llmTimeoutMs` addresses timer expiry, not an exhausted token budget or a host deadline.
|
|
298
|
+
|
|
299
|
+
A higher completion cap can permit more billable output and increase OpenRouter's in-flight credit reservation. The [Cost](#cost) estimate is a planning figure, not a spending limit; raising a cap does not mean every call consumes it.
|
|
300
|
+
|
|
301
|
+
Research sidecars, when enabled, record extraction-budget failures, possible truncation, available serving routes and cache-judge degradation. See [Telemetry Sidecar](https://github.com/Curio-Data/pi-intelli-search/blob/main/docs/ARCHITECTURE.md#telemetry-sidecar) for field definitions and absence semantics. Standalone extraction and collation do not write this sidecar.
|
|
302
|
+
|
|
290
303
|
<a id="quick-start"></a>
|
|
291
304
|
## Usage Examples
|
|
292
305
|
|
|
@@ -341,7 +354,7 @@ The illustration shows the native pipeline with the model configuration at its c
|
|
|
341
354
|
|
|
342
355
|
The search stage merges text links with harvested citation annotations before selecting pages (see [Source Harvesting from Citations](https://github.com/Curio-Data/pi-intelli-search/blob/main/README.md#source-harvesting-from-citations)). Each page is dual-fetched (HTML via Defuddle versus Markdown endpoint) and scored for quality. Per-page extraction (guided by `focusPrompt`) compresses ≈50K chars to ≈3-5K of query-relevant content before collation, keeping the total context manageable (≈30-50K for 10 pages).
|
|
343
356
|
|
|
344
|
-
Completed runs and the degraded exits recorded in `outcome` (`no-links`, `fetch-failed`, `extraction-failed`) attempt to write a local-only `meta.json` telemetry sidecar into the cache directory (see [Cache Structure](#cache-structure)). Set `"disableTelemetry": true` in the native `pi-intelli-search` namespace or the MCP `tuning` object to suppress it.
|
|
357
|
+
Completed runs and the degraded exits recorded in `outcome` (`no-links`, `fetch-failed`, `extraction-failed`) attempt to write a local-only `meta.json` telemetry sidecar into the cache directory (see [Cache Structure](#cache-structure)). Set `"disableTelemetry": true` in the native `pi-intelli-search` namespace or the MCP `tuning` object to suppress it. Budget diagnostics and their absence semantics are defined in [Telemetry Sidecar](https://github.com/Curio-Data/pi-intelli-search/blob/main/docs/ARCHITECTURE.md#telemetry-sidecar); the [script guide](https://github.com/Curio-Data/pi-intelli-search/blob/main/scripts/README.md#reported-metrics) explains the available aggregates.
|
|
345
358
|
|
|
346
359
|
See [docs/ARCHITECTURE.md](https://github.com/Curio-Data/pi-intelli-search/blob/main/docs/ARCHITECTURE.md) for detailed design decisions.
|
|
347
360
|
|
|
@@ -422,10 +435,10 @@ Unspecified tuning comes from the canonical [shared defaults](https://github.com
|
|
|
422
435
|
| `maxUrls` | `20`: hard cap on research pages | Integer from 1 to 100 |
|
|
423
436
|
| `extractMaxChars` | `150000`: per-page extraction input character limit | Integer from 1 to 2,000,000 |
|
|
424
437
|
| `fetchTimeoutMs` | `20000`: page-fetch timeout in milliseconds | Integer from 1 to 600,000 |
|
|
425
|
-
| `llmTimeoutMs` | `
|
|
438
|
+
| `llmTimeoutMs` | `120000`: application timeout per model call in milliseconds | Integer from 1 to 600,000 |
|
|
426
439
|
| `fetchConcurrency` | `4`: simultaneous page fetches | Integer from 1 to 32 |
|
|
427
440
|
| `extractionConcurrency` | `4`: simultaneous per-page extractions | Integer from 1 to 32 |
|
|
428
|
-
| `extractionMaxTokens` | `
|
|
441
|
+
| `extractionMaxTokens` | `8000`: per-page output-token limit (includes hidden reasoning tokens) | Integer from 16 to 128,000 |
|
|
429
442
|
| `collationMaxTokens` | `4000`: synthesis output-token limit | Integer from 16 to 128,000 |
|
|
430
443
|
| `llmRetryAttempts` | `3`: model-call attempts, including the first | Integer from 1 to 10 |
|
|
431
444
|
| `searchRetryAttempts` | `2`: search attempts after a valid response with no usable links, including the first | Integer from 1 to 10 |
|
|
@@ -446,7 +459,7 @@ Unspecified tuning comes from the canonical [shared defaults](https://github.com
|
|
|
446
459
|
|
|
447
460
|
**Reasoning:** The adapter sends reasoning fields only when the catalogue advertises reasoning support; non-reasoning models receive neither effort nor exclusion fields.
|
|
448
461
|
|
|
449
|
-
**Output Budget:** Empty output
|
|
462
|
+
**Output Budget:** Empty extraction output fails instead of becoming successful evidence; empty synthesis is rejected before a completed report is written. When reported output reaches the configured stage cap, nonempty output is retained with a truncation warning. Standalone `intelli_extract` returns `details.truncated`; pass it into manual `intelli_collate` to preserve the warning in its inventory and report. A capped synthesis is warned about in the report and tool result. Only `intelli_research` writes the telemetry sidecar, and only when enabled. Missing usage does not establish completeness. See [Extraction Diagnostics](#extraction-diagnostics) for recovery and the limits of these signals.
|
|
450
463
|
|
|
451
464
|
### Direct Engine Verification
|
|
452
465
|
|
|
@@ -487,7 +500,7 @@ This example incurs inference and search charges when run with a real credential
|
|
|
487
500
|
|
|
488
501
|
Standalone validation rejects unknown argument keys, empty queries, nonpositive or fractional `maxUrls`, arrays exceeding 100 entries, strings exceeding 2,000,000 characters and unsupported extraction statuses. Most of these standalone validation rules are separate from the native tool schemas; the exception is the rejection of `maxUrls` values below 1, which the shared core schema also declares as `minimum: 1`, so it fails schema validation before the runtime's specific message. Positive fractional values at or above 1 still fail the standalone integer check.
|
|
489
502
|
|
|
490
|
-
For manual extraction followed by collation, construct each collation item from the original `url` and `title`, `result.details.extraction` and `result.details.sourceType`, plus an explicit `
|
|
503
|
+
For manual extraction followed by collation, construct each successful collation item from the original `url` and `title`, `result.details.extraction` and `result.details.sourceType`, plus `status: "success"`. Copy `result.details.truncated` into the item's optional `truncated` field when present. If extraction fails, retain that source as a failed item with an empty `extraction`, an explicit `sourceType` such as `unknown`, `status: "failed"` and an optional bounded `error` string describing the failure. Failed items are listed for coverage but do not enter synthesis. Do not forward the entire extraction `details` object: its `currentness` field is not a collation input. Supply actual content in `fullPages` if the full-page file must be cached.
|
|
491
504
|
|
|
492
505
|
`mcp-intelli-search --help` and `--version` need no configuration. `--check-config` validates explicit configuration and workspace syntax without credentials or inference, returning exit status 0 for valid configuration and 1 for invalid input. Neither starts a protocol connection. `loadConfig()` throws an exported `ConfigurationError` for file defects, with a `reason` of `missing`, `unreadable`, `invalid-json` or `invalid`; workspace failures remain separate. JSON syntax diagnostics include a location without echoing file contents. The runtime entrypoint is experimental and has no published TypeScript declaration contract. Execution failures expose a safe `StandaloneError.code`: `INVALID_ARGUMENTS`, `CONFIGURATION`, `WORKSPACE`, `PROVIDER`, `OPERATION` or `CANCELLED`. Cancellation uses the `AbortError` name. Raw provider causes are deliberately not retained. Some shared operations wrap provider exceptions, which become `OPERATION` errors; protocol mapping must not depend on exact diagnostic strings.
|
|
493
506
|
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
resolveCredential,
|
|
5
5
|
validateCacheDir,
|
|
6
6
|
validateDomains
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-LXLEWIYT.js";
|
|
8
8
|
|
|
9
9
|
// packages/mcp/src/runtime.ts
|
|
10
10
|
import { Check } from "typebox/value";
|
|
@@ -149,6 +149,10 @@ async function withMuzzledConsole(fn, muzzleTags) {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
// src/core/util.ts
|
|
152
|
+
function budgetExhausted(usage2, maxTokens) {
|
|
153
|
+
if (usage2?.output == null || maxTokens == null) return false;
|
|
154
|
+
return usage2.output >= maxTokens;
|
|
155
|
+
}
|
|
152
156
|
function throwIfAborted(signal) {
|
|
153
157
|
if (signal?.aborted) throw new DOMException("Aborted", "AbortError");
|
|
154
158
|
}
|
|
@@ -267,7 +271,14 @@ var NON_RETRYABLE_LIMIT_PATTERNS = [
|
|
|
267
271
|
"billing",
|
|
268
272
|
// Sign in with ChatGPT: the subscription's shared usage limit, which resets
|
|
269
273
|
// after hours rather than seconds.
|
|
270
|
-
"subscription_sharing_usage_limit_exceeded"
|
|
274
|
+
"subscription_sharing_usage_limit_exceeded",
|
|
275
|
+
// Sign in with ChatGPT on a ChatGPT Business plan: a usage limit set by the
|
|
276
|
+
// workspace admin. Only the admin can raise it.
|
|
277
|
+
"subscription_sharing_workplace_individual_usage_limit_exceeded",
|
|
278
|
+
// Zhipu/Z.ai (open.bigmodel.cn) error code 1308: the plan's usage limit is
|
|
279
|
+
// reached, sent as HTTP 429. It resets after hours, not seconds (pi #11537).
|
|
280
|
+
// The lookahead keeps a different code such as 13089 from matching.
|
|
281
|
+
'"code"\\s*:\\s*"?1308(?![0-9])'
|
|
271
282
|
];
|
|
272
283
|
var RETRYABLE_PATTERNS = [
|
|
273
284
|
// Generic provider load, HTTP status, and server-side transient failures.
|
|
@@ -278,12 +289,13 @@ var RETRYABLE_PATTERNS = [
|
|
|
278
289
|
"model is at capacity",
|
|
279
290
|
"rate.?limit",
|
|
280
291
|
"too many requests",
|
|
281
|
-
//
|
|
282
|
-
//
|
|
283
|
-
//
|
|
284
|
-
//
|
|
285
|
-
//
|
|
286
|
-
"
|
|
292
|
+
// Status codes, upstream's verbatim form: the lookarounds reject codes
|
|
293
|
+
// embedded in digits or letters (request ids, token counts such as
|
|
294
|
+
// "150293 tokens") while still matching delimited ones. Underscore-adjacent
|
|
295
|
+
// tokens ("HTTP_502_BAD_GATEWAY") match too; that is upstream's accepted
|
|
296
|
+
// trade. This policy keeps no context-overflow pre-filter, so a delimited
|
|
297
|
+
// count such as "128,500 tokens" can still retry (known limitation).
|
|
298
|
+
"(?<![a-z0-9])(?:429|500|502|503|504|520|524)(?![a-z0-9])",
|
|
287
299
|
// Also matches "The service is temporarily unavailable" (pi #10965).
|
|
288
300
|
"service.?(?:is.?)?(?:temporarily.?)?unavailable",
|
|
289
301
|
"server.?error",
|
|
@@ -296,6 +308,12 @@ var RETRYABLE_PATTERNS = [
|
|
|
296
308
|
// Gateway failure relaying the upstream response stream, sent as an OpenAI
|
|
297
309
|
// Responses `response.failed` event without an error code (pi #10920).
|
|
298
310
|
"unable to forward upstream",
|
|
311
|
+
// Other gateway upstream failures relayed as `response.failed` error codes
|
|
312
|
+
// (pi #10920).
|
|
313
|
+
"upstream.?request.?failed",
|
|
314
|
+
"upstream_stream_read_error",
|
|
315
|
+
"stream was interrupted",
|
|
316
|
+
"http/?2 stream failed",
|
|
299
317
|
// Network, proxy, and fetch transport failures, including raw-fetch failures
|
|
300
318
|
// such as "upstream connect", "connection refused", and "reset before
|
|
301
319
|
// headers" (pi #733), plus OpenRouter connection drops (pi #3317).
|
|
@@ -305,6 +323,9 @@ var RETRYABLE_PATTERNS = [
|
|
|
305
323
|
"connection.?lost",
|
|
306
324
|
"other side closed",
|
|
307
325
|
"fetch failed",
|
|
326
|
+
// node-fetch system errors, e.g. the Google ADC OAuth token refresh used by
|
|
327
|
+
// google-vertex. The reason is often empty (pi #10996).
|
|
328
|
+
"request to \\S+ failed, reason:",
|
|
308
329
|
"getaddrinfo",
|
|
309
330
|
"ENOTFOUND",
|
|
310
331
|
"EAI_AGAIN",
|
|
@@ -337,6 +358,10 @@ var RETRYABLE_PATTERNS = [
|
|
|
337
358
|
"stream ended before message_stop",
|
|
338
359
|
"stream ended before a terminal response event",
|
|
339
360
|
"http2 request did not get a response",
|
|
361
|
+
// Codex CLI mid-stream disconnect, relayed by proxies that wrap the Codex
|
|
362
|
+
// CLI, e.g. "stream disconnected before completion: stream closed before
|
|
363
|
+
// response.completed" (pi #11057).
|
|
364
|
+
"stream disconnected before completion",
|
|
340
365
|
// Node ERR_HTTP2_STREAM_CANCEL: the HTTP/2 session died before the request
|
|
341
366
|
// was sent, for example after the Bedrock SDK's session timeout (pi #10379).
|
|
342
367
|
"pending stream has been canceled",
|
|
@@ -693,7 +718,7 @@ ${summary}
|
|
|
693
718
|
const extractionFile = identity2.extractionFileFor(source.url);
|
|
694
719
|
if (!extractionFile) invalid("an evidence source has no extraction file");
|
|
695
720
|
const fullPage = identity2.sourceFileFor(source.url);
|
|
696
|
-
result += `| S${index + 1} | ${cell(source.url)} | ${cell(source.sourceType)} | ${evidence === "fetched" ? "Fetched and extracted" : "Caller-supplied extraction"} | ${cell(`${cachePath}/extractions/${extractionFile}`)} | ${fullPage ? cell(`${cachePath}/sources/${fullPage}`) : "Not cached"} |
|
|
721
|
+
result += `| S${index + 1} | ${cell(source.url)} | ${cell(source.sourceType)}${source.truncated ? " \u26A0 truncated" : ""} | ${evidence === "fetched" ? "Fetched and extracted" : "Caller-supplied extraction"} | ${cell(`${cachePath}/extractions/${extractionFile}`)} | ${fullPage ? cell(`${cachePath}/sources/${fullPage}`) : "Not cached"} |
|
|
697
722
|
`;
|
|
698
723
|
}
|
|
699
724
|
return result.trimEnd();
|
|
@@ -762,7 +787,7 @@ function buildCollationMessage(query, _cachePath, _searchSummary, succeededExtra
|
|
|
762
787
|
}))
|
|
763
788
|
}, null, 2);
|
|
764
789
|
}
|
|
765
|
-
function formatCacheAppendix(cachePath, succeeded, failed) {
|
|
790
|
+
function formatCacheAppendix(cachePath, succeeded, failed, failedEntries = [], truncatedCount = 0) {
|
|
766
791
|
let out = `
|
|
767
792
|
|
|
768
793
|
---
|
|
@@ -771,13 +796,25 @@ function formatCacheAppendix(cachePath, succeeded, failed) {
|
|
|
771
796
|
`;
|
|
772
797
|
out += `**Report**: \`${cachePath}/report.md\`
|
|
773
798
|
`;
|
|
774
|
-
out += `**Sources**: ${succeeded} succeeded, ${failed} failed
|
|
799
|
+
out += `**Sources**: ${succeeded} succeeded${truncatedCount > 0 ? ` (${truncatedCount} truncated at the output cap)` : ""}, ${failed} failed
|
|
775
800
|
`;
|
|
776
801
|
out += `
|
|
777
802
|
- Read the report: \`read ${cachePath}/report.md\`
|
|
778
803
|
`;
|
|
804
|
+
if (failedEntries.length > 0) {
|
|
805
|
+
out += `
|
|
806
|
+
**Failed Sources**:
|
|
807
|
+
`;
|
|
808
|
+
for (const entry of failedEntries) {
|
|
809
|
+
out += `- ${entry.url}`;
|
|
810
|
+
if (entry.error) out += `: ${entry.error}`;
|
|
811
|
+
if (entry.sourceFile) out += ` (full page saved: \`${cachePath}/${entry.sourceFile}\`)`;
|
|
812
|
+
out += `
|
|
813
|
+
`;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
779
816
|
out += `
|
|
780
|
-
Choose exact extraction and full-page paths from the Source
|
|
817
|
+
Choose exact extraction and full-page paths from the Source Assessment above. Not cached means no full-page file exists for that source.
|
|
781
818
|
`;
|
|
782
819
|
return out;
|
|
783
820
|
}
|
|
@@ -847,7 +884,7 @@ async function extract(params, context) {
|
|
|
847
884
|
params.focusPrompt,
|
|
848
885
|
settings.extractMaxChars
|
|
849
886
|
);
|
|
850
|
-
const { text: extraction } = await models.complete({
|
|
887
|
+
const { text: extraction, usage: usage2 } = await models.complete({
|
|
851
888
|
model: extractConfig,
|
|
852
889
|
systemPrompt: EXTRACTION_SYSTEM_PROMPT,
|
|
853
890
|
userMessage,
|
|
@@ -855,15 +892,26 @@ async function extract(params, context) {
|
|
|
855
892
|
signal
|
|
856
893
|
});
|
|
857
894
|
throwIfAborted(signal);
|
|
895
|
+
if (!extraction.trim()) {
|
|
896
|
+
const exhausted = budgetExhausted(usage2, settings.extractionMaxTokens);
|
|
897
|
+
const usageNote = usage2?.output != null ? ` (${usage2.output}/${settings.extractionMaxTokens} output tokens` + (usage2.reasoning ? `, ${usage2.reasoning} hidden reasoning` : "") + ")" : "";
|
|
898
|
+
throw new Error(
|
|
899
|
+
exhausted ? `Extraction returned no visible text${usageNote}; the output budget was exhausted. Review extractionMaxTokens or choose a model with a smaller reasoning requirement.` : `Extraction returned no visible text${usageNote}. The output budget was not reported exhausted; inspect the model response before retrying.`
|
|
900
|
+
);
|
|
901
|
+
}
|
|
858
902
|
const firstLine = extraction.split("\n")[0] ?? "";
|
|
859
903
|
const sourceType = inferSourceType(firstLine);
|
|
860
904
|
const currentness = inferCurrentness(firstLine);
|
|
905
|
+
const truncated = budgetExhausted(usage2, settings.extractionMaxTokens);
|
|
906
|
+
const truncationNote = truncated ? `
|
|
907
|
+
|
|
908
|
+
> \u26A0 Extraction output reached extractionMaxTokens (${settings.extractionMaxTokens}); the text may be cut off mid-sentence.` : "";
|
|
861
909
|
return {
|
|
862
910
|
text: `### Extraction: ${params.title}
|
|
863
911
|
|
|
864
|
-
${extraction}`,
|
|
912
|
+
${extraction}${truncationNote}`,
|
|
865
913
|
outcome: "completed",
|
|
866
|
-
details: { url: params.url, extraction, sourceType, currentness }
|
|
914
|
+
details: { url: params.url, extraction, sourceType, currentness, ...truncated ? { truncated: true } : {} }
|
|
867
915
|
};
|
|
868
916
|
}
|
|
869
917
|
|
|
@@ -1149,7 +1197,7 @@ async function writeReportFile(cachePath, query, collation, extractions, pages,
|
|
|
1149
1197
|
for (const [i, ext] of succeeded.entries()) {
|
|
1150
1198
|
const extractionFile = identity2.extractionFileFor(ext.url);
|
|
1151
1199
|
const sourceFile = identity2.sourceFileFor(ext.url);
|
|
1152
|
-
report += `| ${i + 1} | ${ext.url} | ${ext.sourceType} | ${extractionFile ? `extractions/${extractionFile}` : "Not cached"} | ${sourceFile ? `sources/${sourceFile}` : "Not cached"} |
|
|
1200
|
+
report += `| ${i + 1} | ${ext.url} | ${ext.sourceType}${ext.truncated ? " (\u26A0 truncated at the output cap)" : ""} | ${extractionFile ? `extractions/${extractionFile}` : "Not cached"} | ${sourceFile ? `sources/${sourceFile}` : "Not cached"} |
|
|
1153
1201
|
`;
|
|
1154
1202
|
}
|
|
1155
1203
|
}
|
|
@@ -1159,8 +1207,10 @@ async function writeReportFile(cachePath, query, collation, extractions, pages,
|
|
|
1159
1207
|
|
|
1160
1208
|
`;
|
|
1161
1209
|
for (const entry of blocked) {
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1210
|
+
const fetchError = pages.find((page) => page.url === entry.url)?.error;
|
|
1211
|
+
const reason = entry.error ?? fetchError ?? (entry.status === "blocked" ? "Source marked blocked" : "Extraction failed");
|
|
1212
|
+
const savedSource = identity2.sourceFileFor(entry.url);
|
|
1213
|
+
report += `- ${entry.url}: ${reason}${savedSource ? ` (full page saved: sources/${savedSource})` : ""}
|
|
1164
1214
|
`;
|
|
1165
1215
|
}
|
|
1166
1216
|
}
|
|
@@ -1209,6 +1259,15 @@ function formatIndexForJudge(index, excludeSlug) {
|
|
|
1209
1259
|
if (entries.length === 0) return "No previous searches.";
|
|
1210
1260
|
return entries.map((e, i) => `${i + 1}. "${e.query}" (slug: ${e.slug}, searched: ${e.timestamp})`).join("\n");
|
|
1211
1261
|
}
|
|
1262
|
+
function isWellFormedJudgeResponse(response) {
|
|
1263
|
+
const jsonMatch = response.match(/\[[\s\S]*\]/);
|
|
1264
|
+
if (!jsonMatch) return false;
|
|
1265
|
+
try {
|
|
1266
|
+
return Array.isArray(JSON.parse(jsonMatch[0]));
|
|
1267
|
+
} catch {
|
|
1268
|
+
return false;
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1212
1271
|
function parseJudgeResponse(response, index, excludeSlug) {
|
|
1213
1272
|
const candidates = judgeCandidates(index, excludeSlug);
|
|
1214
1273
|
const jsonMatch = response.match(/\[[\s\S]*\]/);
|
|
@@ -1270,7 +1329,9 @@ async function collate(params, context) {
|
|
|
1270
1329
|
extraction: e.extraction,
|
|
1271
1330
|
sourceType: e.sourceType,
|
|
1272
1331
|
currentness: "undated",
|
|
1273
|
-
status: e.status === "success" && !e.extraction.trim() ? "failed" : e.status
|
|
1332
|
+
status: e.status === "success" && !e.extraction.trim() ? "failed" : e.status,
|
|
1333
|
+
...e.truncated ? { truncated: true } : {},
|
|
1334
|
+
...e.error ? { error: e.error } : {}
|
|
1274
1335
|
}));
|
|
1275
1336
|
const succeeded = evidenceExtractions(extractResults);
|
|
1276
1337
|
const blocked = extractResults.filter((e) => e.status !== "success");
|
|
@@ -1289,14 +1350,19 @@ async function collate(params, context) {
|
|
|
1289
1350
|
succeeded,
|
|
1290
1351
|
identity2
|
|
1291
1352
|
);
|
|
1292
|
-
const { text } = await models.complete({
|
|
1353
|
+
const { text, usage: usage2 } = await models.complete({
|
|
1293
1354
|
model: collateConfig,
|
|
1294
1355
|
systemPrompt: COLLATION_SYSTEM_PROMPT,
|
|
1295
1356
|
userMessage,
|
|
1296
1357
|
maxTokens: settings.collationMaxTokens,
|
|
1297
1358
|
signal
|
|
1298
1359
|
});
|
|
1299
|
-
|
|
1360
|
+
let collation = finalizeCollation(text, cachePath, succeeded, identity2, "supplied");
|
|
1361
|
+
if (budgetExhausted(usage2, settings.collationMaxTokens)) {
|
|
1362
|
+
collation += `
|
|
1363
|
+
|
|
1364
|
+
> \u26A0 Collation output reached collationMaxTokens (${settings.collationMaxTokens}); the synthesis may be cut off mid-sentence. Raise collationMaxTokens or re-run if completeness matters.`;
|
|
1365
|
+
}
|
|
1300
1366
|
await withLock(
|
|
1301
1367
|
cacheLockDir(physicalPath),
|
|
1302
1368
|
async () => {
|
|
@@ -1332,8 +1398,14 @@ async function collate(params, context) {
|
|
|
1332
1398
|
},
|
|
1333
1399
|
signal
|
|
1334
1400
|
);
|
|
1401
|
+
const failedEntries = extractResults.filter((e) => e.status !== "success").map((e) => ({
|
|
1402
|
+
url: e.url,
|
|
1403
|
+
...e.error ? { error: e.error } : {},
|
|
1404
|
+
...identity2.sourceFileFor(e.url) ? { sourceFile: `sources/${identity2.sourceFileFor(e.url)}` } : {}
|
|
1405
|
+
}));
|
|
1406
|
+
const truncatedCount = succeeded.filter((e) => e.truncated).length;
|
|
1335
1407
|
return {
|
|
1336
|
-
text: collation + formatCacheAppendix(cachePath, succeeded.length, blocked.length),
|
|
1408
|
+
text: collation + formatCacheAppendix(cachePath, succeeded.length, blocked.length, failedEntries, truncatedCount),
|
|
1337
1409
|
outcome: "completed",
|
|
1338
1410
|
details: { cachePath, sourcesFetched: succeeded.length + blocked.length }
|
|
1339
1411
|
};
|
|
@@ -1838,10 +1910,18 @@ ${search2.searchResult}`,
|
|
|
1838
1910
|
const fetchFailed = extracted.blockedExtractions.length;
|
|
1839
1911
|
const extractFailed = extracted.extractions.filter((e) => e.status === "failed").length;
|
|
1840
1912
|
const reason = fetchFailed > 0 ? `${fetchFailed} page(s) failed to fetch` : `${extractFailed} extraction(s) failed`;
|
|
1913
|
+
const failureLines = allExtractions.filter((e) => e.status !== "success" && (e.error || fetched.pages.find((pg) => pg.url === e.url)?.error)).map((e) => {
|
|
1914
|
+
const detail = e.error ?? fetched.pages.find((pg) => pg.url === e.url)?.error;
|
|
1915
|
+
return `- ${e.url}: ${String(detail).replace(/\s+/g, " ").slice(0, 200)}`;
|
|
1916
|
+
}).slice(0, 10).join("\n");
|
|
1917
|
+
const failureBlock = failureLines ? `
|
|
1918
|
+
|
|
1919
|
+
Failed Sources (up to 10 known reasons):
|
|
1920
|
+
${failureLines}` : "";
|
|
1841
1921
|
return degradedReturn(
|
|
1842
1922
|
p,
|
|
1843
1923
|
"extraction-failed",
|
|
1844
|
-
`${reason}. No content was extracted
|
|
1924
|
+
`${reason}. No content was extracted.${failureBlock}
|
|
1845
1925
|
|
|
1846
1926
|
Search summary:
|
|
1847
1927
|
${search2.searchResult}`,
|
|
@@ -1849,7 +1929,8 @@ ${search2.searchResult}`,
|
|
|
1849
1929
|
cachePath: "",
|
|
1850
1930
|
urlsSearched: search2.urls.length,
|
|
1851
1931
|
pagesFetched: fetched.successPages.length,
|
|
1852
|
-
pagesFailed: fetched.pages.length - fetched.successPages.length
|
|
1932
|
+
pagesFailed: fetched.pages.length - fetched.successPages.length,
|
|
1933
|
+
extractionFailed: extractFailed
|
|
1853
1934
|
}
|
|
1854
1935
|
);
|
|
1855
1936
|
}
|
|
@@ -1874,7 +1955,28 @@ ${search2.searchResult}`,
|
|
|
1874
1955
|
throwIfAborted(p.signal);
|
|
1875
1956
|
await writeLockedTelemetry(p, "completed");
|
|
1876
1957
|
const failedCount = fetched.pages.length - fetched.successPages.length;
|
|
1877
|
-
const
|
|
1958
|
+
const extractionFailures = allExtractions.filter((e) => e.status === "failed").length;
|
|
1959
|
+
const truncatedCount = succeededExtractions.filter((e) => e.truncated).length;
|
|
1960
|
+
const failedEntries = allExtractions.filter((e) => e.status !== "success").map((e) => {
|
|
1961
|
+
const savedSource = identity2.sourceFileFor(e.url);
|
|
1962
|
+
return {
|
|
1963
|
+
url: e.url,
|
|
1964
|
+
// Extraction reason when the extract call failed; fetch error when
|
|
1965
|
+
// the page never made it that far (blocked entries carry none).
|
|
1966
|
+
...e.error ? { error: e.error } : {},
|
|
1967
|
+
...fetched.pages.find((page) => page.url === e.url)?.error ? { error: fetched.pages.find((page) => page.url === e.url).error.slice(0, 300) } : {},
|
|
1968
|
+
// The full page stays on disk even when extraction failed; pointing
|
|
1969
|
+
// the agent at it recovers work that was already paid for.
|
|
1970
|
+
...savedSource ? { sourceFile: `sources/${savedSource}` } : {}
|
|
1971
|
+
};
|
|
1972
|
+
});
|
|
1973
|
+
const result = collation + formatCacheAppendix(
|
|
1974
|
+
p.cachePath,
|
|
1975
|
+
succeededExtractions.length,
|
|
1976
|
+
allExtractions.length - succeededExtractions.length,
|
|
1977
|
+
failedEntries,
|
|
1978
|
+
truncatedCount
|
|
1979
|
+
) + suggestionsAppendix;
|
|
1878
1980
|
return {
|
|
1879
1981
|
text: result,
|
|
1880
1982
|
outcome: "completed",
|
|
@@ -1882,7 +1984,10 @@ ${search2.searchResult}`,
|
|
|
1882
1984
|
cachePath: p.cachePath,
|
|
1883
1985
|
urlsSearched: search2.urls.length,
|
|
1884
1986
|
pagesFetched: fetched.successPages.length,
|
|
1885
|
-
pagesFailed: failedCount
|
|
1987
|
+
pagesFailed: failedCount,
|
|
1988
|
+
// Extraction failures only (status "failed"); pagesFailed counts fetch
|
|
1989
|
+
// failures (status "blocked"), so the two never double-count a page.
|
|
1990
|
+
extractionFailed: extractionFailures
|
|
1886
1991
|
}
|
|
1887
1992
|
};
|
|
1888
1993
|
}
|
|
@@ -2017,6 +2122,14 @@ async function runExtractStage(p, successPages, pages) {
|
|
|
2017
2122
|
}));
|
|
2018
2123
|
const succeededExtr = extractions.filter((e) => e.status === "success");
|
|
2019
2124
|
const failedExtr = extractions.length - succeededExtr.length;
|
|
2125
|
+
let budgetExhaustedFailures = 0;
|
|
2126
|
+
for (const e of extractions) {
|
|
2127
|
+
if (e.status === "failed" && e.failureKind === "budget") budgetExhaustedFailures += 1;
|
|
2128
|
+
}
|
|
2129
|
+
const truncatedCount = succeededExtr.filter((e) => e.truncated).length;
|
|
2130
|
+
const routeProviders = new Set(
|
|
2131
|
+
extractions.filter((e) => e.routeProvider).map((e) => e.routeProvider)
|
|
2132
|
+
);
|
|
2020
2133
|
const totalIn = successPages.reduce(
|
|
2021
2134
|
(sum, pg) => sum + Math.min(pg.content.length, p.settings.extractMaxChars),
|
|
2022
2135
|
0
|
|
@@ -2027,7 +2140,15 @@ async function runExtractStage(p, successPages, pages) {
|
|
|
2027
2140
|
succeeded: succeededExtr.length,
|
|
2028
2141
|
failed: failedExtr,
|
|
2029
2142
|
totalInputCharsApprox: totalIn,
|
|
2030
|
-
totalOutputChars: totalOut
|
|
2143
|
+
totalOutputChars: totalOut,
|
|
2144
|
+
...truncatedCount > 0 ? { truncated: truncatedCount } : {},
|
|
2145
|
+
...failedExtr > 0 ? {
|
|
2146
|
+
failureReasons: {
|
|
2147
|
+
budgetExhausted: budgetExhaustedFailures,
|
|
2148
|
+
other: failedExtr - budgetExhaustedFailures
|
|
2149
|
+
}
|
|
2150
|
+
} : {},
|
|
2151
|
+
...routeProviders.size === 1 ? { provider: [...routeProviders][0] } : {}
|
|
2031
2152
|
});
|
|
2032
2153
|
return { extractions, blockedExtractions };
|
|
2033
2154
|
}
|
|
@@ -2040,7 +2161,7 @@ async function runCollateStage(p, searchResult, succeededExtractions, identity2)
|
|
|
2040
2161
|
identity2
|
|
2041
2162
|
);
|
|
2042
2163
|
throwIfAborted(p.signal);
|
|
2043
|
-
const { text } = await p.models.complete({
|
|
2164
|
+
const { text, usage: usage2, routeProvider } = await p.models.complete({
|
|
2044
2165
|
model: p.collateConfig,
|
|
2045
2166
|
systemPrompt: COLLATION_SYSTEM_PROMPT,
|
|
2046
2167
|
userMessage: collationUserMsg,
|
|
@@ -2050,10 +2171,18 @@ async function runCollateStage(p, searchResult, succeededExtractions, identity2)
|
|
|
2050
2171
|
timeoutMs: p.settings.llmTimeoutMs,
|
|
2051
2172
|
onRetryNotice: (msg) => p.onProgress?.(progress("collate", msg))
|
|
2052
2173
|
});
|
|
2053
|
-
|
|
2174
|
+
let collation = finalizeCollation(text, p.cachePath, succeededExtractions, identity2, "fetched");
|
|
2175
|
+
const collateTruncated = budgetExhausted(usage2, p.settings.collationMaxTokens);
|
|
2176
|
+
if (collateTruncated) {
|
|
2177
|
+
collation += `
|
|
2178
|
+
|
|
2179
|
+
> \u26A0 Collation output reached collationMaxTokens (${p.settings.collationMaxTokens}); the synthesis may be cut off mid-sentence. Raise collationMaxTokens or re-run if completeness matters.`;
|
|
2180
|
+
}
|
|
2054
2181
|
p.tel?.recordCollate({
|
|
2055
2182
|
model: `${p.collateConfig.provider}/${p.collateConfig.model}`,
|
|
2056
|
-
summaryChars: text.trim().length
|
|
2183
|
+
summaryChars: text.trim().length,
|
|
2184
|
+
...collateTruncated ? { truncated: true } : {},
|
|
2185
|
+
...routeProvider ? { provider: routeProvider } : {}
|
|
2057
2186
|
});
|
|
2058
2187
|
return collation;
|
|
2059
2188
|
}
|
|
@@ -2151,9 +2280,12 @@ async function runCacheSuggestStage(p) {
|
|
|
2151
2280
|
let cacheSuggestRan = false;
|
|
2152
2281
|
let cacheSuggestSurfaced = 0;
|
|
2153
2282
|
let cacheSuggestSlugs = [];
|
|
2283
|
+
let cacheSuggestDegraded;
|
|
2284
|
+
let judgeAttempted = false;
|
|
2154
2285
|
try {
|
|
2155
2286
|
const index = await readIndex(p.paths.cacheRoot);
|
|
2156
2287
|
if (index.searches.some((e) => e.slug !== currentSlug)) {
|
|
2288
|
+
judgeAttempted = true;
|
|
2157
2289
|
const indexText = formatIndexForJudge(index, currentSlug);
|
|
2158
2290
|
const judgeUserMsg = `Current query: "${p.params.query}"
|
|
2159
2291
|
|
|
@@ -2163,12 +2295,18 @@ ${indexText}`;
|
|
|
2163
2295
|
model: p.extractConfig,
|
|
2164
2296
|
systemPrompt: CACHE_SUGGEST_PROMPT,
|
|
2165
2297
|
userMessage: judgeUserMsg,
|
|
2166
|
-
maxTokens:
|
|
2298
|
+
maxTokens: 2e3,
|
|
2167
2299
|
signal: p.signal,
|
|
2168
2300
|
retry: p.retry,
|
|
2169
2301
|
timeoutMs: p.settings.llmTimeoutMs,
|
|
2170
2302
|
onRetryNotice: (msg) => p.onProgress?.(progress("cache", msg))
|
|
2171
2303
|
});
|
|
2304
|
+
if (!judgeResponse.trim() || !isWellFormedJudgeResponse(judgeResponse)) {
|
|
2305
|
+
cacheSuggestDegraded = true;
|
|
2306
|
+
p.logger.error(
|
|
2307
|
+
`Cache suggest judge returned ${judgeResponse.trim() ? "an unparseable" : "an empty"} response; treating as zero matches`
|
|
2308
|
+
);
|
|
2309
|
+
}
|
|
2172
2310
|
const matches = parseJudgeResponse(judgeResponse, index, currentSlug);
|
|
2173
2311
|
cacheSuggestRan = true;
|
|
2174
2312
|
cacheSuggestSurfaced = matches.length;
|
|
@@ -2177,12 +2315,14 @@ ${indexText}`;
|
|
|
2177
2315
|
}
|
|
2178
2316
|
} catch (err) {
|
|
2179
2317
|
throwIfAborted(p.signal);
|
|
2318
|
+
if (judgeAttempted) cacheSuggestDegraded = true;
|
|
2180
2319
|
p.logger.error(`Cache suggest failed: ${errMsg(err)}`);
|
|
2181
2320
|
}
|
|
2182
2321
|
p.tel?.recordCacheSuggest({
|
|
2183
2322
|
ran: cacheSuggestRan,
|
|
2184
2323
|
surfaced: cacheSuggestSurfaced,
|
|
2185
|
-
slugs: cacheSuggestSlugs
|
|
2324
|
+
slugs: cacheSuggestSlugs,
|
|
2325
|
+
...cacheSuggestDegraded ? { degraded: true } : {}
|
|
2186
2326
|
});
|
|
2187
2327
|
return suggestionsAppendix;
|
|
2188
2328
|
}
|
|
@@ -2263,6 +2403,8 @@ async function writeTelemetrySidecar(logger, tel, cachePath, outcome) {
|
|
|
2263
2403
|
}
|
|
2264
2404
|
async function extractPage(p, page) {
|
|
2265
2405
|
throwIfAborted(p.signal);
|
|
2406
|
+
let exhausted;
|
|
2407
|
+
let routeProvider;
|
|
2266
2408
|
try {
|
|
2267
2409
|
const userMessage = buildExtractionMessage(
|
|
2268
2410
|
page.content,
|
|
@@ -2270,7 +2412,7 @@ async function extractPage(p, page) {
|
|
|
2270
2412
|
p.params.focusPrompt,
|
|
2271
2413
|
p.settings.extractMaxChars
|
|
2272
2414
|
);
|
|
2273
|
-
const
|
|
2415
|
+
const completion = await p.models.complete({
|
|
2274
2416
|
model: p.extractConfig,
|
|
2275
2417
|
systemPrompt: EXTRACTION_SYSTEM_PROMPT,
|
|
2276
2418
|
userMessage,
|
|
@@ -2280,7 +2422,15 @@ async function extractPage(p, page) {
|
|
|
2280
2422
|
timeoutMs: p.settings.llmTimeoutMs,
|
|
2281
2423
|
onRetryNotice: (msg) => p.onProgress?.(progress("extract", msg))
|
|
2282
2424
|
});
|
|
2283
|
-
|
|
2425
|
+
const { text: extraction, usage: usage2 } = completion;
|
|
2426
|
+
routeProvider = completion.routeProvider;
|
|
2427
|
+
exhausted = budgetExhausted(usage2, p.settings.extractionMaxTokens);
|
|
2428
|
+
if (!extraction.trim()) {
|
|
2429
|
+
const usageNote = usage2?.output != null ? ` (${usage2.output}/${p.settings.extractionMaxTokens} output tokens` + (usage2.reasoning ? `, ${usage2.reasoning} hidden reasoning` : "") + ")" : "";
|
|
2430
|
+
throw new Error(
|
|
2431
|
+
exhausted ? `Extraction returned no visible text${usageNote}; the output budget was exhausted. Review extractionMaxTokens or choose a model with a smaller reasoning requirement.` : `Extraction returned no visible text${usageNote}. The output budget was not reported exhausted; inspect the model response before retrying.`
|
|
2432
|
+
);
|
|
2433
|
+
}
|
|
2284
2434
|
const firstLine = extraction.split("\n")[0] ?? "";
|
|
2285
2435
|
return {
|
|
2286
2436
|
url: page.url,
|
|
@@ -2288,18 +2438,28 @@ async function extractPage(p, page) {
|
|
|
2288
2438
|
extraction,
|
|
2289
2439
|
sourceType: inferSourceType(firstLine),
|
|
2290
2440
|
currentness: inferCurrentness(firstLine),
|
|
2291
|
-
status: "success"
|
|
2441
|
+
status: "success",
|
|
2442
|
+
// Nonempty output cut off by the cap: kept, but flagged so the report
|
|
2443
|
+
// and telemetry can say so. Missing usage never flags.
|
|
2444
|
+
truncated: exhausted || void 0,
|
|
2445
|
+
...routeProvider ? { routeProvider } : {}
|
|
2292
2446
|
};
|
|
2293
2447
|
} catch (err) {
|
|
2294
2448
|
throwIfAborted(p.signal);
|
|
2295
|
-
|
|
2449
|
+
const message = errMsg(err).replace(/\s+/g, " ").trim().slice(0, 300) || "extraction failed";
|
|
2450
|
+
p.logger.error(`Extraction failed for ${page.url}: ${message}`);
|
|
2296
2451
|
return {
|
|
2297
2452
|
url: page.url,
|
|
2298
2453
|
title: page.title,
|
|
2299
2454
|
extraction: "",
|
|
2300
2455
|
sourceType: "unknown",
|
|
2301
2456
|
currentness: "unknown",
|
|
2302
|
-
status: "failed"
|
|
2457
|
+
status: "failed",
|
|
2458
|
+
error: message + (errMsg(err).length > 300 ? "\u2026" : ""),
|
|
2459
|
+
// Structured classification: usage-based when the call completed, else
|
|
2460
|
+
// a match against our own adapter messages (never free provider text).
|
|
2461
|
+
failureKind: exhausted === true || /exhausted the output budget/.test(message) ? "budget" : "other",
|
|
2462
|
+
...routeProvider ? { routeProvider } : {}
|
|
2303
2463
|
};
|
|
2304
2464
|
}
|
|
2305
2465
|
}
|
|
@@ -2311,7 +2471,12 @@ var extractionSchema = Type.Object({
|
|
|
2311
2471
|
title: Type.String(),
|
|
2312
2472
|
extraction: Type.String(),
|
|
2313
2473
|
sourceType: Type.String(),
|
|
2314
|
-
status: Type.String()
|
|
2474
|
+
status: Type.String(),
|
|
2475
|
+
// Optional diagnostics carried from intelli_extract results: a truncation
|
|
2476
|
+
// flag and the bounded failure reason. Optional so strict argument sampling
|
|
2477
|
+
// that knows only the five core keys keeps working.
|
|
2478
|
+
truncated: Type.Optional(Type.Boolean()),
|
|
2479
|
+
error: Type.Optional(Type.String())
|
|
2315
2480
|
});
|
|
2316
2481
|
var fullPageSchema = Type.Object({
|
|
2317
2482
|
url: Type.String(),
|
|
@@ -2604,17 +2769,23 @@ function createOpenRouterClient(config, options) {
|
|
|
2604
2769
|
const message = record(choice.message);
|
|
2605
2770
|
if (message.refusal || choice.finish_reason === "content_filter")
|
|
2606
2771
|
throw new Error("OpenRouter declined the request under provider policy");
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
if (
|
|
2772
|
+
const content = message.content;
|
|
2773
|
+
const emptyish = content == null || typeof content === "string" && !content.trim();
|
|
2774
|
+
if (emptyish && choice.finish_reason === "length") {
|
|
2775
|
+
const reported = usage(data.usage);
|
|
2776
|
+
const counts = reported?.output != null ? ` (${reported.output} output tokens` + (reported.reasoning ? `, ${reported.reasoning} hidden reasoning` : "") + ")" : "";
|
|
2610
2777
|
throw new Error(
|
|
2611
|
-
"OpenRouter exhausted the output budget without visible text;
|
|
2778
|
+
"OpenRouter exhausted the output budget without visible text" + counts + " (the cap includes any reasoning tokens). For extraction, review extractionMaxTokens; for synthesis, review collationMaxTokens. If this diagnostic came from search or cache suggestions, report the stage because those output caps are not exposed as tuning settings."
|
|
2612
2779
|
);
|
|
2780
|
+
}
|
|
2781
|
+
if (typeof content !== "string")
|
|
2782
|
+
throw new Error("OpenRouter returned no text completion");
|
|
2613
2783
|
return {
|
|
2614
2784
|
value: {
|
|
2615
|
-
text:
|
|
2785
|
+
text: content,
|
|
2616
2786
|
citations: request.collectCitations ? parseCitations(raw) : [],
|
|
2617
|
-
usage: usage(data.usage)
|
|
2787
|
+
usage: usage(data.usage),
|
|
2788
|
+
...typeof data.provider === "string" && data.provider ? { routeProvider: data.provider } : {}
|
|
2618
2789
|
}
|
|
2619
2790
|
};
|
|
2620
2791
|
},
|
|
@@ -22,12 +22,22 @@ function tuningDefaults() {
|
|
|
22
22
|
fetchTimeoutMs: 2e4,
|
|
23
23
|
fetchConcurrency: 4,
|
|
24
24
|
extractionConcurrency: 4,
|
|
25
|
-
|
|
25
|
+
// The completion cap covers hidden reasoning tokens on reasoning models
|
|
26
|
+
// (the default MiniMax M3 reasons for thousands of tokens before any
|
|
27
|
+
// visible text, and a budget-exhausted call returns empty output with
|
|
28
|
+
// finish_reason "length"). 8,000 cleared the failure in live probes
|
|
29
|
+
// (2026-11-02 investigation and reviews); the reasoning tail is route-
|
|
30
|
+
// and page-dependent, so telemetry records residual exhaustion
|
|
31
|
+
// (evidence/2026-11-02-extract-failure-agentskills-io).
|
|
32
|
+
extractionMaxTokens: 8e3,
|
|
26
33
|
collationMaxTokens: 4e3,
|
|
27
34
|
browserFingerprint: "chrome_145",
|
|
28
35
|
disableLlmsFullDiscovery: false,
|
|
29
36
|
disableTelemetry: false,
|
|
30
|
-
|
|
37
|
+
// Scaled with extractionMaxTokens in 0.20.0: an 8,000-token completion at
|
|
38
|
+
// the observed ≈95-104 tokens/s takes 77-84s, so the previous 90s default
|
|
39
|
+
// could abort exactly the calls the raised cap was meant to rescue.
|
|
40
|
+
llmTimeoutMs: 12e4,
|
|
31
41
|
llmRetryAttempts: 3,
|
|
32
42
|
retryBaseDelayMs: 1500,
|
|
33
43
|
retryMaxDelayMs: 2e4,
|
package/dist/cli.js
CHANGED
package/dist/runtime.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createRuntime
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HLF5TGKP.js";
|
|
4
4
|
import {
|
|
5
5
|
ConfigurationError,
|
|
6
6
|
StandaloneError,
|
|
7
7
|
identity,
|
|
8
8
|
loadConfig,
|
|
9
9
|
parseConfig
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-LXLEWIYT.js";
|
|
11
11
|
export {
|
|
12
12
|
ConfigurationError,
|
|
13
13
|
StandaloneError,
|
package/dist/server.js
CHANGED
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
extractSchema,
|
|
8
8
|
researchSchema,
|
|
9
9
|
searchSchema
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-HLF5TGKP.js";
|
|
11
11
|
import {
|
|
12
12
|
ConfigurationError,
|
|
13
13
|
StandaloneError,
|
|
14
14
|
identity
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-LXLEWIYT.js";
|
|
16
16
|
|
|
17
17
|
// packages/mcp/src/server.ts
|
|
18
18
|
import { McpServer, fromJsonSchema } from "@modelcontextprotocol/server";
|
package/package.json
CHANGED