paper-search-cli 0.3.1 → 0.3.2

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 (304) hide show
  1. package/README.md +1 -1
  2. package/README.zh.md +1 -1
  3. package/dist/capabilities/body-snippet-search/handler.d.ts +9 -0
  4. package/dist/capabilities/body-snippet-search/handler.d.ts.map +1 -0
  5. package/dist/capabilities/body-snippet-search/handler.js +17 -0
  6. package/dist/capabilities/body-snippet-search/handler.js.map +1 -0
  7. package/dist/capabilities/body-snippet-search/index.d.ts +7 -0
  8. package/dist/capabilities/body-snippet-search/index.d.ts.map +1 -0
  9. package/dist/capabilities/body-snippet-search/index.js +6 -0
  10. package/dist/capabilities/body-snippet-search/index.js.map +1 -0
  11. package/dist/capabilities/body-snippet-search/schemas.d.ts +36 -0
  12. package/dist/capabilities/body-snippet-search/schemas.d.ts.map +1 -0
  13. package/dist/capabilities/body-snippet-search/schemas.js +16 -0
  14. package/dist/capabilities/body-snippet-search/schemas.js.map +1 -0
  15. package/dist/capabilities/body-snippet-search/service.d.ts +4 -0
  16. package/dist/capabilities/body-snippet-search/service.d.ts.map +1 -0
  17. package/dist/capabilities/body-snippet-search/service.js +4 -0
  18. package/dist/capabilities/body-snippet-search/service.js.map +1 -0
  19. package/dist/capabilities/body-snippet-search/tools.d.ts +187 -0
  20. package/dist/capabilities/body-snippet-search/tools.d.ts.map +1 -0
  21. package/dist/capabilities/body-snippet-search/tools.js +49 -0
  22. package/dist/capabilities/body-snippet-search/tools.js.map +1 -0
  23. package/dist/capabilities/body-snippet-search/types.d.ts +14 -0
  24. package/dist/capabilities/body-snippet-search/types.d.ts.map +1 -0
  25. package/dist/capabilities/body-snippet-search/types.js +2 -0
  26. package/dist/capabilities/body-snippet-search/types.js.map +1 -0
  27. package/dist/capabilities/citation-expansion/CitationService.d.ts +47 -0
  28. package/dist/capabilities/citation-expansion/CitationService.d.ts.map +1 -0
  29. package/dist/capabilities/citation-expansion/CitationService.js +243 -0
  30. package/dist/capabilities/citation-expansion/CitationService.js.map +1 -0
  31. package/dist/capabilities/citation-expansion/handler.d.ts +36 -0
  32. package/dist/capabilities/citation-expansion/handler.d.ts.map +1 -0
  33. package/dist/capabilities/citation-expansion/handler.js +44 -0
  34. package/dist/capabilities/citation-expansion/handler.js.map +1 -0
  35. package/dist/capabilities/citation-expansion/index.d.ts +6 -0
  36. package/dist/capabilities/citation-expansion/index.d.ts.map +1 -0
  37. package/dist/capabilities/citation-expansion/index.js +5 -0
  38. package/dist/capabilities/citation-expansion/index.js.map +1 -0
  39. package/dist/capabilities/citation-expansion/schemas.d.ts +28 -0
  40. package/dist/capabilities/citation-expansion/schemas.d.ts.map +1 -0
  41. package/dist/capabilities/citation-expansion/schemas.js +13 -0
  42. package/dist/capabilities/citation-expansion/schemas.js.map +1 -0
  43. package/dist/capabilities/citation-expansion/tools.d.ts +82 -0
  44. package/dist/capabilities/citation-expansion/tools.d.ts.map +1 -0
  45. package/dist/capabilities/citation-expansion/tools.js +48 -0
  46. package/dist/capabilities/citation-expansion/tools.js.map +1 -0
  47. package/dist/capabilities/citation-expansion/types.d.ts +22 -0
  48. package/dist/capabilities/citation-expansion/types.d.ts.map +1 -0
  49. package/dist/capabilities/citation-expansion/types.js +2 -0
  50. package/dist/capabilities/citation-expansion/types.js.map +1 -0
  51. package/dist/capabilities/journal-metrics/JournalMetricsService.d.ts +3 -0
  52. package/dist/capabilities/journal-metrics/JournalMetricsService.d.ts.map +1 -0
  53. package/dist/capabilities/journal-metrics/JournalMetricsService.js +142 -0
  54. package/dist/capabilities/journal-metrics/JournalMetricsService.js.map +1 -0
  55. package/dist/capabilities/journal-metrics/handler.d.ts +12 -0
  56. package/dist/capabilities/journal-metrics/handler.d.ts.map +1 -0
  57. package/dist/capabilities/journal-metrics/handler.js +38 -0
  58. package/dist/capabilities/journal-metrics/handler.js.map +1 -0
  59. package/dist/capabilities/journal-metrics/index.d.ts +6 -0
  60. package/dist/capabilities/journal-metrics/index.d.ts.map +1 -0
  61. package/dist/capabilities/journal-metrics/index.js +5 -0
  62. package/dist/capabilities/journal-metrics/index.js.map +1 -0
  63. package/dist/capabilities/journal-metrics/schemas.d.ts +28 -0
  64. package/dist/capabilities/journal-metrics/schemas.d.ts.map +1 -0
  65. package/dist/capabilities/journal-metrics/schemas.js +13 -0
  66. package/dist/capabilities/journal-metrics/schemas.js.map +1 -0
  67. package/dist/capabilities/journal-metrics/tools.d.ts +67 -0
  68. package/dist/capabilities/journal-metrics/tools.d.ts.map +1 -0
  69. package/dist/capabilities/journal-metrics/tools.js +27 -0
  70. package/dist/capabilities/journal-metrics/tools.js.map +1 -0
  71. package/dist/capabilities/journal-metrics/types.d.ts +36 -0
  72. package/dist/capabilities/journal-metrics/types.d.ts.map +1 -0
  73. package/dist/capabilities/journal-metrics/types.js +2 -0
  74. package/dist/capabilities/journal-metrics/types.js.map +1 -0
  75. package/dist/capabilities/metadata-search/MultiSourceSearchService.d.ts +9 -0
  76. package/dist/capabilities/metadata-search/MultiSourceSearchService.d.ts.map +1 -0
  77. package/dist/capabilities/metadata-search/MultiSourceSearchService.js +78 -0
  78. package/dist/capabilities/metadata-search/MultiSourceSearchService.js.map +1 -0
  79. package/dist/capabilities/metadata-search/handler.d.ts +23 -0
  80. package/dist/capabilities/metadata-search/handler.d.ts.map +1 -0
  81. package/dist/capabilities/metadata-search/handler.js +163 -0
  82. package/dist/capabilities/metadata-search/handler.js.map +1 -0
  83. package/dist/capabilities/metadata-search/index.d.ts +6 -0
  84. package/dist/capabilities/metadata-search/index.d.ts.map +1 -0
  85. package/dist/capabilities/metadata-search/index.js +5 -0
  86. package/dist/capabilities/metadata-search/index.js.map +1 -0
  87. package/dist/capabilities/metadata-search/schemas.d.ts +83 -0
  88. package/dist/capabilities/metadata-search/schemas.d.ts.map +1 -0
  89. package/dist/capabilities/metadata-search/schemas.js +81 -0
  90. package/dist/capabilities/metadata-search/schemas.js.map +1 -0
  91. package/dist/capabilities/metadata-search/tools.d.ts +178 -0
  92. package/dist/capabilities/metadata-search/tools.d.ts.map +1 -0
  93. package/dist/capabilities/metadata-search/tools.js +75 -0
  94. package/dist/capabilities/metadata-search/tools.js.map +1 -0
  95. package/dist/capabilities/metadata-search/types.d.ts +13 -0
  96. package/dist/capabilities/metadata-search/types.d.ts.map +1 -0
  97. package/dist/capabilities/metadata-search/types.js +2 -0
  98. package/dist/capabilities/metadata-search/types.js.map +1 -0
  99. package/dist/capabilities/pdf-discovery/DownloadTier.d.ts +22 -0
  100. package/dist/capabilities/pdf-discovery/DownloadTier.d.ts.map +1 -0
  101. package/dist/capabilities/pdf-discovery/DownloadTier.js +2 -0
  102. package/dist/capabilities/pdf-discovery/DownloadTier.js.map +1 -0
  103. package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.d.ts +10 -0
  104. package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.d.ts.map +1 -0
  105. package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.js +53 -0
  106. package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.js.map +1 -0
  107. package/dist/capabilities/pdf-discovery/handler.d.ts +19 -0
  108. package/dist/capabilities/pdf-discovery/handler.d.ts.map +1 -0
  109. package/dist/capabilities/pdf-discovery/handler.js +56 -0
  110. package/dist/capabilities/pdf-discovery/handler.js.map +1 -0
  111. package/dist/capabilities/pdf-discovery/index.d.ts +7 -0
  112. package/dist/capabilities/pdf-discovery/index.d.ts.map +1 -0
  113. package/dist/capabilities/pdf-discovery/index.js +5 -0
  114. package/dist/capabilities/pdf-discovery/index.js.map +1 -0
  115. package/dist/capabilities/pdf-discovery/schemas.d.ts +37 -0
  116. package/dist/capabilities/pdf-discovery/schemas.d.ts.map +1 -0
  117. package/dist/capabilities/pdf-discovery/schemas.js +22 -0
  118. package/dist/capabilities/pdf-discovery/schemas.js.map +1 -0
  119. package/dist/capabilities/pdf-discovery/tiers/directPdfUrl.d.ts +3 -0
  120. package/dist/capabilities/pdf-discovery/tiers/directPdfUrl.d.ts.map +1 -0
  121. package/dist/capabilities/pdf-discovery/tiers/directPdfUrl.js +27 -0
  122. package/dist/capabilities/pdf-discovery/tiers/directPdfUrl.js.map +1 -0
  123. package/dist/capabilities/pdf-discovery/tiers/primary.d.ts +3 -0
  124. package/dist/capabilities/pdf-discovery/tiers/primary.d.ts.map +1 -0
  125. package/dist/capabilities/pdf-discovery/tiers/primary.js +21 -0
  126. package/dist/capabilities/pdf-discovery/tiers/primary.js.map +1 -0
  127. package/dist/capabilities/pdf-discovery/tiers/repositories.d.ts +3 -0
  128. package/dist/capabilities/pdf-discovery/tiers/repositories.d.ts.map +1 -0
  129. package/dist/capabilities/pdf-discovery/tiers/repositories.js +35 -0
  130. package/dist/capabilities/pdf-discovery/tiers/repositories.js.map +1 -0
  131. package/dist/capabilities/pdf-discovery/tiers/scihub.d.ts +3 -0
  132. package/dist/capabilities/pdf-discovery/tiers/scihub.d.ts.map +1 -0
  133. package/dist/capabilities/pdf-discovery/tiers/scihub.js +21 -0
  134. package/dist/capabilities/pdf-discovery/tiers/scihub.js.map +1 -0
  135. package/dist/capabilities/pdf-discovery/tiers/unpaywall.d.ts +3 -0
  136. package/dist/capabilities/pdf-discovery/tiers/unpaywall.d.ts.map +1 -0
  137. package/dist/capabilities/pdf-discovery/tiers/unpaywall.js +29 -0
  138. package/dist/capabilities/pdf-discovery/tiers/unpaywall.js.map +1 -0
  139. package/dist/capabilities/pdf-discovery/tools.d.ts +114 -0
  140. package/dist/capabilities/pdf-discovery/tools.d.ts.map +1 -0
  141. package/dist/capabilities/pdf-discovery/tools.js +42 -0
  142. package/dist/capabilities/pdf-discovery/tools.js.map +1 -0
  143. package/dist/capabilities/pdf-discovery/types.d.ts +19 -0
  144. package/dist/capabilities/pdf-discovery/types.d.ts.map +1 -0
  145. package/dist/capabilities/pdf-discovery/types.js +2 -0
  146. package/dist/capabilities/pdf-discovery/types.js.map +1 -0
  147. package/dist/cli.js +6 -6
  148. package/dist/cli.js.map +1 -1
  149. package/dist/core/capabilityProfile.d.ts +1 -17
  150. package/dist/core/capabilityProfile.d.ts.map +1 -1
  151. package/dist/core/capabilityProfile.js +1 -166
  152. package/dist/core/capabilityProfile.js.map +1 -1
  153. package/dist/core/diagnostics.d.ts +1 -42
  154. package/dist/core/diagnostics.d.ts.map +1 -1
  155. package/dist/core/diagnostics.js +1 -585
  156. package/dist/core/diagnostics.js.map +1 -1
  157. package/dist/core/handleToolCall.d.ts +1 -0
  158. package/dist/core/handleToolCall.d.ts.map +1 -1
  159. package/dist/core/handleToolCall.js +265 -509
  160. package/dist/core/handleToolCall.js.map +1 -1
  161. package/dist/core/httpPolicies.d.ts +2 -0
  162. package/dist/core/httpPolicies.d.ts.map +1 -0
  163. package/dist/core/httpPolicies.js +2 -0
  164. package/dist/core/httpPolicies.js.map +1 -0
  165. package/dist/core/liveSmoke.d.ts +1 -41
  166. package/dist/core/liveSmoke.d.ts.map +1 -1
  167. package/dist/core/liveSmoke.js +1 -225
  168. package/dist/core/liveSmoke.js.map +1 -1
  169. package/dist/core/platformFactories.d.ts +2 -0
  170. package/dist/core/platformFactories.d.ts.map +1 -0
  171. package/dist/core/platformFactories.js +2 -0
  172. package/dist/core/platformFactories.js.map +1 -0
  173. package/dist/core/platformMetadata.d.ts +1 -27
  174. package/dist/core/platformMetadata.d.ts.map +1 -1
  175. package/dist/core/platformMetadata.js +1 -257
  176. package/dist/core/platformMetadata.js.map +1 -1
  177. package/dist/core/schemas.d.ts +10 -202
  178. package/dist/core/schemas.d.ts.map +1 -1
  179. package/dist/core/schemas.js +11 -118
  180. package/dist/core/schemas.js.map +1 -1
  181. package/dist/core/searchers.d.ts +24 -24
  182. package/dist/core/searchers.d.ts.map +1 -1
  183. package/dist/core/searchers.js +14 -79
  184. package/dist/core/searchers.js.map +1 -1
  185. package/dist/core/textReports.d.ts +1 -20
  186. package/dist/core/textReports.d.ts.map +1 -1
  187. package/dist/core/textReports.js +1 -84
  188. package/dist/core/textReports.js.map +1 -1
  189. package/dist/core/tools.d.ts.map +1 -1
  190. package/dist/core/tools.js +15 -237
  191. package/dist/core/tools.js.map +1 -1
  192. package/dist/infrastructure/cache/RequestCache.d.ts +26 -0
  193. package/dist/infrastructure/cache/RequestCache.d.ts.map +1 -0
  194. package/dist/infrastructure/cache/RequestCache.js +66 -0
  195. package/dist/infrastructure/cache/RequestCache.js.map +1 -0
  196. package/dist/infrastructure/http/ErrorHandler.d.ts +99 -0
  197. package/dist/infrastructure/http/ErrorHandler.d.ts.map +1 -0
  198. package/dist/infrastructure/http/ErrorHandler.js +266 -0
  199. package/dist/infrastructure/http/ErrorHandler.js.map +1 -0
  200. package/dist/infrastructure/http/HttpClient.d.ts +31 -0
  201. package/dist/infrastructure/http/HttpClient.d.ts.map +1 -0
  202. package/dist/infrastructure/http/HttpClient.js +50 -0
  203. package/dist/infrastructure/http/HttpClient.js.map +1 -0
  204. package/dist/infrastructure/pdf/PDFExtractor.d.ts +34 -0
  205. package/dist/infrastructure/pdf/PDFExtractor.d.ts.map +1 -0
  206. package/dist/infrastructure/pdf/PDFExtractor.js +130 -0
  207. package/dist/infrastructure/pdf/PDFExtractor.js.map +1 -0
  208. package/dist/infrastructure/pdf/PdfDownload.d.ts +7 -0
  209. package/dist/infrastructure/pdf/PdfDownload.d.ts.map +1 -0
  210. package/dist/infrastructure/pdf/PdfDownload.js +175 -0
  211. package/dist/infrastructure/pdf/PdfDownload.js.map +1 -0
  212. package/dist/infrastructure/rate-limit/RateLimiter.d.ts +50 -0
  213. package/dist/infrastructure/rate-limit/RateLimiter.d.ts.map +1 -0
  214. package/dist/infrastructure/rate-limit/RateLimiter.js +128 -0
  215. package/dist/infrastructure/rate-limit/RateLimiter.js.map +1 -0
  216. package/dist/infrastructure/security/SecurityUtils.d.ts +80 -0
  217. package/dist/infrastructure/security/SecurityUtils.d.ts.map +1 -0
  218. package/dist/infrastructure/security/SecurityUtils.js +357 -0
  219. package/dist/infrastructure/security/SecurityUtils.js.map +1 -0
  220. package/dist/management/capability-profile/index.d.ts +18 -0
  221. package/dist/management/capability-profile/index.d.ts.map +1 -0
  222. package/dist/management/capability-profile/index.js +167 -0
  223. package/dist/management/capability-profile/index.js.map +1 -0
  224. package/dist/management/config/index.d.ts +2 -0
  225. package/dist/management/config/index.d.ts.map +1 -0
  226. package/dist/management/config/index.js +2 -0
  227. package/dist/management/config/index.js.map +1 -0
  228. package/dist/management/diagnostics/index.d.ts +43 -0
  229. package/dist/management/diagnostics/index.d.ts.map +1 -0
  230. package/dist/management/diagnostics/index.js +586 -0
  231. package/dist/management/diagnostics/index.js.map +1 -0
  232. package/dist/management/reports/index.d.ts +21 -0
  233. package/dist/management/reports/index.d.ts.map +1 -0
  234. package/dist/management/reports/index.js +85 -0
  235. package/dist/management/reports/index.js.map +1 -0
  236. package/dist/management/skills/index.d.ts +2 -0
  237. package/dist/management/skills/index.d.ts.map +1 -0
  238. package/dist/management/skills/index.js +2 -0
  239. package/dist/management/skills/index.js.map +1 -0
  240. package/dist/management/smoke/index.d.ts +42 -0
  241. package/dist/management/smoke/index.d.ts.map +1 -0
  242. package/dist/management/smoke/index.js +226 -0
  243. package/dist/management/smoke/index.js.map +1 -0
  244. package/dist/registry/aliases.d.ts +2 -0
  245. package/dist/registry/aliases.d.ts.map +1 -0
  246. package/dist/registry/aliases.js +2 -0
  247. package/dist/registry/aliases.js.map +1 -0
  248. package/dist/registry/httpPolicies.d.ts +3 -0
  249. package/dist/registry/httpPolicies.d.ts.map +1 -0
  250. package/dist/registry/httpPolicies.js +17 -0
  251. package/dist/registry/httpPolicies.js.map +1 -0
  252. package/dist/registry/platformFactories.d.ts +8 -0
  253. package/dist/registry/platformFactories.d.ts.map +1 -0
  254. package/dist/registry/platformFactories.js +55 -0
  255. package/dist/registry/platformFactories.js.map +1 -0
  256. package/dist/registry/platformMetadata.d.ts +39 -0
  257. package/dist/registry/platformMetadata.d.ts.map +1 -0
  258. package/dist/registry/platformMetadata.js +321 -0
  259. package/dist/registry/platformMetadata.js.map +1 -0
  260. package/dist/services/CitationService.d.ts +2 -65
  261. package/dist/services/CitationService.d.ts.map +1 -1
  262. package/dist/services/CitationService.js +1 -242
  263. package/dist/services/CitationService.js.map +1 -1
  264. package/dist/services/JournalMetricsService.d.ts +2 -37
  265. package/dist/services/JournalMetricsService.d.ts.map +1 -1
  266. package/dist/services/JournalMetricsService.js +1 -141
  267. package/dist/services/JournalMetricsService.js.map +1 -1
  268. package/dist/services/MultiSourceSearchService.d.ts +2 -18
  269. package/dist/services/MultiSourceSearchService.d.ts.map +1 -1
  270. package/dist/services/MultiSourceSearchService.js +1 -77
  271. package/dist/services/MultiSourceSearchService.js.map +1 -1
  272. package/dist/services/OpenAccessFallbackService.d.ts +3 -40
  273. package/dist/services/OpenAccessFallbackService.d.ts.map +1 -1
  274. package/dist/services/OpenAccessFallbackService.js +1 -146
  275. package/dist/services/OpenAccessFallbackService.js.map +1 -1
  276. package/dist/utils/ErrorHandler.d.ts +2 -98
  277. package/dist/utils/ErrorHandler.d.ts.map +1 -1
  278. package/dist/utils/ErrorHandler.js +2 -265
  279. package/dist/utils/ErrorHandler.js.map +1 -1
  280. package/dist/utils/HttpClient.d.ts +1 -5
  281. package/dist/utils/HttpClient.d.ts.map +1 -1
  282. package/dist/utils/HttpClient.js +1 -29
  283. package/dist/utils/HttpClient.js.map +1 -1
  284. package/dist/utils/PDFExtractor.d.ts +2 -33
  285. package/dist/utils/PDFExtractor.d.ts.map +1 -1
  286. package/dist/utils/PDFExtractor.js +2 -129
  287. package/dist/utils/PDFExtractor.js.map +1 -1
  288. package/dist/utils/PdfDownload.d.ts +1 -6
  289. package/dist/utils/PdfDownload.d.ts.map +1 -1
  290. package/dist/utils/PdfDownload.js +1 -141
  291. package/dist/utils/PdfDownload.js.map +1 -1
  292. package/dist/utils/RateLimiter.d.ts +1 -49
  293. package/dist/utils/RateLimiter.d.ts.map +1 -1
  294. package/dist/utils/RateLimiter.js +1 -127
  295. package/dist/utils/RateLimiter.js.map +1 -1
  296. package/dist/utils/RequestCache.d.ts +2 -25
  297. package/dist/utils/RequestCache.d.ts.map +1 -1
  298. package/dist/utils/RequestCache.js +2 -65
  299. package/dist/utils/RequestCache.js.map +1 -1
  300. package/dist/utils/SecurityUtils.d.ts +2 -79
  301. package/dist/utils/SecurityUtils.d.ts.map +1 -1
  302. package/dist/utils/SecurityUtils.js +2 -356
  303. package/dist/utils/SecurityUtils.js.map +1 -1
  304. package/package.json +1 -1
@@ -0,0 +1,243 @@
1
+ import axios from 'axios';
2
+ import { RequestCache } from '../../utils/RequestCache.js';
3
+ import { RateLimiter } from '../../utils/RateLimiter.js';
4
+ import { ErrorHandler } from '../../utils/ErrorHandler.js';
5
+ import { TIMEOUTS, USER_AGENT } from '../../config/constants.js';
6
+ import { logDebug, logWarn } from '../../utils/Logger.js';
7
+ export class CitationService {
8
+ client;
9
+ cache;
10
+ rateLimiter;
11
+ apiKey;
12
+ constructor(apiKey) {
13
+ this.apiKey = apiKey || process.env.SEMANTIC_SCHOLAR_API_KEY;
14
+ this.client = axios.create({
15
+ baseURL: 'https://api.semanticscholar.org/graph/v1',
16
+ timeout: TIMEOUTS.DEFAULT,
17
+ headers: {
18
+ 'Accept': 'application/json',
19
+ 'User-Agent': USER_AGENT,
20
+ ...(this.apiKey ? { 'x-api-key': this.apiKey } : {})
21
+ }
22
+ });
23
+ // Semantic Scholar rate limits: 100 req/5min (free), 1000 req/5min (paid)
24
+ const requestsPerMinute = this.apiKey ? 180 : 18;
25
+ this.rateLimiter = new RateLimiter({
26
+ requestsPerSecond: requestsPerMinute / 60,
27
+ burstCapacity: Math.max(3, Math.floor(requestsPerMinute / 20))
28
+ });
29
+ this.cache = new RequestCache({
30
+ maxSize: 500,
31
+ ttlMs: 86400000 // 24 hours
32
+ });
33
+ }
34
+ /**
35
+ * Get citation data for a single paper by ID
36
+ */
37
+ async getCitationData(paperId, forceRefresh = false) {
38
+ try {
39
+ // Check cache first
40
+ if (!forceRefresh) {
41
+ const cacheKey = this.cache.generateKey('citation', paperId, {});
42
+ const cached = this.cache.get(cacheKey);
43
+ if (cached) {
44
+ return cached;
45
+ }
46
+ }
47
+ await this.rateLimiter.waitForPermission();
48
+ const fields = [
49
+ 'paperId',
50
+ 'title',
51
+ 'citationCount',
52
+ 'referenceCount',
53
+ 'influentialCitationCount',
54
+ 'year',
55
+ 'authors',
56
+ 'venue',
57
+ 'externalIds',
58
+ 'url'
59
+ ].join(',');
60
+ const response = await ErrorHandler.retryWithBackoff(() => this.client.get(`/paper/${paperId}`, {
61
+ params: { fields }
62
+ }), { context: 'Semantic Scholar citation lookup' });
63
+ if (response.status !== 200 || !response.data) {
64
+ return null;
65
+ }
66
+ const data = this.parseCitationData(response.data);
67
+ // Cache the result
68
+ const cacheKey = this.cache.generateKey('citation', paperId, {});
69
+ this.cache.set(cacheKey, data);
70
+ return data;
71
+ }
72
+ catch (error) {
73
+ logWarn(`Error fetching citation data for ${paperId}:`, error.message);
74
+ return null;
75
+ }
76
+ }
77
+ /**
78
+ * Get citation data by DOI
79
+ */
80
+ async getCitationDataByDoi(doi, forceRefresh = false) {
81
+ try {
82
+ const paperId = `DOI:${doi}`;
83
+ return await this.getCitationData(paperId, forceRefresh);
84
+ }
85
+ catch (error) {
86
+ logWarn(`Error fetching citation data by DOI ${doi}:`, error.message);
87
+ return null;
88
+ }
89
+ }
90
+ /**
91
+ * Get citation data by arXiv ID
92
+ */
93
+ async getCitationDataByArxiv(arxivId, forceRefresh = false) {
94
+ try {
95
+ const paperId = `ARXIV:${arxivId}`;
96
+ return await this.getCitationData(paperId, forceRefresh);
97
+ }
98
+ catch (error) {
99
+ logWarn(`Error fetching citation data by arXiv ID ${arxivId}:`, error.message);
100
+ return null;
101
+ }
102
+ }
103
+ /**
104
+ * Batch lookup citations for multiple papers
105
+ */
106
+ async batchLookup(requests) {
107
+ const results = new Map();
108
+ for (const request of requests) {
109
+ let paperId = null;
110
+ let key;
111
+ if (request.paperId) {
112
+ paperId = request.paperId;
113
+ key = request.paperId;
114
+ }
115
+ else if (request.doi) {
116
+ paperId = `DOI:${request.doi}`;
117
+ key = request.doi;
118
+ }
119
+ else if (request.arxivId) {
120
+ paperId = `ARXIV:${request.arxivId}`;
121
+ key = request.arxivId;
122
+ }
123
+ else if (request.title) {
124
+ key = request.title;
125
+ // Search by title (not implemented in this version)
126
+ results.set(key, null);
127
+ continue;
128
+ }
129
+ else {
130
+ continue;
131
+ }
132
+ try {
133
+ const data = await this.getCitationData(paperId);
134
+ results.set(key, data);
135
+ }
136
+ catch (error) {
137
+ logDebug(`Error in batch lookup for ${key}:`, error);
138
+ results.set(key, null);
139
+ }
140
+ }
141
+ return results;
142
+ }
143
+ /**
144
+ * Get references for a paper
145
+ */
146
+ async getReferences(paperId, limit = 100) {
147
+ try {
148
+ await this.rateLimiter.waitForPermission();
149
+ const fields = [
150
+ 'paperId',
151
+ 'title',
152
+ 'citationCount',
153
+ 'referenceCount',
154
+ 'year',
155
+ 'authors',
156
+ 'venue',
157
+ 'externalIds',
158
+ 'url'
159
+ ].join(',');
160
+ const response = await ErrorHandler.retryWithBackoff(() => this.client.get(`/paper/${paperId}/references`, {
161
+ params: { fields, limit }
162
+ }), { context: 'Semantic Scholar references lookup' });
163
+ if (response.status !== 200 || !response.data?.data) {
164
+ return [];
165
+ }
166
+ return response.data.data
167
+ .map((item) => item.citedPaper)
168
+ .filter((paper) => paper)
169
+ .map((paper) => this.parseCitationData(paper));
170
+ }
171
+ catch (error) {
172
+ logWarn(`Error fetching references for ${paperId}:`, error.message);
173
+ return [];
174
+ }
175
+ }
176
+ /**
177
+ * Get citations for a paper
178
+ */
179
+ async getCitations(paperId, limit = 100) {
180
+ try {
181
+ await this.rateLimiter.waitForPermission();
182
+ const fields = [
183
+ 'paperId',
184
+ 'title',
185
+ 'citationCount',
186
+ 'referenceCount',
187
+ 'year',
188
+ 'authors',
189
+ 'venue',
190
+ 'externalIds',
191
+ 'url'
192
+ ].join(',');
193
+ const response = await ErrorHandler.retryWithBackoff(() => this.client.get(`/paper/${paperId}/citations`, {
194
+ params: { fields, limit }
195
+ }), { context: 'Semantic Scholar citations lookup' });
196
+ if (response.status !== 200 || !response.data?.data) {
197
+ return [];
198
+ }
199
+ return response.data.data
200
+ .map((item) => item.citingPaper)
201
+ .filter((paper) => paper)
202
+ .map((paper) => this.parseCitationData(paper));
203
+ }
204
+ catch (error) {
205
+ logWarn(`Error fetching citations for ${paperId}:`, error.message);
206
+ return [];
207
+ }
208
+ }
209
+ /**
210
+ * Parse Semantic Scholar response to CitationData
211
+ */
212
+ parseCitationData(data) {
213
+ return {
214
+ paperId: data.paperId,
215
+ title: data.title,
216
+ citationCount: data.citationCount || 0,
217
+ referenceCount: data.referenceCount || 0,
218
+ influentialCitationCount: data.influentialCitationCount,
219
+ year: data.year,
220
+ authors: data.authors?.map((author) => ({
221
+ name: author.name,
222
+ authorId: author.authorId
223
+ })),
224
+ venue: data.venue,
225
+ doi: data.externalIds?.DOI,
226
+ url: data.url
227
+ };
228
+ }
229
+ /**
230
+ * Get cache statistics
231
+ */
232
+ getCacheStats() {
233
+ return this.cache.getStats();
234
+ }
235
+ /**
236
+ * Clear cache
237
+ */
238
+ clearCache() {
239
+ this.cache.clear();
240
+ }
241
+ }
242
+ export default CitationService;
243
+ //# sourceMappingURL=CitationService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CitationService.js","sourceRoot":"","sources":["../../../src/capabilities/citation-expansion/CitationService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAK1D,MAAM,OAAO,eAAe;IAClB,M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,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF;AAED,eAAe,eAAe,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { CitationData } from './types.js';
2
+ export declare function resolveCitationTarget(args: {
3
+ paperId?: string;
4
+ doi?: string;
5
+ arxivId?: string;
6
+ }): string;
7
+ export declare function citationResponse(target: string, relation: 'citations' | 'references', papers: CitationData[]): {
8
+ target: string;
9
+ relation: "references" | "citations";
10
+ provider: string;
11
+ total: number;
12
+ papers: CitationData[];
13
+ };
14
+ export declare function handleGetPaperCitations(args: {
15
+ paperId?: string;
16
+ doi?: string;
17
+ arxivId?: string;
18
+ limit?: number;
19
+ }): Promise<{
20
+ content: {
21
+ type: "text";
22
+ text: string;
23
+ }[];
24
+ }>;
25
+ export declare function handleGetPaperReferences(args: {
26
+ paperId?: string;
27
+ doi?: string;
28
+ arxivId?: string;
29
+ limit?: number;
30
+ }): Promise<{
31
+ content: {
32
+ type: "text";
33
+ text: string;
34
+ }[];
35
+ }>;
36
+ //# sourceMappingURL=handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/capabilities/citation-expansion/handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAa/C,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAKxG;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,GAAG,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE;;;;;;EAQ5G;AAED,wBAAsB,uBAAuB,CAAC,IAAI,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;GAMvH;AAED,wBAAsB,wBAAwB,CAAC,IAAI,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;GAMxH"}
@@ -0,0 +1,44 @@
1
+ import CitationService from './CitationService.js';
2
+ function jsonTextResponse(text) {
3
+ return {
4
+ content: [
5
+ {
6
+ type: 'text',
7
+ text
8
+ }
9
+ ]
10
+ };
11
+ }
12
+ export function resolveCitationTarget(args) {
13
+ if (args.paperId)
14
+ return args.paperId;
15
+ if (args.doi)
16
+ return `DOI:${args.doi}`;
17
+ if (args.arxivId)
18
+ return `ARXIV:${args.arxivId}`;
19
+ throw new Error('Provide paperId, doi, or arxivId');
20
+ }
21
+ export function citationResponse(target, relation, papers) {
22
+ return {
23
+ target,
24
+ relation,
25
+ provider: 'semantic_scholar',
26
+ total: papers.length,
27
+ papers
28
+ };
29
+ }
30
+ export async function handleGetPaperCitations(args) {
31
+ const target = resolveCitationTarget(args);
32
+ const service = new CitationService();
33
+ const papers = await service.getCitations(target, args.limit);
34
+ const result = citationResponse(target, 'citations', papers);
35
+ return jsonTextResponse(`Found ${papers.length} citing paper(s).\n\n${JSON.stringify(result, null, 2)}`);
36
+ }
37
+ export async function handleGetPaperReferences(args) {
38
+ const target = resolveCitationTarget(args);
39
+ const service = new CitationService();
40
+ const papers = await service.getReferences(target, args.limit);
41
+ const result = citationResponse(target, 'references', papers);
42
+ return jsonTextResponse(`Found ${papers.length} cited reference(s).\n\n${JSON.stringify(result, null, 2)}`);
43
+ }
44
+ //# sourceMappingURL=handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/capabilities/citation-expansion/handler.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAGnD,SAAS,gBAAgB,CAAC,IAAY;IACpC,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI;aACL;SACF;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAA0D;IAC9F,IAAI,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC;IACtC,IAAI,IAAI,CAAC,GAAG;QAAE,OAAO,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;IACvC,IAAI,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,IAAI,CAAC,OAAO,EAAE,CAAC;IACjD,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAc,EAAE,QAAoC,EAAE,MAAsB;IAC3G,OAAO;QACL,MAAM;QACN,QAAQ;QACR,QAAQ,EAAE,kBAAkB;QAC5B,KAAK,EAAE,MAAM,CAAC,MAAM;QACpB,MAAM;KACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,IAA0E;IACtH,MAAM,MAAM,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAG,IAAI,eAAe,EAAE,CAAC;IACtC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IAC7D,OAAO,gBAAgB,CAAC,SAAS,MAAM,CAAC,MAAM,wBAAwB,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AAC3G,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,IAA0E;IACvH,MAAM,MAAM,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAG,IAAI,eAAe,EAAE,CAAC;IACtC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;IAC9D,OAAO,gBAAgB,CAAC,SAAS,MAAM,CAAC,MAAM,2BAA2B,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AAC9G,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { CitationService, default } from './CitationService.js';
2
+ export { citationResponse, handleGetPaperCitations, handleGetPaperReferences, resolveCitationTarget } from './handler.js';
3
+ export { CitationLookupSchema } from './schemas.js';
4
+ export { CITATION_EXPANSION_TOOLS, GET_PAPER_CITATIONS_TOOL, GET_PAPER_REFERENCES_TOOL } from './tools.js';
5
+ export type { BatchCitationRequest, CitationData } from './types.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/capabilities/citation-expansion/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { CitationService, default } from './CitationService.js';
2
+ export { citationResponse, handleGetPaperCitations, handleGetPaperReferences, resolveCitationTarget } from './handler.js';
3
+ export { CitationLookupSchema } from './schemas.js';
4
+ export { CITATION_EXPANSION_TOOLS, GET_PAPER_CITATIONS_TOOL, GET_PAPER_REFERENCES_TOOL } from './tools.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/capabilities/citation-expansion/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,YAAY,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ export declare const CitationLookupSchema: z.ZodEffects<z.ZodObject<{
3
+ paperId: z.ZodOptional<z.ZodString>;
4
+ doi: z.ZodOptional<z.ZodString>;
5
+ arxivId: z.ZodOptional<z.ZodString>;
6
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ limit: number;
9
+ paperId?: string | undefined;
10
+ doi?: string | undefined;
11
+ arxivId?: string | undefined;
12
+ }, {
13
+ paperId?: string | undefined;
14
+ doi?: string | undefined;
15
+ arxivId?: string | undefined;
16
+ limit?: number | undefined;
17
+ }>, {
18
+ limit: number;
19
+ paperId?: string | undefined;
20
+ doi?: string | undefined;
21
+ arxivId?: string | undefined;
22
+ }, {
23
+ paperId?: string | undefined;
24
+ doi?: string | undefined;
25
+ arxivId?: string | undefined;
26
+ limit?: number | undefined;
27
+ }>;
28
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/capabilities/citation-expansion/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;EAU7B,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ export const CitationLookupSchema = z
3
+ .object({
4
+ paperId: z.coerce.string().min(1).optional(),
5
+ doi: z.coerce.string().min(1).optional(),
6
+ arxivId: z.coerce.string().min(1).optional(),
7
+ limit: z.number().int().min(1).max(100).optional().default(100)
8
+ })
9
+ .strip()
10
+ .refine(value => Boolean(value.paperId || value.doi || value.arxivId), {
11
+ message: 'Provide paperId, doi, or arxivId'
12
+ });
13
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/capabilities/citation-expansion/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC;KAClC,MAAM,CAAC;IACN,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC5C,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACxC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC5C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;CAChE,CAAC;KACD,KAAK,EAAE;KACP,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE;IACrE,OAAO,EAAE,kCAAkC;CAC5C,CAAC,CAAC"}
@@ -0,0 +1,82 @@
1
+ export declare const GET_PAPER_CITATIONS_TOOL: {
2
+ name: string;
3
+ description: string;
4
+ inputSchema: {
5
+ type: string;
6
+ properties: {
7
+ limit: {
8
+ type: string;
9
+ minimum: number;
10
+ maximum: number;
11
+ description: string;
12
+ };
13
+ paperId: {
14
+ type: string;
15
+ description: string;
16
+ };
17
+ doi: {
18
+ type: string;
19
+ description: string;
20
+ };
21
+ arxivId: {
22
+ type: string;
23
+ description: string;
24
+ };
25
+ };
26
+ };
27
+ };
28
+ export declare const GET_PAPER_REFERENCES_TOOL: {
29
+ name: string;
30
+ description: string;
31
+ inputSchema: {
32
+ type: string;
33
+ properties: {
34
+ limit: {
35
+ type: string;
36
+ minimum: number;
37
+ maximum: number;
38
+ description: string;
39
+ };
40
+ paperId: {
41
+ type: string;
42
+ description: string;
43
+ };
44
+ doi: {
45
+ type: string;
46
+ description: string;
47
+ };
48
+ arxivId: {
49
+ type: string;
50
+ description: string;
51
+ };
52
+ };
53
+ };
54
+ };
55
+ export declare const CITATION_EXPANSION_TOOLS: {
56
+ name: string;
57
+ description: string;
58
+ inputSchema: {
59
+ type: string;
60
+ properties: {
61
+ limit: {
62
+ type: string;
63
+ minimum: number;
64
+ maximum: number;
65
+ description: string;
66
+ };
67
+ paperId: {
68
+ type: string;
69
+ description: string;
70
+ };
71
+ doi: {
72
+ type: string;
73
+ description: string;
74
+ };
75
+ arxivId: {
76
+ type: string;
77
+ description: string;
78
+ };
79
+ };
80
+ };
81
+ }[];
82
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/capabilities/citation-expansion/tools.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;CAgBpC,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;CAgBrC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;GAAwD,CAAC"}
@@ -0,0 +1,48 @@
1
+ const CITATION_LOOKUP_PROPERTIES = {
2
+ paperId: {
3
+ type: 'string',
4
+ description: 'Semantic Scholar paper id or external id such as DOI:10.xxxx/xxxxx'
5
+ },
6
+ doi: {
7
+ type: 'string',
8
+ description: 'DOI for the target paper; converted to DOI:<doi>'
9
+ },
10
+ arxivId: {
11
+ type: 'string',
12
+ description: 'arXiv id for the target paper; converted to ARXIV:<id>'
13
+ }
14
+ };
15
+ export const GET_PAPER_CITATIONS_TOOL = {
16
+ name: 'get_paper_citations',
17
+ description: 'Get citing papers for a target paper using Semantic Scholar Graph API. Provide one of paperId, doi, or arxivId.',
18
+ inputSchema: {
19
+ type: 'object',
20
+ properties: {
21
+ ...CITATION_LOOKUP_PROPERTIES,
22
+ limit: {
23
+ type: 'number',
24
+ minimum: 1,
25
+ maximum: 100,
26
+ description: 'Maximum number of citing papers to return. Default: 100'
27
+ }
28
+ }
29
+ }
30
+ };
31
+ export const GET_PAPER_REFERENCES_TOOL = {
32
+ name: 'get_paper_references',
33
+ description: 'Get cited references for a target paper using Semantic Scholar Graph API. Provide one of paperId, doi, or arxivId.',
34
+ inputSchema: {
35
+ type: 'object',
36
+ properties: {
37
+ ...CITATION_LOOKUP_PROPERTIES,
38
+ limit: {
39
+ type: 'number',
40
+ minimum: 1,
41
+ maximum: 100,
42
+ description: 'Maximum number of cited references to return. Default: 100'
43
+ }
44
+ }
45
+ }
46
+ };
47
+ export const CITATION_EXPANSION_TOOLS = [GET_PAPER_CITATIONS_TOOL, GET_PAPER_REFERENCES_TOOL];
48
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/capabilities/citation-expansion/tools.ts"],"names":[],"mappings":"AAAA,MAAM,0BAA0B,GAAG;IACjC,OAAO,EAAE;QACP,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,oEAAoE;KAClF;IACD,GAAG,EAAE;QACH,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,kDAAkD;KAChE;IACD,OAAO,EAAE;QACP,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,wDAAwD;KACtE;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EACT,iHAAiH;IACnH,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,GAAG,0BAA0B;YAC7B,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,GAAG;gBACZ,WAAW,EAAE,yDAAyD;aACvE;SACF;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EACT,oHAAoH;IACtH,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,GAAG,0BAA0B;YAC7B,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,GAAG;gBACZ,WAAW,EAAE,4DAA4D;aAC1E;SACF;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,wBAAwB,EAAE,yBAAyB,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ export interface CitationData {
2
+ paperId: string;
3
+ title: string;
4
+ citationCount: number;
5
+ referenceCount: number;
6
+ influentialCitationCount?: number;
7
+ year?: number;
8
+ authors?: Array<{
9
+ name: string;
10
+ authorId?: string;
11
+ }>;
12
+ venue?: string;
13
+ doi?: string;
14
+ url?: string;
15
+ }
16
+ export interface BatchCitationRequest {
17
+ paperId?: string;
18
+ doi?: string;
19
+ arxivId?: string;
20
+ title?: string;
21
+ }
22
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/capabilities/citation-expansion/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/capabilities/citation-expansion/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import type { JournalMetricsRow, QueryJournalMetricsOptions } from './types.js';
2
+ export declare function queryJournalMetrics(options: QueryJournalMetricsOptions): Promise<JournalMetricsRow[]>;
3
+ //# sourceMappingURL=JournalMetricsService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JournalMetricsService.d.ts","sourceRoot":"","sources":["../../../src/capabilities/journal-metrics/JournalMetricsService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AA0IhF,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAuC3G"}