@autorag/librarian 2.13.10 → 2.13.11

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/dist/index.js CHANGED
@@ -43294,6 +43294,37 @@ function jsonResult(value, isError = false) {
43294
43294
  function toolError(code, message, extra = {}) {
43295
43295
  return jsonResult({ ok: false, errorCode: code, message, ...extra }, true);
43296
43296
  }
43297
+ var DIAGNOSTIC_EXAMPLES_PER_CODE = 3;
43298
+ function capDiagnostics(diagnostics) {
43299
+ const byCode = new Map;
43300
+ for (const entry of diagnostics) {
43301
+ const list = byCode.get(entry.code);
43302
+ if (list === undefined)
43303
+ byCode.set(entry.code, [entry]);
43304
+ else
43305
+ list.push(entry);
43306
+ }
43307
+ const out = [];
43308
+ for (const [code, entries] of byCode) {
43309
+ out.push(...entries.slice(0, DIAGNOSTIC_EXAMPLES_PER_CODE));
43310
+ const rest = entries.slice(DIAGNOSTIC_EXAMPLES_PER_CODE);
43311
+ if (rest.length === 0)
43312
+ continue;
43313
+ const reasons = new Map;
43314
+ for (const entry of rest) {
43315
+ const key = entry.reason ?? "unspecified";
43316
+ reasons.set(key, (reasons.get(key) ?? 0) + 1);
43317
+ }
43318
+ const split = [...reasons].map(([reason, count]) => `${reason}: ${count}`).join(", ");
43319
+ const severity = entries.some((entry) => entry.severity === "error") ? "error" : entries.some((entry) => entry.severity === "warning") ? "warning" : "info";
43320
+ out.push({
43321
+ code,
43322
+ severity,
43323
+ message: `${rest.length} more ${code} entries omitted (${split}); the first ${DIAGNOSTIC_EXAMPLES_PER_CODE} are shown above.`
43324
+ });
43325
+ }
43326
+ return out;
43327
+ }
43297
43328
  function convertResult(details) {
43298
43329
  const { result, links } = details;
43299
43330
  const files = result.files.slice(0, MAX_CONVERT_FILES).map((file) => ({
@@ -43439,7 +43470,10 @@ function createAutoRAGMcpServer(lite, options = {}) {
43439
43470
  inputSchema: emptyInput,
43440
43471
  outputSchema: objectOutput,
43441
43472
  annotations: { readOnlyHint: true, openWorldHint: false }
43442
- }, async () => jsonResult(await lite.getRefreshStatus()));
43473
+ }, async () => {
43474
+ const status = await lite.getRefreshStatus();
43475
+ return jsonResult({ ...status, diagnostics: capDiagnostics(status.diagnostics) });
43476
+ });
43443
43477
  }
43444
43478
  if (isToolEnabled("autorag.search", options)) {
43445
43479
  server.registerTool("autorag.search", {
@@ -43478,7 +43512,7 @@ function createAutoRAGMcpServer(lite, options = {}) {
43478
43512
  content: result.content
43479
43513
  })),
43480
43514
  unsearched: retrieved.unsearched,
43481
- diagnostics: [...status.diagnostics, ...retrieved.diagnostics]
43515
+ diagnostics: capDiagnostics([...status.diagnostics, ...retrieved.diagnostics])
43482
43516
  });
43483
43517
  } catch (error) {
43484
43518
  return toolError(error instanceof RetrievalSelectionError ? "invalid-selection" : "search-failed", error instanceof Error ? error.message : String(error), { retryable: !(error instanceof RetrievalSelectionError) });
@@ -43533,7 +43567,7 @@ function createAutoRAGMcpServer(lite, options = {}) {
43533
43567
  content: result.content
43534
43568
  })),
43535
43569
  unsearched: retrieved.unsearched,
43536
- diagnostics: [...status.diagnostics, ...retrieved.diagnostics]
43570
+ diagnostics: capDiagnostics([...status.diagnostics, ...retrieved.diagnostics])
43537
43571
  });
43538
43572
  } catch (error) {
43539
43573
  return toolError(error instanceof RetrievalSelectionError ? "invalid-selection" : "search-failed", error instanceof Error ? error.message : String(error), { datasourceId: entry.datasourceId, retryable: !(error instanceof RetrievalSelectionError) });
package/dist/mcp/index.js CHANGED
@@ -43115,6 +43115,37 @@ function jsonResult(value, isError = false) {
43115
43115
  function toolError(code, message, extra = {}) {
43116
43116
  return jsonResult({ ok: false, errorCode: code, message, ...extra }, true);
43117
43117
  }
43118
+ var DIAGNOSTIC_EXAMPLES_PER_CODE = 3;
43119
+ function capDiagnostics(diagnostics) {
43120
+ const byCode = new Map;
43121
+ for (const entry of diagnostics) {
43122
+ const list = byCode.get(entry.code);
43123
+ if (list === undefined)
43124
+ byCode.set(entry.code, [entry]);
43125
+ else
43126
+ list.push(entry);
43127
+ }
43128
+ const out = [];
43129
+ for (const [code, entries] of byCode) {
43130
+ out.push(...entries.slice(0, DIAGNOSTIC_EXAMPLES_PER_CODE));
43131
+ const rest = entries.slice(DIAGNOSTIC_EXAMPLES_PER_CODE);
43132
+ if (rest.length === 0)
43133
+ continue;
43134
+ const reasons = new Map;
43135
+ for (const entry of rest) {
43136
+ const key = entry.reason ?? "unspecified";
43137
+ reasons.set(key, (reasons.get(key) ?? 0) + 1);
43138
+ }
43139
+ const split = [...reasons].map(([reason, count]) => `${reason}: ${count}`).join(", ");
43140
+ const severity = entries.some((entry) => entry.severity === "error") ? "error" : entries.some((entry) => entry.severity === "warning") ? "warning" : "info";
43141
+ out.push({
43142
+ code,
43143
+ severity,
43144
+ message: `${rest.length} more ${code} entries omitted (${split}); the first ${DIAGNOSTIC_EXAMPLES_PER_CODE} are shown above.`
43145
+ });
43146
+ }
43147
+ return out;
43148
+ }
43118
43149
  function convertResult(details) {
43119
43150
  const { result, links } = details;
43120
43151
  const files = result.files.slice(0, MAX_CONVERT_FILES).map((file) => ({
@@ -43260,7 +43291,10 @@ function createAutoRAGMcpServer(lite, options = {}) {
43260
43291
  inputSchema: emptyInput,
43261
43292
  outputSchema: objectOutput,
43262
43293
  annotations: { readOnlyHint: true, openWorldHint: false }
43263
- }, async () => jsonResult(await lite.getRefreshStatus()));
43294
+ }, async () => {
43295
+ const status = await lite.getRefreshStatus();
43296
+ return jsonResult({ ...status, diagnostics: capDiagnostics(status.diagnostics) });
43297
+ });
43264
43298
  }
43265
43299
  if (isToolEnabled("autorag.search", options)) {
43266
43300
  server.registerTool("autorag.search", {
@@ -43299,7 +43333,7 @@ function createAutoRAGMcpServer(lite, options = {}) {
43299
43333
  content: result.content
43300
43334
  })),
43301
43335
  unsearched: retrieved.unsearched,
43302
- diagnostics: [...status.diagnostics, ...retrieved.diagnostics]
43336
+ diagnostics: capDiagnostics([...status.diagnostics, ...retrieved.diagnostics])
43303
43337
  });
43304
43338
  } catch (error) {
43305
43339
  return toolError(error instanceof RetrievalSelectionError ? "invalid-selection" : "search-failed", error instanceof Error ? error.message : String(error), { retryable: !(error instanceof RetrievalSelectionError) });
@@ -43354,7 +43388,7 @@ function createAutoRAGMcpServer(lite, options = {}) {
43354
43388
  content: result.content
43355
43389
  })),
43356
43390
  unsearched: retrieved.unsearched,
43357
- diagnostics: [...status.diagnostics, ...retrieved.diagnostics]
43391
+ diagnostics: capDiagnostics([...status.diagnostics, ...retrieved.diagnostics])
43358
43392
  });
43359
43393
  } catch (error) {
43360
43394
  return toolError(error instanceof RetrievalSelectionError ? "invalid-selection" : "search-failed", error instanceof Error ? error.message : String(error), { datasourceId: entry.datasourceId, retryable: !(error instanceof RetrievalSelectionError) });
@@ -6,4 +6,20 @@ export interface AutoRAGMcpServerOptions {
6
6
  /** Test/embedded override; defaults to the current Node platform. */
7
7
  readonly platform?: NodeJS.Platform;
8
8
  }
9
+ interface DiagnosticLike {
10
+ readonly code: string;
11
+ readonly severity: string;
12
+ readonly message: string;
13
+ readonly source?: string;
14
+ readonly reason?: string;
15
+ }
16
+ /**
17
+ * Keep an MCP response small when one code repeats once per file. A corpus whose parser changed reports one
18
+ * `stale-index` entry per source (1,100 of them, about 750 KB, on a real 160k-file index), which the model then has to
19
+ * read through on every search and status call. Each code keeps its first few entries verbatim and one summary entry
20
+ * says how many more there were and how they split by `reason`, so "why is it stale" survives and a different code is
21
+ * never hidden behind a flood of this one. Short lists pass through unchanged.
22
+ */
23
+ export declare function capDiagnostics<T extends DiagnosticLike>(diagnostics: readonly T[]): (T | DiagnosticLike)[];
9
24
  export declare function createAutoRAGMcpServer(lite: AutoRAGLite, options?: AutoRAGMcpServerOptions): McpServer;
25
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorag/librarian",
3
- "version": "2.13.10",
3
+ "version": "2.13.11",
4
4
  "description": "Personal librarian agent for office work on the Pi framework, with pluggable retrieval methods",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {