mcp-scraper 0.42.3 → 0.43.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 (64) hide show
  1. package/README.md +2 -2
  2. package/dist/bin/api-server.cjs +3284 -2130
  3. package/dist/bin/api-server.cjs.map +1 -1
  4. package/dist/bin/api-server.js +2 -2
  5. package/dist/bin/mcp-scraper-cli.cjs +1 -1
  6. package/dist/bin/mcp-scraper-cli.cjs.map +1 -1
  7. package/dist/bin/mcp-scraper-cli.js +3 -4
  8. package/dist/bin/mcp-scraper-cli.js.map +1 -1
  9. package/dist/bin/mcp-scraper-install.cjs +2 -2
  10. package/dist/bin/mcp-scraper-install.cjs.map +1 -1
  11. package/dist/bin/mcp-scraper-install.js +2 -2
  12. package/dist/bin/mcp-stdio-server.cjs +3361 -2817
  13. package/dist/bin/mcp-stdio-server.cjs.map +1 -1
  14. package/dist/bin/mcp-stdio-server.js +51 -24
  15. package/dist/bin/mcp-stdio-server.js.map +1 -1
  16. package/dist/bin/paa-harvest.cjs +21 -21
  17. package/dist/bin/paa-harvest.cjs.map +1 -1
  18. package/dist/bin/paa-harvest.js +2 -3
  19. package/dist/bin/paa-harvest.js.map +1 -1
  20. package/dist/{chunk-MJKVDLVR.js → chunk-2K74LVV7.js} +26 -2
  21. package/dist/{chunk-MJKVDLVR.js.map → chunk-2K74LVV7.js.map} +1 -1
  22. package/dist/{chunk-CB5C3BPB.js → chunk-3ZUBQQPQ.js} +23 -2
  23. package/dist/chunk-3ZUBQQPQ.js.map +1 -0
  24. package/dist/{chunk-6Q7V4IQV.js → chunk-6WLNXYRG.js} +19 -2
  25. package/dist/chunk-6WLNXYRG.js.map +1 -0
  26. package/dist/{chunk-G5MHJGKE.js → chunk-GUI33Q27.js} +2 -2
  27. package/dist/{chunk-DH42LIR3.js → chunk-H7LQ6PTI.js} +24 -16
  28. package/dist/chunk-H7LQ6PTI.js.map +1 -0
  29. package/dist/chunk-MD75M2L5.js +7 -0
  30. package/dist/chunk-MD75M2L5.js.map +1 -0
  31. package/dist/{chunk-ENJQ2NSX.js → chunk-TC4GDB2Q.js} +2 -2
  32. package/dist/{chunk-ENJQ2NSX.js.map → chunk-TC4GDB2Q.js.map} +1 -1
  33. package/dist/{chunk-IMUA3FJB.js → chunk-X5WDJ7D7.js} +6 -6
  34. package/dist/chunk-X5WDJ7D7.js.map +1 -0
  35. package/dist/{chunk-QKCDYMFT.js → chunk-YJNGNMDO.js} +2196 -1584
  36. package/dist/chunk-YJNGNMDO.js.map +1 -0
  37. package/dist/{chunk-FQI5PFE7.js → chunk-ZSJHRZY5.js} +3 -5
  38. package/dist/{chunk-FQI5PFE7.js.map → chunk-ZSJHRZY5.js.map} +1 -1
  39. package/dist/{extract-bundle-FH734F3R.js → extract-bundle-IOM45SFL.js} +5 -5
  40. package/dist/index.cjs +21 -21
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.cts +21 -57
  43. package/dist/index.d.ts +21 -57
  44. package/dist/index.js +2 -3
  45. package/dist/index.js.map +1 -1
  46. package/dist/{server-B27DR4YB.js → server-BPEXEKA6.js} +800 -336
  47. package/dist/server-BPEXEKA6.js.map +1 -0
  48. package/dist/{site-extract-repository-5CVI3OWT.js → site-extract-repository-XNI4ZK2M.js} +3 -3
  49. package/dist/{worker-MQJOY4YP.js → worker-2LIOH744.js} +4 -5
  50. package/dist/{worker-MQJOY4YP.js.map → worker-2LIOH744.js.map} +1 -1
  51. package/package.json +10 -7
  52. package/dist/chunk-2YFTFT3V.js +0 -7
  53. package/dist/chunk-2YFTFT3V.js.map +0 -1
  54. package/dist/chunk-6Q7V4IQV.js.map +0 -1
  55. package/dist/chunk-CB5C3BPB.js.map +0 -1
  56. package/dist/chunk-DH42LIR3.js.map +0 -1
  57. package/dist/chunk-IMUA3FJB.js.map +0 -1
  58. package/dist/chunk-K443GQY5.js +0 -24
  59. package/dist/chunk-K443GQY5.js.map +0 -1
  60. package/dist/chunk-QKCDYMFT.js.map +0 -1
  61. package/dist/server-B27DR4YB.js.map +0 -1
  62. /package/dist/{chunk-G5MHJGKE.js.map → chunk-GUI33Q27.js.map} +0 -0
  63. /package/dist/{extract-bundle-FH734F3R.js.map → extract-bundle-IOM45SFL.js.map} +0 -0
  64. /package/dist/{site-extract-repository-5CVI3OWT.js.map → site-extract-repository-XNI4ZK2M.js.map} +0 -0
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  createSiteExtractBundleArtifactStream,
3
3
  downloadAsset
4
- } from "./chunk-6Q7V4IQV.js";
4
+ } from "./chunk-6WLNXYRG.js";
5
5
  import {
6
6
  computeIssues,
7
7
  renderImageSection,
8
8
  renderIssueReport,
9
9
  renderLinkReport
10
- } from "./chunk-MJKVDLVR.js";
10
+ } from "./chunk-2K74LVV7.js";
11
11
  import {
12
12
  extractJobLimitInfo
13
- } from "./chunk-G5MHJGKE.js";
14
- import "./chunk-IMUA3FJB.js";
13
+ } from "./chunk-GUI33Q27.js";
14
+ import "./chunk-X5WDJ7D7.js";
15
15
  import "./chunk-5UN33CGU.js";
16
16
  import {
17
17
  getDb
@@ -565,4 +565,4 @@ export {
565
565
  SITE_EXTRACT_PAGE_CHUNK,
566
566
  assembleExtractArtifacts
567
567
  };
568
- //# sourceMappingURL=extract-bundle-FH734F3R.js.map
568
+ //# sourceMappingURL=extract-bundle-IOM45SFL.js.map
package/dist/index.cjs CHANGED
@@ -601,11 +601,21 @@ async function ensureKernelProfile(kernelClient, name) {
601
601
  if (!isKernelProfileConflict(err)) throw err;
602
602
  }
603
603
  }
604
- function rankCheckContextOptions(config) {
604
+ async function detectRuntimeUserAgent(browser) {
605
+ try {
606
+ const page = browser.contexts()[0]?.pages()[0];
607
+ if (!page) return null;
608
+ const ua = await page.evaluate(() => navigator.userAgent);
609
+ return typeof ua === "string" && /Chrome\/\d+/.test(ua) ? ua : null;
610
+ } catch {
611
+ return null;
612
+ }
613
+ }
614
+ function rankCheckContextOptions(config, runtimeUserAgent) {
605
615
  return {
606
616
  viewport: config.viewport,
607
617
  locale: config.locale,
608
- userAgent: config.userAgent ?? (config.isMobile ? MOBILE_USER_AGENT : DESKTOP_USER_AGENT),
618
+ userAgent: config.userAgent ?? (config.isMobile ? MOBILE_USER_AGENT : runtimeUserAgent ?? DESKTOP_USER_AGENT),
609
619
  ...config.deviceScaleFactor ? { deviceScaleFactor: config.deviceScaleFactor } : {},
610
620
  ...config.isMobile !== void 0 ? { isMobile: config.isMobile } : {},
611
621
  ...config.hasTouch !== void 0 ? { hasTouch: config.hasTouch } : {}
@@ -702,7 +712,7 @@ var BrowserDriver = class {
702
712
  this.kernelHeadlessSent = useHeadless ? true : null;
703
713
  if (costCtx?.headlessSentOut) costCtx.headlessSentOut.value = this.kernelHeadlessSent;
704
714
  const kernelBrowser = await this.kernelClient.browsers.create({
705
- stealth: true,
715
+ stealth: config.kernelStealth === true,
706
716
  timeout_seconds: timeoutSeconds,
707
717
  ...useHeadless ? { headless: true } : {},
708
718
  ...config.kernelProxyId ? { proxy_id: config.kernelProxyId } : {},
@@ -767,7 +777,9 @@ var BrowserDriver = class {
767
777
  await this.populateKernelRetrieveDebug(kernelDebug, config.kernelProxyId);
768
778
  }
769
779
  this.browser = await import_playwright.chromium.connectOverCDP(kernelBrowser.cdp_ws_url);
770
- this.context = await this.browser.newContext(rankCheckContextOptions(config));
780
+ const runtimeUserAgent = await detectRuntimeUserAgent(this.browser);
781
+ this.debugSnapshot.context.userAgent = config.userAgent ?? (config.isMobile ? MOBILE_USER_AGENT : runtimeUserAgent ?? DESKTOP_USER_AGENT);
782
+ this.context = await this.browser.newContext(rankCheckContextOptions(config, runtimeUserAgent));
771
783
  await this.installEsbuildHelperShims(this.context);
772
784
  this.page = await this.context.newPage();
773
785
  await this.page.setViewportSize(config.viewport);
@@ -2900,7 +2912,6 @@ var import_sdk2 = __toESM(require("@onkernel/sdk"), 1);
2900
2912
  var BACKUP_PROXY_HOST = "pr.oxylabs.io";
2901
2913
  var BACKUP_PROXY_PORT = 7777;
2902
2914
  var BACKUP_STICKY_SESSION_MINUTES = 10;
2903
- var BACKUP_LAST_RESORT_ATTEMPTS = 2;
2904
2915
  function backupProxyUsername() {
2905
2916
  const value = process.env.OXYLABS_USERNAME?.trim();
2906
2917
  return value || void 0;
@@ -3254,15 +3265,6 @@ async function settleCreateExhaustion(options, target, createErrors) {
3254
3265
  }
3255
3266
  return resolution("configured_fallback", options.proxyMode, options.configuredKernelProxyId, target, createErrors.join(" | "));
3256
3267
  }
3257
- async function resolveBackupKernelProxyId(options) {
3258
- if (!options.kernelApiKey || !backupProxyAvailable()) return null;
3259
- try {
3260
- const backupId = await createBackupProxyId(options.kernelApiKey, { attemptIndex: options.attemptIndex });
3261
- return resolution("backup_custom", options.proxyMode, backupId, null, null, true);
3262
- } catch {
3263
- return null;
3264
- }
3265
- }
3266
3268
  async function createFreshLocationProxy(kernel, options, target) {
3267
3269
  const createErrors = [];
3268
3270
  for (const candidate of freshTargetCandidates(target, options.proxyZip, options.attemptIndex)) {
@@ -3622,7 +3624,7 @@ async function harvest(rawOptions) {
3622
3624
  const needsLocationEvidence = proxyMode === "location" && Boolean(proxyOpts.location);
3623
3625
  const requestedMaxAttempts = raw.maxAttempts;
3624
3626
  const baseMaxAttempts = typeof requestedMaxAttempts === "number" && Number.isInteger(requestedMaxAttempts) && requestedMaxAttempts >= 1 ? requestedMaxAttempts : maxAttemptsForProxyMode(proxyMode) + 1;
3625
- const maxAttempts = baseMaxAttempts + (backupProxyAvailable() ? BACKUP_LAST_RESORT_ATTEMPTS : 0);
3627
+ const maxAttempts = baseMaxAttempts;
3626
3628
  const softDeadlineMs = typeof raw.softDeadlineMs === "number" ? raw.softDeadlineMs : null;
3627
3629
  const serializer = new OutputSerializer();
3628
3630
  let lastError = null;
@@ -3633,14 +3635,11 @@ async function harvest(rawOptions) {
3633
3635
  const startedAtMs = Date.now();
3634
3636
  try {
3635
3637
  if (signal?.aborted) throw abortReason(signal);
3636
- const isBackupAttempt = i >= baseMaxAttempts;
3637
- if (isBackupAttempt && softDeadlineMs !== null && Date.now() >= softDeadlineMs) break;
3638
- const resolution2 = isBackupAttempt ? await resolveBackupKernelProxyId({ kernelApiKey, proxyMode: effectiveProxyMode, attemptIndex: i }) : await resolveKernelProxyId({
3638
+ const resolution2 = await resolveKernelProxyId({
3639
3639
  ...proxyOpts,
3640
3640
  proxyMode: effectiveProxyMode,
3641
3641
  attemptIndex: i,
3642
- fresh: effectiveProxyMode === "location",
3643
- backupOnExhaustion: true
3642
+ fresh: effectiveProxyMode === "location"
3644
3643
  });
3645
3644
  if (!resolution2) break;
3646
3645
  const mergedAttempt = {
@@ -3649,9 +3648,10 @@ async function harvest(rawOptions) {
3649
3648
  kernelProxyId: resolution2.kernelProxyId,
3650
3649
  kernelProxyResolution: resolution2.resolution,
3651
3650
  proxyMode: effectiveProxyMode,
3651
+ keepDefaultProxy: i > 0,
3652
3652
  debug: requestedDebug || needsLocationEvidence
3653
3653
  };
3654
- if (effectiveProxyMode === "none" && !isBackupAttempt) mergedAttempt.kernelProxyId = void 0;
3654
+ if (effectiveProxyMode === "none") mergedAttempt.kernelProxyId = void 0;
3655
3655
  const attemptOptions = HarvestOptionsSchema.parse(mergedAttempt);
3656
3656
  await emitAttemptEvent(onAttemptEvent, {
3657
3657
  type: "started",