@curio-data/mcp-intelli-search 0.22.0 → 0.23.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 CHANGED
@@ -6,7 +6,7 @@
6
6
  [![npm downloads](https://img.shields.io/npm/dt/@curio-data/mcp-intelli-search?color=blue)](https://www.npmjs.com/package/@curio-data/mcp-intelli-search)
7
7
  [![node](https://img.shields.io/badge/node-%E2%89%A522-blue)](https://nodejs.org/)
8
8
  [![license](https://img.shields.io/badge/license-Apache--2.0-green)](https://github.com/Curio-Data/pi-intelli-search/blob/main/LICENSE)
9
- ![tests](https://img.shields.io/badge/test%3Aall-1044%20passing-brightgreen)
9
+ ![tests](https://img.shields.io/badge/test%3Aall-1075%20passing-brightgreen)
10
10
 
11
11
  Intelligent web research for coding agents: search, extract, collate, and cache grounded web context in one tool call.
12
12
 
@@ -311,9 +311,9 @@ The degraded outcomes differ in what they save:
311
311
 
312
312
  - **`fetch-failed`:** every fetch failed. The result returns the search summary and up to ten failed URLs with their fetch errors, and saves no report or pages.
313
313
  - **`extraction-failed`:** pages were fetched but no extraction succeeded. Research saves every fetched page under `sources/` and a failure report, and `details.cachePath` names the folder. The result's **Failed Sources** list, repeated under `## Failed Sources` in `report.md`, names each saved page's path and why its extraction failed. A saved page can be read directly, or passed to `intelli_extract` as content, without fetching it again.
314
- - **`collate-failed`:** synthesis failed after extraction. Research saves the extractions and pages with a report that names the failure and lists the saved extractions.
314
+ - **`collate-failed`:** synthesis failed after extraction. Research saves the extractions and pages with a report that names the failure and lists the saved extractions. If source validation rejected nonempty synthesis candidates, research also attempts to save them with their rejection reasons in `rejected-synthesis.json`. This is diagnostic text, not accepted evidence; the result names the file only when saved.
315
315
 
316
- When a successful report for the same query already exists from the same UTC date, including one committed by a concurrent run, an `extraction-failed` or `collate-failed` run preserves that report instead: this run's pages and extractions are not saved, `details.cachePath` is empty, and `details.preservedCachePath` names the preserved report's folder. An `extraction-failed` result still lists up to ten failed pages with their reasons. Neither failure outcome is added to the cache index or runs the cache-suggest judge.
316
+ When a successful report for the same query already exists from the same UTC date, including one committed by a concurrent run, an `extraction-failed` or `collate-failed` run preserves that report instead: this run's pages and extractions are not saved, `details.cachePath` is empty, and `details.preservedCachePath` names the preserved report's folder. The preserved report keeps its own metadata; failed-attempt telemetry and any rejected-synthesis diagnostic go in a separate `attempts/attempt-*` folder beneath it. An `extraction-failed` result still lists up to ten failed pages with their reasons. Neither failure outcome is added to the cache index or runs the cache-suggest judge.
317
317
 
318
318
  Nonempty output that stops at its output cap, shown by finish reason `length` or by a reported token count that reaches the 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. Without either signal, the absence of a warning does not establish completeness, and `outcome: "completed"` does not guarantee complete source coverage.
319
319
 
@@ -594,6 +594,9 @@ Both packages write this format. The native extension resolves the cache against
594
594
  │ ├── report.md # Synthesis + authoritative source inventory
595
595
  │ ├── query.txt # Original search query
596
596
  │ ├── meta.json # Local-only telemetry sidecar (v0.11.0+)
597
+ │ ├── rejected-synthesis.json # Rejected synthesis, when saved; diagnostic only
598
+ │ ├── attempts/ # Failed repeats beside a preserved report
599
+ │ │ └── attempt-<id>/ # The attempt's meta.json and rejected synthesis
597
600
  │ ├── extractions/ # Per-page LLM extractions (≈3-5K each)
598
601
  │ │ ├── 01-developers-cloudflare-com.md
599
602
  │ │ └── 02-developers-cloudflare-com.md
@@ -608,10 +611,10 @@ Each research run writes a cache entry named `<date>-<slug>-<hash>`. The `<hash>
608
611
 
609
612
  Refresh behaviour:
610
613
 
611
- - A completed same-day refresh attempts to archive the previous report, extractions, numbered sources and telemetry sidecar to a numbered sibling folder (`<slug>.1`, then `.2` and so on) before writing the new set.
614
+ - A completed same-day refresh attempts to archive the previous report, extractions, numbered sources, telemetry sidecar and diagnostics (`rejected-synthesis.json` and `attempts/`) to a numbered sibling folder (`<slug>.1`, then `.2` and so on) before writing the new set. Rotation also attempts to update the archived report's cache references to that sibling. An unclosed code fence in an extraction-failure report's search summary can still leave saved-asset references pointing to the live folder.
612
615
  - Archive failure is logged and the completed run can replace canonical files in place; interrupted rotation can leave a partial archive.
613
616
  - Supplementary `llms-full-*` documentation downloads stay with the live folder and are not archived.
614
- - A `no-links` or `fetch-failed` repeat preserves the earlier report, successful or failed, with its extractions, sources and any index entry, and records only the failed attempt in `meta.json`.
617
+ - A `no-links` or `fetch-failed` repeat preserves the earlier report, successful or failed, with its metadata, extractions, sources and any index entry. When telemetry is enabled, the failed attempt is recorded separately in `attempts/attempt-*/meta.json` beneath that cache folder.
615
618
  - An `extraction-failed` or `collate-failed` repeat preserves a successful report in the same way, but archives and replaces an earlier `extraction-failed` or `collate-failed` report. A later run recognises a failure report only by its first line, the marker `<!-- intelli-search:extraction-failed -->` or `<!-- intelli-search:collate-failed -->`; the tool result omits the marker. Committing a failure report also removes any index entry for that folder, so the cache index lists only successful reports.
616
619
  - The numbered siblings are a same-day safety net, not a versioned archive: copy a report elsewhere if it must be retained long-term.
617
620
 
@@ -409,6 +409,10 @@ var RETRYABLE_PATTERNS = [
409
409
  // CLI, e.g. "stream disconnected before completion: stream closed before
410
410
  // response.completed" (pi #11057).
411
411
  "stream disconnected before completion",
412
+ // Gateway relaying a dropped upstream stream after output began, e.g.
413
+ // "Claude Code's stream from Anthropic was cut short after the reply had
414
+ // begun" (pi #11879; upstream since pi-ai 1.5.2).
415
+ "cut short after the reply had begun",
412
416
  // Node ERR_HTTP2_STREAM_CANCEL: the HTTP/2 session died before the request
413
417
  // was sent, for example after the Bedrock SDK's session timeout (pi #10379).
414
418
  "pending stream has been canceled",
@@ -709,21 +713,50 @@ function displayHostname(url) {
709
713
  return url;
710
714
  }
711
715
  }
716
+ var SOURCE_ASSESSMENT_PREAMBLE = "## Source assessment\n\nSource inventory is generated from this run's successful, non-empty extractions, not from search citations. Cross-links in synthesis are not additional fetched sources. Types are extraction metadata, not independent quality ratings.\n\n";
717
+ function closeOpenFence(text) {
718
+ const { fence } = codeBlockView(text);
719
+ return fence ? `${text}
720
+ ${fence.prefix}${fence.char.repeat(fence.length)}` : text;
721
+ }
712
722
  function withoutCodeBlocks(text) {
723
+ return codeBlockView(text).prose;
724
+ }
725
+ function codeBlockView(text) {
713
726
  let fence;
714
- return text.split("\n").map((line) => {
715
- const match = line.match(/^ {0,3}(`{3,}|~{3,})(.*)$/);
727
+ let listIndent = 0;
728
+ let afterBlank = false;
729
+ const prose = text.split("\n").map((line) => {
730
+ if (fence?.indent && line.trim() && !line.startsWith(" ".repeat(fence.indent))) {
731
+ fence = void 0;
732
+ listIndent = 0;
733
+ }
734
+ if (!fence && listIndent && !line.startsWith(" ".repeat(listIndent)) && /^ {0,3}(?:`{3,}|~{3,})/.test(line)) listIndent = 0;
735
+ const thematic = /^ {0,3}(?:([-*_])(?:[ \t]*\1){2,})[ \t\r]*$/.test(line);
736
+ if (!fence && thematic && listIndent && !line.startsWith(" ".repeat(listIndent))) listIndent = 0;
737
+ const item = !fence && !thematic && line.match(/^ {0,3}(?:[-+*]|\d{1,9}[.)])[ \t]+/);
738
+ if (item) listIndent = item[0].length;
739
+ else if (!fence && (afterBlank && line.trim() && !line.startsWith(" ".repeat(listIndent)) || /^ {0,3}(?:#{1,6}(?:\s|$)|>)/.test(line))) listIndent = 0;
740
+ const content = item ? line.slice(item[0].length) : listIndent && line.startsWith(" ".repeat(listIndent)) ? line.slice(listIndent) : line;
741
+ afterBlank = !line.trim();
742
+ const match = content.match(/^ {0,3}(`{3,}|~{3,})(.*)$/);
716
743
  if (fence) {
717
744
  if (match && match[1][0] === fence.char && match[1].length >= fence.length && !match[2].trim())
718
745
  fence = void 0;
719
746
  return "";
720
747
  }
721
748
  if (match) {
722
- fence = { char: match[1][0], length: match[1].length };
749
+ fence = {
750
+ char: match[1][0],
751
+ length: match[1].length,
752
+ indent: listIndent,
753
+ prefix: " ".repeat(listIndent) + (content.match(/^ */)?.[0] ?? "")
754
+ };
723
755
  return "";
724
756
  }
725
- return /^(?: {4}|\t)/.test(line) ? "" : line;
757
+ return /^(?: {4}|\t)/.test(content) ? "" : line;
726
758
  }).join("\n");
759
+ return { prose, fence };
727
760
  }
728
761
  function withoutInlineCode(text) {
729
762
  return text.replace(/(`+)(?!`)[\s\S]*?\1(?!`)/g, "");
@@ -734,11 +767,67 @@ function isWhitespace(char) {
734
767
  function isPunctuation(char) {
735
768
  return char !== void 0 && /[\p{P}\p{S}]/u.test(char);
736
769
  }
770
+ function emphasisPrefix(text, urlIndex) {
771
+ const prefix = text.slice(0, urlIndex);
772
+ const lines = prefix.split("\n");
773
+ let paragraph = "";
774
+ let listIndent = 0;
775
+ let quoteDepth = 0;
776
+ let fence;
777
+ for (const [index, rawLine] of lines.entries()) {
778
+ const completeLine = index < lines.length - 1;
779
+ let line = rawLine;
780
+ let depth = 0;
781
+ let quote;
782
+ while (quote = line.match(/^ {0,3}>[ \t]?/)) {
783
+ depth++;
784
+ line = line.slice(quote[0].length);
785
+ }
786
+ if (depth && depth !== quoteDepth) {
787
+ paragraph = "";
788
+ listIndent = 0;
789
+ }
790
+ if (depth) quoteDepth = depth;
791
+ if (completeLine && !line.trim()) {
792
+ paragraph = "";
793
+ listIndent = 0;
794
+ quoteDepth = depth;
795
+ continue;
796
+ }
797
+ const item = line.match(/^( *)(?:[-+*]|\d{1,9}[.)])[ \t]+/);
798
+ const thematic = /^ {0,3}(?:([-*_])(?:[ \t]*\1){2,})[ \t\r]*$/.test(line);
799
+ if (item && !thematic && (item[1].length <= 3 || listIndent > 0)) {
800
+ paragraph = "";
801
+ listIndent = item[0].length;
802
+ line = line.slice(listIndent);
803
+ } else if (listIndent && line.startsWith(" ".repeat(listIndent))) {
804
+ line = line.slice(listIndent);
805
+ }
806
+ const fenceMarker = line.match(/^ {0,3}(`{3,}|~{3,})(.*)$/);
807
+ if (fence) {
808
+ if (fenceMarker && fenceMarker[1][0] === fence.char && fenceMarker[1].length >= fence.length && !fenceMarker[2].trim()) fence = void 0;
809
+ paragraph = "";
810
+ continue;
811
+ }
812
+ if (completeLine && fenceMarker) {
813
+ fence = { char: fenceMarker[1][0], length: fenceMarker[1].length };
814
+ paragraph = "";
815
+ continue;
816
+ }
817
+ const blockStart = thematic || /^(?: {4}|\t| {0,3}(?:#{1,6}(?:\s|$)|`{3,}|~{3,}|=+[ \t\r]*$))/.test(line);
818
+ if (blockStart) {
819
+ paragraph = completeLine ? "" : line;
820
+ if (completeLine) listIndent = 0;
821
+ continue;
822
+ }
823
+ paragraph += line + (completeLine ? "\n" : "");
824
+ }
825
+ return paragraph;
826
+ }
737
827
  function markdownEmphasisCloser(text, urlIndex, url) {
738
828
  const trailing = url.match(/[*_]+$/)?.[0];
739
829
  if (!trailing) return "";
740
- const lineStart = text.lastIndexOf("\n", urlIndex - 1) + 1;
741
- const rawBefore = text.slice(lineStart, urlIndex);
830
+ const rawBefore = emphasisPrefix(text, urlIndex);
742
831
  const before = rawBefore.replace(/https?:\/\/[^\s<>"`\]]+/g, (match) => " ".repeat(match.length)).replace(/(`+)(?!`)[\s\S]*?\1(?!`)/g, (match) => " ".repeat(match.length));
743
832
  const open = [];
744
833
  for (const match of before.matchAll(/\*+|_+/g)) {
@@ -885,13 +974,9 @@ function finalizeCollation(text, cachePath, extractions, identity2, evidence, al
885
974
  }
886
975
  return `## Summary
887
976
 
888
- ${summary}
889
-
890
- ## Source assessment
977
+ ${closeOpenFence(summary)}
891
978
 
892
- Source inventory is generated from this run's successful, non-empty extractions, not from search citations. Cross-links in synthesis are not additional fetched sources. Types are extraction metadata, not independent quality ratings.
893
-
894
- ` + sourceTable(sources, cachePath, identity2, evidence);
979
+ ` + SOURCE_ASSESSMENT_PREAMBLE + sourceTable(sources, cachePath, identity2, evidence);
895
980
  }
896
981
  function sourceTable(sources, cachePath, identity2, evidence) {
897
982
  let result = "| ID | Source | Type | Evidence | Extraction | Full page |\n";
@@ -975,13 +1060,13 @@ function failureReportHead(heading, marker, reason) {
975
1060
 
976
1061
  `;
977
1062
  }
978
- function collationFailureReport(reason, cachePath, extractions, identity2) {
1063
+ function collationFailureReport(reason, cachePath, extractions, identity2, inputTrimmed = false, synthesisRejected = false) {
979
1064
  const sources = evidenceExtractions(extractions);
980
- return failureReportHead("Collation Failed", COLLATION_FAILED_MARKER, reason) + `No synthesis was produced. The ${sources.length} extraction(s) below were saved; read the extraction files directly, or re-run the research.
1065
+ return failureReportHead("Collation Failed", COLLATION_FAILED_MARKER, reason) + (inputTrimmed ? `No synthesis was ${synthesisRejected ? "accepted" : "produced"}. The ${sources.length} extraction(s) below were saved. Read the saved extraction files to recover omitted text. A repeat may recover synthesis after a transient failure, but does not recover text omitted by the input limits. The trim notice names those limits.
981
1066
 
982
- ## Source assessment
1067
+ ` : `No synthesis was ${synthesisRejected ? "accepted" : "produced"}. The ${sources.length} extraction(s) below were saved; read the extraction files directly, or re-run the research.
983
1068
 
984
- ` + sourceTable(sources, cachePath, identity2, "fetched");
1069
+ `) + "## Source assessment\n\n" + sourceTable(sources, cachePath, identity2, "fetched");
985
1070
  }
986
1071
  function extractionFailureReport(reason, cachePath, savedPages, searchSummary) {
987
1072
  return failureReportHead("Extraction Failed", EXTRACTION_FAILED_MARKER, reason) + `No content was extracted, so no synthesis was produced. ${savedPages} fetched page(s) are saved under ${cachePath}/sources/; the **Failed Sources** list below (in this result and in the saved report) names each failed source, the saved page's path when one exists, and why it failed. Read a saved page directly, or pass its content to \`intelli_extract\` to retry its extraction without refetching it.
@@ -1667,7 +1752,7 @@ async function commitStagedArtefacts(staging, cachePath, writtenExtractions, wri
1667
1752
  await pruneDirectory(finalExtractions, writtenExtractions, null);
1668
1753
  await pruneDirectory(finalSources, writtenSources, LLMS_FULL_PREFIX);
1669
1754
  }
1670
- async function rotateCacheArtefacts(cachePath) {
1755
+ async function rotateCacheArtefacts(cachePath, displayPath = cachePath) {
1671
1756
  let entries;
1672
1757
  try {
1673
1758
  entries = await readdir(cachePath);
@@ -1711,6 +1796,39 @@ async function rotateCacheArtefacts(cachePath) {
1711
1796
  await mkdir(dirname(join2(archive, move.to)), { recursive: true });
1712
1797
  await rename(move.from, join2(archive, move.to));
1713
1798
  }
1799
+ const reportPath = join2(archive, "report.md");
1800
+ const report = await readFile(reportPath, "utf8").catch((error) => {
1801
+ if (error.code === "ENOENT") return void 0;
1802
+ throw error;
1803
+ });
1804
+ if (report !== void 0) {
1805
+ const archivedDisplay = `${displayPath}.${suffix}`;
1806
+ const inventory = report.lastIndexOf(`
1807
+ ${SOURCE_ASSESSMENT_PREAMBLE}`);
1808
+ const inventoryStart = inventory < 0 ? -1 : inventory + 1;
1809
+ let lineOffset = 0;
1810
+ let fence;
1811
+ const rebased = report.split("\n").map((line) => {
1812
+ if (lineOffset === inventoryStart) fence = void 0;
1813
+ lineOffset += line.length + 1;
1814
+ const marker = line.match(/^ {0,3}(`{3,}|~{3,})(.*)$/);
1815
+ if (fence) {
1816
+ if (marker && marker[1][0] === fence.char && marker[1].length >= fence.length && !marker[2].trim()) fence = void 0;
1817
+ return line;
1818
+ }
1819
+ if (marker) {
1820
+ fence = { char: marker[1][0], length: marker[1].length };
1821
+ return line;
1822
+ }
1823
+ if (/^(?: {4}|\t)/.test(line)) return line;
1824
+ if (line === `> Cache: ${displayPath}/`) return `> Cache: ${archivedDisplay}/`;
1825
+ for (const entry of ["sources/", "extractions/", "report.md", "rejected-synthesis.json", "attempts/"]) {
1826
+ line = line.replaceAll(`${displayPath}/${entry}`, `${archivedDisplay}/${entry}`);
1827
+ }
1828
+ return line;
1829
+ }).join("\n");
1830
+ if (rebased !== report) await atomicWriteFile(reportPath, rebased);
1831
+ }
1714
1832
  return archive;
1715
1833
  }
1716
1834
  async function pruneDirectory(dir, keep, preservePrefix) {
@@ -1972,7 +2090,7 @@ async function collate(params, context) {
1972
2090
  await withLock(
1973
2091
  cacheLockDir(physicalPath),
1974
2092
  async () => {
1975
- await rotateCacheArtefacts(physicalPath).catch((error) => {
2093
+ await rotateCacheArtefacts(physicalPath, cachePath).catch((error) => {
1976
2094
  context.logger.error(`Cache archive failed: ${errMsg(error)}`);
1977
2095
  });
1978
2096
  await writeCacheFiles(
@@ -2751,7 +2869,14 @@ ${search2.searchResult}`;
2751
2869
  Search summary:
2752
2870
  ${search2.searchResult}`;
2753
2871
  outcome = "collate-failed";
2754
- collation = collationFailureReport(reason, p.cachePath, succeededExtractions, identity2) + (error instanceof CollationTrimmedInputError ? error.trimNotice : "");
2872
+ collation = collationFailureReport(
2873
+ reason,
2874
+ p.cachePath,
2875
+ succeededExtractions,
2876
+ identity2,
2877
+ error instanceof CollationTrimmedInputError,
2878
+ !!p.rejectedSyntheses?.length
2879
+ ) + (error instanceof CollationTrimmedInputError ? error.trimNotice : "");
2755
2880
  }
2756
2881
  }
2757
2882
  const inferredAssets = inferredAssetsSection(fetched.pages, p.cachePath, identity2);
@@ -2789,7 +2914,7 @@ ${inferredAssets}`;
2789
2914
  return {
2790
2915
  text: failureMessage + (currentInferredAssets ? `
2791
2916
 
2792
- ${currentInferredAssets}` : ""),
2917
+ ${currentInferredAssets}` : "") + rejectedSynthesisNotice(p),
2793
2918
  outcome,
2794
2919
  details: {
2795
2920
  cachePath: "",
@@ -2825,7 +2950,7 @@ ${currentInferredAssets}` : ""),
2825
2950
  ...savedSource ? { sourceFile: `sources/${savedSource}` } : {}
2826
2951
  };
2827
2952
  });
2828
- const result = stripFailureMarkers(collation) + formatCacheAppendix(
2953
+ const result = stripFailureMarkers(collation) + rejectedSynthesisNotice(p) + formatCacheAppendix(
2829
2954
  p.cachePath,
2830
2955
  succeededExtractions.length,
2831
2956
  allExtractions.length - succeededExtractions.length,
@@ -3112,6 +3237,7 @@ async function collateTrimmedEvidence(p, collationUserMsg, succeededExtractions,
3112
3237
  let { completion, maxTokens } = chosen;
3113
3238
  const alternatives = [...chosen.alternatives];
3114
3239
  let firstFailure;
3240
+ const rejected = [];
3115
3241
  let collation;
3116
3242
  while (true) {
3117
3243
  try {
@@ -3127,8 +3253,14 @@ async function collateTrimmedEvidence(p, collationUserMsg, succeededExtractions,
3127
3253
  break;
3128
3254
  } catch (error) {
3129
3255
  firstFailure ??= { error };
3256
+ if (completion.text.trim()) {
3257
+ rejected.push({ text: completion.text, reason: errMsg(error), maxTokens });
3258
+ }
3130
3259
  const next = alternatives.shift();
3131
- if (!next) throw firstFailure.error;
3260
+ if (!next) {
3261
+ p.rejectedSyntheses = rejected;
3262
+ throw firstFailure.error;
3263
+ }
3132
3264
  ({ completion, maxTokens } = next);
3133
3265
  }
3134
3266
  }
@@ -3206,11 +3338,11 @@ async function writeCacheArtifacts(p, allExtractions, fetched, searchResult, col
3206
3338
  (error) => error.code === "ENOENT" ? void 0 : ""
3207
3339
  );
3208
3340
  if (prior !== void 0 && !isCollationFailureReport(prior)) {
3209
- await writeTelemetrySidecar(p.logger, p.tel, p.physicalCachePath, outcome);
3341
+ await writePreservedAttempt(p, outcome);
3210
3342
  return false;
3211
3343
  }
3212
3344
  }
3213
- await rotateCacheArtefacts(p.physicalCachePath).catch((error) => {
3345
+ await rotateCacheArtefacts(p.physicalCachePath, p.cachePath).catch((error) => {
3214
3346
  p.logger.error(`Cache archive failed: ${errMsg(error)}`);
3215
3347
  });
3216
3348
  await writeCacheFiles(
@@ -3221,10 +3353,11 @@ async function writeCacheArtifacts(p, allExtractions, fetched, searchResult, col
3221
3353
  p.params.query,
3222
3354
  identity2
3223
3355
  );
3356
+ await writeRejectedSyntheses(p, p.physicalCachePath);
3224
3357
  await writeReportFile(
3225
3358
  p.physicalCachePath,
3226
3359
  p.params.query,
3227
- collation,
3360
+ collation + rejectedSynthesisNotice(p),
3228
3361
  allExtractions,
3229
3362
  fetched.pages,
3230
3363
  p.cachePath,
@@ -3344,7 +3477,8 @@ async function degradedReturn(p, outcome, message, details) {
3344
3477
  p.signal
3345
3478
  );
3346
3479
  }
3347
- await writeTelemetrySidecar(p.logger, p.tel, p.physicalCachePath, outcome);
3480
+ if (hasReport) await writePreservedAttempt(p, outcome);
3481
+ else await writeTelemetrySidecar(p.logger, p.tel, p.physicalCachePath, outcome);
3348
3482
  },
3349
3483
  p.signal
3350
3484
  );
@@ -3387,6 +3521,36 @@ async function writeLockedTelemetry(p, outcome) {
3387
3521
  p.logger.error(`Telemetry write failed: ${errMsg(error)}`);
3388
3522
  }
3389
3523
  }
3524
+ function rejectedSynthesisNotice(p) {
3525
+ return p.rejectedSynthesisPath ? `
3526
+
3527
+ Rejected synthesis is saved for diagnosis only: ${p.rejectedSynthesisPath}. It failed source validation and is not accepted evidence.` : "";
3528
+ }
3529
+ async function writeRejectedSyntheses(p, directory) {
3530
+ if (!p.rejectedSyntheses?.length) return;
3531
+ try {
3532
+ await writeFile4(
3533
+ join5(directory, "rejected-synthesis.json"),
3534
+ JSON.stringify({ schemaVersion: 1, accepted: false, candidates: p.rejectedSyntheses }, null, 2) + "\n",
3535
+ "utf8"
3536
+ );
3537
+ p.rejectedSynthesisPath = `${displayCachePath(p.paths, directory)}/rejected-synthesis.json`;
3538
+ } catch (error) {
3539
+ p.logger.error(`Rejected synthesis diagnostic write failed: ${errMsg(error)}`);
3540
+ }
3541
+ }
3542
+ async function writePreservedAttempt(p, outcome) {
3543
+ if (!p.tel && !p.rejectedSyntheses?.length) return;
3544
+ try {
3545
+ const attempts = join5(p.physicalCachePath, "attempts");
3546
+ await mkdir3(attempts, { recursive: true });
3547
+ const directory = await mkdtemp(join5(attempts, "attempt-"));
3548
+ await writeTelemetrySidecar(p.logger, p.tel, directory, outcome);
3549
+ await writeRejectedSyntheses(p, directory);
3550
+ } catch (error) {
3551
+ p.logger.error(`Failed attempt diagnostic write failed: ${errMsg(error)}`);
3552
+ }
3553
+ }
3390
3554
  async function writeTelemetrySidecar(logger, tel, cachePath, outcome) {
3391
3555
  if (!tel) return;
3392
3556
  tel.setOutcome(outcome);
package/dist/runtime.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createRuntime
3
- } from "./chunk-IFOKSKKQ.js";
3
+ } from "./chunk-B5ZMILMB.js";
4
4
  import {
5
5
  ConfigurationError,
6
6
  StandaloneError,
package/dist/server.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  extractSchema,
8
8
  researchSchema,
9
9
  searchSchema
10
- } from "./chunk-IFOKSKKQ.js";
10
+ } from "./chunk-B5ZMILMB.js";
11
11
  import {
12
12
  ConfigurationError,
13
13
  StandaloneError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curio-data/mcp-intelli-search",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "Standalone intelligent web research engine and Model Context Protocol stdio server.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",