@ncukondo/reference-manager 0.29.6 → 0.30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/chunks/{SearchableMultiSelect-28VG3xy7.js → SearchableMultiSelect-SOvTpKAU.js} +2 -2
  2. package/dist/chunks/{SearchableMultiSelect-28VG3xy7.js.map → SearchableMultiSelect-SOvTpKAU.js.map} +1 -1
  3. package/dist/chunks/{action-menu-C4nIA-Sl.js → action-menu-DCZcb0HB.js} +3 -3
  4. package/dist/chunks/{action-menu-C4nIA-Sl.js.map → action-menu-DCZcb0HB.js.map} +1 -1
  5. package/dist/chunks/{checker-hg3aQ_DJ.js → checker-CxSG7cdw.js} +4 -4
  6. package/dist/chunks/{checker-hg3aQ_DJ.js.map → checker-CxSG7cdw.js.map} +1 -1
  7. package/dist/chunks/{crossref-client-DozuWO_S.js → crossref-client-CN2pRi3R.js} +2 -2
  8. package/dist/chunks/{crossref-client-DozuWO_S.js.map → crossref-client-CN2pRi3R.js.map} +1 -1
  9. package/dist/chunks/{fix-interaction-B6FGIOz8.js → fix-interaction-C3OrF3yU.js} +5 -5
  10. package/dist/chunks/{fix-interaction-B6FGIOz8.js.map → fix-interaction-C3OrF3yU.js.map} +1 -1
  11. package/dist/chunks/{index-Czz9ZhIH.js → index-4w0pu_0o.js} +393 -241
  12. package/dist/chunks/index-4w0pu_0o.js.map +1 -0
  13. package/dist/chunks/{index-CGV9-f_j.js → index-BZMfDG4M.js} +3 -3
  14. package/dist/chunks/index-BZMfDG4M.js.map +1 -0
  15. package/dist/chunks/{index-KAr1YWtM.js → index-CA9y5wSm.js} +4 -4
  16. package/dist/chunks/{index-KAr1YWtM.js.map → index-CA9y5wSm.js.map} +1 -1
  17. package/dist/chunks/{index-6Aild0Uk.js → index-C_mW5LMY.js} +884 -418
  18. package/dist/chunks/index-C_mW5LMY.js.map +1 -0
  19. package/dist/chunks/{loader-B6sytmQd.js → loader-BG2eomDC.js} +93 -1
  20. package/dist/chunks/loader-BG2eomDC.js.map +1 -0
  21. package/dist/chunks/{pubmed-client-DJdEV1PO.js → pubmed-client-MF5gA6Os.js} +2 -2
  22. package/dist/chunks/{pubmed-client-DJdEV1PO.js.map → pubmed-client-MF5gA6Os.js.map} +1 -1
  23. package/dist/chunks/{reference-select-Hc3wU8jL.js → reference-select-Bm-05R0u.js} +3 -3
  24. package/dist/chunks/{reference-select-Hc3wU8jL.js.map → reference-select-Bm-05R0u.js.map} +1 -1
  25. package/dist/chunks/{style-select-CcRnu0nC.js → style-select-kfWjEg1X.js} +3 -3
  26. package/dist/chunks/{style-select-CcRnu0nC.js.map → style-select-kfWjEg1X.js.map} +1 -1
  27. package/dist/cli/commands/fulltext.d.ts +8 -1
  28. package/dist/cli/commands/fulltext.d.ts.map +1 -1
  29. package/dist/cli/help/convert-help.d.ts +6 -0
  30. package/dist/cli/help/convert-help.d.ts.map +1 -0
  31. package/dist/cli/index.d.ts.map +1 -1
  32. package/dist/cli.js +2 -1
  33. package/dist/cli.js.map +1 -1
  34. package/dist/config/defaults.d.ts.map +1 -1
  35. package/dist/config/key-parser.d.ts +2 -0
  36. package/dist/config/key-parser.d.ts.map +1 -1
  37. package/dist/config/loader.d.ts.map +1 -1
  38. package/dist/config/schema.d.ts +84 -1
  39. package/dist/config/schema.d.ts.map +1 -1
  40. package/dist/features/import/fetcher.d.ts +2 -1
  41. package/dist/features/import/fetcher.d.ts.map +1 -1
  42. package/dist/features/operations/fulltext/builtin-converters.d.ts +13 -0
  43. package/dist/features/operations/fulltext/builtin-converters.d.ts.map +1 -0
  44. package/dist/features/operations/fulltext/command-template.d.ts +16 -0
  45. package/dist/features/operations/fulltext/command-template.d.ts.map +1 -0
  46. package/dist/features/operations/fulltext/convert.d.ts +16 -1
  47. package/dist/features/operations/fulltext/convert.d.ts.map +1 -1
  48. package/dist/features/operations/fulltext/converter-check.d.ts +8 -0
  49. package/dist/features/operations/fulltext/converter-check.d.ts.map +1 -0
  50. package/dist/features/operations/fulltext/converter-resolver.d.ts +20 -0
  51. package/dist/features/operations/fulltext/converter-resolver.d.ts.map +1 -0
  52. package/dist/features/operations/fulltext/custom-converter.d.ts +17 -0
  53. package/dist/features/operations/fulltext/custom-converter.d.ts.map +1 -0
  54. package/dist/features/operations/fulltext/fetch.d.ts.map +1 -1
  55. package/dist/features/operations/fulltext/pdf-converter.d.ts +39 -0
  56. package/dist/features/operations/fulltext/pdf-converter.d.ts.map +1 -0
  57. package/dist/index.js +1 -1
  58. package/dist/mcp/tools/fulltext.d.ts +4 -0
  59. package/dist/mcp/tools/fulltext.d.ts.map +1 -1
  60. package/dist/server/routes/references.d.ts.map +1 -1
  61. package/dist/server.js +3 -3
  62. package/package.json +1 -1
  63. package/dist/chunks/index-6Aild0Uk.js.map +0 -1
  64. package/dist/chunks/index-CGV9-f_j.js.map +0 -1
  65. package/dist/chunks/index-Czz9ZhIH.js.map +0 -1
  66. package/dist/chunks/loader-B6sytmQd.js.map +0 -1
@@ -1,13 +1,13 @@
1
1
  import { Command, Option } from "commander";
2
+ import { n as normalizePathForOutput, d as deleteDirectoryIfEmpty, p as parseFilename, i as isReservedRole, e as ensureDirectory, a as addAttachment, R as RESERVED_ROLES, b as generateFilename, c as findFulltextFiles, h as findFulltextFile, j as extensionToFormat, k as fulltextAttach, l as fulltextDiscover, m as fulltextFetch, o as fulltextConvert, q as fulltextGet, r as getExtension, s as getDefaultExportFromCjs, B as BUILTIN_STYLES, t as packageJson, u as getFulltextAttachmentTypes, v as startServerWithFileWatcher, w as BUILTIN_CONVERTER_NAMES, x as BUILTIN_CONVERTER_INFO } from "./index-C_mW5LMY.js";
2
3
  import { i as isEqual, M as MANAGED_CUSTOM_FIELDS, w as writeFileAtomic, L as Library, h as CslItemSchema, p as pickDefined, a as sortOrderSchema, z as paginationOptionsSchema, F as FileWatcher, b as sortFieldSchema, y as searchSortFieldSchema } from "./file-watcher-CWHg1yol.js";
3
4
  import * as fs from "node:fs";
4
5
  import { promises, readFileSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
5
6
  import * as os from "node:os";
6
7
  import * as path from "node:path";
7
8
  import path__default, { join, basename, dirname } from "node:path";
8
- import { n as normalizePathForOutput, d as deleteDirectoryIfEmpty, p as parseFilename, i as isReservedRole, e as ensureDirectory, a as addAttachment, R as RESERVED_ROLES, b as generateFilename, c as findFulltextFiles, h as findFulltextFile, j as extensionToFormat, k as fulltextAttach, l as fulltextDiscover, m as fulltextFetch, o as fulltextConvert, q as fulltextGet, r as getExtension, s as getDefaultExportFromCjs, B as BUILTIN_STYLES, t as getFulltextAttachmentTypes, u as startServerWithFileWatcher } from "./index-6Aild0Uk.js";
9
9
  import { readFile, unlink, stat, readdir, rename } from "node:fs/promises";
10
- import { o as openWithSystemApp, l as loadConfig, e as getDefaultCurrentDirConfigFilename, h as getDefaultUserConfigPath } from "./loader-B6sytmQd.js";
10
+ import { o as openWithSystemApp, l as loadConfig, e as getDefaultCurrentDirConfigFilename, h as getDefaultUserConfigPath } from "./loader-BG2eomDC.js";
11
11
  import { spawn, spawnSync } from "node:child_process";
12
12
  import process$1, { stdin, stdout } from "node:process";
13
13
  import * as readline from "node:readline";
@@ -18,14 +18,6 @@ import "@citation-js/core";
18
18
  import "@citation-js/plugin-csl";
19
19
  import { ZodOptional as ZodOptional$2, z } from "zod";
20
20
  import { serve } from "@hono/node-server";
21
- const name = "@ncukondo/reference-manager";
22
- const version$1 = "0.29.6";
23
- const description$1 = "A local reference management tool using CSL-JSON as the single source of truth";
24
- const packageJson = {
25
- name,
26
- version: version$1,
27
- description: description$1
28
- };
29
21
  const ISO_DATE_REGEX$1 = /^\d{4}(-\d{2})?(-\d{2})?$/;
30
22
  function datePartsToIso(dateParts) {
31
23
  if (!dateParts || dateParts.length === 0 || !dateParts[0]) {
@@ -901,15 +893,15 @@ class OperationsLibrary {
901
893
  }
902
894
  // High-level operations
903
895
  async search(options) {
904
- const { searchReferences } = await import("./index-6Aild0Uk.js").then((n) => n.E);
896
+ const { searchReferences } = await import("./index-C_mW5LMY.js").then((n) => n.H);
905
897
  return searchReferences(this.library, options);
906
898
  }
907
899
  async list(options) {
908
- const { listReferences } = await import("./index-6Aild0Uk.js").then((n) => n.D);
900
+ const { listReferences } = await import("./index-C_mW5LMY.js").then((n) => n.G);
909
901
  return listReferences(this.library, options ?? {});
910
902
  }
911
903
  async cite(options) {
912
- const { citeReferences } = await import("./index-6Aild0Uk.js").then((n) => n.C);
904
+ const { citeReferences } = await import("./index-C_mW5LMY.js").then((n) => n.F);
913
905
  const defaultStyle = options.defaultStyle ?? this.citationConfig?.defaultStyle;
914
906
  const cslDirectory = options.cslDirectory ?? this.citationConfig?.cslDirectory;
915
907
  const mergedOptions = {
@@ -920,36 +912,36 @@ class OperationsLibrary {
920
912
  return citeReferences(this.library, mergedOptions);
921
913
  }
922
914
  async import(inputs, options) {
923
- const { addReferences } = await import("./index-6Aild0Uk.js").then((n) => n.z);
915
+ const { addReferences } = await import("./index-C_mW5LMY.js").then((n) => n.D);
924
916
  return addReferences(inputs, this.library, options ?? {});
925
917
  }
926
918
  async check(options) {
927
- const { checkReferences } = await import("./index-6Aild0Uk.js").then((n) => n.A);
919
+ const { checkReferences } = await import("./index-C_mW5LMY.js").then((n) => n.E);
928
920
  return checkReferences(this.library, options);
929
921
  }
930
922
  // Attachment operations
931
923
  async attachAdd(options) {
932
- const { addAttachment: addAttachment2 } = await import("./index-CGV9-f_j.js");
924
+ const { addAttachment: addAttachment2 } = await import("./index-BZMfDG4M.js");
933
925
  return addAttachment2(this.library, options);
934
926
  }
935
927
  async attachList(options) {
936
- const { listAttachments: listAttachments2 } = await import("./index-CGV9-f_j.js");
928
+ const { listAttachments: listAttachments2 } = await import("./index-BZMfDG4M.js");
937
929
  return listAttachments2(this.library, options);
938
930
  }
939
931
  async attachGet(options) {
940
- const { getAttachment: getAttachment2 } = await import("./index-CGV9-f_j.js");
932
+ const { getAttachment: getAttachment2 } = await import("./index-BZMfDG4M.js");
941
933
  return getAttachment2(this.library, options);
942
934
  }
943
935
  async attachDetach(options) {
944
- const { detachAttachment: detachAttachment2 } = await import("./index-CGV9-f_j.js");
936
+ const { detachAttachment: detachAttachment2 } = await import("./index-BZMfDG4M.js");
945
937
  return detachAttachment2(this.library, options);
946
938
  }
947
939
  async attachSync(options) {
948
- const { syncAttachments: syncAttachments2 } = await import("./index-CGV9-f_j.js");
940
+ const { syncAttachments: syncAttachments2 } = await import("./index-BZMfDG4M.js");
949
941
  return syncAttachments2(this.library, options);
950
942
  }
951
943
  async attachOpen(options) {
952
- const { openAttachment: openAttachment2 } = await import("./index-CGV9-f_j.js");
944
+ const { openAttachment: openAttachment2 } = await import("./index-BZMfDG4M.js");
953
945
  return openAttachment2(this.library, options);
954
946
  }
955
947
  }
@@ -1814,7 +1806,7 @@ function getAttachExitCode(result) {
1814
1806
  }
1815
1807
  async function executeInteractiveSelect$2(context, config2) {
1816
1808
  const { withAlternateScreen: withAlternateScreen2 } = await Promise.resolve().then(() => alternateScreen);
1817
- const { selectReferencesOrExit } = await import("./reference-select-Hc3wU8jL.js");
1809
+ const { selectReferencesOrExit } = await import("./reference-select-Bm-05R0u.js");
1818
1810
  const allReferences = await context.library.getAll();
1819
1811
  const identifiers = await withAlternateScreen2(
1820
1812
  () => selectReferencesOrExit(allReferences, { multiSelect: false }, config2.cli.tui)
@@ -2479,7 +2471,7 @@ async function handleCheckAction(identifiers, options, globalOpts) {
2479
2471
  const jsonOptions = buildJsonOptionsFromRefs(options, outputFormat, result, allRefs);
2480
2472
  outputCheckResult(result, outputFormat, jsonOptions);
2481
2473
  if (options.fix && result.summary.warnings > 0 && allRefs) {
2482
- const { runFixInteraction } = await import("./fix-interaction-B6FGIOz8.js");
2474
+ const { runFixInteraction } = await import("./fix-interaction-C3OrF3yU.js");
2483
2475
  const findItem = (id2) => allRefs.find((item) => item.id === id2);
2484
2476
  const fixResult = await runFixInteraction(result.results, context.library, findItem);
2485
2477
  const removedSuffix = fixResult.removed.length > 0 ? `, ${fixResult.removed.length} removed` : "";
@@ -2547,7 +2539,7 @@ function outputCheckError(error, format2) {
2547
2539
  }
2548
2540
  async function selectReferencesInteractively(context, config2) {
2549
2541
  const { withAlternateScreen: withAlternateScreen2 } = await Promise.resolve().then(() => alternateScreen);
2550
- const { selectReferenceItemsOrExit } = await import("./reference-select-Hc3wU8jL.js");
2542
+ const { selectReferenceItemsOrExit } = await import("./reference-select-Bm-05R0u.js");
2551
2543
  const allReferences = await context.library.getAll();
2552
2544
  if (allReferences.length === 0) {
2553
2545
  process.stderr.write("No references in library.\n");
@@ -2615,8 +2607,8 @@ function getCiteExitCode(result) {
2615
2607
  }
2616
2608
  async function executeInteractiveCite(options, context, config2) {
2617
2609
  const { withAlternateScreen: withAlternateScreen2 } = await Promise.resolve().then(() => alternateScreen);
2618
- const { runCiteFlow } = await import("./index-KAr1YWtM.js");
2619
- const { buildStyleChoices, listCustomStyles } = await import("./style-select-CcRnu0nC.js");
2610
+ const { runCiteFlow } = await import("./index-CA9y5wSm.js");
2611
+ const { buildStyleChoices, listCustomStyles } = await import("./style-select-kfWjEg1X.js");
2620
2612
  const { search } = await import("./file-watcher-CWHg1yol.js").then((n) => n.B);
2621
2613
  const { tokenize } = await import("./file-watcher-CWHg1yol.js").then((n) => n.A);
2622
2614
  const { checkTTY } = await import("./tty-BMyaEOhX.js");
@@ -2790,6 +2782,21 @@ const CONFIG_KEY_REGISTRY = [
2790
2782
  type: "boolean",
2791
2783
  description: "Auto-fetch fulltext when adding references"
2792
2784
  },
2785
+ {
2786
+ key: "fulltext.pdf_converter",
2787
+ type: "string",
2788
+ description: "PDF converter: auto, marker, docling, mineru, pymupdf, or custom name"
2789
+ },
2790
+ {
2791
+ key: "fulltext.pdf_converter_priority",
2792
+ type: "string[]",
2793
+ description: "PDF converter auto-detection priority order"
2794
+ },
2795
+ {
2796
+ key: "fulltext.pdf_converter_timeout",
2797
+ type: "integer",
2798
+ description: "PDF converter timeout in seconds"
2799
+ },
2793
2800
  {
2794
2801
  key: "fulltext.sources.unpaywall_email",
2795
2802
  type: "string",
@@ -2860,19 +2867,86 @@ const CONFIG_KEY_REGISTRY = [
2860
2867
  // mcp section
2861
2868
  { key: "mcp.default_limit", type: "integer", description: "Default result limit for MCP" }
2862
2869
  ];
2870
+ const DYNAMIC_KEY_PATTERNS = [
2871
+ {
2872
+ key: "fulltext.converters.*.command",
2873
+ type: "string",
2874
+ description: "Shell command template for the converter"
2875
+ },
2876
+ {
2877
+ key: "fulltext.converters.*.output_mode",
2878
+ type: "enum",
2879
+ description: "Output mode",
2880
+ enumValues: ["file", "stdout"],
2881
+ optional: true
2882
+ },
2883
+ {
2884
+ key: "fulltext.converters.*.check_command",
2885
+ type: "string",
2886
+ description: "Command to check converter availability",
2887
+ optional: true
2888
+ },
2889
+ {
2890
+ key: "fulltext.converters.*.timeout",
2891
+ type: "integer",
2892
+ description: "Converter timeout in seconds",
2893
+ optional: true
2894
+ },
2895
+ {
2896
+ key: "fulltext.converters.*.progress",
2897
+ type: "enum",
2898
+ description: "Progress display mode",
2899
+ enumValues: ["inherit", "quiet"],
2900
+ optional: true
2901
+ },
2902
+ {
2903
+ key: "fulltext.converters.*.command_windows",
2904
+ type: "string",
2905
+ description: "Windows-specific command template",
2906
+ optional: true
2907
+ },
2908
+ {
2909
+ key: "fulltext.converters.*.check_command_windows",
2910
+ type: "string",
2911
+ description: "Windows-specific availability check command",
2912
+ optional: true
2913
+ }
2914
+ ];
2915
+ const DYNAMIC_PATTERN_MAP = new Map(
2916
+ DYNAMIC_KEY_PATTERNS.map((info) => [info.key, info])
2917
+ );
2863
2918
  const KEY_MAP = new Map(CONFIG_KEY_REGISTRY.map((info) => [info.key, info]));
2864
2919
  let allKeysCache = null;
2865
2920
  function parseConfigKey(key) {
2866
2921
  return key.split(".");
2867
2922
  }
2923
+ function toDynamicPattern(key) {
2924
+ const segments = key.split(".");
2925
+ if (segments.length >= 4 && segments[0] === "fulltext" && segments[1] === "converters") {
2926
+ return `${segments[0]}.${segments[1]}.*.${segments.slice(3).join(".")}`;
2927
+ }
2928
+ return null;
2929
+ }
2868
2930
  function isValidConfigKey(key) {
2869
2931
  if (!key) {
2870
2932
  return false;
2871
2933
  }
2872
- return KEY_MAP.has(key);
2934
+ if (KEY_MAP.has(key)) {
2935
+ return true;
2936
+ }
2937
+ const pattern2 = toDynamicPattern(key);
2938
+ return pattern2 !== null && DYNAMIC_PATTERN_MAP.has(pattern2);
2873
2939
  }
2874
2940
  function getConfigKeyInfo(key) {
2875
- return KEY_MAP.get(key) ?? null;
2941
+ const info = KEY_MAP.get(key);
2942
+ if (info) {
2943
+ return info;
2944
+ }
2945
+ const pattern2 = toDynamicPattern(key);
2946
+ if (pattern2) {
2947
+ return DYNAMIC_PATTERN_MAP.get(pattern2) ?? null;
2948
+ }
2949
+ return null;
2876
2950
  }
2877
2951
  function getAllConfigKeys(section) {
2878
2952
  if (!allKeysCache) {
@@ -3896,8 +3970,8 @@ function requireReactJsxRuntime_development() {
3896
3970
  if ("object" === typeof type2 && null !== type2 && type2.$$typeof === REACT_LAZY_TYPE)
3897
3971
  return "<...>";
3898
3972
  try {
3899
- var name2 = getComponentNameFromType(type2);
3900
- return name2 ? "<" + name2 + ">" : "<...>";
3973
+ var name = getComponentNameFromType(type2);
3974
+ return name ? "<" + name + ">" : "<...>";
3901
3975
  } catch (x) {
3902
3976
  return "<...>";
3903
3977
  }
@@ -4391,9 +4465,9 @@ function compileStyleAliases(map2) {
4391
4465
  }
4392
4466
  function Type$1(tag, options) {
4393
4467
  options = options || {};
4394
- Object.keys(options).forEach(function(name2) {
4395
- if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name2) === -1) {
4396
- throw new exception('Unknown option "' + name2 + '" is met in definition of "' + tag + '" YAML type.');
4468
+ Object.keys(options).forEach(function(name) {
4469
+ if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
4470
+ throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
4397
4471
  }
4398
4472
  });
4399
4473
  this.options = options;
@@ -4417,9 +4491,9 @@ function Type$1(tag, options) {
4417
4491
  }
4418
4492
  }
4419
4493
  var type$2 = Type$1;
4420
- function compileList(schema2, name2) {
4494
+ function compileList(schema2, name) {
4421
4495
  var result = [];
4422
- schema2[name2].forEach(function(currentType) {
4496
+ schema2[name].forEach(function(currentType) {
4423
4497
  var newIndex = result.length;
4424
4498
  result.forEach(function(previousType, previousIndex) {
4425
4499
  if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
@@ -5133,7 +5207,7 @@ function throwWarning(state, message) {
5133
5207
  }
5134
5208
  }
5135
5209
  var directiveHandlers = {
5136
- YAML: function handleYamlDirective(state, name2, args) {
5210
+ YAML: function handleYamlDirective(state, name, args) {
5137
5211
  var match, major, minor;
5138
5212
  if (state.version !== null) {
5139
5213
  throwError(state, "duplication of %YAML directive");
@@ -5156,7 +5230,7 @@ var directiveHandlers = {
5156
5230
  throwWarning(state, "unsupported YAML version of the document");
5157
5231
  }
5158
5232
  },
5159
- TAG: function handleTagDirective(state, name2, args) {
5233
+ TAG: function handleTagDirective(state, name, args) {
5160
5234
  var handle, prefix;
5161
5235
  if (args.length !== 2) {
5162
5236
  throwError(state, "TAG directive accepts exactly two arguments");
@@ -7217,7 +7291,7 @@ function formatEditOutput(result) {
7217
7291
  }
7218
7292
  async function executeInteractiveEdit(options, context, config2) {
7219
7293
  const { withAlternateScreen: withAlternateScreen2 } = await Promise.resolve().then(() => alternateScreen);
7220
- const { selectReferencesOrExit } = await import("./reference-select-Hc3wU8jL.js");
7294
+ const { selectReferencesOrExit } = await import("./reference-select-Bm-05R0u.js");
7221
7295
  const allReferences = await context.library.getAll();
7222
7296
  const identifiers = await withAlternateScreen2(
7223
7297
  () => selectReferencesOrExit(allReferences, { multiSelect: true }, config2.cli.tui)
@@ -7476,8 +7550,8 @@ class Directives {
7476
7550
  this.atNextDocument = false;
7477
7551
  }
7478
7552
  const parts = line.trim().split(/[ \t]+/);
7479
- const name2 = parts.shift();
7480
- switch (name2) {
7553
+ const name = parts.shift();
7554
+ switch (name) {
7481
7555
  case "%TAG": {
7482
7556
  if (parts.length !== 2) {
7483
7557
  onError(0, "%TAG directive should contain exactly two parts");
@@ -7505,7 +7579,7 @@ class Directives {
7505
7579
  }
7506
7580
  }
7507
7581
  default:
7508
- onError(0, `Unknown directive ${name2}`, true);
7582
+ onError(0, `Unknown directive ${name}`, true);
7509
7583
  return false;
7510
7584
  }
7511
7585
  }
@@ -7604,9 +7678,9 @@ function anchorNames(root) {
7604
7678
  }
7605
7679
  function findNewAnchor(prefix, exclude) {
7606
7680
  for (let i = 1; true; ++i) {
7607
- const name2 = `${prefix}${i}`;
7608
- if (!exclude.has(name2))
7609
- return name2;
7681
+ const name = `${prefix}${i}`;
7682
+ if (!exclude.has(name))
7683
+ return name;
7610
7684
  }
7611
7685
  }
7612
7686
  function createNodeAnchors(doc, prefix) {
@@ -8515,8 +8589,8 @@ function getTagObject(tags, item) {
8515
8589
  tagObj = tags.find((t) => t.nodeClass && obj instanceof t.nodeClass);
8516
8590
  }
8517
8591
  if (!tagObj) {
8518
- const name2 = obj?.constructor?.name ?? (obj === null ? "null" : typeof obj);
8519
- throw new Error(`Tag not resolved for ${name2} value`);
8592
+ const name = obj?.constructor?.name ?? (obj === null ? "null" : typeof obj);
8593
+ throw new Error(`Tag not resolved for ${name} value`);
8520
8594
  }
8521
8595
  return tagObj;
8522
8596
  }
@@ -10104,11 +10178,11 @@ class Document {
10104
10178
  * `name` will be used as a prefix for a new unique anchor.
10105
10179
  * If `name` is undefined, the generated anchor will use 'a' as a prefix.
10106
10180
  */
10107
- createAlias(node, name2) {
10181
+ createAlias(node, name) {
10108
10182
  if (!node.anchor) {
10109
10183
  const prev = anchorNames(this);
10110
10184
  node.anchor = // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
10111
- !name2 || prev.has(name2) ? findNewAnchor(name2 || "a", prev) : name2;
10185
+ !name || prev.has(name) ? findNewAnchor(name || "a", prev) : name;
10112
10186
  }
10113
10187
  return new Alias(node.anchor);
10114
10188
  }
@@ -10362,8 +10436,8 @@ function formatBibtexAuthor(author) {
10362
10436
  function formatBibtexAuthors(authors) {
10363
10437
  return authors.map(formatBibtexAuthor).join(" and ");
10364
10438
  }
10365
- function formatField(name2, value) {
10366
- return ` ${name2} = {${value}},`;
10439
+ function formatField(name, value) {
10440
+ return ` ${name} = {${value}},`;
10367
10441
  }
10368
10442
  function addBasicFields(lines, item) {
10369
10443
  if (item.title) {
@@ -10659,7 +10733,10 @@ async function executeFulltextConvert(options, context) {
10659
10733
  const operationOptions = {
10660
10734
  identifier: options.identifier,
10661
10735
  idType: options.idType,
10662
- fulltextDirectory: options.fulltextDirectory
10736
+ fulltextDirectory: options.fulltextDirectory,
10737
+ from: options.from,
10738
+ converter: options.converter,
10739
+ fulltextConfig: options.fulltextConfig
10663
10740
  };
10664
10741
  return fulltextConvert(context.library, operationOptions);
10665
10742
  }
@@ -10770,16 +10847,27 @@ function formatFetchErrorOutput(result) {
10770
10847
  }
10771
10848
  function formatFulltextConvertOutput(result) {
10772
10849
  if (!result.success) {
10773
- return `Error: ${result.error}`;
10850
+ const lines = [`Error: ${result.error}`];
10851
+ if (result.stderr) {
10852
+ const stderrLines = result.stderr.trim().split("\n").slice(-5);
10853
+ lines.push("", " stderr (last lines):");
10854
+ for (const line of stderrLines) {
10855
+ lines.push(` ${line}`);
10856
+ }
10857
+ }
10858
+ if (result.hints) {
10859
+ lines.push("", result.hints);
10860
+ }
10861
+ return lines.join("\n");
10774
10862
  }
10775
- return `Converted PMC XML to Markdown: ${result.filename}`;
10863
+ return `Converted to Markdown: ${result.filename}`;
10776
10864
  }
10777
10865
  function getFulltextExitCode(result) {
10778
10866
  return result.success ? 0 : 1;
10779
10867
  }
10780
10868
  async function executeInteractiveSelect$1(context, config2, multiSelect = false) {
10781
10869
  const { withAlternateScreen: withAlternateScreen2 } = await Promise.resolve().then(() => alternateScreen);
10782
- const { selectReferencesOrExit } = await import("./reference-select-Hc3wU8jL.js");
10870
+ const { selectReferencesOrExit } = await import("./reference-select-Bm-05R0u.js");
10783
10871
  const allReferences = await context.library.getAll();
10784
10872
  const identifiers = await withAlternateScreen2(
10785
10873
  () => selectReferencesOrExit(allReferences, { multiSelect }, config2.cli.tui)
@@ -11158,7 +11246,11 @@ async function handleFulltextConvertAction(identifierArg, options, globalOpts) {
11158
11246
  const convertOptions = {
11159
11247
  identifier,
11160
11248
  fulltextDirectory: config2.attachments.directory,
11161
- ...options.uuid && { idType: "uuid" }
11249
+ ...options.uuid && { idType: "uuid" },
11250
+ ...options.from && { from: options.from },
11251
+ ...options.converter && { converter: options.converter },
11252
+ ...options.force && { force: options.force },
11253
+ fulltextConfig: config2.fulltext
11162
11254
  };
11163
11255
  const result = await executeFulltextConvert(convertOptions, context);
11164
11256
  const output = formatFulltextConvertOutput(result);
@@ -14971,7 +15063,7 @@ ZodEnum$1.create;
14971
15063
  ZodPromise.create;
14972
15064
  ZodOptional$1.create;
14973
15065
  ZodNullable$1.create;
14974
- function $constructor(name2, initializer2, params) {
15066
+ function $constructor(name, initializer2, params) {
14975
15067
  function init(inst, def) {
14976
15068
  if (!inst._zod) {
14977
15069
  Object.defineProperty(inst, "_zod", {
@@ -14983,10 +15075,10 @@ function $constructor(name2, initializer2, params) {
14983
15075
  enumerable: false
14984
15076
  });
14985
15077
  }
14986
- if (inst._zod.traits.has(name2)) {
15078
+ if (inst._zod.traits.has(name)) {
14987
15079
  return;
14988
15080
  }
14989
- inst._zod.traits.add(name2);
15081
+ inst._zod.traits.add(name);
14990
15082
  initializer2(inst, def);
14991
15083
  const proto = _.prototype;
14992
15084
  const keys = Object.keys(proto);
@@ -15000,7 +15092,7 @@ function $constructor(name2, initializer2, params) {
15000
15092
  const Parent = params?.Parent ?? Object;
15001
15093
  class Definition extends Parent {
15002
15094
  }
15003
- Object.defineProperty(Definition, "name", { value: name2 });
15095
+ Object.defineProperty(Definition, "name", { value: name });
15004
15096
  function _(def) {
15005
15097
  var _a2;
15006
15098
  const inst = params?.Parent ? new Definition() : this;
@@ -15016,10 +15108,10 @@ function $constructor(name2, initializer2, params) {
15016
15108
  value: (inst) => {
15017
15109
  if (params?.Parent && inst instanceof params.Parent)
15018
15110
  return true;
15019
- return inst?._zod?.traits?.has(name2);
15111
+ return inst?._zod?.traits?.has(name);
15020
15112
  }
15021
15113
  });
15022
- Object.defineProperty(_, "name", { value: name2 });
15114
+ Object.defineProperty(_, "name", { value: name });
15023
15115
  return _;
15024
15116
  }
15025
15117
  class $ZodAsyncError extends Error {
@@ -15028,8 +15120,8 @@ class $ZodAsyncError extends Error {
15028
15120
  }
15029
15121
  }
15030
15122
  class $ZodEncodeError extends Error {
15031
- constructor(name2) {
15032
- super(`Encountered unidirectional transform during encode: ${name2}`);
15123
+ constructor(name) {
15124
+ super(`Encountered unidirectional transform during encode: ${name}`);
15033
15125
  this.name = "ZodEncodeError";
15034
15126
  }
15035
15127
  }
@@ -21042,11 +21134,11 @@ const getRefs = (options) => {
21042
21134
  flags: { hasReferencedOpenAiAnyType: false },
21043
21135
  currentPath,
21044
21136
  propertyPath: void 0,
21045
- seen: new Map(Object.entries(_options.definitions).map(([name2, def]) => [
21137
+ seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [
21046
21138
  def._def,
21047
21139
  {
21048
21140
  def: def._def,
21049
- path: [..._options.basePath, _options.definitionPath, name2],
21141
+ path: [..._options.basePath, _options.definitionPath, name],
21050
21142
  // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
21051
21143
  jsonSchema: void 0
21052
21144
  }
@@ -22147,17 +22239,17 @@ const addMeta = (def, refs, jsonSchema) => {
22147
22239
  };
22148
22240
  const zodToJsonSchema = (schema2, options) => {
22149
22241
  const refs = getRefs(options);
22150
- let definitions2 = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name3, schema3]) => ({
22242
+ let definitions2 = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name2, schema3]) => ({
22151
22243
  ...acc,
22152
- [name3]: parseDef(schema3._def, {
22244
+ [name2]: parseDef(schema3._def, {
22153
22245
  ...refs,
22154
- currentPath: [...refs.basePath, refs.definitionPath, name3]
22246
+ currentPath: [...refs.basePath, refs.definitionPath, name2]
22155
22247
  }, true) ?? parseAnyDef(refs)
22156
22248
  }), {}) : void 0;
22157
- const name2 = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
22158
- const main2 = parseDef(schema2._def, name2 === void 0 ? refs : {
22249
+ const name = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
22250
+ const main2 = parseDef(schema2._def, name === void 0 ? refs : {
22159
22251
  ...refs,
22160
- currentPath: [...refs.basePath, refs.definitionPath, name2]
22252
+ currentPath: [...refs.basePath, refs.definitionPath, name]
22161
22253
  }, false) ?? parseAnyDef(refs);
22162
22254
  const title2 = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
22163
22255
  if (title2 !== void 0) {
@@ -22181,18 +22273,18 @@ const zodToJsonSchema = (schema2, options) => {
22181
22273
  };
22182
22274
  }
22183
22275
  }
22184
- const combined = name2 === void 0 ? definitions2 ? {
22276
+ const combined = name === void 0 ? definitions2 ? {
22185
22277
  ...main2,
22186
22278
  [refs.definitionPath]: definitions2
22187
22279
  } : main2 : {
22188
22280
  $ref: [
22189
22281
  ...refs.$refStrategy === "relative" ? [] : refs.basePath,
22190
22282
  refs.definitionPath,
22191
- name2
22283
+ name
22192
22284
  ].join("/"),
22193
22285
  [refs.definitionPath]: {
22194
22286
  ...definitions2,
22195
- [name2]: main2
22287
+ [name]: main2
22196
22288
  }
22197
22289
  };
22198
22290
  if (refs.target === "jsonSchema7") {
@@ -23351,9 +23443,9 @@ function requireScope() {
23351
23443
  exports$1.ValueScope = exports$1.ValueScopeName = exports$1.Scope = exports$1.varKinds = exports$1.UsedValueState = void 0;
23352
23444
  const code_1 = requireCode$1();
23353
23445
  class ValueError extends Error {
23354
- constructor(name2) {
23355
- super(`CodeGen: "code" for ${name2} not defined`);
23356
- this.value = name2.value;
23446
+ constructor(name) {
23447
+ super(`CodeGen: "code" for ${name} not defined`);
23448
+ this.value = name.value;
23357
23449
  }
23358
23450
  }
23359
23451
  var UsedValueState;
@@ -23420,8 +23512,8 @@ function requireScope() {
23420
23512
  var _a2;
23421
23513
  if (value.ref === void 0)
23422
23514
  throw new Error("CodeGen: ref must be passed in value");
23423
- const name2 = this.toName(nameOrPrefix);
23424
- const { prefix } = name2;
23515
+ const name = this.toName(nameOrPrefix);
23516
+ const { prefix } = name;
23425
23517
  const valueKey = (_a2 = value.key) !== null && _a2 !== void 0 ? _a2 : value.ref;
23426
23518
  let vs = this._values[prefix];
23427
23519
  if (vs) {
@@ -23431,12 +23523,12 @@ function requireScope() {
23431
23523
  } else {
23432
23524
  vs = this._values[prefix] = /* @__PURE__ */ new Map();
23433
23525
  }
23434
- vs.set(valueKey, name2);
23526
+ vs.set(valueKey, name);
23435
23527
  const s = this._scope[prefix] || (this._scope[prefix] = []);
23436
23528
  const itemIndex = s.length;
23437
23529
  s[itemIndex] = value.ref;
23438
- name2.setValue(value, { property: prefix, itemIndex });
23439
- return name2;
23530
+ name.setValue(value, { property: prefix, itemIndex });
23531
+ return name;
23440
23532
  }
23441
23533
  getValue(prefix, keyOrRef) {
23442
23534
  const vs = this._values[prefix];
@@ -23445,17 +23537,17 @@ function requireScope() {
23445
23537
  return vs.get(keyOrRef);
23446
23538
  }
23447
23539
  scopeRefs(scopeName, values = this._values) {
23448
- return this._reduceValues(values, (name2) => {
23449
- if (name2.scopePath === void 0)
23450
- throw new Error(`CodeGen: name "${name2}" has no value`);
23451
- return (0, code_1._)`${scopeName}${name2.scopePath}`;
23540
+ return this._reduceValues(values, (name) => {
23541
+ if (name.scopePath === void 0)
23542
+ throw new Error(`CodeGen: name "${name}" has no value`);
23543
+ return (0, code_1._)`${scopeName}${name.scopePath}`;
23452
23544
  });
23453
23545
  }
23454
23546
  scopeCode(values = this._values, usedValues, getCode) {
23455
- return this._reduceValues(values, (name2) => {
23456
- if (name2.value === void 0)
23457
- throw new Error(`CodeGen: name "${name2}" has no value`);
23458
- return name2.value.code;
23547
+ return this._reduceValues(values, (name) => {
23548
+ if (name.value === void 0)
23549
+ throw new Error(`CodeGen: name "${name}" has no value`);
23550
+ return name.value.code;
23459
23551
  }, usedValues, getCode);
23460
23552
  }
23461
23553
  _reduceValues(values, valueCode, usedValues = {}, getCode) {
@@ -23465,20 +23557,20 @@ function requireScope() {
23465
23557
  if (!vs)
23466
23558
  continue;
23467
23559
  const nameSet = usedValues[prefix] = usedValues[prefix] || /* @__PURE__ */ new Map();
23468
- vs.forEach((name2) => {
23469
- if (nameSet.has(name2))
23560
+ vs.forEach((name) => {
23561
+ if (nameSet.has(name))
23470
23562
  return;
23471
- nameSet.set(name2, UsedValueState.Started);
23472
- let c = valueCode(name2);
23563
+ nameSet.set(name, UsedValueState.Started);
23564
+ let c = valueCode(name);
23473
23565
  if (c) {
23474
23566
  const def = this.opts.es5 ? exports$1.varKinds.var : exports$1.varKinds.const;
23475
- code2 = (0, code_1._)`${code2}${def} ${name2} = ${c};${this.opts._n}`;
23476
- } else if (c = getCode === null || getCode === void 0 ? void 0 : getCode(name2)) {
23567
+ code2 = (0, code_1._)`${code2}${def} ${name} = ${c};${this.opts._n}`;
23568
+ } else if (c = getCode === null || getCode === void 0 ? void 0 : getCode(name)) {
23477
23569
  code2 = (0, code_1._)`${code2}${c}${this.opts._n}`;
23478
23570
  } else {
23479
- throw new ValueError(name2);
23571
+ throw new ValueError(name);
23480
23572
  }
23481
- nameSet.set(name2, UsedValueState.Completed);
23573
+ nameSet.set(name, UsedValueState.Completed);
23482
23574
  });
23483
23575
  }
23484
23576
  return code2;
@@ -23556,10 +23648,10 @@ function requireCodegen() {
23556
23648
  }
23557
23649
  }
23558
23650
  class Def extends Node {
23559
- constructor(varKind, name2, rhs) {
23651
+ constructor(varKind, name, rhs) {
23560
23652
  super();
23561
23653
  this.varKind = varKind;
23562
- this.name = name2;
23654
+ this.name = name;
23563
23655
  this.rhs = rhs;
23564
23656
  }
23565
23657
  render({ es5, _n }) {
@@ -23779,17 +23871,17 @@ function requireCodegen() {
23779
23871
  }
23780
23872
  }
23781
23873
  class ForRange extends For {
23782
- constructor(varKind, name2, from, to) {
23874
+ constructor(varKind, name, from, to) {
23783
23875
  super();
23784
23876
  this.varKind = varKind;
23785
- this.name = name2;
23877
+ this.name = name;
23786
23878
  this.from = from;
23787
23879
  this.to = to;
23788
23880
  }
23789
23881
  render(opts) {
23790
23882
  const varKind = opts.es5 ? scope_1.varKinds.var : this.varKind;
23791
- const { name: name2, from, to } = this;
23792
- return `for(${varKind} ${name2}=${from}; ${name2}<${to}; ${name2}++)` + super.render(opts);
23883
+ const { name, from, to } = this;
23884
+ return `for(${varKind} ${name}=${from}; ${name}<${to}; ${name}++)` + super.render(opts);
23793
23885
  }
23794
23886
  get names() {
23795
23887
  const names2 = addExprNames(super.names, this.from);
@@ -23797,11 +23889,11 @@ function requireCodegen() {
23797
23889
  }
23798
23890
  }
23799
23891
  class ForIter extends For {
23800
- constructor(loop, varKind, name2, iterable) {
23892
+ constructor(loop, varKind, name, iterable) {
23801
23893
  super();
23802
23894
  this.loop = loop;
23803
23895
  this.varKind = varKind;
23804
- this.name = name2;
23896
+ this.name = name;
23805
23897
  this.iterable = iterable;
23806
23898
  }
23807
23899
  render(opts) {
@@ -23818,9 +23910,9 @@ function requireCodegen() {
23818
23910
  }
23819
23911
  }
23820
23912
  class Func extends BlockNode {
23821
- constructor(name2, args, async) {
23913
+ constructor(name, args, async) {
23822
23914
  super();
23823
- this.name = name2;
23915
+ this.name = name;
23824
23916
  this.args = args;
23825
23917
  this.async = async;
23826
23918
  }
@@ -23907,10 +23999,10 @@ function requireCodegen() {
23907
23999
  }
23908
24000
  // reserves unique name in the external scope and assigns value to it
23909
24001
  scopeValue(prefixOrName, value) {
23910
- const name2 = this._extScope.value(prefixOrName, value);
23911
- const vs = this._values[name2.prefix] || (this._values[name2.prefix] = /* @__PURE__ */ new Set());
23912
- vs.add(name2);
23913
- return name2;
24002
+ const name = this._extScope.value(prefixOrName, value);
24003
+ const vs = this._values[name.prefix] || (this._values[name.prefix] = /* @__PURE__ */ new Set());
24004
+ vs.add(name);
24005
+ return name;
23914
24006
  }
23915
24007
  getScopeValue(prefix, keyOrRef) {
23916
24008
  return this._extScope.getValue(prefix, keyOrRef);
@@ -23924,11 +24016,11 @@ function requireCodegen() {
23924
24016
  return this._extScope.scopeCode(this._values);
23925
24017
  }
23926
24018
  _def(varKind, nameOrPrefix, rhs, constant) {
23927
- const name2 = this._scope.toName(nameOrPrefix);
24019
+ const name = this._scope.toName(nameOrPrefix);
23928
24020
  if (rhs !== void 0 && constant)
23929
- this._constants[name2.str] = rhs;
23930
- this._leafNode(new Def(varKind, name2, rhs));
23931
- return name2;
24021
+ this._constants[name.str] = rhs;
24022
+ this._leafNode(new Def(varKind, name, rhs));
24023
+ return name;
23932
24024
  }
23933
24025
  // `const` declaration (`var` in es5 mode)
23934
24026
  const(nameOrPrefix, rhs, _constant) {
@@ -24009,20 +24101,20 @@ function requireCodegen() {
24009
24101
  }
24010
24102
  // `for` statement for a range of values
24011
24103
  forRange(nameOrPrefix, from, to, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.let) {
24012
- const name2 = this._scope.toName(nameOrPrefix);
24013
- return this._for(new ForRange(varKind, name2, from, to), () => forBody(name2));
24104
+ const name = this._scope.toName(nameOrPrefix);
24105
+ return this._for(new ForRange(varKind, name, from, to), () => forBody(name));
24014
24106
  }
24015
24107
  // `for-of` statement (in es5 mode replace with a normal for loop)
24016
24108
  forOf(nameOrPrefix, iterable, forBody, varKind = scope_1.varKinds.const) {
24017
- const name2 = this._scope.toName(nameOrPrefix);
24109
+ const name = this._scope.toName(nameOrPrefix);
24018
24110
  if (this.opts.es5) {
24019
24111
  const arr = iterable instanceof code_1.Name ? iterable : this.var("_arr", iterable);
24020
24112
  return this.forRange("_i", 0, (0, code_1._)`${arr}.length`, (i) => {
24021
- this.var(name2, (0, code_1._)`${arr}[${i}]`);
24022
- forBody(name2);
24113
+ this.var(name, (0, code_1._)`${arr}[${i}]`);
24114
+ forBody(name);
24023
24115
  });
24024
24116
  }
24025
- return this._for(new ForIter("of", varKind, name2, iterable), () => forBody(name2));
24117
+ return this._for(new ForIter("of", varKind, name, iterable), () => forBody(name));
24026
24118
  }
24027
24119
  // `for-in` statement.
24028
24120
  // With option `ownProperties` replaced with a `for-of` loop for object keys
@@ -24030,8 +24122,8 @@ function requireCodegen() {
24030
24122
  if (this.opts.ownProperties) {
24031
24123
  return this.forOf(nameOrPrefix, (0, code_1._)`Object.keys(${obj})`, forBody);
24032
24124
  }
24033
- const name2 = this._scope.toName(nameOrPrefix);
24034
- return this._for(new ForIter("in", varKind, name2, obj), () => forBody(name2));
24125
+ const name = this._scope.toName(nameOrPrefix);
24126
+ return this._for(new ForIter("in", varKind, name, obj), () => forBody(name));
24035
24127
  }
24036
24128
  // end `for` loop
24037
24129
  endFor() {
@@ -24096,8 +24188,8 @@ function requireCodegen() {
24096
24188
  return this;
24097
24189
  }
24098
24190
  // `function` heading (or definition if funcBody is passed)
24099
- func(name2, args = code_1.nil, async, funcBody) {
24100
- this._blockNode(new Func(name2, args, async));
24191
+ func(name, args = code_1.nil, async, funcBody) {
24192
+ this._blockNode(new Func(name, args, async));
24101
24193
  if (funcBody)
24102
24194
  this.code(funcBody).endFunc();
24103
24195
  return this;
@@ -26530,10 +26622,10 @@ function requireSchemes() {
26530
26622
  "urn:uuid"
26531
26623
  ]
26532
26624
  );
26533
- function isValidSchemeName(name2) {
26625
+ function isValidSchemeName(name) {
26534
26626
  return supportedSchemeNames.indexOf(
26535
26627
  /** @type {*} */
26536
- name2
26628
+ name
26537
26629
  ) !== -1;
26538
26630
  }
26539
26631
  function wsIsSecure(wsComponent) {
@@ -27370,10 +27462,10 @@ function requireCore$1() {
27370
27462
  return this;
27371
27463
  }
27372
27464
  // Add format
27373
- addFormat(name2, format2) {
27465
+ addFormat(name, format2) {
27374
27466
  if (typeof format2 == "string")
27375
27467
  format2 = new RegExp(format2);
27376
- this.formats[name2] = format2;
27468
+ this.formats[name] = format2;
27377
27469
  return this;
27378
27470
  }
27379
27471
  errorsText(errors2 = this.errors, { separator = ", ", dataVar = "data" } = {}) {
@@ -27490,10 +27582,10 @@ function requireCore$1() {
27490
27582
  this.addSchema(optsSchemas[key], key);
27491
27583
  }
27492
27584
  function addInitialFormats() {
27493
- for (const name2 in this.opts.formats) {
27494
- const format2 = this.opts.formats[name2];
27585
+ for (const name in this.opts.formats) {
27586
+ const format2 = this.opts.formats[name];
27495
27587
  if (format2)
27496
- this.addFormat(name2, format2);
27588
+ this.addFormat(name, format2);
27497
27589
  }
27498
27590
  }
27499
27591
  function addInitialKeywords(defs) {
@@ -29793,11 +29885,11 @@ function requireDist() {
29793
29885
  (0, limit_1.default)(ajv2);
29794
29886
  return ajv2;
29795
29887
  };
29796
- formatsPlugin.get = (name2, mode = "full") => {
29888
+ formatsPlugin.get = (name, mode = "full") => {
29797
29889
  const formats2 = mode === "fast" ? formats_1.fastFormats : formats_1.fullFormats;
29798
- const f = formats2[name2];
29890
+ const f = formats2[name];
29799
29891
  if (!f)
29800
- throw new Error(`Unknown format "${name2}"`);
29892
+ throw new Error(`Unknown format "${name}"`);
29801
29893
  return f;
29802
29894
  };
29803
29895
  function addFormats(ajv2, list, fs2, exportName) {
@@ -30410,11 +30502,11 @@ class UriTemplate {
30410
30502
  const operator = this.getOperator(expr);
30411
30503
  const exploded = expr.includes("*");
30412
30504
  const names2 = this.getNames(expr);
30413
- const name2 = names2[0];
30414
- for (const name3 of names2) {
30415
- UriTemplate.validateLength(name3, MAX_VARIABLE_LENGTH, "Variable name");
30505
+ const name = names2[0];
30506
+ for (const name2 of names2) {
30507
+ UriTemplate.validateLength(name2, MAX_VARIABLE_LENGTH, "Variable name");
30416
30508
  }
30417
- parts.push({ name: name2, operator, names: names2, exploded });
30509
+ parts.push({ name, operator, names: names2, exploded });
30418
30510
  i = end + 1;
30419
30511
  } else {
30420
30512
  currentText += template[i];
@@ -30432,7 +30524,7 @@ class UriTemplate {
30432
30524
  }
30433
30525
  getNames(expr) {
30434
30526
  const operator = this.getOperator(expr);
30435
- return expr.slice(operator.length).split(",").map((name2) => name2.replace("*", "").trim()).filter((name2) => name2.length > 0);
30527
+ return expr.slice(operator.length).split(",").map((name) => name.replace("*", "").trim()).filter((name) => name.length > 0);
30436
30528
  }
30437
30529
  encodeValue(value, operator) {
30438
30530
  UriTemplate.validateLength(value, MAX_VARIABLE_LENGTH, "Variable value");
@@ -30443,12 +30535,12 @@ class UriTemplate {
30443
30535
  }
30444
30536
  expandPart(part, variables) {
30445
30537
  if (part.operator === "?" || part.operator === "&") {
30446
- const pairs2 = part.names.map((name2) => {
30447
- const value2 = variables[name2];
30538
+ const pairs2 = part.names.map((name) => {
30539
+ const value2 = variables[name];
30448
30540
  if (value2 === void 0)
30449
30541
  return "";
30450
30542
  const encoded2 = Array.isArray(value2) ? value2.map((v) => this.encodeValue(v, part.operator)).join(",") : this.encodeValue(value2.toString(), part.operator);
30451
- return `${name2}=${encoded2}`;
30543
+ return `${name}=${encoded2}`;
30452
30544
  }).filter((pair) => pair.length > 0);
30453
30545
  if (pairs2.length === 0)
30454
30546
  return "";
@@ -30456,7 +30548,7 @@ class UriTemplate {
30456
30548
  return separator + pairs2.join("&");
30457
30549
  }
30458
30550
  if (part.names.length > 1) {
30459
- const values2 = part.names.map((name2) => variables[name2]).filter((v) => v !== void 0);
30551
+ const values2 = part.names.map((name) => variables[name]).filter((v) => v !== void 0);
30460
30552
  if (values2.length === 0)
30461
30553
  return "";
30462
30554
  return values2.map((v) => Array.isArray(v) ? v[0] : v).join(",");
@@ -30508,22 +30600,22 @@ class UriTemplate {
30508
30600
  }
30509
30601
  partToRegExp(part) {
30510
30602
  const patterns = [];
30511
- for (const name3 of part.names) {
30512
- UriTemplate.validateLength(name3, MAX_VARIABLE_LENGTH, "Variable name");
30603
+ for (const name2 of part.names) {
30604
+ UriTemplate.validateLength(name2, MAX_VARIABLE_LENGTH, "Variable name");
30513
30605
  }
30514
30606
  if (part.operator === "?" || part.operator === "&") {
30515
30607
  for (let i = 0; i < part.names.length; i++) {
30516
- const name3 = part.names[i];
30608
+ const name2 = part.names[i];
30517
30609
  const prefix = i === 0 ? "\\" + part.operator : "&";
30518
30610
  patterns.push({
30519
- pattern: prefix + this.escapeRegExp(name3) + "=([^&]+)",
30520
- name: name3
30611
+ pattern: prefix + this.escapeRegExp(name2) + "=([^&]+)",
30612
+ name: name2
30521
30613
  });
30522
30614
  }
30523
30615
  return patterns;
30524
30616
  }
30525
30617
  let pattern2;
30526
- const name2 = part.name;
30618
+ const name = part.name;
30527
30619
  switch (part.operator) {
30528
30620
  case "":
30529
30621
  pattern2 = part.exploded ? "([^/]+(?:,[^/]+)*)" : "([^/,]+)";
@@ -30541,7 +30633,7 @@ class UriTemplate {
30541
30633
  default:
30542
30634
  pattern2 = "([^/]+)";
30543
30635
  }
30544
- patterns.push({ pattern: pattern2, name: name2 });
30636
+ patterns.push({ pattern: pattern2, name });
30545
30637
  return patterns;
30546
30638
  }
30547
30639
  match(uri2) {
@@ -30553,9 +30645,9 @@ class UriTemplate {
30553
30645
  pattern2 += this.escapeRegExp(part);
30554
30646
  } else {
30555
30647
  const patterns = this.partToRegExp(part);
30556
- for (const { pattern: partPattern, name: name2 } of patterns) {
30648
+ for (const { pattern: partPattern, name } of patterns) {
30557
30649
  pattern2 += partPattern;
30558
- names2.push({ name: name2, exploded: part.exploded });
30650
+ names2.push({ name, exploded: part.exploded });
30559
30651
  }
30560
30652
  }
30561
30653
  }
@@ -30567,9 +30659,9 @@ class UriTemplate {
30567
30659
  return null;
30568
30660
  const result = {};
30569
30661
  for (let i = 0; i < names2.length; i++) {
30570
- const { name: name2, exploded } = names2[i];
30662
+ const { name, exploded } = names2[i];
30571
30663
  const value = match[i + 1];
30572
- const cleanName = name2.replace("*", "");
30664
+ const cleanName = name.replace("*", "");
30573
30665
  if (exploded && value.includes(",")) {
30574
30666
  result[cleanName] = value.split(",");
30575
30667
  } else {
@@ -30580,34 +30672,34 @@ class UriTemplate {
30580
30672
  }
30581
30673
  }
30582
30674
  const TOOL_NAME_REGEX = /^[A-Za-z0-9._-]{1,128}$/;
30583
- function validateToolName(name2) {
30675
+ function validateToolName(name) {
30584
30676
  const warnings = [];
30585
- if (name2.length === 0) {
30677
+ if (name.length === 0) {
30586
30678
  return {
30587
30679
  isValid: false,
30588
30680
  warnings: ["Tool name cannot be empty"]
30589
30681
  };
30590
30682
  }
30591
- if (name2.length > 128) {
30683
+ if (name.length > 128) {
30592
30684
  return {
30593
30685
  isValid: false,
30594
- warnings: [`Tool name exceeds maximum length of 128 characters (current: ${name2.length})`]
30686
+ warnings: [`Tool name exceeds maximum length of 128 characters (current: ${name.length})`]
30595
30687
  };
30596
30688
  }
30597
- if (name2.includes(" ")) {
30689
+ if (name.includes(" ")) {
30598
30690
  warnings.push("Tool name contains spaces, which may cause parsing issues");
30599
30691
  }
30600
- if (name2.includes(",")) {
30692
+ if (name.includes(",")) {
30601
30693
  warnings.push("Tool name contains commas, which may cause parsing issues");
30602
30694
  }
30603
- if (name2.startsWith("-") || name2.endsWith("-")) {
30695
+ if (name.startsWith("-") || name.endsWith("-")) {
30604
30696
  warnings.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts");
30605
30697
  }
30606
- if (name2.startsWith(".") || name2.endsWith(".")) {
30698
+ if (name.startsWith(".") || name.endsWith(".")) {
30607
30699
  warnings.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts");
30608
30700
  }
30609
- if (!TOOL_NAME_REGEX.test(name2)) {
30610
- const invalidChars = name2.split("").filter((char) => !/[A-Za-z0-9._-]/.test(char)).filter((char, index, arr) => arr.indexOf(char) === index);
30701
+ if (!TOOL_NAME_REGEX.test(name)) {
30702
+ const invalidChars = name.split("").filter((char) => !/[A-Za-z0-9._-]/.test(char)).filter((char, index, arr) => arr.indexOf(char) === index);
30611
30703
  warnings.push(`Tool name contains invalid characters: ${invalidChars.map((c) => `"${c}"`).join(", ")}`, "Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)");
30612
30704
  return {
30613
30705
  isValid: false,
@@ -30619,9 +30711,9 @@ function validateToolName(name2) {
30619
30711
  warnings
30620
30712
  };
30621
30713
  }
30622
- function issueToolNameWarning(name2, warnings) {
30714
+ function issueToolNameWarning(name, warnings) {
30623
30715
  if (warnings.length > 0) {
30624
- console.warn(`Tool name validation warning for "${name2}":`);
30716
+ console.warn(`Tool name validation warning for "${name}":`);
30625
30717
  for (const warning of warnings) {
30626
30718
  console.warn(` - ${warning}`);
30627
30719
  }
@@ -30630,22 +30722,22 @@ function issueToolNameWarning(name2, warnings) {
30630
30722
  console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.");
30631
30723
  }
30632
30724
  }
30633
- function validateAndWarnToolName(name2) {
30634
- const result = validateToolName(name2);
30635
- issueToolNameWarning(name2, result.warnings);
30725
+ function validateAndWarnToolName(name) {
30726
+ const result = validateToolName(name);
30727
+ issueToolNameWarning(name, result.warnings);
30636
30728
  return result.isValid;
30637
30729
  }
30638
30730
  class ExperimentalMcpServerTasks {
30639
30731
  constructor(_mcpServer) {
30640
30732
  this._mcpServer = _mcpServer;
30641
30733
  }
30642
- registerToolTask(name2, config2, handler) {
30734
+ registerToolTask(name, config2, handler) {
30643
30735
  const execution = { taskSupport: "required", ...config2.execution };
30644
30736
  if (execution.taskSupport === "forbidden") {
30645
- throw new Error(`Cannot register task-based tool '${name2}' with taskSupport 'forbidden'. Use registerTool() instead.`);
30737
+ throw new Error(`Cannot register task-based tool '${name}' with taskSupport 'forbidden'. Use registerTool() instead.`);
30646
30738
  }
30647
30739
  const mcpServerInternal = this._mcpServer;
30648
- return mcpServerInternal._createRegisteredTool(name2, config2.title, config2.description, config2.inputSchema, config2.outputSchema, config2.annotations, execution, config2._meta, handler);
30740
+ return mcpServerInternal._createRegisteredTool(name, config2.title, config2.description, config2.inputSchema, config2.outputSchema, config2.annotations, execution, config2._meta, handler);
30649
30741
  }
30650
30742
  }
30651
30743
  class McpServer {
@@ -30701,9 +30793,9 @@ class McpServer {
30701
30793
  }
30702
30794
  });
30703
30795
  this.server.setRequestHandler(ListToolsRequestSchema, () => ({
30704
- tools: Object.entries(this._registeredTools).filter(([, tool]) => tool.enabled).map(([name2, tool]) => {
30796
+ tools: Object.entries(this._registeredTools).filter(([, tool]) => tool.enabled).map(([name, tool]) => {
30705
30797
  const toolDefinition = {
30706
- name: name2,
30798
+ name,
30707
30799
  title: tool.title,
30708
30800
  description: tool.description,
30709
30801
  inputSchema: (() => {
@@ -30975,8 +31067,8 @@ class McpServer {
30975
31067
  return { resources: [...resources, ...templateResources] };
30976
31068
  });
30977
31069
  this.server.setRequestHandler(ListResourceTemplatesRequestSchema, async () => {
30978
- const resourceTemplates = Object.entries(this._registeredResourceTemplates).map(([name2, template]) => ({
30979
- name: name2,
31070
+ const resourceTemplates = Object.entries(this._registeredResourceTemplates).map(([name, template]) => ({
31071
+ name,
30980
31072
  uriTemplate: template.resourceTemplate.uriTemplate.toString(),
30981
31073
  ...template.metadata
30982
31074
  }));
@@ -31013,9 +31105,9 @@ class McpServer {
31013
31105
  }
31014
31106
  });
31015
31107
  this.server.setRequestHandler(ListPromptsRequestSchema, () => ({
31016
- prompts: Object.entries(this._registeredPrompts).filter(([, prompt]) => prompt.enabled).map(([name2, prompt]) => {
31108
+ prompts: Object.entries(this._registeredPrompts).filter(([, prompt]) => prompt.enabled).map(([name, prompt]) => {
31017
31109
  return {
31018
- name: name2,
31110
+ name,
31019
31111
  title: prompt.title,
31020
31112
  description: prompt.description,
31021
31113
  arguments: prompt.argsSchema ? promptArgumentsFromSchema(prompt.argsSchema) : void 0
@@ -31048,7 +31140,7 @@ class McpServer {
31048
31140
  });
31049
31141
  this._promptHandlersInitialized = true;
31050
31142
  }
31051
- resource(name2, uriOrTemplate, ...rest) {
31143
+ resource(name, uriOrTemplate, ...rest) {
31052
31144
  let metadata2;
31053
31145
  if (typeof rest[0] === "object") {
31054
31146
  metadata2 = rest.shift();
@@ -31058,42 +31150,42 @@ class McpServer {
31058
31150
  if (this._registeredResources[uriOrTemplate]) {
31059
31151
  throw new Error(`Resource ${uriOrTemplate} is already registered`);
31060
31152
  }
31061
- const registeredResource = this._createRegisteredResource(name2, void 0, uriOrTemplate, metadata2, readCallback);
31153
+ const registeredResource = this._createRegisteredResource(name, void 0, uriOrTemplate, metadata2, readCallback);
31062
31154
  this.setResourceRequestHandlers();
31063
31155
  this.sendResourceListChanged();
31064
31156
  return registeredResource;
31065
31157
  } else {
31066
- if (this._registeredResourceTemplates[name2]) {
31067
- throw new Error(`Resource template ${name2} is already registered`);
31158
+ if (this._registeredResourceTemplates[name]) {
31159
+ throw new Error(`Resource template ${name} is already registered`);
31068
31160
  }
31069
- const registeredResourceTemplate = this._createRegisteredResourceTemplate(name2, void 0, uriOrTemplate, metadata2, readCallback);
31161
+ const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, void 0, uriOrTemplate, metadata2, readCallback);
31070
31162
  this.setResourceRequestHandlers();
31071
31163
  this.sendResourceListChanged();
31072
31164
  return registeredResourceTemplate;
31073
31165
  }
31074
31166
  }
31075
- registerResource(name2, uriOrTemplate, config2, readCallback) {
31167
+ registerResource(name, uriOrTemplate, config2, readCallback) {
31076
31168
  if (typeof uriOrTemplate === "string") {
31077
31169
  if (this._registeredResources[uriOrTemplate]) {
31078
31170
  throw new Error(`Resource ${uriOrTemplate} is already registered`);
31079
31171
  }
31080
- const registeredResource = this._createRegisteredResource(name2, config2.title, uriOrTemplate, config2, readCallback);
31172
+ const registeredResource = this._createRegisteredResource(name, config2.title, uriOrTemplate, config2, readCallback);
31081
31173
  this.setResourceRequestHandlers();
31082
31174
  this.sendResourceListChanged();
31083
31175
  return registeredResource;
31084
31176
  } else {
31085
- if (this._registeredResourceTemplates[name2]) {
31086
- throw new Error(`Resource template ${name2} is already registered`);
31177
+ if (this._registeredResourceTemplates[name]) {
31178
+ throw new Error(`Resource template ${name} is already registered`);
31087
31179
  }
31088
- const registeredResourceTemplate = this._createRegisteredResourceTemplate(name2, config2.title, uriOrTemplate, config2, readCallback);
31180
+ const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, config2.title, uriOrTemplate, config2, readCallback);
31089
31181
  this.setResourceRequestHandlers();
31090
31182
  this.sendResourceListChanged();
31091
31183
  return registeredResourceTemplate;
31092
31184
  }
31093
31185
  }
31094
- _createRegisteredResource(name2, title2, uri2, metadata2, readCallback) {
31186
+ _createRegisteredResource(name, title2, uri2, metadata2, readCallback) {
31095
31187
  const registeredResource = {
31096
- name: name2,
31188
+ name,
31097
31189
  title: title2,
31098
31190
  metadata: metadata2,
31099
31191
  readCallback,
@@ -31123,7 +31215,7 @@ class McpServer {
31123
31215
  this._registeredResources[uri2] = registeredResource;
31124
31216
  return registeredResource;
31125
31217
  }
31126
- _createRegisteredResourceTemplate(name2, title2, template, metadata2, readCallback) {
31218
+ _createRegisteredResourceTemplate(name, title2, template, metadata2, readCallback) {
31127
31219
  const registeredResourceTemplate = {
31128
31220
  resourceTemplate: template,
31129
31221
  title: title2,
@@ -31134,8 +31226,8 @@ class McpServer {
31134
31226
  enable: () => registeredResourceTemplate.update({ enabled: true }),
31135
31227
  remove: () => registeredResourceTemplate.update({ name: null }),
31136
31228
  update: (updates) => {
31137
- if (typeof updates.name !== "undefined" && updates.name !== name2) {
31138
- delete this._registeredResourceTemplates[name2];
31229
+ if (typeof updates.name !== "undefined" && updates.name !== name) {
31230
+ delete this._registeredResourceTemplates[name];
31139
31231
  if (updates.name)
31140
31232
  this._registeredResourceTemplates[updates.name] = registeredResourceTemplate;
31141
31233
  }
@@ -31152,7 +31244,7 @@ class McpServer {
31152
31244
  this.sendResourceListChanged();
31153
31245
  }
31154
31246
  };
31155
- this._registeredResourceTemplates[name2] = registeredResourceTemplate;
31247
+ this._registeredResourceTemplates[name] = registeredResourceTemplate;
31156
31248
  const variableNames = template.uriTemplate.variableNames;
31157
31249
  const hasCompleter = Array.isArray(variableNames) && variableNames.some((v) => !!template.completeCallback(v));
31158
31250
  if (hasCompleter) {
@@ -31160,7 +31252,7 @@ class McpServer {
31160
31252
  }
31161
31253
  return registeredResourceTemplate;
31162
31254
  }
31163
- _createRegisteredPrompt(name2, title2, description2, argsSchema, callback) {
31255
+ _createRegisteredPrompt(name, title2, description2, argsSchema, callback) {
31164
31256
  const registeredPrompt = {
31165
31257
  title: title2,
31166
31258
  description: description2,
@@ -31171,8 +31263,8 @@ class McpServer {
31171
31263
  enable: () => registeredPrompt.update({ enabled: true }),
31172
31264
  remove: () => registeredPrompt.update({ name: null }),
31173
31265
  update: (updates) => {
31174
- if (typeof updates.name !== "undefined" && updates.name !== name2) {
31175
- delete this._registeredPrompts[name2];
31266
+ if (typeof updates.name !== "undefined" && updates.name !== name) {
31267
+ delete this._registeredPrompts[name];
31176
31268
  if (updates.name)
31177
31269
  this._registeredPrompts[updates.name] = registeredPrompt;
31178
31270
  }
@@ -31189,7 +31281,7 @@ class McpServer {
31189
31281
  this.sendPromptListChanged();
31190
31282
  }
31191
31283
  };
31192
- this._registeredPrompts[name2] = registeredPrompt;
31284
+ this._registeredPrompts[name] = registeredPrompt;
31193
31285
  if (argsSchema) {
31194
31286
  const hasCompletable = Object.values(argsSchema).some((field) => {
31195
31287
  const inner = field instanceof ZodOptional$2 ? field._def?.innerType : field;
@@ -31201,8 +31293,8 @@ class McpServer {
31201
31293
  }
31202
31294
  return registeredPrompt;
31203
31295
  }
31204
- _createRegisteredTool(name2, title2, description2, inputSchema, outputSchema, annotations, execution, _meta, handler) {
31205
- validateAndWarnToolName(name2);
31296
+ _createRegisteredTool(name, title2, description2, inputSchema, outputSchema, annotations, execution, _meta, handler) {
31297
+ validateAndWarnToolName(name);
31206
31298
  const registeredTool = {
31207
31299
  title: title2,
31208
31300
  description: description2,
@@ -31217,11 +31309,11 @@ class McpServer {
31217
31309
  enable: () => registeredTool.update({ enabled: true }),
31218
31310
  remove: () => registeredTool.update({ name: null }),
31219
31311
  update: (updates) => {
31220
- if (typeof updates.name !== "undefined" && updates.name !== name2) {
31312
+ if (typeof updates.name !== "undefined" && updates.name !== name) {
31221
31313
  if (typeof updates.name === "string") {
31222
31314
  validateAndWarnToolName(updates.name);
31223
31315
  }
31224
- delete this._registeredTools[name2];
31316
+ delete this._registeredTools[name];
31225
31317
  if (updates.name)
31226
31318
  this._registeredTools[updates.name] = registeredTool;
31227
31319
  }
@@ -31244,7 +31336,7 @@ class McpServer {
31244
31336
  this.sendToolListChanged();
31245
31337
  }
31246
31338
  };
31247
- this._registeredTools[name2] = registeredTool;
31339
+ this._registeredTools[name] = registeredTool;
31248
31340
  this.setToolRequestHandlers();
31249
31341
  this.sendToolListChanged();
31250
31342
  return registeredTool;
@@ -31252,9 +31344,9 @@ class McpServer {
31252
31344
  /**
31253
31345
  * tool() implementation. Parses arguments passed to overrides defined above.
31254
31346
  */
31255
- tool(name2, ...rest) {
31256
- if (this._registeredTools[name2]) {
31257
- throw new Error(`Tool ${name2} is already registered`);
31347
+ tool(name, ...rest) {
31348
+ if (this._registeredTools[name]) {
31349
+ throw new Error(`Tool ${name} is already registered`);
31258
31350
  }
31259
31351
  let description2;
31260
31352
  let inputSchema;
@@ -31275,21 +31367,21 @@ class McpServer {
31275
31367
  }
31276
31368
  }
31277
31369
  const callback = rest[0];
31278
- return this._createRegisteredTool(name2, void 0, description2, inputSchema, outputSchema, annotations, { taskSupport: "forbidden" }, void 0, callback);
31370
+ return this._createRegisteredTool(name, void 0, description2, inputSchema, outputSchema, annotations, { taskSupport: "forbidden" }, void 0, callback);
31279
31371
  }
31280
31372
  /**
31281
31373
  * Registers a tool with a config object and callback.
31282
31374
  */
31283
- registerTool(name2, config2, cb) {
31284
- if (this._registeredTools[name2]) {
31285
- throw new Error(`Tool ${name2} is already registered`);
31375
+ registerTool(name, config2, cb) {
31376
+ if (this._registeredTools[name]) {
31377
+ throw new Error(`Tool ${name} is already registered`);
31286
31378
  }
31287
31379
  const { title: title2, description: description2, inputSchema, outputSchema, annotations, _meta } = config2;
31288
- return this._createRegisteredTool(name2, title2, description2, inputSchema, outputSchema, annotations, { taskSupport: "forbidden" }, _meta, cb);
31380
+ return this._createRegisteredTool(name, title2, description2, inputSchema, outputSchema, annotations, { taskSupport: "forbidden" }, _meta, cb);
31289
31381
  }
31290
- prompt(name2, ...rest) {
31291
- if (this._registeredPrompts[name2]) {
31292
- throw new Error(`Prompt ${name2} is already registered`);
31382
+ prompt(name, ...rest) {
31383
+ if (this._registeredPrompts[name]) {
31384
+ throw new Error(`Prompt ${name} is already registered`);
31293
31385
  }
31294
31386
  let description2;
31295
31387
  if (typeof rest[0] === "string") {
@@ -31300,7 +31392,7 @@ class McpServer {
31300
31392
  argsSchema = rest.shift();
31301
31393
  }
31302
31394
  const cb = rest[0];
31303
- const registeredPrompt = this._createRegisteredPrompt(name2, void 0, description2, argsSchema, cb);
31395
+ const registeredPrompt = this._createRegisteredPrompt(name, void 0, description2, argsSchema, cb);
31304
31396
  this.setPromptRequestHandlers();
31305
31397
  this.sendPromptListChanged();
31306
31398
  return registeredPrompt;
@@ -31308,12 +31400,12 @@ class McpServer {
31308
31400
  /**
31309
31401
  * Registers a prompt with a config object and callback.
31310
31402
  */
31311
- registerPrompt(name2, config2, cb) {
31312
- if (this._registeredPrompts[name2]) {
31313
- throw new Error(`Prompt ${name2} is already registered`);
31403
+ registerPrompt(name, config2, cb) {
31404
+ if (this._registeredPrompts[name]) {
31405
+ throw new Error(`Prompt ${name} is already registered`);
31314
31406
  }
31315
31407
  const { title: title2, description: description2, argsSchema } = config2;
31316
- const registeredPrompt = this._createRegisteredPrompt(name2, title2, description2, argsSchema, cb);
31408
+ const registeredPrompt = this._createRegisteredPrompt(name, title2, description2, argsSchema, cb);
31317
31409
  this.setPromptRequestHandlers();
31318
31410
  this.sendPromptListChanged();
31319
31411
  return registeredPrompt;
@@ -31419,11 +31511,11 @@ function promptArgumentsFromSchema(schema2) {
31419
31511
  const shape = getObjectShape(schema2);
31420
31512
  if (!shape)
31421
31513
  return [];
31422
- return Object.entries(shape).map(([name2, field]) => {
31514
+ return Object.entries(shape).map(([name, field]) => {
31423
31515
  const description2 = getSchemaDescription(field);
31424
31516
  const isOptional = isSchemaOptional(field);
31425
31517
  return {
31426
- name: name2,
31518
+ name,
31427
31519
  description: description2,
31428
31520
  required: !isOptional
31429
31521
  };
@@ -32015,9 +32107,11 @@ function registerFulltextConvertTool(server, getLibraryOperations, getConfig) {
32015
32107
  server.registerTool(
32016
32108
  "fulltext_convert",
32017
32109
  {
32018
- description: "Convert an attached PMC JATS XML file to Markdown for a reference.",
32110
+ description: "Convert an attached fulltext file (PMC JATS XML or PDF) to Markdown for a reference. Auto-detects format (XML preferred over PDF). Use 'from' to force a specific format.",
32019
32111
  inputSchema: {
32020
- id: z.string().describe("Reference ID")
32112
+ id: z.string().describe("Reference ID"),
32113
+ from: z.enum(["xml", "pdf"]).optional().describe("Input format: xml, pdf (default: auto-detect)"),
32114
+ converter: z.string().optional().describe("PDF converter: auto, marker, docling, mineru, pymupdf, or custom name")
32021
32115
  }
32022
32116
  },
32023
32117
  async (args) => {
@@ -32025,11 +32119,18 @@ function registerFulltextConvertTool(server, getLibraryOperations, getConfig) {
32025
32119
  const config2 = getConfig();
32026
32120
  const result = await fulltextConvert(libraryOps, {
32027
32121
  identifier: args.id,
32028
- fulltextDirectory: config2.attachments.directory
32122
+ fulltextDirectory: config2.attachments.directory,
32123
+ from: args.from,
32124
+ converter: args.converter,
32125
+ fulltextConfig: config2.fulltext
32029
32126
  });
32030
32127
  if (!result.success) {
32128
+ const errorParts = [result.error ?? "Unknown error"];
32129
+ if (result.hints) {
32130
+ errorParts.push(result.hints);
32131
+ }
32031
32132
  return {
32032
- content: [{ type: "text", text: result.error ?? "Unknown error" }],
32133
+ content: [{ type: "text", text: errorParts.join("\n\n") }],
32033
32134
  isError: true
32034
32135
  };
32035
32136
  }
@@ -32037,7 +32138,7 @@ function registerFulltextConvertTool(server, getLibraryOperations, getConfig) {
32037
32138
  content: [
32038
32139
  {
32039
32140
  type: "text",
32040
- text: `Converted PMC XML to Markdown for '${args.id}': ${result.filename}`
32141
+ text: `Converted to Markdown for '${args.id}': ${result.filename}`
32041
32142
  }
32042
32143
  ]
32043
32144
  };
@@ -32234,7 +32335,7 @@ async function mcpStart(options) {
32234
32335
  async function executeRemove(options, context) {
32235
32336
  const { identifier, idType = "id", fulltextDirectory, deleteFulltext = false } = options;
32236
32337
  if (context.mode === "local" && deleteFulltext && fulltextDirectory) {
32237
- const { removeReference } = await import("./index-6Aild0Uk.js").then((n) => n.x);
32338
+ const { removeReference } = await import("./index-C_mW5LMY.js").then((n) => n.A);
32238
32339
  return removeReference(context.library, {
32239
32340
  identifier,
32240
32341
  idType,
@@ -32289,7 +32390,7 @@ Continue?`;
32289
32390
  }
32290
32391
  async function executeInteractiveRemove(context, config2) {
32291
32392
  const { withAlternateScreen: withAlternateScreen2 } = await Promise.resolve().then(() => alternateScreen);
32292
- const { selectReferenceItemsOrExit } = await import("./reference-select-Hc3wU8jL.js");
32393
+ const { selectReferenceItemsOrExit } = await import("./reference-select-Bm-05R0u.js");
32293
32394
  const allReferences = await context.library.getAll();
32294
32395
  const selectedItems = await withAlternateScreen2(
32295
32396
  () => selectReferenceItemsOrExit(allReferences, { multiSelect: false }, config2.cli.tui)
@@ -32514,7 +32615,7 @@ async function executeInteractiveSearch(options, context, config2) {
32514
32615
  validateInteractiveOptions(options);
32515
32616
  const { checkTTY } = await import("./tty-BMyaEOhX.js");
32516
32617
  const { withAlternateScreen: withAlternateScreen2 } = await Promise.resolve().then(() => alternateScreen);
32517
- const { runSearchFlow } = await import("./index-KAr1YWtM.js");
32618
+ const { runSearchFlow } = await import("./index-CA9y5wSm.js");
32518
32619
  const { search } = await import("./file-watcher-CWHg1yol.js").then((n) => n.B);
32519
32620
  const { tokenize } = await import("./file-watcher-CWHg1yol.js").then((n) => n.A);
32520
32621
  checkTTY();
@@ -32533,7 +32634,7 @@ async function executeInteractiveSearch(options, context, config2) {
32533
32634
  })
32534
32635
  );
32535
32636
  if (result.selectedItems && !result.cancelled) {
32536
- const { isSideEffectAction } = await import("./action-menu-C4nIA-Sl.js");
32637
+ const { isSideEffectAction } = await import("./action-menu-DCZcb0HB.js");
32537
32638
  if (isSideEffectAction(result.action)) {
32538
32639
  await executeSideEffectAction(result.action, result.selectedItems, context, config2);
32539
32640
  return { output: "", cancelled: false, action: result.action };
@@ -32549,7 +32650,7 @@ async function executeSideEffectAction(action, items2, context, config2) {
32549
32650
  switch (action) {
32550
32651
  case "open-url": {
32551
32652
  const { resolveDefaultUrl: resolveDefaultUrl2 } = await Promise.resolve().then(() => url);
32552
- const { openWithSystemApp: openWithSystemApp2 } = await import("./loader-B6sytmQd.js").then((n) => n.j);
32653
+ const { openWithSystemApp: openWithSystemApp2 } = await import("./loader-BG2eomDC.js").then((n) => n.j);
32553
32654
  const item = items2[0];
32554
32655
  if (!item) return;
32555
32656
  const url$1 = resolveDefaultUrl2(item);
@@ -32944,7 +33045,7 @@ function formatUpdateOutput(result, identifier) {
32944
33045
  }
32945
33046
  async function executeInteractiveUpdate(context, config2) {
32946
33047
  const { withAlternateScreen: withAlternateScreen2 } = await Promise.resolve().then(() => alternateScreen);
32947
- const { selectReferencesOrExit } = await import("./reference-select-Hc3wU8jL.js");
33048
+ const { selectReferencesOrExit } = await import("./reference-select-Bm-05R0u.js");
32948
33049
  const allReferences = await context.library.getAll();
32949
33050
  const identifiers = await withAlternateScreen2(
32950
33051
  () => selectReferencesOrExit(allReferences, { multiSelect: false }, config2.cli.tui)
@@ -33239,7 +33340,7 @@ function getUrlExitCode(result) {
33239
33340
  }
33240
33341
  async function executeInteractiveSelect(context, config2) {
33241
33342
  const { withAlternateScreen: withAlternateScreen2 } = await Promise.resolve().then(() => alternateScreen);
33242
- const { selectReferencesOrExit } = await import("./reference-select-Hc3wU8jL.js");
33343
+ const { selectReferencesOrExit } = await import("./reference-select-Bm-05R0u.js");
33243
33344
  const allReferences = await context.library.getAll();
33244
33345
  const identifiers = await withAlternateScreen2(
33245
33346
  () => selectReferencesOrExit(allReferences, { multiSelect: false }, config2.cli.tui)
@@ -33351,7 +33452,7 @@ const ID_COMPLETION_COMMANDS = /* @__PURE__ */ new Set(["cite", "remove", "updat
33351
33452
  const ID_COMPLETION_FULLTEXT_SUBCOMMANDS = /* @__PURE__ */ new Set(["attach", "get", "detach", "open"]);
33352
33453
  const ID_COMPLETION_ATTACH_SUBCOMMANDS = /* @__PURE__ */ new Set(["open", "add", "list", "get", "detach", "sync"]);
33353
33454
  function toCompletionItems(values) {
33354
- return values.map((name2) => ({ name: name2 }));
33455
+ return values.map((name) => ({ name }));
33355
33456
  }
33356
33457
  function extractSubcommands(program) {
33357
33458
  return program.commands.map((cmd) => ({
@@ -33380,8 +33481,8 @@ function extractGlobalOptions(program) {
33380
33481
  options.push({ name: "--version", description: "output the version number" });
33381
33482
  return options;
33382
33483
  }
33383
- function findSubcommand(program, name2) {
33384
- return program.commands.find((cmd) => cmd.name() === name2);
33484
+ function findSubcommand(program, name) {
33485
+ return program.commands.find((cmd) => cmd.name() === name);
33385
33486
  }
33386
33487
  function parseCommandContext(env) {
33387
33488
  const words = env.line.trim().split(/\s+/);
@@ -33574,6 +33675,54 @@ function registerCompletionCommand(program) {
33574
33675
  }
33575
33676
  });
33576
33677
  }
33678
+ function buildConvertHelpText() {
33679
+ const rows = BUILTIN_CONVERTER_NAMES.map((name) => {
33680
+ const info = BUILTIN_CONVERTER_INFO[name];
33681
+ return ` ${name.padEnd(10)}${info.install.padEnd(28)}${info.description}`;
33682
+ });
33683
+ const priority = BUILTIN_CONVERTER_NAMES.join(" > ");
33684
+ return `
33685
+ BUILT-IN CONVERTERS
33686
+ Name Install Notes
33687
+ ${rows.join("\n")}
33688
+
33689
+ In auto mode (default), the first available converter is used.
33690
+ Priority: ${priority}
33691
+
33692
+ CUSTOM CONVERTERS
33693
+ Add via config set:
33694
+ ref config set fulltext.converters.my-tool.command "my-tool {input} -o {output}"
33695
+ ref config set fulltext.converters.my-tool.check_command "my-tool --version"
33696
+
33697
+ Or edit config.toml directly (ref config edit):
33698
+ [fulltext.converters.my-tool]
33699
+ command = "my-tool convert {input} -o {output}"
33700
+ check_command = "my-tool --version"
33701
+
33702
+ Template placeholders:
33703
+ {input} Input PDF path
33704
+ {output} Output Markdown path
33705
+ {input_dir} Directory of input file
33706
+ {input_name} Basename of input file
33707
+ {output_name} Basename of output file
33708
+
33709
+ Additional options:
33710
+ output_mode "file" (default) or "stdout"
33711
+ timeout Seconds (default: 300)
33712
+ progress "inherit" (default) or "quiet"
33713
+
33714
+ Use with: ref fulltext convert <ref> --converter my-tool
33715
+
33716
+ CONFIGURATION
33717
+ ref config set fulltext.pdf_converter marker
33718
+ ref config set fulltext.pdf_converter_timeout 600
33719
+ ref config edit # Edit config.toml directly
33720
+
33721
+ EXAMPLES
33722
+ $ ref fulltext convert smith2023
33723
+ $ ref fulltext convert smith2023 --converter marker
33724
+ $ ref fulltext convert smith2023 --from pdf --force`;
33725
+ }
33577
33726
  function buildSearchHelpText() {
33578
33727
  return `
33579
33728
  QUERY SYNTAX
@@ -33796,7 +33945,7 @@ function shouldAutoFetch(cliFlag, configEnabled) {
33796
33945
  return configEnabled;
33797
33946
  }
33798
33947
  async function performAutoFetch(addedItems, context, config2) {
33799
- const { fulltextFetch: fulltextFetch2 } = await import("./index-6Aild0Uk.js").then((n) => n.w);
33948
+ const { fulltextFetch: fulltextFetch2 } = await import("./index-C_mW5LMY.js").then((n) => n.z);
33800
33949
  const fetchResults = await autoFetchFulltext(addedItems, context, {
33801
33950
  fulltextConfig: config2.fulltext,
33802
33951
  fulltextDirectory: config2.attachments.directory,
@@ -34049,7 +34198,10 @@ function registerFulltextCommand(program) {
34049
34198
  fulltextCmd.command("fetch").description("Download OA full text and auto-attach to a reference").argument("[identifier]", "Citation key or UUID (interactive selection if omitted)").option("--source <source>", "Preferred source: pmc, arxiv, unpaywall, core").option("-f, --force", "Overwrite existing fulltext attachment").option("--uuid", "Interpret identifier as UUID").action(async (identifier, options) => {
34050
34199
  await handleFulltextFetchAction(identifier, options, program.opts());
34051
34200
  });
34052
- fulltextCmd.command("convert").description("Convert attached PMC XML to Markdown").argument("[identifier]", "Citation key or UUID (interactive selection if omitted)").option("--uuid", "Interpret identifier as UUID").action(async (identifier, options) => {
34201
+ fulltextCmd.command("convert").description("Convert attached fulltext (XML or PDF) to Markdown").argument("[identifier]", "Citation key or UUID (interactive selection if omitted)").option("--uuid", "Interpret identifier as UUID").option("--from <format>", "Input format: xml, pdf (default: auto-detect)").option(
34202
+ "--converter <name>",
34203
+ "PDF converter: auto, marker, docling, mineru, pymupdf, or custom name"
34204
+ ).option("--force", "Overwrite existing markdown attachment").addHelpText("after", buildConvertHelpText()).action(async (identifier, options) => {
34053
34205
  await handleFulltextConvertAction(identifier, options, program.opts());
34054
34206
  });
34055
34207
  }
@@ -34088,4 +34240,4 @@ export {
34088
34240
  restoreStdinAfterInk as r,
34089
34241
  syncAttachments as s
34090
34242
  };
34091
- //# sourceMappingURL=index-Czz9ZhIH.js.map
34243
+ //# sourceMappingURL=index-4w0pu_0o.js.map